Merge pull request #21506 from Easya-Solutions/new-event-list-with-color
NEW events list with color
This commit is contained in:
commit
a074c89960
@ -54,6 +54,9 @@ $type = 'action';
|
||||
* Actions
|
||||
*/
|
||||
|
||||
$error = 0;
|
||||
$errors = array();
|
||||
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php';
|
||||
|
||||
$reg = array();
|
||||
@ -110,6 +113,33 @@ if ($action == 'set') {
|
||||
} else {
|
||||
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
|
||||
}
|
||||
} 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_current_color', 'alphanohtml'));
|
||||
$res = dolibarr_set_const($db, 'AGENDA_EVENT_CURRENT_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');
|
||||
|
||||
@ -193,9 +223,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();
|
||||
@ -395,7 +426,54 @@ print '</td></tr>'."\n";
|
||||
|
||||
print '</table>';
|
||||
|
||||
print dol_get_fiche_end();
|
||||
print $form->buttonsSaveCancel("Save", '');
|
||||
|
||||
print '</form>';
|
||||
|
||||
|
||||
/*
|
||||
* 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 '<form action="'.$_SERVER["PHP_SELF"].'" name="form_colors">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="action" value="setcolors">';
|
||||
|
||||
print '<table class="noborder allwidth">'."\n";
|
||||
print '<tr class="liste_titre">'."\n";
|
||||
print '<td>'.$langs->trans("Parameters").'</td>'."\n";
|
||||
print '<td class="center"> </td>'."\n";
|
||||
print '<td class="right">'.$langs->trans("Value").'</td>'."\n";
|
||||
print '</tr>'."\n";
|
||||
|
||||
// AGENDA_EVENT_PAST_COLOR
|
||||
print '<tr class="oddeven">'."\n";
|
||||
print '<td>'.$langs->trans('AGENDA_EVENT_PAST_COLOR').'</td>'."\n";
|
||||
print '<td class="center"> </td>'."\n";
|
||||
print '<td class="right">'."\n";
|
||||
print $formother->selectColor($conf->global->AGENDA_EVENT_PAST_COLOR, 'event_past_color');
|
||||
print '</td></tr>'."\n";
|
||||
// AGENDA_EVENT_CURRENT_COLOR
|
||||
print '<tr class="oddeven">'."\n";
|
||||
print '<td>'.$langs->trans('AGENDA_EVENT_CURRENT_COLOR').'</td>'."\n";
|
||||
print '<td class="center"> </td>'."\n";
|
||||
print '<td class="right">'."\n";
|
||||
print $formother->selectColor($conf->global->AGENDA_EVENT_CURRENT_COLOR, 'event_current_color');
|
||||
print '</td></tr>'."\n";
|
||||
// AGENDA_EVENT_FUTURE_COLOR
|
||||
print '<tr class="oddeven">'."\n";
|
||||
print '<td>'.$langs->trans('AGENDA_EVENT_FUTURE_COLOR').'</td>'."\n";
|
||||
print '<td class="center"> </td>'."\n";
|
||||
print '<td class="right">'."\n";
|
||||
print $formother->selectColor($conf->global->AGENDA_EVENT_FUTURE_COLOR, 'event_future_color');
|
||||
print '</td></tr>'."\n";
|
||||
|
||||
print '</table>';
|
||||
|
||||
print $form->buttonsSaveCancel("Save", '');
|
||||
|
||||
@ -403,6 +481,8 @@ print '</form>';
|
||||
|
||||
print "<br>";
|
||||
|
||||
print dol_get_fiche_end();
|
||||
|
||||
// End of page
|
||||
llxFooter();
|
||||
$db->close();
|
||||
|
||||
@ -887,6 +887,7 @@ print "</tr>\n";
|
||||
|
||||
$now = dol_now();
|
||||
$delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60;
|
||||
$today_start_time = dol_mktime(0, 0, 0, date('m', $now), date('d', $now), date('Y', $now));
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/cactioncomm.class.php';
|
||||
$caction = new CActionComm($db);
|
||||
@ -899,6 +900,7 @@ $i = 0;
|
||||
//$savnbfield = $totalarray['nbfield'];
|
||||
//$totalarray['nbfield'] = 0;
|
||||
$imaxinloop = ($limit ? min($num, $limit) : $num);
|
||||
$cache_user_list = array();
|
||||
while ($i < $imaxinloop) {
|
||||
$obj = $db->fetch_object($resql);
|
||||
if (empty($obj)) {
|
||||
@ -933,7 +935,58 @@ while ($i < $imaxinloop) {
|
||||
$actionstatic->fetchResources();
|
||||
}
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
// cache of user list (owners)
|
||||
if ($obj->fk_user_action > 0 && !isset($cache_user_list[$obj->fk_user_action])) {
|
||||
$userstatic = new User($db);
|
||||
$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 ($event_start_date_time > $now) {
|
||||
// future event
|
||||
$event_more_class = 'event-future';
|
||||
$event_start_date_color = $conf->global->AGENDA_EVENT_FUTURE_COLOR;
|
||||
} else {
|
||||
if ($obj->fulldayevent == 1) {
|
||||
$today_start_date_time = $today_start_time;
|
||||
} else {
|
||||
$today_start_date_time = $now;
|
||||
}
|
||||
|
||||
// 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_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_more_class = 'event-past';
|
||||
$event_start_date_color = $conf->global->AGENDA_EVENT_PAST_COLOR;
|
||||
} else {
|
||||
// current event
|
||||
$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 '<tr class="oddeven' . ($event_more_class != '' ? ' '.$event_more_class : '') . '">';
|
||||
// Action column
|
||||
if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) {
|
||||
print '<td class="nowrap center">';
|
||||
@ -955,10 +1008,16 @@ while ($i < $imaxinloop) {
|
||||
|
||||
// User owner
|
||||
if (!empty($arrayfields['owner']['checked'])) {
|
||||
print '<td class="tdoverflowmax150">'; // 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 '<td class="tdoverflowmax150"' . ($event_owner_style != '' ? ' style="'.$event_owner_style.'"' : '') . '>'; // 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])) {
|
||||
$userstatic = new User($db);
|
||||
$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 ' ';
|
||||
}
|
||||
@ -1006,7 +1065,7 @@ while ($i < $imaxinloop) {
|
||||
|
||||
// Start date
|
||||
if (!empty($arrayfields['a.datep']['checked'])) {
|
||||
print '<td class="center nowraponall">';
|
||||
print '<td class="center nowraponall"' . ($event_start_date_style != '' ? ' style="'.$event_start_date_style.'"' : '') . '>';
|
||||
if (empty($obj->fulldayevent)) {
|
||||
print dol_print_date($db->jdate($obj->dp), $formatToUse, 'tzuserrel');
|
||||
} else {
|
||||
|
||||
@ -1828,6 +1828,9 @@ AGENDA_USE_EVENT_TYPE=Use events types (managed in menu Setup -> Dictionaries ->
|
||||
AGENDA_USE_EVENT_TYPE_DEFAULT=Automatically set this default value for type of event in event create form
|
||||
AGENDA_DEFAULT_FILTER_TYPE=Automatically set this type of event in search filter of agenda view
|
||||
AGENDA_DEFAULT_FILTER_STATUS=Automatically set this status for events in search filter of agenda view
|
||||
AGENDA_EVENT_PAST_COLOR=Past event color
|
||||
AGENDA_EVENT_CURRENT_COLOR=Current event color
|
||||
AGENDA_EVENT_FUTURE_COLOR=Future event color
|
||||
AGENDA_DEFAULT_VIEW=Which view do you want to open by default when selecting menu Agenda
|
||||
AGENDA_REMINDER_BROWSER=Enable event reminder <b>on user's browser</b> (When remind date is reached, a popup is shown by the browser. Each user can disable such notifications from its browser notification setup).
|
||||
AGENDA_REMINDER_BROWSER_SOUND=Enable sound notification
|
||||
|
||||
@ -1826,6 +1826,9 @@ AGENDA_USE_EVENT_TYPE=Utiliser les types d'événements (gérés dans le menu Co
|
||||
AGENDA_USE_EVENT_TYPE_DEFAULT=Configurez automatiquement cette valeur par défaut pour le type d'événement dans le formulaire de création d'événement.
|
||||
AGENDA_DEFAULT_FILTER_TYPE=Positionner automatiquement ce type d'événement dans le filtre de recherche de la vue agenda
|
||||
AGENDA_DEFAULT_FILTER_STATUS=Positionner automatiquement ce statut d'événement dans le filtre de recherche de la vue agenda
|
||||
AGENDA_EVENT_PAST_COLOR=Couleur de l'événement passé
|
||||
AGENDA_EVENT_CURRENT_COLOR=Couleur de l'événement en cours
|
||||
AGENDA_EVENT_FUTURE_COLOR=Couleur de l'événement futur
|
||||
AGENDA_DEFAULT_VIEW=Quel onglet voulez-vous voir ouvrir par défaut quand on choisit le menu Agenda
|
||||
AGENDA_REMINDER_BROWSER=Activer le rappel d'événement <b> sur le navigateur de l'utilisateur </b> (lorsque la date de l'événement est atteinte, une popup est affichée sur la navigateur. Chaque utilisateur peut désactiver de telles notification depuis la configuration des notifications de son navigateur)
|
||||
AGENDA_REMINDER_BROWSER_SOUND=Activer les notifications sonores.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user