From f85b6315fbfbafb9ba3a17752f16c62997725993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Courtier?= Date: Thu, 3 Nov 2022 16:46:15 +0100 Subject: [PATCH 01/99] FIX: Wrong Extrafields Element For Assets" --- htdocs/asset/admin/assets_extrafields.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/asset/admin/assets_extrafields.php b/htdocs/asset/admin/assets_extrafields.php index 9a68f99fe06..0c9267a6550 100644 --- a/htdocs/asset/admin/assets_extrafields.php +++ b/htdocs/asset/admin/assets_extrafields.php @@ -41,7 +41,7 @@ foreach ($tmptype2label as $key => $val) { $action = GETPOST('action', 'aZ09'); $attrname = GETPOST('attrname', 'alpha'); -$elementtype = 'don'; //Must be the $table_element of the class that manage extrafield +$elementtype = 'asset'; //Must be the $table_element of the class that manage extrafield if (!$user->admin) { accessforbidden(); From 6dbc57998a362dca3834c022bf9a8892f7183909 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 4 Nov 2022 11:51:47 +0100 Subject: [PATCH 02/99] Fix Object Linked MO Line --- htdocs/core/class/html.form.class.php | 5 +- htdocs/mrp/tpl/linkedobjectblock.tpl.php | 92 ++++++++++++++++-------- 2 files changed, 64 insertions(+), 33 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 5efbdeae8e1..6caf54638c9 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7544,7 +7544,6 @@ class Form public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0, $selected_input_value = '') { global $conf, $user; - $objecttmp = null; // Example of value for $objectdec: @@ -7771,7 +7770,7 @@ class Form } $sql .= $this->db->order($sortfield ? $sortfield : $fieldstoshow, "ASC"); //$sql.=$this->db->plimit($limit, 0); - //print $sql; +// print $sql; // Build output string $resql = $this->db->query($sql); @@ -8509,7 +8508,6 @@ class Form { global $conf, $langs, $hookmanager; global $bc, $action; - $object->fetchObjectLinked(); // Bypass the default method @@ -8624,6 +8622,7 @@ class Form // Output template part (modules that overwrite templates must declare this into descriptor) $dirtpls = array_merge($conf->modules_parts['tpl'], array('/'.$tplpath.'/tpl')); + foreach ($dirtpls as $reldir) { if ($nboftypesoutput == ($nbofdifferenttypes - 1)) { // No more type to show after global $noMoreLinkedObjectBlockAfter; diff --git a/htdocs/mrp/tpl/linkedobjectblock.tpl.php b/htdocs/mrp/tpl/linkedobjectblock.tpl.php index 9374fc2e4d0..7189228abe0 100644 --- a/htdocs/mrp/tpl/linkedobjectblock.tpl.php +++ b/htdocs/mrp/tpl/linkedobjectblock.tpl.php @@ -39,44 +39,76 @@ $langs->load("bom"); $total = 0; $ilink = 0; -$mo_static = new Mo($db); -$res = $mo_static->fetch($object->id); -$TMoChilds = $mo_static->getMoChilds(); +if($object->element == 'mo') { -foreach ($TMoChilds as $key => $objectlink) { - $ilink++; + $mo_static = new Mo($db); + $res = $mo_static->fetch($object->id); + $TMoChilds = $mo_static->getMoChilds(); - $trclass = 'oddeven'; - echo ''; - echo ''.$langs->trans("ManufacturingOrder"); - if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { - print ' $objectlink) { + $ilink++; + + $trclass = 'oddeven'; + + echo ''; + echo '' . $langs->trans("ManufacturingOrder"); + if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { + print ' '; + echo '' . $objectlink->getNomUrl(1) . ''; + + echo ''; + // $result = $product_static->fetch($objectlink->fk_product); + print ''; + echo '' . dol_print_date($objectlink->date_creation, 'day') . ''; + echo '-'; + echo '' . $objectlink->getLibStatut(3) . ''; + echo ''; + + // we want to make the link via element_element for delete action + $sql = " Select rowid from " . MAIN_DB_PREFIX . "element_element"; + $sql .= " WHERE fk_source = " . (int)$object->id . " and fk_target = '" . dol_escape_htmltag($key) . "'"; + + $resql = $db->query($sql); + $k = 0; + if ($resql) { + $obj = $db->fetch_object($resql); + if ($obj->rowid && $obj->rowid > 0) $k = $obj->rowid; + } + echo '' . img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink') . ''; + echo ''; + echo "\n"; } - echo ''; - echo ''.$objectlink->getNomUrl(1).''; +} else { + $linkedObjectBlock = dol_sort_array($linkedObjectBlock, 'date', 'desc', 0, 0, 1); - echo ''; - // $result = $product_static->fetch($objectlink->fk_product); - print ''; - echo ''.dol_print_date($objectlink->date_creation, 'day').''; - echo '-'; - echo ''.$objectlink->getLibStatut(3).''; - echo ''; + $total = 0; + $ilink = 0; + foreach ($linkedObjectBlock as $key => $objectlink) { + $ilink++; - // we want to make the link via element_element for delete action - $sql = " Select rowid from " . MAIN_DB_PREFIX . "element_element"; - $sql .= " WHERE fk_source = ". (int) $object->id . " and fk_target = '" . dol_escape_htmltag($key) ."'"; + $trclass = 'oddeven'; + if ($ilink == count($linkedObjectBlock) && empty($noMoreLinkedObjectBlockAfter) && count($linkedObjectBlock) <= 1) { + $trclass .= ' liste_sub_total'; + } + print ''; + print ''.$langs->trans("ManufacturingOrder"); + if (!empty($showImportButton) && $conf->global->MAIN_ENABLE_IMPORT_LINKED_OBJECT_LINES) { + $url = DOL_URL_ROOT.'/mrp/mo_card.php?id='.$objectlink->id; + print ' '; + } + print ''; - $resql = $db->query($sql); - $k = 0; - if ($resql) { - $obj = $db->fetch_object($resql); - if ($obj->rowid && $obj->rowid > 0 ) $k = $obj->rowid; + print ''.$objectlink->getNomUrl(1).''; + print ''.$objectlink->ref_client.''; + print ''.dol_print_date($objectlink->date_start_planned, 'day').''; + print '-'; + print ''.$objectlink->getLibStatut(3).''; + print ''.img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink').''; + print "\n"; } - echo '' . img_picto($langs->transnoentitiesnoconv("RemoveLink"), 'unlink') . ''; - echo ''; - echo "\n"; } echo "\n"; From d166ae9167d6d2d5eb892c67e357590304479f32 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 8 Nov 2022 09:46:55 +0100 Subject: [PATCH 03/99] MOChild => Linked Object --- htdocs/mrp/mo_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/mrp/mo_card.php b/htdocs/mrp/mo_card.php index 2c333ff616e..b7d3f86b9e7 100644 --- a/htdocs/mrp/mo_card.php +++ b/htdocs/mrp/mo_card.php @@ -731,7 +731,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Show links to link elements $linktoelem = $form->showLinkToObjectBlock($object, null, array('mo')); - $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, false, 'MOChild'); + $somethingshown = $form->showLinkedObjectBlock($object, $linktoelem, false); print '
'; From 0a9c0d704e59dee43c8f0346dc15c928ead37897 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 8 Nov 2022 09:49:20 +0100 Subject: [PATCH 04/99] Clean --- htdocs/core/class/html.form.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 6caf54638c9..50b1e226739 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7770,7 +7770,7 @@ class Form } $sql .= $this->db->order($sortfield ? $sortfield : $fieldstoshow, "ASC"); //$sql.=$this->db->plimit($limit, 0); -// print $sql; + //print $sql; // Build output string $resql = $this->db->query($sql); @@ -8622,7 +8622,6 @@ class Form // Output template part (modules that overwrite templates must declare this into descriptor) $dirtpls = array_merge($conf->modules_parts['tpl'], array('/'.$tplpath.'/tpl')); - foreach ($dirtpls as $reldir) { if ($nboftypesoutput == ($nbofdifferenttypes - 1)) { // No more type to show after global $noMoreLinkedObjectBlockAfter; From f4cf7363bd20cf18a7e50b0d794dd9e0f1d51247 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Tue, 8 Nov 2022 09:50:54 +0100 Subject: [PATCH 05/99] Clean code --- htdocs/core/class/html.form.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 50b1e226739..5efbdeae8e1 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -7544,6 +7544,7 @@ class Form public function selectForForms($objectdesc, $htmlname, $preselectedvalue, $showempty = '', $searchkey = '', $placeholder = '', $morecss = '', $moreparams = '', $forcecombo = 0, $disabled = 0, $selected_input_value = '') { global $conf, $user; + $objecttmp = null; // Example of value for $objectdec: @@ -8508,6 +8509,7 @@ class Form { global $conf, $langs, $hookmanager; global $bc, $action; + $object->fetchObjectLinked(); // Bypass the default method From 15a2f71534f1b34c6f15888abbd2fbe6443e2fcd Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 8 Nov 2022 08:55:25 +0000 Subject: [PATCH 06/99] Fixing style errors. --- htdocs/mrp/tpl/linkedobjectblock.tpl.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/mrp/tpl/linkedobjectblock.tpl.php b/htdocs/mrp/tpl/linkedobjectblock.tpl.php index 7189228abe0..dfa6d9797c2 100644 --- a/htdocs/mrp/tpl/linkedobjectblock.tpl.php +++ b/htdocs/mrp/tpl/linkedobjectblock.tpl.php @@ -39,8 +39,7 @@ $langs->load("bom"); $total = 0; $ilink = 0; -if($object->element == 'mo') { - +if ($object->element == 'mo') { $mo_static = new Mo($db); $res = $mo_static->fetch($object->id); $TMoChilds = $mo_static->getMoChilds(); @@ -69,7 +68,7 @@ if($object->element == 'mo') { // we want to make the link via element_element for delete action $sql = " Select rowid from " . MAIN_DB_PREFIX . "element_element"; - $sql .= " WHERE fk_source = " . (int)$object->id . " and fk_target = '" . dol_escape_htmltag($key) . "'"; + $sql .= " WHERE fk_source = " . (int) $object->id . " and fk_target = '" . dol_escape_htmltag($key) . "'"; $resql = $db->query($sql); $k = 0; From 31153a85d199b7f2a822231cfcde5810f301c5e1 Mon Sep 17 00:00:00 2001 From: Lamrani Abdel Date: Tue, 8 Nov 2022 17:49:15 +0100 Subject: [PATCH 07/99] fix issue for variable does not seem to exist --- htdocs/core/class/commoninvoice.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commoninvoice.class.php b/htdocs/core/class/commoninvoice.class.php index 2a185b362be..cac46635ce8 100644 --- a/htdocs/core/class/commoninvoice.class.php +++ b/htdocs/core/class/commoninvoice.class.php @@ -1740,8 +1740,8 @@ abstract class CommonInvoice extends CommonObject if ($this->ref_client) { $complementaryinfo .= '/20/'.$this->ref_client; } - if ($this->thirdparty->vat_number) { - $complementaryinfo .= '/30/'.$this->thirdparty->vat_number; + if ($this->thirdparty->tva_intra) { + $complementaryinfo .= '/30/'.$this->thirdparty->tva_intra; } // Header From 40e0bc21909f4770faf830a795b50a46efe7a225 Mon Sep 17 00:00:00 2001 From: FLIO Date: Wed, 9 Nov 2022 12:13:57 +0100 Subject: [PATCH 08/99] Fix(Scrutinizer) replace return get with the good --- htdocs/recruitment/class/api_recruitment.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/recruitment/class/api_recruitment.class.php b/htdocs/recruitment/class/api_recruitment.class.php index af2c87dcdb3..cf4fa7a143e 100644 --- a/htdocs/recruitment/class/api_recruitment.class.php +++ b/htdocs/recruitment/class/api_recruitment.class.php @@ -441,7 +441,7 @@ class Recruitment extends DolibarrApi // $this->jobposition->abc = sanitizeVal($this->jobposition->abc, 'alphanohtml'); if ($this->jobposition->update(DolibarrApiAccess::$user, false) > 0) { - return $this->get($id); + return $this->getJobPosition($id); } else { throw new RestException(500, $this->jobposition->error); } @@ -484,7 +484,7 @@ class Recruitment extends DolibarrApi // $this->jobposition->abc = sanitizeVal($this->jobposition->abc, 'alphanohtml'); if ($this->candidature->update(DolibarrApiAccess::$user, false) > 0) { - return $this->get($id); + return $this->getCandidature($id); } else { throw new RestException(500, $this->candidature->error); } From 8cb7b7e8ef8b8e4129186c96ad30dccfee806543 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 10 Nov 2022 10:03:51 +0100 Subject: [PATCH 09/99] fix extrafields create in holiday card --- htdocs/holiday/card.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index ae0f605e512..403a1eb47b5 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -5,7 +5,7 @@ * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2017 Alexandre Spangaro * Copyright (C) 2014-2017 Ferran Marcet - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2022 Frédéric France * Copyright (C) 2020-2021 Udo Tamm * Copyright (C) 2022 Anthony Berton * @@ -253,6 +253,12 @@ if (empty($reshook)) { $error++; } + // Fill array 'array_options' with data from add form + $ret = $extrafields->setOptionalsFromPost(null, $object); + if ($ret < 0) { + $error++; + } + $result = 0; if (!$error) { From 5a1f1bf058c2893ae8d6eb7c4741c03a5d9a753b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 10 Nov 2022 10:12:46 +0100 Subject: [PATCH 10/99] Update list.php --- htdocs/holiday/list.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/holiday/list.php b/htdocs/holiday/list.php index b4985100e44..c32259e42e1 100644 --- a/htdocs/holiday/list.php +++ b/htdocs/holiday/list.php @@ -3,7 +3,7 @@ * Copyright (C) 2013-2020 Laurent Destailleur * Copyright (C) 2012-2016 Regis Houssin * Copyright (C) 2018 Charlene Benke - * Copyright (C) 2019-2021 Frédéric France + * Copyright (C) 2019-2022 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -908,6 +908,8 @@ if ($resql) { } } } + // status + print ''; print ''; } } From dba6c681815411d9e0f890d708e8b91a75e22fb6 Mon Sep 17 00:00:00 2001 From: Thomas Negre Date: Thu, 10 Nov 2022 16:55:23 +0100 Subject: [PATCH 11/99] Fix supplier proposal clone : when a line subprice is empty, it should be saved as 0 in the Database, not null. --- htdocs/supplier_proposal/class/supplier_proposal.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php index 6b76cf23af6..78fc1c7fd15 100644 --- a/htdocs/supplier_proposal/class/supplier_proposal.class.php +++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php @@ -3035,7 +3035,7 @@ class SupplierProposalLine extends CommonObjectLine $sql .= " ".price2num($this->localtax2_tx).","; $sql .= " '".$this->db->escape($this->localtax1_type)."',"; $sql .= " '".$this->db->escape($this->localtax2_type)."',"; - $sql .= " ".(!empty($this->subprice) ?price2num($this->subprice) : "null").","; + $sql .= " ".(!empty($this->subprice) ?price2num($this->subprice) : 0).","; $sql .= " ".price2num($this->remise_percent).","; $sql .= " ".(isset($this->info_bits) ? "'".$this->db->escape($this->info_bits)."'" : "null").","; $sql .= " ".price2num($this->total_ht).","; From 5218b2f804a32e6195564e71a486688376f986e7 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 11 Nov 2022 12:44:20 +0100 Subject: [PATCH 12/99] Fix token error in pice.php --- htdocs/product/price.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 5dcb08dc238..d93fdbe9b17 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -1208,9 +1208,9 @@ if (!empty($conf->global->PRODUIT_MULTIPRICES) || !empty($conf->global->PRODUIT_ if (!empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY) || !empty($conf->global->PRODUIT_CUSTOMER_PRICES_BY_QTY_MULTIPRICES)) { // TODO Fix the form inside tr instead of td print ''.$langs->trans("PriceByQuantity"); if ($object->prices_by_qty[0] == 0) { - print '  ('.$langs->trans("Activate").')'; + print '  ('.$langs->trans("Activate").')'; } else { - print '  ('.$langs->trans("DisablePriceByQty").')'; + print '  ('.$langs->trans("DisablePriceByQty").')'; } print ''; From d05abce43f8de498a7ae96e39f795f1bbb652455 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 11 Nov 2022 16:24:07 +0100 Subject: [PATCH 13/99] FIX edition notes --- htdocs/core/tpl/notes.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/notes.tpl.php b/htdocs/core/tpl/notes.tpl.php index 0430ec16e0e..dbb27a99800 100644 --- a/htdocs/core/tpl/notes.tpl.php +++ b/htdocs/core/tpl/notes.tpl.php @@ -63,7 +63,7 @@ if (!empty($conf->global->MAIN_AUTO_TIMESTAMP_IN_PRIVATE_NOTES)) { // Special cases if ($module == 'propal') { - $permission = $user->hasRight("propale", "creer"); + $permission = $user->hasRight("propal", "creer"); } elseif ($module == 'supplier_proposal') { $permission = $user->hasRight("supplier_proposal", "creer"); } elseif ($module == 'fichinter') { From f82a9edbbdff1946d488f1dc3f20ce7adccb8004 Mon Sep 17 00:00:00 2001 From: FLIO Date: Mon, 14 Nov 2022 15:10:55 +0100 Subject: [PATCH 14/99] Fix(Scrutinizer) replace erros -> errors https://scrutinizer-ci.com/g/Dolibarr/dolibarr/issues/develop/files/htdocs/core/modules/modBlockedLog.class.php?selectedLabels%5B0%5D=9&orderField=lastFound&order=desc&honorSelectedPaths=0 --- htdocs/core/modules/modBlockedLog.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index 0a07fff6aaf..830f9f0f8b1 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -183,7 +183,7 @@ class modBlockedLog extends DolibarrModules $result = $b->setObjectData($object, 'MODULE_SET', 0); if ($result < 0) { $this->error = $b->error; - $this->errors = $b->erros; + $this->errors = $b->errors; return 0; } @@ -226,7 +226,7 @@ class modBlockedLog extends DolibarrModules $result = $b->setObjectData($object, 'MODULE_RESET', 0); if ($result < 0) { $this->error = $b->error; - $this->errors = $b->erros; + $this->errors = $b->errors; return 0; } From eb63c8c5c688e4de64c1381210048558e5259444 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 14 Nov 2022 15:32:16 +0100 Subject: [PATCH 15/99] Fix #11555 : Message display on adherent public --- htdocs/public/members/new.php | 209 +++++++++++++++++----------------- 1 file changed, 106 insertions(+), 103 deletions(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 055ffec56f9..1b7abaa0224 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -289,127 +289,129 @@ if (empty($reshook) && $action == 'add') { $error++; } - $result = $adh->create($user); - if ($result > 0) { - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $object = $adh; + if (!$error) { + $result = $adh->create($user); + if ($result > 0) { + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $object = $adh; - $adht = new AdherentType($db); - $adht->fetch($object->typeid); + $adht = new AdherentType($db); + $adht->fetch($object->typeid); - if ($object->email) { - $subject = ''; - $msg = ''; + if ($object->email) { + $subject = ''; + $msg = ''; - // Send subscription email - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - // Set output language - $outputlangs = new Translate('', $conf); - $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); - // Load traductions files required by page - $outputlangs->loadLangs(array("main", "members")); - // Get email content from template - $arraydefaultmessage = null; - $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER; + // Send subscription email + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + // Set output language + $outputlangs = new Translate('', $conf); + $outputlangs->setDefaultLang(empty($object->thirdparty->default_lang) ? $mysoc->default_lang : $object->thirdparty->default_lang); + // Load traductions files required by page + $outputlangs->loadLangs(array("main", "members")); + // Get email content from template + $arraydefaultmessage = null; + $labeltouse = $conf->global->ADHERENT_EMAIL_TEMPLATE_AUTOREGISTER; - if (!empty($labeltouse)) { - $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + if (!empty($labeltouse)) { + $arraydefaultmessage = $formmail->getEMailTemplate($db, 'member', $user, $outputlangs, 0, 1, $labeltouse); + } + + if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { + $subject = $arraydefaultmessage->topic; + $msg = $arraydefaultmessage->content; + } + + $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); + complete_substitutions_array($substitutionarray, $outputlangs, $object); + $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); + $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs); + + if ($subjecttosend && $texttosend) { + $moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n"; + + $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); + } + /*if ($result < 0) { + $error++; + setEventMessages($object->error, $object->errors, 'errors'); + }*/ } - if (!empty($labeltouse) && is_object($arraydefaultmessage) && $arraydefaultmessage->id > 0) { - $subject = $arraydefaultmessage->topic; - $msg = $arraydefaultmessage->content; - } - - $substitutionarray = getCommonSubstitutionArray($outputlangs, 0, null, $object); - complete_substitutions_array($substitutionarray, $outputlangs, $object); - $subjecttosend = make_substitutions($subject, $substitutionarray, $outputlangs); - $texttosend = make_substitutions(dol_concatdesc($msg, $adht->getMailOnValid()), $substitutionarray, $outputlangs); - - if ($subjecttosend && $texttosend) { - $moreinheader = 'X-Dolibarr-Info: send_an_email by public/members/new.php'."\r\n"; - - $result = $object->send_an_email($texttosend, $subjecttosend, array(), array(), array(), "", "", 0, -1, '', $moreinheader); - } - /*if ($result < 0) { - $error++; - setEventMessages($object->error, $object->errors, 'errors'); - }*/ - } - - // Send email to the foundation to say a new member subscribed with autosubscribe form - if (!empty($conf->global->MAIN_INFO_SOCIETE_MAIL) && !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT) && - !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL)) { - // Define link to login card - $appli = constant('DOL_APPLICATION_TITLE'); - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { - $appli = $conf->global->MAIN_APPLICATION_TITLE; - if (preg_match('/\d\.\d/', $appli)) { - if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) { - $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core + // Send email to the foundation to say a new member subscribed with autosubscribe form + if (!empty($conf->global->MAIN_INFO_SOCIETE_MAIL) && !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT) && + !empty($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL)) { + // Define link to login card + $appli = constant('DOL_APPLICATION_TITLE'); + if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { + $appli = $conf->global->MAIN_APPLICATION_TITLE; + if (preg_match('/\d\.\d/', $appli)) { + if (!preg_match('/'.preg_quote(DOL_VERSION).'/', $appli)) { + $appli .= " (".DOL_VERSION.")"; // If new title contains a version that is different than core + } + } else { + $appli .= " ".DOL_VERSION; } } else { $appli .= " ".DOL_VERSION; } + + $to = $adh->makeSubstitution($conf->global->MAIN_INFO_SOCIETE_MAIL); + $from = $conf->global->ADHERENT_MAIL_FROM; + $mailfile = new CMailFile( + '['.$appli.'] '.$conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT, + $to, + $from, + $adh->makeSubstitution($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL), + array(), + array(), + array(), + "", + "", + 0, + -1 + ); + + if (!$mailfile->sendfile()) { + dol_syslog($langs->trans("ErrorFailedToSendMail", $from, $to), LOG_ERR); + } + } + + if (!empty($backtopage)) { + $urlback = $backtopage; + } elseif (!empty($conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION)) { + $urlback = $conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION; + // TODO Make replacement of __AMOUNT__, etc... } else { - $appli .= " ".DOL_VERSION; + $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken(); } - $to = $adh->makeSubstitution($conf->global->MAIN_INFO_SOCIETE_MAIL); - $from = $conf->global->ADHERENT_MAIL_FROM; - $mailfile = new CMailFile( - '['.$appli.'] '.$conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL_SUBJECT, - $to, - $from, - $adh->makeSubstitution($conf->global->ADHERENT_AUTOREGISTER_NOTIF_MAIL), - array(), - array(), - array(), - "", - "", - 0, - -1 - ); + if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) && $conf->global->MEMBER_NEWFORM_PAYONLINE != '-1') { + if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { // If edition of amount not allowed + // TODO Check amount is same than the amount required for the type of member or if not defined as the defeault amount into $conf->global->MEMBER_NEWFORM_AMOUNT + // It is not so important because a test is done on return of payment validation. + } - if (!$mailfile->sendfile()) { - dol_syslog($langs->trans("ErrorFailedToSendMail", $from, $to), LOG_ERR); + $urlback = getOnlinePaymentUrl(0, 'member', $adh->ref, price2num(GETPOST('amount', 'alpha'), 'MT'), '', 0); + + if (GETPOST('email')) { + $urlback .= '&email='.urlencode(GETPOST('email')); + } + if ($conf->global->MEMBER_NEWFORM_PAYONLINE != '-1' && $conf->global->MEMBER_NEWFORM_PAYONLINE != 'all') { + $urlback .= '&paymentmethod='.urlencode($conf->global->MEMBER_NEWFORM_PAYONLINE); + } + } else { + if (!empty($entity)) { + $urlback .= '&entity='.((int) $entity); + } } - } - if (!empty($backtopage)) { - $urlback = $backtopage; - } elseif (!empty($conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION)) { - $urlback = $conf->global->MEMBER_URL_REDIRECT_SUBSCRIPTION; - // TODO Make replacement of __AMOUNT__, etc... + dol_syslog("member ".$adh->ref." was created, we redirect to ".$urlback); } else { - $urlback = $_SERVER["PHP_SELF"]."?action=added&token=".newToken(); + $error++; + $errmsg .= join('
', $adh->errors); } - - if (!empty($conf->global->MEMBER_NEWFORM_PAYONLINE) && $conf->global->MEMBER_NEWFORM_PAYONLINE != '-1') { - if (empty($conf->global->MEMBER_NEWFORM_EDITAMOUNT)) { // If edition of amount not allowed - // TODO Check amount is same than the amount required for the type of member or if not defined as the defeault amount into $conf->global->MEMBER_NEWFORM_AMOUNT - // It is not so important because a test is done on return of payment validation. - } - - $urlback = getOnlinePaymentUrl(0, 'member', $adh->ref, price2num(GETPOST('amount', 'alpha'), 'MT'), '', 0); - - if (GETPOST('email')) { - $urlback .= '&email='.urlencode(GETPOST('email')); - } - if ($conf->global->MEMBER_NEWFORM_PAYONLINE != '-1' && $conf->global->MEMBER_NEWFORM_PAYONLINE != 'all') { - $urlback .= '&paymentmethod='.urlencode($conf->global->MEMBER_NEWFORM_PAYONLINE); - } - } else { - if (!empty($entity)) { - $urlback .= '&entity='.((int) $entity); - } - } - - dol_syslog("member ".$adh->ref." was created, we redirect to ".$urlback); - } else { - $error++; - $errmsg .= join('
', $adh->errors); } } @@ -469,6 +471,7 @@ if (!empty($conf->global->MEMBER_NEWFORM_TEXT)) { print '
'; dol_htmloutput_errors($errmsg); +dol_htmloutput_events(); // Print form print '
'."\n"; From d54e63b60d0f8d59f64ae2cd440ca9d3d11fd862 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Nov 2022 20:51:52 +0100 Subject: [PATCH 16/99] FIX #22813 --- htdocs/core/modules/modBlockedLog.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index 0c645099f56..a72d673042c 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -183,7 +183,7 @@ class modBlockedLog extends DolibarrModules $result = $b->setObjectData($object, 'MODULE_SET', 0); if ($result < 0) { $this->error = $b->error; - $this->errors = $b->erros; + $this->errors = $b->errors; return 0; } @@ -226,7 +226,7 @@ class modBlockedLog extends DolibarrModules $result = $b->setObjectData($object, 'MODULE_RESET', 0); if ($result < 0) { $this->error = $b->error; - $this->errors = $b->erros; + $this->errors = $b->errors; return 0; } From b766e6de662e7b8b5cfa0b4898d35c713fafa06b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Nov 2022 21:08:54 +0100 Subject: [PATCH 17/99] FIX #22786 --- htdocs/product/reassort.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/reassort.php b/htdocs/product/reassort.php index a711c630414..79498562210 100644 --- a/htdocs/product/reassort.php +++ b/htdocs/product/reassort.php @@ -141,7 +141,7 @@ $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // N $sql .= $hookmanager->resPrint; $sql .= ' FROM '.MAIN_DB_PREFIX.'product as p'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_stock as s ON p.rowid = s.fk_product'; -$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e ON s.fk_entrepot = e.rowid AND e.entity IN ('.getEntity('entrepot').')'; +$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'entrepot as e ON s.fk_entrepot = e.rowid AND e.entity IN ('.getEntity('stock').')'; if (!empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_units as u on p.fk_unit = u.rowid'; } From e604d18d0149b5c5f2e42a33512b93af453b0792 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Mon, 14 Nov 2022 22:10:15 +0100 Subject: [PATCH 18/99] FIX #22824 Accountancy - Journal - Search on subledger when list of subledger is disabled --- htdocs/accountancy/bookkeeping/list.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php index 087b410bcaf..5982a401809 100644 --- a/htdocs/accountancy/bookkeeping/list.php +++ b/htdocs/accountancy/bookkeeping/list.php @@ -346,6 +346,10 @@ if (empty($reshook)) { $filter['t.numero_compte<='] = $search_accountancy_code_end; $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end); } + if (!empty($search_accountancy_aux_code)) { + $filter['t.subledger_account'] = $search_accountancy_aux_code; + $param .= '&search_accountancy_aux_code='.urlencode($search_accountancy_aux_code); + } if (!empty($search_accountancy_aux_code_start)) { $filter['t.subledger_account>='] = $search_accountancy_aux_code_start; $param .= '&search_accountancy_aux_code_start='.urlencode($search_accountancy_aux_code_start); From cd2b9538c17c23ef2d2b375f546ac0f539959125 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 15 Nov 2022 11:51:20 +0100 Subject: [PATCH 19/99] FIx #18304 No adh create if error on public form FIX #18304 - Member subscription confirmation email sent even if mandatory fields are missing --- htdocs/public/members/new.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 7f788a84671..7b0ce31700b 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -279,7 +279,10 @@ if ($action == 'add') $ret = $extrafields->setOptionalsFromPost(null, $adh); if ($ret < 0) $error++; - $result = $adh->create($user); + if (empty($error)) { + $result = $adh->create($user); + } + if ($result > 0) { require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; From c81c91755de94921d86557c2767d1ffaad441ba6 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 15 Nov 2022 10:55:09 +0000 Subject: [PATCH 20/99] Fixing style errors. --- htdocs/public/members/new.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php index 7b0ce31700b..fba9edacaca 100644 --- a/htdocs/public/members/new.php +++ b/htdocs/public/members/new.php @@ -282,7 +282,7 @@ if ($action == 'add') if (empty($error)) { $result = $adh->create($user); } - + if ($result > 0) { require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; From 1912d61ae7e68686be3f5e607fb932cedb7cf9b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 15 Nov 2022 13:50:33 +0100 Subject: [PATCH 21/99] add hook to fetch product in list --- htdocs/product/list.php | 120 +++++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 57 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index e637e478df4..ca86dcee0a8 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1338,49 +1338,55 @@ while ($i < min($num, $limit)) { } } } + $parameters = array('staticdata' => $obj); + // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('loadStaticObject', $parameters, $product_static, $action); + if ($reshook < 0) { + $product_static->fetch($obj->rowid); + } else { + $product_static->id = $obj->rowid; + $product_static->ref = $obj->ref; + $product_static->ref_fourn = empty($obj->ref_supplier) ? '' : $obj->ref_supplier; // deprecated + $product_static->ref_supplier = empty($obj->ref_supplier) ? '' : $obj->ref_supplier; + $product_static->label = $obj->label; + $product_static->finished = $obj->finished; + $product_static->type = $obj->fk_product_type; + $product_static->status_buy = $obj->tobuy; + $product_static->status = $obj->tosell; + $product_static->status_batch = $obj->tobatch; + $product_static->entity = $obj->entity; + $product_static->pmp = $obj->pmp; + $product_static->accountancy_code_sell = $obj->accountancy_code_sell; + $product_static->accountancy_code_sell_export = $obj->accountancy_code_sell_export; + $product_static->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; + $product_static->accountancy_code_buy = $obj->accountancy_code_buy; + $product_static->accountancy_code_buy_intra = $obj->accountancy_code_buy_intra; + $product_static->accountancy_code_buy_export = $obj->accountancy_code_buy_export; + $product_static->length = $obj->length; + $product_static->length_units = $obj->length_units; + $product_static->width = $obj->width; + $product_static->width_units = $obj->width_units; + $product_static->height = $obj->height; + $product_static->height_units = $obj->height_units; + $product_static->weight = $obj->weight; + $product_static->weight_units = $obj->weight_units; + $product_static->volume = $obj->volume; + $product_static->volume_units = $obj->volume_units; + $product_static->surface = $obj->surface; + $product_static->surface_units = $obj->surface_units; + if (!empty($conf->global->PRODUCT_USE_UNITS)) { + $product_static->fk_unit = $obj->fk_unit; + } - $product_static->id = $obj->rowid; - $product_static->ref = $obj->ref; - $product_static->ref_fourn = empty($obj->ref_supplier) ? '' : $obj->ref_supplier; // deprecated - $product_static->ref_supplier = empty($obj->ref_supplier) ? '' : $obj->ref_supplier; - $product_static->label = $obj->label; - $product_static->finished = $obj->finished; - $product_static->type = $obj->fk_product_type; - $product_static->status_buy = $obj->tobuy; - $product_static->status = $obj->tosell; - $product_static->status_batch = $obj->tobatch; - $product_static->entity = $obj->entity; - $product_static->pmp = $obj->pmp; - $product_static->accountancy_code_sell = $obj->accountancy_code_sell; - $product_static->accountancy_code_sell_export = $obj->accountancy_code_sell_export; - $product_static->accountancy_code_sell_intra = $obj->accountancy_code_sell_intra; - $product_static->accountancy_code_buy = $obj->accountancy_code_buy; - $product_static->accountancy_code_buy_intra = $obj->accountancy_code_buy_intra; - $product_static->accountancy_code_buy_export = $obj->accountancy_code_buy_export; - $product_static->length = $obj->length; - $product_static->length_units = $obj->length_units; - $product_static->width = $obj->width; - $product_static->width_units = $obj->width_units; - $product_static->height = $obj->height; - $product_static->height_units = $obj->height_units; - $product_static->weight = $obj->weight; - $product_static->weight_units = $obj->weight_units; - $product_static->volume = $obj->volume; - $product_static->volume_units = $obj->volume_units; - $product_static->surface = $obj->surface; - $product_static->surface_units = $obj->surface_units; - if (!empty($conf->global->PRODUCT_USE_UNITS)) { - $product_static->fk_unit = $obj->fk_unit; - } - - // STOCK_DISABLE_OPTIM_LOAD can be set to force load_stock whatever is permissions on stock. - if ((isModEnabled('stock') && $user->rights->stock->lire && $search_type != 1) || !empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) { // To optimize call of load_stock - if ($obj->fk_product_type != 1 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { // Not a service - $option = 'nobatch'; - if (empty($arrayfields['stock_virtual']['checked'])) { - $option .= ',novirtual'; + // STOCK_DISABLE_OPTIM_LOAD can be set to force load_stock whatever is permissions on stock. + if ((isModEnabled('stock') && $user->rights->stock->lire && $search_type != 1) || !empty($conf->global->STOCK_DISABLE_OPTIM_LOAD)) { // To optimize call of load_stock + if ($product_static->type != 1 || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { // Not a service + $option = 'nobatch'; + if (empty($arrayfields['stock_virtual']['checked'])) { + $option .= ',novirtual'; + } + $product_static->load_stock($option); // Load stock_reel + stock_warehouse. This can also call load_virtual_stock() } - $product_static->load_stock($option); // Load stock_reel + stock_warehouse. This can also call load_virtual_stock() } } @@ -1454,7 +1460,7 @@ while ($i < min($num, $limit)) { // Label if (!empty($arrayfields['p.label']['checked'])) { - print ''.$obj->label.''; + print ''.$product_static->label.''; if (!$i) { $totalarray['nbfield']++; } @@ -1464,7 +1470,7 @@ while ($i < min($num, $limit)) { if (!empty($arrayfields['p.fk_product_type']['checked'])) { print ''; $s = ''; - if ($obj->fk_product_type == 0) { + if ($product_static->type == 0) { $s .= img_picto($langs->trans("Product"), 'product', 'class="paddingleftonly paddingrightonly colorgrey"'); } else { $s .= img_picto($langs->trans("Service"), 'service', 'class="paddingleftonly paddingrightonly colorgrey"'); @@ -1478,7 +1484,7 @@ while ($i < min($num, $limit)) { // Barcode if (!empty($arrayfields['p.barcode']['checked'])) { - print ''.$obj->barcode.''; + print ''.$product_static->barcode.''; if (!$i) { $totalarray['nbfield']++; } @@ -1727,7 +1733,7 @@ while ($i < min($num, $limit)) { // Better buy price if (!empty($arrayfields['p.minbuyprice']['checked'])) { print ''; - if ($obj->tobuy && $obj->bestpurchaseprice != '' && $usercancreadprice) { + if ($product_static->status_buy && $obj->bestpurchaseprice != '' && $usercancreadprice) { if ($product_fourn->find_min_price_product_fournisseur($obj->rowid) > 0) { if ($product_fourn->product_fourn_price_id > 0) { if ((isModEnabled("fournisseur") && !empty($user->rights->fournisseur->lire) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || (isModEnabled("supplier_order") && !empty($user->rights->supplier_order->lire)) || (isModEnabled("supplier_invoice") && !empty($user->rights->supplier_invoice->lire))) { @@ -1748,7 +1754,7 @@ while ($i < min($num, $limit)) { // Number of buy prices if (!empty($arrayfields['p.numbuyprice']['checked'])) { print ''; - if ($obj->tobuy && $usercancreadprice) { + if ($product_static->status_buy && $usercancreadprice) { if (count($productFournList = $product_fourn->list_product_fournisseur_price($obj->rowid)) > 0) { $htmltext = $product_fourn->display_price_product_fournisseur(1, 1, 0, 1, $productFournList); print $form->textwithpicto(count($productFournList), $htmltext); @@ -1788,7 +1794,7 @@ while ($i < min($num, $limit)) { // Limit alert if (!empty($arrayfields['p.seuil_stock_alerte']['checked'])) { print ''; - if ($obj->fk_product_type != 1) { + if ($product_static->type != 1) { print $obj->seuil_stock_alerte; } print ''; @@ -1799,7 +1805,7 @@ while ($i < min($num, $limit)) { // Desired stock if (!empty($arrayfields['p.desiredstock']['checked'])) { print ''; - if ($obj->fk_product_type != 1) { + if ($product_static->type != 1) { print $obj->desiredstock; } print ''; @@ -1810,7 +1816,7 @@ while ($i < min($num, $limit)) { // Stock real if (!empty($arrayfields['p.stock']['checked'])) { print ''; - if ($obj->fk_product_type != 1) { + if ($product_static->type != 1) { if ($obj->seuil_stock_alerte != '' && $product_static->stock_reel < (float) $obj->seuil_stock_alerte) { print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; } @@ -1826,7 +1832,7 @@ while ($i < min($num, $limit)) { // Stock virtual if (!empty($arrayfields['stock_virtual']['checked'])) { print ''; - if ($obj->fk_product_type != 1) { + if ($product_static->type != 1) { if ($obj->seuil_stock_alerte != '' && $product_static->stock_theorique < (float) $obj->seuil_stock_alerte) { print img_warning($langs->trans("StockLowerThanLimit", $obj->seuil_stock_alerte)).' '; } @@ -1868,38 +1874,38 @@ while ($i < min($num, $limit)) { } // Accountancy code sell if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell']['checked'])) { - print ''.$obj->accountancy_code_sell.''; + print ''.$product_static->accountancy_code_sell.''; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_intra']['checked'])) { - print ''.$obj->accountancy_code_sell_intra.''; + print ''.$product_static->accountancy_code_sell_intra.''; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_sell_export']['checked'])) { - print ''.$obj->accountancy_code_sell_export.''; + print ''.$product_static->accountancy_code_sell_export.''; if (!$i) { $totalarray['nbfield']++; } } // Accountancy code buy if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy']['checked'])) { - print ''.$obj->accountancy_code_buy.''; + print ''.$product_static->accountancy_code_buy.''; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_intra']['checked'])) { - print ''.$obj->accountancy_code_buy_intra.''; + print ''.$product_static->accountancy_code_buy_intra.''; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields[$alias_product_perentity . '.accountancy_code_buy_export']['checked'])) { - print ''.$obj->accountancy_code_buy_export.''; + print ''.$product_static->accountancy_code_buy_export.''; if (!$i) { $totalarray['nbfield']++; } @@ -1948,7 +1954,7 @@ while ($i < min($num, $limit)) { if (!empty($conf->use_javascript_ajax) && $user->hasRight("produit", "creer") && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { print ajax_object_onoff($product_static, 'status_buy', 'tobuy', 'ProductStatusOnBuy', 'ProductStatusNotOnBuy'); } else { - print $product_static->LibStatut($obj->tobuy, 5, 1); + print $product_static->LibStatut($product_static->status_buy, 5, 1); } print ''; if (!$i) { From a5aab68958187d38e827f949e881ba0fad2b1812 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Nov 2022 13:49:02 +0100 Subject: [PATCH 22/99] Fix duplicate data c_action_trigger and c_tva --- htdocs/install/mysql/data/llx_c_action_trigger.sql | 5 +---- htdocs/install/mysql/data/llx_c_tva.sql | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index e4936c53ba3..67770ec337d 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -119,9 +119,6 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_APPROVE','Expense report approved','Executed when an expense report is approved','expensereport',203); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_PAID','Expense report billed','Executed when an expense report is set as billed','expensereport',204); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_DELETE','Expense report deleted','Executed when an expense report is deleted','expensereport',205); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_VALIDATE','Expense report validated','Executed when an expense report is validated','expensereport',211); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_MODIFY','Expense report modified','Executed when an expense report is modified','expensereport',212); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_APPROVE','Expense report approved','Executed when an expense report is approved','expensereport',212); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_CREATE','Project creation','Executed when a project is created','project',140); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_VALIDATE','Project validation','Executed when a project is validated','project',141); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROJECT_MODIFY','Project modified','Executed when a project is modified','project',142); @@ -171,7 +168,7 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_CREATE','Holiday created','Executed when a holiday is created','holiday',800); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_MODIFY','Holiday modified','Executed when a holiday is modified','holiday',801); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_VALIDATE','Holiday validated','Executed when a holiday is validated','holiday',802); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_APPROVE','Holiday aprouved','Executed when a holiday is aprouved','holiday',803); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_APPROVE','Holiday approved','Executed when a holiday is aprouved','holiday',803); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_CANCEL','Holiday canceled','Executed when a holiday is canceled','holiday',802); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_DELETE','Holiday deleted','Executed when a holiday is deleted','holiday',804); diff --git a/htdocs/install/mysql/data/llx_c_tva.sql b/htdocs/install/mysql/data/llx_c_tva.sql index d78fea4ad4d..6c96cb46605 100644 --- a/htdocs/install/mysql/data/llx_c_tva.sql +++ b/htdocs/install/mysql/data/llx_c_tva.sql @@ -137,7 +137,6 @@ insert into llx_c_tva(rowid,fk_pays,taux,code,recuperableonly,localtax1,localtax -- GERMANY (id country=5) insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 51, 5, '0','0','No VAT', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 52, 5, '7.0','0','ermäßigte USt.', 1); -insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 53, 5, '0.0','0','keine USt.', 1); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 54, 5, '5.5','0','USt. Forst', 0); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 55, 5, '10.7','0','USt. Landwirtschaft', 0); insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values ( 56, 5, '19.0','0','allgemeine Ust.',1); From 23a5fa7d6254969229d84489beb11cf361fd35b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 15 Nov 2022 13:58:16 +0100 Subject: [PATCH 23/99] add hook to fetch product in list --- htdocs/product/list.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index ca86dcee0a8..c16f5425396 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1528,7 +1528,7 @@ while ($i < min($num, $limit)) { // Weight if (!empty($arrayfields['p.weight']['checked'])) { print ''; - print $obj->weight; + print $product_static->weight; print ''; if (!$i) { $totalarray['nbfield']++; @@ -1548,7 +1548,7 @@ while ($i < min($num, $limit)) { // Length if (!empty($arrayfields['p.length']['checked'])) { print ''; - print $obj->length; + print $product_static->length; print ''; if (!$i) { $totalarray['nbfield']++; @@ -1568,7 +1568,7 @@ while ($i < min($num, $limit)) { // Width if (!empty($arrayfields['p.width']['checked'])) { print ''; - print $obj->width; + print $product_static->width; print ''; if (!$i) { $totalarray['nbfield']++; @@ -1588,7 +1588,7 @@ while ($i < min($num, $limit)) { // Height if (!empty($arrayfields['p.height']['checked'])) { print ''; - print $obj->height; + print $product_static->height; print ''; if (!$i) { $totalarray['nbfield']++; @@ -1608,7 +1608,7 @@ while ($i < min($num, $limit)) { // Surface if (!empty($arrayfields['p.surface']['checked'])) { print ''; - print $obj->surface; + print $product_static->surface; print ''; if (!$i) { $totalarray['nbfield']++; @@ -1628,7 +1628,7 @@ while ($i < min($num, $limit)) { // Volume if (!empty($arrayfields['p.volume']['checked'])) { print ''; - print $obj->volume; + print $product_static->volume; print ''; if (!$i) { $totalarray['nbfield']++; @@ -1660,7 +1660,7 @@ while ($i < min($num, $limit)) { // Sell price if (!empty($arrayfields['p.sellprice']['checked'])) { print ''; - if ($obj->tosell && $usercancreadprice) { + if ($product_static->status && $usercancreadprice) { if ($obj->price_base_type == 'TTC') { print ''.price($obj->price_ttc).' '.$langs->trans("TTC").''; } else { @@ -1683,7 +1683,7 @@ while ($i < min($num, $limit)) { $productpricescache[$obj->rowid] = array(); } - if ($obj->tosell && $usercancreadprice) { + if ($product_static->status && $usercancreadprice) { // Make 1 request for all price levels (without filter on price_level) and saved result into an cache array // then reuse the cache array if we need prices for other price levels $sqlp = "SELECT p.rowid, p.fk_product, p.price, p.price_ttc, p.price_level, p.date_price, p.price_base_type"; @@ -1941,7 +1941,7 @@ while ($i < min($num, $limit)) { if (!empty($conf->use_javascript_ajax) && $user->hasRight("produit", "creer") && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) { print ajax_object_onoff($product_static, 'status', 'tosell', 'ProductStatusOnSell', 'ProductStatusNotOnSell'); } else { - print $product_static->LibStatut($obj->tosell, 5, 0); + print $product_static->LibStatut($product_static->status, 5, 0); } print ''; if (!$i) { From df78a8d2188f7843b2b2164e3d55c4f9d458ba6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 15 Nov 2022 14:31:08 +0100 Subject: [PATCH 24/99] hook on thirdparty list --- htdocs/societe/list.php | 80 +++++++++++++++++++++++------------------ 1 file changed, 45 insertions(+), 35 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index dfb5f5ee279..1c8b51fc0f1 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -767,7 +767,7 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && ( $obj = $db->fetch_object($resql); $id = $obj->rowid; if (!empty($conf->global->SOCIETE_ON_SEARCH_AND_LIST_GO_ON_CUSTOMER_OR_SUPPLIER_CARD)) { - if ($obj->client > 0) { + if ($companystatic->client > 0) { header("Location: ".DOL_URL_ROOT.'/comm/card.php?socid='.$id); exit; } @@ -1447,27 +1447,37 @@ $totalarray = array(); $totalarray['nbfield'] = 0; while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); + $parameters = array('staticdata' => $obj); + // Note that $action and $object may have been modified by hook + $reshook = $hookmanager->executeHooks('loadStaticObject', $parameters, $companystatic, $action); + if ($reshook < 0) { + $companystatic->fetch($obj->rowid); + } else { + $companystatic->id = $obj->rowid; + $companystatic->name = $obj->name; + $companystatic->name_alias = $obj->name_alias; + $companystatic->logo = $obj->logo; + $companystatic->barcode = $obj->barcode; + $companystatic->canvas = $obj->canvas; + $companystatic->client = $obj->client; + $companystatic->status = $obj->status; + $companystatic->email = $obj->email; + $companystatic->address = $obj->address; + $companystatic->zip = $obj->zip; + $companystatic->town = $obj->town; + $companystatic->fournisseur = $obj->fournisseur; + $companystatic->code_client = $obj->code_client; + $companystatic->code_fournisseur = $obj->code_fournisseur; + $companystatic->tva_intra = $obj->tva_intra; + $companystatic->country_code = $obj->country_code; - $companystatic->id = $obj->rowid; - $companystatic->name = $obj->name; - $companystatic->name_alias = $obj->name_alias; - $companystatic->logo = $obj->logo; - $companystatic->canvas = $obj->canvas; - $companystatic->client = $obj->client; - $companystatic->status = $obj->status; - $companystatic->email = $obj->email; - $companystatic->fournisseur = $obj->fournisseur; - $companystatic->code_client = $obj->code_client; - $companystatic->code_fournisseur = $obj->code_fournisseur; - $companystatic->tva_intra = $obj->tva_intra; - $companystatic->country_code = $obj->country_code; + $companystatic->code_compta_client = $obj->code_compta; + $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; - $companystatic->code_compta_client = $obj->code_compta; - $companystatic->code_compta_fournisseur = $obj->code_compta_fournisseur; - - $companystatic->fk_prospectlevel = $obj->fk_prospectlevel; - $companystatic->fk_parent = $obj->fk_parent; - $companystatic->entity = $obj->entity; + $companystatic->fk_prospectlevel = $obj->fk_prospectlevel; + $companystatic->fk_parent = $obj->fk_parent; + $companystatic->entity = $obj->entity; + } print 'global->MAIN_SOCIETE_SHOW_COMPLETE_NAME) ? ' class="tdoverflowmax200"' : '').' data-key="ref">'; if ($contextpage == 'poslist') { - print dol_escape_htmltag($obj->name); + print dol_escape_htmltag($companystatic->name); } else { print $companystatic->getNomUrl(1, '', 100, 0, 1, empty($arrayfields['s.name_alias']['checked']) ? 0 : 1); } @@ -1520,56 +1530,56 @@ while ($i < min($num, $limit)) { } // Barcode if (!empty($arrayfields['s.barcode']['checked'])) { - print ''.dol_escape_htmltag($obj->barcode).''; + print ''.dol_escape_htmltag($companystatic->barcode).''; if (!$i) { $totalarray['nbfield']++; } } // Customer code if (!empty($arrayfields['s.code_client']['checked'])) { - print ''.dol_escape_htmltag($obj->code_client).''; + print ''.dol_escape_htmltag($companystatic->code_client).''; if (!$i) { $totalarray['nbfield']++; } } // Supplier code if (!empty($arrayfields['s.code_fournisseur']['checked'])) { - print ''.dol_escape_htmltag($obj->code_fournisseur).''; + print ''.dol_escape_htmltag($companystatic->code_fournisseur).''; if (!$i) { $totalarray['nbfield']++; } } // Account customer code if (!empty($arrayfields['s.code_compta']['checked'])) { - print ''.dol_escape_htmltag($obj->code_compta).''; + print ''.dol_escape_htmltag($companystatic->code_compta_client).''; if (!$i) { $totalarray['nbfield']++; } } // Account supplier code if (!empty($arrayfields['s.code_compta_fournisseur']['checked'])) { - print ''.dol_escape_htmltag($obj->code_compta_fournisseur).''; + print ''.dol_escape_htmltag($companystatic->code_compta_fournisseur).''; if (!$i) { $totalarray['nbfield']++; } } // Address if (!empty($arrayfields['s.address']['checked'])) { - print ''.dol_escape_htmltag($obj->address).''; + print ''.dol_escape_htmltag($companystatic->address).''; if (!$i) { $totalarray['nbfield']++; } } // Zip if (!empty($arrayfields['s.zip']['checked'])) { - print "".dol_escape_htmltag($obj->zip)."\n"; + print "".dol_escape_htmltag($companystatic->zip)."\n"; if (!$i) { $totalarray['nbfield']++; } } // Town if (!empty($arrayfields['s.town']['checked'])) { - print ''.dol_escape_htmltag($obj->town)."\n"; + print ''.dol_escape_htmltag($companystatic->town)."\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1591,7 +1601,7 @@ while ($i < min($num, $limit)) { // Country if (!empty($arrayfields['country.code_iso']['checked'])) { print ''; - $labelcountry = ($obj->country_code && ($langs->trans("Country".$obj->country_code) != "Country".$obj->country_code)) ? $langs->trans("Country".$obj->country_code) : $obj->country_label; + $labelcountry = ($companystatic->country_code && ($langs->trans("Country".$companystatic->country_code) != "Country".$companystatic->country_code)) ? $langs->trans("Country".$companystatic->country_code) : $obj->country_label; print $labelcountry; print ''; if (!$i) { @@ -1638,13 +1648,13 @@ while ($i < min($num, $limit)) { } } if (!empty($arrayfields['s.phone']['checked'])) { - print ''.dol_print_phone($obj->phone, $obj->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'phone')."\n"; + print ''.dol_print_phone($obj->phone, $companystatic->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'phone')."\n"; if (!$i) { $totalarray['nbfield']++; } } if (!empty($arrayfields['s.fax']['checked'])) { - print ''.dol_print_phone($obj->fax, $obj->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'fax')."\n"; + print ''.dol_print_phone($obj->fax, $companystatic->country_code, 0, $obj->rowid, 'AC_TEL', ' ', 'fax')."\n"; if (!$i) { $totalarray['nbfield']++; } @@ -1693,11 +1703,11 @@ while ($i < min($num, $limit)) { } // VAT if (!empty($arrayfields['s.tva_intra']['checked'])) { - print ''; - if ($obj->tva_intra && !isValidVATID($companystatic)) { + print ''; + if ($companystatic->tva_intra && !isValidVATID($companystatic)) { print img_warning("BadVATNumber", '', 'pictofixedwidth'); } - print $obj->tva_intra; + print $companystatic->tva_intra; print "\n"; if (!$i) { $totalarray['nbfield']++; From d0f9aace1cd6fdff006b14c5d3325b0ffb28a030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 15 Nov 2022 18:22:39 +0100 Subject: [PATCH 25/99] Update list.php --- htdocs/product/list.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index c16f5425396..5716c1a70ea 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -1340,10 +1340,9 @@ while ($i < min($num, $limit)) { } $parameters = array('staticdata' => $obj); // Note that $action and $object may have been modified by hook + // do product_static fetch in hook if wanted or anything else $reshook = $hookmanager->executeHooks('loadStaticObject', $parameters, $product_static, $action); - if ($reshook < 0) { - $product_static->fetch($obj->rowid); - } else { + if (empty($reshook)) { $product_static->id = $obj->rowid; $product_static->ref = $obj->ref; $product_static->ref_fourn = empty($obj->ref_supplier) ? '' : $obj->ref_supplier; // deprecated From a48f48283c027a6cbf1183dffa23df7eff58d696 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 15 Nov 2022 18:23:57 +0100 Subject: [PATCH 26/99] Update list.php --- htdocs/societe/list.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 1c8b51fc0f1..f5fcc56b49d 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -1449,10 +1449,9 @@ while ($i < min($num, $limit)) { $obj = $db->fetch_object($resql); $parameters = array('staticdata' => $obj); // Note that $action and $object may have been modified by hook + // do companystatic fetch in hook if wanted or anything else $reshook = $hookmanager->executeHooks('loadStaticObject', $parameters, $companystatic, $action); - if ($reshook < 0) { - $companystatic->fetch($obj->rowid); - } else { + if (empty($reshook)) { $companystatic->id = $obj->rowid; $companystatic->name = $obj->name; $companystatic->name_alias = $obj->name_alias; From 2f3cc7ce59f7a2dac55ba08203bd873097c78c99 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Nov 2022 19:02:56 +0100 Subject: [PATCH 27/99] FIX Backup using the low memory mode --- htdocs/core/class/utils.class.php | 41 ++++++++++++++++--------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 007d34491d6..47d9b64d2a7 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -360,23 +360,23 @@ class Utils } } else { if ($compression == 'none') { - $fullcommandclear .= " > ".$outputfile; - $fullcommandcrypted .= " > ".$outputfile; + $fullcommandclear .= " | grep -v 'Warning: Using a password on the command line interface can be insecure.' > ".$outputfile; + $fullcommandcrypted .= " | grep -v 'Warning: Using a password on the command line interface can be insecure.' > ".$outputfile; $handle = 1; } elseif ($compression == 'gz') { - $fullcommandclear .= " | gzip > ".$outputfile; - $fullcommandcrypted .= " | gzip > ".$outputfile; - $paramcrypted.=" | gzip"; + $fullcommandclear .= " | grep -v 'Warning: Using a password on the command line interface can be insecure.' | gzip > ".$outputfile; + $fullcommandcrypted .= " | grep -v 'Warning: Using a password on the command line interface can be insecure.' | gzip > ".$outputfile; + $paramcrypted.=" | grep -v 'Warning: Using a password on the command line interface can be insecure.' | gzip"; $handle = 1; } elseif ($compression == 'bz') { - $fullcommandclear .= " | bzip2 > ".$outputfile; - $fullcommandcrypted .= " | bzip2 > ".$outputfile; - $paramcrypted.=" | bzip2"; + $fullcommandclear .= " | grep -v 'Warning: Using a password on the command line interface can be insecure.' | bzip2 > ".$outputfile; + $fullcommandcrypted .= " | grep -v 'Warning: Using a password on the command line interface can be insecure.' | bzip2 > ".$outputfile; + $paramcrypted.=" | grep -v 'Warning: Using a password on the command line interface can be insecure.' | bzip2"; $handle = 1; } elseif ($compression == 'zstd') { - $fullcommandclear .= " | zstd > ".$outputfile; - $fullcommandcrypted .= " | zstd > ".$outputfile; - $paramcrypted.=" | zstd"; + $fullcommandclear .= " | grep -v 'Warning: Using a password on the command line interface can be insecure.' | zstd > ".$outputfile; + $fullcommandcrypted .= " | grep -v 'Warning: Using a password on the command line interface can be insecure.' | zstd > ".$outputfile; + $paramcrypted.=" | grep -v 'Warning: Using a password on the command line interface can be insecure.' | zstd"; $handle = 1; } } @@ -460,15 +460,16 @@ class Utils } } - - if ($compression == 'none') { - fclose($handle); - } elseif ($compression == 'gz') { - gzclose($handle); - } elseif ($compression == 'bz') { - bzclose($handle); - } elseif ($compression == 'zstd') { - fclose($handle); + if (!$lowmemorydump) { + if ($compression == 'none') { + fclose($handle); + } elseif ($compression == 'gz') { + gzclose($handle); + } elseif ($compression == 'bz') { + bzclose($handle); + } elseif ($compression == 'zstd') { + fclose($handle); + } } if (!empty($conf->global->MAIN_UMASK)) { From 344319e8e889b497102b51044d8b1405ae1a6bee Mon Sep 17 00:00:00 2001 From: admin_nsinfo Date: Tue, 15 Nov 2022 21:02:21 +0100 Subject: [PATCH 28/99] #22859 --- htdocs/core/class/html.formticket.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formticket.class.php b/htdocs/core/class/html.formticket.class.php index 0f00bbf770d..f2a185e534d 100644 --- a/htdocs/core/class/html.formticket.class.php +++ b/htdocs/core/class/html.formticket.class.php @@ -334,7 +334,7 @@ class FormTicket print ''; // Severity => Priority - print ''; + print ''; $this->selectSeveritiesTickets((GETPOST('severity_code') ? GETPOST('severity_code') : $this->severity_code), 'severity_code', '', 2, 1); print ''; From 4d771ef726ac6e0c53bf988e2d4a3f002ec06078 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Nov 2022 21:54:19 +0100 Subject: [PATCH 29/99] Fix position of tables in sql request for better performance --- htdocs/core/boxes/box_commandes.php | 3 +-- htdocs/core/boxes/box_factures.php | 3 +-- htdocs/core/boxes/box_propales.php | 3 +-- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/core/boxes/box_commandes.php b/htdocs/core/boxes/box_commandes.php index f4aec2075d7..f5764c8a575 100644 --- a/htdocs/core/boxes/box_commandes.php +++ b/htdocs/core/boxes/box_commandes.php @@ -99,8 +99,7 @@ class box_commandes extends ModeleBoxes $sql .= ", c.total_ht"; $sql .= ", c.total_tva"; $sql .= ", c.total_ttc"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."commande as c"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande as c, ".MAIN_DB_PREFIX."societe as s"; if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } diff --git a/htdocs/core/boxes/box_factures.php b/htdocs/core/boxes/box_factures.php index e34e89c97eb..6a59c6f0d56 100644 --- a/htdocs/core/boxes/box_factures.php +++ b/htdocs/core/boxes/box_factures.php @@ -99,11 +99,10 @@ class box_factures extends ModeleBoxes $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.logo, s.email, s.entity"; $sql .= ", s.tva_intra, s.siren as idprof1, s.siret as idprof2, s.ape as idprof3, s.idprof4, s.idprof5, s.idprof6"; - $sql .= " FROM (".MAIN_DB_PREFIX."societe as s,".MAIN_DB_PREFIX."facture as f"; + $sql .= " FROM ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."societe as s"; if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } - $sql .= ")"; $sql .= " WHERE f.fk_soc = s.rowid"; $sql .= " AND f.entity IN (".getEntity('invoice').")"; if (empty($user->rights->societe->client->voir) && !$user->socid) { diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php index b010779e52a..c284d257986 100644 --- a/htdocs/core/boxes/box_propales.php +++ b/htdocs/core/boxes/box_propales.php @@ -88,8 +88,7 @@ class box_propales extends ModeleBoxes $sql .= ", s.code_client, s.code_compta, s.client"; $sql .= ", s.logo, s.email, s.entity"; $sql .= ", p.rowid, p.ref, p.fk_statut as status, p.datep as dp, p.datec, p.fin_validite, p.date_cloture, p.total_ht, p.total_tva, p.total_ttc, p.tms"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; - $sql .= ", ".MAIN_DB_PREFIX."propal as p"; + $sql .= " FROM ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s"; if (empty($user->rights->societe->client->voir) && !$user->socid) { $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; } From 2a131652185417e6eee3aae001c8cef39ccdf057 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Nov 2022 22:12:53 +0100 Subject: [PATCH 30/99] Clean useless join --- htdocs/projet/class/task.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index bff2df09c9c..87ab0afdc47 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -2192,7 +2192,7 @@ class Task extends CommonObjectLine $sql .= " t.rowid as taskid, t.progress as progress, t.fk_statut as status,"; $sql .= " t.dateo as date_start, t.datee as datee"; $sql .= " FROM ".MAIN_DB_PREFIX."projet as p"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; + //$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid"; //if (! $user->rights->societe->client->voir && ! $socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON sc.fk_soc = s.rowid"; $sql .= ", ".MAIN_DB_PREFIX."projet_task as t"; $sql .= " WHERE p.entity IN (".getEntity('project', 0).')'; From 25c074668d85bfb4bf1e7894c2fa3154a0ffdf60 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Nov 2022 22:23:10 +0100 Subject: [PATCH 31/99] Fix perf index --- htdocs/install/mysql/tables/llx_projet.key.sql | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/install/mysql/tables/llx_projet.key.sql b/htdocs/install/mysql/tables/llx_projet.key.sql index 4b9dd008943..26869454c41 100644 --- a/htdocs/install/mysql/tables/llx_projet.key.sql +++ b/htdocs/install/mysql/tables/llx_projet.key.sql @@ -22,4 +22,8 @@ ALTER TABLE llx_projet ADD UNIQUE INDEX uk_projet_ref (ref, entity); ALTER TABLE llx_projet ADD INDEX idx_projet_fk_soc (fk_soc); +ALTER TABLE llx_projet ADD INDEX idx_projet_ref (ref); +ALTER TABLE llx_projet ADD INDEX idx_projet_fk_statut (fk_statut); +ALTER TABLE llx_projet ADD INDEX idx_projet_fk_opp_status (fk_opp_status); + ALTER TABLE llx_projet ADD CONSTRAINT fk_projet_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid); From 6e33d1e2b1c3a2ff5ed1993cd8ba71ddc4efed94 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Wed, 16 Nov 2022 10:48:25 +0100 Subject: [PATCH 32/99] FIX merge errors on mailing card --- htdocs/comm/mailing/card.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index b91bc866d9a..04eac2b5fbf 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -508,6 +508,7 @@ if (empty($reshook)) { exit; } $mesgs[] = $object->error; + $mesgs = array_merge($mesgs, $object->errors); } setEventMessages(null, $mesgs, 'errors'); @@ -595,6 +596,7 @@ if (empty($reshook)) { exit; } $mesgs[] = $object->error; + $mesgs = array_merge($mesgs, $object->errors); } setEventMessages($mesg, $mesgs, 'errors'); From 10154cc357f812af8658f155a85d054a0e9a6629 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Wed, 16 Nov 2022 11:05:39 +0100 Subject: [PATCH 33/99] FIX remove not initialized variable --- htdocs/comm/mailing/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 04eac2b5fbf..b8bd18f56c2 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -511,7 +511,7 @@ if (empty($reshook)) { $mesgs = array_merge($mesgs, $object->errors); } - setEventMessages(null, $mesgs, 'errors'); + setEventMessages('', $mesgs, 'errors'); $action = "create"; } @@ -599,7 +599,7 @@ if (empty($reshook)) { $mesgs = array_merge($mesgs, $object->errors); } - setEventMessages($mesg, $mesgs, 'errors'); + setEventMessages('', $mesgs, 'errors'); $action = "edit"; } else { $action = "edit"; From 1e3e26e7f9cf127ec16759088813eceef3c86bb9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Nov 2022 14:00:52 +0100 Subject: [PATCH 34/99] Fix use of the lowmemorydump for batch of backup --- htdocs/admin/tools/export.php | 7 ++++--- htdocs/core/class/utils.class.php | 5 ++--- htdocs/core/modules/modCron.class.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/admin/tools/export.php b/htdocs/admin/tools/export.php index d21622d1f68..48e4b1b1558 100644 --- a/htdocs/admin/tools/export.php +++ b/htdocs/admin/tools/export.php @@ -124,6 +124,7 @@ $result = dol_mkdir($outputdir); $utils = new Utils($db); +$lowmemorydump = GETPOSTISSET("lowmemorydump") ? GETPOST("lowmemorydump") : getDolGlobalString('MAIN_LOW_MEMORY_DUMP'); // MYSQL if ($what == 'mysql') { @@ -144,7 +145,7 @@ if ($what == 'mysql') { } if (!$errormsg) { - $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); + $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file, 0, 0, $lowmemorydump); $errormsg = $utils->error; $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; @@ -153,7 +154,7 @@ if ($what == 'mysql') { // MYSQL NO BIN if ($what == 'mysqlnobin') { - $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); + $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file, 0, 0, $lowmemorydump); $errormsg = $utils->error; $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; @@ -182,7 +183,7 @@ if ($what == 'postgresql') { } if (!$errormsg) { - $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file); + $utils->dumpDatabase(GETPOST('compression', 'alpha'), $what, 0, $file, 0, 0, $lowmemorydump); $errormsg = $utils->error; $_SESSION["commandbackuplastdone"] = $utils->result['commandbackuplastdone']; $_SESSION["commandbackuptorun"] = $utils->result['commandbackuptorun']; diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 47d9b64d2a7..1a11cc6e75f 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -191,9 +191,10 @@ class Utils * @param string $file 'auto' or filename to build * @param int $keeplastnfiles Keep only last n files (not used yet) * @param int $execmethod 0=Use default method (that is 1 by default), 1=Use the PHP 'exec' - need size of dump in memory, but low memory method is used if GETPOST('lowmemorydump') is set, 2=Use the 'popen' method (low memory method) + * @param int $lowmemorydump 1=Use the low memory method * @return int 0 if OK, < 0 if KO (this function is used also by cron so only 0 is OK) */ - public function dumpDatabase($compression = 'none', $type = 'auto', $usedefault = 1, $file = 'auto', $keeplastnfiles = 0, $execmethod = 0) + public function dumpDatabase($compression = 'none', $type = 'auto', $usedefault = 1, $file = 'auto', $keeplastnfiles = 0, $execmethod = 0, $lowmemorydump = 0) { global $db, $conf, $langs, $dolibarr_main_data_root; global $dolibarr_main_db_name, $dolibarr_main_db_host, $dolibarr_main_db_user, $dolibarr_main_db_port, $dolibarr_main_db_pass; @@ -343,8 +344,6 @@ class Utils $handle = ''; - $lowmemorydump = GETPOSTISSET("lowmemorydump") ? GETPOST("lowmemorydump") : getDolGlobalString('MAIN_LOW_MEMORY_DUMP'); - // Start call method to execute dump $fullcommandcrypted = $command." ".$paramcrypted." 2>&1"; $fullcommandclear = $command." ".$paramclear." 2>&1"; diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php index d6bea3ff089..26b23c42abd 100644 --- a/htdocs/core/modules/modCron.class.php +++ b/htdocs/core/modules/modCron.class.php @@ -99,7 +99,7 @@ class modCron extends DolibarrModules // Cronjobs $this->cronjobs = array( 0=>array('entity'=>0, 'label'=>'PurgeDeleteTemporaryFilesShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'purgeFiles', 'parameters'=>'tempfilesold+logfiles', 'comment'=>'PurgeDeleteTemporaryFiles', 'frequency'=>2, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>50, 'status'=>1, 'test'=>true), - 1=>array('entity'=>0, 'label'=>'MakeLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'dumpDatabase', 'parameters'=>'none,auto,1,auto,10', 'comment'=>'MakeLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>90, 'status'=>0, 'test'=>'in_array($conf->db->type, array(\'mysql\', \'mysqli\'))'), + 1=>array('entity'=>0, 'label'=>'MakeLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'dumpDatabase', 'parameters'=>'none,auto,1,auto,10,0,0', 'comment'=>'MakeLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7, 'priority'=>90, 'status'=>0, 'test'=>'in_array($conf->db->type, array(\'mysql\', \'mysqli\'))'), 2=>array('entity'=>0, 'label'=>'MakeSendLocalDatabaseDumpShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'sendBackup', 'parameters'=>',,,,,sql', 'comment'=>'MakeSendLocalDatabaseDump', 'frequency'=>1, 'unitfrequency'=>604800, 'priority'=>91, 'status'=>0, 'test'=>'!empty($conf->global->MAIN_ALLOW_BACKUP_BY_EMAIL) && in_array($conf->db->type, array(\'mysql\', \'mysqli\'))'), // 1=>array('entity'=>0, 'label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24) ); From 5a887f11bb84dfa2df911ca0aab80d77baafbb0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 16 Nov 2022 14:12:09 +0100 Subject: [PATCH 35/99] add new tags in receipt printer --- htdocs/core/class/dolreceiptprinter.class.php | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index b76ad8c7a47..7a7c380adf9 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -46,6 +46,7 @@ * {dol_print_barcode} Print barcode * {dol_print_logo} Print logo stored on printer. Example : 32|32 * {dol_print_logo_old} Print logo stored on printer. Must be followed by logo code. For old printers. + * {dol_print_logo_old_cf} Print logo stored on printer. Must be followed by logo code. For old printers. May help for centering image. * {dol_print_object_lines} Print object lines * {dol_print_object_tax} Print object total tax * {dol_print_object_local_tax} Print object local tax @@ -191,10 +192,17 @@ class dolReceiptPrinter extends Printer 'dol_value_day' => 'DOL_VALUE_DAY', 'dol_value_day_letters' => 'DOL_VALUE_DAY', 'dol_value_currentdate' => 'DOL_VALUE_CURRENTDATE', + 'dol_value_currentdate_time' => 'CurrentDateWithTime', + 'dol_value_currentyear' => 'CurrentYear', + 'dol_value_currentmonth_letters' => 'DOL_VALUE_CURRENT_MONTH_LETTERS', + 'dol_value_currentmonth' => 'DOL_VALUE_CURRENT_MONTH', + 'dol_value_currentday' => 'DOL_VALUE_CURRENT_DAY', + 'dol_value_currentday_letters' => 'DOL_VALUE_CURRENT_DAY', 'dol_print_payment' => 'DOL_PRINT_PAYMENT', 'dol_print_curr_date' => 'DOL_PRINT_CURR_DATE', 'dol_print_logo' => 'DOL_PRINT_LOGO', 'dol_print_logo_old' => 'DOL_PRINT_LOGO_OLD', + 'dol_print_logo_old_cf' => 'DOL_PRINT_LOGO_OLD_CF', 'dol_value_object_id' => 'InvoiceID', 'dol_value_object_ref' => 'InvoiceRef', 'dol_print_object_lines' => 'DOL_PRINT_OBJECT_LINES', @@ -577,9 +585,12 @@ class dolReceiptPrinter extends Printer public function sendToPrinter($object, $templateid, $printerid) { global $conf, $mysoc, $langs, $user; + + $langs->load('bills'); + $error = 0; $ret = $this->loadTemplate($templateid); - + $now = dol_now('tzuser'); // tags a remplacer par leur valeur avant de parser (dol_value_xxx) $this->template = str_replace('{dol_value_object_id}', $object->id, $this->template); $this->template = str_replace('{dol_value_object_ref}', $object->ref, $this->template); @@ -591,7 +602,15 @@ class dolReceiptPrinter extends Printer $this->template = str_replace('{dol_value_month}', dol_print_date($object->date, '%m'), $this->template); $this->template = str_replace('{dol_value_day}', dol_print_date($object->date, '%d'), $this->template); $this->template = str_replace('{dol_value_day_letters}', $langs->trans("Day".dol_print_date($object->date, '%m')[1]), $this->template); - $this->template = str_replace('{dol_value_currentdate}', dol_print_date(dol_now(), 'dayhour'), $this->template); + + $this->template = str_replace('{dol_value_currentdate}', dol_print_date($now, 'day'), $this->template); + $this->template = str_replace('{dol_value_currentdate_time}', dol_print_date($now, 'dayhour'), $this->template); + $this->template = str_replace('{dol_value_currentdate_time_letters}', dol_print_date($now, 'dayhourtext'), $this->template); + $this->template = str_replace('{dol_value_currentyear}', dol_print_date($now, '%Y'), $this->template); + $this->template = str_replace('{dol_value_currentmonth_letters}', $langs->trans("Month".dol_print_date($now, '%m')), $this->template); + $this->template = str_replace('{dol_value_currentmonth}', dol_print_date($now, '%m'), $this->template); + $this->template = str_replace('{dol_value_currentday}', dol_print_date($now, '%d'), $this->template); + $this->template = str_replace('{dol_value_currentday_letters}', $langs->trans("Day".dol_print_date($now, '%m')[1]), $this->template); $this->template = str_replace('{dol_value_customer_firstname}', $object->thirdparty->firstname, $this->template); $this->template = str_replace('{dol_value_customer_lastname}', $object->thirdparty->lastname, $this->template); @@ -759,6 +778,10 @@ class dolReceiptPrinter extends Printer $img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo); $this->printer->bitImage($img); break; + case 'DOL_PRINT_LOGO_OLD_CF': + $img = EscposImage::load(DOL_DATA_ROOT.'/mycompany/logos/'.$mysoc->logo); + $this->printer->bitImageColumnFormat($img); + break; case 'DOL_PRINT_QRCODE': // $vals[$tplline]['value'] -> qrCode($content, $ec, $size, $model) $this->printer->qrcode($vals[$tplline]['value']); @@ -845,9 +868,9 @@ class dolReceiptPrinter extends Printer } break; case 'DOL_VALUE_PLACE': - $sql = "SELECT floor, label FROM ".$this->db->prefix()."takepos_floor_tables where rowid=".((int) str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $object->ref))); - $resql = $this->db->query($sql); - $obj = $this->db->fetch_object($resql); + $sql = "SELECT floor, label FROM ".$this->db->prefix()."takepos_floor_tables where rowid=".((int) str_replace(")", "", str_replace("(PROV-POS".$_SESSION["takeposterminal"]."-", "", $object->ref))); + $resql = $this->db->query($sql); + $obj = $this->db->fetch_object($resql); if ($obj) { $this->printer->text($obj->label); } From 2d50b73072686c26aad8c12465b3f3f1c08e7cdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 16 Nov 2022 14:18:51 +0100 Subject: [PATCH 36/99] add new tags in receipt printer --- htdocs/core/class/dolreceiptprinter.class.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php index 7a7c380adf9..3b10f38d238 100644 --- a/htdocs/core/class/dolreceiptprinter.class.php +++ b/htdocs/core/class/dolreceiptprinter.class.php @@ -64,7 +64,8 @@ * Replaced by month number * Replaced by day number * Replaced by day number - * Replaced by current date + * Replaced by current date and time + * Replaced by current date without time * Replaced by object id * Replaced by object ref * Replaced by customer firstname @@ -192,7 +193,8 @@ class dolReceiptPrinter extends Printer 'dol_value_day' => 'DOL_VALUE_DAY', 'dol_value_day_letters' => 'DOL_VALUE_DAY', 'dol_value_currentdate' => 'DOL_VALUE_CURRENTDATE', - 'dol_value_currentdate_time' => 'CurrentDateWithTime', + 'dol_value_currentdate_notime' => 'CurrentDateWithTime', + 'dol_value_currentdate_letters' => 'DOL_VALUE_CURRENTDATE_LETTERS', 'dol_value_currentyear' => 'CurrentYear', 'dol_value_currentmonth_letters' => 'DOL_VALUE_CURRENT_MONTH_LETTERS', 'dol_value_currentmonth' => 'DOL_VALUE_CURRENT_MONTH', @@ -603,9 +605,9 @@ class dolReceiptPrinter extends Printer $this->template = str_replace('{dol_value_day}', dol_print_date($object->date, '%d'), $this->template); $this->template = str_replace('{dol_value_day_letters}', $langs->trans("Day".dol_print_date($object->date, '%m')[1]), $this->template); - $this->template = str_replace('{dol_value_currentdate}', dol_print_date($now, 'day'), $this->template); - $this->template = str_replace('{dol_value_currentdate_time}', dol_print_date($now, 'dayhour'), $this->template); - $this->template = str_replace('{dol_value_currentdate_time_letters}', dol_print_date($now, 'dayhourtext'), $this->template); + $this->template = str_replace('{dol_value_currentdate}', dol_print_date($now, 'dayhour'), $this->template); + $this->template = str_replace('{dol_value_currentdate_notime}', dol_print_date($now, 'day'), $this->template); + $this->template = str_replace('{dol_value_currentdate_letters}', dol_print_date($now, 'dayhourtext'), $this->template); $this->template = str_replace('{dol_value_currentyear}', dol_print_date($now, '%Y'), $this->template); $this->template = str_replace('{dol_value_currentmonth_letters}', $langs->trans("Month".dol_print_date($now, '%m')), $this->template); $this->template = str_replace('{dol_value_currentmonth}', dol_print_date($now, '%m'), $this->template); From 6b4ca7f4fc554d986f3c8592993609e46722865d Mon Sep 17 00:00:00 2001 From: FLIO Date: Wed, 16 Nov 2022 16:04:45 +0100 Subject: [PATCH 37/99] Fix(Scrutinizer) fix name function https://scrutinizer-ci.com/g/Dolibarr/dolibarr/issues/develop/files/htdocs/expedition/stats/month.php?selectedLabels%5B0%5D=9&selectedSeverities%5B0%5D=10&orderField=lastFound&order=desc&honorSelectedPaths=0 --- htdocs/expedition/stats/month.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/expedition/stats/month.php b/htdocs/expedition/stats/month.php index 34842efaaf3..398bc381715 100644 --- a/htdocs/expedition/stats/month.php +++ b/htdocs/expedition/stats/month.php @@ -47,11 +47,12 @@ $WIDTH = DolGraph::getDefaultGraphSizeForStats('width'); $HEIGHT = DolGraph::getDefaultGraphSizeForStats('height'); $mesg = ''; +$mode = ''; print load_fiche_titre($langs->trans("StatisticsOfSendings").' '.$year, $mesg); -$stats = new ExpeditionStats($db); -$data = $stats->getNbExpeditionByMonth($year); +$stats = new ExpeditionStats($db, $socid, $mode); +$data = $stats->getNbByMonth($year); dol_mkdir($conf->expedition->dir_temp); From 45e3f19bd75741ac4e4eb6d994754005d76bdb46 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Nov 2022 20:05:52 +0100 Subject: [PATCH 38/99] Fix remove files not expected --- build/makepack-dolibarr.pl | 1 - htdocs/includes/ckeditor/ckeditor/adapters/jquery.js | 10 ---------- 2 files changed, 11 deletions(-) delete mode 100644 htdocs/includes/ckeditor/ckeditor/adapters/jquery.js diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl index 906601d94d4..34b7b97e593 100755 --- a/build/makepack-dolibarr.pl +++ b/build/makepack-dolibarr.pl @@ -614,7 +614,6 @@ if ($nboftargetok) { $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nnnick/chartjs/scripts`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nnnick/chartjs/src`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nnnick/chartjs/test`; - $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/lib/Mail`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/nusoap/samples`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/php-iban/docs`; $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/includes/sabre/sabre/*/tests`; diff --git a/htdocs/includes/ckeditor/ckeditor/adapters/jquery.js b/htdocs/includes/ckeditor/ckeditor/adapters/jquery.js deleted file mode 100644 index ba745105ecf..00000000000 --- a/htdocs/includes/ckeditor/ckeditor/adapters/jquery.js +++ /dev/null @@ -1,10 +0,0 @@ -/* - Copyright (c) 2003-2019, CKSource - Frederico Knabben. All rights reserved. - For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license -*/ -(function(a){if("undefined"==typeof a)throw Error("jQuery should be loaded before CKEditor jQuery adapter.");if("undefined"==typeof CKEDITOR)throw Error("CKEditor should be loaded before CKEditor jQuery adapter.");CKEDITOR.config.jqueryOverrideVal="undefined"==typeof CKEDITOR.config.jqueryOverrideVal?!0:CKEDITOR.config.jqueryOverrideVal;a.extend(a.fn,{ckeditorGet:function(){var a=this.eq(0).data("ckeditorInstance");if(!a)throw"CKEditor is not initialized yet, use ckeditor() with a callback.";return a}, -ckeditor:function(g,e){if(!CKEDITOR.env.isCompatible)throw Error("The environment is incompatible.");if(!a.isFunction(g)){var m=e;e=g;g=m}var k=[];e=e||{};this.each(function(){var b=a(this),c=b.data("ckeditorInstance"),f=b.data("_ckeditorInstanceLock"),h=this,l=new a.Deferred;k.push(l.promise());if(c&&!f)g&&g.apply(c,[this]),l.resolve();else if(f)c.once("instanceReady",function(){setTimeout(function d(){c.element?(c.element.$==h&&g&&g.apply(c,[h]),l.resolve()):setTimeout(d,100)},0)},null,null,9999); -else{if(e.autoUpdateElement||"undefined"==typeof e.autoUpdateElement&&CKEDITOR.config.autoUpdateElement)e.autoUpdateElementJquery=!0;e.autoUpdateElement=!1;b.data("_ckeditorInstanceLock",!0);c=a(this).is("textarea")?CKEDITOR.replace(h,e):CKEDITOR.inline(h,e);b.data("ckeditorInstance",c);c.on("instanceReady",function(e){var d=e.editor;setTimeout(function n(){if(d.element){e.removeListener();d.on("dataReady",function(){b.trigger("dataReady.ckeditor",[d])});d.on("setData",function(a){b.trigger("setData.ckeditor", -[d,a.data])});d.on("getData",function(a){b.trigger("getData.ckeditor",[d,a.data])},999);d.on("destroy",function(){b.trigger("destroy.ckeditor",[d])});d.on("save",function(){a(h.form).submit();return!1},null,null,20);if(d.config.autoUpdateElementJquery&&b.is("textarea")&&a(h.form).length){var c=function(){b.ckeditor(function(){d.updateElement()})};a(h.form).submit(c);a(h.form).bind("form-pre-serialize",c);b.bind("destroy.ckeditor",function(){a(h.form).unbind("submit",c);a(h.form).unbind("form-pre-serialize", -c)})}d.on("destroy",function(){b.removeData("ckeditorInstance")});b.removeData("_ckeditorInstanceLock");b.trigger("instanceReady.ckeditor",[d]);g&&g.apply(d,[h]);l.resolve()}else setTimeout(n,100)},0)},null,null,9999)}});var f=new a.Deferred;this.promise=f.promise();a.when.apply(this,k).then(function(){f.resolve()});this.editor=this.eq(0).data("ckeditorInstance");return this}});CKEDITOR.config.jqueryOverrideVal&&(a.fn.val=CKEDITOR.tools.override(a.fn.val,function(g){return function(e){if(arguments.length){var m= -this,k=[],f=this.each(function(){var b=a(this),c=b.data("ckeditorInstance");if(b.is("textarea")&&c){var f=new a.Deferred;c.setData(e,function(){f.resolve()});k.push(f.promise());return!0}return g.call(b,e)});if(k.length){var b=new a.Deferred;a.when.apply(this,k).done(function(){b.resolveWith(m)});return b.promise()}return f}var f=a(this).eq(0),c=f.data("ckeditorInstance");return f.is("textarea")&&c?c.getData():g.call(f)}}))})(window.jQuery); \ No newline at end of file From aacb7b16a473a7788ba22c1f9824557238585f24 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Nov 2022 22:36:08 +0100 Subject: [PATCH 39/99] Fix installmodules.lock must also block module builder --- htdocs/langs/en_US/admin.lang | 2 +- htdocs/modulebuilder/index.php | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 8f9c4aa302f..2cd9d55aefb 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -1932,7 +1932,7 @@ BackupDumpWizard=Wizard to build the database dump file BackupZipWizard=Wizard to build the archive of documents directory SomethingMakeInstallFromWebNotPossible=Installation of external module is not possible from the web interface for the following reason: SomethingMakeInstallFromWebNotPossible2=For this reason, process to upgrade described here is a manual process only a privileged user may perform. -InstallModuleFromWebHasBeenDisabledContactUs=Install of external modules from the application is currently locked. Please contact us if you need us to enable this feature. +InstallModuleFromWebHasBeenDisabledContactUs=Install or development of external modules from the application is currently locked for security purpose. Please contact us if you need to enable this feature. InstallModuleFromWebHasBeenDisabledByFile=Install of external module from application has been disabled by your administrator. You must ask him to remove the file %s to allow this feature. ConfFileMustContainCustom=Installing or building an external module from application need to save the module files into directory %s. To have this directory processed by Dolibarr, you must setup your conf/conf.php to add the 2 directive lines:
$dolibarr_main_url_root_alt='/custom';
$dolibarr_main_document_root_alt='%s/custom'; HighlightLinesOnMouseHover=Highlight table lines when mouse move passes over diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 29959822af1..538b1cac290 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1974,6 +1974,28 @@ if ($message) { $infomodulesfound = '
'.$form->textwithpicto('', $langs->trans("ModuleBuilderDesc3", count($listofmodules)).'

'.$langs->trans("ModuleBuilderDesc4", $FILEFLAG).'
'.$textforlistofdirs).'
'; + +$dolibarrdataroot = preg_replace('/([\\/]+)$/i', '', DOL_DATA_ROOT); +$allowonlineinstall = true; +if (dol_is_file($dolibarrdataroot.'/installmodules.lock')) { + $allowonlineinstall = false; +} +if (empty($allowonlineinstall)) { + if (getDolGlobalString('MAIN_MESSAGE_INSTALL_MODULES_DISABLED_CONTACT_US')) { + // Show clean message + $message = info_admin($langs->trans('InstallModuleFromWebHasBeenDisabledContactUs')); + } else { + // Show technical message + $message = info_admin($langs->trans("InstallModuleFromWebHasBeenDisabledByFile", $dolibarrdataroot.'/installmodules.lock'), 0, 0, 1, 'warning'); + } + + print $message; + + llxFooter(); + exit(0); +} + + // Load module descriptor $error = 0; $moduleobj = null; From f145db32225ba82c86548549046aefed76be9aa4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Nov 2022 01:15:18 +0100 Subject: [PATCH 40/99] Fix useless left join --- htdocs/comm/action/class/actioncomm.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index dbca3e6e853..e31e6023210 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1376,7 +1376,6 @@ class ActionComm extends CommonObject if (empty($user->rights->agenda->allactions->read)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources AS ar ON a.id = ar.fk_actioncomm AND ar.element_type ='user' AND ar.fk_element = ".((int) $user->id); } - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON a.fk_soc = s.rowid"; $sql .= " WHERE 1 = 1"; if (empty($load_state_board)) { $sql .= " AND a.percent >= 0 AND a.percent < 100"; From 259ff07bbdada242ee9ec0cabb29b7e4790dd8fe Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Nov 2022 01:19:31 +0100 Subject: [PATCH 41/99] Add missing index --- htdocs/install/mysql/migration/16.0.0-17.0.0.sql | 2 ++ htdocs/install/mysql/tables/llx_actioncomm.key.sql | 1 + 2 files changed, 3 insertions(+) diff --git a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql index bef3e07e910..0b4b773be40 100644 --- a/htdocs/install/mysql/migration/16.0.0-17.0.0.sql +++ b/htdocs/install/mysql/migration/16.0.0-17.0.0.sql @@ -55,6 +55,8 @@ ALTER TABLE llx_user DROP COLUMN idpers3; -- v17 +ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_percent (percent); + UPDATE llx_c_paiement SET code = 'BANCON' WHERE code = 'BAN' AND libelle = 'Bancontact'; -- VMYSQL4.3 ALTER TABLE llx_partnership MODIFY COLUMN fk_user_creat integer NULL; diff --git a/htdocs/install/mysql/tables/llx_actioncomm.key.sql b/htdocs/install/mysql/tables/llx_actioncomm.key.sql index ee16386c7c4..944471620ae 100644 --- a/htdocs/install/mysql/tables/llx_actioncomm.key.sql +++ b/htdocs/install/mysql/tables/llx_actioncomm.key.sql @@ -27,5 +27,6 @@ ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_datep (datep); ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_datep2 (datep2); ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_recurid (recurid); ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_ref_ext (ref_ext); +ALTER TABLE llx_actioncomm ADD INDEX idx_actioncomm_percent (percent); ALTER TABLE llx_actioncomm ADD UNIQUE INDEX uk_actioncomm_ref (ref, entity); From 9fb7e3af5a5e8462e9a419866245baae1cb1c62f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Nov 2022 01:43:16 +0100 Subject: [PATCH 42/99] Trans --- htdocs/langs/en_US/projects.lang | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/langs/en_US/projects.lang b/htdocs/langs/en_US/projects.lang index b6001b2b27b..67dfb75a242 100644 --- a/htdocs/langs/en_US/projects.lang +++ b/htdocs/langs/en_US/projects.lang @@ -240,7 +240,7 @@ OppStatusPENDING=Pending OppStatusWON=Won OppStatusLOST=Lost Budget=Budget -AllowToLinkFromOtherCompany=Allow to link project from other company

Supported values:
- Keep empty: Can link any project of the company (default)
- "all": Can link any projects, even projects of other companies
- A list of third-party ids separated by commas: can link all projects of these third partys (Example: 123,4795,53)
+AllowToLinkFromOtherCompany=Allow to link an element with a project of other company

Supported values:
- Keep empty: Can link elements with any projects in the same company (default)
- "all": Can link elements with any projects, even projects of other companies
- A list of third-party ids separated by commas: can link elements with any projects of these third partys (Example: 123,4795,53)
LatestProjects=Latest %s projects LatestModifiedProjects=Latest %s modified projects OtherFilteredTasks=Other filtered tasks @@ -284,7 +284,7 @@ ProfitIsCalculatedWith=Profit is calculated using AddPersonToTask=Add also to tasks UsageOrganizeEvent=Usage: Event Organization PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE=Classify project as closed when all its tasks are completed (100%% progress) -PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE_help=Note: existing projects with all tasks at 100 %% progress won't be affected: you will have to close them manually. This option only affects open projects. +PROJECT_CLASSIFY_CLOSED_WHEN_ALL_TASKS_DONE_help=Note: existing projects with all tasks already set to a progress of 100 %% won't be affected: you will have to close them manually. This option only affects open projects. SelectLinesOfTimeSpentToInvoice=Select lines of time spent that are unbilled, then bulk action "Generate Invoice" to bill them ProjectTasksWithoutTimeSpent=Project tasks without time spent FormForNewLeadDesc=Thanks to fill the following form to contact us. You can also send us an email directly to %s. From 6684b3c96b3a23b953c90616065b01d33dd4d035 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Nov 2022 02:13:01 +0100 Subject: [PATCH 43/99] Fix balance of columns --- htdocs/comm/propal/list.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index e490a5ca7ac..900eb39ffc1 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -1372,6 +1372,14 @@ if ($resql) { print "\n"; + $totalarray = array( + 'nbfield' => 0, + 'val' => array( + 'p.total_ht' => 0, + 'p.total_tva' => 0, + 'p.total_ttc' => 0, + ), + ); // Fields title print ''; @@ -1489,14 +1497,6 @@ if ($resql) { if (!empty($arrayfields['total_mark_rate']['checked'])) { print_liste_field_titre($arrayfields['total_mark_rate']['label'], $_SERVER['PHP_SELF'], '', '', $param, 'class="right"', $sortfield, $sortorder); } - $totalarray = array( - 'nbfield' => 0, - 'val' => array( - 'p.total_ht' => 0, - 'p.total_tva' => 0, - 'p.total_ttc' => 0, - ), - ); // Extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_title.tpl.php'; // Hook fields @@ -1508,6 +1508,7 @@ if ($resql) { 'totalarray' => &$totalarray, ); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook + print $hookmanager->resPrint; if (!empty($arrayfields['p.datec']['checked'])) { print_liste_field_titre($arrayfields['p.datec']['label'], $_SERVER["PHP_SELF"], "p.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder); @@ -1547,6 +1548,9 @@ if ($resql) { $total_ht = 0; $total_margin = 0; + $savnbfield = $totalarray['nbfield']; + $totalarray = array(); + $totalarray['nbfield'] = 0; $last_num = min($num, $limit); while ($i < $last_num) { $obj = $db->fetch_object($resql); From c11d69dd2154f9715c3fd3551088415eb0ffed71 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Nov 2022 02:23:13 +0100 Subject: [PATCH 44/99] Fix typo in tooltip --- htdocs/comm/propal/list.php | 8 ++++---- htdocs/societe/class/societe.class.php | 13 +++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 900eb39ffc1..987121c091b 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -209,7 +209,7 @@ $arrayfields = array( 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), 's.name_alias'=>array('label'=>"AliasNameShort", 'checked'=>-1), 's.town'=>array('label'=>"Town", 'checked'=>-1), - 's.zip'=>array('label'=>"Zip", 'checked'=>1), + 's.zip'=>array('label'=>"Zip", 'checked'=>-1), 'state.nom'=>array('label'=>"StateShort", 'checked'=>0), 'country.code_iso'=>array('label'=>"Country", 'checked'=>0), 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers), @@ -1680,7 +1680,7 @@ if ($resql) { // Thirdparty if (!empty($arrayfields['s.nom']['checked'])) { - print ''; + print ''; print $companystatic->getNomUrl(1, 'customer'); print ''; if (!$i) { @@ -1964,7 +1964,7 @@ if ($resql) { // Author if (!empty($arrayfields['u.login']['checked'])) { - print ''; + print ''; if ($userstatic->id) { print $userstatic->getNomUrl(-1); } @@ -1976,7 +1976,7 @@ if ($resql) { if (!empty($arrayfields['sale_representative']['checked'])) { // Sales representatives - print ''; + print ''; if ($obj->socid > 0) { $listsalesrepresentatives = $companystatic->getSalesRepresentatives($user); if ($listsalesrepresentatives < 0) { diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 7a8e1004468..5876e8aff4a 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -2683,23 +2683,24 @@ class Societe extends CommonObject if (!empty($this->tva_intra) || (!empty($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP) && strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'vatnumber') !== false)) { $label2 .= '
'.$langs->trans('VATIntra').': '.dol_escape_htmltag($this->tva_intra); } + if (!empty($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP)) { - if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid1') !== false) { + if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid1') !== false && $langs->trans('ProfId1'.$this->country_code) != '-') { $label2 .= '
'.$langs->trans('ProfId1'.$this->country_code).': '.$this->idprof1; } - if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid2') !== false) { + if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid2') !== false && $langs->trans('ProfId2'.$this->country_code) != '-') { $label2 .= '
'.$langs->trans('ProfId2'.$this->country_code).': '.$this->idprof2; } - if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid3') !== false) { + if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid3') !== false && $langs->trans('ProfId3'.$this->country_code) != '-') { $label2 .= '
'.$langs->trans('ProfId3'.$this->country_code).': '.$this->idprof3; } - if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid4') !== false) { + if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid4') !== false && $langs->trans('ProfId4'.$this->country_code) != '-') { $label2 .= '
'.$langs->trans('ProfId4'.$this->country_code).': '.$this->idprof4; } - if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid5') !== false) { + if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid5') !== false && $langs->trans('ProfId5'.$this->country_code) != '-') { $label2 .= '
'.$langs->trans('ProfId5'.$this->country_code).': '.$this->idprof5; } - if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid6') !== false) { + if (strpos($conf->global->SOCIETE_SHOW_FIELD_IN_TOOLTIP, 'profid6') !== false && $langs->trans('ProfId6'.$this->country_code) != '-') { $label2 .= '
'.$langs->trans('ProfId6'.$this->country_code).': '.$this->idprof6; } } From b8e5b10cace4d937bd27be277ad8c0db4b2b04d0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Nov 2022 02:29:30 +0100 Subject: [PATCH 45/99] Default field --- htdocs/comm/propal/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 987121c091b..dc4c4339f1e 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -203,7 +203,7 @@ if (empty($user->socid)) { $checkedtypetiers = 0; $arrayfields = array( 'p.ref'=>array('label'=>"Ref", 'checked'=>1), - 'p.ref_client'=>array('label'=>"RefCustomer", 'checked'=>1), + 'p.ref_client'=>array('label'=>"RefCustomer", 'checked'=>-1), 'pr.ref'=>array('label'=>"ProjectRef", 'checked'=>1, 'enabled'=>(empty($conf->project->enabled) ? 0 : 1)), 'pr.title'=>array('label'=>"ProjectLabel", 'checked'=>0, 'enabled'=>(empty($conf->project->enabled) ? 0 : 1)), 's.nom'=>array('label'=>"ThirdParty", 'checked'=>1), From e3aa438d2a582313dfd5178b8cc5975e0c912c25 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Nov 2022 02:50:30 +0100 Subject: [PATCH 46/99] FIX deletion of a line of time spent --- htdocs/projet/tasks/time.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php index 17eadfe4e17..0b6896260c2 100644 --- a/htdocs/projet/tasks/time.php +++ b/htdocs/projet/tasks/time.php @@ -54,6 +54,7 @@ $toselect = GETPOST('toselect', 'array'); // Array of ids of elements selected i $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'timespentlist'; // To manage different context of search $backtopage = GETPOST('backtopage', 'alpha'); // Go back to a dedicated page $optioncss = GETPOST('optioncss', 'alpha'); +$mode = GETPOST('mode', 'alpha'); $id = GETPOST('id', 'int'); $projectid = GETPOST('projectid', 'int'); @@ -323,10 +324,10 @@ if (($action == 'updateline' || $action == 'updatesplitline') && !$cancel && $us } } -if ($action == 'confirm_deleteline' && $confirm == "yes" && $user->rights->projet->supprimer) { - $object->fetchTimeSpent(GETPOST('lineid', 'int')); // load properties like $object->timespent_id +if ($action == 'confirm_deleteline' && $confirm == "yes" && ($user->hasRight('projet', 'time') || $user->hasRight('projet', 'all', 'creer'))) { + $object->fetchTimeSpent(GETPOST('lineid', 'int')); // load properties like $object->timespent_xxx - if (in_array($object->timespent_fk_user, $childids) || $user->rights->projet->all->creer) { + if (in_array($object->timespent_fk_user, $childids) || $user->hasRight('projet', 'all', 'creer')) { $result = $object->delTimeSpent($user); // delete line with $object->timespent_id if ($result < 0) { @@ -2109,7 +2110,7 @@ if (($id > 0 || !empty($ref)) || $projectidforalltimes > 0 || $allprojectforuser print ' '; print ''; } elseif ($user->hasRight('projet', 'time') || $user->hasRight('projet', 'all', 'creer')) { // Read project and enter time consumed on assigned tasks - if ($task_time->fk_user == $user->id || in_array($task_time->fk_user, $childids) || $user->hasRight('projet', 'all', 'creer')) { + if (in_array($task_time->fk_user, $childids) || $user->hasRight('projet', 'all', 'creer')) { if (getDolGlobalString('MAIN_FEATURES_LEVEL') >= 2) { print ' '; print '
rowid.$param.((empty($id) || $tab == 'timespent') ? '&tab=timespent' : '').'">'; From 5495747d68a663fc79d7124d00ab378183f608fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charl=C3=A8ne=20Benke?= <1179011+defrance@users.noreply.github.com> Date: Thu, 17 Nov 2022 07:12:57 +0100 Subject: [PATCH 47/99] if categorie not enabled, we can't use type_account --- htdocs/compta/bank/list.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 54cd0f2b58c..a56f0486e6f 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -59,7 +59,10 @@ $search_number = GETPOST('search_number', 'alpha'); $search_status = GETPOST('search_status') ?GETPOST('search_status', 'alpha') : 'opened'; // 'all' or ''='opened' $optioncss = GETPOST('optioncss', 'alpha'); -$search_category_list = GETPOST("search_category_".Categorie::TYPE_ACCOUNT."_list", "array"); +$search_category_list =""; +if (isModEnabled('categorie')) { + $search_category_list = GETPOST("search_category_".Categorie::TYPE_ACCOUNT."_list", "array"); +} $socid = 0; // Security check From 309a7ccf34b310aa350a4bdb87fa3ab3662d8554 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Nov 2022 10:21:26 +0100 Subject: [PATCH 48/99] Fix missing abstract methods --- .../class/expeditionstats.class.php | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/htdocs/expedition/class/expeditionstats.class.php b/htdocs/expedition/class/expeditionstats.class.php index 8eb31896f38..aa4e40fcb8f 100644 --- a/htdocs/expedition/class/expeditionstats.class.php +++ b/htdocs/expedition/class/expeditionstats.class.php @@ -131,6 +131,54 @@ class ExpeditionStats extends Stats return $this->_getNbByYear($sql); } + /** + * Return the orders amount by month for a year + * + * @param int $year Year to scan + * @param int $format 0=Label of abscissa is a translated text, 1=Label of abscissa is month number, 2=Label of abscissa is first letter of month + * @return array Array with amount by month + */ + public function getAmountByMonth($year, $format = 0) + { + global $user; + + $sql = "SELECT date_format(c.date_valid,'%m') as dm, SUM(c.".$this->field.")"; + $sql .= " FROM ".$this->from; + if (empty($user->rights->societe->client->voir) && !$this->socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= $this->join; + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); + + $res = $this->_getAmountByMonth($year, $sql, $format); + return $res; + } + + /** + * Return the orders amount average by month for a year + * + * @param int $year year for stats + * @return array array with number by month + */ + public function getAverageByMonth($year) + { + global $user; + + $sql = "SELECT date_format(c.date_valid,'%m') as dm, AVG(c.".$this->field.")"; + $sql .= " FROM ".$this->from; + if (empty($user->rights->societe->client->voir) && !$this->socid) { + $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; + } + $sql .= $this->join; + $sql .= " WHERE ".$this->where; + $sql .= " GROUP BY dm"; + $sql .= $this->db->order('dm', 'DESC'); + + return $this->_getAverageByMonth($year, $sql); + } + /** * Return nb, total and average * From 1c19327454a4536bb2df17944d37be46bf482c0f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Nov 2022 10:48:44 +0100 Subject: [PATCH 49/99] FIX #22843 --- htdocs/expedition/class/expedition.class.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index d3981dcf264..4842a27fa77 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -84,6 +84,13 @@ class Expedition extends CommonObject */ public $picto = 'dolly'; + + /** + * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. + */ + public $fields = array(); + + public $socid; /** From 6d4086fc24a43e5cf4bc6c2cff8704dad97f60fc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Nov 2022 11:08:06 +0100 Subject: [PATCH 50/99] Fix timezone date --- htdocs/user/card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 5a5a5d6fc9e..7fc268568c8 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1834,10 +1834,10 @@ if ($action == 'create' || $action == 'adduserldap') { print ''.$langs->trans("LastConnexion").''; print ''; if ($object->datepreviouslogin) { - print dol_print_date($object->datepreviouslogin, "dayhour").' ('.$langs->trans("Previous").'), '; + print dol_print_date($object->datepreviouslogin, "dayhour", "tzuserrel").' ('.$langs->trans("Previous").'), '; } if ($object->datelastlogin) { - print dol_print_date($object->datelastlogin, "dayhour").' ('.$langs->trans("Currently").')'; + print dol_print_date($object->datelastlogin, "dayhour", "tzuserrel").' ('.$langs->trans("Currently").')'; } print ''; print "\n"; From 28833e71a156189143233b1ecf97e3c68bf3a3f4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Nov 2022 12:39:24 +0100 Subject: [PATCH 51/99] FIX for #22882 --- htdocs/product/fournisseurs.php | 9 ++++++--- htdocs/product/list.php | 13 ++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 5eae5c45dc9..8345839dae1 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -270,10 +270,13 @@ if (empty($reshook)) { if ($ret == -3) { $error++; - $object->fetch($object->product_id_already_linked); - $productLink = $object->getNomUrl(1, 'supplier'); + $tmpobject = new Product($db); + $tmpobject->fetch($object->product_id_already_linked); + $productLink = $tmpobject->getNomUrl(1, 'supplier'); - setEventMessages($langs->trans("ReferenceSupplierIsAlreadyAssociatedWithAProduct", $productLink), null, 'errors'); + $texttoshow = $langs->trans("ReferenceSupplierIsAlreadyAssociatedWithAProduct", '{s1}'); + $texttoshow = str_replace('{s1}', $productLink, $texttoshow); + setEventMessages($texttoshow, null, 'errors'); } elseif ($ret < 0) { $error++; setEventMessages($object->error, $object->errors, 'errors'); diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 5716c1a70ea..b96a0f6447e 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -176,7 +176,6 @@ if (!empty($conf->global->STOCK_CALCULATE_ON_SHIPMENT) // List of fields to search into when doing a "search in all" $fieldstosearchall = array( 'p.ref'=>"Ref", - 'pfp.ref_fourn'=>"RefSupplier", 'p.label'=>"ProductLabel", 'p.description'=>"Description", "p.note"=>"Note", @@ -190,7 +189,6 @@ if (getDolGlobalInt('MAIN_MULTILANGS')) { } if (isModEnabled('barcode')) { $fieldstosearchall['p.barcode'] = 'Gencod'; - $fieldstosearchall['pfp.barcode'] = 'GencodBuyPrice'; } // Personalized search criterias. Example: $conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS = 'p.ref=ProductRef;p.label=ProductLabel;p.description=Description;p.note=Note;' if (!empty($conf->global->PRODUCT_QUICKSEARCH_ON_FIELDS)) { @@ -459,7 +457,16 @@ if (!empty($conf->global->PRODUCT_USE_UNITS)) { $sql .= ' WHERE p.entity IN ('.getEntity('product').')'; if ($sall) { - $sql .= natural_search(array_keys($fieldstosearchall), $sall); + $sql .= ' AND ('; + $sql .= natural_search(array_keys($fieldstosearchall), $sall, 0, 1); + // Search also into a supplier reference 'pfp.ref_fourn'="RefSupplier" + $sql .= ' OR EXISTS (SELECT rowid FROM '.MAIN_DB_PREFIX.'product_fournisseur_price as pfp WHERE pfp.fk_product = p.rowid'; + $sql .= ' AND ('.natural_search('pfp.ref_fourn', $sall, 0, 1); + if (isModEnabled('barcode')) { + // Search also into a supplier barcode 'pfp.barcode'='GencodBuyPrice'; + $sql .= ' OR '.natural_search('pfp.barcode', $sall, 0, 1); + } + $sql .= ')))'; } // if the type is not 1, we show all products (type = 0,2,3) if (dol_strlen($search_type) && $search_type != '-1') { From 328641dfa83d625dcb6ddae2e275294131df536c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Nov 2022 12:54:51 +0100 Subject: [PATCH 52/99] Fix empty list --- htdocs/product/fournisseurs.php | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index a9c4ec15fc2..75d277cd3e4 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -957,52 +957,72 @@ END; $param = "&id=".$object->id; + $nbfields = 0; + print ''; if (!empty($arrayfields['pfp.datec']['checked'])) { print_liste_field_titre("AppliedPricesFrom", $_SERVER["PHP_SELF"], "pfp.datec", "", $param, "", $sortfield, $sortorder, '', '', 1); + $nbfields++; } if (!empty($arrayfields['s.nom']['checked'])) { print_liste_field_titre("Suppliers", $_SERVER["PHP_SELF"], "s.nom", "", $param, "", $sortfield, $sortorder, '', '', 1); + $nbfields++; } print_liste_field_titre("SupplierRef", $_SERVER["PHP_SELF"], "", "", $param, "", $sortfield, $sortorder, '', '', 1); + $nbfields++; if (!empty($arrayfields['pfp.fk_availability']['checked'])) { print_liste_field_titre("Availability", $_SERVER["PHP_SELF"], "pfp.fk_availability", "", $param, "", $sortfield, $sortorder); + $nbfields++; } if (!empty($arrayfields['pfp.quantity']['checked'])) { print_liste_field_titre("QtyMin", $_SERVER["PHP_SELF"], "pfp.quantity", "", $param, '', $sortfield, $sortorder, 'right '); + $nbfields++; } print_liste_field_titre("VATRate", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + $nbfields++; print_liste_field_titre("PriceQtyMinHT", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + $nbfields++; if (!empty($conf->multicurrency->enabled)) { print_liste_field_titre("PriceQtyMinHTCurrency", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + $nbfields++; } if (!empty($arrayfields['pfp.unitprice']['checked'])) { print_liste_field_titre("UnitPriceHT", $_SERVER["PHP_SELF"], "pfp.unitprice", "", $param, '', $sortfield, $sortorder, 'right '); + $nbfields++; } if (!empty($arrayfields['pfp.multicurrency_unitprice']['checked'])) { print_liste_field_titre("UnitPriceHTCurrency", $_SERVER["PHP_SELF"], "pfp.multicurrency_unitprice", "", $param, '', $sortfield, $sortorder, 'right '); + $nbfields++; } if (!empty($conf->multicurrency->enabled)) { print_liste_field_titre("Currency", $_SERVER["PHP_SELF"], "", "", $param, '', $sortfield, $sortorder, 'right '); + $nbfields++; } print_liste_field_titre("DiscountQtyMin", $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'right '); + $nbfields++; if (!empty($arrayfields['pfp.delivery_time_days']['checked'])) { print_liste_field_titre("NbDaysToDelivery", $_SERVER["PHP_SELF"], "pfp.delivery_time_days", "", $param, '', $sortfield, $sortorder, 'right '); + $nbfields++; } if (!empty($arrayfields['pfp.supplier_reputation']['checked'])) { print_liste_field_titre("ReputationForThisProduct", $_SERVER["PHP_SELF"], "pfp.supplier_reputation", "", $param, '', $sortfield, $sortorder, 'center '); + $nbfields++; } if (!empty($arrayfields['pfp.fk_barcode_type']['checked'])) { print_liste_field_titre("BarcodeType", $_SERVER["PHP_SELF"], "pfp.fk_barcode_type", "", $param, '', $sortfield, $sortorder, 'center '); + $nbfields++; } if (!empty($arrayfields['pfp.barcode']['checked'])) { print_liste_field_titre("BarcodeValue", $_SERVER["PHP_SELF"], "pfp.barcode", "", $param, '', $sortfield, $sortorder, 'center '); + $nbfields++; } if (!empty($arrayfields['pfp.packaging']['checked'])) { print_liste_field_titre("PackagingForThisProduct", $_SERVER["PHP_SELF"], "pfp.packaging", "", $param, 'align="center"', $sortfield, $sortorder); + $nbfields++; } if (!empty($arrayfields['pfp.tms']['checked'])) { print_liste_field_titre("DateModification", $_SERVER["PHP_SELF"], "pfp.tms", "", $param, '', $sortfield, $sortorder, 'right ', '', 1); + $nbfields++; } // fetch optionals attributes and labels @@ -1024,6 +1044,7 @@ END; } if (!empty($arrayfields['ef.' . $key]['checked'])) { print_liste_field_titre($extratitle, $_SERVER["PHP_SELF"], 'ef.' . $key, '', $param, '', $sortfield, $sortorder, 'right '); + $nbfields++; } } } @@ -1031,10 +1052,11 @@ END; } if (is_object($hookmanager)) { - $parameters = array('id_fourn'=>(!empty($id_fourn)?$id_fourn:''), 'prod_id'=>$object->id); + $parameters = array('id_fourn'=>(!empty($id_fourn)?$id_fourn:''), 'prod_id'=>$object->id, 'nbfields'=>$nbfields); $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object, $action); } print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch '); + $nbfields++; print "\n"; if (is_array($product_fourn_list)) { @@ -1216,6 +1238,10 @@ END; print ''; } + + if (empty($product_fourn_list)) { + print ''.$langs->trans("None").''; + } } else { dol_print_error($db); } From bbf844939c33e280b3976b586e4041236e49f98b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 17 Nov 2022 16:00:13 +0100 Subject: [PATCH 53/99] fix MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE --- htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php index 5e4b75a183e..7ff463df8b3 100644 --- a/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php +++ b/htdocs/core/modules/supplier_order/doc/pdf_cornas.modules.php @@ -5,7 +5,7 @@ * Copyright (C) 2010-2014 Juanjo Menent * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2018 Frédéric France + * Copyright (C) 2018-2022 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1567,7 +1567,7 @@ class pdf_cornas extends ModelePDFSuppliersOrders 'border-left' => false, // remove left line separator ); - if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE)) { + if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_ORDER_WITH_PICTURE)) { $this->cols['photo']['status'] = true; } From 7a41a851c86846f7107d8ae917b780ec7a02cf7d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Nov 2022 18:09:54 +0100 Subject: [PATCH 54/99] Fix pb with DATABASE_PWD_ENCRYPTED --- htdocs/admin/security.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index a1281351176..8f7dc42a56a 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -58,7 +58,11 @@ if ($action == 'activate_encrypt') { $db->begin(); - dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); + // On old version a bug created the constant into user entity, so we delete it to be sure, such entry won't exists. We want it in entity 0 or nowhere. + dolibarr_del_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); + // We set entity=0 (all) because DATABASE_PWD_ENCRYPTED is a setup into conf file, so always shared for everybody + $entityforall = 0; + dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $entityforall); $sql = "SELECT u.rowid, u.pass, u.pass_crypted"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; From a2e74e37f50fd81cf3b55fb33f98d33d467fcdd0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Nov 2022 18:09:54 +0100 Subject: [PATCH 55/99] Fix missing GETPOST --- htdocs/admin/security.php | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index a1281351176..4d4b9b5247b 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -45,7 +45,7 @@ $allow_disable_encryption = true; */ if ($action == 'setgeneraterule') { - if (!dolibarr_set_const($db, 'USER_PASSWORD_GENERATED', $_GET["value"], 'chaine', 0, '', $conf->entity)) { + if (!dolibarr_set_const($db, 'USER_PASSWORD_GENERATED', GETPOST("value", "none"), 'chaine', 0, '', $conf->entity)) { dol_print_error($db); } else { header("Location: ".$_SERVER["PHP_SELF"]); @@ -58,7 +58,11 @@ if ($action == 'activate_encrypt') { $db->begin(); - dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); + // On old version a bug created the constant into user entity, so we delete it to be sure, such entry won't exists. We want it in entity 0 or nowhere. + dolibarr_del_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $conf->entity); + // We set entity=0 (all) because DATABASE_PWD_ENCRYPTED is a setup into conf file, so always shared for everybody + $entityforall = 0; + dolibarr_set_const($db, "DATABASE_PWD_ENCRYPTED", "1", 'chaine', 0, '', $entityforall); $sql = "SELECT u.rowid, u.pass, u.pass_crypted"; $sql .= " FROM ".MAIN_DB_PREFIX."user as u"; @@ -385,7 +389,8 @@ if ($conf->global->USER_PASSWORD_GENERATED == "Perso") { } -// Cryptage mot de passe +// Crypt passwords in database + print '
'; print ""; print ''; @@ -401,20 +406,20 @@ print ''; // Disable clear password in database print ''; print ''.$langs->trans("DoNotStoreClearPassword").''; -print ''; +print ''; if (getDolGlobalString('DATABASE_PWD_ENCRYPTED')) { print img_picto($langs->trans("Active"), 'tick'); } print ''; if (!getDolGlobalString('DATABASE_PWD_ENCRYPTED')) { - print ''; + print ''; print '
'.$langs->trans("Activate").''; print ""; } // Database conf file encryption if (getDolGlobalString('DATABASE_PWD_ENCRYPTED')) { - print ''; + print ''; if ($allow_disable_encryption) { //On n'autorise pas l'annulation de l'encryption car les mots de passe ne peuvent pas etre decodes //Do not allow "disable encryption" as passwords cannot be decrypted @@ -427,7 +432,8 @@ if (getDolGlobalString('DATABASE_PWD_ENCRYPTED')) { print ""; print ''; -// Cryptage du mot de base de la base dans conf.php + +// Crypt password into config file conf.php print ''; print ''.$langs->trans("MainDbPasswordFileConfEncrypted").''; @@ -438,7 +444,7 @@ if (preg_match('/crypted:/i', $dolibarr_main_db_pass) || !empty($dolibarr_main_d print ''; -print ''; +print ''; if (empty($dolibarr_main_db_pass) && empty($dolibarr_main_db_encrypted_pass)) { $langs->load("errors"); print img_warning($langs->trans("WarningPassIsEmpty")); @@ -460,18 +466,18 @@ print ''; print ''; print ''.$langs->trans("DisableForgetPasswordLinkOnLogonPage").''; -print ''; +print ''; if (getDolGlobalString('MAIN_SECURITY_DISABLEFORGETPASSLINK')) { print img_picto($langs->trans("Active"), 'tick'); } print ''; if (!getDolGlobalString('MAIN_SECURITY_DISABLEFORGETPASSLINK')) { - print ''; + print ''; print ''.$langs->trans("Activate").''; print ""; } if (getDolGlobalString('MAIN_SECURITY_DISABLEFORGETPASSLINK')) { - print ''; + print ''; print ''.$langs->trans("Disable").''; print ""; } From 2f0d9e18bd393ae94fcc223ac29ec4de06f38056 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 17 Nov 2022 23:29:42 +0100 Subject: [PATCH 56/99] Fix missing default bank account on form --- htdocs/comm/card.php | 12 +++---- htdocs/fourn/card.php | 35 +++++++++++++++++++-- htdocs/install/mysql/tables/llx_societe.sql | 2 +- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 4d59a75fb1b..f578aa75cf5 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -158,7 +158,7 @@ if (empty($reshook)) { $action = ""; } - // set accountancy code + // Set accountancy code if ($action == 'setcustomeraccountancycode') { $result = $object->fetch($id); $object->code_compta_client = GETPOST("customeraccountancycode"); @@ -169,7 +169,7 @@ if (empty($reshook)) { } } - // terms of the settlement + // Payment terms of the settlement if ($action == 'setconditions' && $user->rights->societe->creer) { $object->fetch($id); $result = $object->setPaymentTerms(GETPOST('cond_reglement_id', 'int'), GETPOST('cond_reglement_id_deposit_percent', 'alpha')); @@ -178,7 +178,7 @@ if (empty($reshook)) { } } - // mode de reglement + // Payment mode if ($action == 'setmode' && $user->rights->societe->creer) { $object->fetch($id); $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); @@ -187,7 +187,7 @@ if (empty($reshook)) { } } - // transport mode + // Transport mode if ($action == 'settransportmode' && $user->rights->societe->creer) { $object->fetch($id); $result = $object->setTransportMode(GETPOST('transport_mode_id', 'alpha')); @@ -421,7 +421,7 @@ if ($object->id > 0) { print ""; print ''; - // Mode de reglement par defaut + // Default payment mode print ''; print ''; if (isModEnabled("banque")) { - // Compte bancaire par défaut + // Default bank account for payments print '
'; print $langs->trans('PaymentMode'); @@ -440,7 +440,7 @@ if ($object->id > 0) { print '
'; print '"; print ''; - // Mode de reglement par defaut + // Default payment mode print '
'; print $langs->trans('PaymentBankAccount'); diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 2c929aa40ba..f3260d8ea48 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -106,7 +106,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } - // terms of the settlement + // Set payment terms of the settlement if ($action == 'setconditions' && $user->rights->societe->creer) { $object->fetch($id); $result = $object->setPaymentTerms(GETPOST('cond_reglement_supplier_id', 'int')); @@ -114,7 +114,7 @@ if (empty($reshook)) { dol_print_error($db, $object->error); } } - // mode de reglement + // Payment mode if ($action == 'setmode' && $user->rights->societe->creer) { $object->fetch($id); $result = $object->setPaymentMethods(GETPOST('mode_reglement_supplier_id', 'int')); @@ -123,6 +123,15 @@ if (empty($reshook)) { } } + // Bank account + if ($action == 'setbankaccount' && $user->rights->societe->creer) { + $object->fetch($id); + $result = $object->setBankAccount(GETPOST('fk_account', 'int')); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } + } + // update supplier order min amount if ($action == 'setsupplier_order_min_amount') { $object->fetch($id); @@ -276,7 +285,7 @@ if ($object->id > 0) { print "
'; print '"; print ''; + if (isModEnabled("banque")) { + // Default bank account for payments + print '"; + print ''; + } + // Relative discounts (Discounts-Drawbacks-Rebates) print '
'; print $langs->trans('PaymentMode'); @@ -294,6 +303,26 @@ if ($object->id > 0) { print "
'; + print ''; + } + print '
'; + print $langs->trans('PaymentBankAccount'); + print ''; + if (($action != 'editbankaccount') && $user->rights->societe->creer) { + print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; + print '
'; + if ($action == 'editbankaccount') { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_account, 'fk_account', 1); + } else { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?socid='.$object->id, $object->fk_account, 'none'); + } + print "
'; print ''; + print '
'.$langs->trans("SmsInfoCharRemain").': '.(160 - dol_strlen($defaultmessage)).'
'; } print "\n"; } From e480b7cabb25daab7e902ecaa652717375f7cd99 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Nov 2022 01:01:59 +0100 Subject: [PATCH 59/99] Fix phpunit error --- htdocs/admin/security.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/security.php b/htdocs/admin/security.php index 4d4b9b5247b..2c2444cd473 100644 --- a/htdocs/admin/security.php +++ b/htdocs/admin/security.php @@ -45,7 +45,7 @@ $allow_disable_encryption = true; */ if ($action == 'setgeneraterule') { - if (!dolibarr_set_const($db, 'USER_PASSWORD_GENERATED', GETPOST("value", "none"), 'chaine', 0, '', $conf->entity)) { + if (!dolibarr_set_const($db, 'USER_PASSWORD_GENERATED', GETPOST("value", "alphanohtml"), 'chaine', 0, '', $conf->entity)) { dol_print_error($db); } else { header("Location: ".$_SERVER["PHP_SELF"]); From 95d327500e09e1a70e15b38a5bb4fe68e3932e4f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Nov 2022 12:03:50 +0100 Subject: [PATCH 60/99] Debug v17 --- htdocs/admin/mails.php | 47 +++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 035830a0878..e9a8132188c 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -455,6 +455,25 @@ if ($action == 'edit') { } print ''; + // Auth mode + if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) { + print ''; + } + // ID if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) { $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID) ? $conf->global->MAIN_MAIL_SMTPS_ID : ''); @@ -471,24 +490,6 @@ if ($action == 'edit') { } - // OAUTH - if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) { - print ''; - } - // PW if (!empty($conf->use_javascript_ajax) || (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')))) { $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW) ? $conf->global->MAIN_MAIL_SMTPS_PW : ''); @@ -705,11 +706,6 @@ if ($action == 'edit') { print ''; } - // SMTPS ID - if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer'))) { - print ''; - } - // AUTH method if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer'))) { $authtype = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE', 'LOGIN'); @@ -717,6 +713,11 @@ if ($action == 'edit') { print ''; } + // SMTPS ID + if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer'))) { + print ''; + } + // SMTPS PW if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE', 'mail'), array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE') != "XOAUTH2") { print ''; From 1e684353b7a7876431089a50b7d8e51971123fc1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Nov 2022 12:59:21 +0100 Subject: [PATCH 61/99] Debug v17 --- htdocs/admin/mails_emailing.php | 61 +++++++++---------- htdocs/admin/mails_ticket.php | 102 ++++++++++++++++++-------------- 2 files changed, 87 insertions(+), 76 deletions(-) diff --git a/htdocs/admin/mails_emailing.php b/htdocs/admin/mails_emailing.php index d2eabd95e2b..b9cb57e0d80 100644 --- a/htdocs/admin/mails_emailing.php +++ b/htdocs/admin/mails_emailing.php @@ -34,10 +34,6 @@ $langs->loadLangs(array('companies', 'products', 'admin', 'mails', 'other', 'err $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'aZ09'); -if (!$user->admin) { - accessforbidden(); -} - $usersignature = $user->signature; // For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html. if ($action == 'test' || $action == 'send') { @@ -61,6 +57,10 @@ $substitutionarrayfortest = array( ); complete_substitutions_array($substitutionarrayfortest, $langs); +// Security check +if (!$user->admin) { + accessforbidden(); +} /* @@ -394,6 +394,25 @@ if ($action == 'edit') { } print ''; + // AUTH method + if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) { + print ''; + } + // ID if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) { $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID_EMAILING) ? $conf->global->MAIN_MAIL_SMTPS_ID_EMAILING : ''); @@ -409,24 +428,6 @@ if ($action == 'edit') { print ''; } - // OAUTH - if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) { - print ''; - } - // PW if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) { $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW_EMAILING) ? $conf->global->MAIN_MAIL_SMTPS_PW_EMAILING : ''); @@ -442,7 +443,7 @@ if ($action == 'edit') { print ''; } - // OAUTH service provider + // OAUTH service provider if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')))) { print ''; } - // SMTPS ID - if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) { - print ''; - } - // AUTH method if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_EMAILING'), array('smtps', 'swiftmailer'))) { $authtype = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING', 'LOGIN'); @@ -558,6 +554,11 @@ if ($action == 'edit') { print ''; } + // SMTPS ID + if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer'))) { + print ''; + } + // SMTPS PW if (isset($conf->global->MAIN_MAIL_SENDMODE_EMAILING) && in_array($conf->global->MAIN_MAIL_SENDMODE_EMAILING, array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING') != "XOAUTH2") { print ''; @@ -707,8 +708,8 @@ if ($action == 'edit') { $formmail->withfrom = 1; $formmail->witherrorsto = 1; $formmail->withto = (GETPOSTISSET('sendto') ? GETPOST('sendto', 'restricthtml') : ($user->email ? $user->email : 1)); - $formmail->withtocc = (GETPOSTISSET(['sendtocc']) ? GETPOST('sendtocc', 'restricthtml') : 1); // ! empty to keep field if empty - $formmail->withtoccc = (GETPOSTISSET(['sendtoccc']) ? GETPOST('sendtoccc', 'restricthtml') : 1); // ! empty to keep field if empty + $formmail->withtocc = (GETPOSTISSET('sendtocc') ? GETPOST('sendtocc', 'restricthtml') : 1); // ! empty to keep field if empty + $formmail->withtoccc = (GETPOSTISSET('sendtoccc') ? GETPOST('sendtoccc', 'restricthtml') : 1); // ! empty to keep field if empty $formmail->withtopic = (GETPOSTISSET('subject') ? GETPOST('subject') : $langs->trans("Test")); $formmail->withtopicreadonly = 0; $formmail->withfile = 2; diff --git a/htdocs/admin/mails_ticket.php b/htdocs/admin/mails_ticket.php index c48146fc937..05d66516cde 100644 --- a/htdocs/admin/mails_ticket.php +++ b/htdocs/admin/mails_ticket.php @@ -32,23 +32,28 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $langs->loadLangs(array('companies', 'products', 'admin', 'mails', 'other', 'errors')); $action = GETPOST('action', 'aZ09'); -$cancel = GETPOST('cancel', 'alpha'); +$cancel = GETPOST('cancel', 'aZ09'); $usersignature = $user->signature; // For action = test or send, we ensure that content is not html, even for signature, because this we want a test with NO html. if ($action == 'test' || $action == 'send') { - $usersignature = dol_string_nohtmltag($usersignature); + $usersignature = dol_string_nohtmltag($usersignature, 2); } $substitutionarrayfortest = array( -'__LOGIN__' => $user->login, -'__ID__' => 'TESTIdRecord', -'__EMAIL__' => 'TESTEMail', -'__LASTNAME__' => 'TESTLastname', -'__FIRSTNAME__' => 'TESTFirstname', -'__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), -'__SENDEREMAIL_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails -//'__PERSONALIZED__' => 'TESTPersonalized' // Hiden because not used yet + '__DOL_MAIN_URL_ROOT__'=>DOL_MAIN_URL_ROOT, + '__ID__' => 'TESTIdRecord', + '__EMAIL__' => 'TESTEMail', + '__LOGIN__' => $user->login, + '__LASTNAME__' => 'TESTLastname', + '__FIRSTNAME__' => 'TESTFirstname', + '__ADDRESS__'=> 'RecipientAddress', + '__ZIP__'=> 'RecipientZip', + '__TOWN_'=> 'RecipientTown', + '__COUNTRY__'=> 'RecipientCountry', + '__USER_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), + '__SENDEREMAIL_SIGNATURE__' => (($user->signature && empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN)) ? $usersignature : ''), // Done into actions_sendmails + //'__PERSONALIZED__' => 'TESTPersonalized' // Hiden because not used yet ); complete_substitutions_array($substitutionarrayfortest, $langs); @@ -94,10 +99,10 @@ $trackid = (($action == 'testhtml') ? "testhtml" : "test"); $sendcontext = 'ticket'; // Force to use dedicated context of setup for ticket include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; -if ($action == 'presend' && GETPOST('trackid') == 'test') { +if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'test') { $action = 'test'; } -if ($action == 'presend' && GETPOST('trackid') == 'testhtml') { +if ($action == 'presend' && GETPOST('trackid', 'alphanohtml') == 'testhtml') { $action = 'testhtml'; } @@ -317,12 +322,15 @@ if ($action == 'edit') { // Host server - print ''; if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail') { + print ''; } else { + print ''; } - print ''; + print ''; // Port @@ -351,7 +360,7 @@ if ($action == 'edit') { if (!$conf->use_javascript_ajax && $linuxlike && $conf->global->MAIN_MAIL_SENDMODE_TICKET == 'mail') { print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike"); print ''; + // AUTH method + if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) { + print ''; + } + // ID if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) { $mainstmpid = (!empty($conf->global->MAIN_MAIL_SMTPS_ID_TICKET) ? $conf->global->MAIN_MAIL_SMTPS_ID_TICKET : ''); @@ -390,25 +418,6 @@ if ($action == 'edit') { print ''; } - // OAUTH - if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) { - print ''; - } - - // PW if (!empty($conf->use_javascript_ajax) || (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')))) { $mainsmtppw = (!empty($conf->global->MAIN_MAIL_SMTPS_PW_TICKET) ? $conf->global->MAIN_MAIL_SMTPS_PW_TICKET : ''); @@ -514,11 +523,6 @@ if ($action == 'edit') { print ''; } - // SMTPS ID - if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) { - print ''; - } - // AUTH method if (in_array(getDolGlobalString('MAIN_MAIL_SENDMODE_TICKET'), array('smtps', 'swiftmailer'))) { $authtype = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET', 'LOGIN'); @@ -526,6 +530,11 @@ if ($action == 'edit') { print ''; } + // SMTPS ID + if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer'))) { + print ''; + } + // SMTPS PW if (isset($conf->global->MAIN_MAIL_SENDMODE_TICKET) && in_array($conf->global->MAIN_MAIL_SENDMODE_TICKET, array('smtps', 'swiftmailer')) && getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET') != "XOAUTH2") { print ''; @@ -621,6 +630,7 @@ if ($action == 'edit') { // Run the test to connect if ($action == 'testconnect') { + print '
'; print load_fiche_titre($langs->trans("DoTestServerAvailability")); include_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; @@ -651,8 +661,8 @@ if ($action == 'edit') { // Cree l'objet formulaire mail include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; $formmail = new FormMail($db); - $formmail->fromname = (GETPOSTISSET('fromname') ? GETPOST('fromname') : $conf->global->MAIN_MAIL_EMAIL_FROM); - $formmail->frommail = (GETPOSTISSET('frommail') ? GETPOST('frommail') : $conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->fromname = (GETPOSTISSET('fromname') ? GETPOST('fromname', 'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM); + $formmail->frommail = (GETPOSTISSET('frommail') ? GETPOST('frommail', 'restricthtml') : $conf->global->MAIN_MAIL_EMAIL_FROM); $formmail->trackid = (($action == 'testhtml') ? "testhtml" : "test"); $formmail->withfromreadonly = 0; $formmail->withsubstit = 0; @@ -679,7 +689,7 @@ if ($action == 'edit') { $formmail->param["returnurl"] = $_SERVER["PHP_SELF"]; // Init list of files - if (GETPOST("mode") == 'init') { + if (GETPOST("mode", "aZ09") == 'init') { $formmail->clear_attached_files(); } From 2dffe3748d2d983bda5b375fa31b65d77452af0a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Nov 2022 13:41:27 +0100 Subject: [PATCH 62/99] Debug v17 - Fix missing delete picto on ODT setup --- .../doc/doc_generic_asset_odt.modules.php | 4 +- .../bom/doc/doc_generic_bom_odt.modules.php | 4 +- .../doc/doc_generic_order_odt.modules.php | 6 ++- .../doc/doc_generic_contract_odt.modules.php | 44 ++++++++++++++----- .../doc/doc_generic_shipment_odt.modules.php | 4 +- .../doc/doc_generic_invoice_odt.modules.php | 4 +- .../doc/doc_generic_member_odt.class.php | 4 +- .../mrp/doc/doc_generic_mo_odt.modules.php | 4 +- .../doc/doc_generic_project_odt.modules.php | 4 +- .../task/doc/doc_generic_task_odt.modules.php | 4 +- .../doc/doc_generic_reception_odt.modules.php | 4 +- .../doc/doc_generic_stock_odt.modules.php | 4 +- ...doc_generic_supplier_order_odt.modules.php | 6 ++- ..._generic_supplier_proposal_odt.modules.php | 4 +- .../doc/doc_generic_ticket_odt.modules.php | 4 +- .../user/doc/doc_generic_user_odt.modules.php | 4 +- .../doc/doc_generic_myobject_odt.modules.php | 21 ++++----- 17 files changed, 91 insertions(+), 38 deletions(-) diff --git a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php index b11e2a7e563..8be86dda944 100644 --- a/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php +++ b/htdocs/core/modules/asset/doc/doc_generic_asset_odt.modules.php @@ -173,7 +173,9 @@ class doc_generic_asset_odt extends ModelePDFAsset if ($nbofiles) { $texte .= ''; } diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index 2dcf5512dc1..bec28b941aa 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -169,7 +169,9 @@ class doc_generic_bom_odt extends ModelePDFBom $texte .= '
'; // Show list of found files foreach ($listoffiles as $file) { - $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').'
'; + $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').''; + $texte .= '   '.img_picto('', 'delete').''; + $texte .= '
'; } $texte .= '
'; } diff --git a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php index 9239ec0ed4b..5e94397bc91 100644 --- a/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php +++ b/htdocs/core/modules/commande/doc/doc_generic_order_odt.modules.php @@ -159,7 +159,7 @@ class doc_generic_order_odt extends ModelePDFCommandes $texte .= $conf->global->COMMANDE_ADDON_PDF_ODT_PATH; $texte .= ''; $texte .= '
'; - $texte .= ''; + $texte .= ''; $texte .= '
'; // Scan directories @@ -176,7 +176,9 @@ class doc_generic_order_odt extends ModelePDFCommandes $texte .= '
'; // Show list of found files foreach ($listoffiles as $file) { - $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').'
'; + $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').''; + $texte .= '   '.img_picto('', 'delete').''; + $texte .= '
'; } $texte .= '
'; } diff --git a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php index 222286d5592..dad1ebc9122 100644 --- a/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php +++ b/htdocs/core/modules/contract/doc/doc_generic_contract_odt.modules.php @@ -51,8 +51,7 @@ class doc_generic_contract_odt extends ModelePDFContract public $phpmin = array(7, 0); /** - * Dolibarr version of the loaded document - * @var string + * @var string Dolibarr version of the loaded document */ public $version = 'dolibarr'; @@ -94,7 +93,7 @@ class doc_generic_contract_odt extends ModelePDFContract $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts - // Recupere emetteur + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined @@ -123,7 +122,7 @@ class doc_generic_contract_odt extends ModelePDFContract $texte .= ''; $texte .= ''; $texte .= ''; - $texte .= '
'; diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 7f198db6042..47671f4e7c3 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -44,7 +44,7 @@ create table llx_societe town varchar(50), -- town fk_departement integer DEFAULT 0, -- fk_pays integer DEFAULT 0, -- - fk_account integer DEFAULT 0, -- + fk_account integer DEFAULT 0, -- default bank account phone varchar(20), -- phone number fax varchar(20), -- fax number url varchar(255), -- From 88c45f50da1e0dca20a4a0aa710f0a376912c078 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Nov 2022 00:43:29 +0100 Subject: [PATCH 57/99] Fix warning --- htdocs/master.inc.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/master.inc.php b/htdocs/master.inc.php index 79f6f578e5f..03515c9a2e2 100644 --- a/htdocs/master.inc.php +++ b/htdocs/master.inc.php @@ -58,10 +58,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/conf.class.php'; $conf = new Conf(); // Set properties specific to database -$conf->db->host = $dolibarr_main_db_host; -$conf->db->port = $dolibarr_main_db_port; -$conf->db->name = $dolibarr_main_db_name; -$conf->db->user = $dolibarr_main_db_user; +$conf->db->host = empty($dolibarr_main_db_host) ? '' : $dolibarr_main_db_host; +$conf->db->port = empty($dolibarr_main_db_port) ? '' : $dolibarr_main_db_port; +$conf->db->name = empty($dolibarr_main_db_name) ? '' : $dolibarr_main_db_name; +$conf->db->user = empty($dolibarr_main_db_user) ? '' : $dolibarr_main_db_user; $conf->db->pass = empty($dolibarr_main_db_pass) ? '' : $dolibarr_main_db_pass; $conf->db->type = $dolibarr_main_db_type; $conf->db->prefix = $dolibarr_main_db_prefix; From af2df0e500c6881e461d48ac370f871a51dee7ff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Nov 2022 00:58:23 +0100 Subject: [PATCH 58/99] css --- htdocs/core/class/html.formsms.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formsms.class.php b/htdocs/core/class/html.formsms.class.php index 68b8410e647..f08640c6e55 100644 --- a/htdocs/core/class/html.formsms.class.php +++ b/htdocs/core/class/html.formsms.class.php @@ -285,7 +285,7 @@ function limitChars(textarea, limit, infodiv) print ''; } else { print ''; - print '
'.$langs->trans("SmsInfoCharRemain").': '.(160 - dol_strlen($defaultmessage)).'
'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").''; + if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) { + // Note: Default value for MAIN_MAIL_SMTPS_AUTH_TYPE if not defined is 'LOGIN' (but login/pass may be empty and they won't be provided in such a case) + print ' '; + print ''; + print '     '; + print ' '; + print ''; + } else { + $value = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE', 'LOGIN'); + $htmltext = $langs->trans("ContactSuperAdminForChange"); + print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1, 'superadmin'); + print ''; + } + print '
'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").''; - if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) { - print ' '; - print ''; - print '            '; - print ' '; - print ''; - } else { - $value = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE', 'LOGIN'); - $htmltext = $langs->trans("ContactSuperAdminForChange"); - print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1, 'superadmin'); - print ''; - } - print '
'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).''.(!empty($conf->global->MAIN_MAIL_SMTP_PORT) ? $conf->global->MAIN_MAIL_SMTP_PORT : '').'
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''.$conf->global->MAIN_MAIL_SMTPS_ID.'
'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").''.$text.'
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''.$conf->global->MAIN_MAIL_SMTPS_ID.'
'.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW).'
'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").''; + if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) { + // Note: Default value for MAIN_MAIL_SMTPS_AUTH_TYPE if not defined is 'LOGIN' (but login/pass may be empty and they won't be provided in such a case) + print ' '; + print ''; + print '            '; + print ' '; + print ''; + } else { + $value = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING', 'LOGIN'); + $htmltext = $langs->trans("ContactSuperAdminForChange"); + print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1, 'superadmin'); + print ''; + } + print '
'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").''; - if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) { - print ' '; - print ''; - print '            '; - print ' '; - print ''; - } else { - $value = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_EMAILING', 'LOGIN'); - $htmltext = $langs->trans("ContactSuperAdminForChange"); - print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1, 'superadmin'); - print ''; - } - print '
'.$langs->trans("MAIN_MAIL_SMTPS_OAUTH_SERVICE").''; @@ -546,11 +547,6 @@ if ($action == 'edit') { print '
'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).''.(!empty($conf->global->MAIN_MAIL_SMTP_PORT_EMAILING) ? $conf->global->MAIN_MAIL_SMTP_PORT_EMAILING : '').'
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''.getDolGlobalString('MAIN_MAIL_SMTPS_ID_EMAILING').'
'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").''.$text.'
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''.getDolGlobalString('MAIN_MAIL_SMTPS_ID_EMAILING').'
'.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./', '*', getDolGlobalString('MAIN_MAIL_SMTPS_PW_EMAILING')).'
'; + print '
'; print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); print ''; - print $langs->trans("SeeLocalSendMailSetup"); + print ''.$langs->trans("SeeLocalSendMailSetup").''; + print ''; $mainserver = (!empty($conf->global->MAIN_MAIL_SMTP_SERVER_TICKET) ? $conf->global->MAIN_MAIL_SMTP_SERVER_TICKET : ''); $smtpserver = ini_get('SMTP') ?ini_get('SMTP') : $langs->transnoentities("Undefined"); if ($linuxlike) { @@ -333,17 +341,18 @@ if ($action == 'edit') { print ''; // SuperAdministrator access only if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) { - print ''; + print ''; print ''; - print ''.$langs->trans("SeeLocalSendMailSetup").''; + print ''.$langs->trans("SeeLocalSendMailSetup").''; } else { $text = !empty($mainserver) ? $mainserver : $smtpserver; $htmltext = $langs->trans("ContactSuperAdminForChange"); print $form->textwithpicto($text, $htmltext, 1, 'superadmin'); print ''; } + print '
'; - print $langs->trans("SeeLocalSendMailSetup"); + print ''.$langs->trans("SeeLocalSendMailSetup").''; } else { $mainport = (!empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : ''); $smtpport = ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined"); @@ -365,7 +374,7 @@ if ($action == 'edit') { if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) { print ''; print ''; - print ''.$langs->trans("SeeLocalSendMailSetup").''; + print ''.$langs->trans("SeeLocalSendMailSetup").''; } else { $text = (!empty($mainport) ? $mainport : $smtpport); $htmltext = $langs->trans("ContactSuperAdminForChange"); @@ -375,6 +384,25 @@ if ($action == 'edit') { } print '
'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").''; + if (!isModEnabled('multicompany') || ($user->admin && !$user->entity)) { + // Note: Default value for MAIN_MAIL_SMTPS_AUTH_TYPE if not defined is 'LOGIN' (but login/pass may be empty and they won't be provided in such a case) + print ' '; + print ''; + print '            '; + print ' '; + print ''; + } else { + $value = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET', 'LOGIN'); + $htmltext = $langs->trans("ContactSuperAdminForChange"); + print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1, 'superadmin'); + print ''; + } + print '
'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").''; - if (empty($conf->multicompany->enabled) || ($user->admin && !$user->entity)) { - print ' '; - print ''; - print '            '; - print ' '; - print ''; - } else { - $value = getDolGlobalString('MAIN_MAIL_SMTPS_AUTH_TYPE_TICKET', 'LOGIN'); - $htmltext = $langs->trans("ContactSuperAdminForChange"); - print $form->textwithpicto($langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE"), $htmltext, 1, 'superadmin'); - print ''; - } - print '
'.$langs->trans("MAIN_MAIL_SMTP_PORT", ini_get('smtp_port') ?ini_get('smtp_port') : $langs->transnoentities("Undefined")).''.(!empty($conf->global->MAIN_MAIL_SMTP_PORT_TICKET) ? $conf->global->MAIN_MAIL_SMTP_PORT_TICKET : '').'
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''.$conf->global->MAIN_MAIL_SMTPS_ID_TICKET.'
'.$langs->trans("MAIN_MAIL_SMTPS_AUTH_TYPE").''.$text.'
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''.$conf->global->MAIN_MAIL_SMTPS_ID_TICKET.'
'.$langs->trans("MAIN_MAIL_SMTPS_PW").''.preg_replace('/./', '*', $conf->global->MAIN_MAIL_SMTPS_PW_TICKET).'
'; + $texte .= '
'; // List of directories area $texte .= ''; - // Add input to upload a new template file. $texte .= '
'.$langs->trans("UploadNewTemplate"); $maxfilesizearray = getMaxFileSizeArray(); @@ -195,6 +193,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $texte .= ''; $texte .= ''; $texte .= '
'; + $texte .= ''; $texte .= ''; print ''; print ''."\n"; @@ -469,6 +469,11 @@ if ($result) { } */ + $isexpanded = ($updatedmodulename == $obj->module || $module == "allmodules"); + if (!$action) { + $isexpanded = 1; // By default (no action done) we have lines expanded + } + // Break found, it's a new module to catch if (isset($obj->module) && ($oldmod <> $obj->module)) { $oldmod = $obj->module; @@ -485,24 +490,24 @@ if ($result) { print ''; if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->admin)) { if ($caneditperms) { - print ''; - print ''; + print ''; } else { print ''; } print ''; } else { if ($caneditperms) { - print ''; - print ''; + print ''; } else { print ''; } @@ -510,11 +515,11 @@ if ($result) { } print ''; - print ''; //Add picto + / - when open en closed @@ -522,7 +527,7 @@ if ($result) { } print ''."\n"; - print 'module && $module != "allmodules" ? ' style="display:none"' : '').'>'; + print ''; // Picto and label of module print '
'; @@ -161,10 +160,25 @@ class doc_generic_contract_odt extends ModelePDFContract $texte .= '
'; // Scan directories - if (count($listofdir)) { - $texte .= $langs->trans("NumberOfModelFilesFound").': '.count($listoffiles).''; + $nbofiles = count($listoffiles); + if (!empty($conf->global->CONTRACT_ADDON_PDF_ODT_PATH)) { + $texte .= $langs->trans("NumberOfModelFilesFound").': '; + //$texte.=$nbofiles?'':''; + $texte .= count($listoffiles); + //$texte.=$nbofiles?'':''; + $texte .= ''; } + if ($nbofiles) { + $texte .= '
'; + // Show list of found files + foreach ($listoffiles as $file) { + $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').''; + $texte .= '   '.img_picto('', 'delete').''; + $texte .= '
'; + } + $texte .= '
'; + } // Add input to upload a new template file. $texte .= '
'.$langs->trans("UploadNewTemplate"); $maxfilesizearray = getMaxFileSizeArray(); @@ -228,7 +242,7 @@ class doc_generic_contract_odt extends ModelePDFContract $sav_charset_output = $outputlangs->charset_output; $outputlangs->charset_output = 'UTF-8'; - // Load traductions files required by page + // Load translation files required by page $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); if ($conf->contrat->multidir_output[$object->entity]) { @@ -382,16 +396,21 @@ class doc_generic_contract_odt extends ModelePDFContract dol_syslog($e->getMessage(), LOG_INFO); } + // Call the ODTSubstitution hook + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); + $reshook = $hookmanager->executeHooks('ODTSubstitution', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + foreach ($tmparray as $key => $value) { try { - if (preg_match('/logo$/', $key)) { // Image + if (preg_match('/logo$/', $key)) { + // Image if (file_exists($value)) { $odfHandler->setImage($key, $value); } else { $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); } - } else // Text - { + } else { + // Text $odfHandler->setVars($key, $value, true, 'UTF-8'); } } catch (OdfException $e) { @@ -448,7 +467,7 @@ class doc_generic_contract_odt extends ModelePDFContract } // Call the beforeODTSave hook - $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs); + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('beforeODTSave', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks // Write new file @@ -457,6 +476,7 @@ class doc_generic_contract_odt extends ModelePDFContract $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { $this->error = $e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); return -1; } } else { @@ -464,10 +484,12 @@ class doc_generic_contract_odt extends ModelePDFContract $odfHandler->saveToDisk($file); } catch (Exception $e) { $this->error = $e->getMessage(); + dol_syslog($e->getMessage(), LOG_INFO); return -1; } } + $parameters = array('odfHandler'=>&$odfHandler, 'file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs, 'substitutionarray'=>&$tmparray); $reshook = $hookmanager->executeHooks('afterODTCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if (!empty($conf->global->MAIN_UMASK)) { diff --git a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php index cfb23269ca9..73793c5a757 100644 --- a/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php +++ b/htdocs/core/modules/expedition/doc/doc_generic_shipment_odt.modules.php @@ -175,7 +175,9 @@ class doc_generic_shipment_odt extends ModelePdfExpedition $texte .= '
'; // Show list of found files foreach ($listoffiles as $file) { - $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').'
'; + $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').''; + $texte .= '   '.img_picto('', 'delete').''; + $texte .= '
'; } $texte .= '
'; } diff --git a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php index 061f18e5442..0b8fa2d4621 100644 --- a/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php +++ b/htdocs/core/modules/facture/doc/doc_generic_invoice_odt.modules.php @@ -174,7 +174,9 @@ class doc_generic_invoice_odt extends ModelePDFFactures $texte .= '
'; // Show list of found files foreach ($listoffiles as $file) { - $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').'
'; + $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').''; + $texte .= '   '.img_picto('', 'delete').''; + $texte .= '
'; } $texte .= '
'; } diff --git a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php index 2ab951147b9..ed48c93c4de 100644 --- a/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php +++ b/htdocs/core/modules/member/doc/doc_generic_member_odt.class.php @@ -164,7 +164,9 @@ class doc_generic_member_odt extends ModelePDFMember $texte .= '
'; // Show list of found files foreach ($listoffiles as $file) { - $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').'
'; + $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').''; + $texte .= '   '.img_picto('', 'delete').''; + $texte .= '
'; } $texte .= '
'; } diff --git a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php index 42b3c529fe4..b89c4eab2cd 100644 --- a/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php +++ b/htdocs/core/modules/mrp/doc/doc_generic_mo_odt.modules.php @@ -175,7 +175,9 @@ class doc_generic_mo_odt extends ModelePDFMo $texte .= '
'; // Show list of found files foreach ($listoffiles as $file) { - $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').'
'; + $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').''; + $texte .= '   '.img_picto('', 'delete').''; + $texte .= '
'; } $texte .= '
'; } diff --git a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php index 4e8be5f6389..2015da21f61 100644 --- a/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php +++ b/htdocs/core/modules/project/doc/doc_generic_project_odt.modules.php @@ -468,7 +468,9 @@ class doc_generic_project_odt extends ModelePDFProjects $texte .= '
'; // Show list of found files foreach ($listoffiles as $file) { - $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').'
'; + $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').''; + $texte .= '   '.img_picto('', 'delete').''; + $texte .= '
'; } $texte .= '
'; } diff --git a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php index ba386eedfe7..a7f3eab4a30 100644 --- a/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php +++ b/htdocs/core/modules/project/task/doc/doc_generic_task_odt.modules.php @@ -433,7 +433,9 @@ class doc_generic_task_odt extends ModelePDFTask $texte .= '
'; // Show list of found files foreach ($listoffiles as $file) { - $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').'
'; + $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').''; + $texte .= '   '.img_picto('', 'delete').''; + $texte .= '
'; } $texte .= '
'; } diff --git a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php index 4d8edca7f64..4ebc742b4bb 100644 --- a/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php +++ b/htdocs/core/modules/reception/doc/doc_generic_reception_odt.modules.php @@ -168,7 +168,9 @@ class doc_generic_reception_odt extends ModelePdfReception $texte .= '
'; // Show list of found files foreach ($listoffiles as $file) { - $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').'
'; + $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').''; + $texte .= '   '.img_picto('', 'delete').''; + $texte .= '
'; } $texte .= '
'; } diff --git a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php index 0f5adc3fc7d..eb6ba838d7a 100644 --- a/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php +++ b/htdocs/core/modules/stock/doc/doc_generic_stock_odt.modules.php @@ -172,7 +172,9 @@ class doc_generic_stock_odt extends ModelePDFStock $texte .= '
'; // Show list of found files foreach ($listoffiles as $file) { - $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').'
'; + $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').''; + $texte .= '   '.img_picto('', 'delete').''; + $texte .= '
'; } $texte .= '
'; } diff --git a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php index f3177233589..12bbcc12edc 100644 --- a/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php +++ b/htdocs/core/modules/supplier_order/doc/doc_generic_supplier_order_odt.modules.php @@ -163,7 +163,7 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders // Scan directories $nbofiles = count($listoffiles); - if (!empty($conf->global->COMMANDE_ADDON_PDF_ODT_PATH)) { + if (!empty($conf->global->SUPPLIER_ORDER_ADDON_PDF_ODT_PATH)) { $texte .= $langs->trans("NumberOfModelFilesFound").': '; //$texte.=$nbofiles?'':''; $texte .= count($listoffiles); @@ -175,7 +175,9 @@ class doc_generic_supplier_order_odt extends ModelePDFSuppliersOrders $texte .= ''; } diff --git a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php index fc75445123a..55a7710c5a4 100644 --- a/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php +++ b/htdocs/core/modules/supplier_proposal/doc/doc_generic_supplier_proposal_odt.modules.php @@ -179,7 +179,9 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal $texte .= '
'; // Show list of found files foreach ($listoffiles as $file) { - $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').'
'; + $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').''; + $texte .= '   '.img_picto('', 'delete').''; + $texte .= '
'; } $texte .= '
'; diff --git a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php index ff6359be5ce..1a2d1e537cc 100644 --- a/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php +++ b/htdocs/core/modules/ticket/doc/doc_generic_ticket_odt.modules.php @@ -161,7 +161,9 @@ class doc_generic_ticket_odt extends ModelePDFTicket $texte .= '
'; // Show list of found files foreach ($listoffiles as $file) { - $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').'
'; + $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').''; + $texte .= '   '.img_picto('', 'delete').''; + $texte .= '
'; } $texte .= '
'; } diff --git a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php index d129c80f126..1c3e346203b 100644 --- a/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php +++ b/htdocs/core/modules/user/doc/doc_generic_user_odt.modules.php @@ -192,7 +192,9 @@ class doc_generic_user_odt extends ModelePDFUser $texte .= '
'; // Show list of found files foreach ($listoffiles as $file) { - $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').'
'; + $texte .= '- '.$file['name'].' '.img_picto('', 'listlight').''; + $texte .= '   '.img_picto('', 'delete').''; + $texte .= '
'; } $texte .= '
'; } diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php index 46967d6e4fa..b7dfc374a52 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/doc_generic_myobject_odt.modules.php @@ -119,7 +119,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $form = new Form($this->db); $texte = $this->description.".
\n"; - $texte .= ''; + $texte .= ''; $texte .= ''; $texte .= ''; $texte .= ''; @@ -158,7 +158,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $texte .= $conf->global->MYMODULE_MYOBJECT_ADDON_PDF_ODT_PATH; $texte .= ''; $texte .= '
'; - $texte .= ''; + $texte .= ''; $texte .= '
'; // Scan directories @@ -172,18 +172,16 @@ class doc_generic_myobject_odt extends ModelePDFMyObject } if ($nbofiles) { - $texte .= '
'; @@ -282,8 +281,10 @@ class doc_generic_myobject_odt extends ModelePDFMyObject $newfiletmp = preg_replace('/\.od(t|s)/i', '', $newfile); $newfiletmp = preg_replace('/template_/i', '', $newfiletmp); $newfiletmp = preg_replace('/modele_/i', '', $newfiletmp); + $newfiletmp = $objectref . '_' . $newfiletmp; //$file=$dir.'/'.$newfiletmp.'.'.dol_print_date(dol_now(),'%Y%m%d%H%M%S').'.odt'; + // Get extension (ods or odt) $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { @@ -308,7 +309,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject return -1; } - // If CUSTOMER contact defined on order, we use it + // If CUSTOMER contact defined on object, we use it $usecontact = false; $arrayidcontact = $object->getIdContact('external', 'CUSTOMER'); if (count($arrayidcontact) > 0) { @@ -348,7 +349,7 @@ class doc_generic_myobject_odt extends ModelePDFMyObject // Line of free text $newfreetext = ''; - $paramfreetext = 'ORDER_FREE_TEXT'; + $paramfreetext = 'MYMODULE_MYOBJECT_FREE_TEXT'; if (!empty($conf->global->$paramfreetext)) { $newfreetext = make_substitutions($conf->global->$paramfreetext, $substitutionarray); } From fe6e8a5ec18273d75e02293b844bf8cebedacac3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 18 Nov 2022 15:25:11 +0100 Subject: [PATCH 63/99] Fix perms --- htdocs/user/perms.php | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/htdocs/user/perms.php b/htdocs/user/perms.php index 8f7d152e73a..1ededd091b3 100644 --- a/htdocs/user/perms.php +++ b/htdocs/user/perms.php @@ -331,9 +331,9 @@ if (($caneditperms && empty($objMod->rights_admin_allowed)) || empty($object->ad print ''.$langs->trans("Permissions").''; -print ''.img_picto('', 'folder-open', 'class="paddingright"').''.$langs->trans("ExpandAll").''; +print ''.img_picto('', 'folder-open', 'class="paddingright"').''.$langs->trans("ExpandAll").''; print ' | '; -print ''.img_picto('', 'folder', 'class="paddingright"').''.$langs->trans("UndoExpandAll").''; +print ''.img_picto('', 'folder', 'class="paddingright"').''.$langs->trans("UndoExpandAll").''; print '
module && $module != "allmodules" ? ' style="display:none"' : '').'>'; + print 'module || $module == "allmodules" ? ' style="display:none"' : '').'>   module && $module != "allmodules" ? ' style="display:none"' : '').'>'; + print 'module || $module == "allmodules" ? ' style="display:none"' : '').'>  '; - print '
'; + print '
'; + print ''; - print '
'; $htmlhelp = $langs->trans("Example").' :
'; - $htmlhelp .= dol_htmlentitiesbr($manifestjsoncontentdefault); + $htmlhelp .= ''.dol_htmlentitiesbr($manifestjsoncontentdefault).''; print $form->textwithpicto($langs->trans('WEBSITE_MANIFEST_JSON'), $htmlhelp, 1, 'help', '', 0, 2, 'manifestjsontooltip'); print '
'; print $langs->trans("UseManifest").': '.$form->selectyesno('use_manifest', $website->use_manifest, 1).'
'; From c2d0f970637ab0ee1e22396f3406a8a239d14315 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 20 Nov 2022 15:13:40 +0100 Subject: [PATCH 92/99] Website --- .../containers/javascript.js.php | 1 + .../containers/page250.tpl.php | 60 ------------------- .../website_pages.sql | 14 ++--- 3 files changed, 8 insertions(+), 67 deletions(-) diff --git a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/javascript.js.php b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/javascript.js.php index f58102cf00b..fe1f15266af 100644 --- a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/javascript.js.php +++ b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/javascript.js.php @@ -8,6 +8,7 @@ header('Cache-Control: max-age=3600, public, must-revalidate'); header('Content-type: application/javascript'); // END PHP ?> /* JS content (all pages) */ +// test diff --git a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page250.tpl.php b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page250.tpl.php index 8e050354705..ed509115c54 100644 --- a/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page250.tpl.php +++ b/htdocs/install/doctemplates/websites/website_template-restaurant/containers/page250.tpl.php @@ -113,28 +113,6 @@ ob_start(); >26.50 - -
-
- - - - - -
-
@@ -159,28 +137,6 @@ ob_start(); >18.25 - -
-
- - - - - -
-
@@ -217,22 +173,6 @@ ob_start(); -
- -
-
diff --git a/htdocs/install/doctemplates/websites/website_template-restaurant/website_pages.sql b/htdocs/install/doctemplates/websites/website_template-restaurant/website_pages.sql index 9455db927b2..f088e50d33e 100644 --- a/htdocs/install/doctemplates/websites/website_template-restaurant/website_pages.sql +++ b/htdocs/install/doctemplates/websites/website_template-restaurant/website_pages.sql @@ -1,20 +1,20 @@ --- File generated by Dolibarr 17.0.0-beta -- 2022-11-20 13:58:04 UTC --; +-- File generated by Dolibarr 17.0.0-beta -- 2022-11-20 14:10:56 UTC --; -- Page ID 248 -> 1__+MAX_llx_website_page__ - Aliases about --; INSERT INTO llx_website_page(rowid, fk_page, fk_website, pageurl, aliasalt, title, description, lang, image, keywords, status, date_creation, tms, import_key, grabbed_from, type_container, htmlheader, content, author_alias, allowed_in_frames) VALUES(1__+MAX_llx_website_page__, null, __WEBSITE_ID__, 'about', '', 'About us', '', '', '', '', '1', '2022-08-09 16:40:13', '2022-11-20 14:15:19', null, '', 'page', '', '__N____N____N__
__N__
__N____N__
__N__
__N__
__N____N__
__N__

About Us

__N____N__ Get to know us more__N__
__N____N__
__N__
__N____N__
__N__
__N____N__
__N__
__N__
__N____N__
__N__

Team Members

__N__
__N____N__
__N__
__N__ \"\"__N__ __N__
__N__

Sophia

__N____N__

CEO & Founder

__N__
__N__
__N__
__N____N__
__N__
__N__ \"\"__N____N__

Benjamin W.

__N____N__

Restaurant Manager

__N__
__N__
__N____N__
__N__
__N__ \"\"__N__ __N__

Muchen Jack

__N____N__

Senior Chef

__N__
__N__
__N____N__
__N__
__N__
__N__ __N__
__N____N__
__N____N____N____N____N__', '', 0); --- File generated by Dolibarr 17.0.0-beta -- 2022-11-20 13:58:04 UTC --; +-- File generated by Dolibarr 17.0.0-beta -- 2022-11-20 14:10:56 UTC --; -- Page ID 249 -> 2__+MAX_llx_website_page__ - Aliases contact --; INSERT INTO llx_website_page(rowid, fk_page, fk_website, pageurl, aliasalt, title, description, lang, image, keywords, status, date_creation, tms, import_key, grabbed_from, type_container, htmlheader, content, author_alias, allowed_in_frames) VALUES(2__+MAX_llx_website_page__, null, __WEBSITE_ID__, 'contact', '', 'Contact us', '', '', '', '', '1', '2022-08-16 14:40:51', '2022-11-20 14:50:10', null, '', 'page', '', '__N__email;__N__ $message = GETPOST(\'message\', \'alpha\');__N__ $cmail = new CMailFile(\'Contact from website\', $to, $from, $message);__N__ if ($cmail->sendfile()) {__N__ ?>__N__ __N__ trans(\"ErrorFailedToSendMail\", $from, $to).\'. \'.$cmail->error;__N__ }__N__}__N__?>__N____N____N____N____N__
__N__
__N__
__N__
__N__
__N__
__N__

Say Hi

__N____N__ We are happy to get in touch with you__N__
__N__
__N__
__N____N__
__N__
__N____N__
__N__ __N__
__N__
__N__
__N__
__N__

Leave a message

__N__
__N____N__
__N__ __N__ __N__ \">__N__ __N__
__N__
__N____N__
__N__ trans(\"Phone\"); ?>__N____N__ __N__
__N____N__
__N__ trans(\"Email\"); ?>__N____N__ __N____N__ trans(\"Message\"); ?>__N____N__ __N__
__N____N__
__N__ __N__
__N__ __N__
__N____N__
__N__
Weekdays
__N____N__
__N__ $day : \" .getDolGlobalString(\"MAIN_INFO_OPENINGHOURS_$day\") .\"

\"; __N__ }__N__ ?>__N__
__N____N__
Weekends
__N____N__
__N__

Saturday and Sunday

__N____N__

to be determined !

__N__
__N__
__N____N__
__N__

__N__ __N__

__N__ getFullAddress() ?>__N__

__N____N__ __N__
__N__
__N__ __N__
__N__
__N__
__N__
__N__
__N__
__N____N____N__ __N__ __N__ __N__
__N__
__N__
__N__

Reserve a table

__N____N__ __N__
__N____N__ __N__
__N__ __N__ \" />__N__ __N__
__N__
__N____N__
__N__
__N____N__
__N__
__N____N__
__N__
__N____N__
__N__
__N____N__
__N__
__N____N__
__N__
__N____N__
__N__ __N__
__N__ __N__
__N__
__N____N__
__N__
__N__ __N__ __N____N__
__N____N____N____N____N__', '', 0); --- File generated by Dolibarr 17.0.0-beta -- 2022-11-20 13:58:04 UTC --; +-- File generated by Dolibarr 17.0.0-beta -- 2022-11-20 14:10:56 UTC --; -- Page ID 252 -> 3__+MAX_llx_website_page__ - Aliases footer --; INSERT INTO llx_website_page(rowid, fk_page, fk_website, pageurl, aliasalt, title, description, lang, image, keywords, status, date_creation, tms, import_key, grabbed_from, type_container, htmlheader, content, author_alias, allowed_in_frames) VALUES(3__+MAX_llx_website_page__, null, __WEBSITE_ID__, 'footer', '', 'Footer', '', '', '', '', '1', '2022-11-20 12:51:50', '2022-11-20 14:07:39', null, '', 'other', '', '__N__
__N__ __N__ __N__
__N__', '', 0); --- File generated by Dolibarr 17.0.0-beta -- 2022-11-20 13:58:04 UTC --; +-- File generated by Dolibarr 17.0.0-beta -- 2022-11-20 14:10:56 UTC --; -- Page ID 253 -> 4__+MAX_llx_website_page__ - Aliases header --; INSERT INTO llx_website_page(rowid, fk_page, fk_website, pageurl, aliasalt, title, description, lang, image, keywords, status, date_creation, tms, import_key, grabbed_from, type_container, htmlheader, content, author_alias, allowed_in_frames) VALUES(4__+MAX_llx_website_page__, null, __WEBSITE_ID__, 'header', '', 'Header', '', '', '', '', '1', '2022-11-20 13:12:33', '2022-11-20 14:21:25', null, '', 'menu', '', '
__N__ __N__
__N____N__', '', 0); --- File generated by Dolibarr 17.0.0-beta -- 2022-11-20 13:58:04 UTC --; +-- File generated by Dolibarr 17.0.0-beta -- 2022-11-20 14:10:56 UTC --; -- Page ID 250 -> 5__+MAX_llx_website_page__ - Aliases index --; -INSERT INTO llx_website_page(rowid, fk_page, fk_website, pageurl, aliasalt, title, description, lang, image, keywords, status, date_creation, tms, import_key, grabbed_from, type_container, htmlheader, content, author_alias, allowed_in_frames) VALUES(5__+MAX_llx_website_page__, null, __WEBSITE_ID__, 'index', '', 'index', '', '', '', '', '1', '2022-08-09 16:34:54', '2022-11-20 14:27:21', null, '', 'page', '', '__N____N____N____N____N__
__N__
__N__
__N__
__N__
__N__
__N__
__N__

__N__ Delicious Steaks__N__

__N____N__
__N__ __N__
__N__ __N__ __N__ __N__ __N__ __N__
__N__
__N__
__N__
__N__
__N____N__
__N__ __N__
__N__
__N__
__N__ __N__
__N____N__
__N__

__N__ Fine Dining Restaurant__N__

__N__
__N__
__N____N__
__N__
__N__ __N__
__N____N__
__N__ __N__

Steak

__N____N__ 26.50__N__
__N____N__ __N__
__N__ __N__ __N__ __N__ __N__ __N__
__N__
__N__
__N__
__N____N__
__N__
__N__ __N__
__N____N__
__N__ __N__

__N__ Sausage Pasta__N__

__N____N__ 18.25__N__
__N____N__ __N__
__N__ __N__ __N__ __N__ __N__ __N__
__N__
__N__
__N__ __N__ __N____N__ __N__ __N__ Previous__N__ __N____N__ __N__ __N__ Next__N__ __N__ __N__ __N__ __N__ __N____N__
__N__ __N__ __N__ Your browser does not support the video tag.__N__ __N__
__N____N__
__N__
__N____N__
__N__
__N__
__N__
__N__

__N__ Special Menus__N__

__N__
__N____N__
__N__
__N__
__N__ __N____N__ Breakfast__N__
__N____N__ __N__

Morning Fresh

__N____N__ 12.50__N____N__ __N__
__N__ __N__ __N__ __N__ __N__ __N__
__N__
__N__
__N__
__N__
__N____N__
__N__
__N__
__N__ __N____N__ Lunch__N__
__N____N__ __N__

DoliCloud Soup

__N____N__ 24.50__N____N__ __N__
__N__ __N__ __N__ __N__ __N__ __N__
__N__
__N__
__N__ __N__ __N____N__
__N__
__N__
__N__ __N____N__ Dinner__N__
__N____N__ __N__

Premium Steak

__N____N__ 45__N____N__ __N__
__N__ __N__ __N__ __N__ __N__ __N__
__N__
__N__
__N__ __N__ __N____N__
__N__
__N__
__N__ __N____N__ Dinner__N__
__N____N__ __N__

Seafood Set

__N____N__ 86__N____N__ __N__
__N__ __N__ __N__ __N__ __N__ __N__
__N__
__N__
__N__ __N__ __N____N__
__N__
__N__
__N__ __N____N__ Breakfast__N__
__N____N__ __N__

Burger Set

__N____N__ 20.50__N____N__ __N__
__N__ __N__ __N__ __N__ __N__ __N__
__N__
__N__
__N__ __N__ __N____N__
__N__
__N__
__N__ __N____N__ Lunch__N__
__N____N__ __N__

Healthy Soup

__N____N__ 34.20__N____N__ __N__
__N__ __N__ __N__ __N__ __N__ __N__
__N__
__N__
__N__ __N__ __N__ __N__ __N__
__N__
__N____N__
__N____N____N____N__', '', 0); +INSERT INTO llx_website_page(rowid, fk_page, fk_website, pageurl, aliasalt, title, description, lang, image, keywords, status, date_creation, tms, import_key, grabbed_from, type_container, htmlheader, content, author_alias, allowed_in_frames) VALUES(5__+MAX_llx_website_page__, null, __WEBSITE_ID__, 'index', '', 'index', '', '', '', '', '1', '2022-08-09 16:34:54', '2022-11-20 15:10:45', null, '', 'page', '', '__N____N____N____N____N__
__N__
__N__
__N__
__N__
__N__
__N__
__N__

__N__ Delicious Steaks__N__

__N____N__
__N__ __N__
__N__ __N__ __N__ __N__ __N__ __N__
__N__
__N__
__N__
__N__
__N____N__
__N__ __N__
__N__
__N__
__N__ __N__
__N____N__
__N__

__N__ Fine Dining Restaurant__N__

__N__
__N__
__N____N__
__N__
__N__ __N__
__N____N__
__N__ __N__

Steak

__N____N__ 26.50__N__
__N__
__N__
__N____N__
__N__
__N__ __N__
__N____N__
__N__ __N__

__N__ Sausage Pasta__N__

__N____N__ 18.25__N__
__N__
__N__
__N__
__N____N__ __N__ __N__ Previous__N__ __N____N__ __N__ __N__ Next__N__ __N__ __N__ __N__ __N__ __N____N__
__N__
__N____N__
__N__
__N__
__N__
__N__

__N__ Special Menus__N__

__N__
__N____N__
__N__
__N__
__N__ __N____N__ Breakfast__N__
__N____N__ __N__

Morning Fresh

__N____N__ 12.50__N____N__ __N__
__N__ __N__ __N__ __N__ __N__ __N__
__N__
__N__
__N__
__N__
__N____N__
__N__
__N__
__N__ __N____N__ Lunch__N__
__N____N__ __N__

DoliCloud Soup

__N____N__ 24.50__N____N__ __N__
__N__ __N__ __N__ __N__ __N__ __N__
__N__
__N__
__N__ __N__ __N____N__
__N__
__N__
__N__ __N____N__ Dinner__N__
__N____N__ __N__

Premium Steak

__N____N__ 45__N____N__ __N__
__N__ __N__ __N__ __N__ __N__ __N__
__N__
__N__
__N__ __N__ __N____N__
__N__
__N__
__N__ __N____N__ Dinner__N__
__N____N__ __N__

Seafood Set

__N____N__ 86__N____N__ __N__
__N__ __N__ __N__ __N__ __N__ __N__
__N__
__N__
__N__ __N__ __N____N__
__N__
__N__
__N__ __N____N__ Breakfast__N__
__N____N__ __N__

Burger Set

__N____N__ 20.50__N____N__ __N__
__N__ __N__ __N__ __N__ __N__ __N__
__N__
__N__
__N__ __N__ __N____N__
__N__
__N__
__N__ __N____N__ Lunch__N__
__N____N__ __N__

Healthy Soup

__N____N__ 34.20__N____N__ __N__
__N__ __N__ __N__ __N__ __N__ __N__
__N__
__N__
__N__ __N__ __N__ __N__ __N__
__N__
__N____N__
__N____N____N____N__', '', 0); UPDATE llx_website SET fk_default_home = 5__+MAX_llx_website_page__ WHERE rowid = __WEBSITE_ID__; --- File generated by Dolibarr 17.0.0-beta -- 2022-11-20 13:58:04 UTC --; +-- File generated by Dolibarr 17.0.0-beta -- 2022-11-20 14:10:56 UTC --; -- Page ID 251 -> 6__+MAX_llx_website_page__ - Aliases menu --; INSERT INTO llx_website_page(rowid, fk_page, fk_website, pageurl, aliasalt, title, description, lang, image, keywords, status, date_creation, tms, import_key, grabbed_from, type_container, htmlheader, content, author_alias, allowed_in_frames) VALUES(6__+MAX_llx_website_page__, null, __WEBSITE_ID__, 'menu', '', 'Our menus', '', '', '', '', '1', '2022-08-16 14:37:03', '2022-11-20 14:30:03', null, '', 'page', '', '__N____N____N____N____N__
__N__
__N__
__N__
__N__
__N__
__N__

Our Menus

__N____N__ Perfect for all Breakfast, Lunch and__N__ Dinner__N__
__N__
__N__
__N____N__
__N__
__N____N__
__N__
__N__
__N__
__N__

Breakfast Menu

__N__
__N____N__
__N__
__N__ __N____N__ __N__

Fresh Start

__N____N__ $24.50__N__
__N__
__N__
__N____N__
__N__
__N__ __N____N__ __N__

Baked Creamy

__N____N__ $16.50__N__
__N__
__N__
__N____N__
__N__
__N__ __N____N__ __N__

Burger Set

__N____N__ $24.50__N____N__ $36.50__N__
__N__
__N__ __N__ __N__ __N__
__N____N__
__N__
__N__
__N__
__N__

Lunch Menu

__N__
__N____N__
__N__
__N__ __N____N__ __N__

Super Steak Set

__N____N__ $32.75__N____N__ $55__N__
__N__
__N__
__N____N__
__N__
__N__ __N____N__ __N__

Bread & Steak Set

__N____N__ $42.50__N__
__N__
__N__
__N__ __N__ __N__
__N____N__
__N__
__N__
__N__
__N__

Dinner Menu

__N__
__N____N__
__N__
__N__ __N____N__ __N__

Seafood Set

__N____N__ $65.50__N__
__N__
__N__
__N____N__
__N__
__N__ __N____N__ __N__

Premium Steak

__N____N__ $74.25__N__
__N__
__N__
__N____N__
__N__
__N__ __N____N__ __N__

Salmon Set

__N____N__ $60__N__
__N__
__N__ __N__ __N__ __N__
__N__
__N____N__
__N____N____N____N__', '', 0); From c5459a47eb2a15abb94bca56cc7fa0339ab2cf4d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 20 Nov 2022 16:08:32 +0100 Subject: [PATCH 93/99] Enhance default WEBSITE_MAIN_SECURITY_FORCECSP --- htdocs/admin/system/security.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 1ea81cd5dd3..309d5c5db1a 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -548,7 +548,7 @@ print '
'; print 'MAIN_SECURITY_FORCERP = '.(empty($conf->global->MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCERP).'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"same-origin\")
"; print '
'; -print 'WEBSITE_MAIN_SECURITY_FORCECSP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCECSP).'   ('.$langs->trans("Example").": \"default-src 'self'; style-src: https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src: https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src: *;\")
"; +print 'WEBSITE_MAIN_SECURITY_FORCECSP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCECSP).'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; style-src https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src: *;\")
"; print '
'; print 'WEBSITE_MAIN_SECURITY_FORCERP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCERP).'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"strict-origin-when-cross-origin\")
"; From e5a4824ed2bf8af0b3b900b64cd72d9eb034d8fc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 20 Nov 2022 16:11:04 +0100 Subject: [PATCH 94/99] Enhance default WEBSITE_MAIN_SECURITY_FORCECSP --- htdocs/admin/system/security.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 309d5c5db1a..309e6ea3ff1 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -548,7 +548,7 @@ print '
'; print 'MAIN_SECURITY_FORCERP = '.(empty($conf->global->MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCERP).'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"same-origin\")
"; print '
'; -print 'WEBSITE_MAIN_SECURITY_FORCECSP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCECSP).'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; style-src https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src: *;\")
"; +print 'WEBSITE_MAIN_SECURITY_FORCECSP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCECSP).'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; style-src https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src *;\")
"; print '
'; print 'WEBSITE_MAIN_SECURITY_FORCERP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCERP).'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"strict-origin-when-cross-origin\")
"; From 3041edc013fe8de296e657bc96b30712cbf0371a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 20 Nov 2022 21:54:19 +0100 Subject: [PATCH 95/99] Debug --- htdocs/admin/system/security.php | 4 ++-- htdocs/main.inc.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 309e6ea3ff1..25b30fd42f6 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -542,10 +542,10 @@ print '
'; print 'MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL = '.(empty($conf->global->MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL) ? ''.$langs->trans("Undefined").'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or").' 0)' : $conf->global->MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL)."
"; print '
'; -print 'MAIN_SECURITY_FORCECSP = '.(empty($conf->global->MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCECSP).'   ('.$langs->trans("Example").": \"default-src 'self'; img-src *;\")
"; +print 'MAIN_SECURITY_FORCECSP = '.(empty($conf->global->MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCECSP).'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; img-src *;\")
"; print '
'; -print 'MAIN_SECURITY_FORCERP = '.(empty($conf->global->MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCERP).'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"same-origin\")
"; +print 'MAIN_SECURITY_FORCERP = '.(empty($conf->global->MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCERP).'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"same-origin\" so borwser doesn't send any referrer when going into another web site domain)
"; print '
'; print 'WEBSITE_MAIN_SECURITY_FORCECSP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCECSP).'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; style-src https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src *;\")
"; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 32d442008eb..513d9c12fdb 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1484,7 +1484,7 @@ function top_httphead($contenttype = 'text/html', $forcenocache = 0) // Referrer-Policy // Say if we must provide the referrer when we jump onto another web page. - // Default browser are 'strict-origin-when-cross-origin', we want more so we use 'same-origin' so we don't send any referrer when going into another web site + // Default browser are 'strict-origin-when-cross-origin' (only domain is sent on other domain switching), we want more so we use 'same-origin' so borwser doesn't send any referrer when going into another web site domain. if (!defined('MAIN_SECURITY_FORCERP')) { $referrerpolicy = getDolGlobalString('MAIN_SECURITY_FORCERP', "same-origin"); From 767f5db7dc1e44001e033d672301d1704ddaba64 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 20 Nov 2022 22:42:35 +0100 Subject: [PATCH 96/99] Typo --- htdocs/admin/system/security.php | 2 +- htdocs/main.inc.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index 25b30fd42f6..62b012858b5 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -545,7 +545,7 @@ print '
'; print 'MAIN_SECURITY_FORCECSP = '.(empty($conf->global->MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCECSP).'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; img-src *;\")
"; print '
'; -print 'MAIN_SECURITY_FORCERP = '.(empty($conf->global->MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCERP).'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"same-origin\" so borwser doesn't send any referrer when going into another web site domain)
"; +print 'MAIN_SECURITY_FORCERP = '.(empty($conf->global->MAIN_SECURITY_FORCERP) ? ''.$langs->trans("Undefined").'' : $conf->global->MAIN_SECURITY_FORCERP).'   ('.$langs->trans("Recommended").': '.$langs->trans("Undefined").' '.$langs->trans("or")." \"same-origin\" so browser doesn't send any referrer when going into another web site domain)
"; print '
'; print 'WEBSITE_MAIN_SECURITY_FORCECSP = '.(empty($conf->global->WEBSITE_MAIN_SECURITY_FORCECSP) ? ''.$langs->trans("Undefined").'' : $conf->global->WEBSITE_MAIN_SECURITY_FORCECSP).'   ('.$langs->trans("Example").": \"frame-ancestors 'self'; default-src 'self'; style-src https://cdnjs.cloudflare.com https://fonts.googleapis.com; script-src https://cdn.transifex.com https://www.googletagmanager.com; object-src https://youtube.com; frame-src https://youtube.com; img-src *;\")
"; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 513d9c12fdb..4b580e7b808 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1484,7 +1484,7 @@ function top_httphead($contenttype = 'text/html', $forcenocache = 0) // Referrer-Policy // Say if we must provide the referrer when we jump onto another web page. - // Default browser are 'strict-origin-when-cross-origin' (only domain is sent on other domain switching), we want more so we use 'same-origin' so borwser doesn't send any referrer when going into another web site domain. + // Default browser are 'strict-origin-when-cross-origin' (only domain is sent on other domain switching), we want more so we use 'same-origin' so browser doesn't send any referrer when going into another web site domain. if (!defined('MAIN_SECURITY_FORCERP')) { $referrerpolicy = getDolGlobalString('MAIN_SECURITY_FORCERP', "same-origin"); From 7c1eac9774bd1fed0b7b4594159f2ac2d12a4011 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Nov 2022 03:58:22 +0100 Subject: [PATCH 97/99] Fix sqli ->escape after ->escapeforlike --- htdocs/contact/list.php | 7 +- htdocs/core/lib/website.lib.php | 13 +- .../modules/import/import_csv.modules.php | 4 +- .../modules/import/import_xlsx.modules.php | 4 +- test/phpunit/Website.class.php | 178 ++++++++++++++++++ 5 files changed, 194 insertions(+), 12 deletions(-) create mode 100644 test/phpunit/Website.class.php diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 605fafd9e01..d2c8690eb87 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -502,16 +502,17 @@ if (!empty($conf->socialnetworks->enabled)) { if ($value['active'] && strlen($search_[$key])) { $searchkeyinjsonformat = preg_replace('/"$/', '', preg_replace('/^"/', '', json_encode($search_[$key]))); if (in_array($db->type, array('mysql', 'mysqli'))) { - $sql .= " AND p.socialnetworks REGEXP '\"".$db->escapeforlike($db->escape($key))."\":\"[^\"]*".$db->escapeforlike($db->escape($searchkeyinjsonformat))."'"; + $sql .= " AND p.socialnetworks REGEXP '\"".$db->escape($db->escapeforlike($key))."\":\"[^\"]*".$db->escape($db->escapeforlike($searchkeyinjsonformat))."'"; } elseif ($db->type == 'pgsql') { - $sql .= " AND p.socialnetworks ~ '\"".$db->escapeforlike($db->escape($key))."\":\"[^\"]*".$db->escapeforlike($db->escape($searchkeyinjsonformat))."'"; + $sql .= " AND p.socialnetworks ~ '\"".$db->escape($db->escapeforlike($key))."\":\"[^\"]*".$db->escape($db->escapeforlike($searchkeyinjsonformat))."'"; } else { // Works with all database but not reliable because search only for social network code starting with earched value - $sql .= " AND p.socialnetworks LIKE '%\"".$db->escapeforlike($db->escape($key))."\":\"".$db->escapeforlike($db->escape($searchkeyinjsonformat))."%'"; + $sql .= " AND p.socialnetworks LIKE '%\"".$db->escape($db->escapeforlike($key))."\":\"".$db->escape($db->escapeforlike($searchkeyinjsonformat))."%'"; } } } } +//print $sql; if (strlen($search_email)) { $sql .= natural_search('p.email', $search_email); } diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index e9ea4dbcf09..af48ec64885 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -887,7 +887,7 @@ function getSocialNetworkSharingLinks() * @param string $langcode Language code ('' or 'en', 'fr', 'es', ...) * @param array $otherfilters Other filters * @param int $status 0 or 1, or -1 for both - * @return string HTML content + * @return array Array with results of search */ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $sortfield = 'date_creation', $sortorder = 'DESC', $langcode = '', $otherfilters = 'null', $status = 1) { @@ -925,6 +925,8 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so $found = 0; if (!$error && (empty($max) || ($found < $max)) && (preg_match('/meta/', $algo) || preg_match('/content/', $algo))) { + include_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; + $sql = 'SELECT wp.rowid FROM '.MAIN_DB_PREFIX.'website_page as wp'; if (is_array($otherfilters) && !empty($otherfilters['category'])) { $sql .= ', '.MAIN_DB_PREFIX.'categorie_website_page as cwp'; @@ -934,7 +936,7 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so $sql .= " AND wp.status = ".((int) $status); } if ($langcode) { - $sql .= " AND wp.lang ='".$db->escape($langcode)."'"; + $sql .= " AND wp.lang = '".$db->escape($langcode)."'"; } if ($type) { $tmparrayoftype = explode(',', $type); @@ -947,11 +949,11 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so $sql .= " AND ("; $searchalgo = ''; if (preg_match('/meta/', $algo)) { - $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.title LIKE '%".$db->escapeforlike($db->escape($searchstring))."%' OR wp.description LIKE '%".$db->escapeforlike($db->escape($searchstring))."%'"; - $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.keywords LIKE '".$db->escapeforlike($db->escape($searchstring)).",%' OR wp.keywords LIKE '% ".$db->escapeforlike($db->escape($searchstring))."%'"; // TODO Use a better way to scan keywords + $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.title LIKE '%".$db->escape($db->escapeforlike($searchstring))."%' OR wp.description LIKE '%".$db->escape($db->escapeforlike($searchstring))."%'"; + $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.keywords LIKE '".$db->escape($db->escapeforlike($searchstring)).",%' OR wp.keywords LIKE '% ".$db->escape($db->escapeforlike($searchstring))."%'"; // TODO Use a better way to scan keywords } if (preg_match('/content/', $algo)) { - $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.content LIKE '%".$db->escapeforlike($db->escape($searchstring))."%'"; + $searchalgo .= ($searchalgo ? ' OR ' : '')."wp.content LIKE '%".$db->escape($db->escapeforlike($searchstring))."%'"; } $sql .= $searchalgo; if (is_array($otherfilters) && !empty($otherfilters['category'])) { @@ -963,6 +965,7 @@ function getPagesFromSearchCriterias($type, $algo, $searchstring, $max = 25, $so //print $sql; $resql = $db->query($sql); + if ($resql) { $i = 0; while (($obj = $db->fetch_object($resql)) && ($i < $max || $max == 0)) { diff --git a/htdocs/core/modules/import/import_csv.modules.php b/htdocs/core/modules/import/import_csv.modules.php index b251d70ad8f..ea1cb757223 100644 --- a/htdocs/core/modules/import/import_csv.modules.php +++ b/htdocs/core/modules/import/import_csv.modules.php @@ -862,8 +862,8 @@ class ImportCsv extends ModeleImports $stringtosearch = json_encode($socialnetwork).':'.json_encode($json->$socialnetwork); //var_dump($stringtosearch); //var_dump($this->db->escape($stringtosearch)); // This provide a value for sql string (but not for a like) - $where[] = $key." LIKE '%".$this->db->escapeforlike($this->db->escape($stringtosearch))."%'"; - $filters[] = $col." LIKE '%".$this->db->escapeforlike($this->db->escape($stringtosearch))."%'"; + $where[] = $key." LIKE '%".$this->db->escape($this->db->escapeforlike($stringtosearch))."%'"; + $filters[] = $col." LIKE '%".$this->db->escape($this->db->escapeforlike($stringtosearch))."%'"; //var_dump($where[1]); // This provide a value for sql string inside a like } else { $where[] = $key.' = '.$data[$key]; diff --git a/htdocs/core/modules/import/import_xlsx.modules.php b/htdocs/core/modules/import/import_xlsx.modules.php index 4023c1ecc99..eb781b66586 100644 --- a/htdocs/core/modules/import/import_xlsx.modules.php +++ b/htdocs/core/modules/import/import_xlsx.modules.php @@ -908,8 +908,8 @@ class ImportXlsx extends ModeleImports $stringtosearch = json_encode($socialnetwork).':'.json_encode($json->$socialnetwork); //var_dump($stringtosearch); //var_dump($this->db->escape($stringtosearch)); // This provide a value for sql string (but not for a like) - $where[] = $key." LIKE '%".$this->db->escapeforlike($this->db->escape($stringtosearch))."%'"; - $filters[] = $col." LIKE '%".$this->db->escapeforlike($this->db->escape($stringtosearch))."%'"; + $where[] = $key." LIKE '%".$this->db->escape($this->db->escapeforlike($stringtosearch))."%'"; + $filters[] = $col." LIKE '%".$this->db->escape($this->db->escapeforlike($stringtosearch))."%'"; //var_dump($where[1]); // This provide a value for sql string inside a like } else { $where[] = $key.' = '.$data[$key]; diff --git a/test/phpunit/Website.class.php b/test/phpunit/Website.class.php new file mode 100644 index 00000000000..50d0c16453d --- /dev/null +++ b/test/phpunit/Website.class.php @@ -0,0 +1,178 @@ + + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * or see https://www.gnu.org/ + */ + +/** + * \file test/phpunit/WebsiteTest.php + * \ingroup test + * \brief PHPUnit test + * \remarks To run this script as CLI: phpunit filename.php + */ + +global $conf,$user,$langs,$db; +//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver +//require_once 'PHPUnit/Autoload.php'; + +if (! defined('NOREQUIRESOC')) { + define('NOREQUIRESOC', '1'); +} +if (! defined('NOCSRFCHECK')) { + define('NOCSRFCHECK', '1'); +} +if (! defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', '1'); +} +if (! defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); // If there is no menu to show +} +if (! defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php +} +if (! defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} +if (! defined("NOLOGIN")) { + define("NOLOGIN", '1'); // If this page is public (can be called outside logged session) +} +if (! defined("NOSESSION")) { + define("NOSESSION", '1'); +} + +require_once dirname(__FILE__).'/../../htdocs/main.inc.php'; +require_once dirname(__FILE__).'/../../htdocs/core/lib/website.lib.php'; + + +if (empty($user->id)) { + print "Load permissions for admin user nb 1\n"; + $user->fetch(1); + $user->getrights(); +} +$conf->global->MAIN_DISABLE_ALL_MAILS=1; + + +/** + * Class for PHPUnit tests + * + * @backupGlobals disabled + * @backupStaticAttributes enabled + * @remarks backupGlobals must be disabled to have db,conf,user and lang not erased. + */ +class WebsiteTest extends PHPUnit\Framework\TestCase +{ + protected $savconf; + protected $savuser; + protected $savlangs; + protected $savdb; + + /** + * Constructor + * We save global variables into local variables + * + * @return SecurityTest + */ + public function __construct() + { + parent::__construct(); + + //$this->sharedFixture + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; + + print __METHOD__." db->type=".$db->type." user->id=".$user->id; + //print " - db ".$db->db; + print "\n"; + } + + /** + * setUpBeforeClass + * + * @return void + */ + public static function setUpBeforeClass() + { + global $conf,$user,$langs,$db; + $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. + + print __METHOD__."\n"; + } + + /** + * tearDownAfterClass + * + * @return void + */ + public static function tearDownAfterClass() + { + global $conf,$user,$langs,$db; + $db->rollback(); + + print __METHOD__."\n"; + } + + /** + * Init phpunit tests + * + * @return void + */ + protected function setUp() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + print __METHOD__."\n"; + } + + /** + * End phpunit tests + * + * @return void + */ + protected function tearDown() + { + print __METHOD__."\n"; + } + + + /** + * testGetPagesFromSearchCriterias + * + * @return void + */ + public function testGetPagesFromSearchCriterias() + { + global $db; + + $s = "123') OR 1=1-- \' xxx"; + /* + var_dump($s); + var_dump($db->escapeforlike($s)); + var_dump($db->escape($db->escapeforlike($s))); + */ + + $res = getPagesFromSearchCriterias('page,blogpost', 'meta,content', $s, 2, 'date_creation', 'DESC', 'en'); + //var_dump($res); + print __METHOD__." message=".$res['code']."\n"; + // We must found no line (so code should be KO). If we found somethiing, it means there is a SQL injection of the 1=1 + $this->assertEquals($res['code'], 'KO'); + } +} From 44709f986cd2a4833a82ab0d7b2c97bdd8531411 Mon Sep 17 00:00:00 2001 From: FLIO Date: Mon, 21 Nov 2022 11:37:35 +0100 Subject: [PATCH 98/99] Fix(scrutinizer) https://scrutinizer-ci.com/g/Dolibarr/dolibarr/issues/develop/files/htdocs/core/lib/files.lib.php?selectedLabels%5B0%5D=9&selectedSeverities%5B0%5D=10&orderField=lastFound&order=desc&honorSelectedPaths=0 --- htdocs/core/lib/files.lib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index cb7e1a8883e..edbc348444e 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -401,8 +401,8 @@ function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir) /** * Fast compare of 2 files identified by their properties ->name, ->date and ->size * - * @param string $a File 1 - * @param string $b File 2 + * @param object $a File 1 + * @param object $b File 2 * @return int 1, 0, 1 */ function dol_compare_file($a, $b) From 6aefc9edfce56793399360a82b2a1a8785883cdf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 21 Nov 2022 18:30:17 +0100 Subject: [PATCH 99/99] Enable MAIN_MAIL_ADD_INLINE_IMAGES_IF_DATA by default --- htdocs/core/class/CMailFile.class.php | 2 +- htdocs/core/class/conf.class.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 2651df8b2e5..70436641fa4 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -267,7 +267,7 @@ class CMailFile } // Set atleastoneimage if there is at least one embedded file (into ->html_images) - if ($findimg) { + if ($findimg > 0) { foreach ($this->html_images as $i => $val) { if ($this->html_images[$i]) { $this->atleastoneimage = 1; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 42927d398aa..d03604dc124 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -923,6 +923,10 @@ class Conf // Note: Set MAIN_SECURITY_CSRF_TOKEN_RENEWAL_ON_EACH_CALL=1 to have a renewal of token at each page call instead of each session (not recommended) } + if (!isset($this->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_DATA)) { + $this->global->MAIN_MAIL_ADD_INLINE_IMAGES_IF_DATA = 1; + } + if (!defined('MAIN_ANTIVIRUS_BYPASS_COMMAND_AND_PARAM')) { if (defined('MAIN_ANTIVIRUS_COMMAND')) { $this->global->MAIN_ANTIVIRUS_COMMAND = constant('MAIN_ANTIVIRUS_COMMAND');