Compare commits

..

No commits in common. "4b7051c69ff7c2fb28d0ac7f8c14b5c82eaa4884" and "002b10ab7caf5523e99f65fe4eafe384417f86fd" have entirely different histories.

8 changed files with 76 additions and 167 deletions

View File

@ -261,12 +261,10 @@ function metiers_new_admin_menu_order($menu_order)
$new_positions = array( $new_positions = array(
'edit.php?post_type=artisans' => 3, 'edit.php?post_type=artisans' => 3,
'edit.php?post_type=chantiers' => 4, 'edit.php?post_type=chantiers' => 4,
'export_datas' => 8, 'edit.php?post_type=page' => 7,
'edit-tags.php?taxonomy=metiers&post_type=artisans' => 9, 'upload.php' => 8,
'edit-tags.php?taxonomy=elementsbatiments&post_type=artisans' => 10, 'export_datas' => 9,
'edit.php?post_type=page' => 11, 'theme-general-settings' => 11,
'upload.php' => 12,
'theme-general-settings' => 13,
'rank-math' => 20, 'rank-math' => 20,
); );
// helper function to move an element inside an array // helper function to move an element inside an array

View File

@ -331,6 +331,7 @@ add_action('pre_get_posts', 'filter_posts_by_acf_conseiller');
// ########################################################## // ##########################################################
// ########################################################## // ##########################################################
// ########################################################## // ##########################################################
@ -371,7 +372,7 @@ add_action('pre_get_posts', 'filter_posts_by_custom_datas');
// **** FILTRAGE DES POSTS QUAND LA QUERY DE FILTER EST ENVOYEE // **** FILTRAGE DES POSTS QUAND LA QUERY DE FILTER EST ENVOYEE
function metiers_patrimoine_filter_post_by_metiers_query($query) function metiers_patrimoine_filter_post_by_metiers_query($query)
{ {
// write_log("filter_post_by_metiers_query"); write_log("filter_post_by_metiers_query");
} }
// add_filter('parse_query', 'metiers_patrimoine_filter_post_by_metiers_query'); // add_filter('parse_query', 'metiers_patrimoine_filter_post_by_metiers_query');

View File

@ -8,7 +8,7 @@ function export_datas_page_in_menu()
add_menu_page( add_menu_page(
'Export de données', // page <title>Title</title> 'Export de données', // page <title>Title</title>
'Export', // link text 'Export', // link text
'edit_posts', // user capabilities 'manage_options', // user capabilities
'export_datas', // page slug 'export_datas', // page slug
'export_datas_page_callback', // this function prints the page content 'export_datas_page_callback', // this function prints the page content
'dashicons-external', // icon (from Dashicons for example) 'dashicons-external', // icon (from Dashicons for example)

View File

@ -204,40 +204,3 @@ function translate_wordpress_online_statuses($post_status)
} }
return $status_object->label; return $status_object->label;
} }
function getFrenchDateFromTimestamp($timestamp)
{
$date = new DateTime($timestamp);
$formatter = new IntlDateFormatter(
'fr_FR',
IntlDateFormatter::FULL,
IntlDateFormatter::NONE,
'Europe/Paris',
IntlDateFormatter::GREGORIAN,
'd MMMM y'
);
$formatted_date = $formatter->format($date);
return $formatted_date;
}
function getRelativeTimeFromTimestamp($timestamp)
{
$date = new DateTime($timestamp);
$now = new DateTime();
$interval = $date->diff($now);
// Créer le message relatif
$relative_time = '';
if ($interval->y > 0) {
$relative_time = 'il y a ' . $interval->y . ' an' . ($interval->y > 1 ? 's' : '');
} elseif ($interval->m > 0) {
$relative_time = 'il y a ' . $interval->m . ' mois';
} else {
$relative_time = 'il y a ' . $interval->d . ' jour' . ($interval->d > 1 ? 's' : '');
}
return $relative_time;
}

View File

@ -217,33 +217,13 @@ body.post-type-artisans {
font-size: revert; font-size: revert;
} }
} }
/* ------------------------------------
ADMIN MENU REORGANISATION AND ASPECT
------------------------------------*/
#toplevel_page_export_datas {
@apply !py-2;
border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
border-top: 1px solid rgba(255, 255, 255, 0.15) !important;
}
#menu-users {
@apply !py-2;
border-top: 1px solid rgba(255, 255, 255, 0.15) !important;
border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
}
#menu-pages, #menu-pages,
#menu-media { #menu-media {
/* @apply !py-1; */ @apply !py-1;
/* border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important; */ border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
} }
#menu-pages { #menu-pages {
@apply !pt-2; border-top: 1px solid rgba(255, 255, 255, 0.15) !important;
/* border-top: 1px solid rgba(255, 255, 255, 0.15) !important; */
}
#toplevel_page_tm-menu-main {
@apply hidden;
} }
#menu-pages + .wp-menu-separator { #menu-pages + .wp-menu-separator {

View File

@ -38,30 +38,18 @@
} }
&__list { &__list {
li.list-titles {
border: none !important;
@apply !items-end py-0 mb-0 text-neutral-400;
p {
@apply mt-0 mb-2;
}
> span {
@apply text-center;
}
}
li { li {
/* @apply flex justify-between items-center */ @apply flex justify-between items-center pl-4 py-2;
@apply grid pl-4 py-2 gap-4;
grid-template-columns: 2fr 1fr 2fr 1fr;
border-left: 4px solid theme('colors.rose.300'); border-left: 4px solid theme('colors.rose.300');
&:nth-child(even) { &:nth-child(even) {
@apply bg-stone-50; @apply bg-stone-50;
} }
a.post-link { a {
@apply w-fit block text-base mr-auto; @apply w-fit block text-base;
} }
.status-state { .status-state {
@apply mx-0 h-fit; @apply mx-0;
} }
} }
} }
@ -81,7 +69,6 @@
border-left: 4px solid theme('colors.yellow.400'); border-left: 4px solid theme('colors.yellow.400');
} }
} }
&--to-contact,
&--ongoing, &--ongoing,
&--waiting-feedback { &--waiting-feedback {
.group-artisans__title { .group-artisans__title {

View File

@ -19,40 +19,37 @@ $current_user_id = $args['current_user_id'] ?? null;
$not_found_message = $args['not_found_message'] ?? ""; $not_found_message = $args['not_found_message'] ?? "";
$queryAllUnaffectedArtisansByStatus = array( $queryArgsWithStatus = array(
'post_type' => 'artisans', 'post_type' => 'artisans',
'posts_per_page' => -1, '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( 'meta_query' => array(
array( array(
'key' => 'mdp_status', 'key' => 'mdp_status',
'value' => $status, 'value' => $status,
'compare' => '=' '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); $artisans = new WP_Query($currentQueryArgs);
@ -64,37 +61,13 @@ $artisans = new WP_Query($currentQueryArgs);
<?php if ($artisans->found_posts === 0) : ?> <?php if ($artisans->found_posts === 0) : ?>
<p class="group-artisans__no-results"><?php echo $not_found_message ?></p> <p class="group-artisans__no-results"><?php echo $not_found_message ?></p>
<?php else : ?> <?php else : ?>
<li class="list-titles">
<p>Nom</p>
<p>Dernière action</p>
<p>Commentaire</p>
<p>Statut</p>
</li>
<?php foreach ($artisans->posts as $artisan) : ?> <?php foreach ($artisans->posts as $artisan) : ?>
<?php <?php $mdp_status = get_field('mdp_status', $artisan->ID); ?>
$mdp_status = get_field('mdp_status', $artisan->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;
}
?>
<li class="group-artisans__list__item"> <li class="group-artisans__list__item">
<a class="post-link" href="<?php echo get_edit_post_link($artisan->ID) ?>"><?php echo $artisan->post_title ?></a> <a href="<?php echo get_edit_post_link($artisan->ID) ?>"><?php echo $artisan->post_title ?></a>
<?php if ($mdp_status) : ?>
<span class="last-contact-date"> <?php echo $last_contact_date ?></span>
<span class="last-contact-comment"><?php echo $last_contact_comment ?></span>
<span class="status-state status-state--<?php echo $mdp_status['value'] ?>"><?php echo $mdp_status['label'] ?></span> <span class="status-state status-state--<?php echo $mdp_status['value'] ?>"><?php echo $mdp_status['label'] ?></span>
<?php endif; ?>
</li> </li>
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>

View File

@ -10,7 +10,7 @@ $use_current_user = isset($_GET['use-current-user']) ? $_GET['use-current-user']
<?php if ($use_current_user) : ?> <?php if ($use_current_user) : ?>
<h1 class="page-title">Artisans de <?php echo $user_name ?></h1> <h1 class="page-title">Artisans de <?php echo $user_name ?></h1>
<?php else : ?> <?php else : ?>
<h1 class="page-title">Artisans non attribués avec action requise </h1> <h1 class="page-title">Tous les Artisans</h1>
<?php endif; ?> <?php endif; ?>
@ -19,17 +19,26 @@ $use_current_user = isset($_GET['use-current-user']) ? $_GET['use-current-user']
Artisans de <?php echo $user_name ?> Artisans de <?php echo $user_name ?>
</a> </a>
<a href="<?php echo add_query_arg('use-current-user', '0', $_SERVER['REQUEST_URI']); ?>" class="button <?php echo !$use_current_user ? 'filter-active' : ''; ?> "> <a href="<?php echo add_query_arg('use-current-user', '0', $_SERVER['REQUEST_URI']); ?>" class="button <?php echo !$use_current_user ? 'filter-active' : ''; ?> ">
Artisans non attribués Tous les artisans
</a> </a>
</div> </div>
<?php <?php
//===== SECTION : ACTION REQUISE =====//
get_template_part('template-parts/admin/artisans-section-group', null, array(
'type' => 'action-required',
'status_class' => 'action-required ',
'title' => 'Action requise',
'use_current_user' => $use_current_user,
'current_user_id' => $current_user->ID,
'not_found_message' => 'Aucun artisan avec une action requise',
));
//===== SECTION : À ACTUALISER =====// //===== SECTION : À ACTUALISER =====//
get_template_part('template-parts/admin/artisans-section-group', null, array( get_template_part('template-parts/admin/artisans-section-group', null, array(
'status' => 'to_actualize', 'status' => 'to_actualize',
'status_class' => 'to-actualize', 'status_class' => 'to-actualize',
'title' => 'En ligne > À actualiser', 'title' => 'À actualiser',
'use_current_user' => $use_current_user, 'use_current_user' => $use_current_user,
'current_user_id' => $current_user->ID, 'current_user_id' => $current_user->ID,
'not_found_message' => 'Aucun artisan à actualiser', 'not_found_message' => 'Aucun artisan à actualiser',
@ -39,42 +48,40 @@ $use_current_user = isset($_GET['use-current-user']) ? $_GET['use-current-user']
get_template_part('template-parts/admin/artisans-section-group', null, array( get_template_part('template-parts/admin/artisans-section-group', null, array(
'status' => 'to_contact', 'status' => 'to_contact',
'status_class' => 'to-contact', 'status_class' => 'to-contact',
'title' => 'Nouveau > À contacter', 'title' => 'À contacter',
'use_current_user' => $use_current_user, 'use_current_user' => $use_current_user,
'current_user_id' => $current_user->ID, 'current_user_id' => $current_user->ID,
'not_found_message' => 'Aucun artisan à contacter', 'not_found_message' => 'Aucun artisan à contacter',
)); ));
if (!$use_current_user) {
//===== SECTION : EN ATTENTE DE RETOUR =====// //===== SECTION : EN ATTENTE DE RETOUR =====//
// get_template_part('template-parts/admin/artisans-section-group', null, array( get_template_part('template-parts/admin/artisans-section-group', null, array(
// 'status' => 'waiting_feedback', 'status' => 'waiting_feedback',
// 'status_class' => 'waiting-feedback', 'status_class' => 'waiting-feedback',
// 'title' => 'En attente de retour', 'title' => 'En attente de retour',
// 'use_current_user' => $use_current_user, 'use_current_user' => $use_current_user,
// 'current_user_id' => $current_user->ID, 'current_user_id' => $current_user->ID,
// 'not_found_message' => 'Aucun artisan en attente de retour', 'not_found_message' => 'Aucun artisan en attente de retour',
// )); ));
//===== SECTION : EN COURS =====// //===== SECTION : EN COURS =====//
// get_template_part('template-parts/admin/artisans-section-group', null, array( get_template_part('template-parts/admin/artisans-section-group', null, array(
// 'status' => 'ongoing', 'status' => 'ongoing',
// 'status_class' => 'ongoing', 'status_class' => 'ongoing',
// 'title' => 'En cours', 'title' => 'En cours',
// 'use_current_user' => $use_current_user, 'use_current_user' => $use_current_user,
// 'current_user_id' => $current_user->ID, 'current_user_id' => $current_user->ID,
// 'not_found_message' => 'Aucun artisan en cours', 'not_found_message' => 'Aucun artisan en cours',
// )); ));
//===== SECTION : OK =====// //===== SECTION : OK =====//
// get_template_part('template-parts/admin/artisans-section-group', null, array( get_template_part('template-parts/admin/artisans-section-group', null, array(
// 'status' => 'ok', 'status' => 'ok',
// 'status_class' => 'ok', 'status_class' => 'ok',
// 'title' => 'OK', 'title' => 'OK',
// 'use_current_user' => $use_current_user, 'use_current_user' => $use_current_user,
// 'current_user_id' => $current_user->ID, 'current_user_id' => $current_user->ID,
// 'not_found_message' => 'Aucun artisan OK', 'not_found_message' => 'Aucun artisan OK',
// )); ));
}
?> ?>
</div> </div>