Compare commits
8 Commits
002b10ab7c
...
4b7051c69f
| Author | SHA1 | Date | |
|---|---|---|---|
| 4b7051c69f | |||
| 06ca902b9f | |||
| 58876d018c | |||
| e8bef64e07 | |||
| 440f035637 | |||
| f375137846 | |||
| 9c8d6821a5 | |||
| 464ec01f2b |
|
|
@ -261,10 +261,12 @@ 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,
|
||||||
'edit.php?post_type=page' => 7,
|
'export_datas' => 8,
|
||||||
'upload.php' => 8,
|
'edit-tags.php?taxonomy=metiers&post_type=artisans' => 9,
|
||||||
'export_datas' => 9,
|
'edit-tags.php?taxonomy=elementsbatiments&post_type=artisans' => 10,
|
||||||
'theme-general-settings' => 11,
|
'edit.php?post_type=page' => 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
|
||||||
|
|
|
||||||
|
|
@ -331,7 +331,6 @@ add_action('pre_get_posts', 'filter_posts_by_acf_conseiller');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ##########################################################
|
// ##########################################################
|
||||||
// ##########################################################
|
// ##########################################################
|
||||||
// ##########################################################
|
// ##########################################################
|
||||||
|
|
@ -372,7 +371,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');
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
'manage_options', // user capabilities
|
'edit_posts', // 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)
|
||||||
|
|
|
||||||
|
|
@ -204,3 +204,40 @@ 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;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -217,13 +217,33 @@ body.post-type-artisans {
|
||||||
font-size: revert;
|
font-size: revert;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#menu-pages,
|
|
||||||
#menu-media {
|
/* ------------------------------------
|
||||||
@apply !py-1;
|
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;
|
border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important;
|
||||||
}
|
}
|
||||||
|
#menu-pages,
|
||||||
|
#menu-media {
|
||||||
|
/* @apply !py-1; */
|
||||||
|
/* border-bottom: 1px solid rgba(255, 255, 255, 0.15) !important; */
|
||||||
|
}
|
||||||
#menu-pages {
|
#menu-pages {
|
||||||
border-top: 1px solid rgba(255, 255, 255, 0.15) !important;
|
@apply !pt-2;
|
||||||
|
/* 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 {
|
||||||
|
|
|
||||||
|
|
@ -38,18 +38,30 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&__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 pl-4 py-2;
|
/* @apply flex justify-between items-center */
|
||||||
|
@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 {
|
a.post-link {
|
||||||
@apply w-fit block text-base;
|
@apply w-fit block text-base mr-auto;
|
||||||
}
|
}
|
||||||
.status-state {
|
.status-state {
|
||||||
@apply mx-0;
|
@apply mx-0 h-fit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -69,6 +81,7 @@
|
||||||
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 {
|
||||||
|
|
|
||||||
|
|
@ -19,37 +19,40 @@ $current_user_id = $args['current_user_id'] ?? null;
|
||||||
$not_found_message = $args['not_found_message'] ?? "";
|
$not_found_message = $args['not_found_message'] ?? "";
|
||||||
|
|
||||||
|
|
||||||
$queryArgsWithStatus = array(
|
$queryAllUnaffectedArtisansByStatus = 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);
|
||||||
|
|
||||||
|
|
@ -61,13 +64,37 @@ $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 $mdp_status = get_field('mdp_status', $artisan->ID); ?>
|
<?php
|
||||||
|
$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 href="<?php echo get_edit_post_link($artisan->ID) ?>"><?php echo $artisan->post_title ?></a>
|
<a class="post-link" href="<?php echo get_edit_post_link($artisan->ID) ?>"><?php echo $artisan->post_title ?></a>
|
||||||
<?php if ($mdp_status) : ?>
|
|
||||||
<span class="status-state status-state--<?php echo $mdp_status['value'] ?>"><?php echo $mdp_status['label'] ?></span>
|
<span class="last-contact-date"> <?php echo $last_contact_date ?></span>
|
||||||
<?php endif; ?>
|
<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>
|
||||||
|
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
|
||||||
|
|
@ -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">Tous les Artisans</h1>
|
<h1 class="page-title">Artisans non attribués avec action requise </h1>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
|
|
@ -19,26 +19,17 @@ $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' : ''; ?> ">
|
||||||
Tous les artisans
|
Artisans non attribués
|
||||||
</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' => 'À actualiser',
|
'title' => 'En ligne > À 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',
|
||||||
|
|
@ -48,40 +39,42 @@ $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' => 'À contacter',
|
'title' => 'Nouveau > À 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',
|
||||||
));
|
));
|
||||||
|
|
||||||
//===== SECTION : EN ATTENTE DE RETOUR =====//
|
if (!$use_current_user) {
|
||||||
get_template_part('template-parts/admin/artisans-section-group', null, array(
|
//===== SECTION : EN ATTENTE DE RETOUR =====//
|
||||||
'status' => 'waiting_feedback',
|
// get_template_part('template-parts/admin/artisans-section-group', null, array(
|
||||||
'status_class' => 'waiting-feedback',
|
// 'status' => 'waiting_feedback',
|
||||||
'title' => 'En attente de retour',
|
// 'status_class' => 'waiting-feedback',
|
||||||
'use_current_user' => $use_current_user,
|
// 'title' => 'En attente de retour',
|
||||||
'current_user_id' => $current_user->ID,
|
// 'use_current_user' => $use_current_user,
|
||||||
'not_found_message' => 'Aucun artisan en attente de retour',
|
// 'current_user_id' => $current_user->ID,
|
||||||
));
|
// '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>
|
||||||
Loading…
Reference in New Issue
Block a user