From 1414f72794c6850bb950f016b02f2559069d9e57 Mon Sep 17 00:00:00 2001 From: lvessiller Date: Wed, 13 Jul 2022 16:37:50 +0200 Subject: [PATCH] NEW color in action list --- htdocs/admin/agenda_other.php | 88 +++++++++++++++++++++++++++++++++-- htdocs/comm/action/list.php | 32 ++++++++++++- 2 files changed, 116 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/agenda_other.php b/htdocs/admin/agenda_other.php index 1014d40de50..3f976efc784 100644 --- a/htdocs/admin/agenda_other.php +++ b/htdocs/admin/agenda_other.php @@ -53,6 +53,9 @@ $type = 'action'; * Actions */ +$error = 0; +$errors = array(); + include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; $reg = array(); @@ -109,7 +112,36 @@ if ($action == 'set') { } else { setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); } -} elseif ($action == 'specimen') { // For orders + +} elseif ($action == 'setcolors') { + $event_color = preg_replace('/[^0-9a-f#]/i', '', (string) GETPOST('event_past_color', 'alphanohtml')); + $res = dolibarr_set_const($db, 'AGENDA_EVENT_PAST_COLOR', $event_color, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + $errors[] = $db->lasterror(); + } + + $event_color = preg_replace('/[^0-9a-f#]/i', '', (string) GETPOST('event_progress_color', 'alphanohtml')); + $res = dolibarr_set_const($db, 'AGENDA_EVENT_PROGRESS_COLOR', $event_color, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + $errors[] = $db->lasterror(); + } + + $event_color = preg_replace('/[^0-9a-f#]/i', '', (string) GETPOST('event_future_color', 'alphanohtml')); + $res = dolibarr_set_const($db, 'AGENDA_EVENT_FUTURE_COLOR', $event_color, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + $errors[] = $db->lasterror(); + } + + if ($error) { + setEventMessages('', $errors, 'errors'); + } else { + setEventMessage($langs->trans('SetupSaved')); + } +} +elseif ($action == 'specimen') { // For orders $modele = GETPOST('module', 'alpha'); $commande = new CommandeFournisseur($db); @@ -192,9 +224,10 @@ print dol_get_fiche_head($head, 'other', $langs->trans("Agenda"), -1, 'action'); /* - * Documents models for supplier orders + * Miscellaneous */ +print load_fiche_titre($langs->trans('Miscellaneous'), '', ''); // Define array def of models $def = array(); @@ -394,7 +427,54 @@ print ''."\n"; print ''; -print dol_get_fiche_end(); +print $form->buttonsSaveCancel("Save", ''); + +print ''; + + +/* + * User interface (colors) + */ + +print load_fiche_titre($langs->trans('UserInterface'), '', ''); + +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +$formother = new FormOther($db); + +print '
'; +print ''; +print ''; + +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; + +// AGENDA_EVENT_PAST_COLOR +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +// AGENDA_EVENT_PROGRESS_COLOR +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; +// AGENDA_EVENT_FUTURE_COLOR +print ''."\n"; +print ''."\n"; +print ''."\n"; +print ''."\n"; + +print '
'.$langs->trans("Parameters").' '.$langs->trans("Value").'
'.$langs->trans('AGENDA_EVENT_PAST_COLOR').' '."\n"; +print $formother->selectColor($conf->global->AGENDA_EVENT_PAST_COLOR, 'event_past_color'); +print '
'.$langs->trans('AGENDA_EVENT_PROGRESS_COLOR').' '."\n"; +print $formother->selectColor($conf->global->AGENDA_EVENT_PROGRESS_COLOR, 'event_progress_color'); +print '
'.$langs->trans('AGENDA_EVENT_FUTURE_COLOR').' '."\n"; +print $formother->selectColor($conf->global->AGENDA_EVENT_FUTURE_COLOR, 'event_future_color'); +print '
'; print $form->buttonsSaveCancel("Save", ''); @@ -402,6 +482,8 @@ print '
'; print "
"; +print dol_get_fiche_end(); + // End of page llxFooter(); $db->close(); diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index dd877e903e4..0dadd28ff9e 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -889,6 +889,7 @@ $i = 0; //$savnbfield = $totalarray['nbfield']; //$totalarray['nbfield'] = 0; $imaxinloop = ($limit ? min($num, $limit) : $num); +$today_start_date_time = dol_now(); while ($i < $imaxinloop) { $obj = $db->fetch_object($resql); if (empty($obj)) { @@ -923,7 +924,36 @@ while ($i < $imaxinloop) { $actionstatic->fetchResources(); } - print ''; + // get event color + $event_color = ''; + $event_more_class = ''; + $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'; + } 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'; + } 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'; + } else { + // today event + $event_color = $conf->global->AGENDA_EVENT_PROGRESS_COLOR; + $event_more_class = 'event-progress'; + } + } + + print ''; // Ref if (!empty($arrayfields['a.id']['checked'])) {