diff --git a/template-parts/admin/artisans-section-group.php b/template-parts/admin/artisans-section-group.php index 95f5d53..00c92a6 100644 --- a/template-parts/admin/artisans-section-group.php +++ b/template-parts/admin/artisans-section-group.php @@ -19,37 +19,40 @@ $current_user_id = $args['current_user_id'] ?? null; $not_found_message = $args['not_found_message'] ?? ""; -$queryArgsWithStatus = array( +$queryAllUnaffectedArtisansByStatus = array( 'post_type' => 'artisans', 'posts_per_page' => -1, + 'meta_query' => array( + 'relation' => 'AND', + array( + 'key' => 'mdp_status', + 'value' => $status, + 'compare' => '=' + ), + array( + 'key' => 'conseiller', + 'compare' => 'NOT EXISTS' + ) + ) +); + +$queryConseillerRelatedArtisansByStatus = array( + 'post_type' => 'artisans', + 'posts_per_page' => -1, + 'meta_key' => 'conseiller', + 'meta_value' => $current_user_id, 'meta_query' => array( array( 'key' => 'mdp_status', 'value' => $status, 'compare' => '=' - ) - ) -); -$queryArgsActionRequired = array( - 'post_type' => 'artisans', - 'posts_per_page' => -1, - 'meta_query' => array( - array( - 'key' => 'required_action', - 'value' => true, - 'compare' => '=' - ) + ), ) ); -$currentQueryArgs = $status ? $queryArgsWithStatus : $queryArgsActionRequired; - -if ($use_current_user && $current_user_id) { - $currentQueryArgs['meta_value'] = $current_user_id; - $currentQueryArgs['meta_key'] = 'conseiller'; -} +$currentQueryArgs = ($use_current_user && $current_user_id) ? $queryConseillerRelatedArtisansByStatus : $queryAllUnaffectedArtisansByStatus; $artisans = new WP_Query($currentQueryArgs); @@ -61,13 +64,37 @@ $artisans = new WP_Query($currentQueryArgs); found_posts === 0) : ?>

+
  • +

    Nom

    +

    Dernière action

    +

    Commentaire

    +

    Statut

    +
  • posts as $artisan) : ?> - ID); ?> + ID); + $last_contact = get_field('last_action', $artisan->ID); + $last_contact_date = isset($last_contact['last_contact_date']) ? $last_contact['last_contact_date'] : null; + $last_contact_comment = isset($last_contact['comments']) ? $last_contact['comments'] : null; + + if ($last_contact_date) { + $formatted_date = getFrenchDateFromTimestamp($last_contact_date); + $relative_time = getRelativeTimeFromTimestamp($last_contact_date); + + $last_contact_date = $relative_time . ' (' . $formatted_date . ')'; + } else { + $last_contact_date = null; + } + ?> +
  • - post_title ?> - - - + post_title ?> + + + + + +