From f161b47cba0eae757700aa88c8c59b938e46432e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Dec 2020 01:45:08 +0100 Subject: [PATCH 01/11] Debug v13 --- ChangeLog | 6 +++--- htdocs/theme/eldy/info-box.inc.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 20b3a514342..fbb36f221c6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -56,7 +56,6 @@ NEW: add option TAKEPOS_CAN_FORCE_BANK_ACCOUNT_DURING_PAYMENT NEW: add option to define a default warehouse at user level NEW: add option to include products without alert in replenish NEW: add order by lastname and firstname by default in get sales representatives -NEW: add param to not show links when output tags NEW: add PDF document templates for warehouses (list of stock) NEW: add a prospect status for the contact with managment of custom icon NEW: add public note on products ; this also partially fix the #14342 @@ -79,7 +78,7 @@ NEW: appearance tab in TakePOS with more visual parameters NEW: better currency rate editor NEW: can build vendor invoice from vendor orders NEW: can change a product in lines of a recurring invoice or contract -NEW: can change size of logo on PDF documents +NEW: can set the size of the logo on PDF documents NEW: can change VAT rate of all lines of a draft object in one step NEW: can define date range of validity of a login during creation NEW: can disable, from edit page, the whole web site @@ -188,7 +187,7 @@ NEW: show line number on intervention card (via MAIN_VIEW_LINE_NUMBER) NEW: Add some fields to link website page to an other object NEW: fill ECM src object fields in dol_add_file_process NEW: conf to allow to show the full tree in warehouse popup -NEW: can use THEME_DARKMODEENABLED=2 for a preview of theme in dark mode +NEW: can use parameter ?THEME_DARKMODEENABLED=2 for a preview of theme in dark mode NEW: can force the antivirus from conf file or autoprepend ini setup NEW: can add event to log into blockedlog module with a constant NEW: add property cssview when declaring fields of an object @@ -212,6 +211,7 @@ NEW: add a message in error_log after detection of SQL or script injection NEW: add validation of MX domain for emails NEW: calculate the virtual stock in transverse mode ( not on getEntity('commande'), ... but on getEntity('stock') ) NEW: Graphics can be horizontal bars +NEW: add param to not show links when output tags APIs NEW: API get contacts list of a given order diff --git a/htdocs/theme/eldy/info-box.inc.php b/htdocs/theme/eldy/info-box.inc.php index 1bb6ae7c67e..2da8de5cff3 100644 --- a/htdocs/theme/eldy/info-box.inc.php +++ b/htdocs/theme/eldy/info-box.inc.php @@ -25,7 +25,7 @@ if (!defined('ISLOADEDBYSTEELSHEET')) die('Must be call by steelsheet'); ?> .info-box.info-box-sm { min-height: 80px; margin-bottom: 10px; - background: #fff; + /* background: #fff; */ } .opened-dash-board-wrap .info-box.info-box-sm { border-radius: 0 0 0 20px; From 695eacf099e8d4b8cde3412e74467fa13f81b22b Mon Sep 17 00:00:00 2001 From: Stephane Lesage Date: Tue, 1 Dec 2020 19:30:09 +0100 Subject: [PATCH 02/11] Create/Edit extra-field with multi-line text area for computed value --- htdocs/core/tpl/admin_extrafields_add.tpl.php | 7 +++++-- htdocs/core/tpl/admin_extrafields_edit.tpl.php | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 2a9438f4413..de16915fe3c 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -182,11 +182,14 @@ $listofexamplesforlink = 'Societe:societe/class/societe.class.php
Contact:con trans("LanguageFile"); ?> + global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) { ?> - textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?> + textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?> - textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc")).$form->textwithpicto($langs->trans("Computedpersistent"), $langs->trans("ComputedpersistentDesc"), 1, 'warning'); ?> + textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc")).$form->textwithpicto($langs->trans("Computedpersistent"), $langs->trans("ComputedpersistentDesc"), 1, 'warning'); ?> + + trans("DefaultValue").' ('.$langs->trans("Database").')'; ?> diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php index 8990f75951d..9e893bf93e3 100644 --- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php @@ -265,11 +265,14 @@ if (in_array($type, array_keys($typewecanchangeinto))) trans("LanguageFile"); ?> + global->MAIN_STORE_COMPUTED_EXTRAFIELDS)) { ?> - textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?> + textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc"), 1, 'help', '', 0, 2, 'tooltipcompute'); ?> - textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc")).$form->textwithpicto($langs->trans("Computedpersistent"), $langs->trans("ComputedpersistentDesc"), 1, 'warning'); ?> + textwithpicto($langs->trans("ComputedFormula"), $langs->trans("ComputedFormulaDesc")).$form->textwithpicto($langs->trans("Computedpersistent"), $langs->trans("ComputedpersistentDesc"), 1, 'warning'); ?> + + trans("DefaultValue").' ('.$langs->trans("Database").')'; ?> From 9b115def15d7c3eb4f29391d8c078a4636aa9e78 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 1 Jan 2021 06:14:05 +0100 Subject: [PATCH 03/11] NEW: Add total in agent margin & uniformize code --- htdocs/margin/agentMargins.php | 45 ++++++++++++++++++++++++------- htdocs/margin/customerMargins.php | 38 +++++++++++++------------- htdocs/margin/productMargins.php | 26 +++++++++--------- 3 files changed, 68 insertions(+), 41 deletions(-) diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index 9c8ff72681b..6d119ac0280 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -291,17 +291,40 @@ if ($result) print ''; print "".$group_array['htmlname']."\n"; - print "".price(price2num($pv, 'MT'))."\n"; - print "".price(price2num($pa, 'MT'))."\n"; - print "".price(price2num($marge, 'MT'))."\n"; + print ''.price(price2num($pv, 'MT')).''; + print ''.price(price2num($pa, 'MT')).''; + print ''.price(price2num($marge, 'MT')).''; if (!empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%")."\n"; + print ''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").''; if (!empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."\n"; + print ''.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").''; print "\n"; + + $i++; + $cumul_achat += $pa; + $cumul_vente += $pv; } } - print ""; + + // Show total margin + $totalMargin = $cumul_vente - $cumul_achat; + + $marginRate = ($cumul_achat != 0) ? (100 * $totalMargin / $cumul_achat) : ''; + $markRate = ($cumul_vente != 0) ? (100 * $totalMargin / $cumul_vente) : ''; + + print ''; + print ''; + print $langs->trans('TotalMargin').""; + print ''.price(price2num($cumul_vente, 'MT')).''; + print ''.price(price2num($cumul_achat, 'MT')).''; + print ''.price(price2num($totalMargin, 'MT')).''; + if (!empty($conf->global->DISPLAY_MARGIN_RATES)) + print ''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").''; + if (!empty($conf->global->DISPLAY_MARK_RATES)) + print ''.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").''; + print ''; + + print ''; print ''; } else { dol_print_error($db); @@ -310,9 +333,13 @@ $db->free($result); print "\n".''."\n"; diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 0a015f0f73d..5f35b4e4936 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -303,23 +303,23 @@ if ($result) $invoicestatic->id = $objp->facid; $invoicestatic->ref = $objp->ref; print $invoicestatic->getNomUrl(1); - print "\n"; - print ""; - print dol_print_date($db->jdate($objp->datef), 'day').""; + print ''; + print ''; + print dol_print_date($db->jdate($objp->datef), 'day').''; } else { $companystatic->id = $objp->socid; $companystatic->name = $objp->name; $companystatic->client = $objp->client; - print "".$companystatic->getNomUrl(1, 'margin')."\n"; + print ''.$companystatic->getNomUrl(1, 'margin').''; } - print "".price(price2num($pv, 'MT'))."\n"; - print "".price(price2num($pa, 'MT'))."\n"; - print "".price(price2num($marge, 'MT'))."\n"; + print ''.price(price2num($pv, 'MT')).''; + print ''.price(price2num($pa, 'MT')).''; + print ''.price(price2num($marge, 'MT')).''; if (!empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%")."\n"; + print ''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").''; if (!empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."\n"; + print ''.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").''; print "\n"; $i++; @@ -347,16 +347,16 @@ if ($result) print ''; else print ''; print $langs->trans('TotalMargin').""; - print "".price($cumul_vente, null, null, null, null, $rounding)."\n"; - print "".price($cumul_achat, null, null, null, null, $rounding)."\n"; - print "".price($totalMargin, null, null, null, null, $rounding)."\n"; + print ''.price(price2num($cumul_vente, 'MT')).''; + print ''.price(price2num($cumul_achat, 'MT')).''; + print ''.price(price2num($totalMargin, 'MT')).''; if (!empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%")."\n"; + print ''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").''; if (!empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%")."\n"; - print "\n"; + print ''.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").''; + print ''; - print ""; + print ''; print ''; } else { dol_print_error($db); @@ -370,9 +370,9 @@ $(document).ready(function() { $("div.fiche form").submit(); });*/ - $("#totalMargin").html("'.price($totalMargin, null, null, null, null, $rounding).'"); - $("#marginRate").html("'.(($marginRate === '') ? 'n/a' : price($marginRate, null, null, null, null, $rounding)."%").'"); - $("#markRate").html("'.(($markRate === '') ? 'n/a' : price($markRate, null, null, null, null, $rounding)."%").'"); + $("#totalMargin").html("'.price(price2num($totalMargin, 'MT')).'"); + $("#marginRate").html("'.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").'"); + $("#markRate").html("'.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").'"); }); '; diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 46f128b2f36..9fa7389a153 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -300,14 +300,14 @@ if ($result) print "\n"; //print "".$product_static->getNomUrl(1)."\n"; } - print "".$qty."\n"; - print "".price(price2num($pv, 'MT'))."\n"; - print "".price(price2num($pa, 'MT'))."\n"; - print "".price(price2num($marge, 'MT'))."\n"; + print ''.$qty.''; + print ''.price(price2num($pv, 'MT')).''; + print ''.price(price2num($pa, 'MT')).''; + print ''.price(price2num($marge, 'MT')).''; if (!empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%")."\n"; + print ''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").''; if (!empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."\n"; + print ''.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").''; print "\n"; $i++; @@ -328,15 +328,15 @@ if ($result) if ($id > 0) print ''; else print ''; - print $langs->trans('TotalMargin').""; - print "".$cumul_qty.""; - print "".price(price2num($cumul_vente, 'MT'))."\n"; - print "".price(price2num($cumul_achat, 'MT'))."\n"; - print "".price(price2num($totalMargin, 'MT'))."\n"; + print $langs->trans('TotalMargin').''; + print ''.$cumul_qty.''; + print ''.price(price2num($cumul_vente, 'MT')).''; + print ''.price(price2num($cumul_achat, 'MT')).''; + print ''.price(price2num($totalMargin, 'MT')).''; if (!empty($conf->global->DISPLAY_MARGIN_RATES)) - print "".(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%")."\n"; + print ''.(($marginRate === '') ? 'n/a' : price(price2num($marginRate, 'MT'))."%").''; if (!empty($conf->global->DISPLAY_MARK_RATES)) - print "".(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%")."\n"; + print ''.(($markRate === '') ? 'n/a' : price(price2num($markRate, 'MT'))."%").''; print "\n"; print ""; From ad3bc649afa7f6443a15f20519b64dd8f4957663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Jan 2021 16:23:09 +0100 Subject: [PATCH 04/11] doxygen --- htdocs/index.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/htdocs/index.php b/htdocs/index.php index a4060278c50..7bfab28a0f2 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -1028,7 +1028,7 @@ function showWeather($totallate, $text, $options, $morecss = '') * $conf->global->MAIN_METEO_LEVELx * * @param int $totallate Nb of element late - * @return string Return img tag of weather + * @return stdClass Return img tag of weather */ function getWeatherStatus($totallate) { @@ -1063,20 +1063,16 @@ function getWeatherStatus($totallate) if ($totallate <= $level0) { $weather->picto = 'weather-clear.png'; $weather->level = 0; - } - elseif ($totallate <= $level1) { + } elseif ($totallate <= $level1) { $weather->picto = 'weather-few-clouds.png'; $weather->level = 1; - } - elseif ($totallate <= $level2) { + } elseif ($totallate <= $level2) { $weather->picto = 'weather-clouds.png'; $weather->level = 2; - } - elseif ($totallate <= $level3) { + } elseif ($totallate <= $level3) { $weather->picto = 'weather-many-clouds.png'; $weather->level = 3; - } - else { + } else { $weather->picto = 'weather-storm.png'; $weather->level = 4; } From eb937f82c8a8358c8ebb6f4b36aca92c4013ea63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Jan 2021 16:58:05 +0100 Subject: [PATCH 05/11] doxygen --- htdocs/core/class/html.formmail.class.php | 102 ++++++++++++---------- 1 file changed, 56 insertions(+), 46 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index fceaedffb98..096418597da 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -1110,14 +1110,30 @@ class FormMail extends Form } $showinfobcc = ''; - if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) && !empty($this->param['models']) && $this->param['models'] == 'propal_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO; - if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) && !empty($this->param['models']) && $this->param['models'] == 'order_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO; - if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) && !empty($this->param['models']) && $this->param['models'] == 'facture_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO; - if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) && !empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO; - if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) && !empty($this->param['models']) && $this->param['models'] == 'order_supplier_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO; - if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) && !empty($this->param['models']) && $this->param['models'] == 'invoice_supplier_send') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO; - if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) && !empty($this->param['models']) && $this->param['models'] == 'project') $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO; - if ($showinfobcc) $out .= ' + '.$showinfobcc; + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO) && !empty($this->param['models']) && $this->param['models'] == 'propal_send') { + $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_PROPOSAL_TO; + } + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO) && !empty($this->param['models']) && $this->param['models'] == 'order_send') { + $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_ORDER_TO; + } + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO) && !empty($this->param['models']) && $this->param['models'] == 'facture_send') { + $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_INVOICE_TO; + } + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO) && !empty($this->param['models']) && $this->param['models'] == 'supplier_proposal_send') { + $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_PROPOSAL_TO; + } + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO) && !empty($this->param['models']) && $this->param['models'] == 'order_supplier_send') { + $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_ORDER_TO; + } + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO) && !empty($this->param['models']) && $this->param['models'] == 'invoice_supplier_send') { + $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_SUPPLIER_INVOICE_TO; + } + if (!empty($conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO) && !empty($this->param['models']) && $this->param['models'] == 'project') { + $showinfobcc = $conf->global->MAIN_MAIL_AUTOCOPY_PROJECT_TO; + } + if ($showinfobcc) { + $out .= ' + '.$showinfobcc; + } $out .= "\n"; return $out; } @@ -1212,7 +1228,7 @@ class FormMail extends Form * * @param DoliDB $db Database handler * @param string $type_template Get message for model/type=$type_template, type='all' also included. - * @param string $user Get template public or limited to this user + * @param User $user Get template public or limited to this user * @param Translate $outputlangs Output lang object * @param int $id Id of template to find, or -1 for first found with position 0, or 0 for first found whatever is position (priority order depends on lang provided or not) or -2 for exact match with label (no answer if not found) * @param int $active 1=Only active template, 0=Only disabled, -1=All @@ -1232,7 +1248,9 @@ class FormMail extends Form // Define $languagetosearchmain to fall back on main language (for example to get 'es_ES' for 'es_MX') $tmparray = explode('_', $languagetosearch); $languagetosearchmain = $tmparray[0].'_'.strtoupper($tmparray[0]); - if ($languagetosearchmain == $languagetosearch) $languagetosearchmain = ''; + if ($languagetosearchmain == $languagetosearch) { + $languagetosearchmain = ''; + } $sql = "SELECT rowid, label, topic, joinfiles, content, content_lines, lang"; $sql .= " FROM ".MAIN_DB_PREFIX.'c_email_templates'; @@ -1244,14 +1262,16 @@ class FormMail extends Form if (!($id > 0) && $languagetosearch) $sql .= " AND (lang = '".$db->escape($languagetosearch)."'".($languagetosearchmain ? " OR lang = '".$db->escape($languagetosearchmain)."'" : "")." OR lang IS NULL OR lang = '')"; if ($id > 0) $sql .= " AND rowid=".$id; if ($id == -1) $sql .= " AND position=0"; - if ($languagetosearch) $sql .= $db->order("position,lang,label", "ASC,DESC,ASC"); // We want line with lang set first, then with lang null or '' - else $sql .= $db->order("position,lang,label", "ASC,ASC,ASC"); // If no language provided, we give priority to lang not defined + if ($languagetosearch) { + $sql .= $db->order("position,lang,label", "ASC,DESC,ASC"); // We want line with lang set first, then with lang null or '' + } else { + $sql .= $db->order("position,lang,label", "ASC,ASC,ASC"); // If no language provided, we give priority to lang not defined + } $sql .= $db->plimit(1); //print $sql; $resql = $db->query($sql); - if ($resql) - { + if ($resql) { // Get first found $obj = $db->fetch_object($resql); @@ -1321,7 +1341,7 @@ class FormMail extends Form * Search into table c_email_templates * * @param string $type_template Get message for key module - * @param string $user Use template public or limited to this user + * @param User $user Use template public or limited to this user * @param Translate $outputlangs Output lang object * @return int <0 if KO, */ @@ -1332,13 +1352,14 @@ class FormMail extends Form $sql .= " WHERE type_template='".$this->db->escape($type_template)."'"; $sql .= " AND entity IN (".getEntity('c_email_templates').")"; $sql .= " AND (fk_user is NULL or fk_user = 0 or fk_user = ".$user->id.")"; - if (is_object($outputlangs)) $sql .= " AND (lang = '".$this->db->escape($outputlangs->defaultlang)."' OR lang IS NULL OR lang = '')"; + if (is_object($outputlangs)) { + $sql .= " AND (lang = '".$this->db->escape($outputlangs->defaultlang)."' OR lang IS NULL OR lang = '')"; + } $sql .= $this->db->order("lang,label", "ASC"); //print $sql; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $this->db->free($resql); return $num; @@ -1353,7 +1374,7 @@ class FormMail extends Form * Search into table c_email_templates * * @param string $type_template Get message for key module - * @param string $user Use template public or limited to this user + * @param User $user Use template public or limited to this user * @param Translate $outputlangs Output lang object * @param int $active 1=Only active template, 0=Only disabled, -1=All * @return int <0 if KO, nb of records found if OK @@ -1365,18 +1386,18 @@ class FormMail extends Form $sql .= " WHERE type_template IN ('".$this->db->escape($type_template)."', 'all')"; $sql .= " AND entity IN (".getEntity('c_email_templates').")"; $sql .= " AND (private = 0 OR fk_user = ".$user->id.")"; // See all public templates or templates I own. - if ($active >= 0) $sql .= " AND active = ".$active; + if ($active >= 0) { + $sql .= " AND active = ".$active; + } //if (is_object($outputlangs)) $sql.= " AND (lang = '".$this->db->escape($outputlangs->defaultlang)."' OR lang IS NULL OR lang = '')"; // Return all languages $sql .= $this->db->order("position,lang,label", "ASC"); //print $sql; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $this->lines_model = array(); - while ($obj = $this->db->fetch_object($resql)) - { + while ($obj = $this->db->fetch_object($resql)) { $line = new ModelMail(); $line->id = $obj->rowid; $line->label = $obj->label; @@ -1419,10 +1440,8 @@ class FormMail extends Form $this->substit = $tmparray; // Fill substit_lines with each object lines content - if (is_array($object->lines)) - { - foreach ($object->lines as $line) - { + if (is_array($object->lines)) { + foreach ($object->lines as $line) { $substit_line = array( '__PRODUCT_REF__' => isset($line->product_ref) ? $line->product_ref : '', '__PRODUCT_LABEL__' => isset($line->product_label) ? $line->product_label : '', @@ -1438,15 +1457,13 @@ class FormMail extends Form ); // Create dynamic tags for __PRODUCT_EXTRAFIELD_FIELD__ - if (!empty($line->fk_product)) - { + if (!empty($line->fk_product)) { if (!is_object($extrafields)) $extrafields = new ExtraFields($this->db); $extrafields->fetch_name_optionals_label('product', true); $product = new Product($this->db); $product->fetch($line->fk_product, '', '', 1); $product->fetch_optionals(); - if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) - { + if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label']) > 0) { foreach ($extrafields->attributes[$product->table_element]['label'] as $key => $label) { $substit_line['__PRODUCT_EXTRAFIELD_'.strtoupper($key).'__'] = $product->array_options['options_'.$key]; } @@ -1470,24 +1487,20 @@ class FormMail extends Form global $conf, $langs; $tmparray = array(); - if ($mode == 'formemail' || $mode == 'formemailwithlines' || $mode == 'formemailforlines') - { + if ($mode == 'formemail' || $mode == 'formemailwithlines' || $mode == 'formemailforlines') { $parameters = array('mode'=>$mode); $tmparray = getCommonSubstitutionArray($langs, 2, null, $object); // Note: On email templated edition, this is null because it is related to all type of objects complete_substitutions_array($tmparray, $langs, null, $parameters); - if ($mode == 'formwithlines') - { + if ($mode == 'formwithlines') { $tmparray['__LINES__'] = '__LINES__'; // Will be set by the get_form function } - if ($mode == 'formforlines') - { + if ($mode == 'formforlines') { $tmparray['__QUANTITY__'] = '__QUANTITY__'; // Will be set by the get_form function } } - if ($mode == 'emailing') - { + if ($mode == 'emailing') { $parameters = array('mode'=>$mode); $tmparray = getCommonSubstitutionArray($langs, 2, array('object', 'objectamount'), $object); // Note: On email templated edition, this is null because it is related to all type of objects complete_substitutions_array($tmparray, $langs, null, $parameters); @@ -1512,11 +1525,9 @@ class FormMail extends Form if (!empty($conf->paypal->enabled)) $onlinepaymentenabled++; if (!empty($conf->paybox->enabled)) $onlinepaymentenabled++; if (!empty($conf->stripe->enabled)) $onlinepaymentenabled++; - if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) - { + if ($onlinepaymentenabled && !empty($conf->global->PAYMENT_SECURITY_TOKEN)) { $tmparray['__SECUREKEYPAYMENT__'] = $conf->global->PAYMENT_SECURITY_TOKEN; - if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) - { + if (!empty($conf->global->PAYMENT_SECURITY_TOKEN_UNIQUE)) { if ($conf->adherent->enabled) $tmparray['__SECUREKEYPAYMENT_MEMBER__'] = 'SecureKeyPAYMENTUniquePerMember'; if ($conf->facture->enabled) $tmparray['__SECUREKEYPAYMENT_INVOICE__'] = 'SecureKeyPAYMENTUniquePerInvoice'; if ($conf->commande->enabled) $tmparray['__SECUREKEYPAYMENT_ORDER__'] = 'SecureKeyPAYMENTUniquePerOrder'; @@ -1533,8 +1544,7 @@ class FormMail extends Form } } - foreach ($tmparray as $key => $val) - { + foreach ($tmparray as $key => $val) { if (empty($val)) $tmparray[$key] = $key; } From 62d91c3631ec209fac7d08587974f0e3defcb476 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 4 Jan 2021 16:07:47 +0100 Subject: [PATCH 06/11] FIX: Loan - Payment in not integrate in bank due to a problem with the type of payment --- htdocs/loan/class/paymentloan.class.php | 2 +- htdocs/loan/payment/payment.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index dc6d72094b2..34acb06f9ce 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -475,7 +475,7 @@ class PaymentLoan extends CommonObject // Insert payment into llx_bank $bank_line_id = $acc->addline( $this->datep, - $this->fk_typepayment, // Payment mode ID or code ("CHQ or VIR for example") + $this->paymenttype, // Payment mode ID or code ("CHQ or VIR for example") $label, $total, $this->num_payment, diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php index 8a6e1e9c9ba..0c0574c15b4 100644 --- a/htdocs/loan/payment/payment.php +++ b/htdocs/loan/payment/payment.php @@ -152,7 +152,7 @@ if ($action == 'add_payment') // Create a line of payments $payment = new PaymentLoan($db); - $payment->chid = $chid; + $payment->chid = $chid; $payment->datep = $datepaid; $payment->label = $loan->label; $payment->amount_capital = $pay_amount_capital; @@ -176,7 +176,7 @@ if ($action == 'add_payment') if (!$error) { - $result = $payment->addPaymentToBank($user, $chid, 'payment_loan', '(LoanPayment)', GETPOST('accountid', 'int'), '', ''); + $result = $payment->addPaymentToBank($user, $chid, 'payment_loan', '(LoanPayment)', $payment->fk_bank, '', ''); if (!$result > 0) { setEventMessages($payment->error, $payment->errors, 'errors'); From dd55f9ca9159de6e6b91f567c855414e8a471c21 Mon Sep 17 00:00:00 2001 From: zuiko Date: Mon, 4 Jan 2021 21:46:47 +0100 Subject: [PATCH 07/11] update objectline_create.tpl.php FIX #15849 --- htdocs/core/tpl/objectline_create.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 8da4d30af02..2404b05b74a 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -405,10 +405,10 @@ if ($nolinesbefore) { product->enabled) || !empty($conf->service->enabled)) { ?> - + - "> + "> global->DISPLAY_MARGIN_RATES)) From 0efd5934f4e3a12867e8f8bede9bdff20539b6aa Mon Sep 17 00:00:00 2001 From: zuiko Date: Mon, 4 Jan 2021 21:56:47 +0100 Subject: [PATCH 08/11] Update fournisseurs.php FIX #15849 --- htdocs/product/fournisseurs.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index b6f09346385..98700c90fb3 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -507,11 +507,11 @@ if ($id > 0 || $ref) if ($rowid) { print ''; - print ''; + print ''; } else { - print ''; + print ''; } print ''; print ''; From c468db5a7c23b6d41c8ced9c2bbd429e4466ba03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 4 Jan 2021 23:41:20 +0100 Subject: [PATCH 09/11] doxygen --- htdocs/core/class/html.formmail.class.php | 301 +++++++++------------- 1 file changed, 122 insertions(+), 179 deletions(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 096418597da..59c6b2af273 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -116,7 +116,12 @@ class FormMail extends Form */ public $withto; // Show recipient emails - public $withtofree; // Show free text for recipient emails + /** + * @var int|string 0 = Do not Show free text for recipient emails + * 1 = Show free text for recipient emails + * or a free email + */ + public $withtofree; public $withtocc; public $withtoccc; public $withtopic; @@ -354,14 +359,15 @@ class FormMail extends Form require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; $formfile = new Formfile($this->db); - if (!is_object($form)) $form = new Form($this->db); + if (!is_object($form)) { + $form = new Form($this->db); + } // Load translation files required by the page $langs->loadLangs(array('other', 'mails')); // Clear temp files. Must be done at beginning, before call of triggers - if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) - { + if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) { $this->clear_attached_files(); } @@ -375,8 +381,7 @@ class FormMail extends Form ); $reshook = $hookmanager->executeHooks('getFormMail', $parameters, $this); - if (!empty($reshook)) - { + if (!empty($reshook)) { return $hookmanager->resPrint; } else { $out = ''; @@ -387,8 +392,7 @@ class FormMail extends Form $outputlangs = $langs; $newlang = ''; if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $this->param['langsmodels']; - if (!empty($newlang)) - { + if (!empty($newlang)) { $outputlangs = new Translate("", $conf); $outputlangs->setDefaultLang($newlang); $outputlangs->load('other'); @@ -396,11 +400,9 @@ class FormMail extends Form // Get message template for $this->param["models"] into c_email_templates $arraydefaultmessage = -1; - if ($this->param['models'] != 'none') - { + if ($this->param['models'] != 'none') { $model_id = 0; - if (array_key_exists('models_id', $this->param)) - { + if (array_key_exists('models_id', $this->param)) { $model_id = $this->param["models_id"]; } @@ -413,25 +415,27 @@ class FormMail extends Form $listofmimes = array(); $keytoavoidconflict = empty($this->trackid) ? '' : '-'.$this->trackid; // this->trackid must be defined - if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) - { - if (!empty($arraydefaultmessage->joinfiles) && is_array($this->param['fileinit'])) - { - foreach ($this->param['fileinit'] as $file) - { + if (GETPOST('mode', 'alpha') == 'init' || (GETPOST('modelmailselected', 'alpha') && GETPOST('modelmailselected', 'alpha') != '-1')) { + if (!empty($arraydefaultmessage->joinfiles) && is_array($this->param['fileinit'])) { + foreach ($this->param['fileinit'] as $file) { $this->add_attached_files($file, basename($file), dol_mimetype($file)); } } } - if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); - if (!empty($_SESSION["listofnames".$keytoavoidconflict])) $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]); - if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); + if (!empty($_SESSION["listofpaths".$keytoavoidconflict])) { + $listofpaths = explode(';', $_SESSION["listofpaths".$keytoavoidconflict]); + } + if (!empty($_SESSION["listofnames".$keytoavoidconflict])) { + $listofnames = explode(';', $_SESSION["listofnames".$keytoavoidconflict]); + } + if (!empty($_SESSION["listofmimes".$keytoavoidconflict])) { + $listofmimes = explode(';', $_SESSION["listofmimes".$keytoavoidconflict]); + } $out .= "\n".'
'."\n"; - if ($this->withform == 1) - { + if ($this->withform == 1) { $out .= '
'."\n"; $out .= ''; @@ -439,16 +443,13 @@ class FormMail extends Form $out .= ''; $out .= ''; } - if (!empty($this->withfrom)) - { - if (!empty($this->withfromreadonly)) - { + if (!empty($this->withfrom)) { + if (!empty($this->withfromreadonly)) { $out .= ''; $out .= ''; } } - foreach ($this->param as $key=>$value) - { + foreach ($this->param as $key=>$value) { if (is_array($value)) { $out .= "\n"; } else { @@ -457,17 +458,14 @@ class FormMail extends Form } $modelmail_array = array(); - if ($this->param['models'] != 'none') - { + if ($this->param['models'] != 'none') { $result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs); - if ($result < 0) - { + if ($result < 0) { setEventMessages($this->error, $this->errors, 'errors'); } $langs->trans("members"); - foreach ($this->lines_model as $line) - { + foreach ($this->lines_model as $line) { $reg = array(); if (preg_match('/\((.*)\)/', $line->label, $reg)) { $labeltouse = $langs->trans($reg[1]); // langs->trans when label is __(xxx)__ @@ -483,8 +481,7 @@ class FormMail extends Form } // Zone to select email template - if (count($modelmail_array) > 0) - { + if (count($modelmail_array) > 0) { // If list of template is filled $out .= '
'."\n"; $out .= ''.$langs->trans('SelectMailModel').': '; @@ -498,8 +495,7 @@ class FormMail extends Form 'propal_send', 'order_send', 'facture_send', 'shipping_send', 'fichinter_send', 'supplier_proposal_send', 'order_supplier_send', 'invoice_supplier_send', 'thirdparty', 'contract', 'user', 'recruitmentcandidature_send', 'all' - ))) - { + ))) { // If list of template is empty $out .= '
'."\n"; $out .= $langs->trans('SelectMailModel').': '; // Do not put 'disabled' on 'option' tag, it is already on 'select' and it makes chrome crazy. @@ -518,12 +514,10 @@ class FormMail extends Form // Substitution array/string $helpforsubstitution = ''; if (is_array($this->substit) && count($this->substit)) $helpforsubstitution .= $langs->trans('AvailableVariables').' :
'."\n"; - foreach ($this->substit as $key => $val) - { + foreach ($this->substit as $key => $val) { $helpforsubstitution .= $key.' -> '.$langs->trans(dol_string_nohtmltag(dolGetFirstLineOfText($val))).'
'; } - if (!empty($this->withsubstit)) // Unset or set ->withsubstit=0 to disable this. - { + if (!empty($this->withsubstit)) { // Unset or set ->withsubstit=0 to disable this. $out .= ''; //$out.='
'; if (is_numeric($this->withsubstit)) $out .= $form->textwithpicto($langs->trans("EMailTestSubstitutionReplacedByGenericValues"), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltip'); // Old usage @@ -538,10 +532,8 @@ class FormMail extends Form var_dump($this->fromname);*/ // From - if (!empty($this->withfrom)) - { - if (!empty($this->withfromreadonly)) - { + if (!empty($this->withfrom)) { + if (!empty($this->withfromreadonly)) { $out .= ''.$langs->trans("MailFrom").''; // $this->fromtype is the default value to use to select sender @@ -551,16 +543,13 @@ class FormMail extends Form && !preg_match('/user_aliases/', $this->fromtype) && !preg_match('/global_aliases/', $this->fromtype) && !preg_match('/senderprofile/', $this->fromtype) - ) - { + ) { // Use this->fromname and this->frommail or error if not defined $out .= $this->fromname; - if ($this->frommail) - { + if ($this->frommail) { $out .= ' <'.$this->frommail.'>'; } else { - if ($this->fromtype) - { + if ($this->fromtype) { $langs->load('errors'); $out .= ' <'.$langs->trans('ErrorNoMailDefinedForThisUser').'> '; } @@ -569,8 +558,7 @@ class FormMail extends Form $liste = array(); // Add user email - if (empty($user->email)) - { + if (empty($user->email)) { $langs->load('errors'); $liste['user'] = $user->getFullName($langs).' <'.$langs->trans('ErrorNoMailDefinedForThisUser').'>'; } else { @@ -584,13 +572,10 @@ class FormMail extends Form $listaliases = array('user_aliases'=>$user->email_aliases, 'global_aliases'=>$conf->global->MAIN_INFO_SOCIETE_MAIL_ALIASES); // Also add robot email - if (!empty($this->fromalsorobot)) - { - if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && $conf->global->MAIN_MAIL_EMAIL_FROM != $conf->global->MAIN_INFO_SOCIETE_MAIL) - { + if (!empty($this->fromalsorobot)) { + if (!empty($conf->global->MAIN_MAIL_EMAIL_FROM) && $conf->global->MAIN_MAIL_EMAIL_FROM != $conf->global->MAIN_INFO_SOCIETE_MAIL) { $liste['robot'] = $conf->global->MAIN_MAIL_EMAIL_FROM; - if ($this->frommail) - { + if ($this->frommail) { $liste['robot'] .= ' <'.$conf->global->MAIN_MAIL_EMAIL_FROM.'>'; } } @@ -601,31 +586,27 @@ class FormMail extends Form $sql .= ' WHERE active = 1 AND (private = 0 OR private = '.$user->id.')'; $sql .= ' ORDER BY position'; $resql = $this->db->query($sql); - if ($resql) - { + if ($resql) { $num = $this->db->num_rows($resql); $i = 0; - while ($i < $num) - { + while ($i < $num) { $obj = $this->db->fetch_object($resql); - if ($obj) - { + if ($obj) { $listaliases['senderprofile_'.$obj->rowid] = $obj->label.' <'.$obj->email.'>'; } $i++; } - } else dol_print_error($this->db); + } else { + dol_print_error($this->db); + } - foreach ($listaliases as $typealias => $listalias) - { + foreach ($listaliases as $typealias => $listalias) { $posalias = 0; $listaliasarray = explode(',', $listalias); - foreach ($listaliasarray as $listaliasval) - { + foreach ($listaliasarray as $listaliasval) { $posalias++; $listaliasval = trim($listaliasval); - if ($listaliasval) - { + if ($listaliasval) { $listaliasval = preg_replace('//', '>', $listaliasval); if (!preg_match('/</', $listaliasval)) $listaliasval = '<'.$listaliasval.'>'; @@ -637,8 +618,7 @@ class FormMail extends Form // Set the default "From" $defaultfrom = ''; $reshook = $hookmanager->executeHooks('getDefaultFromEmail', $parameters, $this); - if (empty($reshook)) - { + if (empty($reshook)) { $defaultfrom = $this->fromtype; } if (!empty($hookmanager->resArray['defaultfrom'])) $defaultfrom = $hookmanager->resArray['defaultfrom']; @@ -665,19 +645,15 @@ class FormMail extends Form if ($this->withtofree) $out .= $form->textwithpicto($langs->trans("MailTo"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); else $out .= $langs->trans("MailTo"); $out .= ''; - if ($this->withtoreadonly) - { - if (!empty($this->toname) && !empty($this->tomail)) - { + if ($this->withtoreadonly) { + if (!empty($this->toname) && !empty($this->tomail)) { $out .= ''; $out .= ''; - if ($this->totype == 'thirdparty') - { + if ($this->totype == 'thirdparty') { $soc = new Societe($this->db); $soc->fetch($this->toid); $out .= $soc->getNomUrl(1); - } elseif ($this->totype == 'contact') - { + } elseif ($this->totype == 'contact') { $contact = new Contact($this->db); $contact->fetch($this->toid); $out .= $contact->getNomUrl(1); @@ -685,8 +661,7 @@ class FormMail extends Form $out .= $this->toname; } $out .= ' <'.$this->tomail.'>'; - if ($this->withtofree) - { + if ($this->withtofree) { $out .= '
'.$langs->trans("and").' withto) : "").'" />'; } } else { @@ -695,25 +670,21 @@ class FormMail extends Form } } else { // The free input of email - if (!empty($this->withtofree)) - { + if (!empty($this->withtofree)) { $out .= 'withto) : "")).'" />'; } // The select combo - if (!empty($this->withto) && is_array($this->withto)) - { + if (!empty($this->withto) && is_array($this->withto)) { if (!empty($this->withtofree)) $out .= " ".$langs->trans("and")."/".$langs->trans("or")." "; // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time $tmparray = $this->withto; - foreach ($tmparray as $key => $val) - { + foreach ($tmparray as $key => $val) { $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); } $withtoselected = GETPOST("receiver", 'array'); // Array of selected value - if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') - { + if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') { $withtoselected = array_keys($tmparray); } $out .= $form->multiselectarray("receiver", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, ""); @@ -723,21 +694,18 @@ class FormMail extends Form } // To User - if (!empty($this->withtouser) && is_array($this->withtouser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) - { + if (!empty($this->withtouser) && is_array($this->withtouser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { $out .= ''; $out .= $langs->trans("MailToUsers"); $out .= ''; // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time $tmparray = $this->withtouser; - foreach ($tmparray as $key => $val) - { + foreach ($tmparray as $key => $val) { $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); } $withtoselected = GETPOST("receiveruser", 'array'); // Array of selected value - if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') - { + if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') { $withtoselected = array_keys($tmparray); } $out .= $form->multiselectarray("receiveruser", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, ""); @@ -745,8 +713,7 @@ class FormMail extends Form } // With option one email per recipient - if (!empty($this->withoptiononeemailperrecipient)) - { + if (!empty($this->withoptiononeemailperrecipient)) { $out .= ''; $out .= $langs->trans("GroupEmails"); $out .= ''; @@ -760,23 +727,19 @@ class FormMail extends Form } // CC - if (!empty($this->withtocc) || is_array($this->withtocc)) - { + if (!empty($this->withtocc) || is_array($this->withtocc)) { $out .= ''; $out .= $form->textwithpicto($langs->trans("MailCC"), $langs->trans("YouCanUseCommaSeparatorForSeveralRecipients")); $out .= ''; - if ($this->withtoccreadonly) - { + if ($this->withtoccreadonly) { $out .= (!is_array($this->withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : ""; } else { $out .= 'withtocc) && !is_numeric($this->withtocc)) ? $this->withtocc : '')).'" />'; - if (!empty($this->withtocc) && is_array($this->withtocc)) - { + if (!empty($this->withtocc) && is_array($this->withtocc)) { $out .= " ".$langs->trans("and")."/".$langs->trans("or")." "; // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time $tmparray = $this->withtocc; - foreach ($tmparray as $key => $val) - { + foreach ($tmparray as $key => $val) { $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); } $withtoccselected = GETPOST("receivercc", 'array'); // Array of selected value @@ -787,21 +750,18 @@ class FormMail extends Form } // To User cc - if (!empty($this->withtoccuser) && is_array($this->withtoccuser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) - { + if (!empty($this->withtoccuser) && is_array($this->withtoccuser) && !empty($conf->global->MAIN_MAIL_ENABLED_USER_DEST_SELECT)) { $out .= ''; $out .= $langs->trans("MailToCCUsers"); $out .= ''; // multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time $tmparray = $this->withtoccuser; - foreach ($tmparray as $key => $val) - { + foreach ($tmparray as $key => $val) { $tmparray[$key] = dol_htmlentities($tmparray[$key], null, 'UTF-8', true); } $withtoselected = GETPOST("receiverccuser", 'array'); // Array of selected value - if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') - { + if (empty($withtoselected) && count($tmparray) == 1 && GETPOST('action', 'aZ09') == 'presend') { $withtoselected = array_keys($tmparray); } $out .= $form->multiselectarray("receiverccuser", $tmparray, $withtoselected, null, null, 'inline-block minwidth500', null, ""); @@ -814,10 +774,8 @@ class FormMail extends Form } // Replyto - if (!empty($this->withreplyto)) - { - if ($this->withreplytoreadonly) - { + if (!empty($this->withreplyto)) { + if ($this->withreplytoreadonly) { $out .= ''; $out .= ''; $out .= "".$langs->trans("MailReply")."".$this->replytoname.($this->replytomail ? (" <".$this->replytomail.">") : ""); @@ -841,41 +799,32 @@ class FormMail extends Form } // Attached files - if (!empty($this->withfile)) - { + if (!empty($this->withfile)) { $out .= ''; $out .= ''.$langs->trans("MailFile").''; $out .= ''; - if ($this->withmaindocfile) // withmaindocfile is set to 1 or -1 to show the checkbox (-1 = checked or 1 = not checked) - { - if (GETPOSTISSET('sendmail')) - { + if ($this->withmaindocfile) { // withmaindocfile is set to 1 or -1 to show the checkbox (-1 = checked or 1 = not checked) + if (GETPOSTISSET('sendmail')) { $this->withmaindocfile = (GETPOST('addmaindocfile', 'alpha') ? -1 : 1); - } - // If a template was selected, we use setup of template to define if join file checkbox is selected or not. - elseif (is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) - { + } elseif (is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + // If a template was selected, we use setup of template to define if join file checkbox is selected or not. $this->withmaindocfile = ($arraydefaultmessage->joinfiles ? -1 : 1); } } - if (!empty($this->withmaindocfile)) - { - if ($this->withmaindocfile == 1) - { + if (!empty($this->withmaindocfile)) { + if ($this->withmaindocfile == 1) { $out .= ''; } - if ($this->withmaindocfile == -1) - { + if ($this->withmaindocfile == -1) { $out .= ''; } $out .= ' '.$langs->trans("JoinMainDoc").'.
'; } - if (is_numeric($this->withfile)) - { + if (is_numeric($this->withfile)) { // TODO Trick to have param removedfile containing nb of file to delete. But this does not works without javascript $out .= ''."\n"; $out .= ''."\n"; - if (count($listofpaths)) - { - foreach ($listofpaths as $key => $val) - { + if (count($listofpaths)) { + foreach ($listofpaths as $key => $val) { $out .= '
'; // Preview of attachment preg_match('#^(/)(\w+)(/)(.+)$#', substr($val, (strlen(DOL_DATA_ROOT) - strlen($val))), $formfile_params); $out .= img_mime($listofnames[$key]).' '.$listofnames[$key]; $out .= $formfile->showPreview(array(), $formfile_params[2], $formfile_params[4]); - if (!$this->withfilereadonly) - { + if (!$this->withfilereadonly) { $out .= ' '; //$out.= ' '.img_delete($langs->trans("Delete").''; } $out .= '
'; } - } elseif (empty($this->withmaindocfile)) // Do not show message if we asked to show the checkbox - { + } elseif (empty($this->withmaindocfile)) { // Do not show message if we asked to show the checkbox $out .= $langs->trans("NoAttachedFiles").'
'; } - if ($this->withfile == 2) // Can add other files - { + if ($this->withfile == 2) { // Can add other files if (!empty($conf->global->FROM_MAIL_USE_INPUT_FILE_MULTIPLE)) $out .= ''; else $out .= ''; $out .= ' '; @@ -920,11 +864,9 @@ class FormMail extends Form } // Message - if (!empty($this->withbody)) - { + if (!empty($this->withbody)) { $defaultmessage = GETPOST('message', 'restricthtml'); - if (!GETPOST('modelselected', 'alpha') || GETPOST('modelmailselected') != '-1') - { + if (!GETPOST('modelselected', 'alpha') || GETPOST('modelmailselected') != '-1') { if ($arraydefaultmessage && $arraydefaultmessage->content) { $defaultmessage = $arraydefaultmessage->content; } elseif (!is_numeric($this->withbody)) { @@ -934,25 +876,29 @@ class FormMail extends Form // Complete substitution array with the url to make online payment $paymenturl = ''; $validpaymentmethod = array(); - if (empty($this->substit['__REF__'])) - { + if (empty($this->substit['__REF__'])) { $paymenturl = ''; } else { // Set the online payment url link into __ONLINE_PAYMENT_URL__ key require_once DOL_DOCUMENT_ROOT.'/core/lib/payments.lib.php'; $langs->loadLangs(array('paypal', 'other')); $typeforonlinepayment = 'free'; - if ($this->param["models"] == 'order' || $this->param["models"] == 'order_send') $typeforonlinepayment = 'order'; // TODO use detection on something else than template - if ($this->param["models"] == 'invoice' || $this->param["models"] == 'facture_send') $typeforonlinepayment = 'invoice'; // TODO use detection on something else than template - if ($this->param["models"] == 'member') $typeforonlinepayment = 'member'; // TODO use detection on something else than template + if ($this->param["models"] == 'order' || $this->param["models"] == 'order_send') { + $typeforonlinepayment = 'order'; // TODO use detection on something else than template + } + if ($this->param["models"] == 'invoice' || $this->param["models"] == 'facture_send') { + $typeforonlinepayment = 'invoice'; // TODO use detection on something else than template + } + if ($this->param["models"] == 'member') { + $typeforonlinepayment = 'member'; // TODO use detection on something else than template + } $url = getOnlinePaymentUrl(0, $typeforonlinepayment, $this->substit['__REF__']); $paymenturl = $url; $validpaymentmethod = getValidOnlinePaymentMethods(''); } - if (count($validpaymentmethod) > 0 && $paymenturl) - { + if (count($validpaymentmethod) > 0 && $paymenturl) { $langs->load('other'); $this->substit['__ONLINE_PAYMENT_TEXT_AND_URL__'] = str_replace('\n', "\n", $langs->transnoentities("PredefinedMailContentLink", $paymenturl)); $this->substit['__ONLINE_PAYMENT_URL__'] = $paymenturl; @@ -966,10 +912,8 @@ class FormMail extends Form // Add lines substitution key from each line $lines = ''; $defaultlines = $arraydefaultmessage->content_lines; - if (isset($defaultlines)) - { - foreach ($this->substit_lines as $substit_line) - { + if (isset($defaultlines)) { + foreach ($this->substit_lines as $substit_line) { $lines .= make_substitutions($defaultlines, $substit_line)."\n"; } } @@ -1003,8 +947,9 @@ class FormMail extends Form } } - if (GETPOSTISSET("message") && !$_POST['modelselected']) $defaultmessage = $_POST["message"]; - else { + if (GETPOSTISSET("message") && !$_POST['modelselected']) { + $defaultmessage = $_POST["message"]; + } else { $defaultmessage = make_substitutions($defaultmessage, $this->substit); // Clean first \n and br (to avoid empty line when CONTACTCIVNAME is empty) $defaultmessage = preg_replace("/^(
)+/", "", $defaultmessage); @@ -1016,17 +961,17 @@ class FormMail extends Form $out .= $form->textwithpicto($langs->trans('MailText'), $helpforsubstitution, 1, 'help', '', 0, 2, 'substittooltipfrombody'); $out .= ''; $out .= ''; - if ($this->withbodyreadonly) - { + if ($this->withbodyreadonly) { $out .= nl2br($defaultmessage); $out .= ''; } else { - if (!isset($this->ckeditortoolbar)) $this->ckeditortoolbar = 'dolibarr_notes'; + if (!isset($this->ckeditortoolbar)) { + $this->ckeditortoolbar = 'dolibarr_notes'; + } // Editor wysiwyg require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - if ($this->withfckeditor == -1) - { + if ($this->withfckeditor == -1) { if (!empty($conf->global->FCKEDITOR_ENABLE_MAIL)) $this->withfckeditor = 1; else $this->withfckeditor = 0; } @@ -1039,29 +984,27 @@ class FormMail extends Form $out .= ''."\n"; - if ($this->withform == 1 || $this->withform == -1) - { + if ($this->withform == 1 || $this->withform == -1) { $out .= '
'; $out .= 'withfile == 2 && $conf->use_javascript_ajax) - { + if ($this->withfile == 2 && $conf->use_javascript_ajax) { $out .= ' onClick="if (document.mailform.addedfile.value != \'\') { alert(\''.dol_escape_js($langs->trans("FileWasNotUploaded")).'\'); return false; } else { return true; }"'; } $out .= ' />'; - if ($this->withcancel) - { + if ($this->withcancel) { $out .= '     '; $out .= ''; } $out .= '
'."\n"; } - if ($this->withform == 1) $out .= ''."\n"; + if ($this->withform == 1) { + $out .= ''."\n"; + } // Disable enter key if option MAIN_MAILFORM_DISABLE_ENTERKEY is set - if (!empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY)) - { + if (!empty($conf->global->MAIN_MAILFORM_DISABLE_ENTERKEY)) { $out .= '