diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 8c21b070d9f..a3c39cb06ee 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -816,8 +816,8 @@ class AccountancyExport // Keep correct quadra named field instead of anon filler libelle_ecriture2 is 30 char not 32 !!!! // as we use utf8, we must remove accent to have only one ascii char instead of utf8 2 chars for specials that report wrong line size that will exceed import format spec // TODO: we should filter more than only accent to avoid wrong line size - // TODO: remove invoice number doc_ref in libelle, - // TODO: we should offer an option for customer to build the libelle using invoice number / name / date in accounting software + // TODO: remove invoice number doc_ref in label, + // TODO: we should offer an option for customer to build the label using invoice number / name / date in accounting software //$Tab['libelle_ecriture2'] = str_pad(self::trunc($data->doc_ref . ' ' . $data->label_operation, 30), 30); $Tab['libelle_ecriture2'] = str_pad(self::trunc($data->label_operation, 30), 30); $Tab['codetva'] = str_repeat(' ', 2); diff --git a/htdocs/accountancy/class/accountingaccount.class.php b/htdocs/accountancy/class/accountingaccount.class.php index 8e5f7690dd1..0fd2fb2e61d 100644 --- a/htdocs/accountancy/class/accountingaccount.class.php +++ b/htdocs/accountancy/class/accountingaccount.class.php @@ -684,10 +684,10 @@ class AccountingAccount extends CommonObject } /** - * Retourne le libelle du statut d'un user (actif, inactif) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { @@ -696,11 +696,11 @@ class AccountingAccount extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @param int $status Id status - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { diff --git a/htdocs/accountancy/class/accountingjournal.class.php b/htdocs/accountancy/class/accountingjournal.class.php index 7c71d073629..f59ba4559e1 100644 --- a/htdocs/accountancy/class/accountingjournal.class.php +++ b/htdocs/accountancy/class/accountingjournal.class.php @@ -312,10 +312,10 @@ class AccountingJournal extends CommonObject } /** - * Retourne le libelle du statut d'un user (actif, inactif) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court - * @return string Label of type + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibType($mode = 0) { @@ -327,7 +327,7 @@ class AccountingJournal extends CommonObject * Return type of an accounting journal * * @param int $nature Id type - * @param int $mode 0=libelle long, 1=libelle court + * @param int $mode 0=label long, 1=label short * @return string Label of type */ public function LibType($nature, $mode = 0) diff --git a/htdocs/accountancy/journal/purchasesjournal.php b/htdocs/accountancy/journal/purchasesjournal.php index 65608998cf3..319328cdc6e 100644 --- a/htdocs/accountancy/journal/purchasesjournal.php +++ b/htdocs/accountancy/journal/purchasesjournal.php @@ -104,7 +104,7 @@ if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end)) $date_end = dol_get_last_day($pastmonthyear, $pastmonth, false); } -$sql = "SELECT f.rowid, f.ref as ref, f.type, f.datef as df, f.libelle,f.ref_supplier, f.date_lim_reglement as dlr, f.close_code, f.vat_reverse_charge,"; +$sql = "SELECT f.rowid, f.ref as ref, f.type, f.datef as df, f.libelle as label, f.ref_supplier, f.date_lim_reglement as dlr, f.close_code, f.vat_reverse_charge,"; $sql .= " fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva as total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.vat_src_code, fd.info_bits,"; $sql .= " p.default_vat_code AS product_buy_default_vat_code, p.tva_tx as product_buy_vat, p.localtax1_tx as product_buy_localvat1, p.localtax2_tx as product_buy_localvat2,"; $sql .= " co.code as country_code, co.label as country_label,"; diff --git a/htdocs/adherents/class/subscription.class.php b/htdocs/adherents/class/subscription.class.php index 5f8dbf07249..90f211d7a33 100644 --- a/htdocs/adherents/class/subscription.class.php +++ b/htdocs/adherents/class/subscription.class.php @@ -452,10 +452,10 @@ class Subscription extends CommonObject /** - * Retourne le libelle du statut d'une adhesion + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { @@ -464,16 +464,19 @@ class Subscription extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @param int $status Id status - * @return string Label + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ - public function LibStatut($status) + public function LibStatut($status, $mode = 0) { // phpcs:enable global $langs; - $langs->load("members"); + + //$langs->load("members"); + return ''; } diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index 1af4b25bb27..09172e985e9 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -478,7 +478,7 @@ if ($mode == 'feature') { if (isset($objMod->module_parts) && isset($objMod->module_parts['triggers']) && $objMod->module_parts['triggers']) { $yesno = 'Yes'; } else { - $yesno = 'No'; + $yesno = 'No'; } require_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; $interfaces = new Interfaces($db); diff --git a/htdocs/bookmarks/class/bookmark.class.php b/htdocs/bookmarks/class/bookmark.class.php index 7e1e3825b39..f1f81f9e45c 100644 --- a/htdocs/bookmarks/class/bookmark.class.php +++ b/htdocs/bookmarks/class/bookmark.class.php @@ -268,10 +268,10 @@ class Bookmark extends CommonObject } /** - * Return label of contact status + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of contact status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode) { diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 5822e6dd9d2..2b35cc38c4c 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1666,7 +1666,7 @@ class ActionComm extends CommonObject } $canread = 0; - if (!empty($user->rights->agenda->myactions->read) && $this->authorid == $user->id) { + if ($user->hasRight('agenda', 'myactions', 'read') && ($this->authorid == $user->id || $this->userownerid == $user->id)) { $canread = 1; // Can read my event } if (!empty($user->rights->agenda->myactions->read) && array_key_exists($user->id, $this->userassigned)) { diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index ea776094625..12303f87ed8 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -934,6 +934,7 @@ while ($i < $imaxinloop) { $actionstatic->datep = $db->jdate($obj->dp); $actionstatic->percentage = $obj->percent; $actionstatic->authorid = $obj->fk_user_author; + $actionstatic->userownerid = $obj->fk_user_action; // Initialize $this->userassigned && this->socpeopleassigned array && this->userownerid // but only if we need it diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 443444859eb..f77833c0e37 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -40,7 +40,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; // Load translation files required by the page -$langs->load("mails"); +$langs->loadLangs(array("mails")); $id = (GETPOST('mailid', 'int') ? GETPOST('mailid', 'int') : GETPOST('id', 'int')); @@ -48,20 +48,18 @@ $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); $cancel = GETPOST('cancel', 'aZ09'); $urlfrom = GETPOST('urlfrom'); +$backtopageforcancel = GETPOST('backtopageforcancel'); // Initialize technical objects $object = new Mailing($db); $extrafields = new ExtraFields($db); - -if ($id > 0) { - $result = $object->fetch($id); -} +$hookmanager->initHooks(array('mailingcard', 'globalcard')); // Fetch optionals attributes and labels $extrafields->fetch_name_optionals_label($object->table_element); -// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context -$hookmanager->initHooks(array('mailingcard', 'globalcard')); +// Load object +include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. // Array of possible substitutions (See also file mailing-send.php that should manage same substitutions) $object->substitutionarray = FormMail::getAvailableSubstitKey('emailing'); @@ -86,10 +84,14 @@ $listofmethods['smtps'] = 'SMTP/SMTPS socket library'; if (empty($user->rights->mailing->lire) || (empty($conf->global->EXTERNAL_USERS_ARE_AUTHORIZED) && $user->socid > 0)) { accessforbidden(); } +if (empty($action) && empty($object->id)) { + accessforbidden('Object not found'); +} $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); + /* * Actions */ @@ -567,7 +569,7 @@ if (empty($reshook)) { } // Action update description of emailing - if ($action == 'settitle' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto') { + if ($action == 'settitle' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto' || $action == 'setevenunsubscribe') { $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); if ($action == 'settitle') { @@ -582,10 +584,13 @@ if (empty($reshook)) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle")); } elseif ($action == 'setfrom' && empty($object->email_from)) { $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom")); + } elseif ($action == 'setevenunsubscribe') { + $object->evenunsubscribe = (GETPOST('evenunsubscribe') ? 1 : 0); } if (!$mesg) { - if ($object->update($user) >= 0) { + $result = $object->update($user); + if ($result >= 0) { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); exit; } @@ -747,20 +752,21 @@ llxHeader( array() ); + if ($action == 'create') { // EMailing in creation mode print '
'."\n"; print ''; print ''; - $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; + $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':

'; foreach ($object->substitutionarray as $key => $val) { $htmltext .= $key.' = '.$langs->trans($val).'
'; } - $htmltext .= '
'; + $htmltext .= '
'; - $availablelink = $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'availvar'); + $availablelink = $form->textwithpicto(''.$langs->trans("AvailableVariables").'', $htmltext, 1, 'help', '', 0, 2, 'availvar'); //print ''.img_picto($langs->trans("ClickToShowDescription"), $imginfo).''; @@ -931,18 +937,9 @@ if ($action == 'create') { dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); print '
'; + print '
'; print '
'; - - print ''; - - // Description - /* - print ''; - */ + print '
'; - print $form->editfieldkey("MailTitle", 'title', $object->title, $object, $user->hasRight('mailing', 'creer'), 'string'); - print ''; - print $form->editfieldval("MailTitle", 'title', $object->title, $object, $user->hasRight('mailing', 'creer'), 'string'); - print '
'."\n"; // From print ''; + print '
'; @@ -975,10 +972,18 @@ if ($action == 'create') { } print '
'; + print '
'; + + print '
'; + print '
'; + + print ''; + // Number of distinct emails - print ''; - // Other attributes + // Other attributes. Fields from hook formObjectOptions and Extrafields. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; print '
'; + print '
'; print $langs->trans("TotalNbOfDistinctRecipients"); - print ''; + print ''; $nbemail = ($object->nbemail ? $object->nbemail : 0); if (is_numeric($nbemail)) { $text = ''; @@ -1000,12 +1005,14 @@ if ($action == 'create') { } print '
'; + print '
'; + print '
'; - print ""; + print '
'; print dol_get_fiche_end(); @@ -1022,11 +1029,8 @@ if ($action == 'create') { print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneEMailing', $object->ref), 'confirm_clone', $formquestion, 'yes', 2, 240); } - /* - * Actions Buttons - */ - - if (GETPOST('cancel', 'alpha') || $confirm == 'no' || $action == '' || in_array($action, array('settodraft', 'valid', 'delete', 'sendall', 'clone', 'test'))) { + // Actions Buttons + if (GETPOST('cancel', 'alpha') || $confirm == 'no' || $action == '' || in_array($action, array('settodraft', 'valid', 'delete', 'sendall', 'clone', 'test', 'editevenunsubscribe'))) { print "\n\n
\n"; if (($object->statut == 1) && ($user->hasRight('mailing', 'valider') || $object->user_validation == $user->id)) { @@ -1198,17 +1202,32 @@ if ($action == 'create') { $linkback = ''.$langs->trans("BackToList").''; + $morehtmlref = '
'; + // Ref customer + $morehtmlref .= $form->editfieldkey("", 'title', $object->title, $object, $user->hasRight('mailing', 'creer'), 'string', '', 0, 1); + $morehtmlref .= $form->editfieldval("", 'title', $object->title, $object, $user->hasRight('mailing', 'creer'), 'string', '', null, null, '', 1); + $morehtmlref .= '
'; + $morehtmlright = ''; - if ($object->statut == 2) { - $morehtmlright .= ' ('.$object->countNbOfTargets('alreadysent').'/'.$object->nbemail.') '; + $nbtry = $nbok = 0; + if ($object->statut == 2 || $object->statut == 3) { + $nbtry = $object->countNbOfTargets('alreadysent'); + $nbko = $object->countNbOfTargets('alreadysentko'); + + $morehtmlright .= ' ('.$nbtry.'/'.$object->nbemail; + if ($nbko) { + $morehtmlright .= ' - '.$nbko.' '.$langs->trans("Error"); + } + $morehtmlright .= ')   '; } - dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', '', '', 0, '', $morehtmlright); + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); print '
'; + print '
'; print '
'; - print ''; + print '
'; /* print ''; @@ -1217,13 +1236,20 @@ if ($action == 'create') { print ''; */ - // Topic - print ''; // From print ''; // To print ''; + print '
'.$langs->trans("Ref").'
'.$langs->trans("MailTitle").''.$object->title.'
'.$langs->trans("MailFrom").''.dol_print_email($object->email_from, 0, 0, 0, 0, 1).'
'.$langs->trans("MailErrorsTo").''.dol_print_email($object->email_errorsto, 0, 0, 0, 0, 1).'
'; + print '
'; + + + print '
'; + print '
'; + + print ''; + // Number of distinct emails print '
'; print $langs->trans("TotalNbOfDistinctRecipients"); @@ -1259,30 +1285,32 @@ if ($action == 'create') { print '
'; print '
'; + print '
'; + + print '
'; print dol_get_fiche_end(); - - print "
\n"; + print "

\n"; print ''."\n"; print ''; print ''; print ''; - $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':
'; + $htmltext = ''.$langs->trans("FollowingConstantsWillBeSubstituted").':

'; foreach ($object->substitutionarray as $key => $val) { $htmltext .= $key.' = '.$langs->trans($val).'
'; } - $htmltext .= '
'; + $htmltext .= '
'; // Print mail content - print load_fiche_titre($langs->trans("EMail"), $form->textwithpicto($langs->trans("AvailableVariables"), $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp'), 'generic'); + print load_fiche_titre($langs->trans("EMail"), ''.$form->textwithpicto($langs->trans("AvailableVariables").'', $htmltext, 1, 'help', '', 0, 2, 'emailsubstitionhelp'), 'generic'); print dol_get_fiche_head(null, '', '', -1); - print ''; + print '
'; // Subject print ''; @@ -1336,6 +1364,7 @@ if ($action == 'create') { print '
'.$langs->trans("MailTopic").'
'; + // Message print '
'; diff --git a/htdocs/comm/mailing/cibles.php b/htdocs/comm/mailing/cibles.php index 206909d1602..16b73702be0 100644 --- a/htdocs/comm/mailing/cibles.php +++ b/htdocs/comm/mailing/cibles.php @@ -32,6 +32,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formmailing.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/emailing.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/ajax.lib.php'; // Load translation files required by the page $langs->load("mails"); @@ -99,14 +100,22 @@ if ($action == 'add' && $user->hasRight('mailing', 'creer')) { // Add recipient $classname = "mailing_".$module; if (file_exists($file)) { - require_once $file; + include_once $file; // Add targets into database - $obj = new $classname($db); - dol_syslog("Call add_to_target on class ".$classname); - $result = $obj->add_to_target($id); + dol_syslog("Call add_to_target() on class ".$classname." evenunsubscribe=".$object->evenunsubscribe); - $sqlmessage = $obj->sql; + if (class_exists($classname)) { + $obj = new $classname($db); + $obj->evenunsubscribe = $object->evenunsubscribe; + + $result = $obj->add_to_target($id); + + $sqlmessage = $obj->sql; + } else { + $result = -1; + break; + } } } if ($result > 0) { @@ -198,6 +207,38 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_dest_status = ''; } +// Action update description of emailing +if ($action == 'settitle' || $action == 'setemail_from' || $action == 'setreplyto' || $action == 'setemail_errorsto' || $action == 'setevenunsubscribe') { + $upload_dir = $conf->mailing->dir_output."/".get_exdir($object->id, 2, 0, 1, $object, 'mailing'); + + if ($action == 'settitle') { + $object->title = trim(GETPOST('title', 'alpha')); + } elseif ($action == 'setemail_from') { + $object->email_from = trim(GETPOST('email_from', 'alphawithlgt')); // Must allow 'name ' + } elseif ($action == 'setemail_replyto') { + $object->email_replyto = trim(GETPOST('email_replyto', 'alphawithlgt')); // Must allow 'name ' + } elseif ($action == 'setemail_errorsto') { + $object->email_errorsto = trim(GETPOST('email_errorsto', 'alphawithlgt')); // Must allow 'name ' + } elseif ($action == 'settitle' && empty($object->title)) { + $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailTitle")); + } elseif ($action == 'setfrom' && empty($object->email_from)) { + $mesg = $langs->trans("ErrorFieldRequired", $langs->transnoentities("MailFrom")); + } elseif ($action == 'setevenunsubscribe') { + $object->evenunsubscribe = (GETPOST('evenunsubscribe') ? 1 : 0); + } + + if (!$mesg) { + $result = $object->update($user); + if ($result >= 0) { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + $mesg = $object->error; + } + + setEventMessages($mesg, null, 'errors'); + $action = ""; +} /* @@ -224,7 +265,7 @@ if ($object->fetch($id) >= 0) { $morehtmlright = ''; $nbtry = $nbok = 0; - if ($object->statut == 2 || $object->statut == 3) { + if ($object->statut == $object::STATUS_SENTPARTIALY || $object->statut == $object::STATUS_SENTCOMPLETELY) { $nbtry = $object->countNbOfTargets('alreadysent'); $nbko = $object->countNbOfTargets('alreadysentko'); $nbok = ($nbtry - $nbko); @@ -239,13 +280,12 @@ if ($object->fetch($id) >= 0) { dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', $morehtmlright); print '
'; + print '
'; print '
'; print ''; - //print ''; - - print ''; // Errors to - print ''; - // Nb of distinct emails - print '
'.$langs->trans("MailTitle").''.$object->title.'
'.$langs->trans("MailFrom").''; + print '
'.$langs->trans("MailFrom").''; $emailarray = CMailFile::getArrayAddress($object->email_from); foreach ($emailarray as $email => $name) { if ($name && $name != $email) { @@ -264,7 +304,7 @@ if ($object->fetch($id) >= 0) { print '
'.$langs->trans("MailErrorsTo").''; + print '
'.$langs->trans("MailErrorsTo").''; $emailarray = CMailFile::getArrayAddress($object->email_errorsto); foreach ($emailarray as $email => $name) { if ($name != $email) { @@ -280,10 +320,19 @@ if ($object->fetch($id) >= 0) { } print '
'; + print '
'; + print '
'; + + + print '
'; + print '
'; + + print ''; + + // Number of distinct emails + print ''; - print '
'; print $langs->trans("TotalNbOfDistinctRecipients"); - print ''; + print ''; $nbemail = ($object->nbemail ? $object->nbemail : 0); if (is_numeric($nbemail)) { $text = ''; @@ -295,7 +344,7 @@ if ($object->fetch($id) >= 0) { } } if (empty($nbemail)) { - $nbemail .= ' '.img_warning('');//.' '.$langs->trans("NoTargetYet").''; + $nbemail .= ' '.img_warning($langs->trans('ToAddRecipientsChooseHere'));//.' '.$langs->trans("NoTargetYet").''; } if ($text) { print $form->textwithpicto($nbemail, $text, 1, 'warning'); @@ -305,16 +354,21 @@ if ($object->fetch($id) >= 0) { } print '
'; + // Other attributes. Fields from hook formObjectOptions and Extrafields. + include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_view.tpl.php'; - print "
"; + print ''; + print '
'; + print '
'; + + print '
'; print dol_get_fiche_end(); print '
'; - $allowaddtarget = ($object->statut == 0); + $allowaddtarget = ($object->statut == $object::STATUS_DRAFT); // Show email selectors if ($allowaddtarget && $user->rights->mailing->creer) { @@ -327,7 +381,11 @@ if ($object->fetch($id) >= 0) { print '
'; print '
'.$langs->trans("RecipientSelectionModules").'
'; print '
'.$langs->trans("NbOfUniqueEMails").'
'; - print '
'.$langs->trans("Filter").'
'; + print '
'.$langs->trans("Filters"); + print '    
'.$langs->trans("EvenUnsubscribe").' '; + print ajax_object_onoff($object, 'evenunsubscribe', 'evenunsubscribe', 'EvenUnsubscribe:switch_on:warning', 'EvenUnsubscribe', array(), 'small valignmiddle', '', 1); + print '
'; + print '
'; print '
 
'; print '
'; // End tr @@ -386,8 +444,9 @@ if ($object->fetch($id) >= 0) { $var = !$var; if ($allowaddtarget) { - print ''; + print ''; print ''; + print ''; print ''; } else { print '
'; @@ -404,6 +463,8 @@ if ($object->fetch($id) >= 0) { print '
'; try { + $obj->evenunsubscribe = $object->evenunsubscribe; // Set flag to include/exclude email that has opt-out. + $nbofrecipient = $obj->getNbOfRecipients(''); } catch (Exception $e) { dol_syslog($e->getMessage(), LOG_ERR); @@ -470,8 +531,10 @@ if ($object->fetch($id) >= 0) { // List of selected targets $sql = "SELECT mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut, mc.date_envoi, mc.tms,"; - $sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text"; + $sql .= " mc.source_url, mc.source_id, mc.source_type, mc.error_text,"; + $sql .= " COUNT(mu.rowid) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing_cibles as mc"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."mailing_unsubscribe as mu ON mu.email = mc.email"; $sql .= " WHERE mc.fk_mailing=".((int) $object->id); $asearchcriteriahasbeenset = 0; if ($search_lastname) { @@ -494,8 +557,10 @@ if ($object->fetch($id) >= 0) { $sql .= " AND mc.statut = ".((int) $search_dest_status); $asearchcriteriahasbeenset++; } + $sql .= ' GROUP BY mc.rowid, mc.lastname, mc.firstname, mc.email, mc.other, mc.statut, mc.date_envoi, mc.tms, mc.source_url, mc.source_id, mc.source_type, mc.error_text'; $sql .= $db->order($sortfield, $sortorder); + // Count total nb of records $nbtotalofrecords = ''; if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) { @@ -578,6 +643,14 @@ if ($object->fetch($id) >= 0) { // Ligne des champs de filtres print ''; + + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); + print $searchpicto; + print ''; + } // EMail print ''; print ''; @@ -614,10 +687,13 @@ if ($object->fetch($id) >= 0) { print $formmailing->selectDestinariesStatus($search_dest_status, 'search_dest_status', 1); print ''; // Action column - print ''; - $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); - print $searchpicto; - print ''; + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1); + print $searchpicto; + print ''; + } + print ''; if ($page) { @@ -625,6 +701,10 @@ if ($object->fetch($id) >= 0) { } print ''; + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); + } print_liste_field_titre("EMail", $_SERVER["PHP_SELF"], "mc.email", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("Lastname", $_SERVER["PHP_SELF"], "mc.lastname", $param, "", "", $sortfield, $sortorder); print_liste_field_titre("Firstname", $_SERVER["PHP_SELF"], "mc.firstname", $param, "", "", $sortfield, $sortorder); @@ -635,7 +715,10 @@ if ($object->fetch($id) >= 0) { // Date sending print_liste_field_titre("DateSending", $_SERVER["PHP_SELF"], "mc.date_envoi", $param, '', 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "mc.statut", $param, '', 'class="right"', $sortfield, $sortorder); - print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); + } print ''; $i = 0; @@ -656,10 +739,37 @@ if ($object->fetch($id) >= 0) { $obj = $db->fetch_object($resql); print ''; - print ''.img_picto('$obj->email', 'email', 'class="paddingright"').dol_escape_htmltag($obj->email).''; + + // Action column + if (getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + print ''; + if ($obj->statut == $object::STATUS_DRAFT) { // Not sent yet + if (!empty($user->rights->mailing->creer)) { + print ''.img_delete($langs->trans("RemoveRecipient")).''; + } + } + /*if ($obj->statut == -1) // Sent with error + { + print ''.$langs->trans("Retry").''; + }*/ + print ''; + } + + print ''; + print img_picto($obj->email, 'email', 'class="paddingright"'); + if ($obj->nb > 0) { + print img_warning($langs->trans("EmailOptedOut"), 'warning', 'pictofixedwidth'); + } + print dol_escape_htmltag($obj->email); + print ''; + print ''.dol_escape_htmltag($obj->lastname).''; + print ''.dol_escape_htmltag($obj->firstname).''; + print ''.dol_escape_htmltag($obj->other).''; + print ''; if (empty($obj->source_id) || empty($obj->source_type)) { print empty($obj->source_url) ? '' : $obj->source_url; // For backward compatibility @@ -691,7 +801,7 @@ if ($object->fetch($id) >= 0) { print ''; // Status of recipient sending email (Warning != status of emailing) - if ($obj->statut == 0) { + if ($obj->statut == $object::STATUS_DRAFT) { // Date sent print ''; @@ -707,19 +817,21 @@ if ($object->fetch($id) >= 0) { print ''; } - // Search Icon - print ''; - print ''; - if ($obj->statut == 0) { // Not sent yet - if (!empty($user->rights->mailing->creer)) { - print ''.img_delete($langs->trans("RemoveRecipient")).''; + // Action column + if (!getDolGlobalString('MAIN_CHECKBOX_LEFT_COLUMN')) { + print ''; + print ''; + if ($obj->statut == $object::STATUS_DRAFT) { // Not sent yet + if (!empty($user->rights->mailing->creer)) { + print ''.img_delete($langs->trans("RemoveRecipient")).''; + } } + /*if ($obj->statut == -1) // Sent with error + { + print ''.$langs->trans("Retry").''; + }*/ + print ''; } - /*if ($obj->statut == -1) // Sent with error - { - print ''.$langs->trans("Retry").''; - }*/ - print ''; print ''; $i++; diff --git a/htdocs/comm/mailing/class/mailing.class.php b/htdocs/comm/mailing/class/mailing.class.php index e5cda94aa9f..451478e8058 100644 --- a/htdocs/comm/mailing/class/mailing.class.php +++ b/htdocs/comm/mailing/class/mailing.class.php @@ -357,9 +357,10 @@ class Mailing extends CommonObject * Get object from database * * @param int $rowid Id of emailing + * @param string $ref Title to search from title * @return int <0 if KO, >0 if OK */ - public function fetch($rowid) + public function fetch($rowid, $ref = '') { global $conf; @@ -372,7 +373,12 @@ class Mailing extends CommonObject $sql .= ", m.date_envoi"; $sql .= ", m.extraparams"; $sql .= " FROM ".MAIN_DB_PREFIX."mailing as m"; - $sql .= " WHERE m.rowid = ".(int) $rowid; + $sql .= " WHERE entity IN (".getEntity('mailing').")"; + if ($ref) { + $sql .= " AND m.titre = '".$this->db->escape($ref)."'"; + } else { + $sql .= " AND m.rowid = ".(int) $rowid; + } dol_syslog(get_class($this)."::fetch", LOG_DEBUG); $result = $this->db->query($sql); @@ -899,7 +905,7 @@ class Mailing extends CommonObject /** - * Return the label of a given status of a recipient + * Return the label of a given status of a recipient * TODO Add class mailin_target.class.php * * @param int $status Id status diff --git a/htdocs/compta/bank/class/account.class.php b/htdocs/compta/bank/class/account.class.php index f9a665640cd..c036a0b3414 100644 --- a/htdocs/compta/bank/class/account.class.php +++ b/htdocs/compta/bank/class/account.class.php @@ -2589,10 +2589,10 @@ class AccountLine extends CommonObjectLine /** - * Return label of status (activity, closed) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long - * @return string Libelle + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { @@ -2601,11 +2601,11 @@ class AccountLine extends CommonObjectLine // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @param int $status Id statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle du statut + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { diff --git a/htdocs/compta/bank/class/paymentvarious.class.php b/htdocs/compta/bank/class/paymentvarious.class.php index 912f46e074a..7029bddb6d1 100644 --- a/htdocs/compta/bank/class/paymentvarious.class.php +++ b/htdocs/compta/bank/class/paymentvarious.class.php @@ -603,10 +603,10 @@ class PaymentVarious extends CommonObject /** - * Retourne le libelle du statut + * Return the label of the status * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto - * @return string Libelle + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { @@ -615,11 +615,11 @@ class PaymentVarious extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto - * @return string Libelle + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { diff --git a/htdocs/compta/deplacement/class/deplacement.class.php b/htdocs/compta/deplacement/class/deplacement.class.php index fa812a14c3d..c0254f6c316 100644 --- a/htdocs/compta/deplacement/class/deplacement.class.php +++ b/htdocs/compta/deplacement/class/deplacement.class.php @@ -338,10 +338,10 @@ class Deplacement extends CommonObject /** - * Retourne le libelle du statut + * Return the label of the status * - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto - * @return string Libelle + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { @@ -350,11 +350,11 @@ class Deplacement extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto - * @return string Libelle + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index 95647d0f65e..7adb74fbc4e 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -604,10 +604,10 @@ class Localtax extends CommonObject } /** - * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { @@ -616,16 +616,16 @@ class Localtax extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @param int $status Statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle du statut + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { // phpcs:enable - global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + //global $langs; return ''; } diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index e84b0004564..3732c37ab2f 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -995,10 +995,10 @@ class RemiseCheque extends CommonObject } /** - * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { @@ -1007,11 +1007,11 @@ class RemiseCheque extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return label of a status + * Return the label of a given status * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto - * @return string Libelle du statut + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { diff --git a/htdocs/compta/paiement/class/paiement.class.php b/htdocs/compta/paiement/class/paiement.class.php index f573ec5be56..4be546c792c 100644 --- a/htdocs/compta/paiement/class/paiement.class.php +++ b/htdocs/compta/paiement/class/paiement.class.php @@ -1303,10 +1303,10 @@ class Paiement extends CommonObject } /** - * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { @@ -1315,11 +1315,11 @@ class Paiement extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @param int $status Statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle du statut + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { diff --git a/htdocs/compta/payment_vat/card.php b/htdocs/compta/payment_vat/card.php index 6089f9dbcb5..88650256ecc 100644 --- a/htdocs/compta/payment_vat/card.php +++ b/htdocs/compta/payment_vat/card.php @@ -222,11 +222,8 @@ print dol_get_fiche_end(); $disable_delete = 0; $sql = 'SELECT f.rowid as scid, f.label as label, f.paye, f.amount as tva_amount, pf.amount'; -//$sql .= ', pc.libelle as sc_type'; $sql .= ' FROM '.MAIN_DB_PREFIX.'payment_vat as pf,'.MAIN_DB_PREFIX.'tva as f'; -//$sql .= ', '.MAIN_DB_PREFIX.'c_chargesociales as pc'; $sql .= ' WHERE pf.fk_tva = f.rowid'; -//$sql .= ' AND f.fk_type = pc.id'; $sql .= ' AND f.entity = '.$conf->entity; $sql .= ' AND pf.rowid = '.((int) $object->id); diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 3618817e19a..f4f88885a00 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1888,7 +1888,7 @@ class BonPrelevement extends CommonObject fputs($this->file, substr("000000000000000".$montant, -16)); - // Libelle F + // Label F fputs($this->file, substr("*_".$ref."_RDVnet".$rowid." ", 0, 31)); diff --git a/htdocs/compta/sociales/class/cchargesociales.class.php b/htdocs/compta/sociales/class/cchargesociales.class.php index d03132b04f7..741179d067e 100644 --- a/htdocs/compta/sociales/class/cchargesociales.class.php +++ b/htdocs/compta/sociales/class/cchargesociales.class.php @@ -441,9 +441,9 @@ class Cchargesociales } /** - * Retourne le libelle du status d'un user (actif, inactif) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ public function getLibStatut($mode = 0) @@ -453,11 +453,11 @@ class Cchargesociales // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un status donne + * Return the label of a given status * - * @param int $status Id status - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 73d101d7ae6..a798eee92bb 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -664,10 +664,10 @@ class PaymentSocialContribution extends CommonObject /** - * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { @@ -676,11 +676,11 @@ class PaymentSocialContribution extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @param int $status Statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle du statut + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index fcc241c728d..3a088ca30b5 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -663,16 +663,16 @@ class PaymentVAT extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @param int $status Statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle du statut + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { // phpcs:enable - global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + global $langs; $langs->load('compta'); /*if ($mode == 0) diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 2be181d7350..15e8dc8609a 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -849,7 +849,7 @@ class Tva extends CommonObject } /** - * Retourne le libelle du statut d'une TVA (impaye, payee) + * Return the label of the VAT status f object * * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) @@ -862,7 +862,7 @@ class Tva extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given VAT status * * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index eddba0b5ad3..23fcf2d8c0a 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1580,10 +1580,10 @@ class Contact extends CommonObject } /** - * Return label of contact status + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of contact status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode) { @@ -1592,11 +1592,11 @@ class Contact extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @param int $status Id statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode) { @@ -2009,9 +2009,9 @@ class Contact extends CommonObject /** * Return status of prospect * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long + * @param int $mode 0=label long, 1=label short, 2=Picto + Label short, 3=Picto, 4=Picto + Label long * @param string $label Label to use for status for added status - * @return string Libelle + * @return string Label */ public function getLibProspCommStatut($mode = 0, $label = '') { @@ -2029,7 +2029,7 @@ class Contact extends CommonObject * Example: picto.png if picto.png is stored into htdocs/theme/mytheme/img * Example: picto.png@mymodule if picto.png is stored into htdocs/mymodule/img * Example: /mydir/mysubdir/picto.png if picto.png is stored into htdocs/mydir/mysubdir (pictoisfullpath must be set to 1) - * @return string Libelle du statut + * @return string Label of status */ public function libProspCommStatut($statut, $mode = 0, $label = '', $picto = '') { diff --git a/htdocs/core/ajax/objectonoff.php b/htdocs/core/ajax/objectonoff.php index ed670627a90..5166ba52b52 100644 --- a/htdocs/core/ajax/objectonoff.php +++ b/htdocs/core/ajax/objectonoff.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2015-2023 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,7 +17,7 @@ /** * \file htdocs/core/ajax/objectonoff.php - * \brief File to set status for an object + * \brief File to set status for an object. Called when ajax_object_onoff() is used. * This Ajax service is oftenly called when option MAIN_DIRECT_STATUS_UPDATE is set. */ @@ -45,6 +45,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; $action = GETPOST('action', 'aZ09'); +$backtopage = GETPOST('backtopage'); $id = GETPOST('id', 'int'); $element = GETPOST('element', 'alpha'); // 'myobject' (myobject=mymodule) or 'myobject@mymodule' or 'myobject_mysubobject' (myobject=mymodule) @@ -79,7 +80,7 @@ if (!empty($user->socid)) { // We check permission. // Check is done on $user->rights->element->create or $user->rights->element->subelement->create (because $action = 'set') -if (preg_match('/status$/', $field)) { +if (preg_match('/status$/', $field) || ($field == 'evenunsubscribe' && $object->table_element == 'mailing')) { restrictedArea($user, $object->module, $object, $object->table_element, $usesublevelpermission); } elseif ($element == 'product' && in_array($field, array('tosell', 'tobuy', 'tobatch'))) { // Special case for products restrictedArea($user, 'produit|service', $object, 'product&product', '', '', 'rowid'); @@ -114,4 +115,9 @@ if (($action == 'set') && !empty($id)) { http_response_code(500); exit; } + + if ($backtopage) { + header('Location: '.$backtopage); + exit; + } } diff --git a/htdocs/core/class/emailsenderprofile.class.php b/htdocs/core/class/emailsenderprofile.class.php index c43ba48db10..229e5b9e352 100644 --- a/htdocs/core/class/emailsenderprofile.class.php +++ b/htdocs/core/class/emailsenderprofile.class.php @@ -305,10 +305,10 @@ class EmailSenderProfile extends CommonObject } /** - * Retourne le libelle du status d'un user (actif, inactif) + * Return the label of a given status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { @@ -317,11 +317,11 @@ class EmailSenderProfile extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return the status + * Return the label of a given status * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label of status + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public static function LibStatut($status, $mode = 0) { diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 73a8b86ea47..2ae0529b14a 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1267,7 +1267,7 @@ class ExtraFields $labeltoshow = ''; $obj = $this->db->fetch_object($resql); - // Several field into label (eq table:code|libelle:rowid) + // Several field into label (eq table:code|label:rowid) $notrans = false; $fields_label = explode('|', $InfoFieldList[1]); if (is_array($fields_label) && count($fields_label) > 1) { @@ -1487,7 +1487,7 @@ class ExtraFields $obj = $this->db->fetch_object($resql); $notrans = false; - // Several field into label (eq table:code|libelle:rowid) + // Several field into label (eq table:code|label:rowid) $fields_label = explode('|', $InfoFieldList[1]); if (is_array($fields_label)) { $notrans = true; @@ -1722,7 +1722,7 @@ class ExtraFields $obj = $this->db->fetch_object($resql); - // Several field into label (eq table:code|libelle:rowid) + // Several field into label (eq table:code|label:rowid) $fields_label = explode('|', $InfoFieldList[1]); if (is_array($fields_label) && count($fields_label) > 1) { @@ -1830,7 +1830,7 @@ class ExtraFields $value = ''; // value was used, so now we reste it to use it to build final output $toprint = array(); while ($obj = $this->db->fetch_object($resql)) { - // Several field into label (eq table:code|libelle:rowid) + // Several field into label (eq table:code|label:rowid) $fields_label = explode('|', $InfoFieldList[1]); if (is_array($value_arr) && in_array($obj->rowid, $value_arr)) { if (is_array($fields_label) && count($fields_label) > 1) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 73aefd0c3f7..c45ab42fec0 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -196,7 +196,7 @@ class Form * @param string $value Value to show/edit * @param object $object Object (that we want to show) * @param boolean $perm Permission to allow button to edit parameter - * @param string $typeofdata Type of data ('string' by default, 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols%', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datehourpicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select;xkey:xval,ykey:yval,...') + * @param string $typeofdata Type of data ('string' by default, 'checkbox', 'email', 'amount:99', 'numeric:99', 'text' or 'textarea:rows:cols%', 'datepicker' ('day' do not work, don't know why), 'dayhour' or 'datehourpicker', 'ckeditor:dolibarr_zzz:width:height:savemethod:toolbarstartexpanded:rows:cols', 'select;xkey:xval,ykey:yval,...') * @param string $editvalue When in edit mode, use this value as $value instead of value (for example, you can provide here a formated price instead of numeric value, or a select combo). Use '' to use same than $value * @param object $extObject External object ??? * @param mixed $custommsg String or Array of custom messages : eg array('success' => 'MyMessage', 'error' => 'MyMessage') @@ -267,7 +267,7 @@ class Form $ret .= ''; } elseif (preg_match('/^(checkbox)/', $typeofdata)) { $tmp = explode(':', $typeofdata); - $ret .= ''; + $ret .= ''; } elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) { // if wysiwyg is enabled $typeofdata = 'ckeditor' $tmp = explode(':', $typeofdata); $cols = (empty($tmp[2]) ? '' : $tmp[2]); @@ -342,7 +342,7 @@ class Form $ret .= ($value != '' ? price($value, '', $langs, 0, -1, -1, $conf->currency) : ''); } elseif (preg_match('/^(checkbox)/', $typeofdata)) { $tmp = explode(':', $typeofdata); - $ret .= ''; + $ret .= ''; } elseif (preg_match('/^text/', $typeofdata) || preg_match('/^note/', $typeofdata)) { $ret .= dol_htmlentitiesbr($value); } elseif (preg_match('/^safehtmlstring/', $typeofdata)) { diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index c6eb249be5c..e7b0207595a 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -476,13 +476,17 @@ class SMTPs if (!is_numeric($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) { // If value of MAIL_SMTP_USE_FROM_FOR_HELO is a string, we use it as domain name $hosth = $conf->global->MAIL_SMTP_USE_FROM_FOR_HELO; - } else { + } elseif ($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO == 1) { // If value of MAIL_SMTP_USE_FROM_FOR_HELO is 1, we use the domain in the from. // So if the from to is 'aaa ', we will keep 'ccc.com' $hosth = $this->getFrom('addr'); $hosth = preg_replace('/^.*.*$/', '', $hosth); $hosth = preg_replace('/.*@/', '', $hosth); + } elseif ($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO == 2) { + // If value of MAIL_SMTP_USE_FROM_FOR_HELO is 2, we use the domain in the $dolibarr_main_url_root. + global $dolibarr_main_url_root; + $hosth = getDomainFromURL($dolibarr_main_url_root, 1); } } diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index 043d9e6e18e..3a95809e6d4 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -690,29 +690,33 @@ function ajax_constantonoff($code, $input = array(), $entity = null, $revertonof } /** - * On/off button to change status of an object - * This is called when MAIN_DIRECT_STATUS_UPDATE is set and it use tha ajax service objectonoff.php + * On/off button to change a property status of an object + * This uses the ajax service objectonoff.php (May be called when MAIN_DIRECT_STATUS_UPDATE is set for some pages) * * @param Object $object Object to set * @param string $code Name of property in object : 'status' or 'status_buy' for product by example * @param string $field Name of database field : 'tosell' or 'tobuy' for product by example - * @param string $text_on Text if on ('Text' or 'Text:css picto on') - * @param string $text_off Text if off ('Text' or 'Text:css picto on') + * @param string $text_on Text if on ('Text' or 'Text:Picto on:Css picto on') + * @param string $text_off Text if off ('Text' or 'Text:Picto off:Css picto off') * @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid')) * @param string $morecss More CSS - * @param string $htmlname Name of HTML component. Keep '' or use a different value if you need to use this component several time on same page for same property. + * @param string $htmlname Name of HTML component. Keep '' or use a different value if you need to use this component several time on the same page for the same field. + * @param int $forcenojs Force the component to work as link post (without javascript) instead of ajax call * @return string html for button on/off */ -function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input = array(), $morecss = '', $htmlname = '') +function ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input = array(), $morecss = '', $htmlname = '', $forcenojs = 0) { - global $langs; + global $conf, $langs; if (empty($htmlname)) { $htmlname = $code; } //var_dump($object->module); var_dump($object->element); - $out = ''; + } $switchon = 'switch_on'; $switchoff = 'switch_off'; + $cssswitchon = ''; + $cssswitchoff = ''; $tmparray = explode(':', $text_on); if (!empty($tmparray[1])) { $text_on = $tmparray[0]; $switchon = $tmparray[1]; + if (!empty($tmparray[2])) { + $cssswitchon = $tmparray[2]; + } } $tmparray = explode(':', $text_off); if (!empty($tmparray[1])) { $text_off = $tmparray[0]; $switchoff = $tmparray[1]; + if (!empty($tmparray[2])) { + $cssswitchoff = $tmparray[2]; + } } - $out .= ''.img_picto($langs->trans($text_off), $switchoff).''; - $out .= ''.img_picto($langs->trans($text_on), $switchon).''; + if (empty($conf->use_javascript_ajax) || $forcenojs) { + $out .= ''.img_picto($langs->trans($text_off), $switchoff, '', false, 0, 0, '', $cssswitchoff).''; + $out .= ''.img_picto($langs->trans($text_on), $switchon, '', false, 0, 0, '', $cssswitchon).''; + } else { + $out .= ''.img_picto($langs->trans($text_off), $switchoff, '', false, 0, 0, '', $cssswitchoff).''; + $out .= ''.img_picto($langs->trans($text_on), $switchon, '', false, 0, 0, '', $cssswitchon).''; + } return $out; } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 18306842df6..c3fdbf377a3 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -9884,10 +9884,10 @@ function dol_getmypid() * like "keyword1 keyword2" = We want record field like keyword1 AND field like keyword2 * or like "keyword1|keyword2" = We want record field like keyword1 OR field like keyword2 * If param $mode is 1, can contains an operator <, > or = like "<10" or ">=100.5 < -1000" - * If param $mode is 2, can contains a list of int id separated by comma like "1,3,4" - * If param $mode is 3, can contains a list of string separated by comma like "a,b,c" - * @param integer $mode 0=value is list of keyword strings, 1=value is a numeric test (Example ">5.5 <10"), 2=value is a list of ID separated with comma (Example '1,3,4') - * 3=value is list of string separated with comma (Example 'text 1,text 2'), 4=value is a list of ID separated with comma (Example '2,7') to be used to search into a multiselect string '1,2,3,4' + * If param $mode is 2 or -2, can contains a list of int id separated by comma like "1,3,4" + * If param $mode is 3 or -3, can contains a list of string separated by comma like "a,b,c". + * @param integer $mode 0=value is list of keyword strings, 1=value is a numeric test (Example ">5.5 <10"), 2=value is a list of ID separated with comma (Example '1,3,4'), -2 is for exclude list, + * 3=value is list of string separated with comma (Example 'text 1,text 2'), -3 if for exclude list, 4=value is a list of ID separated with comma (Example '2,7') to be used to search into a multiselect string '1,2,3,4' * @param integer $nofirstand 1=Do not output the first 'AND' * @return string $res The statement to append to the SQL query * @see dolSqlDateFilter() @@ -9902,7 +9902,7 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) $value = preg_replace('/\*/', '%', $value); // Replace * with % } if ($mode == 1) { - $value = preg_replace('/([!<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"), '/').'\-])/', '\1\2', $value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do + $value = preg_replace('/([!<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"), '/').'\-])/', '\1\2', $value); // Clean string '< 10' into '<10' so we can then explode on space to get all tests to do } $value = preg_replace('/\s*\|\s*/', '|', $value); @@ -9913,16 +9913,15 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) $fields = array($fields); } - $j = 0; - foreach ($crits as $crit) { + $i1 = 0; // count the nb of and criteria added (all fields / criterias) + foreach ($crits as $crit) { // Loop on each AND criteria $crit = trim($crit); - $i = 0; - $i2 = 0; + $i2 = 0; // count the nb of valid criteria added for this this first criteria $newres = ''; foreach ($fields as $field) { if ($mode == 1) { $tmpcrits = explode('|', $crit); - $i3 = 0; // count the nb of valid criteria added for this field + $i3 = 0; // count the nb of valid criteria added for this current field foreach ($tmpcrits as $tmpcrit) { if ($tmpcrit !== '0' && empty($tmpcrit)) { continue; @@ -9949,7 +9948,7 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) $i3++; // a criteria was added to string } } - $i2++; + $i2++; // a criteria for 1 more field was added to string } elseif ($mode == 2 || $mode == -2) { $crit = preg_replace('/[^0-9,]/', '', $crit); // ID are always integer $newres .= ($i2 > 0 ? ' OR ' : '').$field." ".($mode == -2 ? 'NOT ' : ''); @@ -9957,7 +9956,7 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) if ($mode == -2) { $newres .= ' OR '.$field.' IS NULL'; } - $i2++; // a criteria was added to string + $i2++; // a criteria for 1 more field was added to string } elseif ($mode == 3 || $mode == -3) { $tmparray = explode(',', $crit); if (count($tmparray)) { @@ -9970,7 +9969,7 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) } } $newres .= ($i2 > 0 ? ' OR ' : '').$field." ".($mode == -3 ? 'NOT ' : '')."IN (".$db->sanitize($listofcodes, 1).")"; - $i2++; // a criteria was added to string + $i2++; // a criteria for 1 more field was added to string } if ($mode == -3) { $newres .= ' OR '.$field.' IS NULL'; @@ -9987,20 +9986,20 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) $newres .= ' OR '.$field." LIKE '%,".$db->escape($val)."'"; $newres .= ' OR '.$field." LIKE '%,".$db->escape($val).",%'"; $newres .= ')'; - $i2++; + $i2++; // a criteria for 1 more field was added to string (we can add several citeria for the same field as it is a multiselect search criteria) } } } } else { // $mode=0 $tmpcrits = explode('|', $crit); - $i3 = 0; // count the nb of valid criteria added for this field - foreach ($tmpcrits as $tmpcrit) { + $i3 = 0; // count the nb of valid criteria added for the current couple criteria/field + foreach ($tmpcrits as $tmpcrit) { // loop on each OR criteria if ($tmpcrit !== '0' && empty($tmpcrit)) { continue; } $tmpcrit = trim($tmpcrit); - if ($tmpcrit == '^$') { // If we search empty, we must combined different fields with AND + if ($tmpcrit == '^$' || strpos($crit, '!') === 0) { // If we search empty, we must combined different OR fields with AND $newres .= (($i2 > 0 || $i3 > 0) ? ' AND ' : ''); } else { $newres .= (($i2 > 0 || $i3 > 0) ? ' OR ' : ''); @@ -10046,15 +10045,15 @@ function natural_search($fields, $value, $mode = 0, $nofirstand = 0) $i3++; } - $i2++; // a criteria was added to string + + $i2++; // a criteria for 1 more field was added to string } - $i++; } if ($newres) { $res = $res.($res ? ' AND ' : '').($i2 > 1 ? '(' : '').$newres.($i2 > 1 ? ')' : ''); } - $j++; + $i1++; } $res = ($nofirstand ? "" : " AND ")."(".$res.")"; @@ -11329,6 +11328,12 @@ function getElementProperties($element_type) $classpath = 'contrat/class'; $module = 'contrat'; $subelement = 'contrat'; + } elseif ($element_type == 'mailing') { + $classpath = 'comm/mailing/class'; + $module = 'mailing'; + $classfile = 'mailing'; + $classname = 'Mailing'; + $subelement = ''; } elseif ($element_type == 'member') { $classpath = 'adherents/class'; $module = 'adherent'; @@ -11425,7 +11430,6 @@ function fetchObjectByElement($element_id, $element_type, $element_ref = '') $ret = 0; $element_prop = getElementProperties($element_type); - //var_dump($element_prop); if (is_array($element_prop) && isModEnabled($element_prop['module'])) { dol_include_once('/'.$element_prop['classpath'].'/'.$element_prop['classfile'].'.class.php'); diff --git a/htdocs/core/modules/action/rapport.class.php b/htdocs/core/modules/action/rapport.class.php index d4805143e59..a880b894b73 100644 --- a/htdocs/core/modules/action/rapport.class.php +++ b/htdocs/core/modules/action/rapport.class.php @@ -238,7 +238,7 @@ class CommActionRapport $sql = "SELECT s.nom as thirdparty, s.rowid as socid, s.client,"; $sql .= " a.id, a.datep as dp, a.datep2 as dp2,"; $sql .= " a.fk_contact, a.note, a.percent as percent, a.fulldayevent, a.label, a.fk_project,"; - $sql .= " c.code, c.libelle,"; + $sql .= " c.code, c.libelle as label_type,"; $sql .= " u.login"; $sql .= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; diff --git a/htdocs/core/modules/export/modules_export.php b/htdocs/core/modules/export/modules_export.php index 31b137f6465..0cad4f76509 100644 --- a/htdocs/core/modules/export/modules_export.php +++ b/htdocs/core/modules/export/modules_export.php @@ -107,7 +107,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac } /** - * Renvoi libelle d'un driver export + * Return label of driver export * * @param string $key Key of driver * @return string Label @@ -140,7 +140,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac } /** - * Renvoi libelle de librairie externe du driver + * Renvoi label of driver lib * * @param string $key Key of driver * @return string Label of library @@ -151,7 +151,7 @@ class ModeleExports extends CommonDocGenerator // This class can't be abstrac } /** - * Renvoi version de librairie externe du driver + * Return version of driver lib * * @param string $key Key of driver * @return string Version of library diff --git a/htdocs/core/modules/import/modules_import.php b/htdocs/core/modules/import/modules_import.php index 5fe408f6dd5..4ead826d27f 100644 --- a/htdocs/core/modules/import/modules_import.php +++ b/htdocs/core/modules/import/modules_import.php @@ -253,7 +253,7 @@ class ModeleImports } /** - * Renvoi libelle d'un driver import + * Return label of driver import * * @param string $key Key * @return string @@ -264,7 +264,7 @@ class ModeleImports } /** - * Renvoi la description d'un driver import + * Return description of import drivervoi la description d'un driver import * * @param string $key Key * @return string diff --git a/htdocs/core/modules/mailings/advthirdparties.modules.php b/htdocs/core/modules/mailings/advthirdparties.modules.php index 7649c255d04..6137bcca2ff 100644 --- a/htdocs/core/modules/mailings/advthirdparties.modules.php +++ b/htdocs/core/modules/mailings/advthirdparties.modules.php @@ -82,6 +82,9 @@ class mailing_advthirdparties extends MailingTargets $sql .= " FROM ".MAIN_DB_PREFIX."societe as s LEFT OUTER JOIN ".MAIN_DB_PREFIX."societe_extrafields se ON se.fk_object=s.rowid"; $sql .= " WHERE s.entity IN (".getEntity('societe').")"; $sql .= " AND s.rowid IN (".$this->db->sanitize(implode(',', $socid)).")"; + if (empty($this->evenunsubscribe)) { + $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = s.email and mu.entity = ".((int) $conf->entity).")"; + } $sql .= " ORDER BY email"; // Stock recipients emails into targets table @@ -132,6 +135,9 @@ class mailing_advthirdparties extends MailingTargets if (count($socid) > 0) { $sql .= " AND socp.fk_soc IN (".$this->db->sanitize(implode(',', $socid)).")"; } + if (empty($this->evenunsubscribe)) { + $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = socp.email and mu.entity = ".((int) $conf->entity).")"; + } $sql .= " ORDER BY email"; // Stock recipients emails into targets table @@ -211,6 +217,9 @@ class mailing_advthirdparties extends MailingTargets $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE s.email != ''"; $sql .= " AND s.entity IN (".getEntity('societe').")"; + if (empty($this->evenunsubscribe)) { + $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = s.email and mu.entity = ".((int) $conf->entity).")"; + } // La requete doit retourner un champ "nb" pour etre comprise par parent::getNbOfRecipients return parent::getNbOfRecipients($sql); diff --git a/htdocs/core/modules/mailings/contacts1.modules.php b/htdocs/core/modules/mailings/contacts1.modules.php index 2b8d17723cb..80db8513395 100644 --- a/htdocs/core/modules/mailings/contacts1.modules.php +++ b/htdocs/core/modules/mailings/contacts1.modules.php @@ -82,7 +82,6 @@ class mailing_contacts1 extends MailingTargets $statssql[0] .= " FROM ".MAIN_DB_PREFIX."socpeople as c"; $statssql[0] .= " WHERE c.entity IN (".getEntity('contact').")"; $statssql[0] .= " AND c.email <> ''"; // Note that null != '' is false - $statssql[0] .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = c.email) = 0"; $statssql[0] .= " AND c.statut = 1"; return $statssql; @@ -104,7 +103,9 @@ class mailing_contacts1 extends MailingTargets $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON s.rowid = c.fk_soc"; $sql .= " WHERE c.entity IN (".getEntity('contact').")"; $sql .= " AND c.email <> ''"; // Note that null != '' is false - $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = c.email) = 0"; + if (empty($this->evenunsubscribe)) { + $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = c.email and mu.entity = ".((int) $conf->entity).")"; + } // exclude unsubscribed users $sql .= " AND c.statut = 1"; @@ -331,7 +332,7 @@ class mailing_contacts1 extends MailingTargets // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Ajoute destinataires dans table des cibles + * Add some recipients into target table * * @param int $mailing_id Id of emailing * @return int <0 si erreur, nb ajout si ok @@ -389,7 +390,9 @@ class mailing_contacts1 extends MailingTargets $sql .= " WHERE sp.entity IN (".getEntity('contact').")"; $sql .= " AND sp.email <> ''"; - $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = sp.email) = 0"; + if (empty($this->evenunsubscribe)) { + $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = sp.email and mu.entity = ".((int) $conf->entity).")"; + } // Exclude unsubscribed email adresses $sql .= " AND sp.statut = 1"; $sql .= " AND sp.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".((int) $mailing_id).")"; diff --git a/htdocs/core/modules/mailings/eventorganization.modules.php b/htdocs/core/modules/mailings/eventorganization.modules.php index 0d0ffb63c3a..27af7ab52d8 100644 --- a/htdocs/core/modules/mailings/eventorganization.modules.php +++ b/htdocs/core/modules/mailings/eventorganization.modules.php @@ -85,6 +85,9 @@ class mailing_eventorganization extends MailingTargets $sql .= " AND p.entity IN (".getEntity('project').")"; $sql .= " AND e.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".((int) $mailing_id).")"; $sql .= " AND e.fk_project = ".((int) GETPOST('filter_eventorganization', 'int')); + if (empty($this->evenunsubscribe)) { + $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = e.email and mu.entity = ".((int) $conf->entity).")"; + } $sql .= " ORDER BY e.email"; // Stock recipients emails into targets table @@ -159,14 +162,15 @@ class mailing_eventorganization extends MailingTargets */ public function getNbOfRecipients($sql = '') { - global $conf; - $sql = "SELECT COUNT(DISTINCT(e.email)) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."eventorganization_conferenceorboothattendee as e, "; $sql .= " ".MAIN_DB_PREFIX."projet as p"; $sql .= " WHERE e.email <> ''"; $sql .= " AND e.fk_project = p.rowid"; $sql .= " AND p.entity IN (".getEntity('project').")"; + if (empty($this->evenunsubscribe)) { + $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = e.email and mu.entity = ".((int) $conf->entity).")"; + } //print $sql; diff --git a/htdocs/core/modules/mailings/fraise.modules.php b/htdocs/core/modules/mailings/fraise.modules.php index 8d55ac65864..65bb106ceb4 100644 --- a/htdocs/core/modules/mailings/fraise.modules.php +++ b/htdocs/core/modules/mailings/fraise.modules.php @@ -101,6 +101,9 @@ class mailing_fraise extends MailingTargets $sql = "SELECT count(distinct(a.email)) as nb"; $sql .= " FROM ".MAIN_DB_PREFIX."adherent as a"; $sql .= " WHERE (a.email IS NOT NULL AND a.email != '') AND a.entity IN (".getEntity('member').")"; + if (empty($this->evenunsubscribe)) { + $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = a.email and mu.entity = ".((int) $conf->entity).")"; + } // La requete doit retourner un champ "nb" pour etre comprise par parent::getNbOfRecipients return parent::getNbOfRecipients($sql); @@ -278,6 +281,9 @@ class mailing_fraise extends MailingTargets if (GETPOST('filter_type', 'int') > 0) { $sql .= " AND ta.rowid = ".((int) GETPOST('filter_type', 'int')); } + if (empty($this->evenunsubscribe)) { + $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = a.email and mu.entity = ".((int) $conf->entity).")"; + } $sql .= " ORDER BY a.email"; //print $sql; diff --git a/htdocs/core/modules/mailings/modules_mailings.php b/htdocs/core/modules/mailings/modules_mailings.php index b745934d94d..5a99a44dc0f 100644 --- a/htdocs/core/modules/mailings/modules_mailings.php +++ b/htdocs/core/modules/mailings/modules_mailings.php @@ -53,6 +53,12 @@ class MailingTargets // This can't be abstract as it is used for some method */ public $sql; + public $desc; + + public $name; + + public $evenunsubscribe = 0; // Set this to 1 if you want to flag you also want to include email in target that has opt-out. + /** * Constructor @@ -111,8 +117,11 @@ class MailingTargets // This can't be abstract as it is used for some method { $result = $this->db->query($sql); if ($result) { - $obj = $this->db->fetch_object($result); - return $obj->nb; + $total = 0; + while ($obj = $this->db->fetch_object($result)) { + $total += $obj->nb; + } + return $total; } else { $this->error = $this->db->lasterror(); return -1; @@ -149,7 +158,7 @@ class MailingTargets // This can't be abstract as it is used for some method $nb = $obj->nb; $sql = "UPDATE ".MAIN_DB_PREFIX."mailing"; - $sql .= " SET nbemail = ".$nb." WHERE rowid = ".((int) $mailing_id); + $sql .= " SET nbemail = ".((int) $nb)." WHERE rowid = ".((int) $mailing_id); if (!$this->db->query($sql)) { dol_syslog($this->db->error()); $this->error = $this->db->error(); @@ -162,11 +171,11 @@ class MailingTargets // This can't be abstract as it is used for some method } /** - * Add a list of targets int the database + * Add a list of targets into the database * * @param int $mailing_id Id of emailing * @param array $cibles Array with targets - * @return int < 0 si erreur, nb ajout si ok + * @return int < 0 if error, nb added if OK */ public function addTargetsToDatabase($mailing_id, $cibles) { @@ -186,15 +195,15 @@ class MailingTargets // This can't be abstract as it is used for some method $sql .= " lastname, firstname, email, other, source_url, source_id,"; $sql .= " tag,"; $sql .= " source_type)"; - $sql .= " VALUES (".$mailing_id.","; - $sql .= (empty($targetarray['fk_contact']) ? '0' : "'".$this->db->escape($targetarray['fk_contact'])."'").","; + $sql .= " VALUES (".((int) $mailing_id).","; + $sql .= (empty($targetarray['fk_contact']) ? '0' : (int) $targetarray['fk_contact']).","; $sql .= "'".$this->db->escape($targetarray['lastname'])."',"; $sql .= "'".$this->db->escape($targetarray['firstname'])."',"; $sql .= "'".$this->db->escape($targetarray['email'])."',"; $sql .= "'".$this->db->escape($targetarray['other'])."',"; $sql .= "'".$this->db->escape($targetarray['source_url'])."',"; $sql .= (empty($targetarray['source_id']) ? 'null' : "'".$this->db->escape($targetarray['source_id'])."'").","; - $sql .= "'".$this->db->escape(dol_hash($dolibarr_main_instance_unique_id.";".$targetarray['email'].";".$targetarray['lastname'].";".$mailing_id.";".$conf->global->MAILING_EMAIL_UNSUBSCRIBE_KEY, 'md5'))."',"; + $sql .= "'".$this->db->escape(dol_hash($dolibarr_main_instance_unique_id.";".$targetarray['email'].";".$targetarray['lastname'].";".((int) $mailing_id).";".getDolGlobalString('MAILING_EMAIL_UNSUBSCRIBE_KEY'), 'md5'))."',"; $sql .= "'".$this->db->escape($targetarray['source_type'])."')"; dol_syslog(__METHOD__, LOG_DEBUG); $result = $this->db->query($sql); @@ -232,16 +241,20 @@ class MailingTargets // This can't be abstract as it is used for some method $result=$this->db->query($sql); */ - $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles"; - $sql .= " SET statut=3"; - $sql .= " WHERE fk_mailing = ".((int) $mailing_id)." AND email IN (SELECT mu.email FROM ".MAIN_DB_PREFIX."mailing_unsubscribe AS mu WHERE mu.entity IN ('".getEntity('mailing')."'))"; + if (empty($this->evenunsubscribe)) { + $sql = "UPDATE ".MAIN_DB_PREFIX."mailing_cibles as mc"; + $sql .= " SET mc.statut = 3"; + $sql .= " WHERE mc.fk_mailing = ".((int) $mailing_id); + $sql .= " AND EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = mc.email and mu.entity = ".((int) $conf->entity).")"; - dol_syslog(__METHOD__.":mailing update status to display emails that do not want to be contacted anymore", LOG_DEBUG); - $result = $this->db->query($sql); - if (!$result) { - dol_print_error($this->db); + dol_syslog(__METHOD__.":mailing update status to display emails that do not want to be contacted anymore", LOG_DEBUG); + $result = $this->db->query($sql); + if (!$result) { + dol_print_error($this->db); + } } + // Update nb of recipient into emailing record $this->update_nb($mailing_id); $this->db->commit(); diff --git a/htdocs/core/modules/mailings/partnership.modules.php b/htdocs/core/modules/mailings/partnership.modules.php index b4a8e9d8fd9..07405c9f7ad 100644 --- a/htdocs/core/modules/mailings/partnership.modules.php +++ b/htdocs/core/modules/mailings/partnership.modules.php @@ -86,6 +86,9 @@ class mailing_partnership extends MailingTargets if (GETPOST('filter', 'int') > 0) { $sql .= " AND pt.rowid=".((int) GETPOST('filter', 'int')); } + if (empty($this->evenunsubscribe)) { + $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = s.email and mu.entity = ".((int) $conf->entity).")"; + } $sql .= " UNION "; @@ -99,6 +102,9 @@ class mailing_partnership extends MailingTargets if (GETPOST('filter', 'int') > 0) { $sql .= " AND pt.rowid=".((int) GETPOST('filter', 'int')); } + if (empty($this->evenunsubscribe)) { + $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = s.email and mu.entity = ".((int) $conf->entity).")"; + } $sql .= " ORDER BY email"; @@ -180,6 +186,9 @@ class mailing_partnership extends MailingTargets $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p, ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE s.rowid = p.fk_soc AND s.email <> ''"; $sql .= " AND s.entity IN (".getEntity('societe').")"; + if (empty($this->evenunsubscribe)) { + $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = s.email and mu.entity = ".((int) $conf->entity).")"; + } $sql .= " UNION "; @@ -187,6 +196,9 @@ class mailing_partnership extends MailingTargets $sql .= " FROM ".MAIN_DB_PREFIX."partnership as p, ".MAIN_DB_PREFIX."adherent as s"; $sql .= " WHERE s.rowid = p.fk_member AND s.email <> ''"; $sql .= " AND s.entity IN (".getEntity('member').")"; + if (empty($this->evenunsubscribe)) { + $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = s.email and mu.entity = ".((int) $conf->entity).")"; + } //print $sql; diff --git a/htdocs/core/modules/mailings/pomme.modules.php b/htdocs/core/modules/mailings/pomme.modules.php index 907028ca881..2d2dd7e1809 100644 --- a/htdocs/core/modules/mailings/pomme.modules.php +++ b/htdocs/core/modules/mailings/pomme.modules.php @@ -78,6 +78,7 @@ class mailing_pomme extends MailingTargets $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE u.email != ''"; // u.email IS NOT NULL est implicite dans ce test $sql .= " AND u.entity IN (0,".$conf->entity.")"; + $statssql[0] = $sql; return $statssql; @@ -100,6 +101,9 @@ class mailing_pomme extends MailingTargets $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; $sql .= " WHERE u.email != ''"; // u.email IS NOT NULL est implicite dans ce test $sql .= " AND u.entity IN (0,".$conf->entity.")"; + if (empty($this->evenunsubscribe)) { + $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = u.email and mu.entity = ".((int) $conf->entity).")"; + } // La requete doit retourner un champ "nb" pour etre comprise par parent::getNbOfRecipients return parent::getNbOfRecipients($sql); @@ -183,6 +187,9 @@ class mailing_pomme extends MailingTargets if (GETPOSTISSET("filteremployee") && GETPOST("filteremployee") == '0') { $sql .= " AND u.employee=0"; } + if (empty($this->evenunsubscribe)) { + $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = u.email and mu.entity = ".((int) $conf->entity).")"; + } $sql .= " ORDER BY u.email"; // Stocke destinataires dans cibles diff --git a/htdocs/core/modules/mailings/thirdparties.modules.php b/htdocs/core/modules/mailings/thirdparties.modules.php index fd91e5e849f..f34eb600228 100644 --- a/htdocs/core/modules/mailings/thirdparties.modules.php +++ b/htdocs/core/modules/mailings/thirdparties.modules.php @@ -142,6 +142,9 @@ class mailing_thirdparties extends MailingTargets $sql .= " WHERE s.email <> ''"; $sql .= " AND s.entity IN (".getEntity('societe').")"; $sql .= " AND s.email NOT IN (SELECT email FROM ".MAIN_DB_PREFIX."mailing_cibles WHERE fk_mailing=".((int) $mailing_id).")"; + if (empty($this->evenunsubscribe)) { + $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = s.email) = 0"; + } $sql .= $addFilter; } else { $sql = "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, c.label as label"; @@ -154,6 +157,9 @@ class mailing_thirdparties extends MailingTargets if (GETPOST('filter_thirdparties', 'int') > 0) { $sql .= " AND c.rowid=".((int) GETPOST('filter_thirdparties', 'int')); } + if (empty($this->evenunsubscribe)) { + $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = s.email) = 0"; + } $sql .= $addFilter; $sql .= " UNION "; $sql .= "SELECT s.rowid as id, s.email as email, s.nom as name, null as fk_contact, null as firstname, c.label as label"; @@ -166,6 +172,9 @@ class mailing_thirdparties extends MailingTargets if (GETPOST('filter_thirdparties', 'int') > 0) { $sql .= " AND c.rowid=".((int) GETPOST('filter_thirdparties', 'int')); } + if (empty($this->evenunsubscribe)) { + $sql .= " AND (SELECT count(*) FROM ".MAIN_DB_PREFIX."mailing_unsubscribe WHERE email = s.email) = 0"; + } $sql .= $addFilter; } $sql .= " ORDER BY email"; @@ -250,7 +259,10 @@ class mailing_thirdparties extends MailingTargets $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql .= " WHERE s.email <> ''"; $sql .= " AND s.entity IN (".getEntity('societe').")"; - $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = s.email and mu.entity = ".((int) $conf->entity).")"; + if (empty($this->evenunsubscribe)) { + $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = s.email and mu.entity = ".((int) $conf->entity).")"; + } + // La requete doit retourner un champ "nb" pour etre comprise par parent::getNbOfRecipients return parent::getNbOfRecipients($sql); } diff --git a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php index 9fc43e37388..acbbe4db46c 100644 --- a/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php +++ b/htdocs/core/modules/mailings/thirdparties_services_expired.modules.php @@ -116,6 +116,9 @@ class mailing_thirdparties_services_expired extends MailingTargets $sql .= " AND s.rowid = c.fk_soc AND cd.fk_contrat = c.rowid AND s.email != ''"; $sql .= " AND cd.statut= 4 AND cd.fk_product=p.rowid AND p.ref = '".$this->db->escape($product)."'"; $sql .= " AND cd.date_fin_validite < '".$this->db->idate($now)."'"; + if (empty($this->evenunsubscribe)) { + $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = s.email and mu.entity = ".((int) $conf->entity).")"; + } $sql .= " ORDER BY s.email"; // Stocke destinataires dans cibles @@ -201,6 +204,9 @@ class mailing_thirdparties_services_expired extends MailingTargets $sql .= " AND cd.statut= 4 AND cd.fk_product=p.rowid"; $sql .= " AND p.ref IN (".$this->db->sanitize("'".join("','", $this->arrayofproducts)."'", 1).")"; $sql .= " AND cd.date_fin_validite < '".$this->db->idate($now)."'"; + if (empty($this->evenunsubscribe)) { + $sql .= " AND NOT EXISTS (SELECT rowid FROM ".MAIN_DB_PREFIX."mailing_unsubscribe as mu WHERE mu.email = s.email and mu.entity = ".((int) $conf->entity).")"; + } $a = parent::getNbOfRecipients($sql); diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index 7e288f265ba..010ea7b6f32 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1479,7 +1479,7 @@ class Cronjob extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return label of a giver status * * @param int $status Id statut * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index bf8f68b3bbf..472db131563 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -899,10 +899,10 @@ class Delivery extends CommonObject /** - * Retourne le libelle du statut d'une expedition + * Return the label of the status * - * @param int $mode Mode - * @return string Label + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { @@ -911,11 +911,11 @@ class Delivery extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @param int $status Id status - * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto - * @return string Label + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode) { diff --git a/htdocs/don/class/paymentdonation.class.php b/htdocs/don/class/paymentdonation.class.php index 1769033df28..ca7ee4f3399 100644 --- a/htdocs/don/class/paymentdonation.class.php +++ b/htdocs/don/class/paymentdonation.class.php @@ -507,10 +507,10 @@ class PaymentDonation extends CommonObject /** - * Retourne le libelle du statut d'un don (brouillon, validee, abandonnee, payee) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long - * @return string Libelle + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { @@ -519,11 +519,11 @@ class PaymentDonation extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @param int $status Id status - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle du statut + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { diff --git a/htdocs/ecm/class/ecmdirectory.class.php b/htdocs/ecm/class/ecmdirectory.class.php index 21a43565a25..d0c3657ca07 100644 --- a/htdocs/ecm/class/ecmdirectory.class.php +++ b/htdocs/ecm/class/ecmdirectory.class.php @@ -589,9 +589,9 @@ class EcmDirectory extends CommonObject /** - * Retourne le libelle du status d'un user (actif, inactif) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ public function getLibStatut($mode = 0) diff --git a/htdocs/ecm/class/ecmfiles.class.php b/htdocs/ecm/class/ecmfiles.class.php index e9015c08acb..6851abd0b81 100644 --- a/htdocs/ecm/class/ecmfiles.class.php +++ b/htdocs/ecm/class/ecmfiles.class.php @@ -918,9 +918,9 @@ class EcmFiles extends CommonObject } /** - * Retourne le libelle du status d'un user (actif, inactif) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ public function getLibStatut($mode = 0) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index 550ebeca35b..b0e283fc17a 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -2228,6 +2228,8 @@ class EmailCollector extends CommonObject } } } + } else { + dol_syslog("One and only one existing third party has been found"); } } } @@ -2723,6 +2725,8 @@ class EmailCollector extends CommonObject } } } + } else { + $operationslog .= '
Project already exists for msgid ='.dol_escape_htmltag($msgid); } } elseif ($operation['type'] == 'ticket') { // Create ticket diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 8f024665a77..0f7bedc19d3 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1874,7 +1874,7 @@ class Expedition extends CommonObject * Return status label * * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto - * @return string Libelle + * @return string Label */ public function getLibStatut($mode = 0) { diff --git a/htdocs/expensereport/class/paymentexpensereport.class.php b/htdocs/expensereport/class/paymentexpensereport.class.php index 4fe23ae589c..b065bbb5f16 100644 --- a/htdocs/expensereport/class/paymentexpensereport.class.php +++ b/htdocs/expensereport/class/paymentexpensereport.class.php @@ -445,10 +445,10 @@ class PaymentExpenseReport extends CommonObject /** - * Retourne le libelle du statut d'un don (brouillon, validee, abandonnee, payee) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long - * @return string Libelle + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { @@ -457,16 +457,16 @@ class PaymentExpenseReport extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @param int $status Id status - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle du statut + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { // phpcs:enable - global $langs; + //global $langs; return ''; } diff --git a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php index 02fbff5b363..e4bccaa0980 100644 --- a/htdocs/fourn/class/fournisseur.commande.dispatch.class.php +++ b/htdocs/fourn/class/fournisseur.commande.dispatch.class.php @@ -86,6 +86,7 @@ class CommandeFournisseurDispatch extends CommonObjectLine public $qty_asked; public $libelle; + public $label; public $desc; public $tva_tx; public $vat_src_code; diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index b587922b71d..816580d3167 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -581,10 +581,10 @@ class PaiementFourn extends Paiement } /** - * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { @@ -593,11 +593,11 @@ class PaiementFourn extends Paiement // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @param int $status Statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle du statut + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { diff --git a/htdocs/fourn/facture/card-rec.php b/htdocs/fourn/facture/card-rec.php index 8eb628d697f..fb8179f2042 100644 --- a/htdocs/fourn/facture/card-rec.php +++ b/htdocs/fourn/facture/card-rec.php @@ -947,7 +947,7 @@ if ($action == 'create') { } $htmltext .= ''; - // Libelle + // Label print '' . $langs->trans("Label") . ''; print ''; print ''; diff --git a/htdocs/imports/class/import.class.php b/htdocs/imports/class/import.class.php index 44ec5935d49..61ac4929d40 100644 --- a/htdocs/imports/class/import.class.php +++ b/htdocs/imports/class/import.class.php @@ -162,9 +162,9 @@ class Import $this->array_import_perms[$i] = $user->rights->import->run; // Icon $this->array_import_icon[$i] = (isset($module->import_icon[$r]) ? $module->import_icon[$r] : $module->picto); - // Code du dataset export + // Code of dataset export $this->array_import_code[$i] = $module->import_code[$r]; - // Libelle du dataset export + // Label of dataset export $this->array_import_label[$i] = $module->getImportDatasetLabel($r); // Array of tables to import (key=alias, value=tablename) $this->array_import_tables[$i] = $module->import_tables_array[$r]; diff --git a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql index ca2db7924b4..a86404b105f 100644 --- a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql +++ b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql @@ -386,9 +386,11 @@ ALTER TABLE llx_product_fournisseur_price_log ADD INDEX idx_product_fournisseur_ ALTER TABLE llx_bordereau_cheque ADD COLUMN label varchar(255) AFTER ref; -ALTER TABLE llx_societe ADD COLUMN vat_reverse_charge tinyint DEFAULT 0 AFTER tva_assuj; -ALTER TABLE llx_facture_fourn ADD COLUMN vat_reverse_charge tinyint DEFAULT 0 AFTER close_note; +ALTER TABLE llx_societe ADD COLUMN vat_reverse_charge smallint DEFAULT 0 AFTER tva_assuj; +ALTER TABLE llx_facture_fourn ADD COLUMN vat_reverse_charge smallint DEFAULT 0 AFTER close_note; ALTER TABLE llx_c_email_templates add COLUMN defaultfortype smallint DEFAULT 0; +ALTER TABLE llx_mailing ADD COLUMN fk_user_modif integer AFTER fk_user_creat; ALTER TABLE llx_mailing ADD COLUMN evenunsubscribe smallint DEFAULT 0; +ALTER TABLE llx_mailing ADD COLUMN name_from varchar(128) AFTER email_from; diff --git a/htdocs/install/mysql/tables/llx_mailing-mailing.sql b/htdocs/install/mysql/tables/llx_mailing-mailing.sql index 39392502053..f8ee1c567b9 100644 --- a/htdocs/install/mysql/tables/llx_mailing-mailing.sql +++ b/htdocs/install/mysql/tables/llx_mailing-mailing.sql @@ -18,10 +18,10 @@ -- ======================================================================== --- redaction : 0 --- valide : 1 --- approuve : 2 --- envoye : 3 +-- draft : 0 +-- valid : 1 +-- approved : 2 +-- sent : 3 create table llx_mailing ( @@ -37,6 +37,7 @@ create table llx_mailing cible varchar(60), nbemail integer, email_from varchar(160), -- Email address of sender + name_from varchar(128), -- Name to show of sender email_replyto varchar(160), -- Email address for reply email_errorsto varchar(160), -- Email addresse for errors tag varchar(128) NULL, @@ -46,6 +47,7 @@ create table llx_mailing date_envoi datetime, -- date d'envoi tms timestamp DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, fk_user_creat integer, -- user creator + fk_user_modif integer, -- user of last modification fk_user_valid integer, -- user validator fk_user_appro integer, -- not used extraparams varchar(255), -- for stock other parameters with json format diff --git a/htdocs/langs/en_US/mails.lang b/htdocs/langs/en_US/mails.lang index ed2d1409d00..4c217677375 100644 --- a/htdocs/langs/en_US/mails.lang +++ b/htdocs/langs/en_US/mails.lang @@ -180,3 +180,6 @@ DefaultBlacklistMailingStatus=Default value for field '%s' when creating a new c DefaultStatusEmptyMandatory=Empty but mandatory WarningLimitSendByDay=WARNING: The setup or contract of your instance limits your number of emails per day to %s. Trying to send more may result in having your instance slow down or suspended. Please contact your support if you need a higher quota. NoMoreRecipientToSendTo=No more recipient to send the email to +EmailOptedOut=Email owner has requested to not contact him with this email anymore +EvenUnsubscribe=Include opt-out emails +EvenUnsubscribeDesc=Include opt-out emails when you select emails as targets. Usefull for mandatory service emails for example. \ No newline at end of file diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index be53fa38b3a..bd02374a24c 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -453,10 +453,10 @@ class PaymentLoan extends CommonObject } /** - * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 0bcfa07c672..4a310d51cfb 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -753,13 +753,14 @@ class MyObject extends CommonObject /** * getTooltipContentArray - * @param array $params params to construct tooltip data - * @since v18 - * @return array + * + * @param array $params Params to construct tooltip data + * @since v18 + * @return array */ public function getTooltipContentArray($params) { - global $conf, $langs, $user; + global $conf, $langs; $datas = []; @@ -959,7 +960,7 @@ class MyObject extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Return the status + * Return the label of a given status * * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto diff --git a/htdocs/opensurvey/class/opensurveysondage.class.php b/htdocs/opensurvey/class/opensurveysondage.class.php index 770f16b07d2..18213acdb89 100644 --- a/htdocs/opensurvey/class/opensurveysondage.class.php +++ b/htdocs/opensurvey/class/opensurveysondage.class.php @@ -666,8 +666,8 @@ class Opensurveysondage extends CommonObject /** * Return status label of Order * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label if status */ public function getLibStatut($mode) { @@ -678,9 +678,9 @@ class Opensurveysondage extends CommonObject /** * Return label of status * - * @param int $status Id statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode) { diff --git a/htdocs/product/inventory/class/inventory.class.php b/htdocs/product/inventory/class/inventory.class.php index 80189f29845..275b5272d9c 100644 --- a/htdocs/product/inventory/class/inventory.class.php +++ b/htdocs/product/inventory/class/inventory.class.php @@ -607,9 +607,9 @@ class Inventory extends CommonObject } /** - * Retourne le libelle du status d'un user (actif, inactif) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ public function getLibStatut($mode = 0) diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 8ab5ff77da4..083ea381015 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -1154,10 +1154,10 @@ class MouvementStock extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un status donne + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($mode = 0) { diff --git a/htdocs/product/stock/class/productstockentrepot.class.php b/htdocs/product/stock/class/productstockentrepot.class.php index 1151890a4b1..1856b7b156d 100644 --- a/htdocs/product/stock/class/productstockentrepot.class.php +++ b/htdocs/product/stock/class/productstockentrepot.class.php @@ -532,9 +532,9 @@ class ProductStockEntrepot extends CommonObject } /** - * Retourne le libelle du status d'un user (actif, inactif) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ public function getLibStatut($mode = 0) diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php index 17c5811d716..26119927fda 100644 --- a/htdocs/projet/list.php +++ b/htdocs/projet/list.php @@ -506,7 +506,6 @@ if ($search_opp_percent) { $sql .= dolSqlDateFilter('p.dateo', $search_sday, $search_smonth, $search_syear); $sql .= dolSqlDateFilter('p.datee', $search_eday, $search_emonth, $search_eyear); - if ($search_date_start_start) { $sql .= " AND p.dateo >= '".$db->idate($search_date_start_start)."'"; } @@ -1469,7 +1468,7 @@ while ($i < $imaxinloop) { } // Project url if (!empty($arrayfields['p.ref']['checked'])) { - print ''; + print ''; print $object->getNomUrl(1, (!empty(GETPOST('search_usage_event_organization', 'int'))?'eventorganization':'')); if ($object->hasDelay()) { print img_warning($langs->trans('Late')); diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 018d532a363..f2da87feab5 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -1383,7 +1383,8 @@ class Reception extends CommonObject while ($xnbp < $nbp) { $line = new CommandeFournisseurDispatch($this->db); $line->desc = $langs->trans("Description")." ".$xnbp; - $line->libelle = $langs->trans("Description")." ".$xnbp; + $line->libelle = $langs->trans("Description")." ".$xnbp; // deprecated + $line->label = $langs->trans("Description")." ".$xnbp; $line->qty = 10; $line->fk_product = $this->commande->lines[$xnbp]->fk_product; diff --git a/htdocs/resource/class/dolresource.class.php b/htdocs/resource/class/dolresource.class.php index 578594538cb..b9050d190d2 100644 --- a/htdocs/resource/class/dolresource.class.php +++ b/htdocs/resource/class/dolresource.class.php @@ -750,7 +750,7 @@ class Dolresource extends CommonObject $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); - // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut + $label = ($langs->trans("ResourceTypeShort".$obj->code) != ("ResourceTypeShort".$obj->code) ? $langs->trans("ResourceTypeShort".$obj->code) : ($obj->label != '-' ? $obj->label : '')); $this->cache_code_type_resource[$obj->rowid]['code'] = $obj->code; $this->cache_code_type_resource[$obj->rowid]['label'] = $label; @@ -875,9 +875,9 @@ class Dolresource extends CommonObject /** - * Retourne le libelle du status d'un user (actif, inactif) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ public function getLibStatut($mode = 0) diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php index 4fbf69fd5ee..6446e86655f 100644 --- a/htdocs/salaries/class/salary.class.php +++ b/htdocs/salaries/class/salary.class.php @@ -674,9 +674,9 @@ class Salary extends CommonObject /** - * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * Return label of current status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $mode 0=label long, 1=labels short, 2=Picto + Label short, 3=Picto, 4=Picto + Label long, 5=Label short + Picto * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) * @return string Label */ @@ -687,7 +687,7 @@ class Salary extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return label of a given status * * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 685270a09e0..f85f03cf8d8 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -4643,7 +4643,7 @@ class Societe extends CommonObject /** * Return prostect level * - * @return string Libelle + * @return string Label of prospect status */ public function getLibProspLevel() { @@ -4673,9 +4673,9 @@ class Societe extends CommonObject /** * Return status of prospect * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long + * @param int $mode 0=label long, 1=label short, 2=Picto + Label short, 3=Picto, 4=Picto + Label long * @param string $label Label to use for status for added status - * @return string Libelle + * @return string Label */ public function getLibProspCommStatut($mode = 0, $label = '') { diff --git a/htdocs/societe/class/societeaccount.class.php b/htdocs/societe/class/societeaccount.class.php index 4b39515a585..82ff5c41c11 100644 --- a/htdocs/societe/class/societeaccount.class.php +++ b/htdocs/societe/class/societeaccount.class.php @@ -467,10 +467,10 @@ class SocieteAccount extends CommonObject } /** - * Retourne le libelle du status d'un user (actif, inactif) + * Return the label of a given status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function getLibStatut($mode = 0) { diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index 2487547543b..92baa55ea89 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -685,17 +685,14 @@ class Ticket extends CommonObject $this->timing = $obj->timing; $this->type_code = $obj->type_code; - // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut $label_type = ($langs->trans("TicketTypeShort".$obj->type_code) != ("TicketTypeShort".$obj->type_code) ? $langs->trans("TicketTypeShort".$obj->type_code) : ($obj->type_label != '-' ? $obj->type_label : '')); $this->type_label = $label_type; $this->category_code = $obj->category_code; - // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut $label_category = ($langs->trans("TicketCategoryShort".$obj->category_code) != ("TicketCategoryShort".$obj->category_code) ? $langs->trans("TicketCategoryShort".$obj->category_code) : ($obj->category_label != '-' ? $obj->category_label : '')); $this->category_label = $label_category; $this->severity_code = $obj->severity_code; - // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut $label_severity = ($langs->trans("TicketSeverityShort".$obj->severity_code) != ("TicketSeverityShort".$obj->severity_code) ? $langs->trans("TicketSeverityShort".$obj->severity_code) : ($obj->severity_label != '-' ? $obj->severity_label : '')); $this->severity_label = $label_severity; @@ -855,17 +852,14 @@ class Ticket extends CommonObject $line->progress = $obj->progress; $line->timing = $obj->timing; - // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut $label_type = ($langs->trans("TicketTypeShort".$obj->type_code) != ("TicketTypeShort".$obj->type_code) ? $langs->trans("TicketTypeShort".$obj->type_code) : ($obj->type_label != '-' ? $obj->type_label : '')); $line->type_label = $label_type; $this->category_code = $obj->category_code; - // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut $label_category = ($langs->trans("TicketCategoryShort".$obj->category_code) != ("TicketCategoryShort".$obj->category_code) ? $langs->trans("TicketCategoryShort".$obj->category_code) : ($obj->category_label != '-' ? $obj->category_label : '')); $line->category_label = $label_category; $this->severity_code = $obj->severity_code; - // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut $label_severity = ($langs->trans("TicketSeverityShort".$obj->severity_code) != ("TicketSeverityShort".$obj->severity_code) ? $langs->trans("TicketSeverityShort".$obj->severity_code) : ($obj->severity_label != '-' ? $obj->severity_label : '')); $line->severity_label = $label_severity; @@ -1254,7 +1248,6 @@ class Ticket extends CommonObject $i = 0; while ($i < $num) { $obj = $this->db->fetch_object($resql); - // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut $label = ($langs->trans("TicketTypeShort".$obj->code) != ("TicketTypeShort".$obj->code) ? $langs->trans("TicketTypeShort".$obj->code) : ($obj->label != '-' ? $obj->label : '')); $this->cache_types_tickets[$obj->rowid]['code'] = $obj->code; $this->cache_types_tickets[$obj->rowid]['label'] = $label; @@ -1343,7 +1336,6 @@ class Ticket extends CommonObject $obj = $this->db->fetch_object($resql); $this->cache_severity_tickets[$obj->rowid]['code'] = $obj->code; - // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut $label = ($langs->trans("TicketSeverityShort".$obj->code) != ("TicketSeverityShort".$obj->code) ? $langs->trans("TicketSeverityShort".$obj->code) : ($obj->label != '-' ? $obj->label : '')); $this->cache_severity_tickets[$obj->rowid]['label'] = $label; $this->cache_severity_tickets[$obj->rowid]['use_default'] = $obj->use_default; diff --git a/htdocs/user/class/usergroup.class.php b/htdocs/user/class/usergroup.class.php index a93f7ccebfb..b077650846e 100644 --- a/htdocs/user/class/usergroup.class.php +++ b/htdocs/user/class/usergroup.class.php @@ -698,9 +698,9 @@ class UserGroup extends CommonObject /** - * Return label of status of user (active, inactive) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ public function getLibStatut($mode = 0) @@ -710,11 +710,11 @@ class UserGroup extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Return the label of a given status * - * @param int $status Id status - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 7424f7474c0..84f47e8c0d9 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -305,12 +305,37 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST( } } - if ($prodcomb->update($user) > 0) { + $error = 0; + $db->begin(); + + // Update product variant ref + $product_child = new Product($db); + $product_child->fetch($prodcomb->fk_product_child); + $product_child->oldcopy = clone $product_child; + $product_child->ref = $reference; + + $result = $product_child->update($product_child->id, $user); + if ($result < 0) { + setEventMessages($product_child->error, $product_child->errors, 'errors'); + $error++; + } + + if (!$error) { + // Update product variant infos + $result = $prodcomb->update($user); + if ($result < 0) { + setEventMessages($prodcomb->error, $prodcomb->errors, 'errors'); + $error++; + } + } + + if (!$error) { + $db->commit(); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); - header('Location: '.dol_buildpath('/variants/combinations.php?id='.$id, 2)); + header('Location: ' . dol_buildpath('/variants/combinations.php?id=' . $id, 2)); exit(); } else { - setEventMessages($prodcomb->error, $prodcomb->errors, 'errors'); + $db->rollback(); } } @@ -339,6 +364,9 @@ if ($action === 'confirm_deletecombination') { exit(); } + $product_child = new Product($db); + $product_child->fetch($prodcomb->fk_product_child); + $reference = $product_child->ref; $weight_impact = $prodcomb->variation_weight; $price_impact = $prodcomb->variation_price; $price_impact_percent = $prodcomb->variation_price_percentage; diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 28eb11dde90..e64aa8d837d 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -852,9 +852,9 @@ class Website extends CommonObject } /** - * Retourne le libelle du status d'un user (actif, inactif) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ public function getLibStatut($mode = 0) @@ -864,11 +864,11 @@ class Website extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un status donne + * Return the label of a given status * - * @param int $status Id status - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { diff --git a/htdocs/website/class/websitepage.class.php b/htdocs/website/class/websitepage.class.php index 932762b3998..dbc66ff3ca4 100644 --- a/htdocs/website/class/websitepage.class.php +++ b/htdocs/website/class/websitepage.class.php @@ -795,9 +795,9 @@ class WebsitePage extends CommonObject } /** - * Retourne le libelle du status d'un user (actif, inactif) + * Return the label of the status * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto * @return string Label of status */ public function getLibStatut($mode = 0) @@ -807,11 +807,11 @@ class WebsitePage extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un status donne + * Return the label of a given status * - * @param int $status Id status - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Label of status + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status */ public function LibStatut($status, $mode = 0) { diff --git a/htdocs/workstation/class/workstation.class.php b/htdocs/workstation/class/workstation.class.php index 4f07d48cd21..dcdde005130 100644 --- a/htdocs/workstation/class/workstation.class.php +++ b/htdocs/workstation/class/workstation.class.php @@ -156,8 +156,6 @@ class Workstation extends CommonObject $this->db = $db; - $this->fields['ref']['default'] = $this->getNextNumRef(); - if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) { $this->fields['rowid']['visible'] = 0; } diff --git a/htdocs/workstation/workstation_card.php b/htdocs/workstation/workstation_card.php index 821317ba270..37d7b079c8a 100644 --- a/htdocs/workstation/workstation_card.php +++ b/htdocs/workstation/workstation_card.php @@ -148,8 +148,6 @@ if (empty($reshook)) { /* * View - * - * Put here all code to build page */ $form = new Form($db); @@ -190,6 +188,9 @@ llxHeader('', $title, $help_url); // Part to create if ($action == 'create') { + // Set default value of the property ref + $object->fields['ref']['default'] = $object->getNextNumRef(); + print load_fiche_titre($langs->trans("NewObject", $langs->transnoentitiesnoconv("Workstation")), '', 'object_'.$object->picto); print ''; diff --git a/htdocs/workstation/workstation_list.php b/htdocs/workstation/workstation_list.php index 80c64ff303b..e1ca77e7101 100644 --- a/htdocs/workstation/workstation_list.php +++ b/htdocs/workstation/workstation_list.php @@ -213,7 +213,7 @@ $formresource = new FormResource($db); $now = dol_now(); $help_url = 'EN:Module_Workstation'; -$title = $langs->trans('ListOf', $langs->transnoentitiesnoconv("Workstations")); +$title = $langs->trans("Workstations"); $morejs = array(); $morecss = array();