- Add job submission form section above job listings table - Display form using Formidable shortcode with graceful fallback - Add visual separation styling for form section (gray background, padding, border-radius) - Wrap job listings in separate section for better organization Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
269 lines
5.5 KiB
PHP
269 lines
5.5 KiB
PHP
<?php
|
|
/**
|
|
* Provider Dashboard Template
|
|
*
|
|
* Displays the current provider's job listings in a table format
|
|
*
|
|
* @package DDHH_Job_Manager
|
|
*/
|
|
|
|
// Exit if accessed directly.
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
// Check if user is logged in and has the ddhh_provider role
|
|
if ( ! is_user_logged_in() ) {
|
|
echo '<div class="ddhh-error-message">';
|
|
echo '<p>Sie müssen angemeldet sein, um diese Seite anzuzeigen.</p>';
|
|
echo '</div>';
|
|
return;
|
|
}
|
|
|
|
$current_user = wp_get_current_user();
|
|
if ( ! in_array( 'ddhh_provider', $current_user->roles, true ) ) {
|
|
echo '<div class="ddhh-error-message">';
|
|
echo '<p>Sie haben keine Berechtigung, diese Seite anzuzeigen.</p>';
|
|
echo '</div>';
|
|
return;
|
|
}
|
|
|
|
// Query current user's job_offer posts
|
|
$args = array(
|
|
'post_type' => 'job_offer',
|
|
'author' => get_current_user_id(),
|
|
'post_status' => array( 'publish', 'pending', 'draft' ),
|
|
'orderby' => 'date',
|
|
'order' => 'DESC',
|
|
'posts_per_page' => -1,
|
|
);
|
|
|
|
$job_query = new WP_Query( $args );
|
|
?>
|
|
|
|
<div class="ddhh-provider-dashboard">
|
|
<div class="ddhh-job-submit-section">
|
|
<h2>Neues Stellenangebot erstellen</h2>
|
|
<?php
|
|
$form_id = DDHH_JM_Formidable::get_job_submission_form_id();
|
|
if ( $form_id ) {
|
|
echo do_shortcode( "[formidable id={$form_id}]" );
|
|
} else {
|
|
echo '<p>Formular konnte nicht geladen werden.</p>';
|
|
}
|
|
?>
|
|
</div>
|
|
|
|
<div class="ddhh-job-listings-section">
|
|
<h2>Meine Stellenangebote</h2>
|
|
|
|
<?php if ( $job_query->have_posts() ) : ?>
|
|
<table class="ddhh-jobs-table">
|
|
<thead>
|
|
<tr>
|
|
<th>Titel</th>
|
|
<th>Status</th>
|
|
<th>Standort</th>
|
|
<th>Art</th>
|
|
<th>Aktionen</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php while ( $job_query->have_posts() ) : $job_query->the_post(); ?>
|
|
<?php
|
|
$post_id = get_the_ID();
|
|
$post_status = get_post_status();
|
|
$location = get_field( 'job_location', $post_id );
|
|
$job_type = get_field( 'job_type', $post_id );
|
|
|
|
// Translate status to German
|
|
$status_labels = array(
|
|
'publish' => 'Veröffentlicht',
|
|
'pending' => 'Ausstehend',
|
|
'draft' => 'Entwurf',
|
|
);
|
|
$status_text = isset( $status_labels[ $post_status ] ) ? $status_labels[ $post_status ] : $post_status;
|
|
?>
|
|
<tr>
|
|
<td class="job-title"><?php the_title(); ?></td>
|
|
<td class="job-status">
|
|
<span class="status-badge status-<?php echo esc_attr( $post_status ); ?>">
|
|
<?php echo esc_html( $status_text ); ?>
|
|
</span>
|
|
</td>
|
|
<td class="job-location"><?php echo esc_html( $location ? $location : '-' ); ?></td>
|
|
<td class="job-type"><?php echo esc_html( $job_type ? $job_type : '-' ); ?></td>
|
|
<td class="job-actions">
|
|
<?php
|
|
// Edit link - uses WordPress capabilities to determine if user can edit
|
|
if ( current_user_can( 'edit_job_offer', $post_id ) ) {
|
|
edit_post_link( 'Bearbeiten', '', '', $post_id, 'button edit-link' );
|
|
}
|
|
|
|
// View link - only for published posts
|
|
if ( 'publish' === $post_status ) {
|
|
echo ' <a href="' . esc_url( get_permalink( $post_id ) ) . '" class="button view-link" target="_blank">Ansehen</a>';
|
|
}
|
|
?>
|
|
</td>
|
|
</tr>
|
|
<?php endwhile; ?>
|
|
</tbody>
|
|
</table>
|
|
<?php else : ?>
|
|
<div class="ddhh-empty-state">
|
|
<p>Sie haben noch keine Stellenangebote erstellt.</p>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php wp_reset_postdata(); ?>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
.ddhh-provider-dashboard {
|
|
max-width: 1200px;
|
|
margin: 2rem auto;
|
|
padding: 0 1rem;
|
|
}
|
|
|
|
.ddhh-job-submit-section {
|
|
margin-bottom: 3rem;
|
|
padding: 2rem;
|
|
background: #f5f5f5;
|
|
border-radius: 8px;
|
|
}
|
|
|
|
.ddhh-job-submit-section h2 {
|
|
margin-top: 0;
|
|
margin-bottom: 1.5rem;
|
|
font-size: 1.5rem;
|
|
color: #333;
|
|
}
|
|
|
|
.ddhh-job-listings-section {
|
|
margin-top: 3rem;
|
|
}
|
|
|
|
.ddhh-provider-dashboard h2 {
|
|
margin-bottom: 1.5rem;
|
|
font-size: 2rem;
|
|
color: #333;
|
|
}
|
|
|
|
.ddhh-jobs-table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
background: #fff;
|
|
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.ddhh-jobs-table th,
|
|
.ddhh-jobs-table td {
|
|
padding: 1rem;
|
|
text-align: left;
|
|
border-bottom: 1px solid #e5e7eb;
|
|
}
|
|
|
|
.ddhh-jobs-table thead th {
|
|
background-color: #f9fafb;
|
|
font-weight: 600;
|
|
color: #374151;
|
|
text-transform: uppercase;
|
|
font-size: 0.875rem;
|
|
letter-spacing: 0.05em;
|
|
}
|
|
|
|
.ddhh-jobs-table tbody tr:hover {
|
|
background-color: #f9fafb;
|
|
}
|
|
|
|
.status-badge {
|
|
display: inline-block;
|
|
padding: 0.25rem 0.75rem;
|
|
border-radius: 9999px;
|
|
font-size: 0.875rem;
|
|
font-weight: 500;
|
|
}
|
|
|
|
.status-publish {
|
|
background-color: #d1fae5;
|
|
color: #065f46;
|
|
}
|
|
|
|
.status-pending {
|
|
background-color: #fef3c7;
|
|
color: #92400e;
|
|
}
|
|
|
|
.status-draft {
|
|
background-color: #e5e7eb;
|
|
color: #374151;
|
|
}
|
|
|
|
.job-actions {
|
|
white-space: nowrap;
|
|
}
|
|
|
|
.button {
|
|
display: inline-block;
|
|
padding: 0.5rem 1rem;
|
|
background-color: #3b82f6;
|
|
color: #fff;
|
|
text-decoration: none;
|
|
border-radius: 0.375rem;
|
|
font-size: 0.875rem;
|
|
transition: background-color 0.2s;
|
|
}
|
|
|
|
.button:hover {
|
|
background-color: #2563eb;
|
|
color: #fff;
|
|
}
|
|
|
|
.edit-link {
|
|
background-color: #6366f1;
|
|
}
|
|
|
|
.edit-link:hover {
|
|
background-color: #4f46e5;
|
|
}
|
|
|
|
.view-link {
|
|
background-color: #10b981;
|
|
margin-left: 0.5rem;
|
|
}
|
|
|
|
.view-link:hover {
|
|
background-color: #059669;
|
|
}
|
|
|
|
.ddhh-empty-state,
|
|
.ddhh-error-message {
|
|
padding: 3rem;
|
|
text-align: center;
|
|
background: #f9fafb;
|
|
border-radius: 0.5rem;
|
|
color: #6b7280;
|
|
}
|
|
|
|
.ddhh-error-message {
|
|
background: #fee2e2;
|
|
color: #991b1b;
|
|
}
|
|
|
|
@media (max-width: 768px) {
|
|
.ddhh-jobs-table {
|
|
font-size: 0.875rem;
|
|
}
|
|
|
|
.ddhh-jobs-table th,
|
|
.ddhh-jobs-table td {
|
|
padding: 0.75rem 0.5rem;
|
|
}
|
|
|
|
.button {
|
|
padding: 0.375rem 0.75rem;
|
|
font-size: 0.8125rem;
|
|
}
|
|
}
|
|
</style>
|