Factorize some common code for type of event

This commit is contained in:
Laurent Destailleur 2021-02-14 20:12:43 +01:00
parent 50797bf892
commit 66c7770146
6 changed files with 46 additions and 42 deletions

View File

@ -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 '<tr><td class="fieldrequired">'.$langs->trans("Type").'</td><td colspan="3">';
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 '<input type="hidden" name="actioncode" value="'.$object->type_code.'">'.$langs->trans("Action".$object->type_code);
print '<input type="hidden" name="actioncode" value="'.$object->type_code.'">';
print $object->getTypePicto();
print $langs->trans("Action".$object->type_code);
}
print '</td></tr>';
}
@ -1430,7 +1433,7 @@ if ($id > 0)
// Full day event
print '<tr><td>'.$langs->trans("EventOnFullDay").'</td><td colspan="3"><input type="checkbox" id="fullday" name="fullday" '.($object->fulldayevent ? ' checked' : '').'></td></tr>';
print dol_print_date($object->datep, 'dayhour', 'gmt');
// Date start - end
print '<tr><td class="nowrap"><span class="fieldrequired">'.$langs->trans("DateActionStart").' - '.$langs->trans("DateActionEnd").'</span></td><td colspan="3">';
if (GETPOST("afaire") == 1) {
@ -1510,7 +1513,7 @@ if ($id > 0)
// Location
if (empty($conf->global->AGENDA_DISABLE_LOCATION))
{
print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3"><input type="text" name="location" class="soixantepercent" value="'.$object->location.'"></td></tr>';
print '<tr><td>'.$langs->trans("Location").'</td><td colspan="3"><input type="text" name="location" class="width500" value="'.$object->location.'"></td></tr>';
}
// 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 '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td>'.$langs->trans($object->type).'</td></tr>';
print '<tr><td class="titlefield">'.$langs->trans("Type").'</td><td>';
print $object->getTypePicto();
print $langs->trans($object->type).'</td></tr>';
}
// Full day event

View File

@ -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.
*

View File

@ -688,24 +688,9 @@ if ($resql)
if (!empty($arrayfields['c.libelle']['checked']))
{
print '<td class="nowraponall">';
$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';

View File

@ -4370,6 +4370,9 @@ class Form
$more .= '<div class="tagtr"><div class="tagtd'.(empty($input['tdclass']) ? '' : (' '.$input['tdclass'])).'">'.$input['label'].'</div><div class="tagtd"><input type="password" class="flat'.$morecss.'" id="'.$input['name'].'" name="'.$input['name'].'"'.$size.' value="'.$input['value'].'"'.$moreattr.' /></div></div>'."\n";
} elseif ($input['type'] == 'select')
{
if (empty($morecss)) {
$morecss = 'minwidth100';
}
$more .= '<div class="tagtr"><div class="tagtd'.(empty($input['tdclass']) ? '' : (' '.$input['tdclass'])).'">';
if (!empty($input['label'])) $more .= $input['label'].'</div><div class="tagtd left">';
$more .= $this->selectarray($input['name'], $input['values'], $input['default'], 1, 0, 0, $moreattr, 0, 0, 0, '', $morecss);

View File

@ -263,23 +263,7 @@ class FormActions
// Type
print '<td>';
// 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 {

View File

@ -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',