NEW Can edit the list of sending email profiles.
This commit is contained in:
parent
6f1a51139c
commit
23bb67873f
@ -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 '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'"
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
print '<input type="hidden" name="token" value="'.newToken().'">';
|
||||
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
|
||||
print '<input type="hidden" name="action" value="'.($action == 'create' ? 'add' : 'list').'">';
|
||||
print '<input type="hidden" name="action" value="'.($action == 'create' ? 'add' : ($action == 'edit' ? 'update' : 'list')).'">';
|
||||
print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||
|
||||
$newcardbutton = '';
|
||||
if ($action != 'create') {
|
||||
$newcardbutton = dolGetButtonTitle($langs->trans('New'), '', 'fa fa-plus-circle', $_SERVER['PHP_SELF'].'?action=create', '', $permissiontoadd);
|
||||
|
||||
if ($action == 'edit') {
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" value="'.(GETPOSTISSET('label') ? GETPOST('label', 'alphanohtml') : $object->label).'"></td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Email").'</td><td><input type="text" name="email" value="'.(GETPOSTISSET('email') ? GETPOST('email', 'alphanohtml') : $object->email).'"></td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Signature").'</td><td>';
|
||||
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 '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("User").'</td><td>';
|
||||
print $form->select_dolusers((GETPOSTISSET('private') ? GETPOST('private', 'int') : $object->private), 'private', 1, null, 0, ($user->admin ? '' : $user->id));
|
||||
print '</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Position").'</td><td><input type="text" name="position" class="maxwidth50" value="'.(GETPOSTISSET('position') ? GETPOST('position', 'int') : $object->position).'"></td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Status").'</td><td>';
|
||||
print $form->selectarray('active', $object->fields['active']['arrayofkeyval'], (GETPOSTISSET('active') ? GETPOST('active', 'int') : $object->active), 0, 0, 0, '', 1);
|
||||
print '</td></tr>';
|
||||
print '</table>';
|
||||
print '<br>';
|
||||
print '<div class="center">';
|
||||
print '<input class="button" type="submit" name="save" value="'.$langs->trans("Save").'">';
|
||||
print ' ';
|
||||
print '<input class="button" type="submit" name="cancel" value="'.$langs->trans("Cancel").'">';
|
||||
print '</div>';
|
||||
}
|
||||
} else {
|
||||
/*print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
|
||||
@ -367,7 +397,7 @@ if ($action != 'create') {
|
||||
print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
|
||||
*/
|
||||
print '<table class="border centpercent tableforfield">';
|
||||
print '<tr><td>'.$langs->trans("Label").'</td><td><input type="text" name="label" value="'.GETPOST('label', 'alphanohtml').'"></td></tr>';
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td><input type="text" name="label" value="'.GETPOST('label', 'alphanohtml').'"></td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Email").'</td><td><input type="text" name="email" value="'.GETPOST('email', 'alphanohtml').'"></td></tr>';
|
||||
print '<tr><td>'.$langs->trans("Signature").'</td><td>';
|
||||
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 '<td'.($cssforfield ? ' class="'.$cssforfield.'"' : '').'>';
|
||||
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 '</td>';
|
||||
if (!$i) $totalarray['nbfield']++;
|
||||
@ -550,14 +580,14 @@ while ($i < ($limit ? min($num, $limit) : $num))
|
||||
print $hookmanager->resPrint;
|
||||
// Action column
|
||||
print '<td class="nowrap center">';
|
||||
$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 '<a class="reposition" href="'.$url.'&action=edit">'.img_edit().'</a>';
|
||||
print '<a class="editfielda reposition marginrightonly marginleftonly" href="'.$url.'&action=edit&rowid='.$obj->rowid.'">'.img_edit().'</a>';
|
||||
//print ' ';
|
||||
print '<a href="'.$url.'&action=delete">'.img_delete().'</a> ';
|
||||
print '<a class=" marginrightonly marginleftonly" href="'.$url.'&action=delete">'.img_delete().'</a> ';
|
||||
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;
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user