From 66c777014697d254fc9ea84d38ee01e32047a957 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 14 Feb 2021 20:12:43 +0100 Subject: [PATCH] Factorize some common code for type of event --- htdocs/comm/action/card.php | 16 +++++++---- htdocs/comm/action/class/actioncomm.class.php | 28 +++++++++++++++++++ htdocs/comm/action/list.php | 19 ++----------- htdocs/core/class/html.form.class.php | 3 ++ htdocs/core/class/html.formactions.class.php | 18 +----------- htdocs/core/lib/functions.lib.php | 4 +-- 6 files changed, 46 insertions(+), 42 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 6f1e83103d5..e34dffd6223 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -1363,6 +1363,7 @@ if ($id > 0) $now = dol_now(); $delay_warning = $conf->global->MAIN_DELAY_ACTIONS_TODO * 24 * 60 * 60; + // Confirmation suppression action if ($action == 'delete') { @@ -1418,9 +1419,11 @@ if ($id > 0) print ''.$langs->trans("Type").''; if ($object->type_code != 'AC_OTH_AUTO') { - $formactions->select_type_actions(GETPOST("actioncode", 'aZ09') ?GETPOST("actioncode", 'aZ09') : $object->type_code, "actioncode", "systemauto"); + print $formactions->select_type_actions(GETPOST("actioncode", 'aZ09') ? GETPOST("actioncode", 'aZ09') : $object->type_code, "actioncode", "systemauto", 0, 0, 0, 1); } else { - print ''.$langs->trans("Action".$object->type_code); + print ''; + print $object->getTypePicto(); + print $langs->trans("Action".$object->type_code); } print ''; } @@ -1430,7 +1433,7 @@ if ($id > 0) // Full day event print ''.$langs->trans("EventOnFullDay").'fulldayevent ? ' checked' : '').'>'; - print dol_print_date($object->datep, 'dayhour', 'gmt'); + // Date start - end print ''.$langs->trans("DateActionStart").' - '.$langs->trans("DateActionEnd").''; if (GETPOST("afaire") == 1) { @@ -1510,7 +1513,7 @@ if ($id > 0) // Location if (empty($conf->global->AGENDA_DISABLE_LOCATION)) { - print ''.$langs->trans("Location").''; + print ''.$langs->trans("Location").''; } // Assigned to @@ -1786,7 +1789,6 @@ if ($id > 0) } else { print dol_get_fiche_head($head, 'card', $langs->trans("Action"), -1, 'action'); - // Clone event if ($action == 'clone') { @@ -1873,7 +1875,9 @@ if ($id > 0) // Type if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - print ''.$langs->trans("Type").''.$langs->trans($object->type).''; + print ''.$langs->trans("Type").''; + print $object->getTypePicto(); + print $langs->trans($object->type).''; } // Full day event diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index f7e0ef6acb1..4a3e4b644bc 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1508,6 +1508,34 @@ class ActionComm extends CommonObject return $result; } + /** + * Return Picto of type of event + * + * @return string HTML String + */ + public function getTypePicto() + { + global $conf; + + $imgpicto = ''; + if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) + { + if ($this->type_picto) { + $imgpicto = img_picto('', $this->type_picto); + } else { + if ($this->type_code == 'AC_RDV') $imgpicto = img_picto('', 'meeting', '', false, 0, 0, '', 'paddingright').' '; + elseif ($this->type_code == 'AC_TEL') $imgpicto = img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; + elseif ($this->type_code == 'AC_FAX') $imgpicto = img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; + elseif ($this->type_code == 'AC_EMAIL' || $this->type_code == 'AC_EMAIL_IN') $imgpicto = img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; + elseif ($this->type_code == 'AC_INT') $imgpicto = img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; + elseif ($this->type_code == 'AC_OTH' && $this->code == 'TICKET_MSG') $imgpicto = img_picto('', 'object_conversation', '', false, 0, 0, '', 'paddingright').' '; + elseif (!preg_match('/_AUTO/', $this->type_code)) $imgpicto = img_picto('', 'object_other', '', false, 0, 0, '', 'paddingright').' '; + } + } + return $imgpicto; + } + + /** * Sets object to supplied categories. * diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index b1d864589e8..a0d30620cee 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -688,24 +688,9 @@ if ($resql) if (!empty($arrayfields['c.libelle']['checked'])) { print ''; + $actioncomm = $actionstatic; - // TODO Code common with code into showactions - $imgpicto = ''; - if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) - { - if ($actioncomm->type_picto) { - $imgpicto = img_picto('', $actioncomm->type_picto); - } else { - if ($actioncomm->type_code == 'AC_RDV') $imgpicto = img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright').' '; - elseif ($actioncomm->type_code == 'AC_TEL') $imgpicto = img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright').' '; - elseif ($actioncomm->type_code == 'AC_FAX') $imgpicto = img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright').' '; - elseif ($actioncomm->type_code == 'AC_EMAIL' || $actioncomm->type_code == 'AC_EMAIL_IN') $imgpicto = img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright').' '; - elseif ($actioncomm->type_code == 'AC_INT') $imgpicto = img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright').' '; - elseif ($actioncomm->type_code == 'AC_OTH' && $actioncomm->code == 'TICKET_MSG') $imgpicto = img_picto('', 'object_conversation', '', false, 0, 0, '', 'paddingright').' '; - elseif (!preg_match('/_AUTO/', $actioncomm->type_code)) $imgpicto = img_picto('', 'object_other', '', false, 0, 0, '', 'paddingright').' '; - } - } - print $imgpicto; + print $actionstatic->getTypePicto(); $labeltype = $obj->type_code; if (empty($conf->global->AGENDA_USE_EVENT_TYPE) && empty($arraylist[$labeltype])) $labeltype = 'AC_OTH'; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 1d23953e4d4..a4a905d256d 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4370,6 +4370,9 @@ class Form $more .= '
'.$input['label'].'
'."\n"; } elseif ($input['type'] == 'select') { + if (empty($morecss)) { + $morecss = 'minwidth100'; + } $more .= '
'; if (!empty($input['label'])) $more .= $input['label'].'
'; $more .= $this->selectarray($input['name'], $input['values'], $input['default'], 1, 0, 0, $moreattr, 0, 0, 0, '', $morecss); diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 0cccbe6ad8c..bfd5a6f64f7 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -263,23 +263,7 @@ class FormActions // Type print ''; - // TODO Code common with code into comm/action/list.php - $imgpicto = ''; - if (!empty($conf->global->AGENDA_USE_EVENT_TYPE)) - { - if ($actioncomm->type_picto) { - $imgpicto = img_picto('', $actioncomm->type_picto); - } else { - if ($actioncomm->type_code == 'AC_RDV') $imgpicto = img_picto('', 'object_group', '', false, 0, 0, '', 'paddingright'); - elseif ($actioncomm->type_code == 'AC_TEL') $imgpicto = img_picto('', 'object_phoning', '', false, 0, 0, '', 'paddingright'); - elseif ($actioncomm->type_code == 'AC_FAX') $imgpicto = img_picto('', 'object_phoning_fax', '', false, 0, 0, '', 'paddingright'); - elseif ($actioncomm->type_code == 'AC_EMAIL') $imgpicto = img_picto('', 'object_email', '', false, 0, 0, '', 'paddingright'); - elseif ($actioncomm->type_code == 'AC_INT') $imgpicto = img_picto('', 'object_intervention', '', false, 0, 0, '', 'paddingright'); - elseif ($actioncomm->type_code == 'AC_OTH' && $actioncomm->code == 'TICKET_MSG') $imgpicto = img_picto('', 'object_conversation', '', false, 0, 0, '', 'paddingright'); - elseif (!preg_match('/_AUTO/', $actioncomm->type_code)) $imgpicto = img_picto('', 'object_action', '', false, 0, 0, '', 'paddingright'); - } - } - print $imgpicto; + print $actioncomm->getTypePicto(); if ($actioncomm->type_code == 'AC_OTH' && $actioncomm->code == 'TICKET_MSG') { print $langs->trans("Message"); } else { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 7192a887526..639ad182f4e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3268,7 +3268,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'filter', 'file-code', 'file-export', 'file-import', 'file-upload', 'folder', 'folder-open', 'globe', 'globe-americas', 'grip', 'grip_title', 'group', 'help', 'holiday', 'intervention', 'label', 'language', 'link', 'list', 'listlight', 'loan', 'lot', - 'margin', 'map-marker-alt', 'member', 'money-bill-alt', 'mrp', 'note', 'next', + 'margin', 'map-marker-alt', 'member', 'meeting', 'money-bill-alt', 'mrp', 'note', 'next', 'object_accounting', 'object_account', 'object_accountline', 'object_action', 'object_barcode', 'object_bill', 'object_billa', 'object_billd', 'object_bom', 'object_category', 'object_conversation', 'object_bookmark', 'object_bug', 'object_clock', 'object_dolly', 'object_dollyrevert', 'object_generic', 'object_folder', 'object_list-alt', 'object_calendar', 'object_calendarweek', 'object_calendarmonth', 'object_calendarday', 'object_calendarperuser', @@ -3318,7 +3318,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $ 'email'=>'at', 'edit'=>'pencil-alt', 'grip_title'=>'arrows-alt', 'grip'=>'arrows-alt', 'help'=>'question-circle', 'generic'=>'file', 'holiday'=>'umbrella-beach', 'label'=>'layer-group', 'loan'=>'money-bill-alt', - 'member'=>'users', 'mrp'=>'cubes', 'next'=>'arrow-alt-circle-right', + 'member'=>'users', 'meeting'=>'chalkboard-teacher', 'mrp'=>'cubes', 'next'=>'arrow-alt-circle-right', 'trip'=>'wallet', 'group'=>'users', 'movement'=>'people-carry', 'sign-out'=>'sign-out-alt', 'switch_off'=>'toggle-off', 'switch_on'=>'toggle-on', 'check'=>'check', 'bookmark'=>'star', 'bookmark'=>'star',