feat(07-01): implement complete job management workflow
Adds comprehensive job submission, editing, and deactivation functionality with proper form handling and permissions. Includes administrator capabilities for job_offer management and fixed dashboard navigation. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -37,12 +37,79 @@ if ( $is_edit_mode ) {
|
||||
$form_id = DDHH_JM_Formidable::get_job_edit_form_id();
|
||||
|
||||
if ( $form_id ) {
|
||||
// Get post data
|
||||
$post = get_post( $job_id );
|
||||
if ( ! $post || 'job_offer' !== $post->post_type || absint( $post->post_author ) !== get_current_user_id() ) {
|
||||
echo '<div class="ddhh-error-message"><p>Sie haben keine Berechtigung, dieses Stellenangebot zu bearbeiten.</p></div>';
|
||||
return;
|
||||
}
|
||||
|
||||
// Get field IDs
|
||||
$fields = FrmField::getAll( array( 'fi.form_id' => $form_id ), 'field_order' );
|
||||
$field_params = array();
|
||||
|
||||
foreach ( $fields as $field ) {
|
||||
$field_value = '';
|
||||
switch ( $field->field_key ) {
|
||||
case 'job_title2':
|
||||
$field_value = $post->post_title;
|
||||
break;
|
||||
case 'job_description2':
|
||||
$field_value = $post->post_content;
|
||||
break;
|
||||
case 'job_location2':
|
||||
$field_value = get_post_meta( $job_id, 'job_location', true );
|
||||
break;
|
||||
case 'job_type2':
|
||||
$field_value = get_post_meta( $job_id, 'job_type', true );
|
||||
break;
|
||||
case 'job_deadline2':
|
||||
$field_value = get_post_meta( $job_id, 'job_deadline', true );
|
||||
break;
|
||||
case 'job_contact_email2':
|
||||
$field_value = get_post_meta( $job_id, 'job_contact_email', true );
|
||||
break;
|
||||
case 'job_logo2':
|
||||
$field_value = get_post_thumbnail_id( $job_id );
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ! empty( $field_value ) ) {
|
||||
$field_params[ $field->id ] = $field_value;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="ddhh-provider-dashboard">
|
||||
<div class="ddhh-job-edit-section">
|
||||
<h2>Stellenangebot bearbeiten</h2>
|
||||
<p><a href="<?php echo esc_url( get_permalink() ); ?>" class="back-to-dashboard">← Zurück zur Übersicht</a></p>
|
||||
<?php echo do_shortcode( "[formidable id={$form_id} id_param={$job_id}]" ); ?>
|
||||
<p><a href="<?php echo esc_url( home_url( '/anbieter-dashboard/' ) ); ?>" class="back-to-dashboard">← Zurück zur Übersicht</a></p>
|
||||
<?php echo do_shortcode( "[formidable id={$form_id}]" ); ?>
|
||||
|
||||
<script type="text/javascript">
|
||||
jQuery(document).ready(function($) {
|
||||
// Populate form fields with existing data
|
||||
var formData = <?php echo json_encode( $field_params ); ?>;
|
||||
|
||||
// Wait for form to be fully loaded
|
||||
setTimeout(function() {
|
||||
$.each(formData, function(fieldId, value) {
|
||||
var field = $('input[name="item_meta[' + fieldId + ']"], textarea[name="item_meta[' + fieldId + ']"], select[name="item_meta[' + fieldId + ']"]');
|
||||
|
||||
if (field.length) {
|
||||
if (field.is('select')) {
|
||||
field.val(value).trigger('change');
|
||||
} else if (field.is(':checkbox') || field.is(':radio')) {
|
||||
field.filter('[value="' + value + '"]').prop('checked', true);
|
||||
} else {
|
||||
field.val(value);
|
||||
}
|
||||
console.log('Populated field ' + fieldId + ' with:', value);
|
||||
}
|
||||
});
|
||||
}, 500);
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
@@ -59,7 +126,7 @@ if ( $is_deactivate_mode ) {
|
||||
<div class="ddhh-provider-dashboard">
|
||||
<div class="ddhh-job-deactivate-section">
|
||||
<h2>Stellenangebot deaktivieren</h2>
|
||||
<p><a href="<?php echo esc_url( get_permalink() ); ?>" class="back-to-dashboard">← Zurück zur Übersicht</a></p>
|
||||
<p><a href="<?php echo esc_url( home_url( '/anbieter-dashboard/' ) ); ?>" class="back-to-dashboard">← Zurück zur Übersicht</a></p>
|
||||
<?php echo do_shortcode( "[formidable id={$form_id} id_param={$job_id}]" ); ?>
|
||||
</div>
|
||||
</div>
|
||||
@@ -137,12 +204,14 @@ $job_query = new WP_Query( $args );
|
||||
<?php
|
||||
// Edit link - points to edit form on dashboard
|
||||
if ( current_user_can( 'edit_job_offer', $post_id ) ) {
|
||||
$dashboard_url = home_url( '/anbieter-dashboard/' );
|
||||
$edit_url = add_query_arg(
|
||||
array(
|
||||
'action' => 'edit_job',
|
||||
'job_id' => $post_id,
|
||||
'action' => 'edit_job',
|
||||
'job_id' => $post_id,
|
||||
'id_param' => $post_id, // For Formidable form action
|
||||
),
|
||||
get_permalink()
|
||||
$dashboard_url
|
||||
);
|
||||
echo '<a href="' . esc_url( $edit_url ) . '" class="button edit-link">Bearbeiten</a>';
|
||||
}
|
||||
@@ -154,12 +223,13 @@ $job_query = new WP_Query( $args );
|
||||
|
||||
// Deactivate link - only for published posts
|
||||
if ( 'publish' === $post_status ) {
|
||||
$dashboard_url = home_url( '/anbieter-dashboard/' );
|
||||
$deactivate_url = add_query_arg(
|
||||
array(
|
||||
'action' => 'deactivate_job',
|
||||
'job_id' => $post_id,
|
||||
),
|
||||
get_permalink()
|
||||
$dashboard_url
|
||||
);
|
||||
echo ' <a href="' . esc_url( $deactivate_url ) . '" class="button deactivate-link">Deaktivieren</a>';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user