From 23bb67873fa2ddd9f5cedae6f83bd1fd93652bb0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 25 Aug 2020 19:40:17 +0200 Subject: [PATCH] NEW Can edit the list of sending email profiles. --- htdocs/admin/mails_senderprofile_list.php | 46 +++++++++++++++---- htdocs/admin/mails_templates.php | 10 ++-- .../core/class/emailsenderprofile.class.php | 38 +++++---------- 3 files changed, 55 insertions(+), 39 deletions(-) diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index bf841a03abe..89f9e23fdca 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -43,6 +43,7 @@ $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') $id = GETPOST('id', 'int'); +$rowid = GETPOST('rowid', 'alpha'); // Load variable for pagination $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; @@ -122,6 +123,10 @@ $permissiontoread = $user->admin; $permissiontoadd = $user->admin; $permissiontodelete = $user->admin; +if ($id > 0) { + $object->fetch($id); +} + /* * Actions @@ -191,7 +196,6 @@ $now = dol_now(); $help_url = ''; $title = $langs->trans("EMailsSetup"); - llxHeader('', $title); $linkback = ''; @@ -230,7 +234,7 @@ foreach ($search as $key => $val) { if ($key == 'status' && $search[$key] == -1) continue; $mode_search = (($object->isInt($object->fields[$key]) || $object->isFloat($object->fields[$key])) ? 1 : 0); - if (strpos($object->fields[$key]['type'], 'integer:') === 0) { + if (strpos($object->fields[$key]['type'], 'integer:') === 0 || $key == 'active') { if ($search[$key] == '-1') $search[$key] = ''; $mode_search = 2; } @@ -347,15 +351,41 @@ print '
'; print ''; print ''; -print ''; +print ''; print ''; print ''; print ''; +print ''; print ''; $newcardbutton = ''; if ($action != 'create') { $newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $_SERVER['PHP_SELF'].'?action=create', '', $permissiontoadd); + + if ($action == 'edit') { + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print '
'.$langs->trans("Label").'
'.$langs->trans("Email").'
'.$langs->trans("Signature").''; + require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor = new DolEditor('signature', (GETPOSTISSET('signature') ? GETPOST('signature', 'restricthtml') : $object->signature), '', 138, 'dolibarr_notes', 'In', true, true, empty($conf->global->FCKEDITOR_ENABLE_USERSIGN) ? 0 : 1, ROWS_4, '90%'); + print $doleditor->Create(1); + print '
'.$langs->trans("User").''; + print $form->select_dolusers((GETPOSTISSET('private') ? GETPOST('private', 'int') : $object->private), 'private', 1, null, 0, ($user->admin ? '' : $user->id)); + print '
'.$langs->trans("Position").'
'.$langs->trans("Status").''; + print $form->selectarray('active', $object->fields['active']['arrayofkeyval'], (GETPOSTISSET('active') ? GETPOST('active', 'int') : $object->active), 0, 0, 0, '', 1); + print '
'; + print '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; + } } else { /*print ''; if ($optioncss != '') print ''; @@ -367,7 +397,7 @@ if ($action != 'create') { print ''; */ print ''; - print ''; + print ''; print ''; print ''; if (!$i) $totalarray['nbfield']++; @@ -550,14 +580,14 @@ while ($i < ($limit ? min($num, $limit) : $num)) print $hookmanager->resPrint; // Action column print '
'.$langs->trans("Label").'
'.$langs->trans("Label").'
'.$langs->trans("Email").'
'.$langs->trans("Signature").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; @@ -531,7 +561,7 @@ while ($i < ($limit ? min($num, $limit) : $num)) if (!empty($arrayfields['t.'.$key]['checked'])) { print ''; - if ($key == 'status') print $object->getLibStatut(5); + if ($key == 'status' || $key == 'active') print $object->getLibStatut(5); else print $object->showOutputField($val, $key, $object->$key, ''); print ''; - $url = $_SERVER["PHP_SELF"].'?action=list&id='.$obj->rowid; + $url = $_SERVER["PHP_SELF"].'?id='.$obj->rowid; if ($limit) $url .= '&limit='.urlencode($limit); if ($page) $url .= '&page='.urlencode($page); if ($sortfield) $url .= '&sortfield='.urlencode($sortfield); if ($sortorder) $url .= '&page='.urlencode($sortorder); - //print ''.img_edit().''; + print ''.img_edit().''; //print '   '; - print ''.img_delete().'   '; + print ''.img_delete().'   '; if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined { $selected = 0; diff --git a/htdocs/admin/mails_templates.php b/htdocs/admin/mails_templates.php index bdd9f571123..83c8f583450 100644 --- a/htdocs/admin/mails_templates.php +++ b/htdocs/admin/mails_templates.php @@ -45,7 +45,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; // Load translation files required by the page $langs->loadLangs(array("errors", "admin", "mails", "languages")); -$action = GETPOST('action', 'alpha') ?GETPOST('action', 'alpha') : 'view'; +$action = GETPOST('action', 'aZ09') ?GETPOST('action', 'aZ09') : 'view'; $confirm = GETPOST('confirm', 'alpha'); // Result of a confirmation $id = GETPOST('id', 'int'); @@ -410,13 +410,15 @@ if (empty($reshook)) $form = new Form($db); $formadmin = new FormAdmin($db); -llxHeader(); +$help_url = ''; +$title = $langs->trans("EMailsSetup"); + +llxHeader('', $title); -$titre = $langs->trans("EMailsSetup"); $linkback = ''; $titlepicto = 'title_setup'; -print load_fiche_titre($titre, $linkback, $titlepicto); +print load_fiche_titre($title, $linkback, $titlepicto); $head = email_admin_prepare_head(); diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index 25a0d2a25c5..7cf18ae4801 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -95,13 +95,12 @@ class EmailSenderProfile extends CommonObject 'entity' => array('type'=>'integer', 'label'=>'Entity', 'visible'=>-1, 'enabled'=>1, 'position'=>20, 'notnull'=>1, 'index'=>1,), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'visible'=>1, 'enabled'=>1, 'position'=>30, 'notnull'=>1), 'email' => array('type'=>'varchar(255)', 'label'=>'Email', 'visible'=>1, 'enabled'=>1, 'position'=>40, 'notnull'=>-1), - //'fk_user_creat' => array('type'=>'integer', 'label'=>'UserAuthor', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), 'private' => array('type'=>'integer:User:user/class/user.class.php', 'label'=>'User', 'visible'=>-1, 'enabled'=>1, 'position'=>50, 'default'=>'0', 'notnull'=>1), 'signature' => array('type'=>'text', 'label'=>'Signature', 'visible'=>3, 'enabled'=>1, 'position'=>400, 'notnull'=>-1, 'index'=>1,), 'position' => array('type'=>'integer', 'label'=>'Position', 'visible'=>1, 'enabled'=>1, 'position'=>405, 'notnull'=>-1, 'index'=>1,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), 'tms' => array('type'=>'timestamp', 'label'=>'DateModification', 'visible'=>-1, 'enabled'=>1, 'position'=>500, 'notnull'=>1,), - 'active' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'default'=>1, 'position'=>1000, 'notnull'=>-1, 'index'=>1, 'arrayofkeyval'=>array(0=>'Disabled', 1=>'Enabled')), + 'active' => array('type'=>'integer', 'label'=>'Status', 'visible'=>1, 'enabled'=>1, 'default'=>1, 'position'=>1000, 'notnull'=>1, 'index'=>1, 'arrayofkeyval'=>array(0=>'Disabled', 1=>'Enabled')), ); /** @@ -331,7 +330,7 @@ class EmailSenderProfile extends CommonObject */ public function getLibStatut($mode = 0) { - return $this->LibStatut($this->status, $mode); + return $this->LibStatut($this->active, $mode); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -346,31 +345,16 @@ class EmailSenderProfile extends CommonObject { global $langs; - if ($mode == 0 || $mode == 1) - { - if ($status == 1) return $langs->trans('Enabled'); - elseif ($status == 0) return $langs->trans('Disabled'); - } elseif ($mode == 2) - { - if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); - } elseif ($mode == 3) - { - if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4'); - elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5'); - } elseif ($mode == 4) - { - if ($status == 1) return img_picto($langs->trans('Enabled'), 'statut4').' '.$langs->trans('Enabled'); - elseif ($status == 0) return img_picto($langs->trans('Disabled'), 'statut5').' '.$langs->trans('Disabled'); - } elseif ($mode == 5) - { - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); - elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); - } elseif ($mode == 6) - { - if ($status == 1) return $langs->trans('Enabled').' '.img_picto($langs->trans('Enabled'), 'statut4'); - elseif ($status == 0) return $langs->trans('Disabled').' '.img_picto($langs->trans('Disabled'), 'statut5'); + if ($status == 1) { + $label = $labelshort = $langs->trans('Enabled'); + } else { + $label = $labelshort = $langs->trans('Disabled'); } + + $statusType = 'status'.$status; + if ($status == self::STATUS_ENABLED) $statusType = 'status4'; + + return dolGetStatus($label, $labelshort, '', $statusType, $mode); } /**