From f161b47cba0eae757700aa88c8c59b938e46432e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 10 Dec 2020 01:45:08 +0100 Subject: [PATCH 01/22] 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 e4b5ec122eee2f6a9f1017c92b5d226466af0a2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sat, 2 Jan 2021 16:38:19 +0100 Subject: [PATCH 02/22] syntax error --- htdocs/contrat/card.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index d07b8dcc60e..74d3436c453 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -373,8 +373,7 @@ if (empty($reshook)) $action = 'create'; } } - } elseif ($action == 'classin' && $user->rights->contrat->creer) - { + } elseif ($action == 'classin' && $user->rights->contrat->creer) { $object->setProject(GETPOST('projectid')); } @@ -385,7 +384,7 @@ if (empty($reshook)) $predef = ''; $product_desc = (GETPOSTISSET('dp_desc') ? GETPOST('dp_desc', 'restricthtml') : ''); $price_ht = price2num(GETPOST('price_ht'), 'MU'); - $price_ht_devise = price2num(GETPOST('multicurrency_price_ht', 'CR'); + $price_ht_devise = price2num(GETPOST('multicurrency_price_ht', 'CR')); if (GETPOST('prod_entry_mode', 'alpha') == 'free') { $idprod = 0; From ade0e008e9c8c80c2db310eb6c0c82bb489dd5e1 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Sat, 2 Jan 2021 17:42:33 +0100 Subject: [PATCH 03/22] Some debug on Shipments. Wrong object status on list paging. Parameter error on link contact. nbr Linked files not shown in tab badge. --- htdocs/core/lib/sendings.lib.php | 2 +- htdocs/expedition/contact.php | 2 +- htdocs/expedition/list.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index cf1d1793a88..0bb0db6afd1 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -81,7 +81,7 @@ function shipping_prepare_head($object) require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/link.class.php'; - $upload_dir = $conf->commande->dir_output."/".dol_sanitizeFileName($object->ref); + $upload_dir = $conf->expedition->dir_output."/sending/".dol_sanitizeFileName($object->ref); $nbFiles = count(dol_dir_list($upload_dir, 'files', 0, '', '(\.meta|_preview.*\.png)$')); $nbLinks = Link::count($db, $object->element, $object->id); $head[$h][0] = DOL_URL_ROOT.'/expedition/document.php?id='.$object->id; diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index c6b10bd6967..ffdd395cffc 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -80,7 +80,7 @@ if ($action == 'addcontact' && $user->rights->expedition->creer) { if ($result > 0 && $id > 0) { - $result = $objectsrc->add_contact(GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'), $_POST["type"], $_POST["source"]); + $result = $objectsrc->add_contact(GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'), $_POST["typecontact"], $_POST["source"]); } if ($result >= 0) diff --git a/htdocs/expedition/list.php b/htdocs/expedition/list.php index eaae2438b55..4494db8c21d 100644 --- a/htdocs/expedition/list.php +++ b/htdocs/expedition/list.php @@ -340,7 +340,7 @@ if ($resql) if ($search_product_category != '') $param .= '&search_product_category='.urlencode($search_product_category); if ($search_categ_cus > 0) $param .= '&search_categ_cus='.urlencode($search_categ_cus); - if ($search_status != '') $param .= '&viewstatut='.urlencode($search_status); + if ($search_status != '') $param .= '&search_status='.urlencode($search_status); if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss); // Add $param from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; From 799927432c349653c566f45164c5fe9d347fb587 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Sun, 3 Jan 2021 10:53:48 +0100 Subject: [PATCH 04/22] regression for user type on shipment contact --- htdocs/expedition/contact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index ffdd395cffc..09559a64a2c 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -80,7 +80,7 @@ if ($action == 'addcontact' && $user->rights->expedition->creer) { if ($result > 0 && $id > 0) { - $result = $objectsrc->add_contact(GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'), $_POST["typecontact"], $_POST["source"]); + $result = $objectsrc->add_contact(GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'), GETPOST('type') ? GETPOST('type') : GETPOST('typecontact'), GETPOST('source')); } if ($result >= 0) From cbf6fe1f6282e69fe04dd550cae646af3cade65c Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Sun, 3 Jan 2021 11:42:11 +0100 Subject: [PATCH 05/22] Clean code --- htdocs/expedition/contact.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index 09559a64a2c..c5d74a2f39d 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -80,7 +80,9 @@ if ($action == 'addcontact' && $user->rights->expedition->creer) { if ($result > 0 && $id > 0) { - $result = $objectsrc->add_contact(GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'), GETPOST('type') ? GETPOST('type') : GETPOST('typecontact'), GETPOST('source')); + $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $objectsrc->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } if ($result >= 0) From 50d2e2d16153345ac88e21892be2b50f0f1a7eb1 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Sun, 3 Jan 2021 12:21:20 +0100 Subject: [PATCH 06/22] Debug reception contacts and list --- htdocs/reception/contact.php | 9 +++------ htdocs/reception/list.php | 2 +- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/htdocs/reception/contact.php b/htdocs/reception/contact.php index 908f7a441be..ad8811a4e1f 100644 --- a/htdocs/reception/contact.php +++ b/htdocs/reception/contact.php @@ -67,11 +67,6 @@ if ($id > 0 || !empty($ref)) $objectsrc = new CommandeFournisseur($db); $objectsrc->fetch($object->$typeobject->id); } - if ($typeobject == 'propal' && $object->$typeobject->id && !empty($conf->propal->enabled)) - { - $objectsrc = new Propal($db); - $objectsrc->fetch($object->$typeobject->id); - } } @@ -83,7 +78,9 @@ if ($action == 'addcontact' && $user->rights->reception->creer) { if ($result > 0 && $id > 0) { - $result = $objectsrc->add_contact(GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid'), $_POST["type"], $_POST["source"]); + $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); + $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); + $result = $objectsrc->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } if ($result >= 0) diff --git a/htdocs/reception/list.php b/htdocs/reception/list.php index ec08c7ba94a..30d31291a74 100644 --- a/htdocs/reception/list.php +++ b/htdocs/reception/list.php @@ -505,7 +505,7 @@ if ($resql) if ($search_town) $param .= "&search_town=".urlencode($search_town); if ($search_zip) $param .= "&search_zip=".urlencode($search_zip); if ($search_state) $param .= "&search_state=".urlencode($search_state); - if ($search_status) $param .= "&search_status=".urlencode($search_status); + if ($search_status != '') $param .= "&search_status=".urlencode($search_status); if ($search_country) $param .= "&search_country=".urlencode($search_country); if ($search_type_thirdparty) $param .= "&search_type_thirdparty=".urlencode($search_type_thirdparty); if ($search_ref_supplier) $param .= "&search_ref_supplier=".urlencode($search_ref_supplier); From 236ff2d4e47ceb37c683031caabb0eb5769f8839 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Sun, 3 Jan 2021 12:26:10 +0100 Subject: [PATCH 07/22] indent --- htdocs/expedition/contact.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index c5d74a2f39d..d15e267b285 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -80,7 +80,7 @@ if ($action == 'addcontact' && $user->rights->expedition->creer) { if ($result > 0 && $id > 0) { - $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); + $contactid = (GETPOST('userid', 'int') ? GETPOST('userid', 'int') : GETPOST('contactid', 'int')); $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); $result = $objectsrc->add_contact($contactid, $typeid, GETPOST("source", 'aZ09')); } From 8df5928e9c5b92e6574352ce847fe226c7b3e52d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Jan 2021 13:32:43 +0100 Subject: [PATCH 08/22] Fix selection must depends on enabled modules --- htdocs/compta/accounting-files.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 734d21b1c87..02098e986ba 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -549,16 +549,17 @@ if (!empty($conf->multicompany->enabled) && is_object($mc)) print '
'; $listofchoices = array( - 'selectinvoices'=>array('label'=>'Invoices', 'lang'=>'bills'), - 'selectsupplierinvoices'=>array('label'=>'BillsSuppliers', 'lang'=>'bills'), - 'selectexpensereports'=>array('label'=>'ExpenseReports', 'lang'=>'trips'), - 'selectdonations'=>array('label'=>'Donations', 'lang'=>'donation'), - 'selectpaymentsofsalaries'=>array('label'=>'SalariesPayments', 'lang'=>'salaries'), - 'selectsocialcontributions'=>array('label'=>'SocialContributions'), - 'selectvariouspayment'=>array('label'=>'VariousPayment'), - 'selectloanspayment'=>array('label'=>'PaymentLoan'), + 'selectinvoices'=>array('label'=>'Invoices', 'lang'=>'bills', 'enabled' => !empty($conf->facture->enabled)), + 'selectsupplierinvoices'=>array('label'=>'BillsSuppliers', 'lang'=>'bills', 'enabled' => !empty($conf->supplier_invoice->enabled)), + 'selectexpensereports'=>array('label'=>'ExpenseReports', 'lang'=>'trips', 'enabled' => !empty($conf->expensereport->enabled)), + 'selectdonations'=>array('label'=>'Donations', 'lang'=>'donation', 'enabled' => !empty($conf->don->enabled)), + 'selectsocialcontributions'=>array('label'=>'SocialContributions', 'enabled' => !empty($conf->tax->enabled)), + 'selectpaymentsofsalaries'=>array('label'=>'SalariesPayments', 'lang'=>'salaries', 'enabled' => !empty($conf->salaries->enabled)), + 'selectvariouspayment'=>array('label'=>'VariousPayment', 'enabled' => !empty($conf->banque->enabled)), + 'selectloanspayment'=>array('label'=>'PaymentLoan', 'enabled' => !empty($conf->loan->enabled)), ); foreach ($listofchoices as $choice => $val) { + if (empty($val['enabled'])) continue; // list not qualified $checked = (((!GETPOSTISSET('search') && $action != 'searchfiles') || GETPOST($choice)) ? ' checked="checked"' : ''); print '
'; } From ef76c067e07334f746a1c727ea79c7270fe9b9ed Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Jan 2021 13:37:21 +0100 Subject: [PATCH 09/22] Add limit to 25000 --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e1d64da77f1..3bf47b7da7a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4615,7 +4615,7 @@ function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $be } if ((int) $limit > 0 && empty($hideselectlimit)) { - $pagesizechoices = '10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000,5000:5000'; + $pagesizechoices = '10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000,5000:5000,25000:25000'; //$pagesizechoices.=',0:'.$langs->trans("All"); // Not yet supported //$pagesizechoices.=',2:2'; if (!empty($conf->global->MAIN_PAGESIZE_CHOICES)) $pagesizechoices = $conf->global->MAIN_PAGESIZE_CHOICES; From 7141fa315ea7968e885bee55a4674435342bc192 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Jan 2021 15:32:18 +0100 Subject: [PATCH 10/22] Debug v13 --- htdocs/compta/paiement.php | 6 +++--- htdocs/core/tpl/object_discounts.tpl.php | 12 ++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index a03fd03ffef..83393a52cb6 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -710,10 +710,10 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Price print ''.price($sign * $objp->total_ttc).''; - // Received or paid back + // Received + already paid print ''.price($sign * $paiement); - if ($creditnotes) print '+'.price($creditnotes); - if ($deposits) print '+'.price($deposits); + if ($creditnotes) print '+'.price($creditnotes).''; + if ($deposits) print '+'.price($deposits).''; print ''; // Remain to take or to pay back diff --git a/htdocs/core/tpl/object_discounts.tpl.php b/htdocs/core/tpl/object_discounts.tpl.php index 7bc98d12278..293ea333682 100644 --- a/htdocs/core/tpl/object_discounts.tpl.php +++ b/htdocs/core/tpl/object_discounts.tpl.php @@ -62,7 +62,11 @@ if ($absolute_discount > 0) { $text .= ' ('.$addabsolutediscount.')'; } - print '
'.$text.'
'; + if ($isNewObject) { + print '
'.$text; + } else { + print '
'.$text.'
'; + } } else { // Discount available of type fixed amount (not credit note) $more = '('.$addabsolutediscount.')'; @@ -85,7 +89,11 @@ if ($absolute_creditnote > 0) { $text .= '('.$addabsolutediscount.')'; } - print '
'.$text.'
'; + if ($isNewObject) { + print '
'.$text; + } else { + print '
'.$text.'
'; + } } else { // We can add a credit note on a down payment or standard invoice or situation invoice // There is credit notes discounts available $more = $isInvoice && !$isNewObject ? ' ('.$viewabsolutediscount.')' : ''; From 62d91c3631ec209fac7d08587974f0e3defcb476 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 4 Jan 2021 16:07:47 +0100 Subject: [PATCH 11/22] 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 c58451dbb6aeaea9833d66365e475e2dec250a67 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Jan 2021 16:07:54 +0100 Subject: [PATCH 12/22] Code comment --- htdocs/core/class/commonobject.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 47c025b0c0a..af0a625875f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6845,6 +6845,7 @@ abstract class CommonObject break; } + // Output value of the current field if ($extrafields->attributes[$this->table_element]['type'][$key] == 'separate') { $extrafields_collapse_num = ''; From f8fe7b5a0e2305060722fe2e377ffce465a3e3d5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 4 Jan 2021 16:38:09 +0100 Subject: [PATCH 13/22] FIX #15851 --- htdocs/user/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/user/list.php b/htdocs/user/list.php index e7a8a31af4e..9a1a06f5a17 100644 --- a/htdocs/user/list.php +++ b/htdocs/user/list.php @@ -345,7 +345,7 @@ if ($catid > 0) $sql .= " AND cu.fk_categorie = ".((int) $catid); if ($catid == -2) $sql .= " AND cu.fk_categorie IS NULL"; if ($search_categ > 0) $sql .= " AND cu.fk_categorie = ".$db->escape($search_categ); if ($search_categ == -2) $sql .= " AND cu.fk_categorie IS NULL"; -if ($mode == 'employee' && empty($user->rights->salaries->readall)) $sql .= " AND s.fk_user IN (".join(',', $childids).")"; +if ($mode == 'employee' && empty($user->rights->salaries->readall)) $sql .= " AND u.fk_user IN (".join(',', $childids).")"; // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks From dd55f9ca9159de6e6b91f567c855414e8a471c21 Mon Sep 17 00:00:00 2001 From: zuiko Date: Mon, 4 Jan 2021 21:46:47 +0100 Subject: [PATCH 14/22] 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 15/22] 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 16/22] 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 .= '