Clean code

This commit is contained in:
Laurent Destailleur 2022-08-29 19:56:57 +02:00
parent c4b8bac43f
commit 52b912aa51
4 changed files with 37 additions and 38 deletions

View File

@ -332,7 +332,9 @@ if ($action == 'valid') {
$html = new Form($db);
$formaccounting = new FormAccounting($db);
llxHeader('', $langs->trans("CreateMvts"));
$title = $langs->trans("CreateMvts");
llxHeader('', $title);
// Confirmation to delete the command
if ($action == 'delete') {
@ -341,7 +343,7 @@ if ($action == 'delete') {
}
if ($action == 'create') {
print load_fiche_titre($langs->trans("CreateMvts"));
print load_fiche_titre($title);
$object = new BookKeeping($db);
$next_num_mvt = $object->getNextNumMvt('_tmp');

View File

@ -219,29 +219,6 @@ if ($action == 'add') {
}
}
// delete
if ($action == 'confirm_delete' && $confirm == 'yes') {
$db->begin();
$sql = "DELETE FROM ".MAIN_DB_PREFIX."menu WHERE rowid = ".GETPOST('menuId', 'int');
$result = $db->query($sql);
if ($result == 0) {
$db->commit();
llxHeader();
setEventMessages($langs->trans("MenuDeleted"), null, 'mesgs');
llxFooter();
exit;
} else {
$db->rollback();
$reload = 0;
$_GET["action"] = '';
$action = '';
}
}
/*

View File

@ -652,7 +652,7 @@ class Utils
* @param string $outputfile A path for an output file (used only when method is 2). For example: $conf->admin->dir_temp.'/out.tmp';
* @param int $execmethod 0=Use default method (that is 1 by default), 1=Use the PHP 'exec', 2=Use the 'popen' method
* @param string $redirectionfile If defined, a redirection of output to this file is added.
* @param int $noescapecommand 1=Do not escape command. Warning: Using this parameter need you alreay sanitized the command. if not, it will lead to security vulnerability.
* @param int $noescapecommand 1=Do not escape command. Warning: Using this parameter needs you alreay have sanitized the command. if not, it will lead to security vulnerability.
* This parameter is provided for backward compatibility with external modules. Always use 0 in core.
* @param string $redirectionfileerr If defined, a redirection of error is added to this file instead of to channel 1.
* @return array array('result'=>...,'output'=>...,'error'=>...). result = 0 means OK.

View File

@ -156,7 +156,7 @@ if ($action == 'presend') {
$formmail->inreplyto = empty($inreplyto) ? '' : $inreplyto;
$formmail->withfrom = 1;
// Fill list of recipient with email inside <>.
// Define $liste, a list of recipients with email inside <>.
$liste = array();
if ($object->element == 'expensereport') {
$fuser = new User($db);
@ -202,16 +202,6 @@ if ($action == 'presend') {
}
}
$formmail->withto = $liste;
$formmail->withtofree = (GETPOST('sendto', 'alphawithlgt') ? GETPOST('sendto', 'alphawithlgt') : '1');
$formmail->withtocc = $liste;
$formmail->withtoccc = getDolGlobalString('MAIN_EMAIL_USECCC');
$formmail->withtopic = $topicmail;
$formmail->withfile = 2;
$formmail->withbody = 1;
$formmail->withdeliveryreceipt = 1;
$formmail->withcancel = 1;
//$arrayoffamiliestoexclude=array('system', 'mycompany', 'object', 'objectamount', 'date', 'user', ...);
if (!isset($arrayoffamiliestoexclude)) {
$arrayoffamiliestoexclude = null;
@ -219,6 +209,7 @@ if ($action == 'presend') {
// Make substitution in email content
if ($object) {
// First we set ->substit (useless, it will be erased later) and ->substit_lines
$formmail->setSubstitFromObject($object, $langs);
}
$substitutionarray = getCommonSubstitutionArray($outputlangs, 0, $arrayoffamiliestoexclude, $object);
@ -237,7 +228,7 @@ if ($action == 'presend') {
);
complete_substitutions_array($substitutionarray, $outputlangs, $object, $parameters);
// Find the good contact address
// Find all external contact addresses
$tmpobject = $object;
if (($object->element == 'shipping' || $object->element == 'reception')) {
$origin = $object->origin;
@ -289,17 +280,46 @@ if ($action == 'presend') {
if (is_array($contactarr) && count($contactarr) > 0) {
require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
$contactstatic = new Contact($db);
$tmpcompany = new Societe($db);
foreach ($contactarr as $contact) {
$contactstatic->fetch($contact['id']);
// Complete substitution array
$substitutionarray['__CONTACT_NAME_'.$contact['code'].'__'] = $contactstatic->getFullName($outputlangs, 1);
$substitutionarray['__CONTACT_LASTNAME_'.$contact['code'].'__'] = $contactstatic->lastname;
$substitutionarray['__CONTACT_FIRSTNAME_'.$contact['code'].'__'] = $contactstatic->firstname;
$substitutionarray['__CONTACT_TITLE_'.$contact['code'].'__'] = $contactstatic->getCivilityLabel();
// Complete $liste with the $contact
if (empty($liste[$contact['id']])) { // If this contact id not already into the $liste
$contacttoshow = '';
if (isset($object->thirdparty) && is_object($object->thirdparty)) {
if ($contactstatic->fk_soc != $object->thirdparty->id) {
$tmpcompany->fetch($contactstatic->fk_soc);
if ($tmpcompany->id > 0) {
$contacttoshow .= $tmpcompany->name.': ';
}
}
}
$contacttoshow .= $contactstatic->getFullName($outputlangs, 1);
$contacttoshow .= " <".($contactstatic->email ? $contactstatic->email : $langs->transnoentitiesnoconv("NoEMail")) .">";
$liste[$contact['id']] = $contacttoshow;
}
}
}
$formmail->withto = $liste;
$formmail->withtofree = (GETPOST('sendto', 'alphawithlgt') ? GETPOST('sendto', 'alphawithlgt') : '1');
$formmail->withtocc = $liste;
$formmail->withtoccc = getDolGlobalString('MAIN_EMAIL_USECCC');
$formmail->withtopic = $topicmail;
$formmail->withfile = 2;
$formmail->withbody = 1;
$formmail->withdeliveryreceipt = 1;
$formmail->withcancel = 1;
// Array of substitutions
$formmail->substit = $substitutionarray;