From 161958d34613d1bcc9ffb30f0f61b9ec440ac957 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Thu, 21 Jul 2022 10:56:03 +0200 Subject: [PATCH] NEW color for start date and owner --- htdocs/comm/action/list.php | 48 +++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index ec42c0257af..096771c9ea7 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -890,6 +890,7 @@ $i = 0; //$totalarray['nbfield'] = 0; $imaxinloop = ($limit ? min($num, $limit) : $num); $today_start_date_time = dol_now(); +$cache_user_list = array(); while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); if (empty($obj)) { @@ -924,36 +925,54 @@ while ($i < $imaxinloop) { $actionstatic->fetchResources(); } - // get event color - $event_color = ''; + // cache of user list (owners) + if ($obj->fk_user_action > 0 && !isset($cache_user_list[$obj->fk_user_action])) { + $res = $userstatic->fetch($obj->fk_user_action); + if ($res > 0) { + $cache_user_list[$obj->fk_user_action] = $userstatic; + } + } + + // get event style for user owner + $event_owner_style = ''; + // We decide to choose color of owner of event (event->userownerid is user id of owner, event->userassigned contains all users assigned to event) + if ($cache_user_list[$obj->fk_user_action]->color != '') { + $event_owner_style .= 'border-left: #' . $cache_user_list[$obj->fk_user_action]->color . ' 5px solid;'; + } + + // get event style for start date $event_more_class = ''; + $event_start_date_style = ''; $event_start_date_time = $actionstatic->datep; if ($obj->fulldayevent) { $today_start_date_time = dol_mktime(0, 0, 0, date('m', $today_start_date_time), date('d', $today_start_date_time), date('Y', $today_start_date_time)); } if ($event_start_date_time > $today_start_date_time) { // future event - $event_color = $conf->global->AGENDA_EVENT_FUTURE_COLOR; $event_more_class = 'event-future'; + $event_start_date_color = $conf->global->AGENDA_EVENT_FUTURE_COLOR; } else { // check event end date $event_end_date_time = $db->jdate($obj->dp2); if ($event_end_date_time != null && $event_end_date_time < $today_start_date_time) { // past event - $event_color = $conf->global->AGENDA_EVENT_PAST_COLOR; $event_more_class = 'event-past'; + $event_start_date_color = $conf->global->AGENDA_EVENT_PAST_COLOR; } elseif ($event_end_date_time == null && $event_start_date_time < $today_start_date_time) { // past event - $event_color = $conf->global->AGENDA_EVENT_PAST_COLOR; $event_more_class = 'event-past'; + $event_start_date_color = $conf->global->AGENDA_EVENT_PAST_COLOR; } else { // current event - $event_color = $conf->global->AGENDA_EVENT_CURRENT_COLOR; $event_more_class = 'event-current'; + $event_start_date_color = $conf->global->AGENDA_EVENT_CURRENT_COLOR; } } + if ($event_start_date_color != '') { + $event_start_date_style .= 'background: #' . $event_start_date_color . ';'; + } - print ''; + print ''; // Ref if (!empty($arrayfields['a.id']['checked'])) { @@ -964,10 +983,15 @@ while ($i < $imaxinloop) { // User owner if (!empty($arrayfields['owner']['checked'])) { - print ''; // With edge and chrome the td overflow is not supported correctly when content is not full text. - if ($obj->fk_user_action > 0) { - $userstatic->fetch($obj->fk_user_action); - print $userstatic->getNomUrl(-1); + print ''; // With edge and chrome the td overflow is not supported correctly when content is not full text. + if ($obj->fk_user_action > 0 && !isset($cache_user_list[$obj->fk_user_action])) { + $res = $userstatic->fetch($obj->fk_user_action); + if ($res > 0) { + $cache_user_list[$obj->fk_user_action] = $userstatic; + } + } + if (isset($cache_user_list[$obj->fk_user_action])) { + print $cache_user_list[$obj->fk_user_action]->getNomUrl(-1); } else { print ' '; } @@ -1015,7 +1039,7 @@ while ($i < $imaxinloop) { // Start date if (!empty($arrayfields['a.datep']['checked'])) { - print ''; + print ''; if (empty($obj->fulldayevent)) { print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuserrel'); } else {