From 65c0167d077605451f37351d94ef76cd8113fc69 Mon Sep 17 00:00:00 2001 From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com> Date: Sun, 10 Oct 2021 20:50:51 +0200 Subject: [PATCH 001/178] ADD : info of number of product still to dispatched in a supplier order --- htdocs/core/lib/fourn.lib.php | 4 ++ .../class/fournisseur.commande.class.php | 43 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index efc9f60147c..e81bdb5e9d0 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -157,8 +157,12 @@ function ordersupplier_prepare_head($object) if (!empty($conf->stock->enabled) && (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))) { $langs->load("stocks"); + $nbLineToDispatch = count($object->getNotCompletlyDispatchedLines()); $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id; $head[$h][1] = $langs->trans("OrderDispatch"); + if ($nbLineToDispatch > 0) { + $head[$h][1] .= ''.$nbLineToDispatch.''; + } $head[$h][2] = 'dispatch'; $h++; } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 99ef4e54e87..5277f5b1d34 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2274,6 +2274,49 @@ class CommandeFournisseur extends CommonOrder return $ret; } + /** + * Return array of the lines that are waiting to be dispatched + * + * @return array Array of lines + */ + public function getNotCompletlyDispatchedLines() + { + $ret = array(); + + $sql = "SELECT supplierOrderDet.fk_product as product_id, supplierOrderDet.qty as qty_ordered, supplierOrderDet.fk_commande,"; + $sql .= " dispatch.rowid as dispatchedlineid, sum(dispatch.qty) as qty_dispatched"; + $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as supplierOrderDet"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as dispatch ON supplierOrderDet.rowid = dispatch.fk_commandefourndet"; + $sql .= " WHERE supplierOrderDet.fk_commande = ".$this->id; + $sql .= " GROUP BY supplierOrderDet.fk_product"; + + $resql = $this->db->query($sql); + + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + + while ($i < $num) { + $objp = $this->db->fetch_object($resql); + + if ($objp) { + // If product not completly dispatched + if (is_null($objp->qty_dispatched) OR ($objp->qty_dispatched < $objp->qty_ordered)){ + $ret[] = array( + 'product_id' => $objp->product_id, + 'qty_ordered' => $objp->qty_ordered, + 'qty_dispatched' => $objp->qty_dispatched, + ); + } + } + $i++; + } + } else { + dol_print_error($this->db, 'Failed to execute request to get not completly dispatched lines'); + } + + return $ret; + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** From 73bd05606c554802d3371cfb7235e365e8f0fff2 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 10 Oct 2021 18:53:22 +0000 Subject: [PATCH 002/178] Fixing style errors. --- htdocs/fourn/class/fournisseur.commande.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 5277f5b1d34..a9d3cbdcac5 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2289,7 +2289,7 @@ class CommandeFournisseur extends CommonOrder $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as dispatch ON supplierOrderDet.rowid = dispatch.fk_commandefourndet"; $sql .= " WHERE supplierOrderDet.fk_commande = ".$this->id; $sql .= " GROUP BY supplierOrderDet.fk_product"; - + $resql = $this->db->query($sql); if ($resql) { @@ -2301,7 +2301,7 @@ class CommandeFournisseur extends CommonOrder if ($objp) { // If product not completly dispatched - if (is_null($objp->qty_dispatched) OR ($objp->qty_dispatched < $objp->qty_ordered)){ + if (is_null($objp->qty_dispatched) OR ($objp->qty_dispatched < $objp->qty_ordered)) { $ret[] = array( 'product_id' => $objp->product_id, 'qty_ordered' => $objp->qty_ordered, From a7563ff62e1fbef41f99bbb679674f0ef2cce67c Mon Sep 17 00:00:00 2001 From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com> Date: Sun, 10 Oct 2021 21:15:14 +0200 Subject: [PATCH 003/178] Fix : Found non quoted or not casted var into sql request --- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index a9d3cbdcac5..787d9ee321b 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2287,7 +2287,7 @@ class CommandeFournisseur extends CommonOrder $sql .= " dispatch.rowid as dispatchedlineid, sum(dispatch.qty) as qty_dispatched"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as supplierOrderDet"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as dispatch ON supplierOrderDet.rowid = dispatch.fk_commandefourndet"; - $sql .= " WHERE supplierOrderDet.fk_commande = ".$this->id; + $sql .= " WHERE supplierOrderDet.fk_commande = ".((int) $this->id); $sql .= " GROUP BY supplierOrderDet.fk_product"; $resql = $this->db->query($sql); From 5d7587259d88e17df0c49f63d3bf791f239b62e7 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 13 Oct 2021 21:21:16 +0200 Subject: [PATCH 004/178] FIX Accountancy - If deposit invoice is used, force binding in deposit accounting account to solve transaction --- htdocs/accountancy/customer/list.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index 5ce9f5e13e8..2be7cd5f4ca 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -637,11 +637,15 @@ if ($result) { } // Manage Deposit - if ($objp->description == "(DEPOSIT)") { - $accountdeposittoventilated = new AccountingAccount($db); - $accountdeposittoventilated->fetch('', $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT, 1); - $objp->code_sell_l = $accountdeposittoventilated->ref; - $objp->aarowid_suggest = $accountdeposittoventilated->rowid; + if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT)) { + if ($objp->description == "(DEPOSIT)" || $objp->ftype == $facture_static::TYPE_DEPOSIT) { + $accountdeposittoventilated = new AccountingAccount($db); + $accountdeposittoventilated->fetch('', $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT, 1); + $objp->code_sell_l = $accountdeposittoventilated->ref; + $objp->code_sell_p = ''; + $objp->code_sell_t = ''; + $objp->aarowid_suggest = $accountdeposittoventilated->rowid; + } } if (!empty($objp->code_sell_p)) { From 9e3a00521d8a1f7e4daa221cce5d2f393bee29ef Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Wed, 13 Oct 2021 21:36:04 +0200 Subject: [PATCH 005/178] FIX also on customer index for automatic binding --- htdocs/accountancy/customer/index.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index 0ee9c865603..7dc88a6939a 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -170,6 +170,8 @@ if ($action == 'validatehistory') { } else { $num_lines = $db->num_rows($result); + $facture_static = new Facture($db); + $isSellerInEEC = isInEEC($mysoc); $i = 0; @@ -213,6 +215,18 @@ if ($action == 'validatehistory') { } } + // Manage Deposit + if (!empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT)) { + if ($objp->description == "(DEPOSIT)" || $objp->ftype == $facture_static::TYPE_DEPOSIT) { + $accountdeposittoventilated = new AccountingAccount($db); + $accountdeposittoventilated->fetch('', $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT, 1); + $objp->code_sell_l = $accountdeposittoventilated->ref; + $objp->code_sell_p = ''; + $objp->code_sell_t = ''; + $objp->aarowid_suggest = $accountdeposittoventilated->rowid; + } + } + if ($objp->aarowid_suggest > 0) { $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."facturedet"; $sqlupdate .= " SET fk_code_ventilation = ".((int) $objp->aarowid_suggest); From d3d3a87ce9ca1ee8eb9328f87a367dd9c5625210 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Sun, 24 Oct 2021 01:38:13 +0200 Subject: [PATCH 006/178] Add new class to help setup generation --- htdocs/core/class/html.formsetup.class.php | 403 ++++++++++++++++++ htdocs/modulebuilder/template/admin/setup.php | 157 +------ 2 files changed, 410 insertions(+), 150 deletions(-) create mode 100644 htdocs/core/class/html.formsetup.class.php diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php new file mode 100644 index 00000000000..095cf0d8887 --- /dev/null +++ b/htdocs/core/class/html.formsetup.class.php @@ -0,0 +1,403 @@ + + * + * 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 . + */ + + +/** + * This class help you create setup render + */ +class formSetup{ + + /** + * @var DoliDB Database handler. + */ + public $db; + + /** @var formSetupItem[] */ + public $arrayOfParameters = array(); + + public $setupNotEmpty = 0; + + /** @var Translate */ + public $langs; + + /** @var Form */ + public $form; + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db, $outputLangs = false) + { + global $langs; + $this->db = $db; + $this->form = new Form($this->db); + + if($outputLangs){ + $this->langs = $outputLangs; + } + else{ + $this->langs = $langs; + } + } + + /** + * @return string + */ + public function generateOutput($edit = false){ + + require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + + $out = ''; + $out.= ''; + $out.= ' '; + $out.= ' '; + $out.= ''; + + foreach ($this->arrayOfParameters as $const => $item) { + $out.= $this->generateLineOutput($item, $edit); + } + + $out.= '
'.$this->langs->trans("Parameter").''.$this->langs->trans("Value").'
'; + return $out; + } + + /** + * @param formSetupItem $item + * @param bool $edit + * @return string + */ + public function generateLineOutput($item, $edit = false){ + + $out = ''; + if ($item->enabled==1) { + $this->setupNotEmpty++; + $out.= ''; + + $out.= ''; + $out.= ''; + $out.= $this->form->textwithpicto($item->getNameText(), $item->getHelpText(), 1, 'info', '', 0, 3, 'tootips'.$item->confKey); + $out.= ''; + $out.= ''; + + $out.= ''; + + if($edit){ + $item->generateInputField(); + } + else{ + $item->generateOutputField(); + } + + if(!empty($item->errors)){ + // TODO : move set event message in a methode to be called by cards not by this class + setEventMessages(null, $item->errors, 'errors'); + } + + $out.= ''; + $out.= ''; + } + + return $out; + } + + + /** + * @param string $confKey + * @param array $params + * @ + */ + public function addItemsFromParamsArray($params){ + + if(!array($params)){ return false; } + + foreach ($params as $confKey => $param){ + $this->addItemFromParams($confKey, $param); // todo manage error + } + } + + + /** + * From old + * @param string $confKey + * @param array $params + */ + public function addItemFromParams($confKey, $params){ + + if(empty($confKey) || !empty($params['type'])){ return false; } + + /* + * Exemple from old module builder setup page + * // 'MYMODULE_MYPARAM1'=>array('type'=>'string', 'css'=>'minwidth500' ,'enabled'=>1), + // 'MYMODULE_MYPARAM2'=>array('type'=>'textarea','enabled'=>1), + //'MYMODULE_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), + //'MYMODULE_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1), + //'MYMODULE_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1), + //'MYMODULE_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1), + //'MYMODULE_MYPARAM6'=>array('type'=>'securekey', 'enabled'=>1), + //'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1), + */ + + $item = new formSetupItem($this->db); + $item->type = $params['type']; + + if(!empty($params['enabled'])) { + $item->enabled = $params['enabled']; + } + + if(!empty($params['css'])){ + $item->enabled = $params['css']; + } + + $this->arrayOfParameters[$item->confKey] = $item; + + return true; + } + +} + + +class formSetupItem +{ + /** + * @var DoliDB Database handler. + */ + public $db; + + /** @var Translate */ + public $langs; + + /** @var Form */ + public $form; + + /** @var string $confKey the conf key used in database */ + public $confKey; + + /** @var string|false $nameText */ + public $nameText = false; + + /** @var string $helpText */ + public $helpText = ''; + + /** @var bool|string set this var to override field output */ + public $fieldOverride = false; + + /** + * @var string $errors + */ + public $errors = array(); + + /** + * @var string $type 'string', 'textarea', 'category:'.Categorie::TYPE_CUSTOMER', 'emailtemplate', 'thirdparty_type' + */ + public $type; + + public $enabled = 0; + + public $cssClass = ''; + + /** + * Constructor + * + * @param $confKey + */ + public function __construct($confKey) + { + global $langs, $db; + $this->db = $db; + $this->form = new Form($this->db); + $this->langs = $langs; + + $this->confKey = $confKey; + } + + public function getHelpText(){ + if(!empty($this->helpText)){ return $this->helpText; } + return (($this->langs->trans($this->confKey . 'Tooltip') != $this->confKey . 'Tooltip') ? $this->langs->trans($this->confKey . 'Tooltip') : ''); + } + + public function getNameText(){ + if(!empty($this->nameText)){ return $this->nameText; } + return (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : ''); + } + + public function generateInputField(){ + global $conf, $user; + + if(!empty($this->fieldOverride)){ + return $this->fieldOverride; + } + + $out = ''; + + if ($this->type == 'textarea') { + $out.= '\n"; + } elseif ($this->type== 'html') { + require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + $doleditor = new DolEditor($this->confKey, $conf->global->{$this->confKey}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor->Create(); + } elseif ($this->type == 'yesno') { + $out.= $this->form->selectyesno($this->confKey, $conf->global->{$this->confKey}, 1); + } elseif (preg_match('/emailtemplate:/', $this->type)) { + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($this->db); + + $tmp = explode(':', $this->type); + $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang + //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, ''); + $arrayOfMessageName = array(); + if (is_array($formmail->lines_model)) { + foreach ($formmail->lines_model as $modelMail) { + //var_dump($modelmail); + $moreonlabel = ''; + if (!empty($arrayOfMessageName[$modelMail->label])) { + $moreonlabel = ' (' . $this->langs->trans("SeveralLangugeVariatFound") . ')'; + } + // The 'label' is the key that is unique if we exclude the language + $arrayOfMessageName[$modelMail->id] = $this->langs->trans(preg_replace('/\(|\)/', '', $modelMail->label)) . $moreonlabel; + } + } + $out.= $this->form->selectarray($this->confKey, $arrayOfMessageName, $conf->global->{$this->confKey}, 'None', 0, 0, '', 0, 0, 0, '', '', 1); + } elseif (preg_match('/category:/', $this->type)) { + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + $formother = new FormOther($this->db); + + $tmp = explode(':', $this->type); + $out.= img_picto('', 'category', 'class="pictofixedwidth"'); + $out.= $formother->select_categories($tmp[1], $conf->global->{$this->confKey}, $this->confKey, 0, $this->langs->trans('CustomersProspectsCategoriesShort')); + } elseif (preg_match('/thirdparty_type/', $this->type)) { + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; + $formcompany = new FormCompany($this->db); + $out.= $formcompany->selectProspectCustomerType($conf->global->{$this->confKey}, $this->confKey); + } elseif ($this->type == 'securekey') { + $out.= ''; + if (!empty($conf->use_javascript_ajax)) { + $out.= ' '.img_picto($this->langs->trans('Generate'), 'refresh', 'id="generate_token'.$this->confKey.'" class="linkobject"'); + } + if (!empty($conf->use_javascript_ajax)) { + $out.= "\n".''; + } + } elseif ($this->type == 'product') { + if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { + $selected = (empty($conf->global->{$this->confKey}) ? '' : $conf->global->{$this->confKey}); + $this->form->select_produits($selected, $this->confKey, '', 0); + } + } else { + $out.= ''; + } + + return $out; + } + + + /** + * add error + * @param array|string $errors + */ + public function setErrors($errors){ + if(is_array($errors)){ + if(!empty($errors)){ + foreach ($errors as $error){ + $this->setErrors($error); + } + } + } + elseif(!empty($errors)){ + $this->errors[] = $errors; + } + } + + public function generateOutputField(){ + global $conf, $user; + + if(!empty($this->fieldOverride)){ + return $this->fieldOverride; + } + + $out = ''; + + if ($this->type == 'textarea') { + print dol_nl2br($conf->global->{$this->confKey}); + } elseif ($this->type== 'html') { + print $conf->global->{$this->confKey}; + } elseif ($this->type == 'yesno') { + print ajax_constantonoff($this->confKey); + } elseif (preg_match('/emailtemplate:/', $this->type)) { + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($this->db); + + $tmp = explode(':', $this->type); + + $template = $formmail->getEMailTemplate($this->db, $tmp[1], $user, $this->langs, $conf->global->{$this->confKey}); + if ($template<0) { + $this->setErrors($formmail->errors); + } + print $this->langs->trans($template->label); + } elseif (preg_match('/category:/', $this->type)) { + $c = new Categorie($this->db); + $result = $c->fetch($conf->global->{$this->confKey}); + if ($result < 0) { + $this->setErrors($c->errors); + } + $ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text + $toprint = array(); + foreach ($ways as $way) { + $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; + } + print '
      ' . implode(' ', $toprint) . '
    '; + } elseif (preg_match('/thirdparty_type/', $this->type)) { + if ($conf->global->{$this->confKey}==2) { + print $this->langs->trans("Prospect"); + } elseif ($conf->global->{$this->confKey}==3) { + print $this->langs->trans("ProspectCustomer"); + } elseif ($conf->global->{$this->confKey}==1) { + print $this->langs->trans("Customer"); + } elseif ($conf->global->{$this->confKey}==0) { + print $this->langs->trans("NorProspectNorCustomer"); + } + } elseif ($this->type == 'product') { + $product = new Product($this->db); + $resprod = $product->fetch($conf->global->{$this->confKey}); + if ($resprod > 0) { + print $product->ref; + } elseif ($resprod < 0) { + $this->setErrors($product->errors); + } + } else { + print $conf->global->{$this->confKey}; + } + + return $out; + } + +} diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 7c6c6b2c04e..390f45d955c 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -222,96 +222,17 @@ print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "mymo echo ''.$langs->trans("MyModuleSetupPage").'

    '; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; +$formSetup = new formSetup($db); + +$formSetup->addItemsFromParamsArray($arrayofparameters); + if ($action == 'edit') { print '
    '; print ''; print ''; - print ''; - print ''; - - foreach ($arrayofparameters as $constname => $val) { - if ($val['enabled']==1) { - $setupnotempty++; - print ''; - } - } - print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; - $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); - print ''.$form->textwithpicto($langs->trans($constname), $tooltiphelp, 1, 'info', '', 0, 3, 'tootips'.$constname).''; - print ''; - - if ($val['type'] == 'textarea') { - print '\n"; - } elseif ($val['type']== 'html') { - require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($constname, $conf->global->{$constname}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); - $doleditor->Create(); - } elseif ($val['type'] == 'yesno') { - print $form->selectyesno($constname, $conf->global->{$constname}, 1); - } elseif (preg_match('/emailtemplate:/', $val['type'])) { - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - $tmp = explode(':', $val['type']); - $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang - //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, ''); - $arrayofmessagename = array(); - if (is_array($formmail->lines_model)) { - foreach ($formmail->lines_model as $modelmail) { - //var_dump($modelmail); - $moreonlabel = ''; - if (!empty($arrayofmessagename[$modelmail->label])) { - $moreonlabel = ' (' . $langs->trans("SeveralLangugeVariatFound") . ')'; - } - // The 'label' is the key that is unique if we exclude the language - $arrayofmessagename[$modelmail->id] = $langs->trans(preg_replace('/\(|\)/', '', $modelmail->label)) . $moreonlabel; - } - } - print $form->selectarray($constname, $arrayofmessagename, $conf->global->{$constname}, 'None', 0, 0, '', 0, 0, 0, '', '', 1); - } elseif (preg_match('/category:/', $val['type'])) { - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; - $formother = new FormOther($db); - - $tmp = explode(':', $val['type']); - print img_picto('', 'category', 'class="pictofixedwidth"'); - print $formother->select_categories($tmp[1], $conf->global->{$constname}, $constname, 0, $langs->trans('CustomersProspectsCategoriesShort')); - } elseif (preg_match('/thirdparty_type/', $val['type'])) { - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; - $formcompany = new FormCompany($db); - print $formcompany->selectProspectCustomerType($conf->global->{$constname}, $constname); - } elseif ($val['type'] == 'securekey') { - print ''; - if (!empty($conf->use_javascript_ajax)) { - print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token'.$constname.'" class="linkobject"'); - } - if (!empty($conf->use_javascript_ajax)) { - print "\n".''; - } - } elseif ($val['type'] == 'product') { - if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { - $selected = (empty($conf->global->$constname) ? '' : $conf->global->$constname); - $form->select_produits($selected, $constname, '', 0); - } - } else { - print ''; - } - print '
    '; + print $formSetup->generateOutput(true); print '
    '; print ''; @@ -321,72 +242,8 @@ if ($action == 'edit') { print '
    '; } else { if (!empty($arrayofparameters)) { - print ''; - print ''; - foreach ($arrayofparameters as $constname => $val) { - if ($val['enabled']==1) { - $setupnotempty++; - print ''; - } - } - - print '
    '.$langs->trans("Parameter").''.$langs->trans("Value").'
    '; - $tooltiphelp = (($langs->trans($constname . 'Tooltip') != $constname . 'Tooltip') ? $langs->trans($constname . 'Tooltip') : ''); - print $form->textwithpicto($langs->trans($constname), $tooltiphelp); - print ''; - - if ($val['type'] == 'textarea') { - print dol_nl2br($conf->global->{$constname}); - } elseif ($val['type']== 'html') { - print $conf->global->{$constname}; - } elseif ($val['type'] == 'yesno') { - print ajax_constantonoff($constname); - } elseif (preg_match('/emailtemplate:/', $val['type'])) { - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - $tmp = explode(':', $val['type']); - - $template = $formmail->getEMailTemplate($db, $tmp[1], $user, $langs, $conf->global->{$constname}); - if ($template<0) { - setEventMessages(null, $formmail->errors, 'errors'); - } - print $langs->trans($template->label); - } elseif (preg_match('/category:/', $val['type'])) { - $c = new Categorie($db); - $result = $c->fetch($conf->global->{$constname}); - if ($result < 0) { - setEventMessages(null, $c->errors, 'errors'); - } - $ways = $c->print_all_ways(' >> ', 'none', 0, 1); // $ways[0] = "ccc2 >> ccc2a >> ccc2a1" with html formated text - $toprint = array(); - foreach ($ways as $way) { - $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; - } - print '
      ' . implode(' ', $toprint) . '
    '; - } elseif (preg_match('/thirdparty_type/', $val['type'])) { - if ($conf->global->{$constname}==2) { - print $langs->trans("Prospect"); - } elseif ($conf->global->{$constname}==3) { - print $langs->trans("ProspectCustomer"); - } elseif ($conf->global->{$constname}==1) { - print $langs->trans("Customer"); - } elseif ($conf->global->{$constname}==0) { - print $langs->trans("NorProspectNorCustomer"); - } - } elseif ($val['type'] == 'product') { - $product = new Product($db); - $resprod = $product->fetch($conf->global->{$constname}); - if ($resprod > 0) { - print $product->ref; - } elseif ($resprod < 0) { - setEventMessages(null, $object->errors, "errors"); - } - } else { - print $conf->global->{$constname}; - } - print '
    '; + print $formSetup->generateOutput(); print '
    '; print ''.$langs->trans("Modify").''; From fdcb9674d8470419daddb3c1b970113117f6a46b Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Sun, 24 Oct 2021 02:09:49 +0200 Subject: [PATCH 007/178] Remove prints --- htdocs/core/class/html.formsetup.class.php | 38 +++++++++++----------- htdocs/langs/en_US/admin.lang | 1 + 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 095cf0d8887..27b0e3fb615 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -69,7 +69,7 @@ class formSetup{ $out.= ' '.$this->langs->trans("Value").''; $out.= ''; - foreach ($this->arrayOfParameters as $const => $item) { + foreach ($this->arrayOfParameters as $item) { $out.= $this->generateLineOutput($item, $edit); } @@ -98,10 +98,10 @@ class formSetup{ $out.= ''; if($edit){ - $item->generateInputField(); + $out.= $item->generateInputField(); } else{ - $item->generateOutputField(); + $out.= $item->generateOutputField(); } if(!empty($item->errors)){ @@ -125,7 +125,6 @@ class formSetup{ public function addItemsFromParamsArray($params){ if(!array($params)){ return false; } - foreach ($params as $confKey => $param){ $this->addItemFromParams($confKey, $param); // todo manage error } @@ -139,7 +138,7 @@ class formSetup{ */ public function addItemFromParams($confKey, $params){ - if(empty($confKey) || !empty($params['type'])){ return false; } + if(empty($confKey) || empty($params['type'])){ return false; } /* * Exemple from old module builder setup page @@ -155,13 +154,14 @@ class formSetup{ $item = new formSetupItem($this->db); $item->type = $params['type']; + $item->confKey = $confKey; if(!empty($params['enabled'])) { $item->enabled = $params['enabled']; } if(!empty($params['css'])){ - $item->enabled = $params['css']; + $item->cssClass = $params['css']; } $this->arrayOfParameters[$item->confKey] = $item; @@ -233,7 +233,7 @@ class formSetupItem public function getNameText(){ if(!empty($this->nameText)){ return $this->nameText; } - return (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : ''); + return (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : $this->langs->trans('MissingTranslationForConfKey',$this->confKey)); } public function generateInputField(){ @@ -313,7 +313,7 @@ class formSetupItem $this->form->select_produits($selected, $this->confKey, '', 0); } } else { - $out.= ''; + $out.= ''; } return $out; @@ -347,11 +347,11 @@ class formSetupItem $out = ''; if ($this->type == 'textarea') { - print dol_nl2br($conf->global->{$this->confKey}); + $out.= dol_nl2br($conf->global->{$this->confKey}); } elseif ($this->type== 'html') { - print $conf->global->{$this->confKey}; + $out.= $conf->global->{$this->confKey}; } elseif ($this->type == 'yesno') { - print ajax_constantonoff($this->confKey); + $out.= ajax_constantonoff($this->confKey); } elseif (preg_match('/emailtemplate:/', $this->type)) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($this->db); @@ -362,7 +362,7 @@ class formSetupItem if ($template<0) { $this->setErrors($formmail->errors); } - print $this->langs->trans($template->label); + $out.= $this->langs->trans($template->label); } elseif (preg_match('/category:/', $this->type)) { $c = new Categorie($this->db); $result = $c->fetch($conf->global->{$this->confKey}); @@ -374,27 +374,27 @@ class formSetupItem foreach ($ways as $way) { $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; } - print '
      ' . implode(' ', $toprint) . '
    '; + $out.= '
      ' . implode(' ', $toprint) . '
    '; } elseif (preg_match('/thirdparty_type/', $this->type)) { if ($conf->global->{$this->confKey}==2) { - print $this->langs->trans("Prospect"); + $out.= $this->langs->trans("Prospect"); } elseif ($conf->global->{$this->confKey}==3) { - print $this->langs->trans("ProspectCustomer"); + $out.= $this->langs->trans("ProspectCustomer"); } elseif ($conf->global->{$this->confKey}==1) { - print $this->langs->trans("Customer"); + $out.= $this->langs->trans("Customer"); } elseif ($conf->global->{$this->confKey}==0) { - print $this->langs->trans("NorProspectNorCustomer"); + $out.= $this->langs->trans("NorProspectNorCustomer"); } } elseif ($this->type == 'product') { $product = new Product($this->db); $resprod = $product->fetch($conf->global->{$this->confKey}); if ($resprod > 0) { - print $product->ref; + $out.= $product->ref; } elseif ($resprod < 0) { $this->setErrors($product->errors); } } else { - print $conf->global->{$this->confKey}; + $out.= $conf->global->{$this->confKey}; } return $out; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index f75ba12abe5..96fba681373 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2198,3 +2198,4 @@ SkinAndColors=Skin and colors IfYouUseASecondTaxYouMustSetYouUseTheMainTax=If you want to use a second tax, you must enable also the first sales tax IfYouUseAThirdTaxYouMustSetYouUseTheMainTax=If you want to use a third tax, you must enable also the first sales tax PDF_USE_1A=Generate PDF with PDF/A-1b format +MissingTranslationForConfKey = Missing translation for %s From 61576dad539cc363fa3efdfbb55e9f9512cb5cf7 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sun, 24 Oct 2021 00:17:18 +0000 Subject: [PATCH 008/178] Fixing style errors. --- htdocs/core/class/html.formsetup.class.php | 73 ++++++++++++---------- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 27b0e3fb615..70dd11e47ae 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -19,7 +19,8 @@ /** * This class help you create setup render */ -class formSetup{ +class formSetup +{ /** * @var DoliDB Database handler. @@ -48,10 +49,9 @@ class formSetup{ $this->db = $db; $this->form = new Form($this->db); - if($outputLangs){ + if ($outputLangs) { $this->langs = $outputLangs; - } - else{ + } else { $this->langs = $langs; } } @@ -59,7 +59,8 @@ class formSetup{ /** * @return string */ - public function generateOutput($edit = false){ + public function generateOutput($edit = false) + { require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; @@ -82,7 +83,8 @@ class formSetup{ * @param bool $edit * @return string */ - public function generateLineOutput($item, $edit = false){ + public function generateLineOutput($item, $edit = false) + { $out = ''; if ($item->enabled==1) { @@ -97,14 +99,13 @@ class formSetup{ $out.= ''; - if($edit){ + if ($edit) { $out.= $item->generateInputField(); - } - else{ + } else { $out.= $item->generateOutputField(); } - if(!empty($item->errors)){ + if (!empty($item->errors)) { // TODO : move set event message in a methode to be called by cards not by this class setEventMessages(null, $item->errors, 'errors'); } @@ -122,10 +123,11 @@ class formSetup{ * @param array $params * @ */ - public function addItemsFromParamsArray($params){ + public function addItemsFromParamsArray($params) + { - if(!array($params)){ return false; } - foreach ($params as $confKey => $param){ + if (!array($params)) { return false; } + foreach ($params as $confKey => $param) { $this->addItemFromParams($confKey, $param); // todo manage error } } @@ -136,9 +138,10 @@ class formSetup{ * @param string $confKey * @param array $params */ - public function addItemFromParams($confKey, $params){ + public function addItemFromParams($confKey, $params) + { - if(empty($confKey) || empty($params['type'])){ return false; } + if (empty($confKey) || empty($params['type'])) { return false; } /* * Exemple from old module builder setup page @@ -156,11 +159,11 @@ class formSetup{ $item->type = $params['type']; $item->confKey = $confKey; - if(!empty($params['enabled'])) { + if (!empty($params['enabled'])) { $item->enabled = $params['enabled']; } - if(!empty($params['css'])){ + if (!empty($params['css'])) { $item->cssClass = $params['css']; } @@ -168,7 +171,6 @@ class formSetup{ return true; } - } @@ -226,20 +228,23 @@ class formSetupItem $this->confKey = $confKey; } - public function getHelpText(){ - if(!empty($this->helpText)){ return $this->helpText; } + public function getHelpText() + { + if (!empty($this->helpText)) { return $this->helpText; } return (($this->langs->trans($this->confKey . 'Tooltip') != $this->confKey . 'Tooltip') ? $this->langs->trans($this->confKey . 'Tooltip') : ''); } - public function getNameText(){ - if(!empty($this->nameText)){ return $this->nameText; } - return (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : $this->langs->trans('MissingTranslationForConfKey',$this->confKey)); + public function getNameText() + { + if (!empty($this->nameText)) { return $this->nameText; } + return (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : $this->langs->trans('MissingTranslationForConfKey', $this->confKey)); } - public function generateInputField(){ + public function generateInputField() + { global $conf, $user; - if(!empty($this->fieldOverride)){ + if (!empty($this->fieldOverride)) { return $this->fieldOverride; } @@ -324,23 +329,24 @@ class formSetupItem * add error * @param array|string $errors */ - public function setErrors($errors){ - if(is_array($errors)){ - if(!empty($errors)){ - foreach ($errors as $error){ + public function setErrors($errors) + { + if (is_array($errors)) { + if (!empty($errors)) { + foreach ($errors as $error) { $this->setErrors($error); } } - } - elseif(!empty($errors)){ + } elseif (!empty($errors)) { $this->errors[] = $errors; } } - public function generateOutputField(){ + public function generateOutputField() + { global $conf, $user; - if(!empty($this->fieldOverride)){ + if (!empty($this->fieldOverride)) { return $this->fieldOverride; } @@ -399,5 +405,4 @@ class formSetupItem return $out; } - } From 1e45b9b1cd5f0b6c934a3b275c225ec6d3da7e8a Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 25 Oct 2021 15:25:58 +0200 Subject: [PATCH 009/178] FIX : We need a default price base type in variant creation case with multiprices when parent has been created with only one level price --- htdocs/variants/class/ProductCombination.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index bc479b68653..10318f11a46 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -509,7 +509,7 @@ class ProductCombination for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { if ($parent->multiprices[$i] != '' || isset($this->combination_price_levels[$i]->variation_price)) { - $new_type = $parent->multiprices_base_type[$i]; + $new_type = !empty($parent->multiprices_base_type[$i]) ? $parent->multiprices_base_type[$i] : 'HT'; $new_min_price = $parent->multiprices_min[$i]; $variation_price = doubleval(!isset($this->combination_price_levels[$i]->variation_price) ? $this->variation_price : $this->combination_price_levels[$i]->variation_price); $variation_price_percentage = doubleval(!isset($this->combination_price_levels[$i]->variation_price_percentage) ? $this->variation_price_percentage : $this->combination_price_levels[$i]->variation_price_percentage); From 1683f46d9bd7142f89cd801ecd07e086f2efcd5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 25 Oct 2021 21:21:48 +0200 Subject: [PATCH 010/178] backport fix --- htdocs/main.inc.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 2e9f0558421..9753f4b3d83 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -1042,6 +1042,16 @@ if (!defined('NOLOGIN')) { //Required if advanced permissions are used with MAIN_USE_ADVANCED_PERMS if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS)) { + if (empty($user->rights->user->user_advance)) { + $user->rights->user->user_advance = new stdClass(); // To avoid warnings + } + if (empty($user->rights->user->self_advance)) { + $user->rights->user->self_advance = new stdClass(); // To avoid warnings + } + if (empty($user->rights->user->group_advance)) { + $user->rights->user->group_advance = new stdClass(); // To avoid warnings + } + $user->rights->user->user_advance->readperms = 1; $user->rights->user->user_advance->write = 1; $user->rights->user->self_advance->readperms = 1; From c998abe54e36977b8144936c4587919eff2dab21 Mon Sep 17 00:00:00 2001 From: Administrator Date: Wed, 27 Oct 2021 11:09:00 +0200 Subject: [PATCH 011/178] FIX: resource list : Use standard code to handle list filters --- htdocs/resource/list.php | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/htdocs/resource/list.php b/htdocs/resource/list.php index 033d49ae8c8..a4721b2d174 100644 --- a/htdocs/resource/list.php +++ b/htdocs/resource/list.php @@ -75,22 +75,16 @@ if ($search_type != '') { } // Add $param from extra fields -foreach ($search_array_options as $key => $val) -{ - $crit = $val; - $tmpkey = preg_replace('/search_options_/', '', $key); - $typ = $extrafields->attributes[$object->table_element]['type'][$tmpkey]; - if ($val != '') { - $param .= '&search_options_'.$tmpkey.'='.urlencode($val); - } - $mode_search = 0; - if (in_array($typ, array('int', 'double', 'real'))) $mode_search = 1; // Search on a numeric - if (in_array($typ, array('sellist', 'link')) && $crit != '0' && $crit != '-1') $mode_search = 2; // Search on a foreign key int - if ($crit != '' && (!in_array($typ, array('select', 'sellist')) || $crit != '0') && (!in_array($typ, array('link')) || $crit != '-1')) - { - $filter['ef.'.$tmpkey] = natural_search('ef.'.$tmpkey, $crit, $mode_search); - } -} +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php'; +$sql= null; +include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; + +// Including the previous script generate the correct SQL filter for all the extrafields +// we are playing with the behaviour of the Dolresource::fetch_all() by generating a fake +// extrafields filter key to make it works +$filter['ef.resource'] = $sql; + + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); From 3a862212905ceebf3a1de29b33dd1abede9ae25f Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Sat, 30 Oct 2021 12:54:13 +0200 Subject: [PATCH 012/178] add more customisation --- htdocs/core/class/html.formsetup.class.php | 327 +++++++++++++----- htdocs/modulebuilder/template/admin/setup.php | 28 +- 2 files changed, 272 insertions(+), 83 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 27b0e3fb615..f781afe0079 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -19,7 +19,8 @@ /** * This class help you create setup render */ -class formSetup{ +class formSetup +{ /** * @var DoliDB Database handler. @@ -27,7 +28,7 @@ class formSetup{ public $db; /** @var formSetupItem[] */ - public $arrayOfParameters = array(); + public $params = array(); public $setupNotEmpty = 0; @@ -37,10 +38,12 @@ class formSetup{ /** @var Form */ public $form; + /** * Constructor * - * @param DoliDB $db Database handler + * @param DoliDB $db Database handler + * @param Translate $outputLangs if needed can use another lang */ public function __construct($db, $outputLangs = false) { @@ -48,41 +51,53 @@ class formSetup{ $this->db = $db; $this->form = new Form($this->db); - if($outputLangs){ + if ($outputLangs) { $this->langs = $outputLangs; - } - else{ + } else { $this->langs = $langs; } } /** + * @param bool $editMode true will display output on edit mod * @return string */ - public function generateOutput($edit = false){ + public function generateOutput($editMode = false) + { + $out = ''; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - $out = ''; + $out.= ''; + if ($editMode) { + $out .= ''; + } + + $out.= '
    '; + $out.= ''; $out.= ''; $out.= ' '; $out.= ' '; $out.= ''; + $out.= ''; - foreach ($this->arrayOfParameters as $item) { - $out.= $this->generateLineOutput($item, $edit); + $out.= ''; + foreach ($this->params as $item) { + $out.= $this->generateLineOutput($item, $editMode); } + $out.= ''; $out.= '
    '.$this->langs->trans("Parameter").''.$this->langs->trans("Value").'
    '; return $out; } /** - * @param formSetupItem $item - * @param bool $edit - * @return string + * @param formSetupItem $item the setup item + * @param bool $editMode Display as edit mod + * @return string the html output for an setup item */ - public function generateLineOutput($item, $edit = false){ + public function generateLineOutput($item, $editMode = false) + { $out = ''; if ($item->enabled==1) { @@ -97,14 +112,13 @@ class formSetup{ $out.= ''; - if($edit){ + if ($editMode) { $out.= $item->generateInputField(); - } - else{ + } else { $out.= $item->generateOutputField(); } - if(!empty($item->errors)){ + if (!empty($item->errors)) { // TODO : move set event message in a methode to be called by cards not by this class setEventMessages(null, $item->errors, 'errors'); } @@ -118,14 +132,14 @@ class formSetup{ /** - * @param string $confKey - * @param array $params - * @ + * @param array $params an array of arrays of params from old modulBuilder params + * @deprecated was used to test module builder convertion to this form usage + * @return null */ - public function addItemsFromParamsArray($params){ - - if(!array($params)){ return false; } - foreach ($params as $confKey => $param){ + public function addItemsFromParamsArray($params) + { + if (!array($params)) { return false; } + foreach ($params as $confKey => $param) { $this->addItemFromParams($confKey, $param); // todo manage error } } @@ -133,12 +147,14 @@ class formSetup{ /** * From old - * @param string $confKey - * @param array $params + * @param string $confKey the conf name to store + * @param array $params an array of params from old modulBuilder params + * @deprecated was used to test module builder convertion to this form usage + * @return bool */ - public function addItemFromParams($confKey, $params){ - - if(empty($confKey) || empty($params['type'])){ return false; } + public function addItemFromParams($confKey, $params) + { + if (empty($confKey) || empty($params['type'])) { return false; } /* * Exemple from old module builder setup page @@ -152,26 +168,56 @@ class formSetup{ //'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1), */ - $item = new formSetupItem($this->db); + $item = new formSetupItem($confKey); $item->type = $params['type']; - $item->confKey = $confKey; - if(!empty($params['enabled'])) { + if (!empty($params['enabled'])) { $item->enabled = $params['enabled']; } - if(!empty($params['css'])){ + if (!empty($params['css'])) { $item->cssClass = $params['css']; } - $this->arrayOfParameters[$item->confKey] = $item; + $this->params[$item->confKey] = $item; return true; } + /** + * Reload for each item default conf + * note: this will override custom configuration + * @return bool + */ + public function reloadConfs() + { + + if (!array($this->params)) { return false; } + foreach ($this->params as $item) { + $item->reloadConf(); + } + + return true; + } + + + + /** + * Create a new item + * @param $confKey the conf key used in database + * @return formSetupItem the new setup item created + */ + public function newItem($confKey) + { + $item = new formSetupItem($confKey); + $this->params[$item->confKey] = $item; + return $this->params[$item->confKey]; + } } - +/** + * This class help to create item for class formSetup + */ class formSetupItem { /** @@ -194,67 +240,108 @@ class formSetupItem /** @var string $helpText */ public $helpText = ''; - /** @var bool|string set this var to override field output */ + /** @var string $value */ + public $fieldValue; + + /** @var bool|string set this var to override field output will override $fieldInputOverride and $fieldOutputOverride too */ public $fieldOverride = false; + /** @var bool|string set this var to override field output */ + public $fieldInputOverride = false; + + /** @var bool|string set this var to override field output */ + public $fieldOutputOverride = false; + /** * @var string $errors */ public $errors = array(); /** + * TODO each type must have setAs{type} method to help configuration + * And set var as protected when its done configuration must be done by method * @var string $type 'string', 'textarea', 'category:'.Categorie::TYPE_CUSTOMER', 'emailtemplate', 'thirdparty_type' */ - public $type; + public $type = 'string'; - public $enabled = 0; + public $enabled = 1; public $cssClass = ''; /** * Constructor * - * @param $confKey + * @param $confKey the conf key used in database */ public function __construct($confKey) { - global $langs, $db; + global $langs, $db, $conf; $this->db = $db; $this->form = new Form($this->db); $this->langs = $langs; $this->confKey = $confKey; + $this->fieldValue = $conf->global->{$this->confKey}; } - public function getHelpText(){ - if(!empty($this->helpText)){ return $this->helpText; } + /** + * reload conf value from databases + * @return null + */ + public function reloadConf() + { + global $conf; + $this->fieldValue = $conf->global->{$this->confKey}; + } + + /** + * Get help text or generate it + * @return int|string + */ + public function getHelpText() + { + if (!empty($this->helpText)) { return $this->helpText; } return (($this->langs->trans($this->confKey . 'Tooltip') != $this->confKey . 'Tooltip') ? $this->langs->trans($this->confKey . 'Tooltip') : ''); } - public function getNameText(){ - if(!empty($this->nameText)){ return $this->nameText; } - return (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : $this->langs->trans('MissingTranslationForConfKey',$this->confKey)); + /** + * Get field name text or generate it + * @return false|int|string + */ + public function getNameText() + { + if (!empty($this->nameText)) { return $this->nameText; } + return (($this->langs->trans($this->confKey) != $this->confKey) ? $this->langs->trans($this->confKey) : $this->langs->trans('MissingTranslationForConfKey', $this->confKey)); } - public function generateInputField(){ + /** + * generate input field + * @return bool|string + */ + public function generateInputField() + { global $conf, $user; - if(!empty($this->fieldOverride)){ + if (!empty($this->fieldOverride)) { return $this->fieldOverride; } + if (!empty($this->fieldInputOverride)) { + return $this->fieldInputOverride; + } + $out = ''; if ($this->type == 'textarea') { $out.= '\n"; } elseif ($this->type== 'html') { require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($this->confKey, $conf->global->{$this->confKey}, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); + $doleditor = new DolEditor($this->confKey, $this->fieldValue, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); $doleditor->Create(); } elseif ($this->type == 'yesno') { - $out.= $this->form->selectyesno($this->confKey, $conf->global->{$this->confKey}, 1); + $out.= $this->form->selectyesno($this->confKey, $this->fieldValue, 1); } elseif (preg_match('/emailtemplate:/', $this->type)) { include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; $formmail = new FormMail($this->db); @@ -274,7 +361,7 @@ class formSetupItem $arrayOfMessageName[$modelMail->id] = $this->langs->trans(preg_replace('/\(|\)/', '', $modelMail->label)) . $moreonlabel; } } - $out.= $this->form->selectarray($this->confKey, $arrayOfMessageName, $conf->global->{$this->confKey}, 'None', 0, 0, '', 0, 0, 0, '', '', 1); + $out.= $this->form->selectarray($this->confKey, $arrayOfMessageName, $this->fieldValue, 'None', 0, 0, '', 0, 0, 0, '', '', 1); } elseif (preg_match('/category:/', $this->type)) { require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; @@ -282,13 +369,13 @@ class formSetupItem $tmp = explode(':', $this->type); $out.= img_picto('', 'category', 'class="pictofixedwidth"'); - $out.= $formother->select_categories($tmp[1], $conf->global->{$this->confKey}, $this->confKey, 0, $this->langs->trans('CustomersProspectsCategoriesShort')); + $out.= $formother->select_categories($tmp[1], $this->fieldValue, $this->confKey, 0, $this->langs->trans('CustomersProspectsCategoriesShort')); } elseif (preg_match('/thirdparty_type/', $this->type)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $formcompany = new FormCompany($this->db); - $out.= $formcompany->selectProspectCustomerType($conf->global->{$this->confKey}, $this->confKey); + $out.= $formcompany->selectProspectCustomerType($this->fieldValue, $this->confKey); } elseif ($this->type == 'securekey') { - $out.= ''; + $out.= ''; if (!empty($conf->use_javascript_ajax)) { $out.= ' '.img_picto($this->langs->trans('Generate'), 'refresh', 'id="generate_token'.$this->confKey.'" class="linkobject"'); } @@ -309,11 +396,11 @@ class formSetupItem } } elseif ($this->type == 'product') { if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { - $selected = (empty($conf->global->{$this->confKey}) ? '' : $conf->global->{$this->confKey}); + $selected = (empty($this->fieldValue) ? '' : $this->fieldValue); $this->form->select_produits($selected, $this->confKey, '', 0); } } else { - $out.= ''; + $out.= ''; } return $out; @@ -321,35 +408,44 @@ class formSetupItem /** - * add error - * @param array|string $errors + * Add error + * @param array|string $errors the error text + * @return null */ - public function setErrors($errors){ - if(is_array($errors)){ - if(!empty($errors)){ - foreach ($errors as $error){ + public function setErrors($errors) + { + if (is_array($errors)) { + if (!empty($errors)) { + foreach ($errors as $error) { $this->setErrors($error); } } - } - elseif(!empty($errors)){ + } elseif (!empty($errors)) { $this->errors[] = $errors; } } - public function generateOutputField(){ + /** + * @return bool|string Generate the output html for this item + */ + public function generateOutputField() + { global $conf, $user; - if(!empty($this->fieldOverride)){ + if (!empty($this->fieldOverride)) { return $this->fieldOverride; } + if (!empty($this->fieldOutputOverride)) { + return $this->fieldOutputOverride; + } + $out = ''; if ($this->type == 'textarea') { - $out.= dol_nl2br($conf->global->{$this->confKey}); + $out.= dol_nl2br($this->fieldValue); } elseif ($this->type== 'html') { - $out.= $conf->global->{$this->confKey}; + $out.= $this->fieldValue; } elseif ($this->type == 'yesno') { $out.= ajax_constantonoff($this->confKey); } elseif (preg_match('/emailtemplate:/', $this->type)) { @@ -358,14 +454,14 @@ class formSetupItem $tmp = explode(':', $this->type); - $template = $formmail->getEMailTemplate($this->db, $tmp[1], $user, $this->langs, $conf->global->{$this->confKey}); + $template = $formmail->getEMailTemplate($this->db, $tmp[1], $user, $this->langs, $this->fieldValue); if ($template<0) { $this->setErrors($formmail->errors); } $out.= $this->langs->trans($template->label); } elseif (preg_match('/category:/', $this->type)) { $c = new Categorie($this->db); - $result = $c->fetch($conf->global->{$this->confKey}); + $result = $c->fetch($this->fieldValue); if ($result < 0) { $this->setErrors($c->errors); } @@ -376,28 +472,105 @@ class formSetupItem } $out.= '
      ' . implode(' ', $toprint) . '
    '; } elseif (preg_match('/thirdparty_type/', $this->type)) { - if ($conf->global->{$this->confKey}==2) { + if ($this->fieldValue==2) { $out.= $this->langs->trans("Prospect"); - } elseif ($conf->global->{$this->confKey}==3) { + } elseif ($this->fieldValue==3) { $out.= $this->langs->trans("ProspectCustomer"); - } elseif ($conf->global->{$this->confKey}==1) { + } elseif ($this->fieldValue==1) { $out.= $this->langs->trans("Customer"); - } elseif ($conf->global->{$this->confKey}==0) { + } elseif ($this->fieldValue==0) { $out.= $this->langs->trans("NorProspectNorCustomer"); } } elseif ($this->type == 'product') { $product = new Product($this->db); - $resprod = $product->fetch($conf->global->{$this->confKey}); + $resprod = $product->fetch($this->fieldValue); if ($resprod > 0) { $out.= $product->ref; } elseif ($resprod < 0) { $this->setErrors($product->errors); } } else { - $out.= $conf->global->{$this->confKey}; + $out.= $this->fieldValue; } return $out; } + /* + * METHODS FOR SETTING DISPLAY TYPE + */ + + /** + * Set type of input as string + * @return null + */ + public function setAsString() + { + $this->type = 'string'; + } + + /** + * Set type of input as textarea + * @return null + */ + public function setAsTextarea() + { + $this->type = 'textarea'; + } + + /** + * Set type of input as html editor + * @return null + */ + public function setAsHtml() + { + $this->type = 'html'; + } + + /** + * Set type of input as emailtemplate selector + * @return null + */ + public function setAsEmailTemplate() + { + $this->type = 'emailtemplate'; + } + + /** + * Set type of input as thirdparty_type selector + * @return null + */ + public function setAsThirdpartyType() + { + $this->type = 'thirdparty_type'; + } + + /** + * Set type of input as Yes + * @return null + */ + public function setAsYesNo() + { + $this->type = 'yesno'; + } + + /** + * Set type of input as secure key + * @return null + */ + public function setAsSecureKey() + { + $this->type = 'securekey'; + } + + /** + * Set type of input as a category selector + * TODO add default value + * @param int $catType Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated. + * @return null + */ + public function setAsCategory($catType) + { + $this->type = 'category:'.$catType; + } } diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 390f45d955c..e3e32cf6f6b 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -85,6 +85,27 @@ $arrayofparameters = array( //'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1), ); +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; +$formSetup = new formSetup($db); + +$formSetup->addItemsFromParamsArray($arrayofparameters); + +// Hôte +$item = $formSetup->newItem('GPC_HOST'); +$item->fieldOverride = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST']; + +// Setup conf MYMODULE_MYPARAM1 as a simple string input +$item = $formSetup->newItem('MYMODULE_MYPARAM1'); + +// // Setup conf MYMODULE_MYPARAM1 as a simple textarea input but we replace the text of field title +$item = $formSetup->newItem('MYMODULE_MYPARAM2'); +$item->nameText = $item->getNameText().' https://console.developers.google.com/apis/credentials'; + +// Clé pour API : Client Secret +$formSetup->newItem('GPC_GOOGLE_CLIENT_SECRET'); + + + $error = 0; $setupnotempty = 0; @@ -97,6 +118,7 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); if ((float) DOL_VERSION >= 6) { include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + $formSetup->reloadConfs(); } if ($action == 'updateMask') { @@ -222,11 +244,6 @@ print dol_get_fiche_head($head, 'settings', $langs->trans($page_name), -1, "mymo echo ''.$langs->trans("MyModuleSetupPage").'

    '; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; -$formSetup = new formSetup($db); - -$formSetup->addItemsFromParamsArray($arrayofparameters); - if ($action == 'edit') { print ''; print ''; @@ -242,7 +259,6 @@ if ($action == 'edit') { print '
    '; } else { if (!empty($arrayofparameters)) { - print $formSetup->generateOutput(); print '
    '; From 5179f2c90b26fab6bbd0ed121ff68f3ff7d7b22f Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Sat, 30 Oct 2021 13:03:23 +0200 Subject: [PATCH 013/178] Add demo data --- htdocs/modulebuilder/template/admin/setup.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index e3e32cf6f6b..f7f30c19228 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -90,8 +90,9 @@ $formSetup = new formSetup($db); $formSetup->addItemsFromParamsArray($arrayofparameters); + // Hôte -$item = $formSetup->newItem('GPC_HOST'); +$item = $formSetup->newItem('NO_PARAM_JUST_TEXT'); $item->fieldOverride = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST']; // Setup conf MYMODULE_MYPARAM1 as a simple string input @@ -99,12 +100,15 @@ $item = $formSetup->newItem('MYMODULE_MYPARAM1'); // // Setup conf MYMODULE_MYPARAM1 as a simple textarea input but we replace the text of field title $item = $formSetup->newItem('MYMODULE_MYPARAM2'); -$item->nameText = $item->getNameText().' https://console.developers.google.com/apis/credentials'; - -// Clé pour API : Client Secret -$formSetup->newItem('GPC_GOOGLE_CLIENT_SECRET'); +$item->nameText = $item->getNameText().' more html text '; +// Setup conf MYMODULE_MYPARAM3 +$item = $formSetup->newItem('MYMODULE_MYPARAM3'); +$item->setAsThirdpartyType(); + +// Setup conf MYMODULE_MYPARAM4 : quick define write style +$formSetup->newItem('MYMODULE_MYPARAM4')->setAsYesNo(); $error = 0; $setupnotempty = 0; From cdf1538ffacac651367a423cffce3b83d0c93ec9 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Sat, 30 Oct 2021 16:36:51 +0200 Subject: [PATCH 014/178] fix save using template --- htdocs/core/class/html.formsetup.class.php | 59 +++++++++++++++---- htdocs/modulebuilder/template/admin/setup.php | 19 +++++- 2 files changed, 64 insertions(+), 14 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index f229d12101d..eb5a9710da1 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -183,6 +183,24 @@ class formSetup return true; } + /** + * used to export param array for /core/actions_setmoduleoptions.inc.php template + * @return array $arrayofparameters for /core/actions_setmoduleoptions.inc.php + * @deprecated + */ + public function exportItemsAsParamsArray() + { + $arrayofparameters = array(); + foreach ($this->params as $key => $item) { + $arrayofparameters[$item->confKey] = array( + 'type' => $item->type, + 'enabled' => $item->enabled + ); + } + + return $arrayofparameters; + } + /** * Reload for each item default conf * note: this will override custom configuration @@ -396,7 +414,7 @@ class formSetupItem } elseif ($this->type == 'product') { if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $selected = (empty($this->fieldValue) ? '' : $this->fieldValue); - $this->form->select_produits($selected, $this->confKey, '', 0); + $out.= $this->form->select_produits($selected, $this->confKey, '', 0, 0, 1, 2, '', 0, array(), 0, '1', 0, $this->cssClass, 0, '', null, 1); } } else { $out.= ''; @@ -501,75 +519,94 @@ class formSetupItem /** * Set type of input as string - * @return null + * @return self */ public function setAsString() { $this->type = 'string'; + return $this; } /** * Set type of input as textarea - * @return null + * @return self */ public function setAsTextarea() { $this->type = 'textarea'; + return $this; } /** * Set type of input as html editor - * @return null + * @return self */ public function setAsHtml() { $this->type = 'html'; + return $this; } /** * Set type of input as emailtemplate selector - * @return null + * @param string $templateType email template type + * @return self */ - public function setAsEmailTemplate() + public function setAsEmailTemplate($templateType) { - $this->type = 'emailtemplate'; + $this->type = 'emailtemplate:'.$templateType; + return $this; } /** * Set type of input as thirdparty_type selector - * @return null + * @return self */ public function setAsThirdpartyType() { $this->type = 'thirdparty_type'; + return $this; } /** * Set type of input as Yes - * @return null + * @return self */ public function setAsYesNo() { $this->type = 'yesno'; + return $this; } /** * Set type of input as secure key - * @return null + * @return self */ public function setAsSecureKey() { $this->type = 'securekey'; + return $this; + } + + /** + * Set type of input as product + * @return self + */ + public function setAsProduct() + { + $this->type = 'product'; + return $this; } /** * Set type of input as a category selector * TODO add default value * @param int $catType Type of category ('customer', 'supplier', 'contact', 'product', 'member'). Old mode (0, 1, 2, ...) is deprecated. - * @return null + * @return self */ public function setAsCategory($catType) { $this->type = 'category:'.$catType; + return $this; } } diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index f7f30c19228..007e9d84b12 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -94,22 +94,33 @@ $formSetup->addItemsFromParamsArray($arrayofparameters); // Hôte $item = $formSetup->newItem('NO_PARAM_JUST_TEXT'); $item->fieldOverride = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST']; +$item->cssClass = 'minwidth500'; + // Setup conf MYMODULE_MYPARAM1 as a simple string input $item = $formSetup->newItem('MYMODULE_MYPARAM1'); -// // Setup conf MYMODULE_MYPARAM1 as a simple textarea input but we replace the text of field title +// Setup conf MYMODULE_MYPARAM1 as a simple textarea input but we replace the text of field title $item = $formSetup->newItem('MYMODULE_MYPARAM2'); $item->nameText = $item->getNameText().' more html text '; - // Setup conf MYMODULE_MYPARAM3 $item = $formSetup->newItem('MYMODULE_MYPARAM3'); $item->setAsThirdpartyType(); -// Setup conf MYMODULE_MYPARAM4 : quick define write style +// Setup conf MYMODULE_MYPARAM4 : exemple of quick define write style $formSetup->newItem('MYMODULE_MYPARAM4')->setAsYesNo(); +// Setup conf MYMODULE_MYPARAM5 +$formSetup->newItem('MYMODULE_MYPARAM5')->setAsEmailTemplate('thirdparty'); + +// Setup conf MYMODULE_MYPARAM6 +$formSetup->newItem('MYMODULE_MYPARAM6')->setAsSecureKey()->enabled = 0; // disabled + +// Setup conf MYMODULE_MYPARAM7 +$formSetup->newItem('MYMODULE_MYPARAM7')->setAsProduct(); + + $error = 0; $setupnotempty = 0; @@ -121,6 +132,8 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); */ if ((float) DOL_VERSION >= 6) { + // TODO Add save setup by formSetup + $arrayofparameters = $formSetup->exportItemsAsParamsArray(); include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; $formSetup->reloadConfs(); } From ca766c2e712a2e6e50b1e078541da8e0b70ee642 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Sun, 31 Oct 2021 09:29:20 +0100 Subject: [PATCH 015/178] Factoring --- htdocs/core/class/html.formsetup.class.php | 73 +++++++++++++++++----- 1 file changed, 59 insertions(+), 14 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index eb5a9710da1..219308bd5e6 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -63,11 +63,9 @@ class formSetup */ public function generateOutput($editMode = false) { - - $out = ''; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - $out.= ''; + $out = ''; if ($editMode) { $out .= ''; } @@ -168,7 +166,7 @@ class formSetup */ $item = new formSetupItem($confKey); - $item->type = $params['type']; + $item->setTypeFromTypeString($params['type']); if (!empty($params['enabled'])) { $item->enabled = $params['enabled']; @@ -186,7 +184,7 @@ class formSetup /** * used to export param array for /core/actions_setmoduleoptions.inc.php template * @return array $arrayofparameters for /core/actions_setmoduleoptions.inc.php - * @deprecated + * @deprecated yes this method came deprecated because it exists only for manage setup convertion */ public function exportItemsAsParamsArray() { @@ -279,7 +277,7 @@ class formSetupItem * And set var as protected when its done configuration must be done by method * @var string $type 'string', 'textarea', 'category:'.Categorie::TYPE_CUSTOMER', 'emailtemplate', 'thirdparty_type' */ - public $type = 'string'; + protected $type = 'string'; public $enabled = 1; @@ -349,14 +347,12 @@ class formSetupItem $out = ''; - if ($this->type == 'textarea') { - $out.= '\n"; + if ($this->type == 'title') { + $out.= $this->generateOutputField(); // title have no input + } elseif ($this->type == 'textarea') { + $out.= $this->generateInputFieldTextarea(); } elseif ($this->type== 'html') { - require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; - $doleditor = new DolEditor($this->confKey, $this->fieldValue, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); - $doleditor->Create(); + $out.= $this->generateInputFieldHtml(); } elseif ($this->type == 'yesno') { $out.= $this->form->selectyesno($this->confKey, $this->fieldValue, 1); } elseif (preg_match('/emailtemplate:/', $this->type)) { @@ -423,6 +419,42 @@ class formSetupItem return $out; } + /** + * generate input field for textarea + * @return string + */ + public function generateInputFieldTextarea() + { + $out = '\n"; + return $out; + } + /** + * generate input field for html + * @return string + */ + public function generateInputFieldHtml() + { + global $conf; + require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php'; + $doleditor = new DolEditor($this->confKey, $this->fieldValue, '', 160, 'dolibarr_notes', '', false, false, $conf->fckeditor->enabled, ROWS_5, '90%'); + return $doleditor->Create(1); + } + + /** + * set the type from string : used for old module builder setup conf style conversion and tests + * because this two class will quickly evolve it's important to not set directly $this->type (will be protected) so this method exist + * to be sure we can manage evolution easily + * @param string $type possible values based on old module builder setup : 'string', 'textarea', 'category:'.Categorie::TYPE_CUSTOMER', 'emailtemplate', 'thirdparty_type' + * @deprecated yes this method came deprecated because it exists only for manage setup convertion + * @return bool + */ + public function setTypeFromTypeString($type) + { + $this->type = $type; + return true; + } /** * Add error @@ -459,7 +491,9 @@ class formSetupItem $out = ''; - if ($this->type == 'textarea') { + if ($this->type == 'title') { + // nothing to do + } elseif ($this->type == 'textarea') { $out.= dol_nl2br($this->fieldValue); } elseif ($this->type== 'html') { $out.= $this->fieldValue; @@ -609,4 +643,15 @@ class formSetupItem $this->type = 'category:'.$catType; return $this; } + + /** + * Set type of input as a simple title + * no data to store + * @return self + */ + public function setAsTitle() + { + $this->type = 'title'; + return $this; + } } From cee573cf96094cee86453f0553cb542573d502dd Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 31 Oct 2021 17:42:43 +0100 Subject: [PATCH 016/178] Update ProductCombination.class.php --- htdocs/variants/class/ProductCombination.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 10318f11a46..336503056f9 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -509,7 +509,7 @@ class ProductCombination for ($i = 1; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) { if ($parent->multiprices[$i] != '' || isset($this->combination_price_levels[$i]->variation_price)) { - $new_type = !empty($parent->multiprices_base_type[$i]) ? $parent->multiprices_base_type[$i] : 'HT'; + $new_type = empty($parent->multiprices_base_type[$i]) ? 'HT' : $parent->multiprices_base_type[$i]; $new_min_price = $parent->multiprices_min[$i]; $variation_price = doubleval(!isset($this->combination_price_levels[$i]->variation_price) ? $this->variation_price : $this->combination_price_levels[$i]->variation_price); $variation_price_percentage = doubleval(!isset($this->combination_price_levels[$i]->variation_price_percentage) ? $this->variation_price_percentage : $this->combination_price_levels[$i]->variation_price_percentage); From 39777d4cc5a589c2028bfb56d1a4f00296d36f6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Mon, 1 Nov 2021 09:37:07 +0100 Subject: [PATCH 017/178] fix error --- htdocs/core/modules/printing/modules_printing.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/printing/modules_printing.php b/htdocs/core/modules/printing/modules_printing.php index 41a87cb2704..1bbf78df022 100644 --- a/htdocs/core/modules/printing/modules_printing.php +++ b/htdocs/core/modules/printing/modules_printing.php @@ -69,7 +69,7 @@ class PrintingDriver $listoffiles = array(); $dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']); foreach ($dirmodels as $dir) { - $tmpfiles = dol_dir_list(dol_buildpath($dir, 0), 'all', 0, '\modules.php', '', 'name', SORT_ASC, 0); + $tmpfiles = dol_dir_list(dol_buildpath($dir, 0), 'all', 0, '.modules.php', '', 'name', SORT_ASC, 0); if (!empty($tmpfiles)) { $listoffiles = array_merge($listoffiles, $tmpfiles); } From 4c016cc3be9fe59716d703c415648728711bc192 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Mon, 1 Nov 2021 10:11:43 +0100 Subject: [PATCH 018/178] integrate fix from V14 --- htdocs/core/class/html.formsetup.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 219308bd5e6..a7df249e44c 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -447,7 +447,7 @@ class formSetupItem * because this two class will quickly evolve it's important to not set directly $this->type (will be protected) so this method exist * to be sure we can manage evolution easily * @param string $type possible values based on old module builder setup : 'string', 'textarea', 'category:'.Categorie::TYPE_CUSTOMER', 'emailtemplate', 'thirdparty_type' - * @deprecated yes this method came deprecated because it exists only for manage setup convertion + * @deprecated yes this setTypeFromTypeString came deprecated because it exists only for manage setup convertion * @return bool */ public function setTypeFromTypeString($type) @@ -521,7 +521,7 @@ class formSetupItem foreach ($ways as $way) { $toprint[] = '
  • color ? ' style="background: #' . $c->color . ';"' : ' style="background: #bbb"') . '>' . $way . '
  • '; } - $out.= '
      ' . implode(' ', $toprint) . '
    '; + $out.='
      ' . implode(' ', $toprint) . '
    '; } elseif (preg_match('/thirdparty_type/', $this->type)) { if ($this->fieldValue==2) { $out.= $this->langs->trans("Prospect"); From ea641b707d17a0ca44c2aefc4838453e0e7eee9f Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Mon, 1 Nov 2021 10:32:37 +0100 Subject: [PATCH 019/178] Factoring --- htdocs/core/class/html.formsetup.class.php | 141 ++++++++++++++------- 1 file changed, 95 insertions(+), 46 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index a7df249e44c..df99b6cdbbb 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -191,7 +191,7 @@ class formSetup $arrayofparameters = array(); foreach ($this->params as $key => $item) { $arrayofparameters[$item->confKey] = array( - 'type' => $item->type, + 'type' => $item->getType(), 'enabled' => $item->enabled ); } @@ -356,57 +356,15 @@ class formSetupItem } elseif ($this->type == 'yesno') { $out.= $this->form->selectyesno($this->confKey, $this->fieldValue, 1); } elseif (preg_match('/emailtemplate:/', $this->type)) { - include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; - $formmail = new FormMail($this->db); - - $tmp = explode(':', $this->type); - $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang - //$arraydefaultmessage = $formmail->getEMailTemplate($db, $tmp[1], $user, null, 0, 1, ''); - $arrayOfMessageName = array(); - if (is_array($formmail->lines_model)) { - foreach ($formmail->lines_model as $modelMail) { - //var_dump($modelmail); - $moreonlabel = ''; - if (!empty($arrayOfMessageName[$modelMail->label])) { - $moreonlabel = ' (' . $this->langs->trans("SeveralLangugeVariatFound") . ')'; - } - // The 'label' is the key that is unique if we exclude the language - $arrayOfMessageName[$modelMail->id] = $this->langs->trans(preg_replace('/\(|\)/', '', $modelMail->label)) . $moreonlabel; - } - } - $out.= $this->form->selectarray($this->confKey, $arrayOfMessageName, $this->fieldValue, 'None', 0, 0, '', 0, 0, 0, '', '', 1); + $out.= $this->generateInputFieldEmailTemplate(); } elseif (preg_match('/category:/', $this->type)) { - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; - $formother = new FormOther($this->db); - - $tmp = explode(':', $this->type); - $out.= img_picto('', 'category', 'class="pictofixedwidth"'); - $out.= $formother->select_categories($tmp[1], $this->fieldValue, $this->confKey, 0, $this->langs->trans('CustomersProspectsCategoriesShort')); + $out.=$this->generateInputFieldCategories(); } elseif (preg_match('/thirdparty_type/', $this->type)) { require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $formcompany = new FormCompany($this->db); $out.= $formcompany->selectProspectCustomerType($this->fieldValue, $this->confKey); } elseif ($this->type == 'securekey') { - $out.= ''; - if (!empty($conf->use_javascript_ajax)) { - $out.= ' '.img_picto($this->langs->trans('Generate'), 'refresh', 'id="generate_token'.$this->confKey.'" class="linkobject"'); - } - if (!empty($conf->use_javascript_ajax)) { - $out.= "\n".''; - } + $out.= $this->generateInputFieldSecureKey(); } elseif ($this->type == 'product') { if (!empty($conf->product->enabled) || !empty($conf->service->enabled)) { $selected = (empty($this->fieldValue) ? '' : $this->fieldValue); @@ -430,6 +388,7 @@ class formSetupItem $out.= "\n"; return $out; } + /** * generate input field for html * @return string @@ -442,6 +401,96 @@ class formSetupItem return $doleditor->Create(1); } + /** + * generate input field for categories + * @return string + */ + public function generateInputFieldCategories() + { + global $conf; + require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; + $formother = new FormOther($this->db); + + $tmp = explode(':', $this->type); + $out= img_picto('', 'category', 'class="pictofixedwidth"'); + $out.= $formother->select_categories($tmp[1], $this->fieldValue, $this->confKey, 0, $this->langs->trans('CustomersProspectsCategoriesShort')); + return $out; + } + + /** + * generate input field for email template selector + * @return string + */ + public function generateInputFieldEmailTemplate() + { + global $conf, $user; + $out = ''; + if (preg_match('/emailtemplate:/', $this->type)) { + include_once DOL_DOCUMENT_ROOT . '/core/class/html.formmail.class.php'; + $formmail = new FormMail($this->db); + + $tmp = explode(':', $this->type); + $nboftemplates = $formmail->fetchAllEMailTemplate($tmp[1], $user, null, 1); // We set lang=null to get in priority record with no lang + $arrayOfMessageName = array(); + if (is_array($formmail->lines_model)) { + foreach ($formmail->lines_model as $modelMail) { + $moreonlabel = ''; + if (!empty($arrayOfMessageName[$modelMail->label])) { + $moreonlabel = ' (' . $this->langs->trans("SeveralLangugeVariatFound") . ')'; + } + // The 'label' is the key that is unique if we exclude the language + $arrayOfMessageName[$modelMail->id] = $this->langs->trans(preg_replace('/\(|\)/', '', $modelMail->label)) . $moreonlabel; + } + } + $out .= $this->form->selectarray($this->confKey, $arrayOfMessageName, $this->fieldValue, 'None', 0, 0, '', 0, 0, 0, '', '', 1); + } + + return $out; + } + + + /** + * generate input field for secure key + * @return string + */ + public function generateInputFieldSecureKey() + { + global $conf; + $out = ''; + if (!empty($conf->use_javascript_ajax)) { + $out.= ' '.img_picto($this->langs->trans('Generate'), 'refresh', 'id="generate_token'.$this->confKey.'" class="linkobject"'); + } + if (!empty($conf->use_javascript_ajax)) { + $out .= "\n" . ''; + } + return $out; + } + + /** + * get the type : used for old module builder setup conf style conversion and tests + * because this two class will quickly evolve it's important to not set or get directly $this->type (will be protected) so this method exist + * to be sure we can manage evolution easily + * + * @return string + */ + public function getType() + { + return $this->type; + } + /** * set the type from string : used for old module builder setup conf style conversion and tests * because this two class will quickly evolve it's important to not set directly $this->type (will be protected) so this method exist From 772c3eb43ab784f9154bd57cab7b180a89dc2148 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 1 Nov 2021 11:13:44 +0100 Subject: [PATCH 020/178] Works on ldap password hash type --- htdocs/admin/ldap.php | 15 ++++++++++++--- htdocs/core/class/ldap.class.php | 13 +++++-------- htdocs/langs/en_US/ldap.lang | 2 ++ 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index 4010d724c1a..1b93ada1119 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004 Rodolphe Quiedeville * Copyright (C) 2004 Sebastien Di Cintio * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2005-2017 Regis Houssin + * Copyright (C) 2005-2021 Regis Houssin * Copyright (C) 2006-2020 Laurent Destailleur * Copyright (C) 2011-2013 Juanjo Menent * @@ -29,10 +29,11 @@ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/ldap.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formldap.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/ldap.lib.php'; // Load translation files required by the page -$langs->load("admin"); +$langs->loadLangs(array("admin", "ldap")); if (!$user->admin) { accessforbidden(); @@ -99,6 +100,9 @@ if (empty($reshook)) { if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_ACTIVE', GETPOST("activememberstypes", 'aZ09'), 'chaine', 0, '', $conf->entity)) { $error++; } + if (!dolibarr_set_const($db, 'LDAP_PASSWORD_HASH_TYPE', GETPOST("'LDAP_PASSWORD_HASH_TYPE'", 'aZ09'), 'chaine', 0, '', $conf->entity)) { + $error++; + } if (!$error) { $db->commit(); @@ -129,7 +133,7 @@ if (!function_exists("ldap_connect")) { $form = new Form($db); - +$formldap = new FormLdap($db); print ''; print ''; @@ -251,6 +255,11 @@ $arraylist['1'] = $langs->trans("Yes"); print $form->selectarray('usetls', $arraylist, $conf->global->LDAP_SERVER_USE_TLS); print ''.$langs->trans("LDAPServerUseTLSExample").''; +// Password hash type +print ''.$langs->trans("LDAPPasswordHashType").''; +print $formldap->selectLdapPasswordHashType(getDolGlobalString('LDAP_PASSWORD_HASH_TYPE'), 'LDAP_PASSWORD_HASH_TYPE'); +print ''.$langs->trans("LDAPPasswordHashTypeExample").''; + print ''; print ''.$langs->trans("ForANonAnonymousAccess").''; print "\n"; diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index e2ce33cc45f..0815874d71c 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -159,8 +159,6 @@ class Ldap $this->attr_mobile = $conf->global->LDAP_FIELD_MOBILE; } - - // Connection handling methods ------------------------------------------- // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -218,8 +216,9 @@ class Ldap // Upgrade connexion to TLS, if requested by the configuration if (!empty($conf->global->LDAP_SERVER_USE_TLS)) { // For test/debug - //ldap_set_option($this->connection, LDAP_OPT_DEBUG_LEVEL, 7); - //ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, 3); + ldap_set_option($this->connection, LDAP_OPT_DEBUG_LEVEL, 7); + ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, 3); + ldap_set_option($this->connection, LDAP_OPT_REFERRALS, 0); $resulttls = ldap_start_tls($this->connection); if (!$resulttls) { @@ -291,8 +290,6 @@ class Ldap return $return; } - - /** * Simply closes the connection set up earlier. * Returns true if OK, false if there was an error. @@ -906,10 +903,10 @@ class Ldap return -3; } - $search = ldap_search($this->connection, $dn, $filter); + $search = @ldap_search($this->connection, $dn, $filter); // Only one entry should ever be returned - $entry = ldap_first_entry($this->connection, $search); + $entry = @ldap_first_entry($this->connection, $search); if (!$entry) { $this->ldapErrorCode = -1; diff --git a/htdocs/langs/en_US/ldap.lang b/htdocs/langs/en_US/ldap.lang index 8b6f0864215..b13e454159d 100644 --- a/htdocs/langs/en_US/ldap.lang +++ b/htdocs/langs/en_US/ldap.lang @@ -25,3 +25,5 @@ ContactSynchronized=Contact synchronized ForceSynchronize=Force synchronizing Dolibarr -> LDAP ErrorFailedToReadLDAP=Failed to read LDAP database. Check LDAP module setup and database accessibility. PasswordOfUserInLDAP=Password of user in LDAP +LDAPPasswordHashType=Password hash type +LDAPPasswordHashTypeExample=Type of password hash used on the server \ No newline at end of file From 5be40b926b6198e638dba1e796c2114417cd75c9 Mon Sep 17 00:00:00 2001 From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com> Date: Mon, 1 Nov 2021 19:56:24 +0100 Subject: [PATCH 021/178] Clean function not use anymore --- .../class/fournisseur.commande.class.php | 44 ------------------- 1 file changed, 44 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 787d9ee321b..9cf3c74e967 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -2274,50 +2274,6 @@ class CommandeFournisseur extends CommonOrder return $ret; } - /** - * Return array of the lines that are waiting to be dispatched - * - * @return array Array of lines - */ - public function getNotCompletlyDispatchedLines() - { - $ret = array(); - - $sql = "SELECT supplierOrderDet.fk_product as product_id, supplierOrderDet.qty as qty_ordered, supplierOrderDet.fk_commande,"; - $sql .= " dispatch.rowid as dispatchedlineid, sum(dispatch.qty) as qty_dispatched"; - $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as supplierOrderDet"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as dispatch ON supplierOrderDet.rowid = dispatch.fk_commandefourndet"; - $sql .= " WHERE supplierOrderDet.fk_commande = ".((int) $this->id); - $sql .= " GROUP BY supplierOrderDet.fk_product"; - - $resql = $this->db->query($sql); - - if ($resql) { - $num = $this->db->num_rows($resql); - $i = 0; - - while ($i < $num) { - $objp = $this->db->fetch_object($resql); - - if ($objp) { - // If product not completly dispatched - if (is_null($objp->qty_dispatched) OR ($objp->qty_dispatched < $objp->qty_ordered)) { - $ret[] = array( - 'product_id' => $objp->product_id, - 'qty_ordered' => $objp->qty_ordered, - 'qty_dispatched' => $objp->qty_dispatched, - ); - } - } - $i++; - } - } else { - dol_print_error($this->db, 'Failed to execute request to get not completly dispatched lines'); - } - - return $ret; - } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set a delivery in database for this supplier order From 7b88f1da3fea112919f0c61bf9cb894323cbfbab Mon Sep 17 00:00:00 2001 From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com> Date: Mon, 1 Nov 2021 19:56:55 +0100 Subject: [PATCH 022/178] Change to have number of item dispached on number of total item --- htdocs/core/lib/fourn.lib.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index e81bdb5e9d0..7fc903db72b 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -157,12 +157,24 @@ function ordersupplier_prepare_head($object) if (!empty($conf->stock->enabled) && (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION) || !empty($conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE))) { $langs->load("stocks"); - $nbLineToDispatch = count($object->getNotCompletlyDispatchedLines()); $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id; $head[$h][1] = $langs->trans("OrderDispatch"); - if ($nbLineToDispatch > 0) { - $head[$h][1] .= ''.$nbLineToDispatch.''; + + //If dispach process running we add the number of item to dispatch into the head + if ($object->statut == '3' OR $object->statut == '4' OR $object->statut == '5') { + $lines = $object->fetch_lines(); + $dispachedLines = $object->getDispachedLines(1); + $sumQtyAllreadyDispatched = 0; + for ($line = 0 ; $line < count($dispachedLines) ; $line++) { + $sumQtyAllreadyDispatched = $sumQtyAllreadyDispatched + $dispachedLines[$line]['qty']; + } + $sumQtyOrdered = 0; + for ($line = 0 ; $line < count($object->lines) ; $line++) { + $sumQtyOrdered = $sumQtyOrdered + $object->lines[$line]->qty; + } + $head[$h][1] .= ''.$sumQtyAllreadyDispatched.' / '.$sumQtyOrdered.''; } + $head[$h][2] = 'dispatch'; $h++; } From 85372a70836d2d9cdb003cc490bd8fa17c73fc46 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 1 Nov 2021 18:57:35 +0000 Subject: [PATCH 023/178] Fixing style errors. --- htdocs/core/lib/fourn.lib.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 7fc903db72b..27ebc98635d 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -159,22 +159,22 @@ function ordersupplier_prepare_head($object) $langs->load("stocks"); $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/dispatch.php?id='.$object->id; $head[$h][1] = $langs->trans("OrderDispatch"); - + //If dispach process running we add the number of item to dispatch into the head if ($object->statut == '3' OR $object->statut == '4' OR $object->statut == '5') { $lines = $object->fetch_lines(); $dispachedLines = $object->getDispachedLines(1); $sumQtyAllreadyDispatched = 0; - for ($line = 0 ; $line < count($dispachedLines) ; $line++) { + for ($line = 0 ; $line < count($dispachedLines); $line++) { $sumQtyAllreadyDispatched = $sumQtyAllreadyDispatched + $dispachedLines[$line]['qty']; } $sumQtyOrdered = 0; - for ($line = 0 ; $line < count($object->lines) ; $line++) { + for ($line = 0 ; $line < count($object->lines); $line++) { $sumQtyOrdered = $sumQtyOrdered + $object->lines[$line]->qty; - } + } $head[$h][1] .= ''.$sumQtyAllreadyDispatched.' / '.$sumQtyOrdered.''; } - + $head[$h][2] = 'dispatch'; $h++; } From 85776f7529dbc3d969e827a82d6fcf1c1b168159 Mon Sep 17 00:00:00 2001 From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com> Date: Mon, 1 Nov 2021 20:08:00 +0100 Subject: [PATCH 024/178] Avoid function calls in a FOR loop test part --- htdocs/core/lib/fourn.lib.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 27ebc98635d..25bbd52e413 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -162,14 +162,17 @@ function ordersupplier_prepare_head($object) //If dispach process running we add the number of item to dispatch into the head if ($object->statut == '3' OR $object->statut == '4' OR $object->statut == '5') { - $lines = $object->fetch_lines(); + $object->fetch_lines(); + $nbLinesOrdered = count($object->lines); $dispachedLines = $object->getDispachedLines(1); + $nbDispachedLines = count($dispachedLines); + $sumQtyAllreadyDispatched = 0; - for ($line = 0 ; $line < count($dispachedLines); $line++) { + for ($line = 0 ; $line < $nbDispachedLines; $line++) { $sumQtyAllreadyDispatched = $sumQtyAllreadyDispatched + $dispachedLines[$line]['qty']; } $sumQtyOrdered = 0; - for ($line = 0 ; $line < count($object->lines); $line++) { + for ($line = 0 ; $line < $nbLinesOrdered; $line++) { $sumQtyOrdered = $sumQtyOrdered + $object->lines[$line]->qty; } $head[$h][1] .= ''.$sumQtyAllreadyDispatched.' / '.$sumQtyOrdered.''; From 5bb6185e64359d476954359076e64473d13591e6 Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Tue, 2 Nov 2021 12:37:39 +0100 Subject: [PATCH 025/178] add_substitution --- htdocs/core/lib/functions.lib.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 084a4a4f25a..5eb0bd7d62c 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7212,7 +7212,10 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, if ($object->id > 0) { $substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__'] = ($paymenturl ?str_replace('\n', "\n", $outputlangs->trans("PredefinedMailContentLink", $paymenturl)) : ''); $substitutionarray['__ONLINE_PAYMENT_URL__'] = $paymenturl; - + + if (is_object($object) && $object->element == 'propal') { + $substitutionarray['__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0, 'proposal', $object->ref); + } if (!empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'propal') { $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element); } else { From b98efd7e44085ff4f7bb0e9ac056139994bb7c4a Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Tue, 2 Nov 2021 13:55:12 +0100 Subject: [PATCH 026/178] Add rank item management and add Hook --- htdocs/core/class/html.formsetup.class.php | 258 ++++++++++++++++-- htdocs/modulebuilder/template/admin/setup.php | 27 +- 2 files changed, 248 insertions(+), 37 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index df99b6cdbbb..cbf8cbd37ba 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -30,6 +30,9 @@ class formSetup /** @var formSetupItem[] */ public $params = array(); + /** + * @var int + */ public $setupNotEmpty = 0; /** @var Translate */ @@ -38,6 +41,9 @@ class formSetup /** @var Form */ public $form; + /** @var int */ + protected $maxItemRank; + /** * Constructor * @@ -63,29 +69,81 @@ class formSetup */ public function generateOutput($editMode = false) { + global $hookmanager, $action; require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; - $out = ''; - if ($editMode) { - $out .= ''; + $parameters = array( + 'editMode' => $editMode + ); + $reshook = $hookmanager->executeHooks('formSetupBeforeGenerateOutput', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook < 0) { + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); } - $out.= ''; - $out.= ''; - $out.= ''; - $out.= ' '; - $out.= ' '; - $out.= ''; - $out.= ''; + if ($reshook > 0) { + return $hookmanager->resPrint; + } else { + $out = ''; + if ($editMode) { + $out .= ''; + } - $out.= ''; + $out .= '
    '.$this->langs->trans("Parameter").''.$this->langs->trans("Value").'
    '; + $out .= ''; + $out .= ''; + $out .= ' '; + $out .= ' '; + $out .= ''; + $out .= ''; + + // Sort items before render + $this->sortingItems(); + + $out .= ''; + foreach ($this->params as $item) { + $out .= $this->generateLineOutput($item, $editMode); + } + $out .= ''; + + $out .= '
    ' . $this->langs->trans("Parameter") . '' . $this->langs->trans("Value") . '
    '; + return $out; + } + } + + /** + * @param bool $noMessageInUpdate display event message on errors and success + * @return void|null + */ + public function saveConfFromPost($noMessageInUpdate = false) + { + + if (empty($this->params)) { + return null; + } + + $this->db->begin(); + $error = 0; foreach ($this->params as $item) { - $out.= $this->generateLineOutput($item, $editMode); + $res = $item->setValueFromPost(); + if ($res > 0) { + $item->saveConfValue(); + } elseif ($res < 0) { + $error++; + break; + } } - $out.= ''; - $out.= ''; - return $out; + if (!$error) { + $this->db->commit(); + if (empty($noMessageInUpdate)) { + setEventMessages($this->langs->trans("SetupSaved"), null); + } + } else { + $this->db->rollback(); + if (empty($noMessageInUpdate)) { + setEventMessages($this->langs->trans("SetupNotSaved"), null, 'errors'); + } + } } /** @@ -209,25 +267,133 @@ class formSetup if (!array($this->params)) { return false; } foreach ($this->params as $item) { - $item->reloadConf(); + $item->reloadValueFromConf(); } return true; } - /** * Create a new item + * the tagret is useful with hooks : that allow externals modules to add setup items on good place * @param $confKey the conf key used in database + * @param string $targetItemKey target item used to place the new item beside + * @param bool $insertAfterTarget insert before or after target item ? * @return formSetupItem the new setup item created */ - public function newItem($confKey) + public function newItem($confKey, $targetItemKey = false, $insertAfterTarget = false) { $item = new formSetupItem($confKey); + + // set item rank if not defined as last item + if (empty($item->rank)) { + $item->rank = $this->getCurentItemMaxRank() + 1; + $this->setItemMaxRank($item->rank); // set new max rank if needed + } + + // try to get rank from target column, this will override item->rank + if (!empty($targetItemKey)) { + if (isset($this->params[$targetItemKey])) { + $targetItem = $this->params[$targetItemKey]; + $item->rank = $targetItem->rank; // $targetItem->rank will be increase after + if ($targetItem->rank >= 0 && $insertAfterTarget) { + $item->rank++; + } + } + + // calc new rank for each item to make place for new item + foreach ($this->params as $fItem) { + if ($item->rank <= $fItem->rank) { + $fItem->rank = $fItem->rank + 1; + $this->setItemMaxRank($fItem->rank); // set new max rank if needed + } + } + } + $this->params[$item->confKey] = $item; return $this->params[$item->confKey]; } + + /** + * Sort items according to rank + * @return bool + */ + public function sortingItems() + { + // Sorting + return uasort($this->params, array($this, 'itemSort')); + } + + /** + * @param bool $cache To use cache or not + * @return int + */ + public function getCurentItemMaxRank($cache = true) + { + if (empty($this->params)) { + return 0; + } + + if ($cache && $this->maxItemRank > 0) { + return $this->maxItemRank; + } + + $this->maxItemRank = 0; + foreach ($this->params as $item) { + $this->maxItemRank = max($this->maxItemRank, $item->rank); + } + + return $this->maxItemRank; + } + + + /** + * set new max rank if needed + * @param int $rank the item rank + * @return int|void + */ + public function setItemMaxRank($rank) + { + $this->maxItemRank = max($this->maxItemRank, $rank); + } + + + /** + * get item position rank from item key + * + * @param string $itemKey the item key + * @return int rank on success and -1 on error + */ + public function getLineRank($itemKey) + { + if (!isset($this->params[$itemKey]->rank)) { + return -1; + } + return $this->params[$itemKey]->rank; + } + + + /** + * uasort callback function to Sort params items + * + * @param formSetupItem $a formSetup item + * @param formSetupItem $b formSetup item + * @return int Return compare result + */ + public function itemSort(formSetupItem $a, formSetupItem $b) + { + if (empty($a->rank)) { + $a->rank = 0; + } + if (empty($b->rank)) { + $b->rank = 0; + } + if ($a->rank == $b->rank) { + return 0; + } + return ($a->rank < $b->rank) ? -1 : 1; + } } /** @@ -243,6 +409,9 @@ class formSetupItem /** @var Translate */ public $langs; + /** @var int */ + public $entity; + /** @var Form */ public $form; @@ -267,6 +436,9 @@ class formSetupItem /** @var bool|string set this var to override field output */ public $fieldOutputOverride = false; + /** @var int $rank */ + public $rank = 0; + /** * @var string $errors */ @@ -294,6 +466,7 @@ class formSetupItem $this->db = $db; $this->form = new Form($this->db); $this->langs = $langs; + $this->entity = $conf->entity; $this->confKey = $confKey; $this->fieldValue = $conf->global->{$this->confKey}; @@ -303,12 +476,58 @@ class formSetupItem * reload conf value from databases * @return null */ - public function reloadConf() + public function reloadValueFromConf() { global $conf; $this->fieldValue = $conf->global->{$this->confKey}; } + + /** + * Save const value based on htdocs/core/actions_setmoduleoptions.inc.php + * @return int -1 if KO, 1 if OK + */ + public function saveConfValue() + { + // Modify constant only if key was posted (avoid resetting key to the null value) + if ($this->type != 'title') { + $result = dolibarr_set_const($this->db, $this->confKey, $this->fieldValue, 'chaine', 0, '', $this->entity); + if ($result < 0) { + return -1; + } else { + return 1; + } + } + } + + + /** + * Save const value based on htdocs/core/actions_setmoduleoptions.inc.php + * @return int -1 if KO, 0 nothing to do , 1 if OK + */ + public function setValueFromPost() + { + // Modify constant only if key was posted (avoid resetting key to the null value) + if ($this->type != 'title') { + if (preg_match('/category:/', $this->type)) { + if (GETPOST($this->confKey, 'int') == '-1') { + $val_const = ''; + } else { + $val_const = GETPOST($this->confKey, 'int'); + } + } else { + $val_const = GETPOST($this->confKey, 'alpha'); + } + + // TODO add value check with class validate + $this->fieldValue = $val_const; + + return 1; + } + + return 0; + } + /** * Get help text or generate it * @return int|string @@ -596,6 +815,7 @@ class formSetupItem return $out; } + /* * METHODS FOR SETTING DISPLAY TYPE */ diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 007e9d84b12..527ea8eb32d 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -60,6 +60,9 @@ require_once '../lib/mymodule.lib.php'; // Translations $langs->loadLangs(array("admin", "mymodule@mymodule")); +// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context +$hookmanager->initHooks(array('mymodulesetup', 'globalsetup')); + // Access control if (!$user->admin) { accessforbidden(); @@ -74,22 +77,10 @@ $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scan_dir', 'alpha'); $type = 'myobject'; -$arrayofparameters = array( - 'MYMODULE_MYPARAM1'=>array('type'=>'string', 'css'=>'minwidth500' ,'enabled'=>1), - 'MYMODULE_MYPARAM2'=>array('type'=>'textarea','enabled'=>1), - //'MYMODULE_MYPARAM3'=>array('type'=>'category:'.Categorie::TYPE_CUSTOMER, 'enabled'=>1), - //'MYMODULE_MYPARAM4'=>array('type'=>'emailtemplate:thirdparty', 'enabled'=>1), - //'MYMODULE_MYPARAM5'=>array('type'=>'yesno', 'enabled'=>1), - //'MYMODULE_MYPARAM5'=>array('type'=>'thirdparty_type', 'enabled'=>1), - //'MYMODULE_MYPARAM6'=>array('type'=>'securekey', 'enabled'=>1), - //'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1), -); require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; $formSetup = new formSetup($db); -$formSetup->addItemsFromParamsArray($arrayofparameters); - // Hôte $item = $formSetup->newItem('NO_PARAM_JUST_TEXT'); @@ -131,11 +122,10 @@ $dirmodels = array_merge(array('/'), (array) $conf->modules_parts['models']); * Actions */ -if ((float) DOL_VERSION >= 6) { - // TODO Add save setup by formSetup - $arrayofparameters = $formSetup->exportItemsAsParamsArray(); - include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; - $formSetup->reloadConfs(); +if ((float) DOL_VERSION >= 15) { + if ($action == 'update') { + $formSetup->saveConfFromPost(); + } } if ($action == 'updateMask') { @@ -275,8 +265,9 @@ if ($action == 'edit') { print ''; print '
    '; } else { - if (!empty($arrayofparameters)) { + if (!empty($formSetup->params)) { print $formSetup->generateOutput(); + $setupnotempty++; print '
    '; print ''.$langs->trans("Modify").''; From bbe71c9c32d792a3fd0cfe56b37394d9af6f4942 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Tue, 2 Nov 2021 14:07:36 +0100 Subject: [PATCH 027/178] Rename var --- htdocs/core/class/html.formsetup.class.php | 36 +++++++++---------- htdocs/modulebuilder/template/admin/setup.php | 2 +- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index cbf8cbd37ba..8f9d3af0528 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -28,7 +28,7 @@ class formSetup public $db; /** @var formSetupItem[] */ - public $params = array(); + public $items = array(); /** * @var int @@ -100,7 +100,7 @@ class formSetup $this->sortingItems(); $out .= ''; - foreach ($this->params as $item) { + foreach ($this->items as $item) { $out .= $this->generateLineOutput($item, $editMode); } $out .= ''; @@ -117,13 +117,13 @@ class formSetup public function saveConfFromPost($noMessageInUpdate = false) { - if (empty($this->params)) { + if (empty($this->items)) { return null; } $this->db->begin(); $error = 0; - foreach ($this->params as $item) { + foreach ($this->items as $item) { $res = $item->setValueFromPost(); if ($res > 0) { $item->saveConfValue(); @@ -234,7 +234,7 @@ class formSetup $item->cssClass = $params['css']; } - $this->params[$item->confKey] = $item; + $this->items[$item->confKey] = $item; return true; } @@ -247,7 +247,7 @@ class formSetup public function exportItemsAsParamsArray() { $arrayofparameters = array(); - foreach ($this->params as $key => $item) { + foreach ($this->items as $key => $item) { $arrayofparameters[$item->confKey] = array( 'type' => $item->getType(), 'enabled' => $item->enabled @@ -265,8 +265,8 @@ class formSetup public function reloadConfs() { - if (!array($this->params)) { return false; } - foreach ($this->params as $item) { + if (!array($this->items)) { return false; } + foreach ($this->items as $item) { $item->reloadValueFromConf(); } @@ -294,8 +294,8 @@ class formSetup // try to get rank from target column, this will override item->rank if (!empty($targetItemKey)) { - if (isset($this->params[$targetItemKey])) { - $targetItem = $this->params[$targetItemKey]; + if (isset($this->items[$targetItemKey])) { + $targetItem = $this->items[$targetItemKey]; $item->rank = $targetItem->rank; // $targetItem->rank will be increase after if ($targetItem->rank >= 0 && $insertAfterTarget) { $item->rank++; @@ -303,7 +303,7 @@ class formSetup } // calc new rank for each item to make place for new item - foreach ($this->params as $fItem) { + foreach ($this->items as $fItem) { if ($item->rank <= $fItem->rank) { $fItem->rank = $fItem->rank + 1; $this->setItemMaxRank($fItem->rank); // set new max rank if needed @@ -311,8 +311,8 @@ class formSetup } } - $this->params[$item->confKey] = $item; - return $this->params[$item->confKey]; + $this->items[$item->confKey] = $item; + return $this->items[$item->confKey]; } /** @@ -322,7 +322,7 @@ class formSetup public function sortingItems() { // Sorting - return uasort($this->params, array($this, 'itemSort')); + return uasort($this->items, array($this, 'itemSort')); } /** @@ -331,7 +331,7 @@ class formSetup */ public function getCurentItemMaxRank($cache = true) { - if (empty($this->params)) { + if (empty($this->items)) { return 0; } @@ -340,7 +340,7 @@ class formSetup } $this->maxItemRank = 0; - foreach ($this->params as $item) { + foreach ($this->items as $item) { $this->maxItemRank = max($this->maxItemRank, $item->rank); } @@ -367,10 +367,10 @@ class formSetup */ public function getLineRank($itemKey) { - if (!isset($this->params[$itemKey]->rank)) { + if (!isset($this->items[$itemKey]->rank)) { return -1; } - return $this->params[$itemKey]->rank; + return $this->items[$itemKey]->rank; } diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 527ea8eb32d..417c28f30a2 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -265,7 +265,7 @@ if ($action == 'edit') { print ''; print '
    '; } else { - if (!empty($formSetup->params)) { + if (!empty($formSetup->items)) { print $formSetup->generateOutput(); $setupnotempty++; From 12b046cb68a41ace480a519d366f3243b03144d6 Mon Sep 17 00:00:00 2001 From: John BOTELLA Date: Tue, 2 Nov 2021 14:11:36 +0100 Subject: [PATCH 028/178] Fix class name --- htdocs/core/class/html.formsetup.class.php | 20 +++++++++---------- htdocs/modulebuilder/template/admin/setup.php | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/html.formsetup.class.php b/htdocs/core/class/html.formsetup.class.php index 8f9d3af0528..6f2ec2acfb6 100644 --- a/htdocs/core/class/html.formsetup.class.php +++ b/htdocs/core/class/html.formsetup.class.php @@ -19,7 +19,7 @@ /** * This class help you create setup render */ -class formSetup +class FormSetup { /** @@ -27,7 +27,7 @@ class formSetup */ public $db; - /** @var formSetupItem[] */ + /** @var FormSetupItem[] */ public $items = array(); /** @@ -147,7 +147,7 @@ class formSetup } /** - * @param formSetupItem $item the setup item + * @param FormSetupItem $item the setup item * @param bool $editMode Display as edit mod * @return string the html output for an setup item */ @@ -223,7 +223,7 @@ class formSetup //'MYMODULE_MYPARAM7'=>array('type'=>'product', 'enabled'=>1), */ - $item = new formSetupItem($confKey); + $item = new FormSetupItem($confKey); $item->setTypeFromTypeString($params['type']); if (!empty($params['enabled'])) { @@ -280,11 +280,11 @@ class formSetup * @param $confKey the conf key used in database * @param string $targetItemKey target item used to place the new item beside * @param bool $insertAfterTarget insert before or after target item ? - * @return formSetupItem the new setup item created + * @return FormSetupItem the new setup item created */ public function newItem($confKey, $targetItemKey = false, $insertAfterTarget = false) { - $item = new formSetupItem($confKey); + $item = new FormSetupItem($confKey); // set item rank if not defined as last item if (empty($item->rank)) { @@ -377,11 +377,11 @@ class formSetup /** * uasort callback function to Sort params items * - * @param formSetupItem $a formSetup item - * @param formSetupItem $b formSetup item + * @param FormSetupItem $a formSetup item + * @param FormSetupItem $b formSetup item * @return int Return compare result */ - public function itemSort(formSetupItem $a, formSetupItem $b) + public function itemSort(FormSetupItem $a, FormSetupItem $b) { if (empty($a->rank)) { $a->rank = 0; @@ -399,7 +399,7 @@ class formSetup /** * This class help to create item for class formSetup */ -class formSetupItem +class FormSetupItem { /** * @var DoliDB Database handler. diff --git a/htdocs/modulebuilder/template/admin/setup.php b/htdocs/modulebuilder/template/admin/setup.php index 417c28f30a2..206cca0ff52 100644 --- a/htdocs/modulebuilder/template/admin/setup.php +++ b/htdocs/modulebuilder/template/admin/setup.php @@ -79,7 +79,7 @@ $type = 'myobject'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsetup.class.php'; -$formSetup = new formSetup($db); +$formSetup = new FormSetup($db); // Hôte From 82b7f0e9e45e7b85b544ed8a8d9ca60cdb0dfabc Mon Sep 17 00:00:00 2001 From: kamel Date: Tue, 2 Nov 2021 15:21:14 +0100 Subject: [PATCH 029/178] FIX second approval back in stable feature as is the setting for minimum amount (last part from PR#14286) --- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 72ba5be84ee..00bc994096f 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -999,7 +999,7 @@ class CommandeFournisseur extends CommonOrder if (empty($secondlevel)) { // standard or first level approval $sql .= " date_approve='".$this->db->idate($now)."',"; $sql .= " fk_user_approve = ".$user->id; - if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $conf->global->MAIN_FEATURES_LEVEL > 0 && $this->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) { + if (!empty($conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) && $this->total_ht >= $conf->global->SUPPLIER_ORDER_3_STEPS_TO_BE_APPROVED) { if (empty($this->user_approve_id2)) { $movetoapprovestatus = false; // second level approval not done $comment = ' (first level)'; From 126fbf9f631a3ff7d226e8719d0c3b12a8c2dc20 Mon Sep 17 00:00:00 2001 From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com> Date: Tue, 2 Nov 2021 15:46:04 +0100 Subject: [PATCH 030/178] Change date format to be equal to mass stock transfert --- htdocs/product/stock/tpl/stockcorrection.tpl.php | 2 +- htdocs/product/stock/tpl/stocktransfer.tpl.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index 05d628902fb..e1a5e734016 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -155,7 +155,7 @@ print ''.$langs->trans("MovementLabel").''; print ''; print ''; print ''; -print ''.$langs->trans("InventoryCode").''; +print ''.$langs->trans("InventoryCode").''; print ''; print ''; diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index 27c9b2acb21..711e5a0c9ac 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -130,7 +130,7 @@ print ''.$langs->trans("MovementLabel").''; print ''; print ''; print ''; -print ''.$langs->trans("InventoryCode").''; +print ''.$langs->trans("InventoryCode").''; print ''; print ''; From 0c1d4c9d5104717bc9957ac0cde20bba21872881 Mon Sep 17 00:00:00 2001 From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com> Date: Tue, 2 Nov 2021 15:48:12 +0100 Subject: [PATCH 031/178] No need of escape htmltag thanks to GETPOST before --- htdocs/product/stock/tpl/stocktransfer.tpl.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index 711e5a0c9ac..b71e1e8b248 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -124,11 +124,11 @@ if (!empty($conf->productbatch->enabled) && } // Label -$valformovementlabel = (GETPOST("label") ?GETPOST("label") : $langs->trans("MovementTransferStock", $productref)); +$valformovementlabel = (GETPOST("label") ? GETPOST("label") : $langs->trans("MovementTransferStock", $productref)); print ''; print ''.$langs->trans("MovementLabel").''; print ''; -print ''; +print ''; print ''; print ''.$langs->trans("InventoryCode").''; print ''; From 49d955b7948a1c730c519402f5c003fb5f2dfb5d Mon Sep 17 00:00:00 2001 From: Benjamin Chantalat <74144396+PyroShape@users.noreply.github.com> Date: Tue, 2 Nov 2021 15:53:57 +0100 Subject: [PATCH 032/178] Uniformization of the table code as the line above --- htdocs/product/stock/tpl/stockcorrection.tpl.php | 5 ++++- htdocs/product/stock/tpl/stocktransfer.tpl.php | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/product/stock/tpl/stockcorrection.tpl.php b/htdocs/product/stock/tpl/stockcorrection.tpl.php index e1a5e734016..e4dfd8b5d7c 100644 --- a/htdocs/product/stock/tpl/stockcorrection.tpl.php +++ b/htdocs/product/stock/tpl/stockcorrection.tpl.php @@ -155,7 +155,10 @@ print ''.$langs->trans("MovementLabel").''; print ''; print ''; print ''; -print ''.$langs->trans("InventoryCode").''; +print ''.$langs->trans("InventoryCode").''; +print ''; +print ''; +print ''; print ''; print ''; diff --git a/htdocs/product/stock/tpl/stocktransfer.tpl.php b/htdocs/product/stock/tpl/stocktransfer.tpl.php index b71e1e8b248..31a3103c3eb 100644 --- a/htdocs/product/stock/tpl/stocktransfer.tpl.php +++ b/htdocs/product/stock/tpl/stocktransfer.tpl.php @@ -130,7 +130,10 @@ print ''.$langs->trans("MovementLabel").''; print ''; print ''; print ''; -print ''.$langs->trans("InventoryCode").''; +print ''.$langs->trans("InventoryCode").''; +print ''; +print ''; +print ''; print ''; print ''; From b02c89bd8b7e68090c52142ef33e42d8c39be7d7 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 2 Nov 2021 23:07:46 +0100 Subject: [PATCH 033/178] Add link year subscription list in subscription by year stats page --- htdocs/adherents/stats/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index ed79978552f..de9a5b3d9d9 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -196,7 +196,7 @@ foreach ($data as $val) { print ''; print ''; //print ''; - print $year; + print ''.$year.''; //print ''; print ''; print ''.$val['nb'].''; From d334fe1292b1abfe4b2ec1083f504e5b1f852bf1 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Wed, 3 Nov 2021 13:12:33 +0100 Subject: [PATCH 034/178] Fix Bad count of subscription by year If --- htdocs/core/boxes/box_members_subscriptions_by_year.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_members_subscriptions_by_year.php b/htdocs/core/boxes/box_members_subscriptions_by_year.php index be835511c6b..b6c146312bc 100644 --- a/htdocs/core/boxes/box_members_subscriptions_by_year.php +++ b/htdocs/core/boxes/box_members_subscriptions_by_year.php @@ -111,7 +111,7 @@ class box_members_subscriptions_by_year extends ModeleBoxes $i = 0; while ($i < $num) { $objp = $this->db->fetch_object($result); - $year = dol_print_date($this->db->jdate($objp->dateh), "%Y", 'gmt'); + $year = dol_print_date($this->db->jdate($objp->dateh), "%Y"); $Total[$year] = (isset($Total[$year]) ? $Total[$year] : 0) + $objp->subscription; $Number[$year] = (isset($Number[$year]) ? $Number[$year] : 0) + 1; $tot += $objp->subscription; From 973f408b6e3caa54a862b887f759279d214d487b Mon Sep 17 00:00:00 2001 From: daraelmin Date: Wed, 3 Nov 2021 20:35:57 +0100 Subject: [PATCH 035/178] Fix default enddate subscription must be in futur --- htdocs/adherents/subscription.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 1316a337610..839680c3874 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -943,8 +943,10 @@ if ($rowid > 0) { } if (!$datefrom) { $datefrom = $object->datevalid; - if ($object->datefin > 0) { - $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); + if ($object->datefin > 0 && dol_now() > dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd') { + $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); + } else { + $datefrom = dol_get_first_day(dol_print_date(time(), "%Y")); } } print $form->selectDate($datefrom, '', '', '', '', "subscription", 1, 1); From 0e91b32e990e764fade7abec6e03ea6d7a605b9c Mon Sep 17 00:00:00 2001 From: daraelmin Date: Wed, 3 Nov 2021 20:40:09 +0100 Subject: [PATCH 036/178] Update subscription.php --- htdocs/adherents/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 839680c3874..11b3aed8f00 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -943,7 +943,7 @@ if ($rowid > 0) { } if (!$datefrom) { $datefrom = $object->datevalid; - if ($object->datefin > 0 && dol_now() > dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd') { + if ($object->datefin > 0 && dol_now() > dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd')) { $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); } else { $datefrom = dol_get_first_day(dol_print_date(time(), "%Y")); From f9db196512ac5b405780368bc2ea2667e43db5a3 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Wed, 3 Nov 2021 22:31:45 +0100 Subject: [PATCH 037/178] Update subscription.php --- htdocs/adherents/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 11b3aed8f00..f38562da5a0 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -943,7 +943,7 @@ if ($rowid > 0) { } if (!$datefrom) { $datefrom = $object->datevalid; - if ($object->datefin > 0 && dol_now() > dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd')) { + if ($object->datefin > 0 && dol_now() < dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd')) { $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); } else { $datefrom = dol_get_first_day(dol_print_date(time(), "%Y")); From 586005ff2e5daf46870bb62c908052aa947cd28c Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 3 Nov 2021 21:43:30 +0000 Subject: [PATCH 038/178] Fixing style errors. --- htdocs/adherents/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index f38562da5a0..e8a703a6efb 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -944,7 +944,7 @@ if ($rowid > 0) { if (!$datefrom) { $datefrom = $object->datevalid; if ($object->datefin > 0 && dol_now() < dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd')) { - $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); + $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); } else { $datefrom = dol_get_first_day(dol_print_date(time(), "%Y")); } From 3fb0e3c5ad4789209478f43ff65716edc358c93c Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 3 Nov 2021 22:56:15 +0100 Subject: [PATCH 039/178] NEW add html.formldap.class.php --- htdocs/adherents/ldap.php | 4 +- htdocs/adherents/type_ldap.php | 4 +- htdocs/admin/ldap.php | 67 ++---- htdocs/admin/ldap_groups.php | 4 +- htdocs/admin/ldap_members_types.php | 2 +- htdocs/admin/ldap_users.php | 4 +- htdocs/contact/ldap.php | 4 +- htdocs/core/class/conf.class.php | 21 +- htdocs/core/class/html.formldap.class.php | 196 ++++++++++++++++++ htdocs/core/class/ldap.class.php | 19 +- htdocs/core/login/functions_ldap.php | 2 +- ...interface_50_modLdap_Ldapsynchro.class.php | 44 ++-- htdocs/langs/en_US/ldap.lang | 4 +- htdocs/user/card.php | 2 +- htdocs/user/group/ldap.php | 4 +- htdocs/user/ldap.php | 4 +- 16 files changed, 293 insertions(+), 92 deletions(-) create mode 100644 htdocs/core/class/html.formldap.class.php diff --git a/htdocs/adherents/ldap.php b/htdocs/adherents/ldap.php index 4b64290f107..70624983815 100644 --- a/htdocs/adherents/ldap.php +++ b/htdocs/adherents/ldap.php @@ -158,13 +158,13 @@ print dol_get_fiche_end(); */ print '
    '; -if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr') { +if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != Ldap::SYNCHRO_LDAP_TO_DOLIBARR) { print ''; } print "
    \n"; -if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != 'ldap2dolibarr') { +if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE != Ldap::SYNCHRO_LDAP_TO_DOLIBARR) { print "
    \n"; } diff --git a/htdocs/adherents/type_ldap.php b/htdocs/adherents/type_ldap.php index 43902a5e1bf..d7650a8de2b 100644 --- a/htdocs/adherents/type_ldap.php +++ b/htdocs/adherents/type_ldap.php @@ -124,13 +124,13 @@ print dol_get_fiche_end(); print '
    '; -if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1) { +if (getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { print ''.$langs->trans("ForceSynchronize").''; } print "
    \n"; -if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == 1) { +if (getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { print "
    \n"; } diff --git a/htdocs/admin/ldap.php b/htdocs/admin/ldap.php index 167c48d84c0..99c86f783fc 100644 --- a/htdocs/admin/ldap.php +++ b/htdocs/admin/ldap.php @@ -100,7 +100,7 @@ if (empty($reshook)) { if (!dolibarr_set_const($db, 'LDAP_MEMBER_TYPE_ACTIVE', GETPOST("activememberstypes", 'aZ09'), 'chaine', 0, '', $conf->entity)) { $error++; } - if (!dolibarr_set_const($db, 'LDAP_PASSWORD_HASH_TYPE', GETPOST("'LDAP_PASSWORD_HASH_TYPE'", 'aZ09'), 'chaine', 0, '', $conf->entity)) { + if (!dolibarr_set_const($db, 'LDAP_PASSWORD_HASH_TYPE', GETPOST("LDAP_PASSWORD_HASH_TYPE", 'aZ09'), 'chaine', 0, '', $conf->entity)) { $error++; } @@ -150,13 +150,9 @@ print "\n"; // Synchro utilisateurs/groupes active print ''.$langs->trans("LDAPDnSynchroActive").''; -$arraylist = array(); -$arraylist['0'] = $langs->trans("No"); -$arraylist['ldap2dolibarr'] = $langs->trans("LDAPToDolibarr"); -$arraylist['dolibarr2ldap'] = $langs->trans("DolibarrToLDAP"); -print $form->selectarray('activesynchro', $arraylist, $conf->global->LDAP_SYNCHRO_ACTIVE); +print $formldap->selectLdapDnSynchroActive(getDolGlobalInt('LDAP_SYNCHRO_ACTIVE'), 'activesynchro'); print ''.$langs->trans("LDAPDnSynchroActiveExample").''; -if ($conf->global->LDAP_SYNCHRO_ACTIVE && !$conf->global->LDAP_USER_DN) { +if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && empty($conf->global->LDAP_USER_DN)) { print '
    '.$langs->trans("LDAPSetupNotComplete").''; } print ''; @@ -164,32 +160,21 @@ print ''; // Synchro contact active if (!empty($conf->societe->enabled)) { print ''.$langs->trans("LDAPDnContactActive").''; - $arraylist = array(); - $arraylist['0'] = $langs->trans("No"); - $arraylist['1'] = $langs->trans("DolibarrToLDAP"); - print $form->selectarray('activecontact', $arraylist, $conf->global->LDAP_CONTACT_ACTIVE); + print $formldap->selectLdapDnSynchroActive(getDolGlobalInt('LDAP_CONTACT_ACTIVE'), 'activecontact', array(Ldap::SYNCHRO_LDAP_TO_DOLIBARR)); print ''.$langs->trans("LDAPDnContactActiveExample").''; } // Synchro member active if (!empty($conf->adherent->enabled)) { print ''.$langs->trans("LDAPDnMemberActive").''; - $arraylist = array(); - $arraylist['0'] = $langs->trans("No"); - $arraylist['1'] = $langs->trans("DolibarrToLDAP"); - $arraylist['ldap2dolibarr'] = $langs->trans("LDAPToDolibarr").' ('.$langs->trans("SupportedForLDAPImportScriptOnly").')'; - print $form->selectarray('activemembers', $arraylist, $conf->global->LDAP_MEMBER_ACTIVE); + print $formldap->selectLdapDnSynchroActive(getDolGlobalInt('LDAP_MEMBER_ACTIVE'), 'activemembers', array(), 2); print ''.$langs->trans("LDAPDnMemberActiveExample").''; } // Synchro member type active if (!empty($conf->adherent->enabled)) { print ''.$langs->trans("LDAPDnMemberTypeActive").''; - $arraylist = array(); - $arraylist['0'] = $langs->trans("No"); - $arraylist['1'] = $langs->trans("DolibarrToLDAP"); - $arraylist['ldap2dolibarr'] = $langs->trans("LDAPToDolibarr").' ('.$langs->trans("SupportedForLDAPImportScriptOnly").')'; - print $form->selectarray('activememberstypes', $arraylist, $conf->global->LDAP_MEMBER_TYPE_ACTIVE); + print $formldap->selectLdapDnSynchroActive(getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE'), 'activememberstypes', array(), 2); print ''.$langs->trans("LDAPDnMemberTypeActiveExample").''; } @@ -206,53 +191,39 @@ print "\n"; // Type print ''.$langs->trans("Type").''; -$arraylist = array(); -$arraylist['activedirectory'] = 'Active Directory'; -$arraylist['openldap'] = 'OpenLdap'; -$arraylist['egroupware'] = 'Egroupware'; -print $form->selectarray('type', $arraylist, $conf->global->LDAP_SERVER_TYPE); +print $formldap->selectLdapServerType(getDolGlobalString('LDAP_SERVER_TYPE'), 'type'); print ' '; // Version print ''.$langs->trans("Version").''; -$arraylist = array(); -$arraylist['3'] = 'Version 3'; -$arraylist['2'] = 'Version 2'; -print $form->selectarray('LDAP_SERVER_PROTOCOLVERSION', $arraylist, $conf->global->LDAP_SERVER_PROTOCOLVERSION); +print $formldap->selectLdapServerProtocolVersion(getDolGlobalString('LDAP_SERVER_PROTOCOLVERSION'), 'LDAP_SERVER_PROTOCOLVERSION'); print ''.$langs->trans("LDAPServerProtocolVersion").''; // Serveur primaire print ''; print $langs->trans("LDAPPrimaryServer").''; -print ''; +print ''; print ''.$langs->trans("LDAPServerExample").''; // Serveur secondaire print ''; print $langs->trans("LDAPSecondaryServer").''; -print ''; +print ''; print ''.$langs->trans("LDAPServerExample").''; // Port print ''.$langs->trans("LDAPServerPort").''; -if (!empty($conf->global->LDAP_SERVER_PORT)) { - print ''; -} else { - print ''; -} +print ''; print ''.$langs->trans("LDAPServerPortExample").''; // DNserver print ''.$langs->trans("LDAPServerDn").''; -print ''; +print ''; print ''.$langs->trans("LDAPServerDnExample").''; // Utiliser TLS print ''.$langs->trans("LDAPServerUseTLS").''; -$arraylist = array(); -$arraylist['0'] = $langs->trans("No"); -$arraylist['1'] = $langs->trans("Yes"); -print $form->selectarray('usetls', $arraylist, $conf->global->LDAP_SERVER_USE_TLS); +print $form->selectyesno('usetls', getDolGlobalInt('LDAP_SERVER_USE_TLS'), 1); print ''.$langs->trans("LDAPServerUseTLSExample").''; // Password hash type @@ -267,7 +238,7 @@ print "\n"; // DNAdmin print ''; print ''.$langs->trans("LDAPAdminDn").''; -print ''; +print ''; print ''.$langs->trans("LDAPAdminDnExample").''; // Pass @@ -276,7 +247,7 @@ print ''.$langs->trans("LDAPPassword").''; if (!empty($conf->global->LDAP_ADMIN_PASS)) { print ''; // je le met en visible pour test } else { - print ''; + print ''; } print ''.$langs->trans('Password').' (ex: secret)'; @@ -306,17 +277,17 @@ if (function_exists("ldap_connect")) { if ($result > 0) { // Test ldap connect and bind print img_picto('', 'info').' '; - print ''.$langs->trans("LDAPTCPConnectOK", $ldap->connectedServer, $conf->global->LDAP_SERVER_PORT).''; + print ''.$langs->trans("LDAPTCPConnectOK", $ldap->connectedServer, getDolGlobalString('LDAP_SERVER_PORT')).''; print '
    '; if (!empty($conf->global->LDAP_ADMIN_DN) && !empty($conf->global->LDAP_ADMIN_PASS)) { if ($result == 2) { print img_picto('', 'info').' '; - print ''.$langs->trans("LDAPBindOK", $ldap->connectedServer, $conf->global->LDAP_SERVER_PORT, $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).''; + print ''.$langs->trans("LDAPBindOK", $ldap->connectedServer, getDolGlobalString('LDAP_SERVER_PORT'), $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).''; print '
    '; } else { print img_picto('', 'error').' '; - print ''.$langs->trans("LDAPBindKO", $ldap->connectedServer, $conf->global->LDAP_SERVER_PORT, $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).''; + print ''.$langs->trans("LDAPBindKO", $ldap->connectedServer, getDolGlobalString('LDAP_SERVER_PORT'), $conf->global->LDAP_ADMIN_DN, preg_replace('/./i', '*', $conf->global->LDAP_ADMIN_PASS)).''; print '
    '; print $langs->trans("Error").' '.$ldap->error; print '
    '; @@ -342,7 +313,7 @@ if (function_exists("ldap_connect")) { $ldap->unbind(); } else { print img_picto('', 'error').' '; - print ''.$langs->trans("LDAPTCPConnectKO", $ldap->connectedServer, $conf->global->LDAP_SERVER_PORT).''; + print ''.$langs->trans("LDAPTCPConnectKO", $ldap->connectedServer, getDolGlobalString('LDAP_SERVER_PORT')).''; print '
    '; print $langs->trans("Error").' '.$ldap->error; print '
    '; diff --git a/htdocs/admin/ldap_groups.php b/htdocs/admin/ldap_groups.php index 82ee85b9a20..5723183735e 100644 --- a/htdocs/admin/ldap_groups.php +++ b/htdocs/admin/ldap_groups.php @@ -218,7 +218,7 @@ print ''; /* * Test de la connexion */ -if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { +if (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $butlabel = $langs->trans("LDAPTestSynchroGroup"); $testlabel = 'testgroup'; $key = $conf->global->LDAP_KEY_GROUPS; @@ -226,7 +226,7 @@ if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { $objectclass = $conf->global->LDAP_GROUP_OBJECT_CLASS; show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); -} elseif ($conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') { +} elseif (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_LDAP_TO_DOLIBARR) { $butlabel = $langs->trans("LDAPTestSearch"); $testlabel = 'testsearchgroup'; $key = $conf->global->LDAP_KEY_GROUPS; diff --git a/htdocs/admin/ldap_members_types.php b/htdocs/admin/ldap_members_types.php index 05572dc8bbf..7933b59d5e0 100644 --- a/htdocs/admin/ldap_members_types.php +++ b/htdocs/admin/ldap_members_types.php @@ -188,7 +188,7 @@ print ''; /* * Test de la connexion */ -if ($conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { +if (getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $butlabel = $langs->trans("LDAPTestSynchroMemberType"); $testlabel = 'testmembertype'; $key = $conf->global->LDAP_KEY_MEMBERS_TYPES; diff --git a/htdocs/admin/ldap_users.php b/htdocs/admin/ldap_users.php index 33bec1cb2e8..f395eb88fb4 100644 --- a/htdocs/admin/ldap_users.php +++ b/htdocs/admin/ldap_users.php @@ -405,7 +405,7 @@ print ''; /* * Test de la connexion */ -if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') == 'dolibarr2ldap') { +if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $butlabel = $langs->trans("LDAPTestSynchroUser"); $testlabel = 'testuser'; $key = getDolGlobalString('LDAP_KEY_USERS'); @@ -413,7 +413,7 @@ if (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') == 'dolibarr2ldap') { $objectclass = getDolGlobalString('LDAP_USER_OBJECT_CLASS'); show_ldap_test_button($butlabel, $testlabel, $key, $dn, $objectclass); -} elseif (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') == 'ldap2dolibarr') { +} elseif (getDolGlobalString('LDAP_SYNCHRO_ACTIVE') == Ldap::SYNCHRO_LDAP_TO_DOLIBARR) { $butlabel = $langs->trans("LDAPTestSearch"); $testlabel = 'testsearchuser'; $key = getDolGlobalString('LDAP_KEY_USERS'); diff --git a/htdocs/contact/ldap.php b/htdocs/contact/ldap.php index d29aab0386b..92b9c1ad337 100644 --- a/htdocs/contact/ldap.php +++ b/htdocs/contact/ldap.php @@ -136,13 +136,13 @@ print dol_get_fiche_end(); */ print '
    '; -if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') { +if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != Ldap::SYNCHRO_LDAP_TO_DOLIBARR) { print ''.$langs->trans("ForceSynchronize").''; } print "
    \n"; -if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != 'ldap2dolibarr') { +if (!empty($conf->global->LDAP_CONTACT_ACTIVE) && $conf->global->LDAP_CONTACT_ACTIVE != Ldap::SYNCHRO_LDAP_TO_DOLIBARR) { print "
    \n"; } diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 044dc192426..cf54151d2d6 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -775,8 +775,8 @@ class Conf $this->contrat->services->expires->warning_delay = (isset($this->global->MAIN_DELAY_RUNNING_SERVICES) ? $this->global->MAIN_DELAY_RUNNING_SERVICES : 0) * 86400; } if (isset($this->commande)) { - $this->bank->rappro = new stdClass(); - $this->bank->cheque = new stdClass(); + $this->bank->rappro = new stdClass(); + $this->bank->cheque = new stdClass(); $this->bank->rappro->warning_delay = (isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE) ? $this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE : 0) * 86400; $this->bank->cheque->warning_delay = (isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT) ? $this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT : 0) * 86400; } @@ -845,6 +845,23 @@ class Conf } } + // For backward compatibility + if (!empty($this->global->LDAP_SYNCHRO_ACTIVE)) { + if ($this->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { + $this->global->LDAP_SYNCHRO_ACTIVE = 1; + } else if ($this->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') { + $this->global->LDAP_SYNCHRO_ACTIVE = 2; + } + } + // For backward compatibility + if (!empty($this->global->LDAP_MEMBER_ACTIVE) && $this->global->LDAP_MEMBER_ACTIVE == 'ldap2dolibarr') { + $this->global->LDAP_MEMBER_ACTIVE = 2; + } + // For backward compatibility + if (!empty($this->global->LDAP_MEMBER_TYPE_ACTIVE) && $this->global->LDAP_MEMBER_TYPE_ACTIVE == 'ldap2dolibarr') { + $this->global->LDAP_MEMBER_TYPE_ACTIVE = 2; + } + if (!empty($this->global->MAIN_TZUSERINPUTKEY)) { $this->tzuserinputkey = $this->global->MAIN_TZUSERINPUTKEY; // 'tzserver' or 'tzuserrel' } diff --git a/htdocs/core/class/html.formldap.class.php b/htdocs/core/class/html.formldap.class.php new file mode 100644 index 00000000000..acee0bbbea7 --- /dev/null +++ b/htdocs/core/class/html.formldap.class.php @@ -0,0 +1,196 @@ + + * + * 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 . + */ + +/** + * \file htdocs/core/class/html.formldap.class.php + * \ingroup core + * \brief File of class with ldap html predefined components + */ +require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php'; + +/** + * Class to manage generation of HTML components for ldap module + */ +class FormLdap +{ + /** + * @var DoliDB Database handler. + */ + public $db; + + /** + * @var string Error code (or message) + */ + public $error = ''; + + /** + * @var string[] Array of error strings + */ + public $errors = array(); + + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + global $langs, $form; + + if (!is_object($form)) { + $form = new Form($this->db); + } + + $langs->loadLangs(array("admin", "ldap")); + + $this->db = $db; + } + + /** + * Return list of types of hash + * + * @param string $selected Preselected type + * @param string $htmlname Name of field in form + * @param int $showempty Add an empty field + * @return string HTML select string + */ + public function selectLdapPasswordHashType($selected = 'md5', $htmlname = 'ldaphashtype', $showempty = 0) + { + global $form; + + if (empty($selected)) { + $selected = 'md5'; + } + if (empty($htmlname)) { + $htmlname = 'ldaphashtype'; + } + + $arraylist = array( + "pbkdf2sha256" => "PBKDF2_SHA256", + "ssha512" => "SSHA512", + "ssha256" => "SSHA256", + "ssha" => "SSHA", + "sha" => "SHA", + "md5" => "MD5", + "smd5" => "SMD5", + "cryptmd5" => "CRYPT-MD5", + "cryptsha512" => "CRYPT-SHA512", + "cryptsha256" => "CRYPT-SHA256", + "crypt" => "CRYPT", + "clear" => "CLEAR" + ); + + return $form->selectarray($htmlname, $arraylist, $selected, $showempty); + } + + /** + * Return list of type of synchronization + * + * @param int $selected Preselected type + * @param string $htmlname Name of field in form + * @param array $exclude Exclude values from the list + * @param int $scriptonly Add warning if synchro only work with a script (0 = disable, 1 = Dolibarr2ldap, 2 = ldap2dolibarr, 3 = all) + * @param int $showempty Add an empty field + * @return string HTML select string + */ + public function selectLdapDnSynchroActive($selected = 0, $htmlname = 'activesynchro', $exclude = array(), $scriptonly = 0, $showempty = 0) + { + global $langs, $form; + + if (empty($selected)) { + $selected = Ldap::SYNCHRO_NONE; + } + if (empty($htmlname)) { + $htmlname = 'activesynchro'; + } + + $dolibarr2ldaplabel = $langs->trans("DolibarrToLDAP") . (($scriptonly == 1 || $scriptonly == 3) ? " (".$langs->trans("SupportedForLDAPExportScriptOnly").")" : ""); + $ldap2dolibarrlabel = $langs->trans("LDAPToDolibarr") . (($scriptonly == 2 || $scriptonly == 3) ? " (".$langs->trans("SupportedForLDAPImportScriptOnly").")" : ""); + + $arraylist = array( + Ldap::SYNCHRO_NONE => $langs->trans("No"), + Ldap::SYNCHRO_DOLIBARR_TO_LDAP => $dolibarr2ldaplabel, + Ldap::SYNCHRO_LDAP_TO_DOLIBARR => $ldap2dolibarrlabel + ); + + if (is_array($exclude) && !empty($exclude)) { + foreach($exclude as $value) { + if (array_key_exists($value, $arraylist)) { + unset($arraylist[$value]); + } + } + } + + return $form->selectarray($htmlname, $arraylist, $selected, $showempty); + } + + /** + * Return list of ldap server types + * + * @param string $selected Preselected type + * @param string $htmlname Name of field in form + * @param int $showempty Add an empty field + * @return string HTML select string + */ + public function selectLdapServerType($selected = 'openldap', $htmlname = 'type', $showempty = 0) + { + global $form; + + if (empty($selected)) { + $selected = 'openldap'; + } + if (empty($htmlname)) { + $htmlname = 'type'; + } + + $arraylist = array( + 'activedirectory' => 'Active Directory', + 'openldap' => 'OpenLdap', + 'egroupware' => 'Egroupware' + ); + + return $form->selectarray($htmlname, $arraylist, $selected, $showempty); + } + + /** + * Return list of ldap server protocol version + * + * @param string $selected Preselected type + * @param string $htmlname Name of field in form + * @param int $showempty Add an empty field + * @return string HTML select string + */ + public function selectLdapServerProtocolVersion($selected = '3', $htmlname = 'ldapprotocolversion', $showempty = 0) + { + global $form; + + if (empty($selected)) { + $selected = '3'; + } + if (empty($htmlname)) { + $htmlname = 'ldapprotocolversion'; + } + + $arraylist = array( + '3' => 'Version 3', + '2' => 'Version 2' + ); + + return $form->selectarray($htmlname, $arraylist, $selected, $showempty); + } +} diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index a1921ea2217..bd0ccbee5ac 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -122,6 +122,21 @@ class Ldap */ public $result; + /** + * No Ldap synchronization + */ + const SYNCHRO_NONE = 0; + + /** + * Dolibarr to Ldap synchronization + */ + const SYNCHRO_DOLIBARR_TO_LDAP = 1; + + /** + * Ldap to Dolibarr synchronization + */ + const SYNCHRO_LDAP_TO_DOLIBARR = 2; + /** * Constructor @@ -230,7 +245,7 @@ class Ldap dol_syslog(get_class($this)."::connect_bind failed to start tls", LOG_WARNING); $this->error = 'ldap_start_tls Failed to start TLS '.ldap_errno($this->connection).' '.ldap_error($this->connection); $connected = 0; - $this->close(); + $this->unbind(); } } @@ -279,7 +294,7 @@ class Ldap } if (!$connected) { - $this->close(); + $this->unbind(); } } } diff --git a/htdocs/core/login/functions_ldap.php b/htdocs/core/login/functions_ldap.php index 2d55ca2815b..5ae3af3f008 100644 --- a/htdocs/core/login/functions_ldap.php +++ b/htdocs/core/login/functions_ldap.php @@ -181,7 +181,7 @@ function check_user_password_ldap($usertotest, $passwordtotest, $entitytotest) } // ldap2dolibarr synchronisation - if ($login && !empty($conf->ldap->enabled) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr') { // ldap2dolibarr synchronisation + if ($login && !empty($conf->ldap->enabled) && $conf->global->LDAP_SYNCHRO_ACTIVE == Ldap::SYNCHRO_LDAP_TO_DOLIBARR) { // ldap2dolibarr synchronization dol_syslog("functions_ldap::check_user_password_ldap Sync ldap2dolibarr"); // On charge les attributs du user ldap diff --git a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php index d4db5ebccfc..24df646efd6 100644 --- a/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php +++ b/htdocs/core/triggers/interface_50_modLdap_Ldapsynchro.class.php @@ -81,7 +81,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers // Users if ($action == 'USER_CREATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -98,7 +98,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'USER_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -177,7 +177,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'USER_NEW_PASSWORD') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -212,7 +212,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); } elseif ($action == 'USER_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -229,7 +229,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } /*} elseif ($action == 'USER_SETINGROUP') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -263,7 +263,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'USER_REMOVEFROMGROUP') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -298,7 +298,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } elseif ($action == 'USERGROUP_CREATE') { // Groupes dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -320,7 +320,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'USERGROUP_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -353,7 +353,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'USERGROUP_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE === 'dolibarr2ldap') { + if (!empty($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -439,7 +439,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } elseif ($action == 'MEMBER_CREATE') { // Members dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -450,7 +450,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $result = $ldap->add($dn, $info, $user); // For member type - if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { if ($object->typeid > 0) { require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"; $membertype = new AdherentType($this->db); @@ -482,7 +482,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'MEMBER_VALIDATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { // If status field is setup to be synchronized if (!empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) { $ldap = new Ldap(); @@ -503,7 +503,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'MEMBER_SUBSCRIPTION') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { // If subscriptions fields are setup to be synchronized if ($conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE || $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT @@ -528,7 +528,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'MEMBER_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -557,7 +557,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $result = $ldap->update($dn, $info, $user, $olddn, $newrdn, $newparent); // For member type - if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"; /* @@ -616,7 +616,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'MEMBER_NEW_PASSWORD') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { // If password field is setup to be synchronized if ($conf->global->LDAP_FIELD_PASSWORD || $conf->global->LDAP_FIELD_PASSWORD_CRYPTED) { $ldap = new Ldap(); @@ -637,7 +637,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'MEMBER_RESILIATE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { // If status field is setup to be synchronized if (!empty($conf->global->LDAP_FIELD_MEMBER_STATUS)) { $ldap = new Ldap(); @@ -658,7 +658,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'MEMBER_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_ACTIVE) && (string) $conf->global->LDAP_MEMBER_ACTIVE == Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -669,7 +669,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers $result = $ldap->delete($dn); // For member type - if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { if ($object->typeid > 0) { require_once DOL_DOCUMENT_ROOT."/adherents/class/adherent_type.class.php"; @@ -706,7 +706,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } elseif ($action == 'MEMBER_TYPE_CREATE') { // Members types dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -728,7 +728,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'MEMBER_TYPE_MODIFY') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); @@ -765,7 +765,7 @@ class InterfaceLdapsynchro extends DolibarrTriggers } } elseif ($action == 'MEMBER_TYPE_DELETE') { dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id); - if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && (string) $conf->global->LDAP_MEMBER_TYPE_ACTIVE == '1') { + if (!empty($conf->global->LDAP_MEMBER_TYPE_ACTIVE) && getDolGlobalInt('LDAP_MEMBER_TYPE_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { $ldap = new Ldap(); $result = $ldap->connect_bind(); diff --git a/htdocs/langs/en_US/ldap.lang b/htdocs/langs/en_US/ldap.lang index b13e454159d..19dd29e0a51 100644 --- a/htdocs/langs/en_US/ldap.lang +++ b/htdocs/langs/en_US/ldap.lang @@ -26,4 +26,6 @@ ForceSynchronize=Force synchronizing Dolibarr -> LDAP ErrorFailedToReadLDAP=Failed to read LDAP database. Check LDAP module setup and database accessibility. PasswordOfUserInLDAP=Password of user in LDAP LDAPPasswordHashType=Password hash type -LDAPPasswordHashTypeExample=Type of password hash used on the server \ No newline at end of file +LDAPPasswordHashTypeExample=Type of password hash used on the server +SupportedForLDAPExportScriptOnly=Only supported by an ldap export script +SupportedForLDAPImportScriptOnly=Only supported by an ldap import script \ No newline at end of file diff --git a/htdocs/user/card.php b/htdocs/user/card.php index e3a72384050..da4cbf5fac0 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -731,7 +731,7 @@ if ($action == 'create' || $action == 'adduserldap') { print "
    "; - if (!empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && $conf->global->LDAP_SYNCHRO_ACTIVE == 'ldap2dolibarr')) { + if (!empty($conf->ldap->enabled) && (isset($conf->global->LDAP_SYNCHRO_ACTIVE) && getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_LDAP_TO_DOLIBARR)) { // Show form to add an account from LDAP if sync LDAP -> Dolibarr is set $ldap = new Ldap(); $result = $ldap->connect_bind(); diff --git a/htdocs/user/group/ldap.php b/htdocs/user/group/ldap.php index d8d1995a847..e3a01f27731 100644 --- a/htdocs/user/group/ldap.php +++ b/htdocs/user/group/ldap.php @@ -147,13 +147,13 @@ print dol_get_fiche_end(); */ print '
    '; -if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { +if (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { print ''.$langs->trans("ForceSynchronize").''; } print "
    \n"; -if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { +if (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { print "
    \n"; } diff --git a/htdocs/user/ldap.php b/htdocs/user/ldap.php index 8e12bf1b461..66199e9b3f6 100644 --- a/htdocs/user/ldap.php +++ b/htdocs/user/ldap.php @@ -153,13 +153,13 @@ print dol_get_fiche_end(); */ print '
    '; -if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { +if (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { print ''.$langs->trans("ForceSynchronize").''; } print "
    \n"; -if ($conf->global->LDAP_SYNCHRO_ACTIVE == 'dolibarr2ldap') { +if (getDolGlobalInt('LDAP_SYNCHRO_ACTIVE') === Ldap::SYNCHRO_DOLIBARR_TO_LDAP) { print "
    \n"; } From dd8d4e9e983c5650f31db1386fdb698ee668f315 Mon Sep 17 00:00:00 2001 From: ATM john Date: Thu, 4 Nov 2021 12:10:19 +0100 Subject: [PATCH 040/178] Fix missing return status --- htdocs/core/db/DoliDB.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 8f2a9dc315e..af470ac62d6 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -308,7 +308,7 @@ abstract class DoliDB implements Database * Note : This method executes a given SQL query and retrieves the first row of results as an object. It should only be used with SELECT queries * Dont add LIMIT to your query, it will be added by this method * @param string $sql the sql query string - * @return bool| object + * @return bool|int|object false on failure, 0 on empty, object on success */ public function getRow($sql) { @@ -317,7 +317,13 @@ abstract class DoliDB implements Database $res = $this->query($sql); if ($res) { - return $this->fetch_object($res); + $obj = $this->fetch_object($res); + if(!$obj){ + return 0; + } + else{ + return $obj; + } } return false; From 3959d12a39bf5022c6436b493b6de4be77f754fb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Nov 2021 12:42:42 +0100 Subject: [PATCH 041/178] Update DoliDB.class.php --- htdocs/core/db/DoliDB.class.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index af470ac62d6..68e29f22481 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -312,17 +312,15 @@ abstract class DoliDB implements Database */ public function getRow($sql) { - $sql .= ' LIMIT 1;'; + $sql .= ' LIMIT 1'; $res = $this->query($sql); - if ($res) - { + if ($res) { $obj = $this->fetch_object($res); - if(!$obj){ - return 0; - } - else{ + if ($obj) { return $obj; + } else { + return 0; } } From 19b9412c1357299940c14be206bf464fc774cd61 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Nov 2021 12:49:33 +0100 Subject: [PATCH 042/178] FIX #19305 --- htdocs/core/modules/modPropale.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index 007e92e4277..12835530bf9 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -156,7 +156,8 @@ class modPropale extends DolibarrModules $this->rights[$r][1] = 'Close commercial proposals'; // libelle de la permission $this->rights[$r][2] = 'd'; // type de la permission (deprecie a ce jour) $this->rights[$r][3] = 0; // La permission est-elle une permission par defaut - $this->rights[$r][4] = 'cloturer'; + $this->rights[$r][4] = 'propal_advance'; + $this->rights[$r][5] = 'close'; $r++; $this->rights[$r][0] = 27; // id de la permission From 15bc4a7d6b4b0a7a9c943b12989f3950b3fb5aad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 5 Nov 2021 13:18:37 +0100 Subject: [PATCH 043/178] Update index.php --- htdocs/adherents/stats/index.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/adherents/stats/index.php b/htdocs/adherents/stats/index.php index de9a5b3d9d9..7bf395e9bcc 100644 --- a/htdocs/adherents/stats/index.php +++ b/htdocs/adherents/stats/index.php @@ -195,9 +195,7 @@ foreach ($data as $val) { } print ''; print ''; - //print ''; - print ''.$year.''; - //print ''; + print ''.$year.''; print ''; print ''.$val['nb'].''; print ''.price(price2num($val['total'], 'MT'), 1).''; From 9d7f7e2090fa84ebece603aefa7fb34e7952bdb5 Mon Sep 17 00:00:00 2001 From: daraelmin Date: Fri, 5 Nov 2021 14:03:56 +0100 Subject: [PATCH 044/178] Better condition --- htdocs/adherents/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index e8a703a6efb..05e55206c02 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -943,7 +943,7 @@ if ($rowid > 0) { } if (!$datefrom) { $datefrom = $object->datevalid; - if ($object->datefin > 0 && dol_now() < dol_time_plus_duree(dol_time_plus_duree($object->datefin, 2 * $defaultdelay, $defaultdelayunit), -1, 'd')) { + if ($object->datefin > 0 && dol_time_plus_duree($object->datefin, $defaultdelay, $defaultdelayunit) < dol_now()) { $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); } else { $datefrom = dol_get_first_day(dol_print_date(time(), "%Y")); From 61d97ccd22abfc9fd60bce6741b7cf4e1d2047bf Mon Sep 17 00:00:00 2001 From: Nicolas Domenech Date: Fri, 5 Nov 2021 16:02:24 +0100 Subject: [PATCH 045/178] NEW : redirect after connection in login page --- htdocs/core/lib/security2.lib.php | 5 +++++ htdocs/core/tpl/login.tpl.php | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index ab47bc02899..d6546e64cfd 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -224,6 +224,11 @@ if (!function_exists('dol_loginfunction')) { $reshook = $hookmanager->executeHooks('getLoginPageExtraOptions', $parameters); // Note that $action and $object may have been modified by some hooks. $moreloginextracontent = $hookmanager->resPrint; + //Redirect after connection + $parameters = array('entity' => GETPOST('entity', 'int')); + $reshook = $hookmanager->executeHooks('redirectAfterConnection', $parameters); // Note that $action and $object may have been modified by some hooks. + $php_self = $hookmanager->resPrint; + // Login $login = (!empty($hookmanager->resArray['username']) ? $hookmanager->resArray['username'] : (GETPOST("username", "alpha") ? GETPOST("username", "alpha") : $demologin)); $password = $demopassword; diff --git a/htdocs/core/tpl/login.tpl.php b/htdocs/core/tpl/login.tpl.php index 0a4bb149986..9f2f2f68712 100644 --- a/htdocs/core/tpl/login.tpl.php +++ b/htdocs/core/tpl/login.tpl.php @@ -57,7 +57,7 @@ if (!empty($conf->dol_use_jmobile)) { $conf->use_javascript_ajax = 1; } -$php_self = dol_escape_htmltag($_SERVER['PHP_SELF']); +$php_self = empty($php_self) ? dol_escape_htmltag($_SERVER['PHP_SELF']) : $php_self; $php_self .= dol_escape_htmltag($_SERVER["QUERY_STRING"]) ? '?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]) : ''; if (!preg_match('/mainmenu=/', $php_self)) { $php_self .= (preg_match('/\?/', $php_self) ? '&' : '?').'mainmenu=home'; From 77864f2c2c45678f167c891e106d9912bf738edf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 Nov 2021 19:07:28 +0100 Subject: [PATCH 046/178] NEW Can set value for EHLO smtp command in MAIL_SMTP_USE_FROM_FOR_HELO --- htdocs/core/class/smtps.class.php | 77 ++++++++++++++++++++++++------- 1 file changed, 61 insertions(+), 16 deletions(-) diff --git a/htdocs/core/class/smtps.class.php b/htdocs/core/class/smtps.class.php index c287aae1c2f..dbaaacc2d18 100644 --- a/htdocs/core/class/smtps.class.php +++ b/htdocs/core/class/smtps.class.php @@ -464,20 +464,26 @@ class SMTPs $host = 'tls://'.$host; } - $hosth = $host; + $hosth = $host; // so for example 'localhost' or 'smtp-relay.gmail.com' if (!empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) { - // If the from to is 'aaa ', we will keep 'ccc.com' - $hosth = $this->getFrom('addr'); - $hosth = preg_replace('/^.*.*$/', '', $hosth); - $hosth = preg_replace('/.*@/', '', $hosth); + if (!is_numeric($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) { + // If value of MAIL_SMTP_USE_FROM_FOR_HELO is a string, we use it as domain name + $hosth = $conf->global->MAIL_SMTP_USE_FROM_FOR_HELO; + } else { + // If value of MAIL_SMTP_USE_FROM_FOR_HELO is 1, we use the domain in the from. + // So if the from to is 'aaa ', we will keep 'ccc.com' + $hosth = $this->getFrom('addr'); + $hosth = preg_replace('/^.*.*$/', '', $hosth); + $hosth = preg_replace('/.*@/', '', $hosth); + } } if ($_retVal = $this->socket_send_str('EHLO '.$hosth, '250')) { if ($usetls) { /* - The following dialog illustrates how a client and server can start a TLS STARTTLS session + The following dialog illustrates how a client and server can start a TLS STARTTLS session: S: C: S: 220 mail.imc.org SMTP service ready @@ -494,6 +500,39 @@ class SMTPs S: 250-server-domain.com S: 250 AUTH LOGIN C: + S: 250 OK + C: RCPT TO: + S: 250 OK + C: DATA + S: 354 Send message, end with a "." on a line by itself + C: + S . + S: 250 OK, message accepted for delivery: queued as 12345 + C: QUIT + S: 221 Bye */ if (!$_retVal = $this->socket_send_str('STARTTLS', 220)) { $this->_setErr(131, 'STARTTLS connection is not supported.'); @@ -517,10 +556,10 @@ class SMTPs $this->_setErr(132, 'STARTTLS connection failed.'); return $_retVal; } - // Most server servers expect a 2nd pass of EHLO after TLS is established to get another time + // Most servers expect a 2nd pass of EHLO after TLS is established to get another time // the answer with list of supported AUTH methods. They may differs between non STARTTLS and with STARTTLS. - if (!$_retVal = $this->socket_send_str('EHLO '.$hosth, '250')) { - $this->_setErr(126, '"'.$hosth.'" does not support authenticated connections.'); + if (! $_retVal = $this->socket_send_str('EHLO '.$hosth, '250')) { + $this->_setErr(126, '"'.$hosth.'" does not support authenticated connections. Error after sending EHLO '.$hosth); return $_retVal; } } @@ -560,7 +599,7 @@ class SMTPs $this->_setErr(130, 'Invalid Authentication Credentials.'); } } else { - $this->_setErr(126, '"'.$host.'" does not support authenticated connections.'); + $this->_setErr(126, '"'.$host.'" does not support authenticated connections. Error after sending EHLO '.$hosth); } return $_retVal; @@ -603,11 +642,17 @@ class SMTPs $hosth = $host; if (!empty($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) { - // If the from to is 'aaa ', we will keep 'ccc.com' - $hosth = $this->getFrom('addr'); - $hosth = preg_replace('/^.*.*$/', '', $hosth); - $hosth = preg_replace('/.*@/', '', $hosth); + if (!is_numeric($conf->global->MAIL_SMTP_USE_FROM_FOR_HELO)) { + // If value of MAIL_SMTP_USE_FROM_FOR_HELO is a string, we use it as domain name + $hosth = $conf->global->MAIL_SMTP_USE_FROM_FOR_HELO; + } else { + // If value of MAIL_SMTP_USE_FROM_FOR_HELO is 1, we use the domain in the from. + // If the from to is 'aaa ', we will keep 'ccc.com' + $hosth = $this->getFrom('addr'); + $hosth = preg_replace('/^.*.*$/', '', $hosth); + $hosth = preg_replace('/.*@/', '', $hosth); + } } $_retVal = $this->socket_send_str('HELO '.$hosth, '250'); From 65105a3e05b26a8c6959da65394ed38fb909df42 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 Nov 2021 19:27:50 +0100 Subject: [PATCH 047/178] Better log --- htdocs/core/class/ldap.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index e2ce33cc45f..48618a83dd9 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -261,7 +261,7 @@ class Ldap } // Try in anonymous if (!$this->bind) { - dol_syslog(get_class($this)."::connect_bind try bind on ".$host, LOG_DEBUG); + dol_syslog(get_class($this)."::connect_bind try bind anonymously on ".$host, LOG_DEBUG); $result = $this->bind(); if ($result) { $this->bind = $this->result; From fc70adb2e74f53dbcf3746b94731dc55ae4df8c9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 6 Nov 2021 20:40:26 +0100 Subject: [PATCH 048/178] Fix ref suffix for patnership into PSHIP --- .../core/modules/partnership/mod_partnership_standard.php | 2 +- htdocs/partnership/partnership_card.php | 4 ++-- htdocs/partnership/partnership_list.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php b/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php index fefcafa2350..d5a2bb326b2 100644 --- a/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php +++ b/htdocs/partnership/core/modules/partnership/mod_partnership_standard.php @@ -36,7 +36,7 @@ class mod_partnership_standard extends ModeleNumRefPartnership */ public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' - public $prefix = 'PARTNERSHIP'; + public $prefix = 'PSHIP'; /** * @var string Error code (or message) diff --git a/htdocs/partnership/partnership_card.php b/htdocs/partnership/partnership_card.php index 99cdb74e264..72787042e0e 100644 --- a/htdocs/partnership/partnership_card.php +++ b/htdocs/partnership/partnership_card.php @@ -232,7 +232,7 @@ if (empty($reshook)) { // Actions to send emails $triggersendname = 'PARTNERSHIP_SENTBYMAIL'; $autocopy = 'MAIN_MAIL_AUTOCOPY_PARTNERSHIP_TO'; - $trackid = 'partnership'.$object->id; + $trackid = 'pship'.$object->id; include DOL_DOCUMENT_ROOT.'/core/actions_sendmails.inc.php'; if (!empty($id) && !empty(GETPOST('confirm'))) { @@ -664,7 +664,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea $modelmail = 'partnership_send'; $defaulttopic = 'InformationMessage'; $diroutput = $conf->partnership->dir_output; - $trackid = 'partnership'.$object->id; + $trackid = 'pship'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php'; } diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index a5c52609d74..ef3b55ae44b 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -464,7 +464,7 @@ print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sort $topicmail = "SendPartnershipRef"; $modelmail = "partnership_send"; $objecttmp = new Partnership($db); -$trackid = 'partnership'.$object->id; +$trackid = 'pship'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; if ($search_all) { From ccc1d4d1fa1871d7b5680376427dbd95a43ef513 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 12:24:25 +0100 Subject: [PATCH 049/178] Fix warning --- htdocs/core/lib/pdf.lib.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 4821bfde2b9..3ba436cf28c 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -979,6 +979,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $outputlangs->load("dict"); $line = ''; + $reg = aray(); $dims = $pdf->getPageDimensions(); @@ -1273,6 +1274,7 @@ function pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $pos // Fix bug of some HTML editors that replace links ]*src=")([^"]*)(&)([^"]*")/', '\1\2&\4', $labelproductservice, -1, $nbrep); //var_dump($labelproductservice);exit; From 713db0e61355924009116566e720c8e90bc8b7e7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 12:26:44 +0100 Subject: [PATCH 050/178] Removed function pdf_getTotalQty (duplicate with pdf_getlineqty) --- htdocs/core/lib/pdf.lib.php | 42 ------------------------------------- 1 file changed, 42 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 1a8d15a4fc4..c8334edc705 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2214,48 +2214,6 @@ function pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails = 0) return $result; } -/** - * Return total quantity of products and/or services - * - * @param Object $object Object - * @param string $type Type - * @param Translate $outputlangs Object langs for output - * @return integer - * @deprecated Not used by Dolibarr core, so will be removed. - */ -function pdf_getTotalQty($object, $type, $outputlangs) -{ - global $hookmanager; - - $total = 0; - $nblines = count($object->lines); - - // Loop on each lines - for ($i = 0; $i < $nblines; $i++) { - if ($object->lines[$i]->special_code != 3) { - if ($type == 'all') { - $total += $object->lines[$i]->qty; - } elseif ($type == 9 && is_object($hookmanager) && (($object->lines[$i]->product_type == 9 && !empty($object->lines[$i]->special_code)) || !empty($object->lines[$i]->fk_parent_line))) { - $special_code = $object->lines[$i]->special_code; - if (!empty($object->lines[$i]->fk_parent_line)) { - $special_code = $object->getSpecialCode($object->lines[$i]->fk_parent_line); - } - $hidedetails = ''; - $parameters = array('i'=>$i, 'outputlangs'=>$outputlangs, 'hidedetails'=>$hidedetails, 'special_code'=>$special_code); - $action = ''; - $reshook = $hookmanager->executeHooks('pdf_getTotalQty', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks - return $hookmanager->resPrint; - } elseif ($type == 0 && $object->lines[$i]->product_type == 0) { - $total += $object->lines[$i]->qty; - } elseif ($type == 1 && $object->lines[$i]->product_type == 1) { - $total += $object->lines[$i]->qty; - } - } - } - - return $total; -} - /** * Return linked objects to use for document generation. * Warning: To save space, this function returns only one link per link type (all links are concated on same record string). This function is used by pdf_writeLinkedObjects From 11bb7428cedf682dd322f1494b545e80d7c5f3f6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 12:34:08 +0100 Subject: [PATCH 051/178] Clean code --- htdocs/fourn/facture/list.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 6c133c9b5a1..7dbead5536b 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -975,13 +975,13 @@ if ($resql) { // Ref if (!empty($arrayfields['f.ref']['checked'])) { print ''; - print ''; + print ''; print ''; } // Ref supplier if (!empty($arrayfields['f.ref_supplier']['checked'])) { print ''; - print ''; + print ''; print ''; } // Type @@ -1006,7 +1006,7 @@ if ($resql) { // Label if (!empty($arrayfields['f.label']['checked'])) { print ''; - print ''; + print ''; print ''; } // Date invoice @@ -1037,11 +1037,11 @@ if ($resql) { } // Project if (!empty($arrayfields['p.ref']['checked'])) { - print ''; + print ''; } // Thirpdarty if (!empty($arrayfields['s.nom']['checked'])) { - print ''; + print ''; } // Town if (!empty($arrayfields['s.town']['checked'])) { @@ -1096,13 +1096,13 @@ if ($resql) { if (!empty($arrayfields['f.total_localtax1']['checked'])) { // Amount tax 1 print ''; - print ''; + print ''; print ''; } if (!empty($arrayfields['f.total_localtax2']['checked'])) { // Amount tax 2 print ''; - print ''; + print ''; print ''; } if (!empty($arrayfields['f.total_ttc']['checked'])) { From 09d9d1ac4242a626d253fe4b02c6fe2d667b1958 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 12:38:44 +0100 Subject: [PATCH 052/178] Add missing unique key --- .../install/mysql/migration/14.0.0-15.0.0.sql | 2 ++ .../tables/llx_c_partnership_type.key.sql | 19 +++++++++++++++++++ .../mysql/tables/llx_c_partnership_type.sql | 2 +- 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 htdocs/install/mysql/tables/llx_c_partnership_type.key.sql diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 02a18f69a40..2c460d4ab88 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -80,6 +80,8 @@ INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, -- v15 +ALTER TABLE llx_c_partnership_type ADD UNIQUE INDEX uk_c_partnership_type(entity, code); + ALTER TABLE llx_c_holiday_types CHANGE COLUMN newByMonth newbymonth double(8,5) DEFAULT 0 NOT NULL; ALTER TABLE llx_product ADD COLUMN mandatory_period tinyint NULL DEFAULT 0; diff --git a/htdocs/install/mysql/tables/llx_c_partnership_type.key.sql b/htdocs/install/mysql/tables/llx_c_partnership_type.key.sql new file mode 100644 index 00000000000..c4aa0c04b0a --- /dev/null +++ b/htdocs/install/mysql/tables/llx_c_partnership_type.key.sql @@ -0,0 +1,19 @@ +-- ======================================================================== +-- Copyright (C) 2021 Laurent Destailleur +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- 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 . +-- +-- ======================================================================== + +ALTER TABLE llx_c_partnership_type ADD UNIQUE INDEX uk_c_partnership_type(entity, code); diff --git a/htdocs/install/mysql/tables/llx_c_partnership_type.sql b/htdocs/install/mysql/tables/llx_c_partnership_type.sql index 23d5a89e16c..d2a4a3b7549 100644 --- a/htdocs/install/mysql/tables/llx_c_partnership_type.sql +++ b/htdocs/install/mysql/tables/llx_c_partnership_type.sql @@ -30,6 +30,6 @@ create table llx_c_partnership_type entity integer DEFAULT 1 NOT NULL, code varchar(32) NOT NULL, label varchar(64) NOT NULL, - active tinyint DEFAULT 1 NOT NULL + active tinyint DEFAULT 1 NOT NULL )ENGINE=innodb; From e8a2fc33c31fce90c5c51563a0ea3021e2caa2de Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 12:47:03 +0100 Subject: [PATCH 053/178] Fix visiblity of dictionnary for MAIN_USE_EXPENSE_IK --- htdocs/admin/dict.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 4a5a09a3461..035d44cf3b2 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -509,8 +509,8 @@ $tabcond[30] = !empty($conf->label->enabled); $tabcond[32] = (!empty($conf->holiday->enabled) || !empty($conf->hrm->enabled)); $tabcond[33] = !empty($conf->hrm->enabled); $tabcond[34] = !empty($conf->hrm->enabled); -$tabcond[35] = !empty($conf->expensereport->enabled); -$tabcond[36] = !empty($conf->expensereport->enabled); +$tabcond[35] = !empty($conf->expensereport->enabled) && !empty($conf->global->MAIN_USE_EXPENSE_IK); +$tabcond[36] = !empty($conf->expensereport->enabled) && !empty($conf->global->MAIN_USE_EXPENSE_IK); $tabcond[37] = !empty($conf->product->enabled); $tabcond[38] = !empty($conf->socialnetworks->enabled); $tabcond[39] = (!empty($conf->societe->enabled) && empty($conf->global->SOCIETE_DISABLE_PROSPECTS) && !empty($conf->global->THIRDPARTY_ENABLE_PROSPECTION_ON_ALTERNATIVE_ADRESSES)); From 22345225190627b3b1a44c5a9d121db2af9931aa Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 13:51:31 +0100 Subject: [PATCH 054/178] Debug module parnership. Add the type of partnership. --- htdocs/admin/dict.php | 2 +- htdocs/core/lib/modulebuilder.lib.php | 4 +- .../install/mysql/migration/14.0.0-15.0.0.sql | 2 + .../install/mysql/tables/llx_partnership.sql | 1 + htdocs/modulebuilder/index.php | 29 +- .../template/class/myobject.class.php | 6 +- .../partnership/class/partnership.class.php | 18 +- .../class/partnership_type.class.php | 562 ++++++++++++++++++ 8 files changed, 609 insertions(+), 15 deletions(-) create mode 100644 htdocs/partnership/class/partnership_type.class.php diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php index 035d44cf3b2..35fd58980b1 100644 --- a/htdocs/admin/dict.php +++ b/htdocs/admin/dict.php @@ -2107,7 +2107,7 @@ if ($id) { if ($iserasable) { print ''; if ($user->admin) { - print ''.img_delete().''; + print ''.img_delete().''; } //else print ''.img_delete().''; // Some dictionary can be edited by other profile than admin print ''; diff --git a/htdocs/core/lib/modulebuilder.lib.php b/htdocs/core/lib/modulebuilder.lib.php index a5589679b50..d44da05fa38 100644 --- a/htdocs/core/lib/modulebuilder.lib.php +++ b/htdocs/core/lib/modulebuilder.lib.php @@ -17,8 +17,8 @@ */ /** - * \file htdocs/core/lib/memory.lib.php - * \brief Set of function for memory/cache management + * \file htdocs/core/lib/modulebuilder.lib.php + * \brief Set of function for modulebuilder management */ diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 2c460d4ab88..960b8010d51 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -82,6 +82,8 @@ INSERT INTO llx_c_email_templates (entity, module, type_template, lang, private, ALTER TABLE llx_c_partnership_type ADD UNIQUE INDEX uk_c_partnership_type(entity, code); +ALTER TABLE llx_partnership ADD COLUMN fk_type integer DEFAULT 0 NOT NULL; + ALTER TABLE llx_c_holiday_types CHANGE COLUMN newByMonth newbymonth double(8,5) DEFAULT 0 NOT NULL; ALTER TABLE llx_product ADD COLUMN mandatory_period tinyint NULL DEFAULT 0; diff --git a/htdocs/install/mysql/tables/llx_partnership.sql b/htdocs/install/mysql/tables/llx_partnership.sql index 6ab312f8875..47ee7f3a48b 100644 --- a/htdocs/install/mysql/tables/llx_partnership.sql +++ b/htdocs/install/mysql/tables/llx_partnership.sql @@ -20,6 +20,7 @@ CREATE TABLE llx_partnership( rowid integer AUTO_INCREMENT PRIMARY KEY NOT NULL, ref varchar(128) DEFAULT '(PROV)' NOT NULL, status smallint NOT NULL DEFAULT '0', + fk_type integer DEFAULT 0 NOT NULL, fk_soc integer, fk_member integer, date_partnership_start date NOT NULL, diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index cab90270d64..9239413d951 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -262,6 +262,7 @@ if ($dirins && $action == 'initmodule' && $modulename) { // Delete some files related to Object (because the previous dolCopyDir has copied everything) dol_delete_file($destdir.'/myobject_card.php'); + dol_delete_file($destdir.'/myobject_contact.php'); dol_delete_file($destdir.'/myobject_note.php'); dol_delete_file($destdir.'/myobject_document.php'); dol_delete_file($destdir.'/myobject_agenda.php'); @@ -337,6 +338,14 @@ if ($dirins && $action == 'initmodule' && $modulename) { setEventMessages('ModuleInitialized', null); $module = $modulename; $modulename = ''; + + clearstatcache(true); + if (function_exists('opcache_invalidate')) { + opcache_reset(); // remove the include cache hell ! + } + + header("Location: ".$_SERVER["PHP_SELF"].'?module='.$modulename); + exit; } } @@ -953,7 +962,7 @@ if ($dirins && $action == 'initobject' && $module && GETPOST('createtablearray', if ($notnull) { $string .= ", 'notnull'=>".$notnull; } - if ($fieldname == 'ref') { + if ($fieldname == 'ref' || $fieldname == 'code') { $string .= ", 'showoncombobox'=>1"; } $string .= ", 'position'=>".$position; @@ -1417,6 +1426,14 @@ if ($dirins && $action == 'confirm_deletemodule') { if ($result > 0) { setEventMessages($langs->trans("DirWasRemoved", $modulelowercase), null); + + clearstatcache(true); + if (function_exists('opcache_invalidate')) { + opcache_reset(); // remove the include cache hell ! + } + + header("Location: ".$_SERVER["PHP_SELF"].'?module=deletemodule'); + exit; } else { setEventMessages($langs->trans("PurgeNothingToDelete"), null, 'warnings'); } @@ -1757,6 +1774,10 @@ if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') { $loadclasserrormessage = $e->getMessage()."
    \n"; $loadclasserrormessage .= 'File: '.$e->getFile()."
    \n"; $loadclasserrormessage .= 'Line: '.$e->getLine()."
    \n"; + } catch (Exception $e) { + $loadclasserrormessage = $e->getMessage()."
    \n"; + $loadclasserrormessage .= 'File: '.$e->getFile()."
    \n"; + $loadclasserrormessage .= 'Line: '.$e->getLine()."
    \n"; } if (class_exists($class)) { @@ -1771,6 +1792,7 @@ if (!empty($module) && $module != 'initmodule' && $module != 'deletemodule') { $error++; } $langs->load("errors"); + print ''; print img_warning('').' '.$langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).'
    '; print $loadclasserrormessage; } @@ -2423,8 +2445,8 @@ if ($module == 'initmodule') { print ''.$langs->trans("EnterNameOfObjectDesc").'

    '; print '
    '; - print ' '.$form->textwithpicto($langs->trans("IncludeRefGeneration"), $langs->trans("IncludeRefGenerationHelp")).'
    '; - print ' '.$form->textwithpicto($langs->trans("IncludeDocGeneration"), $langs->trans("IncludeDocGenerationHelp")).'
    '; + print '
    '; + print '
    '; print ''; print '
    '; print '
    '; @@ -2633,6 +2655,7 @@ if ($module == 'initmodule') { print '


    '; + clearstatcache(true); if (function_exists('opcache_invalidate')) { opcache_invalidate($dirread.'/'.$pathtoclass, true); // remove the include cache hell ! } diff --git a/htdocs/modulebuilder/template/class/myobject.class.php b/htdocs/modulebuilder/template/class/myobject.class.php index 8e316d014d5..6e5d6efcff4 100644 --- a/htdocs/modulebuilder/template/class/myobject.class.php +++ b/htdocs/modulebuilder/template/class/myobject.class.php @@ -767,7 +767,7 @@ class MyObject extends CommonObject if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { $add_save_lastsearch_values = 1; } - if ($add_save_lastsearch_values) { + if ($url && $add_save_lastsearch_values) { $url .= '&save_lastsearch_values=1'; } } @@ -784,13 +784,13 @@ class MyObject extends CommonObject $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } - if ($option == 'nolink') { + if ($option == 'nolink' || empty($url)) { $linkstart = ''; - if ($option == 'nolink') { + if ($option == 'nolink' || empty($url)) { $linkend = ''; } else { $linkend = ''; diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index f2b15735762..b378435e546 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2021 NextGestion +/* Copyright (C) 2017 Laurent Destailleur + * Copyright (C) 2021 NextGestion * * 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 @@ -27,6 +27,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; //require_once DOL_DOCUMENT_ROOT . '/societe/class/societe.class.php'; //require_once DOL_DOCUMENT_ROOT . '/product/class/product.class.php'; + /** * Class for Partnership */ @@ -105,7 +106,7 @@ class Partnership extends CommonObject 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'ref' => array('type'=>'varchar(128)', 'label'=>'Ref', 'enabled'=>'1', 'position'=>10, 'notnull'=>1, 'visible'=>4, 'noteditable'=>'1', 'default'=>'(PROV)', 'index'=>1, 'searchall'=>1, 'showoncombobox'=>'1', 'comment'=>"Reference of object"), 'entity' => array('type' => 'integer', 'label' => 'Entity', 'default' => 1, 'enabled' => 1, 'visible' => -2, 'notnull' => 1, 'position' => 15, 'index' => 1), - //'fk_type' => array('type' => 'integer:PartnershipType:partnership/class/partnershiptype.class.php', 'label' => 'Type', 'default' => 1, 'enabled' => 1, 'visible' => 1, 'position' => 20), + 'fk_type' => array('type' => 'integer:PartnershipType:partnership/class/partnership_type.class.php', 'label' => 'Type', 'enabled' => 1, 'visible' => 1, 'position' => 20), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0,), 'note_private' => array('type'=>'html', 'label'=>'NotePrivate', 'enabled'=>'1', 'position'=>62, 'notnull'=>0, 'visible'=>0,), 'date_creation' => array('type'=>'datetime', 'label'=>'DateCreation', 'enabled'=>'1', 'position'=>500, 'notnull'=>1, 'visible'=>-2,), @@ -366,14 +367,15 @@ class Partnership extends CommonObject return -1; } - $sql = 'SELECT p.rowid, p.ref, p.fk_soc, p.fk_member, p.status'; + $sql = 'SELECT p.rowid, p.ref, p.fk_type, p.fk_soc, p.fk_member, p.status'; $sql .= ', p.entity, p.date_partnership_start, p.date_partnership_end, p.date_creation'; $sql .= ', p.fk_user_creat, p.tms, p.fk_user_modif, p.fk_user_modif'; $sql .= ', p.note_private, p.note_public'; $sql .= ', p.last_main_doc, p.count_last_url_check_error, p.last_check_backlink, p.reason_decline_or_cancel'; $sql .= ', p.import_key, p.model_pdf'; - + $sql .= ', pt.code as type_code, pt.label as type_label'; $sql .= ' FROM '.MAIN_DB_PREFIX.'partnership as p'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_partnership_type as pt ON p.fk_type = pt.rowid'; if ($id) { $sql .= " WHERE p.rowid=".((int) $id); @@ -400,8 +402,12 @@ class Partnership extends CommonObject if ($obj) { $this->id = $obj->rowid; $this->entity = $obj->entity; - $this->rowid = $obj->rowid; $this->ref = $obj->ref; + + $this->fk_type = $obj->fk_type; + $this->type_code = $obj->type_code; + $this->type_label = $obj->type_label; + $this->fk_soc = $obj->fk_soc; $this->fk_member = $obj->fk_member; $this->status = $obj->status; diff --git a/htdocs/partnership/class/partnership_type.class.php b/htdocs/partnership/class/partnership_type.class.php new file mode 100644 index 00000000000..6916d95e4f3 --- /dev/null +++ b/htdocs/partnership/class/partnership_type.class.php @@ -0,0 +1,562 @@ + + * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2009-2017 Regis Houssin + * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2018-2019 Thibault Foucart + * Copyright (C) 2021 Waël Almoman + * + * 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 . + */ + +/** + * \file htdocs/partnership/class/partnership_type.class.php + * \ingroup partnership + * \brief File of class to manage partnership types + */ + +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; + + +/** + * Class to manage partnership type + */ +class PartnershipType extends CommonObject +{ + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'c_partnership_type'; + + /** + * @var string ID to identify managed object + */ + public $element = 'partnership_type'; + + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'generic'; + + /** + * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe + * @var int + */ + public $ismultientitymanaged = 1; + + /** + * @var string Partnership code + */ + public $code; + + /** + * @var string Partnership type label + */ + public $label; + + + public $fields=array( + 'rowid' =>array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>10), + 'entity' =>array('type'=>'integer', 'label'=>'Entity', 'default'=>1, 'enabled'=>1, 'visible'=>-2, 'notnull'=>1, 'position'=>15, 'index'=>1), + 'code' =>array('type'=>'varchar(32)', 'label'=>'Code', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>20, 'showoncombobox'=>1), + 'label' =>array('type'=>'varchar(64)', 'label'=>'Label', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>25, 'showoncombobox'=>1), + 'active' =>array('type'=>'integer', 'label'=>'Active', 'enabled'=>1, 'visible'=>-1, 'notnull'=>1, 'position'=>30), + ); + + + + /** + * Constructor + * + * @param DoliDb $db Database handler + */ + public function __construct(DoliDB $db) + { + global $conf, $langs; + + $this->db = $db; + + if (empty($conf->global->MAIN_SHOW_TECHNICAL_ID) && isset($this->fields['rowid'])) { + $this->fields['rowid']['visible'] = 0; + } + if (empty($conf->multicompany->enabled) && isset($this->fields['entity'])) { + $this->fields['entity']['enabled'] = 0; + } + + // Example to show how to set values of fields definition dynamically + /*if ($user->rights->mymodule->myobject->read) { + $this->fields['myfield']['visible'] = 1; + $this->fields['myfield']['noteditable'] = 0; + }*/ + + // Unset fields that are disabled + foreach ($this->fields as $key => $val) { + if (isset($val['enabled']) && empty($val['enabled'])) { + unset($this->fields[$key]); + } + } + + // Translate some data of arrayofkeyval + if (is_object($langs)) { + foreach ($this->fields as $key => $val) { + if (!empty($val['arrayofkeyval']) && is_array($val['arrayofkeyval'])) { + foreach ($val['arrayofkeyval'] as $key2 => $val2) { + $this->fields[$key]['arrayofkeyval'][$key2] = $langs->trans($val2); + } + } + } + } + } + + /** + * Create object into database + * + * @param User $user User that creates + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, Id of created object if OK + */ + public function create(User $user, $notrigger = false) + { + $resultcreate = $this->createCommon($user, $notrigger); + + //$resultvalidate = $this->validate($user, $notrigger); + + return $resultcreate; + } + + /** + * Load object in memory from the database + * + * @param int $id Id object + * @param string $ref Ref + * @return int <0 if KO, 0 if not found, >0 if OK + */ + public function fetch($id, $ref = null) + { + $result = $this->fetchCommon($id, $ref); + if ($result > 0 && !empty($this->table_element_line)) { + $this->fetchLines(); + } + return $result; + } + + /** + * Load list of objects in memory from the database. + * + * @param string $sortorder Sort Order + * @param string $sortfield Sort field + * @param int $limit limit + * @param int $offset Offset + * @param array $filter Filter array. Example array('field'=>'valueforlike', 'customurl'=>...) + * @param string $filtermode Filter mode (AND or OR) + * @return array|int int <0 if KO, array of pages if OK + */ + public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') + { + global $conf; + + dol_syslog(__METHOD__, LOG_DEBUG); + + $records = array(); + + $sql = "SELECT "; + $sql .= $this->getFieldList('t'); + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) { + $sql .= " WHERE t.entity IN (".getEntity($this->table_element).")"; + } else { + $sql .= " WHERE 1 = 1"; + } + // Manage filter + $sqlwhere = array(); + if (count($filter) > 0) { + foreach ($filter as $key => $value) { + if ($key == 't.rowid') { + $sqlwhere[] = $key." = ".((int) $value); + } elseif (in_array($this->fields[$key]['type'], array('date', 'datetime', 'timestamp'))) { + $sqlwhere[] = $key." = '".$this->db->idate($value)."'"; + } elseif ($key == 'customsql') { + $sqlwhere[] = $value; + } elseif (strpos($value, '%') === false) { + $sqlwhere[] = $key." IN (".$this->db->sanitize($this->db->escape($value)).")"; + } else { + $sqlwhere[] = $key." LIKE '%".$this->db->escape($value)."%'"; + } + } + } + if (count($sqlwhere) > 0) { + $sql .= " AND (".implode(" ".$filtermode." ", $sqlwhere).")"; + } + + if (!empty($sortfield)) { + $sql .= $this->db->order($sortfield, $sortorder); + } + if (!empty($limit)) { + $sql .= $this->db->plimit($limit, $offset); + } + + $resql = $this->db->query($sql); + if ($resql) { + $num = $this->db->num_rows($resql); + $i = 0; + while ($i < ($limit ? min($limit, $num) : $num)) { + $obj = $this->db->fetch_object($resql); + + $record = new self($this->db); + $record->setVarsFromFetchObj($obj); + + $records[$record->id] = $record; + + $i++; + } + $this->db->free($resql); + + return $records; + } else { + $this->errors[] = 'Error '.$this->db->lasterror(); + dol_syslog(__METHOD__.' '.join(',', $this->errors), LOG_ERR); + + return -1; + } + } + + /** + * Update object into database + * + * @param User $user User that modifies + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update(User $user, $notrigger = false) + { + return $this->updateCommon($user, $notrigger); + } + + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + //return $this->deleteCommon($user, $notrigger, 1); + } + + /** + * Set draft status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, >0 if OK + */ + public function setDraft($user, $notrigger = 0) + { + // Protection + if ($this->status <= self::STATUS_DRAFT) { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_DRAFT, $notrigger, 'PARTNERSHIPTYPE_UNVALIDATE'); + } + + /** + * Set cancel status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function cancel($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_VALIDATED) { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_CANCELED, $notrigger, 'PARTNERSHIPTYPE_CANCEL'); + } + + /** + * Set back to validated status + * + * @param User $user Object user that modify + * @param int $notrigger 1=Does not execute triggers, 0=Execute triggers + * @return int <0 if KO, 0=Nothing done, >0 if OK + */ + public function reopen($user, $notrigger = 0) + { + // Protection + if ($this->status != self::STATUS_CANCELED) { + return 0; + } + + /*if (! ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->write)) + || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->mymodule->mymodule_advance->validate)))) + { + $this->error='Permission denied'; + return -1; + }*/ + + return $this->setStatusCommon($user, self::STATUS_VALIDATED, $notrigger, 'PARTNERSHIPTYPE_REOPEN'); + } + + /** + * Return a link to the object card (with optionaly the picto) + * + * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) + * @param string $option On what the link point to ('nolink', ...) + * @param int $notooltip 1=Disable tooltip + * @param string $morecss Add more css on link + * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking + * @return string String with URL + */ + public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) + { + global $conf, $langs, $hookmanager; + + if (!empty($conf->dol_no_mouse_hover)) { + $notooltip = 1; // Force disable tooltips + } + + $result = ''; + + $label = img_picto('', $this->picto).' '.$langs->trans("PartnershipType").''; + if (isset($this->status)) { + $label .= ' '.$this->getLibStatut(5); + } + $label .= '
    '; + $label .= ''.$langs->trans('Code').': '.$this->code; + $label .= '
    '.$langs->trans('Label').': '.$this->label; + + //$url = dol_buildpath('/partnership/partnership_card.php', 1).'?id='.$this->id; + $url = ''; + + if ($option != 'nolink') { + // Add param to save lastsearch_values or not + $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); + if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { + $add_save_lastsearch_values = 1; + } + if ($url && $add_save_lastsearch_values) { + $url .= '&save_lastsearch_values=1'; + } + } + + $linkclose = ''; + if (empty($notooltip)) { + if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) { + $label = $langs->trans("ShowMyObject"); + $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; + } + $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; + $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; + } else { + $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); + } + + if ($option == 'nolink' || empty($url)) { + $linkstart = ''; + if ($option == 'nolink' || empty($url)) { + $linkend = ''; + } else { + $linkend = ''; + } + + $result .= $linkstart; + + if (empty($this->showphoto_on_popup)) { + if ($withpicto) { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + } else { + if ($withpicto) { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + list($class, $module) = explode('@', $this->picto); + $upload_dir = $conf->$module->multidir_output[$conf->entity]."/$class/".dol_sanitizeFileName($this->ref); + $filearray = dol_dir_list($upload_dir, "files"); + $filename = $filearray[0]['name']; + if (!empty($filename)) { + $pospoint = strpos($filearray[0]['name'], '.'); + + $pathtophoto = $class.'/'.$this->ref.'/thumbs/'.substr($filename, 0, $pospoint).'_mini'.substr($filename, $pospoint); + if (empty($conf->global->{strtoupper($module.'_'.$class).'_FORMATLISTPHOTOSASUSERS'})) { + $result .= '
    No photo
    '; + } else { + $result .= '
    No photo
    '; + } + + $result .= '
    '; + } else { + $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1); + } + } + } + + if ($withpicto != 2) { + $result .= $this->ref; + } + + $result .= $linkend; + //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); + + global $action, $hookmanager; + $hookmanager->initHooks(array('myobjectdao')); + $parameters = array('id'=>$this->id, 'getnomurl'=>$result); + $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks + if ($reshook > 0) { + $result = $hookmanager->resPrint; + } else { + $result .= $hookmanager->resPrint; + } + + return $result; + } + + /** + * Return the label of the status + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function getLabelStatus($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } + + /** + * Return the label of the status + * + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->status, $mode); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Return the status + * + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=Short label + Picto, 6=Long label + Picto + * @return string Label of status + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + if (empty($this->labelStatus) || empty($this->labelStatusShort)) { + global $langs; + //$langs->load("mymodule@mymodule"); + $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); + $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled'); + $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled'); + $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); + $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Enabled'); + $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Disabled'); + } + + $statusType = 'status'.$status; + //if ($status == self::STATUS_VALIDATED) $statusType = 'status1'; + if ($status == self::STATUS_CANCELED) { + $statusType = 'status6'; + } + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); + } + + /** + * Load the info information in the object + * + * @param int $id Id of object + * @return void + */ + public function info($id) + { + $sql = "SELECT rowid, date_creation as datec, tms as datem,"; + $sql .= " fk_user_creat, fk_user_modif"; + $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element." as t"; + $sql .= " WHERE t.rowid = ".((int) $id); + + $result = $this->db->query($sql); + if ($result) { + if ($this->db->num_rows($result)) { + $obj = $this->db->fetch_object($result); + $this->id = $obj->rowid; + if ($obj->fk_user_author) { + $cuser = new User($this->db); + $cuser->fetch($obj->fk_user_author); + $this->user_creation = $cuser; + } + + if ($obj->fk_user_valid) { + $vuser = new User($this->db); + $vuser->fetch($obj->fk_user_valid); + $this->user_validation = $vuser; + } + + if ($obj->fk_user_cloture) { + $cluser = new User($this->db); + $cluser->fetch($obj->fk_user_cloture); + $this->user_cloture = $cluser; + } + + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->datem); + $this->date_validation = $this->db->jdate($obj->datev); + } + + $this->db->free($result); + } else { + dol_print_error($this->db); + } + } + + /** + * Initialise object with example values + * Id must be 0 if object instance is a specimen + * + * @return void + */ + public function initAsSpecimen() + { + // Set here init that are not commonf fields + // $this->property1 = ... + // $this->property2 = ... + + $this->initAsSpecimenCommon(); + } +} From 3b7c385c6c5ee621586a78e775ccf943c0699b50 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 13:53:30 +0100 Subject: [PATCH 055/178] Fix syntax error --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 3ba436cf28c..1b051a6081f 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -979,7 +979,7 @@ function pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_ $outputlangs->load("dict"); $line = ''; - $reg = aray(); + $reg = array(); $dims = $pdf->getPageDimensions(); From 98ba48c0e76f7585701e1d5bf9017d7cc797e87e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 15:58:46 +0100 Subject: [PATCH 056/178] Look and feel v15 --- htdocs/modulebuilder/index.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 9239413d951..ef777569ee5 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1724,8 +1724,8 @@ print load_fiche_titre($text, '', 'title_setup'); print ''.$langs->trans("ModuleBuilderDesc", 'https://wiki.dolibarr.org/index.php/Module_development#Create_your_module').'
    '; -print $textforlistofdirs; -print '
    '; +//print $textforlistofdirs; +//print '
    '; //var_dump($listofmodules); @@ -1750,7 +1750,7 @@ if ($message) { } //print $langs->trans("ModuleBuilderDesc3", count($listofmodules), $FILEFLAG).'
    '; -$infomodulesfound = '
    '.$form->textwithpicto(''.$langs->trans("ModuleBuilderDesc3", count($listofmodules)).'', $langs->trans("ModuleBuilderDesc4", $FILEFLAG)).'
    '; +$infomodulesfound = '
    '.$form->textwithpicto(''.$langs->trans("ModuleBuilderDesc3", count($listofmodules)).'', $langs->trans("ModuleBuilderDesc4", $FILEFLAG).'
    '.$textforlistofdirs).'
    '; // Load module descriptor From 6d10facf5bda1e5d0a04893a334625134e865153 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 16:04:37 +0100 Subject: [PATCH 057/178] Debug v15 --- htdocs/modulebuilder/index.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index ef777569ee5..1ab03743747 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -3355,7 +3355,8 @@ if ($module == 'initmodule') { } } else { print ''; - print ' '.$langs->trans("NoTrigger"); + print ' '.$langs->trans("TriggersFile"); + print ' : '.$langs->trans("FileNotYetGenerated").''; print ''.img_picto('Generate', 'generate', 'class="paddingleft"').''; print ''; print ''; From ed9806576aa61063fe6ea9bf7da9ddb146137dd9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 16:07:16 +0100 Subject: [PATCH 058/178] Trans --- htdocs/langs/en_US/modulebuilder.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 5d6b51d5fe4..e479438769d 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -98,7 +98,7 @@ MenusDefDescTooltip=The menus provided by your module/application are defined in DictionariesDefDescTooltip=The dictionaries provided by your module/application are defined into the array $this->dictionaries into the module descriptor file. You can edit manually this file or use the embedded editor.

    Note: Once defined (and module re-activated), dictionaries are also visible into the setup area to administrator users on %s. PermissionsDefDescTooltip=The permissions provided by your module/application are defined into the array $this->rights into the module descriptor file. You can edit manually this file or use the embedded editor.

    Note: Once defined (and module re-activated), permissions are visible into the default permissions setup %s. HooksDefDesc=Define in the module_parts['hooks'] property, in the module descriptor, the context of hooks you want to manage (list of contexts can be found by a search on 'initHooks(' in core code).
    Edit the hook file to add code of your hooked functions (hookable functions can be found by a search on 'executeHooks' in core code). -TriggerDefDesc=Define in the trigger file the code you want to execute for each business event executed. +TriggerDefDesc=Define in the trigger file the code that you want to execute when a business event external to your module is executed (events recorded by other modules). SeeIDsInUse=See IDs in use in your installation SeeReservedIDsRangeHere=See range of reserved IDs ToolkitForDevelopers=Toolkit for Dolibarr developers From 969fe16442a098490142eb0d2622377622933e3e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 16:51:18 +0100 Subject: [PATCH 059/178] Debug mass actions of partnership module --- htdocs/core/actions_massactions.inc.php | 1 + htdocs/langs/en_US/partnership.lang | 1 + .../partnership/class/partnership.class.php | 22 ++++---- .../class/partnershiputils.class.php | 4 +- htdocs/partnership/partnership_card.php | 8 +-- htdocs/partnership/partnership_list.php | 56 +++++++++++++++++-- 6 files changed, 69 insertions(+), 23 deletions(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 00bfe865aaa..8ccff0eb017 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1556,6 +1556,7 @@ if (!$error && ($massaction == 'disable' || ($action == 'disable' && $confirm == } } +// Approve for leave only if (!$error && ($massaction == 'approveleave' || ($action == 'approveleave' && $confirm == 'yes')) && $permissiontoapprove) { $db->begin(); diff --git a/htdocs/langs/en_US/partnership.lang b/htdocs/langs/en_US/partnership.lang index f5b9ebcde24..0eb73c17920 100644 --- a/htdocs/langs/en_US/partnership.lang +++ b/htdocs/langs/en_US/partnership.lang @@ -58,6 +58,7 @@ ManagePartnership=Manage partnership BacklinkNotFoundOnPartnerWebsite=Backlink not found on partner website ConfirmClosePartnershipAsk=Are you sure you want to cancel this partnership? PartnershipType=Partnership type +PartnershipRefApproved=Partnership %s approved # # Template Mail diff --git a/htdocs/partnership/class/partnership.class.php b/htdocs/partnership/class/partnership.class.php index b378435e546..4981dde2b45 100644 --- a/htdocs/partnership/class/partnership.class.php +++ b/htdocs/partnership/class/partnership.class.php @@ -67,7 +67,7 @@ class Partnership extends CommonObject const STATUS_DRAFT = 0; const STATUS_VALIDATED = 1; // Validate (no more draft) - const STATUS_ACCEPTED = 2; // Approved + const STATUS_APPROVED = 2; // Approved const STATUS_REFUSED = 3; // Refused const STATUS_CANCELED = 9; @@ -707,13 +707,13 @@ class Partnership extends CommonObject } /** - * Accept object + * Approve object * * @param User $user User making status change * @param int $notrigger 1=Does not execute triggers, 0= execute triggers * @return int <=0 if OK, 0=Nothing done, >0 if KO */ - public function accept($user, $notrigger = 0) + public function approve($user, $notrigger = 0) { global $conf, $langs; @@ -722,7 +722,7 @@ class Partnership extends CommonObject $error = 0; // Protection - if ($this->status == self::STATUS_ACCEPTED) { + if ($this->status == self::STATUS_APPROVED) { dol_syslog(get_class($this)."::accept action abandonned: already acceptd", LOG_WARNING); return 0; } @@ -751,7 +751,7 @@ class Partnership extends CommonObject // Accept $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql .= " SET ref = '".$this->db->escape($num)."',"; - $sql .= " status = ".self::STATUS_ACCEPTED; + $sql .= " status = ".self::STATUS_APPROVED; // if (!empty($this->fields['date_validation'])) { // $sql .= ", date_validation = '".$this->db->idate($now)."'"; // } @@ -818,7 +818,7 @@ class Partnership extends CommonObject // Set new ref and current status if (!$error) { $this->ref = $num; - $this->status = self::STATUS_ACCEPTED; + $this->status = self::STATUS_APPROVED; } if (!$error) { @@ -893,7 +893,7 @@ class Partnership extends CommonObject public function cancel($user, $notrigger = 0) { // Protection - if ($this->status != self::STATUS_ACCEPTED) { + if ($this->status != self::STATUS_APPROVED) { return 0; } @@ -928,7 +928,7 @@ class Partnership extends CommonObject return -1; }*/ - return $this->setStatusCommon($user, self::STATUS_ACCEPTED, $notrigger, 'PARTNERSHIP_REOPEN'); + return $this->setStatusCommon($user, self::STATUS_APPROVED, $notrigger, 'PARTNERSHIP_REOPEN'); } /** @@ -1073,18 +1073,18 @@ class Partnership extends CommonObject //$langs->load("partnership"); $this->labelStatus[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); $this->labelStatus[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); - $this->labelStatus[self::STATUS_ACCEPTED] = $langs->transnoentitiesnoconv('Accepted'); + $this->labelStatus[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved'); $this->labelStatus[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused'); $this->labelStatus[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled'); $this->labelStatusShort[self::STATUS_DRAFT] = $langs->transnoentitiesnoconv('Draft'); $this->labelStatusShort[self::STATUS_VALIDATED] = $langs->transnoentitiesnoconv('Validated'); - $this->labelStatusShort[self::STATUS_ACCEPTED] = $langs->transnoentitiesnoconv('Accepted'); + $this->labelStatusShort[self::STATUS_APPROVED] = $langs->transnoentitiesnoconv('Approved'); $this->labelStatusShort[self::STATUS_REFUSED] = $langs->transnoentitiesnoconv('Refused'); $this->labelStatusShort[self::STATUS_CANCELED] = $langs->transnoentitiesnoconv('Canceled'); } $statusType = 'status'.$status; - if ($status == self::STATUS_ACCEPTED) { + if ($status == self::STATUS_APPROVED) { $statusType = 'status4'; } if ($status == self::STATUS_REFUSED) { diff --git a/htdocs/partnership/class/partnershiputils.class.php b/htdocs/partnership/class/partnershiputils.class.php index 0588b9e5df2..35b8a3b01e5 100644 --- a/htdocs/partnership/class/partnershiputils.class.php +++ b/htdocs/partnership/class/partnershiputils.class.php @@ -101,7 +101,7 @@ class PartnershipUtils $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."adherent_type as dty on (dty.rowid = d.fk_adherent_type)"; $sql .= " WHERE fk_member > 0"; $sql .= " AND (d.datefin < '".$this->db->idate($datetotest)."' AND dty.subscription = 1)"; - $sql .= " AND p.status = ".((int) $partnership::STATUS_ACCEPTED); // Only accepted not yet canceled + $sql .= " AND p.status = ".((int) $partnership::STATUS_APPROVED); // Only accepted not yet canceled $sql .= $this->db->order('d.rowid', 'ASC'); // Limit is managed into loop later @@ -262,7 +262,7 @@ class PartnershipUtils $sql .= " WHERE 1 = 1"; $sql .= " AND p.".$fk_partner." > 0"; - $sql .= " AND p.status = ".((int) $partnership::STATUS_ACCEPTED); // Only accepted not yet canceled + $sql .= " AND p.status = ".((int) $partnership::STATUS_APPROVED); // Only accepted not yet canceled $sql .= " AND (p.last_check_backlink IS NULL OR p.last_check_backlink <= '".$this->db->idate($now - 7 * 24 * 3600)."')"; // Every week, check that website contains a link to dolibarr. $sql .= $this->db->order('p.rowid', 'ASC'); // Limit is managed into loop later diff --git a/htdocs/partnership/partnership_card.php b/htdocs/partnership/partnership_card.php index 72787042e0e..0f32eb94580 100644 --- a/htdocs/partnership/partnership_card.php +++ b/htdocs/partnership/partnership_card.php @@ -153,7 +153,7 @@ if (empty($reshook)) { setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action == 'confirm_accept' && $confirm == 'yes' && $permissiontoadd) { - $result = $object->accept($user); + $result = $object->approve($user); if ($result >= 0) { // Define output language if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { @@ -590,9 +590,9 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Cancel if ($permissiontoadd) { - if ($object->status == $object::STATUS_ACCEPTED) { + if ($object->status == $object::STATUS_APPROVED) { print dolGetButtonAction($langs->trans('Cancel'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=close&token='.newToken(), '', $permissiontoadd); - } elseif ($object->status > $object::STATUS_ACCEPTED) { + } elseif ($object->status > $object::STATUS_APPROVED) { // print ''.$langs->trans("Re-Open").''."\n"; print dolGetButtonAction($langs->trans('Re-Open'), '', 'default', $_SERVER["PHP_SELF"].'?id='.$object->id.'&action=confirm_reopen&confirm=yes&token='.newToken(), '', $permissiontoadd); } @@ -600,7 +600,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea // Refuse if ($permissiontoadd) { - if ($object->status != $object::STATUS_DRAFT && $object->status != $object::STATUS_ACCEPTED && $object->status != $object::STATUS_CANCELED && $object->status != $object::STATUS_REFUSED) { + if ($object->status != $object::STATUS_DRAFT && $object->status != $object::STATUS_APPROVED && $object->status != $object::STATUS_CANCELED && $object->status != $object::STATUS_REFUSED) { print dolGetButtonAction($langs->trans('Refuse'), '', 'default', $_SERVER['PHP_SELF'].'?id='.$object->id.'&action=refuse&token='.newToken(), '', $permissiontoadd); } } diff --git a/htdocs/partnership/partnership_list.php b/htdocs/partnership/partnership_list.php index ef3b55ae44b..2703d431e1a 100644 --- a/htdocs/partnership/partnership_list.php +++ b/htdocs/partnership/partnership_list.php @@ -29,8 +29,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; - -// load partnership libraries require_once DOL_DOCUMENT_ROOT.'/partnership/class/partnership.class.php'; // for other modules @@ -158,6 +156,8 @@ if ($user->socid > 0) { // Protection if external user * Actions */ +$error = 0; + if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; @@ -200,6 +200,43 @@ if (empty($reshook)) { $uploaddir = $conf->partnership->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + // Validate and approve + if (!$error && $massaction == 'approve' && $permissiontoadd) { + $objecttmp = new Partnership($db); + + $db->begin(); + $error = 0; + $result = 0; + + foreach ($toselect as $checked) { + if ($objecttmp->fetch($checked)) { + if ($objecttmp->status == $objecttmp::STATUS_DRAFT) { + //$objecttmp->date = dol_now(); + $result = $objecttmp->validate($user); + } + + if ($result >= 0 && $objecttmp->status == $objecttmp::STATUS_VALIDATED) { + $result = $objecttmp->approve($user); + if ($result > 0) { + setEventMessages($langs->trans("PartnershipRefApproved", $objecttmp->ref), null); + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + } + } else { + setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); + $error++; + } + } + } + + if (!$error) { + $db->commit(); + } else { + $db->rollback(); + } + } + // Cancel partnership if ($massaction == 'cancel' && $permissiontoadd) { $db->begin(); @@ -208,9 +245,14 @@ if (empty($reshook)) { $nbok = 0; foreach ($toselect as $toselectid) { $result = $objecttmp->fetch($toselectid); + var_dump($objecttmp->status); if ($result > 0) { - $result = $objecttmp->cancel($user, 3); - if ($result <= 0) { + $result = $objecttmp->cancel($user, 0); + var_dump($result); + if ($result == 0) { + setEventMessages($langs->trans('StatusOfRefMustBe', $objecttmp->ref, $objecttmp->LibStatut($objecttmp::STATUS_APPROVED)), null, 'warnings'); + $error++; + } elseif ($result <= 0) { setEventMessages($objecttmp->error, $objecttmp->errors, 'errors'); $error++; break; @@ -432,7 +474,9 @@ $param .= $hookmanager->resPrint; // List of mass actions available $arrayofmassactions = array( -'cancel'=>img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Cancel"), + //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"), + 'approve'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ValidateAndApprove"), + 'cancel'=>img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Cancel"), //'generate_doc'=>img_picto('', 'pdf').$langs->trans("ReGeneratePDF"), //'builddoc'=>img_picto('', 'pdf').$langs->trans("PDFMerge"), 'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendMail"), @@ -440,7 +484,7 @@ $arrayofmassactions = array( if ($permissiontodelete) { $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); } -if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) { +if (GETPOST('nomassaction', 'int') || in_array($massaction, array('prevalidate', 'presend', 'predelete'))) { $arrayofmassactions = array(); } $massactionbutton = $form->selectMassAction('', $arrayofmassactions); From 424727546550d4f653e58176d9e03f74b61cf0a5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 17:27:37 +0100 Subject: [PATCH 060/178] css --- htdocs/index.php | 8 ++++---- htdocs/theme/eldy/global.inc.php | 2 +- htdocs/theme/md/style.css.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/index.php b/htdocs/index.php index 1884d9a823a..b9ac604ca95 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -539,9 +539,9 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $openedDashBoard .= '
    '; if (!empty($board->labelShort)) { - $infoName = ''.$board->labelShort.''; + $infoName = ''.$board->labelShort.''; } else { - $infoName = $board->label; + $infoName = ''.$board->label.''; } $textLateTitle = $langs->trans("NActionsLate", $board->nbtodolate); @@ -563,7 +563,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $nbtodClass = 'badge badge-info'; } - $openedDashBoard .= ' '.$infoName.' : '.$board->nbtodo.''; + $openedDashBoard .= ' '.$infoName.''.$board->nbtodo.''; if ($textLate) { if ($board->url_late) { $openedDashBoard .= ''; @@ -576,7 +576,7 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $openedDashBoard .= ''."\n"; if ($board->total > 0 && !empty($conf->global->MAIN_WORKBOARD_SHOW_TOTAL_WO_TAX)) { - $openedDashBoard .= ''.$langs->trans('Total').' : '.price($board->total).''; + $openedDashBoard .= ''.$langs->trans('Total').' '.price($board->total).''; } $openedDashBoard .= '
    '."\n"; } diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index d2e3c43a3aa..31bc0e036b6 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1086,7 +1086,7 @@ select.flat.selectlimit { max-width: 62px; } .selectlimit, .marginrightonly { - margin-right: 10px !important; + margin-: 10px !important; } .marginleftonly { margin-: 10px !important; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 4acf119eff7..06598624da2 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1170,7 +1170,7 @@ select.flat.selectlimit { max-width: 62px; } .selectlimit, .marginrightonly { - margin-right: 10px !important; + margin-: 10px !important; } .marginleftonly { margin-: 10px !important; From 1934a3767651f836b3eabe3b228f7d8cf1f732dc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 17:35:43 +0100 Subject: [PATCH 061/178] Escape to avoid false positive, even if it should be useless. --- htdocs/core/class/commonobject.class.php | 7 +------ htdocs/core/class/fileupload.class.php | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 91446f38070..812353591ed 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -7874,11 +7874,6 @@ abstract class CommonObject $out .= ($display_type=='card' ? '' : '
    '); - /*for($ii = 0; $ii < ($colspan - 1); $ii++) - { - $out .=''; - }*/ - if (!empty($conf->global->MAIN_EXTRAFIELDS_USE_TWO_COLUMS) && (($e % 2) == 1)) { $out .= ($display_type=='card' ? '' : '
    '); } else { @@ -8887,7 +8882,7 @@ abstract class CommonObject $sql = "SELECT ".$objectline->getFieldList('l'); $sql .= " FROM ".MAIN_DB_PREFIX.$objectline->table_element." as l"; - $sql .= " WHERE l.fk_".$this->element." = ".((int) $this->id); + $sql .= " WHERE l.fk_".$this->db->escape($this->element)." = ".((int) $this->id); if ($morewhere) { $sql .= $morewhere; } diff --git a/htdocs/core/class/fileupload.class.php b/htdocs/core/class/fileupload.class.php index 45bc622b9db..ea8618c8b92 100644 --- a/htdocs/core/class/fileupload.class.php +++ b/htdocs/core/class/fileupload.class.php @@ -222,7 +222,7 @@ class FileUpload protected function setFileDeleteUrl($file) { $file->delete_url = $this->options['script_url'] - .'?file='.rawurlencode($file->name).'&fk_element='.$this->fk_element.'&element='.$this->element; + .'?file='.urlencode($file->name).'&fk_element='.urlencode($this->fk_element).'&element='.urlencode($this->element); $file->delete_type = $this->options['delete_type']; if ($file->delete_type !== 'DELETE') { $file->delete_url .= '&_method=DELETE'; From 66f85d674db5967808806cacea45cc5945d27df7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 17:43:17 +0100 Subject: [PATCH 062/178] Fix warning scrutinizer --- htdocs/core/class/ldap.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 1d31c0cfc86..4af22683b2c 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -181,6 +181,8 @@ class Ldap $connected = 0; $this->bind = 0; + $this->error = 0; + $this->connectedServer = ''; // Check parameters if (count($this->server) == 0 || empty($this->server[0])) { @@ -229,7 +231,7 @@ class Ldap dol_syslog(get_class($this)."::connect_bind failed to start tls", LOG_WARNING); $this->error = 'ldap_start_tls Failed to start TLS '.ldap_errno($this->connection).' '.ldap_error($this->connection); $connected = 0; - $this->close(); + $this->unbind(); } } @@ -278,7 +280,9 @@ class Ldap } if (!$connected) { - $this->close(); + $this->unbind(); + } else { + $this->connectedServer = $host; } } } @@ -291,7 +295,7 @@ class Ldap $return = -1; dol_syslog(get_class($this)."::connect_bind return=".$return.' - '.$this->error, LOG_WARNING); } - $this->connectedServer = $host; + return $return; } From 68295073720d52307b3c8040269dfbf6bab28be8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 17:44:34 +0100 Subject: [PATCH 063/178] Fix missing $db --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 25dec3e47bb..602460e0e6d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -106,7 +106,7 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port) */ function getEntity($element, $shared = 1, $currentobject = null) { - global $conf, $mc, $hookmanager, $object, $action; + global $conf, $mc, $hookmanager, $object, $action, $db; if (! is_object($hookmanager)) { $hookmanager = new HookManager($db); From 2e499c2d17326353b6a4417c70175f199e995739 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 17:46:08 +0100 Subject: [PATCH 064/178] Fix unknown property --- htdocs/core/lib/functions.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 602460e0e6d..0ad85cc6c49 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -144,10 +144,10 @@ function getEntity($element, $shared = 1, $currentobject = null) $reshook = $hookmanager->executeHooks('hookGetEntity', $parameters, $currentobject, $action); // Note that $action and $object may have been modified by some hooks if (is_numeric($reshook)) { - if ($reshook == 0 && !empty($hookmanager->resprints)) { - $out .= ','.$hookmanager->resprints; // add + if ($reshook == 0 && !empty($hookmanager->resPrint)) { + $out .= ','.$hookmanager->resPrint; // add } elseif ($reshook == 1) { - $out = $hookmanager->resprints; // replace + $out = $hookmanager->resPrint; // replace } } From 5613ec71d60b2c64f4444609c69bbd8aa2f85738 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 17:48:01 +0100 Subject: [PATCH 065/178] Fix syntax --- htdocs/fourn/facture/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index a6cf0cb232d..7ad7d434f46 100755 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -1,4 +1,4 @@ - * Copyright (C) 2004-2020 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles From eaf2c6e89cf762cc31c7efab842607ab07ee2023 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 17:49:31 +0100 Subject: [PATCH 066/178] Fix $action not defined --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 0ad85cc6c49..53ec09f943b 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1845,7 +1845,7 @@ function dol_get_fiche_end($notab = 0) */ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldid = 'rowid', $fieldref = 'ref', $morehtmlref = '', $moreparam = '', $nodbprefix = 0, $morehtmlleft = '', $morehtmlstatus = '', $onlybanner = 0, $morehtmlright = '') { - global $conf, $form, $user, $langs, $hookmanager; + global $conf, $form, $user, $langs, $hookmanager, $action; $error = 0; From 5d4cf586d60a8ebdae04b03a7d6ddf1e0f696c1a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 17:51:30 +0100 Subject: [PATCH 067/178] Fix duplicate call --- scripts/company/sync_contacts_dolibarr2ldap.php | 1 - scripts/members/sync_members_dolibarr2ldap.php | 1 - scripts/members/sync_members_types_dolibarr2ldap.php | 1 - scripts/user/sync_groups_dolibarr2ldap.php | 1 - scripts/user/sync_users_dolibarr2ldap.php | 1 - 5 files changed, 5 deletions(-) diff --git a/scripts/company/sync_contacts_dolibarr2ldap.php b/scripts/company/sync_contacts_dolibarr2ldap.php index e161a813ec7..ccaabb1afda 100755 --- a/scripts/company/sync_contacts_dolibarr2ldap.php +++ b/scripts/company/sync_contacts_dolibarr2ldap.php @@ -154,7 +154,6 @@ if ($resql) { } $ldap->unbind(); - $ldap->close(); } else { dol_print_error($db); } diff --git a/scripts/members/sync_members_dolibarr2ldap.php b/scripts/members/sync_members_dolibarr2ldap.php index 66c245cf3eb..74a5c4db210 100755 --- a/scripts/members/sync_members_dolibarr2ldap.php +++ b/scripts/members/sync_members_dolibarr2ldap.php @@ -163,7 +163,6 @@ if ($resql) { } $ldap->unbind(); - $ldap->close(); } else { dol_print_error($db); } diff --git a/scripts/members/sync_members_types_dolibarr2ldap.php b/scripts/members/sync_members_types_dolibarr2ldap.php index 3d592673296..3ec2c9d0d90 100755 --- a/scripts/members/sync_members_types_dolibarr2ldap.php +++ b/scripts/members/sync_members_types_dolibarr2ldap.php @@ -121,7 +121,6 @@ if ($resql) { } $ldap->unbind(); - $ldap->close(); } else { print $ldap->error; } diff --git a/scripts/user/sync_groups_dolibarr2ldap.php b/scripts/user/sync_groups_dolibarr2ldap.php index dd0476bbfca..7d9ed2f307e 100755 --- a/scripts/user/sync_groups_dolibarr2ldap.php +++ b/scripts/user/sync_groups_dolibarr2ldap.php @@ -112,7 +112,6 @@ if ($resql) { } $ldap->unbind(); - $ldap->close(); } else { dol_print_error($db); } diff --git a/scripts/user/sync_users_dolibarr2ldap.php b/scripts/user/sync_users_dolibarr2ldap.php index 26b1363d5a1..abe0b9fbcf4 100755 --- a/scripts/user/sync_users_dolibarr2ldap.php +++ b/scripts/user/sync_users_dolibarr2ldap.php @@ -111,7 +111,6 @@ if ($resql) { } $ldap->unbind(); - $ldap->close(); } else { dol_print_error($db); } From f5edd25f6dfefcc6e090c603bb69af074c190cad Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 18:14:49 +0100 Subject: [PATCH 068/178] Clean code --- .../class/ProductCombination.class.php | 28 ++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 5e396fba8db..bb6372fd5eb 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -1061,37 +1061,33 @@ class ProductCombinationLevel */ public function fetchAll($fk_product_attribute_combination, $fk_price_level = 0) { + $result = array(); $sql = "SELECT rowid, fk_product_attribute_combination, fk_price_level, variation_price, variation_price_percentage"; $sql .= " FROM ".MAIN_DB_PREFIX.$this->table_element; $sql .= " WHERE fk_product_attribute_combination = ".intval($fk_product_attribute_combination); - if (!empty($fk_price_level)) { $sql .= ' AND fk_price_level = '.intval($fk_price_level); } - $combination_price_levels = $this->db->getRows($sql); - - if (!is_array($combination_price_levels)) { - return -1; - } - - $result = array(); - - if (!empty($combination_price_levels)) { - // For more simple usage set level as array key - foreach ($combination_price_levels as $k => $row) { - $productCombinationLevel = new ProductCombinationLevel($this->db); - $productCombinationLevel->fetchFormObj($row); - $result[$row->fk_price_level] = $productCombinationLevel; + $res = $this->db->query($sql); + if ($res) { + if ($this->db->num_rows($res) > 0) { + while ($obj = $this->db->fetch_object($res)) { + $productCombinationLevel = new ProductCombinationLevel($this->db); + $productCombinationLevel->fetchFormObj($obj); + $result[$obj->fk_price_level] = $productCombinationLevel; + } } + } else { + return -1; } return $result; } /** - * assign vars form an stdclass like sql obj + * Assign vars form an stdclass like sql obj * * @param int $obj Object resultset * @return int <0 KO, >0 OK From 142e9473c5af94978048f70149e097a72b27d307 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 18:28:59 +0100 Subject: [PATCH 069/178] Responsive --- htdocs/admin/barcode.php | 152 +++++++++++++++++-------------- htdocs/variants/combinations.php | 40 +++++--- 2 files changed, 109 insertions(+), 83 deletions(-) diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php index c370c07b73b..2fbfed35536 100644 --- a/htdocs/admin/barcode.php +++ b/htdocs/admin/barcode.php @@ -176,6 +176,71 @@ foreach ($dirbarcode as $reldir) { } } + + +// Select barcode numbering module +if ($conf->product->enabled) { + print load_fiche_titre($langs->trans("BarCodeNumberManager")." (".$langs->trans("Product").")", '', ''); + + print '
    '; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); + + foreach ($dirbarcodenum as $dirroot) { + $dir = dol_buildpath($dirroot, 0); + + $handle = @opendir($dir); + if (is_resource($handle)) { + while (($file = readdir($handle)) !== false) { + if (preg_match('/^mod_barcode_product_.*php$/', $file)) { + $file = substr($file, 0, dol_strlen($file) - 4); + + try { + dol_include_once($dirroot.$file.'.php'); + } catch (Exception $e) { + dol_syslog($e->getMessage(), LOG_ERR); + } + + $modBarCode = new $file(); + + print ''; + print ''; + print '\n"; + + if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM) && $conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file") { + print ''; + } else { + print ''; + } + print ''; + print "\n"; + } + } + closedir($handle); + } + } + print "
    '.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
    '.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)."\n"; + print $modBarCode->info($langs); + print ''.$modBarCode->getExample($langs)."'; + print img_picto($langs->trans("Activated"), 'switch_on'); + print ''; + print img_picto($langs->trans("Disabled"), 'switch_off'); + print ''; + $s = $modBarCode->getToolTip($langs, null, -1); + print $form->textwithpicto('', $s, 1); + print '
    \n"; + print '
    '; +} + + /* * CHOIX ENCODAGE */ @@ -189,6 +254,7 @@ if (empty($conf->use_javascript_ajax)) { print ''; } +print '
    '; print ''; print ''; print ''; @@ -211,8 +277,9 @@ if ($resql) { while ($i < $num) { $obj = $db->fetch_object($resql); - print ''; + print '
    '.$langs->trans("Name").'
    '; - print $obj->label; + print '
    '; + print dol_escape_htmltag($obj->label); print "\n"; print $langs->trans('BarcodeDesc'.$obj->encoding); //print "L'EAN se compose de 8 caracteres, 7 chiffres plus une cle de controle.
    "; @@ -270,6 +337,7 @@ if ($resql) { } } print "
    \n"; +print '
    '; if (empty($conf->use_javascript_ajax)) { print $form->buttonsSaveCancel("Save", ''); @@ -287,6 +355,7 @@ print "
    "; print ''; print ""; +print '
    '; print ''; print ''; print ''; @@ -304,7 +373,9 @@ if (!isset($_SERVER['WINDIR'])) { $langs->load("errors"); print '
    '.$langs->trans("ErrorFileNotFound", $conf->global->GENBARCODE_LOCATION).''; } - print ''; + print ''; + print ''; + print ''; } // Module products @@ -313,7 +384,9 @@ if (!empty($conf->product->enabled)) { print ''; print ''; + print ''; + print ''; + print ''; } // Module thirdparty @@ -322,10 +395,14 @@ if (!empty($conf->societe->enabled)) { print ''; print ''; + print ''; + print ''; + print ''; } print "
    '.$langs->trans("Parameter").'
     
    '.$langs->trans("SetDefaultBarcodeTypeProducts").''; print $formbarcode->selectBarcodeType($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE, "PRODUIT_DEFAULT_BARCODE_TYPE", 1); - print '
     
    '.$langs->trans("SetDefaultBarcodeTypeThirdParties").''; print $formbarcode->selectBarcodeType($conf->global->GENBARCODE_BARCODETYPE_THIRDPARTY, "GENBARCODE_BARCODETYPE_THIRDPARTY", 1); - print '
     
    \n"; +print '
    '; + print '
    '; print ''; print "
    "; @@ -334,71 +411,6 @@ print '
    '; print '
    '; - -// Select barcode numbering module -if ($conf->product->enabled) { - print load_fiche_titre($langs->trans("BarCodeNumberManager")." (".$langs->trans("Product").")", '', ''); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - - $dirbarcodenum = array_merge(array('/core/modules/barcode/'), $conf->modules_parts['barcode']); - - foreach ($dirbarcodenum as $dirroot) { - $dir = dol_buildpath($dirroot, 0); - - $handle = @opendir($dir); - if (is_resource($handle)) { - while (($file = readdir($handle)) !== false) { - if (preg_match('/^mod_barcode_product_.*php$/', $file)) { - $file = substr($file, 0, dol_strlen($file) - 4); - - try { - dol_include_once($dirroot.$file.'.php'); - } catch (Exception $e) { - dol_syslog($e->getMessage(), LOG_ERR); - } - - $modBarCode = new $file(); - - print ''; - print ''; - print '\n"; - - if (!empty($conf->global->BARCODE_PRODUCT_ADDON_NUM) && $conf->global->BARCODE_PRODUCT_ADDON_NUM == "$file") { - print ''; - } else { - print ''; - } - print ''; - print "\n"; - } - } - closedir($handle); - } - } - print "
    '.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
    '.(isset($modBarCode->name) ? $modBarCode->name : $modBarCode->nom)."\n"; - print $modBarCode->info($langs); - print ''.$modBarCode->getExample($langs)."'; - print img_picto($langs->trans("Activated"), 'switch_on'); - print ''; - print img_picto($langs->trans("Disabled"), 'switch_off'); - print ''; - $s = $modBarCode->getToolTip($langs, null, -1); - print $form->textwithpicto('', $s, 1); - print '
    \n"; -} - -//print ''; - -print "
    "; - // End of page llxFooter(); $db->close(); diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index d70419060f5..1569fcabb39 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -194,14 +194,11 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST( $bulkaction = $massaction; $error = 0; - - $db->begin(); foreach ($toselect as $prodid) { // need create new of Product to prevent rename dir behavior $prodstatic = new Product($db); - if ($prodstatic->fetch($prodid) < 0) { continue; } @@ -209,33 +206,50 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST( if ($bulkaction == 'on_sell') { $prodstatic->status = 1; $res = $prodstatic->update($prodstatic->id, $user); + if ($res <= 0) { + setEventMessages($prodstatic->error, $prodstatic->errors, 'errors'); + $error++; + break; + } } elseif ($bulkaction == 'on_buy') { $prodstatic->status_buy = 1; $res = $prodstatic->update($prodstatic->id, $user); + if ($res <= 0) { + setEventMessages($prodstatic->error, $prodstatic->errors, 'errors'); + $error++; + break; + } } elseif ($bulkaction == 'not_sell') { $prodstatic->status = 0; $res = $prodstatic->update($prodstatic->id, $user); + if ($res <= 0) { + setEventMessages($prodstatic->error, $prodstatic->errors, 'errors'); + $error++; + break; + } } elseif ($bulkaction == 'not_buy') { $prodstatic->status_buy = 0; $res = $prodstatic->update($prodstatic->id, $user); + if ($res <= 0) { + setEventMessages($prodstatic->error, $prodstatic->errors, 'errors'); + $error++; + break; + } } elseif ($bulkaction == 'delete') { $res = $prodstatic->delete($user, $prodstatic->id); + if ($res <= 0) { + setEventMessages($prodstatic->error, $prodstatic->errors, 'errors'); + $error++; + break; + } } else { break; } - - if ($res <= 0) { - $error++; - break; - } } if ($error) { $db->rollback(); - - if ($prodstatic->error) { - setEventMessages($prodstatic->error, $prodstatic->errors, 'errors'); - } else { + if (empty($prodstatic->error)) { setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors'); } } else { @@ -834,7 +848,7 @@ if (!empty($id) || !empty($ref)) { $aaa .= ' '; $aaa .= ' '; $aaa .= ''; - $aaa .= ''; + $aaa .= ''; } $massactionbutton = $aaa; From 9fd57279855a097354c80ea58ca73800c657e722 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 18:47:27 +0100 Subject: [PATCH 070/178] Try to fix some regressions --- htdocs/accountancy/customer/list.php | 13 ++++++++----- htdocs/accountancy/supplier/list.php | 21 +++++++++++++-------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index abf5a8d4c2e..c07f4854b84 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -413,6 +413,9 @@ if ($result) { if ($search_ref) { $param .= '&search_ref='.urlencode($search_ref); } + if ($search_label) { + $param .= '&search_label='.urlencode($search_label); + } if ($search_desc) { $param .= '&search_desc='.urlencode($search_desc); } @@ -491,7 +494,7 @@ if ($result) { $searchpicto = $form->showFilterButtons(); print $searchpicto; print ''; - print ''; + print "\n"; print ''; print_liste_field_titre("LineId", $_SERVER["PHP_SELF"], "l.rowid", "", $param, '', $sortfield, $sortorder); @@ -539,7 +542,7 @@ if ($result) { $thirdpartystatic->email = $objp->email; $thirdpartystatic->country_code = $objp->country_code; $thirdpartystatic->tva_intra = $objp->tva_intra; - $thirdpartystatic->code_compta = $objp->company_code_sell; + $thirdpartystatic->code_compta_company = $objp->company_code_sell; $product_static->ref = $objp->product_ref; $product_static->id = $objp->product_id; @@ -558,7 +561,7 @@ if ($result) { $facture_static->ref = $objp->ref; $facture_static->id = $objp->facid; $facture_static->type = $objp->ftype; - $facture_static->date = $objp->datef; + $facture_static->date = $db->jdate($objp->datef); $facture_static_det->id = $objp->rowid; $facture_static_det->total_ht = $objp->total_ht; @@ -634,7 +637,7 @@ if ($result) { // Ref Invoice print ''.$facture_static->getNomUrl(1).''; - print ''.dol_print_date($db->jdate($facture_static->date), 'day').''; + print ''.dol_print_date($facture_static->date, 'day').''; // Ref Product print ''; @@ -728,7 +731,7 @@ if ($result) { // Column with checkbox print ''; - if (!empty($suggestedid) && $suggestedaccountingaccountfor<>'') { + if (!empty($suggestedid) && $suggestedaccountingaccountfor <> '') { $ischecked=1; } elseif ($suggestedaccountingaccountfor == 'eecwithoutvatnumber') { $ischecked = 0; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 20230c7cfad..b7e914c381a 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -291,7 +291,7 @@ if (strlen(trim($search_ref))) { $sql .= natural_search("p.ref", $search_ref); } if (strlen(trim($search_label))) { - $sql .= natural_search("f.libelle", $search_label); + $sql .= natural_search(array("p.label", "f.libelle"), $search_label); } if (strlen(trim($search_desc))) { $sql .= natural_search("l.description", $search_desc); @@ -546,7 +546,7 @@ if ($result) { $thirdpartystatic->email = $objp->email; $thirdpartystatic->country_code = $objp->country_code; $thirdpartystatic->tva_intra = $objp->tva_intra; - $thirdpartystatic->code_compta_fournisseur = $objp->company_code_buy; + $thirdpartystatic->code_compta_company = $objp->company_code_buy; $product_static->ref = $objp->product_ref; $product_static->id = $objp->product_id; @@ -566,10 +566,11 @@ if ($result) { $facturefourn_static->id = $objp->facid; $facturefourn_static->type = $objp->ftype; $facturefourn_static->label = $objp->invoice_label; + $facturefourn_static->date = $db->jdate($objp->datef); $facturefourn_static_det->id = $objp->rowid; $facturefourn_static_det->total_ht = $objp->total_ht; - $facturefourn_static_det->tva_tx_line = $objp->tva_tx_line; + $facturefourn_static_det->tva_tx = $objp->tva_tx_line; $facturefourn_static_det->vat_src_code = $objp->vat_src_code; $facturefourn_static_det->product_type = $objp->type_l; $facturefourn_static_det->desc = $objp->description; @@ -608,6 +609,9 @@ if ($result) { if (empty($code_buy_l) && empty($code_buy_p)) { $code_buy_p_notset = 'color:red'; } + /*if ($suggestedaccountingaccountfor == 'eecwithoutvatnumber' && empty($code_sell_p_notset)) { + $code_sell_p_notset = 'color:orange'; + }*/ // $code_buy_l is now default code of product/service // $code_buy_p is now code of product/service @@ -626,15 +630,15 @@ if ($result) { print ''; */ - print ''.dol_print_date($db->jdate($facturefourn_static_det->datef), 'day').''; + print ''.dol_print_date($facturefourn_static->date, 'day').''; // Ref Product print ''; if ($product_static->id > 0) { print $product_static->getNomUrl(1); } - if ($product_static->product_label) { - print '
    '.$product_static->product_label.''; + if ($product_static->label) { + print '
    '.$product_static->label.''; } print ''; @@ -650,11 +654,12 @@ if ($result) { print ''; // Vat rate + $code_vat_differ=''; if ($objp->vat_tx_l != $objp->vat_tx_p && ! empty($objp->vat_tx_l)) { // Note: having a vat rate of 0 is often the normal case when sells is intra b2b or to export $code_vat_differ = 'font-weight:bold; text-decoration:blink; color:red'; } print ''; - print vatrate($facturefourn_static_det->tva_tx_line.($facturefourn_static_det->vat_src_code ? ' ('.$facturefourn_static_det->vat_src_code.')' : '')); + print vatrate($facturefourn_static_det->tva_tx.($facturefourn_static_det->vat_src_code ? ' ('.$facturefourn_static_det->vat_src_code.')' : '')); print ''; // Thirdparty @@ -671,7 +676,7 @@ if ($result) { // Found accounts print ''; - $s = '1. '.(($facturefourn_static_det->type_l == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; + $s = '1. '.(($facturefourn_static_det->product_type == 1) ? $langs->trans("DefaultForService") : $langs->trans("DefaultForProduct")).': '; $shelp = ''; if ($suggestedaccountingaccountbydefaultfor == 'eec') { $shelp .= $langs->trans("SaleEEC"); From 47451432a743abe22270c6d803f38b4673c8dfef Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 18:49:58 +0100 Subject: [PATCH 071/178] Fix warning --- htdocs/admin/defaultvalues.php | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/htdocs/admin/defaultvalues.php b/htdocs/admin/defaultvalues.php index 026a4315c83..9c80b1f7fa8 100644 --- a/htdocs/admin/defaultvalues.php +++ b/htdocs/admin/defaultvalues.php @@ -350,17 +350,15 @@ if (empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES)) { $disabled = ' disabled="disabled"'; } print ''; -print "\n"; -print ''; +print ''."\n"; +print ''."\n"; -$result=$object->fetchAll($sortorder, $sortfield, 0, 0, array('t.type'=>$mode,'t.entity'=>array($user->entity,$conf->entity))); +$result = $object->fetchAll($sortorder, $sortfield, 0, 0, array('t.type'=>$mode,'t.entity'=>array($user->entity,$conf->entity))); -if (!is_array($result) && $result<0) { +if (!is_array($result) && $result < 0) { setEventMessages($object->error, $object->errors, 'errors'); -} elseif (count($result)>0) { - foreach ($result as $key=>$defaultvalue) { - print "\n"; - +} elseif (is_array($result) && count($result) > 0) { + foreach ($result as $key => $defaultvalue) { print ''; // Page @@ -378,11 +376,6 @@ if (!is_array($result) && $result<0) { // Value if ($mode != 'focus' && $mode != 'mandatory') { print ''; - /*print ''; - print ''; - print ''; - print ''; - */ if ($action != 'edit' || GETPOST('rowid') != $defaultvalue->id) print dol_escape_htmltag($defaultvalue->value); else print ''; print ''; @@ -405,8 +398,6 @@ if (!is_array($result) && $result<0) { print ''; print "\n"; - print "\n"; - $i++; } } From 5085db36a7e6fba0d8a2f6dbce9fee0f501eb704 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 18:54:59 +0100 Subject: [PATCH 072/178] Clean code --- .../accountancy/class/accountancyexport.class.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 2c4dbfd51cd..07d28b7abdb 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -87,11 +87,11 @@ class AccountancyExport * * @param DoliDb $db Database handler */ - public function __construct(DoliDB &$db) + public function __construct(DoliDB $db) { global $conf; - $this->db = &$db; + $this->db = $db; $this->separator = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV; $this->end_line = empty($conf->global->ACCOUNTING_EXPORT_ENDLINE) ? "\n" : ($conf->global->ACCOUNTING_EXPORT_ENDLINE == 1 ? "\n" : "\r\n"); } @@ -928,17 +928,18 @@ class AccountancyExport $date_validation = dol_print_date($line->date_validation, '%Y%m%d'); $date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d'); + $refInvoice = ''; if ($line->doc_type == 'customer_invoice') { // Customer invoice require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $invoice = new Facture($db); + $invoice = new Facture($this->db); $invoice->fetch($line->fk_doc); $refInvoice = $invoice->ref; } elseif ($line->doc_type == 'supplier_invoice') { // Supplier invoice require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $invoice = new FactureFournisseur($db); + $invoice = new FactureFournisseur($this->db); $invoice->fetch($line->fk_doc); $refInvoice = $invoice->ref_supplier; @@ -1054,17 +1055,18 @@ class AccountancyExport $date_validation = dol_print_date($line->date_validation, '%Y%m%d'); $date_limit_payment = dol_print_date($line->date_lim_reglement, '%Y%m%d'); + $refInvoice = ''; if ($line->doc_type == 'customer_invoice') { // Customer invoice require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; - $invoice = new Facture($db); + $invoice = new Facture($this->db); $invoice->fetch($line->fk_doc); $refInvoice = $invoice->ref; } elseif ($line->doc_type == 'supplier_invoice') { // Supplier invoice require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; - $invoice = new FactureFournisseur($db); + $invoice = new FactureFournisseur($this->db); $invoice->fetch($line->fk_doc); $refInvoice = $invoice->ref_supplier; From 1d09ffa4c6f7cd63292ccd636e26718c268c263b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 18:59:11 +0100 Subject: [PATCH 073/178] Fix scrutinizer --- htdocs/admin/hrm.php | 10 ++++++---- htdocs/admin/mails.php | 7 +++++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/hrm.php b/htdocs/admin/hrm.php index 8eb2f93c13c..c006688fca1 100644 --- a/htdocs/admin/hrm.php +++ b/htdocs/admin/hrm.php @@ -79,10 +79,12 @@ if ($action == 'update') { if (!empty($max_rank)) { $static_skill = new Skill($db); $TAllSkills = $static_skill->fetchAll(); - foreach ($TAllSkills as &$skill) { - if (empty($skill->lines)) $skill->fetchLines(); - if (count($skill->lines) < $conf->global->HRM_MAXRANK) { - $skill->createSkills(count($skill->lines) + 1); + if (is_array($TAllSkills)) { + foreach ($TAllSkills as &$skill) { + if (empty($skill->lines)) $skill->fetchLines(); + if (count($skill->lines) < $conf->global->HRM_MAXRANK) { + $skill->createSkills(count($skill->lines) + 1); + } } } } diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 90036b752b0..d60b4e4ddc6 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -851,8 +851,11 @@ if ($action == 'edit') { $companyemail = getDolGlobalString('MAIN_INFO_SOCIETE_MAIL'); $dnsinfo = false; if (!empty($companyemail) && function_exists('dns_get_record')) { - $domain = array_pop(explode('@', $companyemail)); - $dnsinfo = dns_get_record($domain, DNS_TXT); + $arrayofemailparts = explode('@', $companyemail); + if (count($arrayofemailparts) == 2) { + $domain = $arrayofemailparts[1]; + $dnsinfo = dns_get_record($domain, DNS_TXT); + } } if (!empty($dnsinfo) && is_array($dnsinfo)) { foreach ($dnsinfo as $info) { From 29bf662cc4431c1c2503bcfcb5526fd7f7332b57 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 19:01:44 +0100 Subject: [PATCH 074/178] Fix warnings --- htdocs/adherents/class/adherent_type.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/class/adherent_type.class.php b/htdocs/adherents/class/adherent_type.class.php index 90b34e604be..cdf021cfa68 100644 --- a/htdocs/adherents/class/adherent_type.class.php +++ b/htdocs/adherents/class/adherent_type.class.php @@ -90,7 +90,7 @@ class AdherentType extends CommonObject public $subscription; /** - * @var float amount for subscription + * @var float|string Amount for subscription (null or '' means not defined) */ public $amount; From c3fb8416a58e0d0327c658541ec0b4932731029b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 20:40:02 +0100 Subject: [PATCH 075/178] reponsive --- htdocs/contrat/list.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index cee0faf95aa..ca544e94a1b 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -492,7 +492,7 @@ $massactionbutton = $form->selectMassAction('', $arrayofmassactions); $url = DOL_URL_ROOT.'/contrat/card.php?action=create'; if (!empty($socid)) { - $url .= '&socid='.$socid; + $url .= '&socid='.((int) $socid); } $newcardbutton = dolGetButtonTitle($langs->trans('NewContractSubscription'), '', 'fa fa-plus-circle', $url, '', $user->rights->contrat->creer); @@ -795,11 +795,12 @@ while ($i < min($num, $limit)) { print ''; } + // Ref thirdparty if (!empty($arrayfields['c.ref_customer']['checked'])) { - print ''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).''; + print ''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).''; } if (!empty($arrayfields['c.ref_supplier']['checked'])) { - print ''.$obj->ref_supplier.''; + print ''.dol_escape_htmltag($obj->ref_supplier).''; } if (!empty($arrayfields['s.nom']['checked'])) { print ''; @@ -810,7 +811,7 @@ while ($i < min($num, $limit)) { print ''; } if (!empty($arrayfields['s.email']['checked'])) { - print ''.$obj->email.''; + print ''.dol_print_email($obj->email).''; } // Town if (!empty($arrayfields['s.town']['checked'])) { From a386d637b3cd5c062187a9910be580abd020eb9f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 20:43:04 +0100 Subject: [PATCH 076/178] Clean code --- htdocs/contrat/list.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index ca544e94a1b..110afee0cd5 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -319,7 +319,7 @@ if ($sall) { } if ($search_user > 0) { $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='contrat' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".((int) $search_user); -} +}tdoverflowmax200 // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks @@ -600,11 +600,11 @@ if (!empty($arrayfields['s.email']['checked'])) { } // Town if (!empty($arrayfields['s.town']['checked'])) { - print ''; + print ''; } // Zip if (!empty($arrayfields['s.zip']['checked'])) { - print ''; + print ''; } // State if (!empty($arrayfields['state.nom']['checked'])) { @@ -797,7 +797,7 @@ while ($i < min($num, $limit)) { // Ref thirdparty if (!empty($arrayfields['c.ref_customer']['checked'])) { - print ''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).''; + print ''.$contracttmp->getFormatedCustomerRef($obj->ref_customer).''; } if (!empty($arrayfields['c.ref_supplier']['checked'])) { print ''.dol_escape_htmltag($obj->ref_supplier).''; From c7cb5213bd321873f9e1eb477c9e09321e6c07e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 7 Nov 2021 20:43:26 +0100 Subject: [PATCH 077/178] Clean code --- htdocs/contrat/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 110afee0cd5..0cfa0b2bf16 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -319,7 +319,7 @@ if ($sall) { } if ($search_user > 0) { $sql .= " AND ec.fk_c_type_contact = tc.rowid AND tc.element='contrat' AND tc.source='internal' AND ec.element_id = c.rowid AND ec.fk_socpeople = ".((int) $search_user); -}tdoverflowmax200 +} // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; // Add where from hooks From 2fc05a4c1cdd0541e51b90e960d7d23e5501110e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 00:37:42 +0100 Subject: [PATCH 078/178] Add test virus file --- test/phpunit/testvirus.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test/phpunit/testvirus.txt diff --git a/test/phpunit/testvirus.txt b/test/phpunit/testvirus.txt new file mode 100644 index 00000000000..a2463df6d64 --- /dev/null +++ b/test/phpunit/testvirus.txt @@ -0,0 +1 @@ +X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H* \ No newline at end of file From d591a83085c93346e969054c6967350648d68755 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 00:57:00 +0100 Subject: [PATCH 079/178] css --- htdocs/admin/tools/dolibarr_import.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/htdocs/admin/tools/dolibarr_import.php b/htdocs/admin/tools/dolibarr_import.php index 29bfe5c12a4..77dea6f23ab 100644 --- a/htdocs/admin/tools/dolibarr_import.php +++ b/htdocs/admin/tools/dolibarr_import.php @@ -207,6 +207,9 @@ if (in_array($type, array('mysql', 'mysqli'))) { //if (empty($_GET["showpass"]) && $dolibarr_main_db_pass) print '
    '.$langs->trans("UnHidePassword").''; //else print '
    '.$langs->trans("HidePassword").''; print '
    '; + + print '
    '; + print ''; } From bbd3293c3c5c13dc6b9e9f98947bce37d626439b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 01:42:38 +0100 Subject: [PATCH 080/178] Data ref --- htdocs/install/mysql/data/llx_c_availability.sql | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/install/mysql/data/llx_c_availability.sql b/htdocs/install/mysql/data/llx_c_availability.sql index 2e06d1de8b3..7291c399da0 100644 --- a/htdocs/install/mysql/data/llx_c_availability.sql +++ b/htdocs/install/mysql/data/llx_c_availability.sql @@ -27,6 +27,8 @@ delete from llx_c_availability; INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (1, 'AV_NOW', 'Immediate', 1, 10); -INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (2, 'AV_1W', '1 week', 1, 20); -INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (3, 'AV_2W', '2 weeks', 1, 30); -INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (4, 'AV_3W', '3 weeks', 1, 40); +INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (2, 'AV_1W', '1 week', 1, 20); +INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (3, 'AV_2W', '2 weeks', 1, 30); +INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (4, 'AV_3W', '3 weeks', 1, 40); +INSERT INTO llx_c_availability (rowid,code,label,active,position) VALUES (5, 'AV_4W', '4 weeks', 1, 50); + From 2ea248e705fdb8986b27e72ee46666caec7c5cc2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 02:09:20 +0100 Subject: [PATCH 081/178] Clean code --- htdocs/hrm/core/tpl/objectline_view.tpl.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/htdocs/hrm/core/tpl/objectline_view.tpl.php b/htdocs/hrm/core/tpl/objectline_view.tpl.php index 9be74a5f38f..9dd0e0099ab 100644 --- a/htdocs/hrm/core/tpl/objectline_view.tpl.php +++ b/htdocs/hrm/core/tpl/objectline_view.tpl.php @@ -57,11 +57,6 @@ $domData .= ' data-id="'.$line->id.'"'; $domData .= ' data-qty="'.$line->qty.'"'; $domData .= ' data-product_type="'.$line->product_type.'"'; -$sign = 1; -if (!empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE_SCREEN) && in_array($object->element, array('facture', 'invoice_supplier')) && $object->type == $object::TYPE_CREDIT_NOTE) { - $sign = -1; -} - $coldisplay = 0; ?> From e8b3875e2e79b4c30681e86a5ab7ab9ed988fb21 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 02:57:21 +0100 Subject: [PATCH 082/178] FIX bad sign of amount stored for multicurrency columns on credit notes --- htdocs/compta/facture/card.php | 19 ++++++++------- htdocs/compta/facture/class/facture.class.php | 23 ++++++++++--------- .../fourn/class/fournisseur.facture.class.php | 23 ++++++++++--------- .../install/mysql/migration/13.0.0-14.0.0.sql | 20 ++++++++++++++++ htdocs/langs/en_US/bills.lang | 2 ++ htdocs/theme/eldy/global.inc.php | 2 +- 6 files changed, 58 insertions(+), 31 deletions(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index ed4f3d873e9..d9be7ff3f1c 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -3845,13 +3845,14 @@ if ($action == 'create') { $totalpaye = $object->getSommePaiement(); $totalcreditnotes = $object->getSumCreditNotesUsed(); $totaldeposits = $object->getSumDepositsUsed(); - // print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits." + //print "totalpaye=".$totalpaye." totalcreditnotes=".$totalcreditnotes." totaldeposts=".$totaldeposits." // selleruserrevenuestamp=".$selleruserevenustamp; // We can also use bcadd to avoid pb with floating points // For example print 239.2 - 229.3 - 9.9; does not return 0. // $resteapayer=bcadd($object->total_ttc,$totalpaye,$conf->global->MAIN_MAX_DECIMALS_TOT); // $resteapayer=bcadd($resteapayer,$totalavoir,$conf->global->MAIN_MAX_DECIMALS_TOT); + $resteapayer = price2num($object->total_ttc - $totalpaye - $totalcreditnotes - $totaldeposits, 'MT'); // Multicurrency @@ -5089,7 +5090,7 @@ if ($action == 'create') { print ''; print $langs->trans('RemainderToPay'); if ($resteapayeraffiche < 0) { - print ' ('.$langs->trans('ExcessReceived').')'; + print ' ('.$langs->trans('NegativeIfExcessReceived').')'; } print ''; print ''; @@ -5117,23 +5118,25 @@ if ($action == 'create') { print ' :'.price($retainedWarranty).' '; } } else { // Credit note + + $resteapayeraffiche = $resteapayer; $cssforamountpaymentcomplete = 'amountpaymentneutral'; // Total already paid back print ''; - print $langs->trans('AlreadyPaidBack'); - print ' :'.price($sign * $totalpaye).' '; + print ''.$langs->trans('AlreadyPaidBack').''; + print ''.price($sign * $totalpaye).' '; // Billed - print ''.$langs->trans("Billed").' :'.price($sign * $object->total_ttc).' '; + print ''.$langs->trans("Billed").''.price($sign * $object->total_ttc).' '; // Remainder to pay back print ''; - print $langs->trans('RemainderToPayBack'); + print ''.$langs->trans('RemainderToPayBack'); if ($resteapayeraffiche > 0) { - print ' ('.$langs->trans('ExcessPaid').')'; + print ' ('.$langs->trans('NegativeIfExcessRefunded').')'; } - print ' :'; + print ''; print ''.price($sign * $resteapayeraffiche).''; print ' '; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index a28838756d9..f8f246924e3 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -3296,8 +3296,8 @@ class Facture extends CommonInvoice $this->line->desc = $desc; $this->line->ref_ext = $ref_ext; - $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ?abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative - $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ?-abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise + $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ? abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative + $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise $this->line->vat_src_code = $vat_src_code; $this->line->tva_tx = $txtva; @@ -3306,11 +3306,11 @@ class Facture extends CommonInvoice $this->line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0]; $this->line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2]; - $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative - $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ttc) : $total_ttc); // For credit note and if qty is negative, total is negative - $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_tva) : $total_tva); // For credit note and if qty is negative, total is negative - $this->line->total_localtax1 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_localtax1) : $total_localtax1); // For credit note and if qty is negative, total is negative - $this->line->total_localtax2 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_localtax2) : $total_localtax2); // For credit note and if qty is negative, total is negative + $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative + $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ttc) : $total_ttc); // For credit note and if qty is negative, total is negative + $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_tva) : $total_tva); // For credit note and if qty is negative, total is negative + $this->line->total_localtax1 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_localtax1) : $total_localtax1); // For credit note and if qty is negative, total is negative + $this->line->total_localtax2 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_localtax2) : $total_localtax2); // For credit note and if qty is negative, total is negative $this->line->fk_product = $fk_product; $this->line->product_type = $product_type; @@ -3337,10 +3337,11 @@ class Facture extends CommonInvoice // Multicurrency $this->line->fk_multicurrency = $this->fk_multicurrency; $this->line->multicurrency_code = $this->multicurrency_code; - $this->line->multicurrency_subprice = $pu_ht_devise; - $this->line->multicurrency_total_ht = $multicurrency_total_ht; - $this->line->multicurrency_total_tva = $multicurrency_total_tva; - $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + $this->line->multicurrency_subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht_devise) : $pu_ht_devise); // For credit note, unit price always negative, always positive otherwise + + $this->line->multicurrency_total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_ht) : $multicurrency_total_ht); // For credit note and if qty is negative, total is negative + $this->line->multicurrency_total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_tva) : $multicurrency_total_tva); // For credit note and if qty is negative, total is negative + $this->line->multicurrency_total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_ttc) : $multicurrency_total_ttc); // For credit note and if qty is negative, total is negative if (is_array($array_options) && count($array_options) > 0) { $this->line->array_options = $array_options; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 2601c610e15..851dcf645a5 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1957,8 +1957,8 @@ class FactureFournisseur extends CommonInvoice $this->line->desc = $desc; $this->line->ref_supplier = $ref_supplier; - $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ?abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative - $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ?-abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise + $this->line->qty = ($this->type == self::TYPE_CREDIT_NOTE ? abs($qty) : $qty); // For credit note, quantity is always positive and unit price negative + $this->line->subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht) : $pu_ht); // For credit note, unit price always negative, always positive otherwise $this->line->vat_src_code = $vat_src_code; $this->line->tva_tx = $txtva; @@ -1967,11 +1967,11 @@ class FactureFournisseur extends CommonInvoice $this->line->localtax1_type = empty($localtaxes_type[0]) ? '' : $localtaxes_type[0]; $this->line->localtax2_type = empty($localtaxes_type[2]) ? '' : $localtaxes_type[2]; - $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative - $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_tva) : $total_tva); - $this->line->total_localtax1 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_localtax1) : $total_localtax1); - $this->line->total_localtax2 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_localtax2) : $total_localtax2); - $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ?-abs($total_ttc) : $total_ttc); + $this->line->total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ht) : $total_ht); // For credit note and if qty is negative, total is negative + $this->line->total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_tva) : $total_tva); // For credit note and if qty is negative, total is negative + $this->line->total_localtax1 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_localtax1) : $total_localtax1); // For credit note and if qty is negative, total is negative + $this->line->total_localtax2 = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_localtax2) : $total_localtax2); // For credit note and if qty is negative, total is negative + $this->line->total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($total_ttc) : $total_ttc); // For credit note and if qty is negative, total is negative $this->line->fk_product = $fk_product; $this->line->product_type = $type; @@ -1992,10 +1992,11 @@ class FactureFournisseur extends CommonInvoice // Multicurrency $this->line->fk_multicurrency = $this->fk_multicurrency; $this->line->multicurrency_code = $this->multicurrency_code; - $this->line->multicurrency_subprice = $pu_ht_devise; - $this->line->multicurrency_total_ht = $multicurrency_total_ht; - $this->line->multicurrency_total_tva = $multicurrency_total_tva; - $this->line->multicurrency_total_ttc = $multicurrency_total_ttc; + $this->line->multicurrency_subprice = ($this->type == self::TYPE_CREDIT_NOTE ? -abs($pu_ht_devise) : $pu_ht_devise); // For credit note, unit price always negative, always positive otherwise + + $this->line->multicurrency_total_ht = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_ht) : $multicurrency_total_ht); // For credit note and if qty is negative, total is negative + $this->line->multicurrency_total_tva = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_tva) : $multicurrency_total_tva); // For credit note and if qty is negative, total is negative + $this->line->multicurrency_total_ttc = (($this->type == self::TYPE_CREDIT_NOTE || $qty < 0) ? -abs($multicurrency_total_ttc) : $multicurrency_total_ttc); // For credit note and if qty is negative, total is negative if (is_array($array_options) && count($array_options) > 0) { $this->line->array_options = $array_options; diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 03110b4425e..ac032d3541d 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -87,6 +87,26 @@ DELETE FROM llx_user_param where param = 'MAIN_THEME' and value in ('auguria', ' -- For v14 +--Fix bad sign on multicompany column for customer invoice lines +UPDATE llx_facturedet SET multicurrency_subprice = -multicurrency_subprice WHERE ((multicurrency_subprice < 0 and subprice > 0) OR (multicurrency_subprice > 0 and subprice < 0)); +UPDATE llx_facturedet SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0)); +UPDATE llx_facturedet SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0)); +UPDATE llx_facturedet SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0)); +--Fix bad sign on multicompany column for customer invoices +UPDATE llx_facture SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0)); +UPDATE llx_facture SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0)); +UPDATE llx_facture SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0)); +--Fix bad sign on multicurrency column for supplier invoice lines +UPDATE llx_facture_fourn_det SET multicurrency_subprice = -multicurrency_subprice WHERE ((multicurrency_subprice < 0 and pu_ht > 0) OR (multicurrency_subprice > 0 and pu_ht < 0)); +UPDATE llx_facture_fourn_det SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0)); +UPDATE llx_facture_fourn_det SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and tva > 0) OR (multicurrency_total_tva > 0 and tva < 0)); +UPDATE llx_facture_fourn_det SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0)); +--Fix bad sign on multicompany column for customer invoices +UPDATE llx_facture_fourn SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0)); +UPDATE llx_facture_fourn SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0)); +UPDATE llx_facture_fourn SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0)); + + UPDATE llx_c_ticket_type set label = 'Issue or bug' WHERE code = 'ISSUE'; INSERT INTO llx_c_ticket_type (code, pos, label, active, use_default, description) VALUES('PROBLEM', '22', 'Problem', 0, 0, NULL); diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index a835ec8475d..6078942f574 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -236,9 +236,11 @@ Abandoned=Abandoned RemainderToPay=Remaining unpaid RemainderToTake=Remaining amount to take RemainderToPayBack=Remaining amount to refund +NegativeIfExcessRefunded=negative if excess refunded Rest=Pending AmountExpected=Amount claimed ExcessReceived=Excess received +NegativeIfExcessReceived=negative if excess received ExcessPaid=Excess paid EscompteOffered=Discount offered (payment before term) EscompteOfferedShort=Discount diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php index 4da2d71dfd7..39c62b2685f 100644 --- a/htdocs/theme/eldy/global.inc.php +++ b/htdocs/theme/eldy/global.inc.php @@ -1195,7 +1195,7 @@ select.flat.selectlimit { } /* Styles for amount on card */ -table.paymenttable td.amountpaymentcomplete, table.paymenttable td.amountremaintopay { +table.paymenttable td.amountpaymentcomplete, table.paymenttable td.amountremaintopay, table.paymenttable td.amountremaintopayback { padding-top: 0px; padding-bottom: 0px; } From cd4f59bb2a5777536598ea3e45afd6f54a6f7b87 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 03:01:18 +0100 Subject: [PATCH 083/178] FIX bad sign of amount stored for multicurrency columns on credit notes --- htdocs/install/mysql/migration/repair.sql | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 59f04fdb2ca..5208a733769 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -501,6 +501,25 @@ UPDATE llx_accounting_bookkeeping set date_creation = tms where date_creation IS -- UPDATE llx_facturedet_rec set label = NULL WHERE label IS NOT NULL; +--Fix bad sign on multicompany column for customer invoice lines +UPDATE llx_facturedet SET multicurrency_subprice = -multicurrency_subprice WHERE ((multicurrency_subprice < 0 and subprice > 0) OR (multicurrency_subprice > 0 and subprice < 0)); +UPDATE llx_facturedet SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0)); +UPDATE llx_facturedet SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0)); +UPDATE llx_facturedet SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0)); +--Fix bad sign on multicompany column for customer invoices +UPDATE llx_facture SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0)); +UPDATE llx_facture SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0)); +UPDATE llx_facture SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0)); +--Fix bad sign on multicurrency column for supplier invoice lines +UPDATE llx_facture_fourn_det SET multicurrency_subprice = -multicurrency_subprice WHERE ((multicurrency_subprice < 0 and pu_ht > 0) OR (multicurrency_subprice > 0 and pu_ht < 0)); +UPDATE llx_facture_fourn_det SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0)); +UPDATE llx_facture_fourn_det SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and tva > 0) OR (multicurrency_total_tva > 0 and tva < 0)); +UPDATE llx_facture_fourn_det SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0)); +--Fix bad sign on multicompany column for customer invoices +UPDATE llx_facture_fourn SET multicurrency_total_ht = -multicurrency_total_ht WHERE ((multicurrency_total_ht < 0 and total_ht > 0) OR (multicurrency_total_ht > 0 and total_ht < 0)); +UPDATE llx_facture_fourn SET multicurrency_total_tva = -multicurrency_total_tva WHERE ((multicurrency_total_tva < 0 and total_tva > 0) OR (multicurrency_total_tva > 0 and total_tva < 0)); +UPDATE llx_facture_fourn SET multicurrency_total_ttc = -multicurrency_total_ttc WHERE ((multicurrency_total_ttc < 0 and total_ttc > 0) OR (multicurrency_total_ttc > 0 and total_ttc < 0)); + UPDATE llx_facturedet SET situation_percent = 100 WHERE situation_percent IS NULL AND fk_prev_id IS NULL; From be1ca6ebab44388d5b29ff3c27344ebaaf461458 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 03:21:15 +0100 Subject: [PATCH 084/178] Clean code --- .../core/class/commondocgenerator.class.php | 123 +++++++++--------- 1 file changed, 61 insertions(+), 62 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 7183605ae10..a92179e7b6a 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -399,7 +399,7 @@ abstract class CommonDocGenerator $sumpayed = $sumdeposit = $sumcreditnote = ''; $already_payed_all = 0; - $remain_to_pay = 0; + if ($object->element == 'facture') { $invoice_source = new Facture($this->db); if ($object->fk_facture_source > 0) { @@ -409,7 +409,6 @@ abstract class CommonDocGenerator $sumdeposit = $object->getSumDepositsUsed(); $sumcreditnote = $object->getSumCreditNotesUsed(); $already_payed_all = $sumpayed + $sumdeposit + $sumcreditnote; - $remain_to_pay = $sumpayed - $sumdeposit - $sumcreditnote; if ($object->fk_account > 0) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -421,76 +420,76 @@ abstract class CommonDocGenerator $date = ($object->element == 'contrat' ? $object->date_contrat : $object->date); $resarray = array( - $array_key.'_id'=>$object->id, - $array_key.'_ref'=>$object->ref, - $array_key.'_ref_ext'=>$object->ref_ext, - $array_key.'_ref_customer'=>(!empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ? '' : $object->ref_customer)), - $array_key.'_ref_supplier'=>(!empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), - $array_key.'_source_invoice_ref'=>$invoice_source->ref, - // Dates - $array_key.'_hour'=>dol_print_date($date, 'hour'), - $array_key.'_date'=>dol_print_date($date, 'day'), - $array_key.'_date_rfc'=>dol_print_date($date, 'dayrfc'), - $array_key.'_date_limit'=>(!empty($object->date_lim_reglement) ?dol_print_date($object->date_lim_reglement, 'day') : ''), - $array_key.'_date_end'=>(!empty($object->fin_validite) ?dol_print_date($object->fin_validite, 'day') : ''), - $array_key.'_date_creation'=>dol_print_date($object->date_creation, 'day'), - $array_key.'_date_modification'=>(!empty($object->date_modification) ?dol_print_date($object->date_modification, 'day') : ''), - $array_key.'_date_validation'=>(!empty($object->date_validation) ?dol_print_date($object->date_validation, 'dayhour') : ''), - $array_key.'_date_delivery_planed'=>(!empty($object->date_livraison) ?dol_print_date($object->date_livraison, 'day') : ''), - $array_key.'_date_close'=>(!empty($object->date_cloture) ?dol_print_date($object->date_cloture, 'dayhour') : ''), + $array_key.'_id'=>$object->id, + $array_key.'_ref'=>$object->ref, + $array_key.'_ref_ext'=>$object->ref_ext, + $array_key.'_ref_customer'=>(!empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ? '' : $object->ref_customer)), + $array_key.'_ref_supplier'=>(!empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), + $array_key.'_source_invoice_ref'=>$invoice_source->ref, + // Dates + $array_key.'_hour'=>dol_print_date($date, 'hour'), + $array_key.'_date'=>dol_print_date($date, 'day'), + $array_key.'_date_rfc'=>dol_print_date($date, 'dayrfc'), + $array_key.'_date_limit'=>(!empty($object->date_lim_reglement) ?dol_print_date($object->date_lim_reglement, 'day') : ''), + $array_key.'_date_end'=>(!empty($object->fin_validite) ?dol_print_date($object->fin_validite, 'day') : ''), + $array_key.'_date_creation'=>dol_print_date($object->date_creation, 'day'), + $array_key.'_date_modification'=>(!empty($object->date_modification) ?dol_print_date($object->date_modification, 'day') : ''), + $array_key.'_date_validation'=>(!empty($object->date_validation) ?dol_print_date($object->date_validation, 'dayhour') : ''), + $array_key.'_date_delivery_planed'=>(!empty($object->date_livraison) ?dol_print_date($object->date_livraison, 'day') : ''), + $array_key.'_date_close'=>(!empty($object->date_cloture) ?dol_print_date($object->date_cloture, 'dayhour') : ''), - $array_key.'_payment_mode_code'=>$object->mode_reglement_code, - $array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) : $object->mode_reglement), - $array_key.'_payment_term_code'=>$object->cond_reglement_code, - $array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) : ($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement)), + $array_key.'_payment_mode_code'=>$object->mode_reglement_code, + $array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) : $object->mode_reglement), + $array_key.'_payment_term_code'=>$object->cond_reglement_code, + $array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) : ($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement)), - $array_key.'_incoterms'=>(method_exists($object, 'display_incoterms') ? $object->display_incoterms() : ''), + $array_key.'_incoterms'=>(method_exists($object, 'display_incoterms') ? $object->display_incoterms() : ''), - $array_key.'_bank_iban'=>$bank_account->iban, - $array_key.'_bank_bic'=>$bank_account->bic, - $array_key.'_bank_label'=>$bank_account->label, - $array_key.'_bank_number'=>$bank_account->number, - $array_key.'_bank_proprio'=>$bank_account->proprio, + $array_key.'_bank_iban'=>$bank_account->iban, + $array_key.'_bank_bic'=>$bank_account->bic, + $array_key.'_bank_label'=>$bank_account->label, + $array_key.'_bank_number'=>$bank_account->number, + $array_key.'_bank_proprio'=>$bank_account->proprio, - $array_key.'_total_ht_locale'=>price($object->total_ht, 0, $outputlangs), - $array_key.'_total_vat_locale'=>(!empty($object->total_vat) ?price($object->total_vat, 0, $outputlangs) : price($object->total_tva, 0, $outputlangs)), - $array_key.'_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs), - $array_key.'_total_localtax2_locale'=>price($object->total_localtax2, 0, $outputlangs), - $array_key.'_total_ttc_locale'=>price($object->total_ttc, 0, $outputlangs), + $array_key.'_total_ht_locale'=>price($object->total_ht, 0, $outputlangs), + $array_key.'_total_vat_locale'=>(!empty($object->total_vat) ?price($object->total_vat, 0, $outputlangs) : price($object->total_tva, 0, $outputlangs)), + $array_key.'_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs), + $array_key.'_total_localtax2_locale'=>price($object->total_localtax2, 0, $outputlangs), + $array_key.'_total_ttc_locale'=>price($object->total_ttc, 0, $outputlangs), - $array_key.'_total_ht'=>price2num($object->total_ht), - $array_key.'_total_vat'=>(!empty($object->total_vat) ?price2num($object->total_vat) : price2num($object->total_tva)), - $array_key.'_total_localtax1'=>price2num($object->total_localtax1), - $array_key.'_total_localtax2'=>price2num($object->total_localtax2), - $array_key.'_total_ttc'=>price2num($object->total_ttc), + $array_key.'_total_ht'=>price2num($object->total_ht), + $array_key.'_total_vat'=>(!empty($object->total_vat) ?price2num($object->total_vat) : price2num($object->total_tva)), + $array_key.'_total_localtax1'=>price2num($object->total_localtax1), + $array_key.'_total_localtax2'=>price2num($object->total_localtax2), + $array_key.'_total_ttc'=>price2num($object->total_ttc), - $array_key.'_multicurrency_code' => $object->multicurrency_code, - $array_key.'_multicurrency_tx' => price2num($object->multicurrency_tx), - $array_key.'_multicurrency_total_ht' => price2num($object->multicurrency_total_ht), - $array_key.'_multicurrency_total_tva' => price2num($object->multicurrency_total_tva), - $array_key.'_multicurrency_total_ttc' => price2num($object->multicurrency_total_ttc), - $array_key.'_multicurrency_total_ht_locale' => price($object->multicurrency_total_ht, 0, $outputlangs), - $array_key.'_multicurrency_total_tva_locale' => price($object->multicurrency_total_tva, 0, $outputlangs), - $array_key.'_multicurrency_total_ttc_locale' => price($object->multicurrency_total_ttc, 0, $outputlangs), + $array_key.'_multicurrency_code' => $object->multicurrency_code, + $array_key.'_multicurrency_tx' => price2num($object->multicurrency_tx), + $array_key.'_multicurrency_total_ht' => price2num($object->multicurrency_total_ht), + $array_key.'_multicurrency_total_tva' => price2num($object->multicurrency_total_tva), + $array_key.'_multicurrency_total_ttc' => price2num($object->multicurrency_total_ttc), + $array_key.'_multicurrency_total_ht_locale' => price($object->multicurrency_total_ht, 0, $outputlangs), + $array_key.'_multicurrency_total_tva_locale' => price($object->multicurrency_total_tva, 0, $outputlangs), + $array_key.'_multicurrency_total_ttc_locale' => price($object->multicurrency_total_ttc, 0, $outputlangs), - $array_key.'_note_private'=>$object->note, - $array_key.'_note_public'=>$object->note_public, - $array_key.'_note'=>$object->note_public, // For backward compatibility + $array_key.'_note_private'=>$object->note, + $array_key.'_note_public'=>$object->note_public, + $array_key.'_note'=>$object->note_public, // For backward compatibility - // Payments - $array_key.'_already_payed_locale'=>price($sumpayed, 0, $outputlangs), - $array_key.'_already_payed'=>price2num($sumpayed), - $array_key.'_already_deposit_locale'=>price($sumdeposit, 0, $outputlangs), - $array_key.'_already_deposit'=>price2num($sumdeposit), - $array_key.'_already_creditnote_locale'=>price($sumcreditnote, 0, $outputlangs), - $array_key.'_already_creditnote'=>price2num($sumcreditnote), + // Payments + $array_key.'_already_payed_locale'=>price($sumpayed, 0, $outputlangs), + $array_key.'_already_payed'=>price2num($sumpayed), + $array_key.'_already_deposit_locale'=>price($sumdeposit, 0, $outputlangs), + $array_key.'_already_deposit'=>price2num($sumdeposit), + $array_key.'_already_creditnote_locale'=>price($sumcreditnote, 0, $outputlangs), + $array_key.'_already_creditnote'=>price2num($sumcreditnote), - $array_key.'_already_payed_all_locale'=>price(price2num($already_payed_all, 'MT'), 0, $outputlangs), - $array_key.'_already_payed_all'=> price2num($already_payed_all, 'MT'), + $array_key.'_already_payed_all_locale'=>price(price2num($already_payed_all, 'MT'), 0, $outputlangs), + $array_key.'_already_payed_all'=> price2num($already_payed_all, 'MT'), - // Remain to pay with all know information (except open direct debit requests) - $array_key.'_remain_to_pay_locale'=>price(price2num($object->total_ttc - $remain_to_pay, 'MT'), 0, $outputlangs), - $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $remain_to_pay, 'MT') + // Remain to pay with all known information (except open direct debit requests) + $array_key.'_remain_to_pay_locale'=>price(price2num($object->total_ttc - $already_payed_all, 'MT'), 0, $outputlangs), + $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $already_payed_all, 'MT') ); if (method_exists($object, 'getTotalDiscount') && in_array(get_class($object), array('Proposal', 'Commande', 'Facture', 'SupplierProposal', 'CommandeFournisseur', 'FactureFournisseur'))) { From a94b2b4f7e9ffe4ae0ecf99c72e27ffefd53d7c4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 03:21:15 +0100 Subject: [PATCH 085/178] Clean code --- .../core/class/commondocgenerator.class.php | 123 +++++++++--------- 1 file changed, 61 insertions(+), 62 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 641c2f80902..d65ecc1325d 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -398,7 +398,7 @@ abstract class CommonDocGenerator $sumpayed = $sumdeposit = $sumcreditnote = ''; $already_payed_all = 0; - $remain_to_pay = 0; + if ($object->element == 'facture') { $invoice_source = new Facture($this->db); if ($object->fk_facture_source > 0) { @@ -408,7 +408,6 @@ abstract class CommonDocGenerator $sumdeposit = $object->getSumDepositsUsed(); $sumcreditnote = $object->getSumCreditNotesUsed(); $already_payed_all = $sumpayed + $sumdeposit + $sumcreditnote; - $remain_to_pay = $sumpayed - $sumdeposit - $sumcreditnote; if ($object->fk_account > 0) { require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; @@ -420,76 +419,76 @@ abstract class CommonDocGenerator $date = ($object->element == 'contrat' ? $object->date_contrat : $object->date); $resarray = array( - $array_key.'_id'=>$object->id, - $array_key.'_ref'=>$object->ref, - $array_key.'_ref_ext'=>$object->ref_ext, - $array_key.'_ref_customer'=>(!empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ? '' : $object->ref_customer)), - $array_key.'_ref_supplier'=>(!empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), - $array_key.'_source_invoice_ref'=>$invoice_source->ref, - // Dates - $array_key.'_hour'=>dol_print_date($date, 'hour'), - $array_key.'_date'=>dol_print_date($date, 'day'), - $array_key.'_date_rfc'=>dol_print_date($date, 'dayrfc'), - $array_key.'_date_limit'=>(!empty($object->date_lim_reglement) ?dol_print_date($object->date_lim_reglement, 'day') : ''), - $array_key.'_date_end'=>(!empty($object->fin_validite) ?dol_print_date($object->fin_validite, 'day') : ''), - $array_key.'_date_creation'=>dol_print_date($object->date_creation, 'day'), - $array_key.'_date_modification'=>(!empty($object->date_modification) ?dol_print_date($object->date_modification, 'day') : ''), - $array_key.'_date_validation'=>(!empty($object->date_validation) ?dol_print_date($object->date_validation, 'dayhour') : ''), - $array_key.'_date_delivery_planed'=>(!empty($object->date_livraison) ?dol_print_date($object->date_livraison, 'day') : ''), - $array_key.'_date_close'=>(!empty($object->date_cloture) ?dol_print_date($object->date_cloture, 'dayhour') : ''), + $array_key.'_id'=>$object->id, + $array_key.'_ref'=>$object->ref, + $array_key.'_ref_ext'=>$object->ref_ext, + $array_key.'_ref_customer'=>(!empty($object->ref_client) ? $object->ref_client : (empty($object->ref_customer) ? '' : $object->ref_customer)), + $array_key.'_ref_supplier'=>(!empty($object->ref_fournisseur) ? $object->ref_fournisseur : (empty($object->ref_supplier) ? '' : $object->ref_supplier)), + $array_key.'_source_invoice_ref'=>$invoice_source->ref, + // Dates + $array_key.'_hour'=>dol_print_date($date, 'hour'), + $array_key.'_date'=>dol_print_date($date, 'day'), + $array_key.'_date_rfc'=>dol_print_date($date, 'dayrfc'), + $array_key.'_date_limit'=>(!empty($object->date_lim_reglement) ?dol_print_date($object->date_lim_reglement, 'day') : ''), + $array_key.'_date_end'=>(!empty($object->fin_validite) ?dol_print_date($object->fin_validite, 'day') : ''), + $array_key.'_date_creation'=>dol_print_date($object->date_creation, 'day'), + $array_key.'_date_modification'=>(!empty($object->date_modification) ?dol_print_date($object->date_modification, 'day') : ''), + $array_key.'_date_validation'=>(!empty($object->date_validation) ?dol_print_date($object->date_validation, 'dayhour') : ''), + $array_key.'_date_delivery_planed'=>(!empty($object->date_livraison) ?dol_print_date($object->date_livraison, 'day') : ''), + $array_key.'_date_close'=>(!empty($object->date_cloture) ?dol_print_date($object->date_cloture, 'dayhour') : ''), - $array_key.'_payment_mode_code'=>$object->mode_reglement_code, - $array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) : $object->mode_reglement), - $array_key.'_payment_term_code'=>$object->cond_reglement_code, - $array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) : ($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement)), + $array_key.'_payment_mode_code'=>$object->mode_reglement_code, + $array_key.'_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) != 'PaymentType'.$object->mode_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code) : $object->mode_reglement), + $array_key.'_payment_term_code'=>$object->cond_reglement_code, + $array_key.'_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) != 'PaymentCondition'.$object->cond_reglement_code ? $outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code) : ($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement)), - $array_key.'_incoterms'=>(method_exists($object, 'display_incoterms') ? $object->display_incoterms() : ''), + $array_key.'_incoterms'=>(method_exists($object, 'display_incoterms') ? $object->display_incoterms() : ''), - $array_key.'_bank_iban'=>$bank_account->iban, - $array_key.'_bank_bic'=>$bank_account->bic, - $array_key.'_bank_label'=>$bank_account->label, - $array_key.'_bank_number'=>$bank_account->number, - $array_key.'_bank_proprio'=>$bank_account->proprio, + $array_key.'_bank_iban'=>$bank_account->iban, + $array_key.'_bank_bic'=>$bank_account->bic, + $array_key.'_bank_label'=>$bank_account->label, + $array_key.'_bank_number'=>$bank_account->number, + $array_key.'_bank_proprio'=>$bank_account->proprio, - $array_key.'_total_ht_locale'=>price($object->total_ht, 0, $outputlangs), - $array_key.'_total_vat_locale'=>(!empty($object->total_vat) ?price($object->total_vat, 0, $outputlangs) : price($object->total_tva, 0, $outputlangs)), - $array_key.'_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs), - $array_key.'_total_localtax2_locale'=>price($object->total_localtax2, 0, $outputlangs), - $array_key.'_total_ttc_locale'=>price($object->total_ttc, 0, $outputlangs), + $array_key.'_total_ht_locale'=>price($object->total_ht, 0, $outputlangs), + $array_key.'_total_vat_locale'=>(!empty($object->total_vat) ?price($object->total_vat, 0, $outputlangs) : price($object->total_tva, 0, $outputlangs)), + $array_key.'_total_localtax1_locale'=>price($object->total_localtax1, 0, $outputlangs), + $array_key.'_total_localtax2_locale'=>price($object->total_localtax2, 0, $outputlangs), + $array_key.'_total_ttc_locale'=>price($object->total_ttc, 0, $outputlangs), - $array_key.'_total_ht'=>price2num($object->total_ht), - $array_key.'_total_vat'=>(!empty($object->total_vat) ?price2num($object->total_vat) : price2num($object->total_tva)), - $array_key.'_total_localtax1'=>price2num($object->total_localtax1), - $array_key.'_total_localtax2'=>price2num($object->total_localtax2), - $array_key.'_total_ttc'=>price2num($object->total_ttc), + $array_key.'_total_ht'=>price2num($object->total_ht), + $array_key.'_total_vat'=>(!empty($object->total_vat) ?price2num($object->total_vat) : price2num($object->total_tva)), + $array_key.'_total_localtax1'=>price2num($object->total_localtax1), + $array_key.'_total_localtax2'=>price2num($object->total_localtax2), + $array_key.'_total_ttc'=>price2num($object->total_ttc), - $array_key.'_multicurrency_code' => $object->multicurrency_code, - $array_key.'_multicurrency_tx' => price2num($object->multicurrency_tx), - $array_key.'_multicurrency_total_ht' => price2num($object->multicurrency_total_ht), - $array_key.'_multicurrency_total_tva' => price2num($object->multicurrency_total_tva), - $array_key.'_multicurrency_total_ttc' => price2num($object->multicurrency_total_ttc), - $array_key.'_multicurrency_total_ht_locale' => price($object->multicurrency_total_ht, 0, $outputlangs), - $array_key.'_multicurrency_total_tva_locale' => price($object->multicurrency_total_tva, 0, $outputlangs), - $array_key.'_multicurrency_total_ttc_locale' => price($object->multicurrency_total_ttc, 0, $outputlangs), + $array_key.'_multicurrency_code' => $object->multicurrency_code, + $array_key.'_multicurrency_tx' => price2num($object->multicurrency_tx), + $array_key.'_multicurrency_total_ht' => price2num($object->multicurrency_total_ht), + $array_key.'_multicurrency_total_tva' => price2num($object->multicurrency_total_tva), + $array_key.'_multicurrency_total_ttc' => price2num($object->multicurrency_total_ttc), + $array_key.'_multicurrency_total_ht_locale' => price($object->multicurrency_total_ht, 0, $outputlangs), + $array_key.'_multicurrency_total_tva_locale' => price($object->multicurrency_total_tva, 0, $outputlangs), + $array_key.'_multicurrency_total_ttc_locale' => price($object->multicurrency_total_ttc, 0, $outputlangs), - $array_key.'_note_private'=>$object->note, - $array_key.'_note_public'=>$object->note_public, - $array_key.'_note'=>$object->note_public, // For backward compatibility + $array_key.'_note_private'=>$object->note, + $array_key.'_note_public'=>$object->note_public, + $array_key.'_note'=>$object->note_public, // For backward compatibility - // Payments - $array_key.'_already_payed_locale'=>price($sumpayed, 0, $outputlangs), - $array_key.'_already_payed'=>price2num($sumpayed), - $array_key.'_already_deposit_locale'=>price($sumdeposit, 0, $outputlangs), - $array_key.'_already_deposit'=>price2num($sumdeposit), - $array_key.'_already_creditnote_locale'=>price($sumcreditnote, 0, $outputlangs), - $array_key.'_already_creditnote'=>price2num($sumcreditnote), + // Payments + $array_key.'_already_payed_locale'=>price($sumpayed, 0, $outputlangs), + $array_key.'_already_payed'=>price2num($sumpayed), + $array_key.'_already_deposit_locale'=>price($sumdeposit, 0, $outputlangs), + $array_key.'_already_deposit'=>price2num($sumdeposit), + $array_key.'_already_creditnote_locale'=>price($sumcreditnote, 0, $outputlangs), + $array_key.'_already_creditnote'=>price2num($sumcreditnote), - $array_key.'_already_payed_all_locale'=>price(price2num($already_payed_all, 'MT'), 0, $outputlangs), - $array_key.'_already_payed_all'=> price2num($already_payed_all, 'MT'), + $array_key.'_already_payed_all_locale'=>price(price2num($already_payed_all, 'MT'), 0, $outputlangs), + $array_key.'_already_payed_all'=> price2num($already_payed_all, 'MT'), - // Remain to pay with all know information (except open direct debit requests) - $array_key.'_remain_to_pay_locale'=>price(price2num($object->total_ttc - $remain_to_pay, 'MT'), 0, $outputlangs), - $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $remain_to_pay, 'MT') + // Remain to pay with all known information (except open direct debit requests) + $array_key.'_remain_to_pay_locale'=>price(price2num($object->total_ttc - $already_payed_all, 'MT'), 0, $outputlangs), + $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $already_payed_all, 'MT') ); if (method_exists($object, 'getTotalDiscount') && in_array(get_class($object), array('Proposal', 'Commande', 'Facture', 'SupplierProposal', 'CommandeFournisseur', 'FactureFournisseur'))) { From d026c721cf8f59933f8b66d3230af3f7896c08d7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 03:27:27 +0100 Subject: [PATCH 086/178] Update security2.lib.php --- htdocs/core/lib/security2.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index d6546e64cfd..2edb2e629de 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -215,17 +215,17 @@ if (!function_exists('dol_loginfunction')) { } // Execute hook getLoginPageOptions (for table) - $parameters = array('entity' => GETPOST('entity', 'int')); + $parameters = array('entity' => GETPOST('entity', 'int'), 'switchentity' => GETPOST('switchentity', 'int')); $reshook = $hookmanager->executeHooks('getLoginPageOptions', $parameters); // Note that $action and $object may have been modified by some hooks. $morelogincontent = $hookmanager->resPrint; // Execute hook getLoginPageExtraOptions (eg for js) - $parameters = array('entity' => GETPOST('entity', 'int')); + $parameters = array('entity' => GETPOST('entity', 'int'), 'switchentity' => GETPOST('switchentity', 'int')); $reshook = $hookmanager->executeHooks('getLoginPageExtraOptions', $parameters); // Note that $action and $object may have been modified by some hooks. $moreloginextracontent = $hookmanager->resPrint; //Redirect after connection - $parameters = array('entity' => GETPOST('entity', 'int')); + $parameters = array('entity' => GETPOST('entity', 'int'), 'switchentity' => GETPOST('switchentity', 'int')); $reshook = $hookmanager->executeHooks('redirectAfterConnection', $parameters); // Note that $action and $object may have been modified by some hooks. $php_self = $hookmanager->resPrint; From e8e0768eec34e01f6e10f11bfb8a8144cec0a199 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 03:47:16 +0100 Subject: [PATCH 087/178] Fix phpcs --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e18d0c081c2..81a5413182e 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -7227,7 +7227,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey = 0, $exclude = null, if ($object->id > 0) { $substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__'] = ($paymenturl ?str_replace('\n', "\n", $outputlangs->trans("PredefinedMailContentLink", $paymenturl)) : ''); $substitutionarray['__ONLINE_PAYMENT_URL__'] = $paymenturl; - + if (is_object($object) && $object->element == 'propal') { $substitutionarray['__ONLINE_SIGN_URL__'] = getOnlineSignatureUrl(0, 'proposal', $object->ref); } From b34fb95f4f8163ebc7287587803502054f4fba8f Mon Sep 17 00:00:00 2001 From: Gerhard Stephan Date: Mon, 8 Nov 2021 10:59:04 +0100 Subject: [PATCH 088/178] Load product data optional fields to the line -> enables to use "line_options_{extrafield}" --- htdocs/core/class/commondocgenerator.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index a92179e7b6a..e5a2ef4c9db 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -559,6 +559,15 @@ abstract class CommonDocGenerator $resarray = $this->fill_substitutionarray_with_extrafields($object, $resarray, $extrafields, $array_key, $outputlangs); } + // Load product data optional fields to the line -> enables to use "line_options_{extrafield}" + if (isset($line->fk_product) && $line->fk_product > 0) + { + $tmpproduct = new Product($this->db); + $result = $tmpproduct->fetch($line->fk_product); + foreach($tmpproduct->array_options as $key=>$label) + $resarray["line_".$key] = $label; + } + return $resarray; } From 3ff880aa74c12f389135cdad31b0726bf0084b84 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 11:40:40 +0100 Subject: [PATCH 089/178] Avoid virus detection --- test/phpunit/testvirus.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/phpunit/testvirus.txt b/test/phpunit/testvirus.txt index a2463df6d64..4a130462173 100644 --- a/test/phpunit/testvirus.txt +++ b/test/phpunit/testvirus.txt @@ -1 +1,2 @@ -X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H* \ No newline at end of file +# Remove this line and replace the ABC with X50 to get a file that is detected by antiviruses. +ABC!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H* \ No newline at end of file From 0a3a0862ffaf4c63396f4d96f765238e9f3e92cf Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 8 Nov 2021 13:33:24 +0100 Subject: [PATCH 090/178] fixes to be pure markdown --- SECURITY.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index 427b1cc7ae2..9c28e2874b9 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -12,8 +12,7 @@ This file contains some policies about the security reports on Dolibarr ERP CRM ## Reporting a Vulnerability -To report a vulnerability, please use GitHub security advisory at https://github.com/Dolibarr/dolibarr/security/advisories/new (if you have permissions) or alternatively send an email to security@dolibarr.org (for everybody) - +To report a vulnerability, please use GitHub security advisory at [https://github.com/Dolibarr/dolibarr/security/advisories/new](https://github.com/Dolibarr/dolibarr/security/advisories/new) (if you have permissions) or alternatively send an email to security@dolibarr.org (for everybody) ## Hunting vulnerabilities on Dolibarr @@ -23,7 +22,7 @@ If you believe you've found a security bug in our service, we are happy to work Any type of denial of service attacks is strictly forbidden, as well as any interference with network equipment and Dolibarr infrastructure. -We recommand to install Dolibarr ERP CRM on your own server (as most Open Source software, download and use is free: https://www.dolibarr.org/download) to get access on every side of application. +We recommand to install Dolibarr ERP CRM on your own server (as most Open Source software, download and use is free: [https://www.dolibarr.org/download](https://www.dolibarr.org/download)) to get access on every side of application. ### User Agent @@ -31,8 +30,7 @@ If you try to find bug on Dolibarr, we recommend to append to your user-agent he ### Account access -You can install the web application yourself on your own platform/server so you get full access to application and sources. Download the zip of the files to put into your own web server virtual host from https://www.dolibarr.org/download - +You can install the web application yourself on your own platform/server so you get full access to application and sources. Download the zip of the files to put into your own web server virtual host from [https://www.dolibarr.org/download](https://www.dolibarr.org/download) ## Eligibility and Responsible Disclosure @@ -46,7 +44,6 @@ You must avoid tests that could cause degradation or interruption of our service You must not leak, manipulate, or destroy any user data of third parties to find your vulnerability. - ## Scope for qualified vulnerabilities ONLY vulnerabilities discovered, when the following setup on test platform is used, are "valid": @@ -64,7 +61,6 @@ ONLY vulnerabilities discovered, when the following setup on test platform is us Scope is the web application (back office) and the APIs. - ## Qualifying vulnerabilities for reporting * Remote code execution (RCE) @@ -81,7 +77,6 @@ Scope is the web application (back office) and the APIs. * Software version disclosure (for non admin users only) * Stack traces or path disclosure (for non admin users only) - ## Non-qualifying vulnerabilities for reporting * "Self" XSS @@ -99,4 +94,3 @@ Scope is the web application (back office) and the APIs. * Software version or private IP disclosure when logged user is admin * Stack traces or path disclosure when logged user is admin * Any vulnerabilities due to a configuration different than the one defined into chapter "Scope for qualified vulnerabilities". - From d06d6c51cd7ca5802bcac3047386e9011e0fb14a Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 8 Nov 2021 13:44:46 +0100 Subject: [PATCH 091/178] MD041 - First line in a file should be a top-level heading --- htdocs/modulebuilder/template/core/boxes/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/modulebuilder/template/core/boxes/README.md b/htdocs/modulebuilder/template/core/boxes/README.md index b641e7136bc..3989bca5847 100644 --- a/htdocs/modulebuilder/template/core/boxes/README.md +++ b/htdocs/modulebuilder/template/core/boxes/README.md @@ -1 +1 @@ -Directory where widgets files are stored. \ No newline at end of file +# Directory where widgets files are stored From 85a3bbba3d9fc491b16ba761ce82afdef42b7af8 Mon Sep 17 00:00:00 2001 From: Philippe GRAND Date: Mon, 8 Nov 2021 13:51:03 +0100 Subject: [PATCH 092/178] Translations --- .../mailings/mailinglist_mymodule_myobject.modules.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php index dc797b99a94..b50f4acf741 100644 --- a/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mailings/mailinglist_mymodule_myobject.modules.php @@ -55,9 +55,9 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets /** - * Affiche formulaire de filtre qui apparait dans page de selection des destinataires de mailings + * Displays the filter form that appears in the mailing recipient selection page * - * @return string Retourne zone select + * @return string Return select zone */ public function formFilter() { @@ -83,7 +83,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets /** - * Renvoie url lien vers fiche de la source du destinataire du mailing + * Returns url link to file of the source of the recipient of the mailing * * @param int $id ID * @return string Url lien @@ -115,7 +115,7 @@ class mailing_mailinglist_mymodule_myobject extends MailingTargets } $sql .= " ORDER BY email"; - // Stocke destinataires dans target + // Store recipients in target $result = $this->db->query($sql); if ($result) { $num = $this->db->num_rows($result); From 39b8916215623e9d19d477d8ebe10e554510408e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 14:01:15 +0100 Subject: [PATCH 093/178] css --- htdocs/index.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/index.php b/htdocs/index.php index b9ac604ca95..be439300291 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -561,9 +561,11 @@ if (empty($conf->global->MAIN_DISABLE_GLOBAL_WORKBOARD)) { $nbtodClass = ''; if ($board->nbtodo > 0) { $nbtodClass = 'badge badge-info'; + } else { + $nbtodClass = 'opacitymedium'; } - $openedDashBoard .= ' '.$infoName.''.$board->nbtodo.''; + $openedDashBoard .= ''.$infoName.''.$board->nbtodo.''; if ($textLate) { if ($board->url_late) { $openedDashBoard .= ''; From c858c7bf53ff4f7be7dbef8b5a7f305ce090515e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 14:05:07 +0100 Subject: [PATCH 094/178] Trans shorter --- htdocs/langs/en_US/ticket.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/ticket.lang b/htdocs/langs/en_US/ticket.lang index 0134b96b935..d38358eb74d 100644 --- a/htdocs/langs/en_US/ticket.lang +++ b/htdocs/langs/en_US/ticket.lang @@ -318,7 +318,7 @@ BoxTicketLastXDays=Number of new tickets by days the last %s days BoxTicketLastXDayswidget = Number of new tickets by days the last X days BoxNoTicketLastXDays=No new tickets the last %s days BoxNumberOfTicketByDay=Number of new tickets by day -BoxNewTicketVSClose=Number of today's new tickets versus today's closed tickets +BoxNewTicketVSClose=Number of tickets versus closed tickets (today) TicketCreatedToday=Ticket created today TicketClosedToday=Ticket closed today KMFoundForTicketGroup=We found topics and FAQs that may answers your question, thanks to check them before submitting the ticket From c464a1cfd22385b70e94c2b8818034ac1f11cc47 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 14:37:21 +0100 Subject: [PATCH 095/178] Fix colors --- htdocs/core/class/dolgraph.class.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index e52ab780195..59213e9066e 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -107,10 +107,12 @@ class DolGraph global $conf; global $theme_bordercolor, $theme_datacolor, $theme_bgcolor; + // Some default values for the case it is not defined into the theme later. $this->bordercolor = array(235, 235, 224); $this->datacolor = array(array(120, 130, 150), array(160, 160, 180), array(190, 190, 220)); $this->bgcolor = array(235, 235, 224); + // Load color of the theme $color_file = DOL_DOCUMENT_ROOT . '/theme/' . $conf->theme . '/theme_vars.inc.php'; if (is_readable($color_file)) { include $color_file; @@ -1415,13 +1417,13 @@ class DolGraph $color = 'rgb(' . $newcolor[0] . ', ' . $newcolor[1] . ', ' . $newcolor[2] . ', 0.9)'; $bordercolor = 'rgb(' . $newcolor[0] . ', ' . $newcolor[1] . ', ' . $newcolor[2] . ')'; } else { // We do not use a 'group by' - if (!empty($this->bordercolor[$i]) && is_array($this->datacolor[$i])) { + if (!empty($this->datacolor[$i]) && is_array($this->datacolor[$i])) { $color = 'rgb(' . $this->datacolor[$i][0] . ', ' . $this->datacolor[$i][1] . ', ' . $this->datacolor[$i][2] . ', 0.9)'; } else { $color = $this->datacolor[$i]; } if (!empty($this->bordercolor[$i]) && is_array($this->bordercolor[$i])) { - $color = 'rgb(' . $this->bordercolor[$i][0] . ', ' . $this->bordercolor[$i][1] . ', ' . $this->bordercolor[$i][2] . ', 0.9)'; + $bordercolor = 'rgb(' . $this->bordercolor[$i][0] . ', ' . $this->bordercolor[$i][1] . ', ' . $this->bordercolor[$i][2] . ', 0.9)'; } else { if ($type != 'horizontalBar') { $bordercolor = $color; From f4b2a6ec9235545f84b5f58ade7fbc7eaa769de6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 14:51:14 +0100 Subject: [PATCH 096/178] Fix negative colors for bars --- htdocs/core/class/dolgraph.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 59213e9066e..a93ed92e8f5 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -1431,6 +1431,14 @@ class DolGraph $bordercolor = $this->bordercolor[$i]; } } + + // For negative colors, we invert border and background + $tmp = str_replace('#', '', $color); + if (strpos($tmp, '-') !== false) { + $foundnegativecolor++; + $bordercolor = str_replace('-', '', $color); + $color = '#FFFFFF'; // If $val is '-123' + } } if ($i > 0) { $this->stringtoshow .= ', '; From c1a2e7b12e1706f02dd9f5df50256cc7f0c1fc2b Mon Sep 17 00:00:00 2001 From: Marc de Lima Lucio <68746600+marc-dll@users.noreply.github.com> Date: Mon, 8 Nov 2021 17:51:19 +0100 Subject: [PATCH 097/178] FIX: project task list: extrafields could not be displayed --- htdocs/projet/tasks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks.php b/htdocs/projet/tasks.php index d61dffeee3c..03816ff91df 100644 --- a/htdocs/projet/tasks.php +++ b/htdocs/projet/tasks.php @@ -135,6 +135,7 @@ if ($object->usage_bill_time) { } // Extra fields +$extrafieldsobjectkey = $taskstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_array_fields.tpl.php'; $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -774,7 +775,6 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third if (!empty($conf->global->PROJECT_SHOW_CONTACTS_IN_LIST)) print ''; - $extrafieldsobjectkey = $taskstatic->table_element; include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_input.tpl.php'; // Action column From 86365271254fa9bcc8933bc944bbc3155cf17a9b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 17:53:18 +0100 Subject: [PATCH 098/178] Clean code --- .../boxes/box_graph_invoices_permonth.php | 10 ++----- .../box_graph_invoices_supplier_permonth.php | 28 +++++-------------- 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/htdocs/core/boxes/box_graph_invoices_permonth.php b/htdocs/core/boxes/box_graph_invoices_permonth.php index 18ffe022610..65498ab6362 100644 --- a/htdocs/core/boxes/box_graph_invoices_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_permonth.php @@ -146,9 +146,6 @@ class box_graph_invoices_permonth extends ModeleBoxes $filenamenb = $dir."/".$prefix."invoicesnbinyear-".$endyear.".png"; // default value for customer mode $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$endyear.'.png'; - if ($mode == 'supplier') { - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessuppliernbinyear-'.$endyear.'.png'; - } $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); @@ -189,10 +186,7 @@ class box_graph_invoices_permonth extends ModeleBoxes $filenamenb = $dir."/".$prefix."invoicesamountinyear-".$endyear.".png"; // default value for customer mode - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$endyear.'.png'; - if ($mode == 'supplier') { - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessupplieramountinyear-'.$endyear.'.png'; - } + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$endyear.'.png'; $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); @@ -251,7 +245,7 @@ class box_graph_invoices_permonth extends ModeleBoxes $stringtoshow .= ' '.$langs->trans("AmountOfBillsByMonthHT"); $stringtoshow .= '
    '; $stringtoshow .= $langs->trans("Year").' '; - $stringtoshow .= ''; + $stringtoshow .= ''; $stringtoshow .= ''; $stringtoshow .= ''; if ($shownb && $showtot) { diff --git a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php index 3d8cb88938d..4ba27c74b1a 100644 --- a/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php +++ b/htdocs/core/boxes/box_graph_invoices_supplier_permonth.php @@ -125,9 +125,6 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes $showtot = 1; } $nowarray = dol_getdate(dol_now(), true); - if (empty($year)) { - $year = $nowarray['year']; - } if (empty($endyear)) { $endyear = $nowarray['year']; } @@ -143,12 +140,9 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes if ($shownb) { $data1 = $stats->getNbByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); - $filenamenb = $dir."/".$prefix."invoicessuppliernbinyear-".$year.".png"; + $filenamenb = $dir."/".$prefix."invoicessuppliernbinyear-".$endyear.".png"; // default value for customer mode - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesnbinyear-'.$year.'.png'; - if ($mode == 'supplier') { - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessuppliernbinyear-'.$year.'.png'; - } + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessuppliernbinyear-'.$endyear.'.png'; $px1 = new DolGraph(); $mesg = $px1->isGraphKo(); @@ -186,12 +180,9 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes if ($showtot) { $data2 = $stats->getAmountByMonthWithPrevYear($endyear, $startyear, (GETPOST('action', 'aZ09') == $refreshaction ?-1 : (3600 * 24)), ($WIDTH < 300 ? 2 : 0), $startmonth); - $filenamenb = $dir."/".$prefix."invoicessupplieramountinyear-".$year.".png"; + $filenamenb = $dir."/".$prefix."invoicessupplieramountinyear-".$endyear.".png"; // default value for customer mode - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstats&file=invoicesamountinyear-'.$year.'.png'; - if ($mode == 'supplier') { - $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessupplieramountinyear-'.$year.'.png'; - } + $fileurlnb = DOL_URL_ROOT.'/viewimage.php?modulepart=billstatssupplier&file=invoicessupplieramountinyear-'.$endyear.'.png'; $px2 = new DolGraph(); $mesg = $px2->isGraphKo(); @@ -273,17 +264,12 @@ class box_graph_invoices_supplier_permonth extends ModeleBoxes } $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover center"', 'textnoformat'=>$stringtoshow); } else { - $this->info_box_contents[0][0] = array( - 'tr'=>'class="oddeven nohover"', - 'td' => 'class="nohover left"', - 'maxlength'=>500, - 'text' => $mesg, - ); + $this->info_box_contents[0][0] = array('tr'=>'class="oddeven nohover"', 'td' => 'class="nohover left"', 'maxlength'=>500, 'text' => $mesg); } } else { $this->info_box_contents[0][0] = array( - 'td' => 'class="nohover opacitymedium left"', - 'text' => $langs->trans("ReadPermissionNotAllowed") + 'td' => 'class="nohover left"', + 'text' => ''.$langs->trans("ReadPermissionNotAllowed").'' ); } } From bd9d3bb4aba43dbdd0edb7e092c68562880d6bf9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 18:10:35 +0100 Subject: [PATCH 099/178] Clean code --- htdocs/includes/odtphp/odf.php | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/htdocs/includes/odtphp/odf.php b/htdocs/includes/odtphp/odf.php index a7416258a57..80183843b36 100644 --- a/htdocs/includes/odtphp/odf.php +++ b/htdocs/includes/odtphp/odf.php @@ -79,7 +79,7 @@ class Odf // Create tmp direcoty (will be deleted in destructor) if (!file_exists($this->tmpdir)) { - $result=mkdir($this->tmpdir); + $result = mkdir($this->tmpdir); } // Load zip proxy @@ -329,6 +329,7 @@ class Odf $tempHtml = $html; while (strlen($tempHtml) > 0) { + $matches = array(); // Check if the string includes a html tag if (preg_match_all('/<([A-Za-z]+)(?:\s([A-Za-z]+(?:\-[A-Za-z]+)?(?:=(?:".*?")|(?:[0-9]+))))*(?:(?:\s\/>)|(?:>(.*)<\/\1>))/', $tempHtml, $matches)) { $tagOffset = strpos($tempHtml, $matches[0][0]); @@ -342,6 +343,7 @@ class Odf $tempHtml = substr($tempHtml, $tagOffset); } // Extract the attribute data from the html tag + $explodedAttributes = array(); preg_match_all('/([0-9A-Za-z]+(?:="[0-9A-Za-z\:\-\s\,\;\#]*")?)+/', $matches[2][0], $explodedAttributes); $explodedAttributes = array_filter($explodedAttributes[0]); $attributes = array(); @@ -447,32 +449,6 @@ class Odf return $value; } - /** - * Evaluating php codes inside the ODT and output the buffer (print, echo) inplace of the code - * - * @return int 0 - */ - public function phpEval() - { - preg_match_all('/[\{\<]\?(php)?\s+(?P.+)\?[\}\>]/iU', $this->contentXml, $matches); // detecting all {?php code ?} or - $nbfound=count($matches['content']); - for ($i=0; $i < $nbfound; $i++) { - try { - $ob_output = ''; // flush the output for each code. This var will be filled in by the eval($code) and output buffering : any print or echo or output will be redirected into this variable - $code = $matches['content'][$i]; - ob_start(); - eval($code); - $ob_output = ob_get_contents(); // send the content of the buffer into $ob_output - $this->contentXml = str_replace($matches[0][$i], $ob_output, $this->contentXml); - ob_end_clean(); - } catch (Exception $e) { - ob_end_clean(); - $this->contentXml = str_replace($matches[0][$i], 'ERROR: there was a problem while evaluating this portion of code, please fix it: '.$e, $this->contentXml); - } - } - return 0; - } - /** * Assign a template variable as a picture * @@ -515,10 +491,12 @@ IMG; // Search all possible rows in the document $reg1 = "#]*>(.*)#smU"; + $matches = array(); preg_match_all($reg1, $this->contentXml, $matches); for ($i = 0, $size = count($matches[0]); $i < $size; $i++) { // Check if the current row contains a segment row.* $reg2 = '#\[!--\sBEGIN\s(row.[\S]*)\s--\](.*)\[!--\sEND\s\\1\s--\]#sm'; + $matches2 = array(); if (preg_match($reg2, $matches[0][$i], $matches2)) { $balise = str_replace('row.', '', $matches2[1]); // Move segment tags around the row @@ -665,6 +643,7 @@ IMG; } // $reg = "#\[!--\sBEGIN\s$segment\s--\]<\/text:p>(.*)\[!--\sEND\s$segment\s--\]#sm"; $reg = "#\[!--\sBEGIN\s$segment\s--\](.*)\[!--\sEND\s$segment\s--\]#sm"; + $m = array(); if (preg_match($reg, html_entity_decode($this->contentXml), $m) == 0) { throw new OdfException("'".$segment."' segment not found in the document. The tag [!-- BEGIN xxx --] or [!-- END xxx --] is not present into content file."); } @@ -1005,6 +984,7 @@ IMG; public function getvalue($valuename) { $searchreg="/\\[".$valuename."\\](.*)\\[\\/".$valuename."\\]/"; + $matches = array(); preg_match($searchreg, $this->contentXml, $matches); $this->contentXml = preg_replace($searchreg, "", $this->contentXml); return $matches[1]; From 6e01f1702e2642a52787ce23b59a2550d1c444e4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 18:45:00 +0100 Subject: [PATCH 100/178] Fix css --- htdocs/projet/stats/index.php | 6 +++++- htdocs/projet/tasks/stats/index.php | 9 +++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/htdocs/projet/stats/index.php b/htdocs/projet/stats/index.php index c5acc20bfe6..878b80165d5 100644 --- a/htdocs/projet/stats/index.php +++ b/htdocs/projet/stats/index.php @@ -302,7 +302,9 @@ print $form->selectarray('year', $arrayyears, $year, 0); print ''; print ''; print ''; + print ''; + print '

    '; print '
    '; @@ -369,10 +371,12 @@ $stringtoshow .= ''; print $stringtoshow; +print '
    '; -print ''; print '
    '; +print dol_get_fiche_end(); + // End of page llxFooter(); $db->close(); diff --git a/htdocs/projet/tasks/stats/index.php b/htdocs/projet/tasks/stats/index.php index 60cbdf37072..5fd6b47407c 100644 --- a/htdocs/projet/tasks/stats/index.php +++ b/htdocs/projet/tasks/stats/index.php @@ -172,7 +172,9 @@ print $form->selectarray('year', $arrayyears, $year, 0); print ''; print ''; print ''; + print ''; + print '

    '; @@ -190,13 +192,13 @@ foreach ($data_all_year as $val) { $oldyear--; print ''; - print ' 0 ? '&userid='.$userid : '').'">'.$oldyear.''; + print ' 0 ? '&userid='.$userid : '').'">'.$oldyear.''; print '0'; print ''; } print ''; - print ' 0 ? '&userid='.$userid : '').'">'.$year.''; + print ' 0 ? '&userid='.$userid : '').'">'.$year.''; print ''.$val['nb'].''; print ''; $oldyear = $year; @@ -220,8 +222,11 @@ print $stringtoshow; print ''; + print '
    '; +print dol_get_fiche_end(); + // End of page llxFooter(); $db->close(); From 69ea6c5b7a82284c9d06f527cd641f2b61980d1b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 18:49:30 +0100 Subject: [PATCH 101/178] css --- htdocs/theme/md/style.css.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 06598624da2..42de9b1c6f1 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1987,7 +1987,7 @@ div.fichehalfleft { print "float: ".$left.";\n"; } ?> browser->layout != 'phone') { - print "width: calc(50% - 10px);\n"; + print "width: calc(50% - 14px);\n"; } ?> } div.fichehalfright { @@ -1995,7 +1995,7 @@ div.fichehalfright { print "float: ".$right.";\n"; } ?> browser->layout != 'phone') { - print "width: calc(50% - 10px);\n"; + print "width: calc(50% - 14px);\n"; } ?> } div.fichehalfright { From 6e1213128faeb28fb21e3f159d8b8eef9cd52275 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 18:53:19 +0100 Subject: [PATCH 102/178] Look and feel v15 --- htdocs/contrat/list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php index 0cfa0b2bf16..4c8c9c7aae5 100644 --- a/htdocs/contrat/list.php +++ b/htdocs/contrat/list.php @@ -810,8 +810,9 @@ while ($i < min($num, $limit)) { } print ''; } + // Email if (!empty($arrayfields['s.email']['checked'])) { - print ''.dol_print_email($obj->email).''; + print ''.dol_print_email($obj->email, 0, $obj->socid, 0, 0, 1, 1).''; } // Town if (!empty($arrayfields['s.town']['checked'])) { From 13e8e3d33c8a31e989f30615e5919de0487374c0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 19:15:02 +0100 Subject: [PATCH 103/178] Look and feel v15 --- htdocs/core/class/html.formother.class.php | 1 - htdocs/theme/md/style.css.php | 9 +++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 99ee1b6af9b..ebe28237cc4 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -542,7 +542,6 @@ class FormOther $resql_usr = $this->db->query($sql_usr); if ($resql_usr) { $userstatic = new User($this->db); - $showstatus = 1; while ($obj_usr = $this->db->fetch_object($resql_usr)) { $userstatic->id = $obj_usr->rowid; diff --git a/htdocs/theme/md/style.css.php b/htdocs/theme/md/style.css.php index 42de9b1c6f1..b750ac21b1e 100644 --- a/htdocs/theme/md/style.css.php +++ b/htdocs/theme/md/style.css.php @@ -1521,11 +1521,11 @@ table[summary="list_of_modules"] .fa-cog { } /* Set a width. Note: add also a max-width, for example maxwidth500, that will be used in priority */ -.widthcentpercentminusx { +select.widthcentpercentminusx, span.widthcentpercentminusx:not(.select2-selection), input.widthcentpercentminusx { width: calc(100% - 50px) !important; display: inline-block; } -.widthcentpercentminusxx { +select.widthcentpercentminusxx, span.widthcentpercentminusxx:not(.select2-selection), input.widthcentpercentminusxx { width: calc(100% - 70px) !important; display: inline-block; } @@ -3829,11 +3829,12 @@ div.liste_titre_bydiv { border-top-color: var(--colortopbordertitle1); border-top-style: solid; - box-shadow: none; border-collapse: collapse; display: table; padding: 2px 0px 2px 0; - width: calc(100% - 1px); + box-shadow: none; + /*width: calc(100% - 1px); 1px more, i don't know why so i remove */ + width: calc(100%); } tr.liste_titre, tr.liste_titre_sel, form.liste_titre, form.liste_titre_sel, table.dataTable.tr, tagtr.liste_titre { From ebdcff3b49e6bc76c8e519f784864b15fe6465eb Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 20:07:03 +0100 Subject: [PATCH 104/178] FIX filter for export of accounting documents --- htdocs/compta/accounting-files.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 2c94cea750c..791da74b030 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -610,8 +610,12 @@ if (!empty($date_start) && !empty($date_stop)) { echo dol_print_date($date_start, 'day')." - ".dol_print_date($date_stop, 'day'); - print ''; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; foreach ($listofchoices as $choice => $val) { print ''; } From d28edae46009f9ca0f01042946e0fcf905b10263 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 20:11:32 +0100 Subject: [PATCH 105/178] Fix idate must be jdate --- htdocs/compta/accounting-files.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 791da74b030..15096e28b4f 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -348,8 +348,8 @@ if (($action == 'searchfiles' || $action == 'dl')) { $nofile = array(); $nofile['id'] = $objd->id; $nofile['entity'] = $objd->entity; - $nofile['date'] = $db->idate($objd->date); - $nofile['date_due'] = $db->idate($objd->date_due); + $nofile['date'] = $db->jdate($objd->date); + $nofile['date_due'] = $db->jdate($objd->date_due); $nofile['paid'] = $objd->paid; $nofile['amount_ht'] = $objd->total_ht; $nofile['amount_ttc'] = $objd->total_ttc; @@ -368,8 +368,8 @@ if (($action == 'searchfiles' || $action == 'dl')) { foreach ($files as $key => $file) { $file['id'] = $objd->id; $file['entity'] = $objd->entity; - $file['date'] = $db->idate($objd->date); - $file['date_due'] = $db->idate($objd->date_due); + $file['date'] = $db->jdate($objd->date); + $file['date_due'] = $db->jdate($objd->date_due); $file['paid'] = $objd->paid; $file['amount_ht'] = $objd->total_ht; $file['amount_ttc'] = $objd->total_ttc; From 9f8e21bc2cd3f0a2e6edffdd33a53c162a9b9a23 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Nov 2021 20:39:52 +0100 Subject: [PATCH 106/178] Fix filter on dates --- htdocs/compta/accounting-files.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/accounting-files.php b/htdocs/compta/accounting-files.php index 15096e28b4f..a06dd8dacaf 100644 --- a/htdocs/compta/accounting-files.php +++ b/htdocs/compta/accounting-files.php @@ -57,12 +57,12 @@ $date_start = GETPOST('date_start', 'alpha'); $date_startDay = GETPOST('date_startday', 'int'); $date_startMonth = GETPOST('date_startmonth', 'int'); $date_startYear = GETPOST('date_startyear', 'int'); -$date_start = ($date_startDay ? dol_mktime(0, 0, 0, $date_startMonth, $date_startDay, $date_startYear, 'tzuserrel') : dol_stringtotime($date_start)); +$date_start = dol_mktime(0, 0, 0, $date_startMonth, $date_startDay, $date_startYear, 'tzuserrel'); $date_stop = GETPOST('date_stop', 'alpha'); $date_stopDay = GETPOST('date_stopday', 'int'); $date_stopMonth = GETPOST('date_stopmonth', 'int'); $date_stopYear = GETPOST('date_stopyear', 'int'); -$date_stop = ($date_stopDay ? dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear, 'tzuserrel') : dol_stringtotime($date_stop)); +$date_stop = dol_mktime(23, 59, 59, $date_stopMonth, $date_stopDay, $date_stopYear, 'tzuserrel'); $action = GETPOST('action', 'aZ09'); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context @@ -460,7 +460,7 @@ if ($result && $action == "dl" && !$error) { $log .= ','.$langs->transnoentitiesnoconv("Country"); $log .= ','.$langs->transnoentitiesnoconv("VATIntra"); $log .= ','.$langs->transnoentitiesnoconv("Sens")."\n"; - $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc')."-".dol_print_date($date_stop, 'dayrfc').'_export.zip'; + $zipname = $dirfortmpfile.'/'.dol_print_date($date_start, 'dayrfc', 'tzuserrel')."-".dol_print_date($date_stop, 'dayrfc', 'tzuserrel').'_export.zip'; dol_delete_file($zipname); @@ -608,7 +608,7 @@ if (!empty($date_start) && !empty($date_stop)) { print '
    '."\n"; print ''; - echo dol_print_date($date_start, 'day')." - ".dol_print_date($date_stop, 'day'); + echo dol_print_date($date_start, 'day', 'tzuserrel')." - ".dol_print_date($date_stop, 'day', 'tzuserrel'); print ''; print ''; @@ -745,19 +745,19 @@ if (!empty($date_start) && !empty($date_stop)) { print ''.$data['paid'].''; // Total ET - print ''.price($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'])."\n"; + print ''.price(price2num($data['sens'] ? $data['amount_ht'] : -$data['amount_ht'], 'MT'))."\n"; // Total IT - print ''.price($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'])."\n"; + print ''.price(price2num($data['sens'] ? $data['amount_ttc'] : -$data['amount_ttc'], 'MT'))."\n"; // Total VAT - print ''.price($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'])."\n"; + print ''.price(price2num($data['sens'] ? $data['amount_vat'] : -$data['amount_vat'], 'MT'))."\n"; - print ''.$data['thirdparty_name']."\n"; + print ''.dol_escape_htmltag($data['thirdparty_name'])."\n"; print ''.$data['thirdparty_code']."\n"; print ''.$data['country_code']."\n"; - print ''.$data['vatnum']."\n"; + print ''.dol_escape_htmltag($data['vatnum'])."\n"; if ($data['sens']) { $totalET_credit += $data['amount_ht']; From d611b99d958a0404c9d97e3193cdbc43a609d4f7 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Tue, 9 Nov 2021 03:01:48 +0100 Subject: [PATCH 107/178] GNU version 3 --- dev/initdemo/sftpget_and_loaddump.php | 2 +- dev/initdemo/updatedemo.php | 2 +- dev/translation/sanity_check_en_langfiles.php | 2 +- dev/translation/strip_language_file.php | 2 +- htdocs/accountancy/class/lettering.class.php | 2 +- htdocs/admin/expensereport_ik.php | 2 +- htdocs/admin/expensereport_rules.php | 2 +- htdocs/compta/bank/account_statement_document.php | 2 +- htdocs/compta/bank/document.php | 2 +- htdocs/fourn/commande/dispatch.php | 11 +++++------ htdocs/holiday/month_report.php | 2 +- htdocs/install/mysql/data/llx_c_units.sql | 2 +- htdocs/install/mysql/tables/llx_c_exp_tax_cat.sql | 2 +- htdocs/install/mysql/tables/llx_c_exp_tax_range.sql | 2 +- .../mysql/tables/llx_c_ticket_category.key.sql | 2 +- htdocs/install/mysql/tables/llx_c_ticket_category.sql | 2 +- .../mysql/tables/llx_c_ticket_resolution.key.sql | 2 +- .../install/mysql/tables/llx_c_ticket_resolution.sql | 2 +- .../mysql/tables/llx_c_ticket_severity.key.sql | 2 +- htdocs/install/mysql/tables/llx_c_ticket_severity.sql | 2 +- htdocs/install/mysql/tables/llx_c_ticket_type.key.sql | 2 +- htdocs/install/mysql/tables/llx_c_ticket_type.sql | 2 +- htdocs/install/mysql/tables/llx_c_units.key.sql | 2 +- htdocs/install/mysql/tables/llx_c_units.sql | 2 +- htdocs/install/mysql/tables/llx_expensereport_ik.sql | 2 +- .../install/mysql/tables/llx_expensereport_rules.sql | 2 +- .../install/mysql/tables/llx_facturedet_rec.key.sql | 2 +- .../install/mysql/tables/llx_ticket_extrafields.sql | 2 +- htdocs/loan/calcmens.php | 5 ++--- htdocs/public/ticket/create_ticket.php | 2 +- 30 files changed, 35 insertions(+), 37 deletions(-) diff --git a/dev/initdemo/sftpget_and_loaddump.php b/dev/initdemo/sftpget_and_loaddump.php index 7d781fe5b0c..63b5ac65054 100755 --- a/dev/initdemo/sftpget_and_loaddump.php +++ b/dev/initdemo/sftpget_and_loaddump.php @@ -4,7 +4,7 @@ * * 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 2 of the License, or + * 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, diff --git a/dev/initdemo/updatedemo.php b/dev/initdemo/updatedemo.php index 4dd98451823..4ee2032c7cf 100755 --- a/dev/initdemo/updatedemo.php +++ b/dev/initdemo/updatedemo.php @@ -4,7 +4,7 @@ * * 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 2 of the License, or + * 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, diff --git a/dev/translation/sanity_check_en_langfiles.php b/dev/translation/sanity_check_en_langfiles.php index 39db0a55764..840f09a0adb 100755 --- a/dev/translation/sanity_check_en_langfiles.php +++ b/dev/translation/sanity_check_en_langfiles.php @@ -6,7 +6,7 @@ * * 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 2 of the License, or + * 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, diff --git a/dev/translation/strip_language_file.php b/dev/translation/strip_language_file.php index 3467b648457..f0a0397cd6e 100755 --- a/dev/translation/strip_language_file.php +++ b/dev/translation/strip_language_file.php @@ -5,7 +5,7 @@ * * 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 2 of the License, or + * 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, diff --git a/htdocs/accountancy/class/lettering.class.php b/htdocs/accountancy/class/lettering.class.php index 1dd4c4df3e5..f722a716b79 100644 --- a/htdocs/accountancy/class/lettering.class.php +++ b/htdocs/accountancy/class/lettering.class.php @@ -6,7 +6,7 @@ * * 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 2 of the License, or + * 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, diff --git a/htdocs/admin/expensereport_ik.php b/htdocs/admin/expensereport_ik.php index d32ef64aebc..900754ef4b4 100644 --- a/htdocs/admin/expensereport_ik.php +++ b/htdocs/admin/expensereport_ik.php @@ -5,7 +5,7 @@ * * 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 2 of the License, or + * 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, diff --git a/htdocs/admin/expensereport_rules.php b/htdocs/admin/expensereport_rules.php index bddaf58475a..77fb8f24f82 100644 --- a/htdocs/admin/expensereport_rules.php +++ b/htdocs/admin/expensereport_rules.php @@ -6,7 +6,7 @@ * * 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 2 of the License, or + * 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, diff --git a/htdocs/compta/bank/account_statement_document.php b/htdocs/compta/bank/account_statement_document.php index 0a979e01d39..f36d455dc74 100644 --- a/htdocs/compta/bank/account_statement_document.php +++ b/htdocs/compta/bank/account_statement_document.php @@ -8,7 +8,7 @@ * * 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 2 of the License, or + * 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, diff --git a/htdocs/compta/bank/document.php b/htdocs/compta/bank/document.php index 7dce00005f3..389c8195f37 100644 --- a/htdocs/compta/bank/document.php +++ b/htdocs/compta/bank/document.php @@ -7,7 +7,7 @@ * * 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 2 of the License, or + * 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, diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 170785c0118..547abd33b4b 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -10,19 +10,18 @@ * Copyright (C) 2018 Frédéric France * Copyright (C) 2019-2020 Christophe Battarel * - * 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 2 of the License, or + * 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, + * 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 + * 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/ */ /** diff --git a/htdocs/holiday/month_report.php b/htdocs/holiday/month_report.php index 1bb58ca98b0..ad9b0295b2d 100644 --- a/htdocs/holiday/month_report.php +++ b/htdocs/holiday/month_report.php @@ -6,7 +6,7 @@ * * 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 2 of the License, or + * 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, diff --git a/htdocs/install/mysql/data/llx_c_units.sql b/htdocs/install/mysql/data/llx_c_units.sql index 59692793fe2..475020aabaf 100644 --- a/htdocs/install/mysql/data/llx_c_units.sql +++ b/htdocs/install/mysql/data/llx_c_units.sql @@ -6,7 +6,7 @@ -- -- 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 2 of the License, or +-- 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, diff --git a/htdocs/install/mysql/tables/llx_c_exp_tax_cat.sql b/htdocs/install/mysql/tables/llx_c_exp_tax_cat.sql index 15d89c4747c..90c60d87b97 100644 --- a/htdocs/install/mysql/tables/llx_c_exp_tax_cat.sql +++ b/htdocs/install/mysql/tables/llx_c_exp_tax_cat.sql @@ -5,7 +5,7 @@ -- -- 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 2 of the License, or +-- 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, diff --git a/htdocs/install/mysql/tables/llx_c_exp_tax_range.sql b/htdocs/install/mysql/tables/llx_c_exp_tax_range.sql index e80eeb15d50..0d996df7033 100644 --- a/htdocs/install/mysql/tables/llx_c_exp_tax_range.sql +++ b/htdocs/install/mysql/tables/llx_c_exp_tax_range.sql @@ -5,7 +5,7 @@ -- -- 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 2 of the License, or +-- 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, diff --git a/htdocs/install/mysql/tables/llx_c_ticket_category.key.sql b/htdocs/install/mysql/tables/llx_c_ticket_category.key.sql index 3afa9b5be1d..d5917ce1f5d 100644 --- a/htdocs/install/mysql/tables/llx_c_ticket_category.key.sql +++ b/htdocs/install/mysql/tables/llx_c_ticket_category.key.sql @@ -2,7 +2,7 @@ -- -- 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 2 of the License, or +-- 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, diff --git a/htdocs/install/mysql/tables/llx_c_ticket_category.sql b/htdocs/install/mysql/tables/llx_c_ticket_category.sql index 57bd15f2c23..8477b455796 100644 --- a/htdocs/install/mysql/tables/llx_c_ticket_category.sql +++ b/htdocs/install/mysql/tables/llx_c_ticket_category.sql @@ -3,7 +3,7 @@ -- -- 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 2 of the License, or +-- 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, diff --git a/htdocs/install/mysql/tables/llx_c_ticket_resolution.key.sql b/htdocs/install/mysql/tables/llx_c_ticket_resolution.key.sql index ac3690b70bb..472a4f4ca30 100644 --- a/htdocs/install/mysql/tables/llx_c_ticket_resolution.key.sql +++ b/htdocs/install/mysql/tables/llx_c_ticket_resolution.key.sql @@ -2,7 +2,7 @@ -- -- 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 2 of the License, or +-- 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, diff --git a/htdocs/install/mysql/tables/llx_c_ticket_resolution.sql b/htdocs/install/mysql/tables/llx_c_ticket_resolution.sql index 2f6d0d1d3da..d935d9556a4 100644 --- a/htdocs/install/mysql/tables/llx_c_ticket_resolution.sql +++ b/htdocs/install/mysql/tables/llx_c_ticket_resolution.sql @@ -2,7 +2,7 @@ -- -- 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 2 of the License, or +-- 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, diff --git a/htdocs/install/mysql/tables/llx_c_ticket_severity.key.sql b/htdocs/install/mysql/tables/llx_c_ticket_severity.key.sql index a564f0059d2..fbe3e9e7de1 100644 --- a/htdocs/install/mysql/tables/llx_c_ticket_severity.key.sql +++ b/htdocs/install/mysql/tables/llx_c_ticket_severity.key.sql @@ -2,7 +2,7 @@ -- -- 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 2 of the License, or +-- 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, diff --git a/htdocs/install/mysql/tables/llx_c_ticket_severity.sql b/htdocs/install/mysql/tables/llx_c_ticket_severity.sql index b9f565c4395..c87c258faa6 100644 --- a/htdocs/install/mysql/tables/llx_c_ticket_severity.sql +++ b/htdocs/install/mysql/tables/llx_c_ticket_severity.sql @@ -2,7 +2,7 @@ -- -- 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 2 of the License, or +-- 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, diff --git a/htdocs/install/mysql/tables/llx_c_ticket_type.key.sql b/htdocs/install/mysql/tables/llx_c_ticket_type.key.sql index 7a4374e35fa..c912c3da835 100644 --- a/htdocs/install/mysql/tables/llx_c_ticket_type.key.sql +++ b/htdocs/install/mysql/tables/llx_c_ticket_type.key.sql @@ -2,7 +2,7 @@ -- -- 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 2 of the License, or +-- 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, diff --git a/htdocs/install/mysql/tables/llx_c_ticket_type.sql b/htdocs/install/mysql/tables/llx_c_ticket_type.sql index 462d1a71535..3c476ff848b 100644 --- a/htdocs/install/mysql/tables/llx_c_ticket_type.sql +++ b/htdocs/install/mysql/tables/llx_c_ticket_type.sql @@ -2,7 +2,7 @@ -- -- 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 2 of the License, or +-- 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, diff --git a/htdocs/install/mysql/tables/llx_c_units.key.sql b/htdocs/install/mysql/tables/llx_c_units.key.sql index d3e1d40e50a..93c8b9600d2 100644 --- a/htdocs/install/mysql/tables/llx_c_units.key.sql +++ b/htdocs/install/mysql/tables/llx_c_units.key.sql @@ -4,7 +4,7 @@ -- -- 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 2 of the License, or +-- 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, diff --git a/htdocs/install/mysql/tables/llx_c_units.sql b/htdocs/install/mysql/tables/llx_c_units.sql index ef77703ae6e..7b2424a8f54 100644 --- a/htdocs/install/mysql/tables/llx_c_units.sql +++ b/htdocs/install/mysql/tables/llx_c_units.sql @@ -5,7 +5,7 @@ -- -- 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 2 of the License, or +-- 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, diff --git a/htdocs/install/mysql/tables/llx_expensereport_ik.sql b/htdocs/install/mysql/tables/llx_expensereport_ik.sql index 839fbac8e9a..d2b1fd80815 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_ik.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_ik.sql @@ -5,7 +5,7 @@ -- -- 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 2 of the License, or +-- 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, diff --git a/htdocs/install/mysql/tables/llx_expensereport_rules.sql b/htdocs/install/mysql/tables/llx_expensereport_rules.sql index ae8f9b09496..1892ead3500 100644 --- a/htdocs/install/mysql/tables/llx_expensereport_rules.sql +++ b/htdocs/install/mysql/tables/llx_expensereport_rules.sql @@ -4,7 +4,7 @@ -- -- 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 2 of the License, or +-- 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, diff --git a/htdocs/install/mysql/tables/llx_facturedet_rec.key.sql b/htdocs/install/mysql/tables/llx_facturedet_rec.key.sql index 2580c33a7ab..616df5ec148 100644 --- a/htdocs/install/mysql/tables/llx_facturedet_rec.key.sql +++ b/htdocs/install/mysql/tables/llx_facturedet_rec.key.sql @@ -5,7 +5,7 @@ -- -- 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 2 of the License, or +-- 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, diff --git a/htdocs/install/mysql/tables/llx_ticket_extrafields.sql b/htdocs/install/mysql/tables/llx_ticket_extrafields.sql index 31f82064461..5131150649a 100644 --- a/htdocs/install/mysql/tables/llx_ticket_extrafields.sql +++ b/htdocs/install/mysql/tables/llx_ticket_extrafields.sql @@ -2,7 +2,7 @@ -- -- 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 2 of the License, or +-- 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, diff --git a/htdocs/loan/calcmens.php b/htdocs/loan/calcmens.php index 19763c0a924..cc6debab86c 100644 --- a/htdocs/loan/calcmens.php +++ b/htdocs/loan/calcmens.php @@ -5,7 +5,7 @@ * * 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 2 of the License, or + * 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, @@ -14,8 +14,7 @@ * 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, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * along with this program. If not, see . */ /** diff --git a/htdocs/public/ticket/create_ticket.php b/htdocs/public/ticket/create_ticket.php index e621feb6653..00eff71da78 100644 --- a/htdocs/public/ticket/create_ticket.php +++ b/htdocs/public/ticket/create_ticket.php @@ -4,7 +4,7 @@ * * 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 2 of the License, or + * 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, From 33e40c12c8e5552f568f8c70f620b53f2dfa168a Mon Sep 17 00:00:00 2001 From: lvessiller Date: Tue, 9 Nov 2021 14:12:28 +0100 Subject: [PATCH 108/178] FIX close cash with some terminals in TakePOS --- htdocs/takepos/index.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 344955a9167..f3b9991061e 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -732,6 +732,7 @@ $( document ).ready(function() { if ($conf->global->TAKEPOS_CONTROL_CASH_OPENING) { $sql = "SELECT rowid, status FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE"; $sql .= " entity = ".$conf->entity." AND "; + $sql .= " posnumber = ".$_SESSION["takeposterminal"]." AND "; $sql .= " date(date_creation) = CURDATE()"; $resql = $db->query($sql); if ($resql) { @@ -918,6 +919,7 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { $sql = "SELECT rowid, status, entity FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE"; $sql .= " entity = ".$conf->entity." AND "; +$sql .= " posnumber = ".$_SESSION["takeposterminal"]." AND "; $sql .= " date(date_creation) = CURDATE()"; $resql = $db->query($sql); if ($resql) From cea3d93b91c3eaa829f34ae73aa9ee2d8bed676a Mon Sep 17 00:00:00 2001 From: daraelmin Date: Tue, 9 Nov 2021 20:51:27 +0100 Subject: [PATCH 109/178] Fix wrong sign in test --- htdocs/adherents/subscription.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 05e55206c02..d9ab62336a1 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -943,7 +943,7 @@ if ($rowid > 0) { } if (!$datefrom) { $datefrom = $object->datevalid; - if ($object->datefin > 0 && dol_time_plus_duree($object->datefin, $defaultdelay, $defaultdelayunit) < dol_now()) { + if ($object->datefin > 0 && dol_time_plus_duree($object->datefin, $defaultdelay, $defaultdelayunit) > dol_now()) { $datefrom = dol_time_plus_duree($object->datefin, 1, 'd'); } else { $datefrom = dol_get_first_day(dol_print_date(time(), "%Y")); From e5d40bf464894bb815a7032590f72373fd0afbf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 10 Nov 2021 12:06:39 +0100 Subject: [PATCH 110/178] error display --- htdocs/compta/cashcontrol/cashcontrol_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index c7b74abfc39..4e82aa12686 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -128,7 +128,7 @@ if (GETPOST('cancel', 'alpha')) { if ($action == "reopen") { $result = $object->setStatut($object::STATUS_DRAFT, null, '', 'CASHFENCE_REOPEN'); if ($result < 0) { - dol_print_error($db, $object->error, $object->error); + setEventMessages($object->error, $object->error, 'errors'); } $action = 'view'; From 005254ad3438ce400c6136d88b56eb0b0f626e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 10 Nov 2021 12:21:03 +0100 Subject: [PATCH 111/178] Update cashcontrol_card.php --- htdocs/compta/cashcontrol/cashcontrol_card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 4e82aa12686..2cb658f135f 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -356,7 +356,7 @@ if ($action == "create" || $action == "start" || $action == 'close') { } elseif ($syear && $smonth && $sday) { $sql .= " AND datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'"; } else { - dol_print_error('', 'Year not defined'); + setEventMessages($langs->trans('Year not defined'), null, 'errors'); } $resql = $db->query($sql); From 06e6479a123c74b11cf732814077e485b8cb184a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 10 Nov 2021 12:24:53 +0100 Subject: [PATCH 112/178] Update cashcontrol_card.php --- htdocs/compta/cashcontrol/cashcontrol_card.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 2cb658f135f..1950cdb5392 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -312,7 +312,7 @@ if ($action == "create" || $action == "start" || $action == 'close') { } elseif ($syear && $smonth && $sday) { $sql .= " AND dateo < '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."'"; } else { - dol_print_error('', 'Year not defined'); + setEventMessages($langs->trans('YearNotDefined'), null, 'errors'); } $resql = $db->query($sql); @@ -356,7 +356,7 @@ if ($action == "create" || $action == "start" || $action == 'close') { } elseif ($syear && $smonth && $sday) { $sql .= " AND datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'"; } else { - setEventMessages($langs->trans('Year not defined'), null, 'errors'); + setEventMessages($langs->trans('YearNotDefined'), null, 'errors'); } $resql = $db->query($sql); From c9517db43badbc80b514d35625358cad2efe63a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 10 Nov 2021 12:26:28 +0100 Subject: [PATCH 113/178] Update cashdesk.lang --- htdocs/langs/en_US/cashdesk.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 22d5afed2fc..5792e015040 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -133,3 +133,4 @@ SplitSale=Split sale PrintWithoutDetailsButton=Add "Print without details" button PrintWithoutDetailsLabelDefault=Line label by default on printing without details PrintWithoutDetails=Print without details +YearNotDefined=Year is not defined From 0afaf080ee0bb5f94458427eb2bfe24f66b79c5c Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Wed, 10 Nov 2021 14:53:17 +0100 Subject: [PATCH 114/178] FIX bug if multicompany disabled avoid bad constantes --- htdocs/core/class/html.form.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 56f7c41994b..fb0bba95ac4 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1926,7 +1926,7 @@ class Form $sql .= " WHERE u.entity IS NOT NULL"; } } else { - if (!empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { + if (!empty($conf->multicompany->enabled) && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."usergroup_user as ug"; $sql .= " ON ug.fk_user = u.rowid"; $sql .= " WHERE ug.entity = ".$conf->entity; From 285bd67d90d60743124bf7f81e6f699b3a0c6b21 Mon Sep 17 00:00:00 2001 From: Gerhard Stephan Date: Wed, 10 Nov 2021 15:16:36 +0100 Subject: [PATCH 115/178] Added -Propal- as a missing class name to the commondocgenerator.class.php --- htdocs/core/class/commondocgenerator.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index e5a2ef4c9db..544a08198f8 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -492,7 +492,7 @@ abstract class CommonDocGenerator $array_key.'_remain_to_pay'=>price2num($object->total_ttc - $already_payed_all, 'MT') ); - if (method_exists($object, 'getTotalDiscount') && in_array(get_class($object), array('Proposal', 'Commande', 'Facture', 'SupplierProposal', 'CommandeFournisseur', 'FactureFournisseur'))) { + if (method_exists($object, 'getTotalDiscount') && in_array(get_class($object), array('Propal', 'Proposal', 'Commande', 'Facture', 'SupplierProposal', 'CommandeFournisseur', 'FactureFournisseur'))) { $resarray[$array_key.'_total_discount_ht_locale'] = price($object->getTotalDiscount(), 0, $outputlangs); $resarray[$array_key.'_total_discount_ht'] = price2num($object->getTotalDiscount()); } else { @@ -538,7 +538,7 @@ abstract class CommonDocGenerator // Note that this added fields does not match a field into database in Dolibarr (Dolibarr manage discount on lines not as a global property of object) $resarray['object_total_up'] = $totalUp; $resarray['object_total_up_locale'] = price($resarray['object_total_up'], 0, $outputlangs); - if (method_exists($object, 'getTotalDiscount') && in_array(get_class($object), array('Proposal', 'Commande', 'Facture', 'SupplierProposal', 'CommandeFournisseur', 'FactureFournisseur'))) { + if (method_exists($object, 'getTotalDiscount') && in_array(get_class($object), array('Propal', 'Proposal', 'Commande', 'Facture', 'SupplierProposal', 'CommandeFournisseur', 'FactureFournisseur'))) { $totalDiscount = $object->getTotalDiscount(); } else { $totalDiscount = 0; From 7c5810dee61f7416521e3e157dfc9e5d06824702 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 10 Nov 2021 14:19:14 +0000 Subject: [PATCH 116/178] Fixing style errors. --- htdocs/core/class/commondocgenerator.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 544a08198f8..a0f3f311ed4 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -560,14 +560,13 @@ abstract class CommonDocGenerator } // Load product data optional fields to the line -> enables to use "line_options_{extrafield}" - if (isset($line->fk_product) && $line->fk_product > 0) - { + if (isset($line->fk_product) && $line->fk_product > 0) { $tmpproduct = new Product($this->db); $result = $tmpproduct->fetch($line->fk_product); - foreach($tmpproduct->array_options as $key=>$label) + foreach ($tmpproduct->array_options as $key=>$label) $resarray["line_".$key] = $label; } - + return $resarray; } From 6a216e520f202142e93c4f9f21099ef527cd9003 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Thu, 11 Nov 2021 11:06:05 +0100 Subject: [PATCH 117/178] block deletion of items not free to delete (is_deletable) --- htdocs/core/actions_massactions.inc.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 8ccff0eb017..7c24257594f 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1295,7 +1295,14 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' if ($objectclass == 'Facture' && empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED) && $objecttmp->status != Facture::STATUS_DRAFT) { $langs->load("errors"); $nbignored++; - $resaction .= '
    '.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).'

    '; + $TMsg[] = '
    '.$langs->trans('ErrorOnlyDraftStatusCanBeDeletedInMassAction', $objecttmp->ref).'

    '; + continue; + } + + if ($objecttmp->is_erasable() <= 0) { + $langs->load("errors"); + $nbignored++; + $TMsg[] = '
    '.$langs->trans('ErrorRecordHasChildren').' '.$objecttmp->ref.'

    '; continue; } From 28e14ac336f16610449c3de73c84934d6c97f845 Mon Sep 17 00:00:00 2001 From: Christian Foellmann Date: Thu, 11 Nov 2021 13:28:33 +0100 Subject: [PATCH 118/178] fix permission on supplier_order document upload --- htdocs/supplier_proposal/document.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/supplier_proposal/document.php b/htdocs/supplier_proposal/document.php index a8b85fc25b5..884519a4f9a 100644 --- a/htdocs/supplier_proposal/document.php +++ b/htdocs/supplier_proposal/document.php @@ -75,7 +75,7 @@ if ($object->id > 0) { $upload_dir = $conf->supplier_proposal->dir_output.'/'.dol_sanitizeFileName($object->ref); } - +$permissiontoadd = $user->rights->supplier_proposal->creer; /* * Actions From bbd97c6e16a42d3e57c4df7c7680d95236a90df6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 13:36:04 +0100 Subject: [PATCH 119/178] Code comment --- htdocs/core/db/DoliDB.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php index 1aecd205da3..1ebea289470 100644 --- a/htdocs/core/db/DoliDB.class.php +++ b/htdocs/core/db/DoliDB.class.php @@ -233,7 +233,7 @@ abstract class DoliDB implements Database * Define sort criteria of request * * @param string $sortfield List of sort fields, separated by comma. Example: 't1.fielda,t2.fieldb' - * @param string $sortorder Sort order, separated by comma. Example: 'ASC,DESC'; + * @param string $sortorder Sort order, separated by comma. Example: 'ASC,DESC'. Note: If the quantity fo sortorder values is lower than sortfield, we used the last value for missing values. * @return string String to provide syntax of a sort sql string */ public function order($sortfield = null, $sortorder = null) From fd3fd9d945f51a14146df69be9e60baf2f755946 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 13:46:58 +0100 Subject: [PATCH 120/178] Fix getpost --- htdocs/compta/bank/transfer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php index 9665a8a2b1f..f728dc74f4e 100644 --- a/htdocs/compta/bank/transfer.php +++ b/htdocs/compta/bank/transfer.php @@ -61,8 +61,8 @@ if ($action == 'add') { $dateo = dol_mktime(12, 0, 0, GETPOST('remonth', 'int'), GETPOST('reday', 'int'), GETPOST('reyear', 'int')); $label = GETPOST('label', 'alpha'); - $amount = price2num(GETPOST('amount', 'alpha'), 'MT'); - $amountto = price2num(GETPOST('amountto', 'alpha'), 'MT'); + $amount = price2num(GETPOST('amount', 'alpha'), 'MT', 2); + $amountto = price2num(GETPOST('amountto', 'alpha'), 'MT', 2); if (!$label) { $error++; From 0443302c3d5fb814eb6e813c1bafe27393730c08 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 13:49:21 +0100 Subject: [PATCH 121/178] FIX calculation of balance in conciliation page on desc sorting. --- htdocs/compta/bank/bankentries_list.php | 13 ++++++------- htdocs/core/lib/functions.lib.php | 8 +++++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 8628e287bd0..00a61a7ce7e 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -178,7 +178,6 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); - /* * Actions */ @@ -270,13 +269,15 @@ if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', ' if (!$error) { $param = 'action=reconcile&contextpage=banktransactionlist&id='.$id.'&search_account='.$id; - $param .= '&search_conciliated='.urlencode($search_conciliated); if ($page) { $param .= '&page='.urlencode($page); } if ($offset) { $param .= '&offset='.urlencode($offset); } + if ($search_conciliated != '' && $search_conciliated != '-1') { + $param .= '&search_conciliated='.urlencode($search_conciliated); + } if ($search_thirdparty_user) { $param .= '&search_thirdparty='.urlencode($search_thirdparty_user); } @@ -419,7 +420,6 @@ $banklinestatic = new AccountLine($db); $now = dol_now(); - // Must be before button action $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { @@ -757,7 +757,7 @@ if ($resql) { // Confirmation delete if ($action == 'delete') { $text = $langs->trans('ConfirmDeleteTransaction'); - print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid"), $langs->trans('DeleteTransaction'), $text, 'confirm_delete', null, '', 1); + print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid", 'int'), $langs->trans('DeleteTransaction'), $text, 'confirm_delete', null, '', 1); } // Lines of title fields @@ -1200,7 +1200,7 @@ if ($resql) { $objforbalance = $db->fetch_object($resqlforbalance); if ($objforbalance) { // If sort is desc,desc,desc then total of previous date + amount is the balancebefore of the previous line before the line to show - if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc') { + if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) { $balancebefore = $objforbalance->previoustotal + ($sign * $objp->amount); } else { // If sort is asc,asc,asc then total of previous date is balance of line before the next line to show @@ -1285,8 +1285,7 @@ if ($resql) { } } - - if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc') { + if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) { $balance = price2num($balancebefore, 'MT'); // balance = balancebefore of previous line (sort is desc) $balancebefore = price2num($balancebefore - ($sign * $objp->amount), 'MT'); } else { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 81a5413182e..54a44753513 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5378,13 +5378,16 @@ function price2num($amount, $rounding = '', $option = 0) if ($thousand != ',' && $thousand != '.') { $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users } + $amount = str_replace(' ', '', $amount); // To avoid spaces $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is . $amount = str_replace($dec, '.', $amount); + + $amount = preg_replace('/[^0-9\-\.]/', '', $amount); // Clean non numeric chars (so it clean some UTF8 spaces for example. } //print ' XX'.$amount.' '.$rounding; - // Now, make a rounding if required + // Now, $amount is a real PHP float number. We make a rounding if required. if ($rounding) { $nbofdectoround = ''; if ($rounding == 'MU') { @@ -5424,9 +5427,12 @@ function price2num($amount, $rounding = '', $option = 0) if ($thousand != ',' && $thousand != '.') { $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users } + $amount = str_replace(' ', '', $amount); // To avoid spaces $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is . $amount = str_replace($dec, '.', $amount); + + $amount = preg_replace('/[^0-9\-\.]/', '', $amount); // Clean non numeric chars (so it clean some UTF8 spaces for example. } return $amount; From 28aa17e4fd5d17511f1646021ebf98b397990903 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 13:49:21 +0100 Subject: [PATCH 122/178] FIX calculation of balance in conciliation page on desc sorting. --- htdocs/compta/bank/bankentries_list.php | 13 ++++++------- htdocs/core/lib/functions.lib.php | 8 +++++++- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 14aeee29d69..84938f24dbc 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -175,7 +175,6 @@ $object->fields = dol_sort_array($object->fields, 'position'); $arrayfields = dol_sort_array($arrayfields, 'position'); - /* * Actions */ @@ -266,13 +265,15 @@ if ((GETPOST('confirm_savestatement', 'alpha') || GETPOST('confirm_reconcile', ' if (!$error) { $param = 'action=reconcile&contextpage=banktransactionlist&id='.$id.'&search_account='.$id; - $param .= '&search_conciliated='.urlencode($search_conciliated); if ($page) { $param .= '&page='.urlencode($page); } if ($offset) { $param .= '&offset='.urlencode($offset); } + if ($search_conciliated != '' && $search_conciliated != '-1') { + $param .= '&search_conciliated='.urlencode($search_conciliated); + } if ($search_thirdparty_user) { $param .= '&search_thirdparty='.urlencode($search_thirdparty_user); } @@ -415,7 +416,6 @@ $banklinestatic = new AccountLine($db); $now = dol_now(); - // Must be before button action $param = ''; if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) { @@ -748,7 +748,7 @@ if ($resql) { // Confirmation delete if ($action == 'delete') { $text = $langs->trans('ConfirmDeleteTransaction'); - print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid"), $langs->trans('DeleteTransaction'), $text, 'confirm_delete', null, '', 1); + print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&rowid='.GETPOST("rowid", 'int'), $langs->trans('DeleteTransaction'), $text, 'confirm_delete', null, '', 1); } // Lines of title fields @@ -1189,7 +1189,7 @@ if ($resql) { $objforbalance = $db->fetch_object($resqlforbalance); if ($objforbalance) { // If sort is desc,desc,desc then total of previous date + amount is the balancebefore of the previous line before the line to show - if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc') { + if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) { $balancebefore = $objforbalance->previoustotal + ($sign * $objp->amount); } else { // If sort is asc,asc,asc then total of previous date is balance of line before the next line to show @@ -1274,8 +1274,7 @@ if ($resql) { } } - - if ($sortfield == 'b.datev,b.dateo,b.rowid' && $sortorder == 'desc,desc,desc') { + if ($sortfield == 'b.datev,b.dateo,b.rowid' && ($sortorder == 'desc' || $sortorder == 'desc,desc' || $sortorder == 'desc,desc,desc')) { $balance = price2num($balancebefore, 'MT'); // balance = balancebefore of previous line (sort is desc) $balancebefore = price2num($balancebefore - ($sign * $objp->amount), 'MT'); } else { diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index eae8546a338..07ff2930f0f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -5329,13 +5329,16 @@ function price2num($amount, $rounding = '', $option = 0) if ($thousand != ',' && $thousand != '.') { $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users } + $amount = str_replace(' ', '', $amount); // To avoid spaces $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is . $amount = str_replace($dec, '.', $amount); + + $amount = preg_replace('/[^0-9\-\.]/', '', $amount); // Clean non numeric chars (so it clean some UTF8 spaces for example. } //print ' XX'.$amount.' '.$rounding; - // Now, make a rounding if required + // Now, $amount is a real PHP float number. We make a rounding if required. if ($rounding) { $nbofdectoround = ''; if ($rounding == 'MU') { @@ -5375,9 +5378,12 @@ function price2num($amount, $rounding = '', $option = 0) if ($thousand != ',' && $thousand != '.') { $amount = str_replace(',', '.', $amount); // To accept 2 notations for french users } + $amount = str_replace(' ', '', $amount); // To avoid spaces $amount = str_replace($thousand, '', $amount); // Replace of thousand before replace of dec to avoid pb if thousand is . $amount = str_replace($dec, '.', $amount); + + $amount = preg_replace('/[^0-9\-\.]/', '', $amount); // Clean non numeric chars (so it clean some UTF8 spaces for example. } return $amount; From 9cb094b46638fe37b8028084214a6525650686c5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 14:37:25 +0100 Subject: [PATCH 123/178] Fix error method not defined --- htdocs/core/actions_massactions.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 7c24257594f..80ba0b671eb 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1299,7 +1299,7 @@ if (!$error && ($massaction == 'delete' || ($action == 'delete' && $confirm == ' continue; } - if ($objecttmp->is_erasable() <= 0) { + if (method_exists($objecttmp, 'is_erasable') && $objecttmp->is_erasable() <= 0) { $langs->load("errors"); $nbignored++; $TMsg[] = '
    '.$langs->trans('ErrorRecordHasChildren').' '.$objecttmp->ref.'

    '; From da2f3e7b406fdcfa76be9651b7d54a7ad6c1b51f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 14:55:59 +0100 Subject: [PATCH 124/178] Code comment --- htdocs/core/class/commondocgenerator.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index a92179e7b6a..e5d8db4cb53 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -516,8 +516,9 @@ abstract class CommonDocGenerator // Add vat by rates if (is_array($object->lines) && count($object->lines) > 0) { $totalUp = 0; + // Set substitution keys for different VAT rates foreach ($object->lines as $line) { - // $line->tva_tx format depends on database field accuraty, no reliable. This is kept for backward compatibility + // $line->tva_tx format depends on database field accuracy, no reliable. This is kept for backward compatibility if (empty($resarray[$array_key.'_total_vat_'.$line->tva_tx])) { $resarray[$array_key.'_total_vat_'.$line->tva_tx] = 0; } From c6ecf87a8a8ee583cb99264f70c03d0e9778a189 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 15:02:51 +0100 Subject: [PATCH 125/178] Update commondocgenerator.class.php --- htdocs/core/class/commondocgenerator.class.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index a0f3f311ed4..0f962a9ca09 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -559,14 +559,6 @@ abstract class CommonDocGenerator $resarray = $this->fill_substitutionarray_with_extrafields($object, $resarray, $extrafields, $array_key, $outputlangs); } - // Load product data optional fields to the line -> enables to use "line_options_{extrafield}" - if (isset($line->fk_product) && $line->fk_product > 0) { - $tmpproduct = new Product($this->db); - $result = $tmpproduct->fetch($line->fk_product); - foreach ($tmpproduct->array_options as $key=>$label) - $resarray["line_".$key] = $label; - } - return $resarray; } From 66f1dd854584717bfbaa95002e3d933da8abc20f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 15:12:31 +0100 Subject: [PATCH 126/178] Fix avoid too large PDF --- htdocs/core/lib/pdf.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index dda52e653fe..255d4dcf453 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2247,7 +2247,7 @@ function pdf_getLinkedObjects(&$object, $outputlangs) } elseif ($objecttype == 'commande' || $objecttype == 'supplier_order') { $outputlangs->load('orders'); - if (count($objects) > 1) { + if (count($objects) > 1 && count($objects) <= (getDolGlobalInt("MAXREFONDOC") ? getDolGlobalInt("MAXREFONDOC") : 5)) { $object->note_public .= dol_concatdesc($object->note_public, '
    '.$outputlangs->transnoentities("RefOrder").' :
    '); foreach ($objects as $elementobject) { $object->note_public .= dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref).($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '').($elementobject->ref_supplier ? ' ('.$elementobject->ref_supplier.')' : '').' '); From 436dbcd81d176737fe6a6a4f8288d38b0d5eb16a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 15:22:54 +0100 Subject: [PATCH 127/178] Shorter pdf label --- htdocs/langs/en_US/propal.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/langs/en_US/propal.lang b/htdocs/langs/en_US/propal.lang index ed07831fcba..db7b559a8a7 100644 --- a/htdocs/langs/en_US/propal.lang +++ b/htdocs/langs/en_US/propal.lang @@ -5,7 +5,7 @@ ProposalShort=Proposal ProposalsDraft=Draft commercial proposals ProposalsOpened=Open commercial proposals CommercialProposal=Commercial proposal -PdfCommercialProposalTitle=Commercial proposal +PdfCommercialProposalTitle=Proposal ProposalCard=Proposal card NewProp=New commercial proposal NewPropal=New proposal From 06f378db18d4dfb18956c04b822c630ce48cbbaf Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 15:31:19 +0100 Subject: [PATCH 128/178] FIX Bad use of dol_concatdesc() --- htdocs/core/lib/pdf.lib.php | 27 ++++++++++---------- htdocs/datapolicy/class/datapolicy.class.php | 16 ++++++------ 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 255d4dcf453..873b375496e 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -2247,13 +2247,11 @@ function pdf_getLinkedObjects(&$object, $outputlangs) } elseif ($objecttype == 'commande' || $objecttype == 'supplier_order') { $outputlangs->load('orders'); - if (count($objects) > 1 && count($objects) <= (getDolGlobalInt("MAXREFONDOC") ? getDolGlobalInt("MAXREFONDOC") : 5)) { - $object->note_public .= dol_concatdesc($object->note_public, '
    '.$outputlangs->transnoentities("RefOrder").' :
    '); + if (count($objects) > 1 && count($objects) <= (getDolGlobalInt("MAXREFONDOC") ? getDolGlobalInt("MAXREFONDOC") : 10)) { + $object->note_public = dol_concatdesc($object->note_public, '
    '.$outputlangs->transnoentities("RefOrder").' :
    '); foreach ($objects as $elementobject) { - $object->note_public .= dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref).($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '').($elementobject->ref_supplier ? ' ('.$elementobject->ref_supplier.')' : '').' '); - $object->note_public .= dol_concatdesc($object->note_public, $outputlangs->transnoentities("OrderDate").' : '); - $object->note_public .= dol_concatdesc($object->note_public, dol_print_date($elementobject->date, 'day', '', $outputlangs)); - $object->note_public .= dol_concatdesc($object->note_public, '
    '); + $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref).($elementobject->ref_client ? ' ('.$elementobject->ref_client.')' : '').($elementobject->ref_supplier ? ' ('.$elementobject->ref_supplier.')' : '').' '); + $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities("OrderDate").' : '.dol_print_date($elementobject->date, 'day', '', $outputlangs).'
    '); } } elseif (count($objects) == 1) { $elementobject = array_shift($objects); @@ -2283,8 +2281,11 @@ function pdf_getLinkedObjects(&$object, $outputlangs) if (count($objects) > 1) { $order = null; - if (empty($object->linkedObjects['commande']) && $object->element != 'commande') $object->note_public .= dol_concatdesc($object->note_public, '
    '.$outputlangs->transnoentities("RefOrder").' / '.$outputlangs->transnoentities("RefSending").' :
    '); - else $object->note_public .= dol_concatdesc($object->note_public, '
    '.$outputlangs->transnoentities("RefSending").' :
    '); + if (empty($object->linkedObjects['commande']) && $object->element != 'commande') { + $object->note_public = dol_concatdesc($object->note_public, '
    '.$outputlangs->transnoentities("RefOrder").' / '.$outputlangs->transnoentities("RefSending").' :
    '); + } else { + $object->note_public = dol_concatdesc($object->note_public, '
    '.$outputlangs->transnoentities("RefSending").' :
    '); + } // We concat this record info into fields xxx_value. title is overwrote. foreach ($objects as $elementobject) { if (empty($object->linkedObjects['commande']) && $object->element != 'commande') { // There is not already a link to order and object is not the order, so we show also info with order @@ -2300,12 +2301,12 @@ function pdf_getLinkedObjects(&$object, $outputlangs) } if (! is_object($order)) { - $object->note_public .= dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref)); - $object->note_public .= dol_concatdesc($object->note_public, '
    '); + $object->note_public = dol_concatdesc($object->note_public, $outputlangs->transnoentities($elementobject->ref)); + $object->note_public = dol_concatdesc($object->note_public, '
    '); } else { - $object->note_public .= dol_concatdesc($object->note_public, $outputlangs->convToOutputCharset($order->ref).($order->ref_client ? ' ('.$order->ref_client.')' : '')); - $object->note_public .= dol_concatdesc($object->note_public, ' / '.$outputlangs->transnoentities($elementobject->ref)); - $object->note_public .= dol_concatdesc($object->note_public, '
    '); + $object->note_public = dol_concatdesc($object->note_public, $outputlangs->convToOutputCharset($order->ref).($order->ref_client ? ' ('.$order->ref_client.')' : '')); + $object->note_public = dol_concatdesc($object->note_public, ' / '.$outputlangs->transnoentities($elementobject->ref)); + $object->note_public = dol_concatdesc($object->note_public, '
    '); } } } elseif (count($objects) == 1) { diff --git a/htdocs/datapolicy/class/datapolicy.class.php b/htdocs/datapolicy/class/datapolicy.class.php index a7ed08d7e6f..7d53020ce3a 100644 --- a/htdocs/datapolicy/class/datapolicy.class.php +++ b/htdocs/datapolicy/class/datapolicy.class.php @@ -269,11 +269,11 @@ class DataPolicy $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { if ($sendtocc) { - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); } - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); - $actionmsg .= dol_concatdesc($actionmsg, $message); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } // Send mail @@ -343,11 +343,11 @@ class DataPolicy $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { if ($sendtocc) { - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); } - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); - $actionmsg .= dol_concatdesc($actionmsg, $message); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } From fa4b5d99c0f728c66238e1da52694190af5c7bd0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 15:35:34 +0100 Subject: [PATCH 129/178] FIX Bad use of dol_concatdesc() --- htdocs/datapolicy/class/datapolicy.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/datapolicy/class/datapolicy.class.php b/htdocs/datapolicy/class/datapolicy.class.php index a7ed08d7e6f..7d53020ce3a 100644 --- a/htdocs/datapolicy/class/datapolicy.class.php +++ b/htdocs/datapolicy/class/datapolicy.class.php @@ -269,11 +269,11 @@ class DataPolicy $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { if ($sendtocc) { - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); } - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); - $actionmsg .= dol_concatdesc($actionmsg, $message); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } // Send mail @@ -343,11 +343,11 @@ class DataPolicy $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto; if ($message) { if ($sendtocc) { - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc').": ".$sendtocc); } - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); - $actionmsg .= dol_concatdesc($actionmsg, $message); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic').": ".$subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody').":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } From ba724204a430cc841a068b777ebf1d6e2ca727cc Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 15:50:32 +0100 Subject: [PATCH 130/178] FIX Bad use of dol_concatdesc() --- htdocs/datapolicy/class/datapolicy.class.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/datapolicy/class/datapolicy.class.php b/htdocs/datapolicy/class/datapolicy.class.php index bf1033084d5..7383e059ae3 100644 --- a/htdocs/datapolicy/class/datapolicy.class.php +++ b/htdocs/datapolicy/class/datapolicy.class.php @@ -259,11 +259,11 @@ class DataPolicy { if ($sendtocc) { - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); } - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); - $actionmsg .= dol_concatdesc($actionmsg, $message); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } // Send mail @@ -329,11 +329,11 @@ class DataPolicy $actionmsg = $langs->transnoentities('MailSentBy') . ' ' . $from . ' ' . $langs->transnoentities('To') . ' ' . $sendto; if ($message) { if ($sendtocc) { - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('Bcc') . ": " . $sendtocc); } - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); - $actionmsg .= dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); - $actionmsg .= dol_concatdesc($actionmsg, $message); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('MailTopic') . ": " . $subject); + $actionmsg = dol_concatdesc($actionmsg, $langs->transnoentities('TextUsedInTheMessageBody') . ":"); + $actionmsg = dol_concatdesc($actionmsg, $message); } From 38d3b9ca71a8a8d55ebf591539c71c0ee444be7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 11 Nov 2021 16:54:20 +0100 Subject: [PATCH 131/178] fix regex --- htdocs/core/modules/printing/modules_printing.php | 2 +- htdocs/core/modules/printing/printipp.modules.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/core/modules/printing/modules_printing.php b/htdocs/core/modules/printing/modules_printing.php index 1bbf78df022..fa86d832b73 100644 --- a/htdocs/core/modules/printing/modules_printing.php +++ b/htdocs/core/modules/printing/modules_printing.php @@ -69,7 +69,7 @@ class PrintingDriver $listoffiles = array(); $dirmodels = array_merge(array('/core/modules/printing/'), (array) $conf->modules_parts['printing']); foreach ($dirmodels as $dir) { - $tmpfiles = dol_dir_list(dol_buildpath($dir, 0), 'all', 0, '.modules.php', '', 'name', SORT_ASC, 0); + $tmpfiles = dol_dir_list(dol_buildpath($dir, 0), 'all', 0, '\.modules.php', '', 'name', SORT_ASC, 0); if (!empty($tmpfiles)) { $listoffiles = array_merge($listoffiles, $tmpfiles); } diff --git a/htdocs/core/modules/printing/printipp.modules.php b/htdocs/core/modules/printing/printipp.modules.php index f290b2b4e90..584e7751fd7 100644 --- a/htdocs/core/modules/printing/printipp.modules.php +++ b/htdocs/core/modules/printing/printipp.modules.php @@ -108,10 +108,10 @@ class printing_printipp extends PrintingDriver global $conf; $this->db = $db; - $this->host = $conf->global->PRINTIPP_HOST; - $this->port = $conf->global->PRINTIPP_PORT; - $this->user = $conf->global->PRINTIPP_USER; - $this->password = $conf->global->PRINTIPP_PASSWORD; + $this->host = getDolGlobalString('PRINTIPP_HOST'); + $this->port = getDolGlobalString('PRINTIPP_PORT'); + $this->user = getDolGlobalString('PRINTIPP_USER'); + $this->password = getDolGlobalString('PRINTIPP_PASSWORD'); $this->conf[] = array('varname'=>'PRINTIPP_HOST', 'required'=>1, 'example'=>'localhost', 'type'=>'text'); $this->conf[] = array('varname'=>'PRINTIPP_PORT', 'required'=>1, 'example'=>'631', 'type'=>'text'); $this->conf[] = array('varname'=>'PRINTIPP_USER', 'required'=>0, 'example'=>'', 'type'=>'text', 'moreattributes'=>'autocomplete="off"'); From 00213812010a43454ab7a61558f67009cdd638da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 17:08:35 +0100 Subject: [PATCH 132/178] Fix #yogosha7605 --- htdocs/core/db/mysqli.class.php | 16 ++++++++++++---- htdocs/core/db/pgsql.class.php | 12 ++++++++---- htdocs/core/db/sqlite3.class.php | 16 ++++++++++++---- htdocs/install/upgrade.php | 1 + test/phpunit/CodingPhpTest.php | 4 ++-- test/phpunit/CodingSqlTest.php | 2 +- 6 files changed, 36 insertions(+), 15 deletions(-) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 0db4e16a897..b64ec0708e2 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -663,9 +663,13 @@ class DoliDBMysqli extends DoliDB $like = ''; if ($table) { - $like = "LIKE '".$table."'"; + $tmptable = preg_replace('/[^a-z0-9\.\-\_%]/i', '', $table); + + $like = "LIKE '".$this->escape($tmptable)."'"; } - $sql = "SHOW TABLES FROM ".$database." ".$like.";"; + $tmpdatabase = preg_replace('/[^a-z0-9\.\-\_]/i', '', $database); + + $sql = "SHOW TABLES FROM ".$tmpdatabase." ".$like.";"; //print $sql; $result = $this->query($sql); if ($result) { @@ -688,7 +692,9 @@ class DoliDBMysqli extends DoliDB // phpcs:enable $infotables = array(); - $sql = "SHOW FULL COLUMNS FROM ".$table.";"; + $tmptable = preg_replace('/[^a-z0-9\.\-\_]/i', '', $table); + + $sql = "SHOW FULL COLUMNS FROM ".$tmptable.";"; dol_syslog($sql, LOG_DEBUG); $result = $this->query($sql); @@ -794,7 +800,9 @@ class DoliDBMysqli extends DoliDB public function DDLDropTable($table) { // phpcs:enable - $sql = "DROP TABLE ".$table; + $tmptable = preg_replace('/[^a-z0-9\.\-\_]/i', '', $table); + + $sql = "DROP TABLE ".$tmptable; if (!$this->query($sql)) { return -1; diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index 5997349d0c5..ac6b8de33f3 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -937,7 +937,9 @@ class DoliDBPgsql extends DoliDB $escapedlike = ''; if ($table) { - $escapedlike = " AND table_name LIKE '".$this->escape($table)."'"; + $tmptable = preg_replace('/[^a-z0-9\.\-\_%]/i', '', $table); + + $escapedlike = " AND table_name LIKE '".$this->escape($tmptable)."'"; } $result = pg_query($this->db, "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'".$escapedlike." ORDER BY table_name"); if ($result) { @@ -973,8 +975,8 @@ class DoliDBPgsql extends DoliDB $sql .= " '' as \"Extra\","; $sql .= " '' as \"Privileges\""; $sql .= " FROM information_schema.columns infcol"; - $sql .= " WHERE table_schema='public' "; - $sql .= " AND table_name='".$this->escape($table)."'"; + $sql .= " WHERE table_schema = 'public' "; + $sql .= " AND table_name = '".$this->escape($table)."'"; $sql .= " ORDER BY ordinal_position;"; dol_syslog($sql, LOG_DEBUG); @@ -1078,7 +1080,9 @@ class DoliDBPgsql extends DoliDB public function DDLDropTable($table) { // phpcs:enable - $sql = "DROP TABLE ".$table; + $tmptable = preg_replace('/[^a-z0-9\.\-\_]/i', '', $table); + + $sql = "DROP TABLE ".$tmptable; if (!$this->query($sql)) { return -1; diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index c03d2a5ee04..bc01ee7a535 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -875,9 +875,13 @@ class DoliDBSqlite3 extends DoliDB $like = ''; if ($table) { - $like = "LIKE '".$table."'"; + $tmptable = preg_replace('/[^a-z0-9\.\-\_%]/i', '', $table); + + $like = "LIKE '".$this->escape($tmptable)."'"; } - $sql = "SHOW TABLES FROM ".$database." ".$like.";"; + $tmpdatabase = preg_replace('/[^a-z0-9\.\-\_]/i', '', $database); + + $sql = "SHOW TABLES FROM ".$tmpdatabase." ".$like.";"; //print $sql; $result = $this->query($sql); if ($result) { @@ -901,7 +905,9 @@ class DoliDBSqlite3 extends DoliDB // phpcs:enable $infotables = array(); - $sql = "SHOW FULL COLUMNS FROM ".$table.";"; + $tmptable = preg_replace('/[^a-z0-9\.\-\_]/i', '', $table); + + $sql = "SHOW FULL COLUMNS FROM ".$tmptable.";"; dol_syslog($sql, LOG_DEBUG); $result = $this->query($sql); @@ -1002,7 +1008,9 @@ class DoliDBSqlite3 extends DoliDB public function DDLDropTable($table) { // phpcs:enable - $sql = "DROP TABLE ".$table; + $tmptable = preg_replace('/[^a-z0-9\.\-\_]/i', '', $table); + + $sql = "DROP TABLE ".$tmptable; if (!$this->query($sql)) { return -1; diff --git a/htdocs/install/upgrade.php b/htdocs/install/upgrade.php index b36914ad36b..c03678151fc 100644 --- a/htdocs/install/upgrade.php +++ b/htdocs/install/upgrade.php @@ -260,6 +260,7 @@ if (!GETPOST('action', 'aZ09') || preg_match('/upgrade/i', GETPOST('action', 'aZ ); $listtables = $db->DDLListTables($conf->db->name, ''); + foreach ($listtables as $val) { // Database prefix filter if (preg_match('/^'.MAIN_DB_PREFIX.'/', $val)) { diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 2681164c857..383c37e95e5 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -17,7 +17,7 @@ */ /** - * \file test/phpunit/SqlTest.php + * \file test/phpunit/CodingPhpTest.php * \ingroup test * \brief PHPUnit test * \remarks To run this script as CLI: phpunit filename.php @@ -363,7 +363,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase // Check string sql|set|WHERE|...'".$yyy->xxx with xxx that is not 'escape', 'idate', .... It means we forget a db->escape when forging sql request. $ok=true; $matches=array(); - preg_match_all('/(sql|SET|WHERE|INSERT|VALUES).+\s*\'"\s*\.\s*\$(.......)/', $filecontent, $matches, PREG_SET_ORDER); + preg_match_all('/(sql|SET|WHERE|INSERT|VALUES|LIKE).+\s*\'"\s*\.\s*\$(.......)/', $filecontent, $matches, PREG_SET_ORDER); foreach ($matches as $key => $val) { if (! in_array($val[2], array('this->d', 'this->e', 'db->esc', 'dbs->es', 'mydb->e', 'dbsessi', 'db->ida', 'escaped', 'exclude', 'include'))) { $ok=false; // This will generate error diff --git a/test/phpunit/CodingSqlTest.php b/test/phpunit/CodingSqlTest.php index 9217ebbe7f6..f79205a0443 100644 --- a/test/phpunit/CodingSqlTest.php +++ b/test/phpunit/CodingSqlTest.php @@ -17,7 +17,7 @@ */ /** - * \file test/phpunit/SqlTest.php + * \file test/phpunit/CodingSqlTest.php * \ingroup test * \brief PHPUnit test * \remarks To run this script as CLI: phpunit filename.php From e98cfb3ef1b5af51acef2c529d7ae1e48dfa104b Mon Sep 17 00:00:00 2001 From: andreubisquerra Date: Thu, 11 Nov 2021 18:02:56 +0100 Subject: [PATCH 133/178] FIX Save TakePOS credit note as a pos sale --- htdocs/takepos/invoice.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/takepos/invoice.php b/htdocs/takepos/invoice.php index 660b6cbb18f..2a951a505ae 100644 --- a/htdocs/takepos/invoice.php +++ b/htdocs/takepos/invoice.php @@ -330,6 +330,8 @@ if ($action == 'creditnote' && $user->rights->facture->creer) { $creditnote = new Facture($db); $creditnote->socid = $invoice->socid; $creditnote->date = dol_now(); + $creditnote->module_source = 'takepos'; + $creditnote->pos_source = isset($_SESSION["takeposterminal"]) ? $_SESSION["takeposterminal"] : '' ; $creditnote->type = Facture::TYPE_CREDIT_NOTE; $creditnote->fk_facture_source = $placeid; $creditnote->remise_absolue = $invoice->remise_absolue; From aab9c2e6cacb0ca194d028481645c236be4652f3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 18:20:31 +0100 Subject: [PATCH 134/178] Fix #yogosha7605 --- htdocs/core/db/mysqli.class.php | 5 +++-- htdocs/core/db/pgsql.class.php | 5 +++-- htdocs/core/db/sqlite3.class.php | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index b64ec0708e2..4dd71f0e351 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -933,8 +933,9 @@ class DoliDBMysqli extends DoliDB public function DDLDropField($table, $field_name) { // phpcs:enable - $sql = "ALTER TABLE ".$table." DROP COLUMN `".$field_name."`"; - dol_syslog(get_class($this)."::DDLDropField ".$sql, LOG_DEBUG); + $tmp_field_name = preg_replace('/[^a-z0-9\.\-\_]/i', '', $field_name); + + $sql = "ALTER TABLE ".$table." DROP COLUMN `".$tmp_field_name."`"; if ($this->query($sql)) { return 1; } diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php index ac6b8de33f3..7cf0a5d905a 100644 --- a/htdocs/core/db/pgsql.class.php +++ b/htdocs/core/db/pgsql.class.php @@ -1240,8 +1240,9 @@ class DoliDBPgsql extends DoliDB public function DDLDropField($table, $field_name) { // phpcs:enable - $sql = "ALTER TABLE ".$table." DROP COLUMN ".$field_name; - dol_syslog($sql, LOG_DEBUG); + $tmp_field_name = preg_replace('/[^a-z0-9\.\-\_]/i', '', $field_name); + + $sql = "ALTER TABLE ".$table." DROP COLUMN ".$tmp_field_name; if (!$this->query($sql)) { $this->error = $this->lasterror(); return -1; diff --git a/htdocs/core/db/sqlite3.class.php b/htdocs/core/db/sqlite3.class.php index bc01ee7a535..d1d6a4b680a 100644 --- a/htdocs/core/db/sqlite3.class.php +++ b/htdocs/core/db/sqlite3.class.php @@ -1120,8 +1120,9 @@ class DoliDBSqlite3 extends DoliDB public function DDLDropField($table, $field_name) { // phpcs:enable - $sql = "ALTER TABLE ".$table." DROP COLUMN `".$field_name."`"; - dol_syslog(get_class($this)."::DDLDropField ".$sql, LOG_DEBUG); + $tmp_field_name = preg_replace('/[^a-z0-9\.\-\_]/i', '', $field_name); + + $sql = "ALTER TABLE ".$table." DROP COLUMN `".$tmp_field_name."`"; if (!$this->query($sql)) { $this->error = $this->lasterror(); return -1; From fd1585eda07ad2e2459fbbb486a91a1e150dc7b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Thu, 11 Nov 2021 18:23:34 +0100 Subject: [PATCH 135/178] add load langs --- htdocs/core/lib/functions2.lib.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 26c56d45463..fe6e8e0fa40 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -2131,30 +2131,38 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '') // Special cases, to work with non standard path if ($objecttype == 'facture' || $objecttype == 'invoice') { + $langs->load('bills'); $classpath = 'compta/facture/class'; $module = 'facture'; $myobject = 'facture'; } elseif ($objecttype == 'commande' || $objecttype == 'order') { + $langs->load('orders'); $classpath = 'commande/class'; $module = 'commande'; $myobject = 'commande'; } elseif ($objecttype == 'propal') { + $langs->load('propal'); $classpath = 'comm/propal/class'; } elseif ($objecttype == 'supplier_proposal') { + $langs->load('supplier_proposal'); $classpath = 'supplier_proposal/class'; } elseif ($objecttype == 'shipping') { + $langs->load('sendings'); $classpath = 'expedition/class'; $myobject = 'expedition'; $module = 'expedition_bon'; } elseif ($objecttype == 'delivery') { + $langs->load('deliveries'); $classpath = 'delivery/class'; $myobject = 'delivery'; $module = 'delivery_note'; } elseif ($objecttype == 'contract') { + $langs->load('contracts'); $classpath = 'contrat/class'; $module = 'contrat'; $myobject = 'contrat'; } elseif ($objecttype == 'member') { + $langs->load('members'); $classpath = 'adherents/class'; $module = 'adherent'; $myobject = 'adherent'; @@ -2163,13 +2171,16 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '') $module = 'cabinetmed'; $myobject = 'cabinetmedcons'; } elseif ($objecttype == 'fichinter') { + $langs->load('interventions'); $classpath = 'fichinter/class'; $module = 'ficheinter'; $myobject = 'fichinter'; } elseif ($objecttype == 'project') { + $langs->load('projects'); $classpath = 'projet/class'; $module = 'projet'; } elseif ($objecttype == 'task') { + $langs->load('projects'); $classpath = 'projet/class'; $module = 'projet'; $myobject = 'task'; From a725ffefdd80286502770c9eddfda64d69f30aa4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 18:30:17 +0100 Subject: [PATCH 136/178] Fix sql error --- htdocs/takepos/index.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 4d729bde2fa..1ec50dd3799 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -1037,13 +1037,10 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { } $sql = "SELECT rowid, status, entity FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE"; -$sql .= " entity = ".$conf->entity." AND "; -<<<<<<< HEAD +$sql .= " entity = ".((int) $conf->entity)." AND "; +$sql .= " posnumber = ".((int) $_SESSION["takeposterminal"])." AND "; $sql .= " date_creation > '".$db->idate(dol_get_first_hour(dol_now()))."'"; -======= -$sql .= " posnumber = ".$_SESSION["takeposterminal"]." AND "; -$sql .= " date(date_creation) = CURDATE()"; ->>>>>>> branch '12.0' of git@github.com:Dolibarr/dolibarr.git + $resql = $db->query($sql); if ($resql) { From 21c2dba9222913883e3aa46d6ea0af9ef007a64b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 11 Nov 2021 19:06:55 +0100 Subject: [PATCH 137/178] Fix phpcs --- htdocs/compta/facture/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index d9be7ff3f1c..e01d71a1020 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -5118,7 +5118,6 @@ if ($action == 'create') { print ' :'.price($retainedWarranty).' '; } } else { // Credit note - $resteapayeraffiche = $resteapayer; $cssforamountpaymentcomplete = 'amountpaymentneutral'; From 3b21fc2d37e71f057a0f971a5ac233e5a00a7127 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 12 Nov 2021 10:50:19 +0100 Subject: [PATCH 138/178] Better way to report value of stock when PRODUIT_MULTIPRICES is on --- htdocs/langs/en_US/stocks.lang | 2 +- htdocs/product/stock/product.php | 69 +++++++++++++++++++++++++------- 2 files changed, 55 insertions(+), 16 deletions(-) diff --git a/htdocs/langs/en_US/stocks.lang b/htdocs/langs/en_US/stocks.lang index 8c0cc76f075..19875f55148 100644 --- a/htdocs/langs/en_US/stocks.lang +++ b/htdocs/langs/en_US/stocks.lang @@ -96,7 +96,7 @@ RealStock=Real Stock RealStockDesc=Physical/real stock is the stock currently in the warehouses. RealStockWillAutomaticallyWhen=The real stock will be modified according to this rule (as defined in the Stock module): VirtualStock=Virtual stock -VirtualStockAtDate=Virtual stock at date +VirtualStockAtDate=Virtual stock at a future date VirtualStockAtDateDesc=Virtual stock once all the pending orders that are planned to be processed before the chosen date will be finished VirtualStockDesc=Virtual stock is the calculated stock available once all open/pending actions (that affect stocks) are closed (purchase orders received, sales orders shipped, manufacturing orders produced, etc) AtDate=At date diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 23900c85c0b..247d11d00c6 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -763,7 +763,7 @@ if ($id > 0 || $ref) { if ($result < 0) { dol_print_error($db, $object->error); } - $helpondiff .= ' ('.$langs->trans("ProductQtyInDraft").': '.$object->stats_commande['qty'].')'; + $helpondiff .= ' ('.$langs->trans("ProductQtyInDraft").': '.$object->stats_commande['qty'].')'; } // Number of product from customer order already sent (partial shipping) @@ -797,7 +797,7 @@ if ($id > 0 || $ref) { if ($result < 0) { dol_print_error($db, $object->error); } - $helpondiff .= ' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$object->stats_commande_fournisseur['qty'].')'; + $helpondiff .= ' ('.$langs->trans("ProductQtyInDraftOrWaitingApproved").': '.$object->stats_commande_fournisseur['qty'].')'; } // Number of product from supplier order already received (partial receipt) @@ -983,6 +983,7 @@ if (!$variants) { $entrepotstatic = new Entrepot($db); $product_lot_static = new Productlot($db); + $num = 0; $total = 0; $totalvalue = $totalvaluesell = 0; @@ -1025,18 +1026,45 @@ if (!$variants) { print ''.(price2num($object->pmp) ? price(price2num($object->pmp * $obj->reel, 'MT')) : '').''; // Sell price + $minsellprice = null; $maxsellprice = null; print ''; - print price(price2num($object->price, 'MU'), 1); if (!empty($conf->global->PRODUIT_MULTIPRICES)) { + foreach ($object->multiprices as $priceforlevel) { + if (is_numeric($priceforlevel)) { + if (is_null($maxsellprice) || $priceforlevel > $maxsellprice) { + $maxsellprice = $priceforlevel; + } + if (is_null($minsellprice) || $priceforlevel < $minsellprice) { + $minsellprice = $priceforlevel; + } + } + } + print ''; + if ($minsellprice != $maxsellprice) { + print price(price2num($minsellprice, 'MU'), 1).' - '.price(price2num($maxsellprice, 'MU'), 1); + } else { + print price(price2num($minsellprice, 'MU'), 1); + } + print ''; print $form->textwithpicto('', $langs->trans("Variable")); + } else { + print price(price2num($object->price, 'MU'), 1); } print ''; // Value sell print ''; - print price(price2num($object->price * $obj->reel, 'MT'), 1); if (!empty($conf->global->PRODUIT_MULTIPRICES)) { + print ''; + if ($minsellprice != $maxsellprice) { + print price(price2num($minsellprice * $obj->reel, 'MT'), 1).' - '.price(price2num($maxsellprice * $obj->reel, 'MT'), 1); + } else { + print price(price2num($minsellprice * $obj->reel, 'MT'), 1); + } + print ''; print $form->textwithpicto('', $langs->trans("Variable")); + } else { + print price(price2num($object->price * $obj->reel, 'MT'), 1); } print ''; print ''; @@ -1148,17 +1176,28 @@ if (!$variants) { print $totalvalue ? price(price2num($totalvalue, 'MT'), 1) : ' '; print ''; print ''; - print ($total ? price($totalvaluesell / $total, 1) : ' '); - if (!empty($conf->global->PRODUIT_MULTIPRICES)) { - print $form->textwithpicto('', $langs->trans("Variable")); + if ($num) { + if ($total) { + print ''; + if (!empty($conf->global->PRODUIT_MULTIPRICES)) { + print $form->textwithpicto('', $langs->trans("Variable")); + } else { + print price($totalvaluesell / $total, 1); + } + print ''; + } } print ''; // Value to sell - print ''; - if (empty($conf->global->PRODUIT_MULTIPRICES)) { - print price(price2num($totalvaluesell, 'MT'), 1); - } else { - print $langs->trans("Variable"); + print ''; + if ($num) { + print ''; + if (empty($conf->global->PRODUIT_MULTIPRICES)) { + print price(price2num($totalvaluesell, 'MT'), 1); + } else { + print $form->textwithpicto('', $langs->trans("Variable")); + } + print ''; } print ''; print ''; @@ -1180,13 +1219,13 @@ if (!$variants) { } print ''; if (!empty($user->rights->produit->creer)) { - print ''; + print ''; print ''; print ''; print ''; print ''; } else { - print ''; + print ''; print ''; print ''; print ''; @@ -1200,7 +1239,7 @@ if (!$variants) { foreach ($lines as $line) { $ent = new Entrepot($db); $ent->fetch($line['fk_entrepot']); - print ''; + print ''; print ''; print ''; if (!empty($user->rights->produit->creer)) { From 5c8d91ba6c817bd8215f935f672a38559251b20d Mon Sep 17 00:00:00 2001 From: Yaacov Akiba Slama Date: Fri, 12 Nov 2021 12:46:18 +0200 Subject: [PATCH 139/178] BankAccountNumber is not required. The IBAN can contain all the needed information. So there is no reason for the account number to be required --- htdocs/core/modules/modSociete.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index ca5b484499a..60e593cf3f1 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -757,7 +757,7 @@ class modSociete extends DolibarrModules 'sr.bank' => "Bank", 'sr.code_banque' => "BankCode", 'sr.code_guichet' => "DeskCode", - 'sr.number' => "BankAccountNumber*", + 'sr.number' => "BankAccountNumber", 'sr.cle_rib' => "BankAccountNumberKey", 'sr.bic' => "BIC", 'sr.iban_prefix' => "IBAN", From de435576a988144ed9059d0d05147deea09f7d1f Mon Sep 17 00:00:00 2001 From: Yaacov Akiba Slama Date: Fri, 12 Nov 2021 12:46:37 +0200 Subject: [PATCH 140/178] Allow WithdrawMode to be imported --- htdocs/core/modules/modSociete.class.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/modules/modSociete.class.php b/htdocs/core/modules/modSociete.class.php index 60e593cf3f1..2826091155c 100644 --- a/htdocs/core/modules/modSociete.class.php +++ b/htdocs/core/modules/modSociete.class.php @@ -766,6 +766,7 @@ class modSociete extends DolibarrModules 'sr.owner_address' => "BankAccountOwnerAddress", 'sr.default_rib' => 'Default', 'sr.rum' => 'RUM', + 'sr.frstrecur' => "WithdrawMode", 'sr.type' => "Type ban is defaut", ); @@ -797,6 +798,7 @@ class modSociete extends DolibarrModules 'sr.owner_address' => 'address of account holder', 'sr.default_rib' => '1 (default account) / 0 (not default)', 'sr.rum' => 'RUM code', + 'sr.frstrecur' => 'FRST', 'sr.type' => 'ban', ); From 968ffbcef0b379929c8417c9a7c14143a60a7b22 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 12 Nov 2021 13:06:41 +0100 Subject: [PATCH 141/178] FIX add ldap hash algo --- htdocs/core/class/html.formldap.class.php | 17 +++++--- htdocs/core/lib/security.lib.php | 53 +++++++++++++---------- 2 files changed, 40 insertions(+), 30 deletions(-) diff --git a/htdocs/core/class/html.formldap.class.php b/htdocs/core/class/html.formldap.class.php index acee0bbbea7..1f9d6591560 100644 --- a/htdocs/core/class/html.formldap.class.php +++ b/htdocs/core/class/html.formldap.class.php @@ -81,16 +81,21 @@ class FormLdap } $arraylist = array( - "pbkdf2sha256" => "PBKDF2_SHA256", - "ssha512" => "SSHA512", - "ssha256" => "SSHA256", + //"pbkdf2sha256" => "PBKDF2_SHA256", + "ssha512" => "SSHA-512", + "ssha384" => "SSHA-384", + "ssha256" => "SSHA-256", "ssha" => "SSHA", + "sha512" => "SHA-512", + "sha384" => "SHA-384", + "sha256" => "SHA-256", "sha" => "SHA", "md5" => "MD5", "smd5" => "SMD5", - "cryptmd5" => "CRYPT-MD5", - "cryptsha512" => "CRYPT-SHA512", - "cryptsha256" => "CRYPT-SHA256", + //"cryptmd5" => "CRYPT-MD5", + //"cryptsha512" => "CRYPT-SHA512", + //"cryptsha384" => "CRYPT-SHA384", + //"cryptsha256" => "CRYPT-SHA256", "crypt" => "CRYPT", "clear" => "CLEAR" ); diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index 1eb737880c6..ec3d73f2f72 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -97,7 +97,7 @@ function dol_decode($chain, $key = '1') * If constant MAIN_SECURITY_SALT is defined, we use it as a salt (used only if hashing algorightm is something else than 'password_hash'). * * @param string $chain String to hash - * @param string $type Type of hash ('0':auto will use MAIN_SECURITY_HASH_ALGO else md5, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap with no salt, '5':sha256, '6':password_hash). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. + * @param string $type Type of hash ('0':auto will use MAIN_SECURITY_HASH_ALGO else md5, '1':sha1, '2':sha1+md5, '3':md5, '4': for OpenLdap, '5':sha256, '6':password_hash). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. * @return string Hash of string * @see getRandomPassword() */ @@ -122,7 +122,7 @@ function dol_hash($chain, $type = '0') } elseif ($type == '3' || $type == 'md5') { return md5($chain); } elseif ($type == '4' || $type == 'openldap') { - return dolGetLdapHash($chain, getDolGlobalString('LDAP_PASSWORD_HASH_TYPE', 'md5'), getDolGlobalString('MAIN_SECURITY_SALT')); + return dolGetLdapPasswordHash($chain, getDolGlobalString('LDAP_PASSWORD_HASH_TYPE', 'md5'), getDolGlobalString('MAIN_SECURITY_SALT')); } elseif ($type == '5' || $type == 'sha256') { return hash('sha256', $chain); } elseif ($type == '6' || $type == 'password_hash') { @@ -145,7 +145,7 @@ function dol_hash($chain, $type = '0') * * @param string $chain String to hash (not hashed string) * @param string $hash hash to compare - * @param string $type Type of hash ('0':auto, '1':sha1, '2':sha1+md5, '3':md5, '4':md5 for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. + * @param string $type Type of hash ('0':auto, '1':sha1, '2':sha1+md5, '3':md5, '4': for OpenLdap, '5':sha256). Use '3' here, if hash is not needed for security purpose, for security need, prefer '0'. * @return bool True if the computed hash is the same as the given one */ function dol_verifyHash($chain, $hash, $type = '0') @@ -168,41 +168,46 @@ function dol_verifyHash($chain, $hash, $type = '0') } /** - * Returns a specific ldap hash of a string. + * Returns a specific ldap hash of a password. * - * @param string $chain String to hash + * @param string $password Password to hash * @param string $type Type of hash - * @return string Hash of string + * @return string Hash of password */ -function dolGetLdapHash($chain, $type = 'md5') +function dolGetLdapPasswordHash($password, $type = 'md5') { if (empty($type)) { $type = 'md5'; } + $salt = substr(sha1(time()), 0, 8); + if ($type === 'md5') { - return '{MD5}' . base64_encode(pack("H*", md5($chain))); // For OpenLdap with md5 (based on an unencrypted password in base) + return '{MD5}' . base64_encode(hash("md5", $password, true)); //For OpenLdap with md5 (based on an unencrypted password in base) } elseif ($type === 'md5frommd5') { - return '{MD5}' . base64_encode(hex2bin($chain)); // Create OpenLDAP MD5 password from Dolibarr MD5 password + return '{MD5}' . base64_encode(hex2bin($password)); // Create OpenLDAP MD5 password from Dolibarr MD5 password } elseif ($type === 'smd5') { - mt_srand((double)microtime()*1000000); - $salt = pack("CCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand()); - return "{SMD5}" . base64_encode(pack("H*", md5($chain . $salt)) . $salt); + return "{SMD5}" . base64_encode(hash("md5", $password . $salt, true) . $salt); } elseif ($type === 'sha') { - return '{SHA}' . base64_encode(sha1($chain), true); + return '{SHA}' . base64_encode(hash("sha1", $password, true)); } elseif ($type === 'ssha') { - mt_srand((double)microtime()*1000000); - $salt = pack("CCCC", mt_rand(), mt_rand(), mt_rand(), mt_rand()); - return "{SSHA}" . base64_encode(pack("H*", sha1($chain . $salt)) . $salt); + return "{SSHA}" . base64_encode(hash("sha1", $password . $salt, true) . $salt); + } elseif ($type === 'sha256') { + return "{SHA256}" . base64_encode(hash("sha256", $password, true)); + } elseif ($type === 'ssha256') { + return "{SSHA256}" . base64_encode(hash("sha256", $password . $salt, true) . $salt); + } elseif ($type === 'sha384') { + return "{SHA384}" . base64_encode(hash("sha384", $password, true)); + } elseif ($type === 'ssha384') { + return "{SSHA384}" . base64_encode(hash("sha384", $password . $salt, true) . $salt); + } elseif ($type === 'sha512') { + return "{SHA512}" . base64_encode(hash("sha512", $password, true)); + } elseif ($type === 'ssha512') { + return "{SSHA512}" . base64_encode(hash("sha512", $password . $salt, true) . $salt); } elseif ($type === 'crypt') { - // Generate salt - $salt = ""; - $pattern = '0123456789'.'abcdefghijklmnopqrstuvwxyz'.'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.'./'; - mt_srand((double)microtime() * 1000000); - while (strlen($salt) < 2) { - $salt .= substr($pattern, (rand() % strlen($pattern)), 1); - } - return '{CRYPT}' . crypt($chain, $salt); + return '{CRYPT}' . crypt($password, $salt); + } elseif ($type === 'clear') { + return '{CLEAR}' . $password; // Just for test, plain text password is not secured ! } } From 1169ae551fc2acc5d5c38ebf633e001fe3fc1ba1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 12 Nov 2021 13:12:49 +0100 Subject: [PATCH 142/178] FIX remove debug --- htdocs/core/class/ldap.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index e4b22cc529c..120c2993801 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -238,9 +238,9 @@ class Ldap // Upgrade connexion to TLS, if requested by the configuration if (!empty($conf->global->LDAP_SERVER_USE_TLS)) { // For test/debug - ldap_set_option($this->connection, LDAP_OPT_DEBUG_LEVEL, 7); - ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, 3); - ldap_set_option($this->connection, LDAP_OPT_REFERRALS, 0); + //ldap_set_option($this->connection, LDAP_OPT_DEBUG_LEVEL, 7); + //ldap_set_option($this->connection, LDAP_OPT_PROTOCOL_VERSION, 3); + //ldap_set_option($this->connection, LDAP_OPT_REFERRALS, 0); $resulttls = ldap_start_tls($this->connection); if (!$resulttls) { From 7324375caad3b0335234db2d17c5f3d4c091924b Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 12 Nov 2021 13:15:40 +0100 Subject: [PATCH 143/178] FIX missing rename function --- htdocs/adherents/class/adherent.class.php | 2 +- htdocs/user/class/user.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/adherents/class/adherent.class.php b/htdocs/adherents/class/adherent.class.php index fb77b062780..0b5fddd5da4 100644 --- a/htdocs/adherents/class/adherent.class.php +++ b/htdocs/adherents/class/adherent.class.php @@ -2714,7 +2714,7 @@ class Adherent extends CommonObject if ($this->pass_indatabase_crypted && !empty($conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED)) { // Create OpenLDAP MD5 password from Dolibarr MD5 password // Note: This suppose that "pass_indatabase_crypted" is a md5 (guaranted by the previous test if "(empty($conf->global->MAIN_SECURITY_HASH_ALGO))" - $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dolGetLdapHash($this->pass_indatabase_crypted, 'md5frommd5'); + $info[$conf->global->LDAP_MEMBER_FIELD_PASSWORD_CRYPTED] = dolGetLdapPasswordHash($this->pass_indatabase_crypted, 'md5frommd5'); } } } elseif (!empty($this->pass_indatabase)) { diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index ae663bc9fdd..daa23328b63 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -2948,7 +2948,7 @@ class User extends CommonObject // Just for the default MD5 ! if (empty($conf->global->MAIN_SECURITY_HASH_ALGO)) { if ($this->pass_indatabase_crypted && !empty($conf->global->LDAP_FIELD_PASSWORD_CRYPTED)) { - $info[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED] = dolGetLdapHash($this->pass_indatabase_crypted, 'md5frommd5'); // Create OpenLDAP MD5 password from Dolibarr MD5 password + $info[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED] = dolGetLdapPasswordHash($this->pass_indatabase_crypted, 'md5frommd5'); // Create OpenLDAP MD5 password from Dolibarr MD5 password } } } elseif (!empty($this->pass_indatabase)) { From 991c1b4f139da7873ee85d5d0b72a9e8e862c6ff Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 12 Nov 2021 13:20:58 +0100 Subject: [PATCH 144/178] ADD Klarna provider with Stripe --- htdocs/stripe/class/stripe.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 9324d7d3a5d..d60b084ff39 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -409,6 +409,9 @@ class Stripe extends CommonObject if (!empty($conf->global->STRIPE_SEPA_DIRECT_DEBIT)) { $paymentmethodtypes[] = "sepa_debit"; //&& ($object->thirdparty->isInEEC()) } + if (!empty($conf->global->STRIPE_KLARNA)) { + $paymentmethodtypes[] = "klarna"; + } if (!empty($conf->global->STRIPE_BANCONTACT)) { $paymentmethodtypes[] = "bancontact"; } @@ -450,7 +453,9 @@ class Stripe extends CommonObject if (!empty($conf->global->STRIPE_GIROPAY)) { unset($dataforintent['setup_future_usage']); } - + if (!empty($conf->global->STRIPE_KLARNA)) { + unset($dataforintent['setup_future_usage']); + } if (!is_null($payment_method)) { $dataforintent["payment_method"] = $payment_method; $description .= ' - '.$payment_method; @@ -602,6 +607,9 @@ class Stripe extends CommonObject if (!empty($conf->global->STRIPE_BANCONTACT)) { $paymentmethodtypes[] = "bancontact"; } + if (!empty($conf->global->STRIPE_KLARNA)) { + $paymentmethodtypes[] = "klarna"; + } if (!empty($conf->global->STRIPE_IDEAL)) { $paymentmethodtypes[] = "ideal"; } From 97d2722c4ce36f2b7a962bccb28687d8b9f2ef57 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Fri, 12 Nov 2021 13:21:40 +0100 Subject: [PATCH 145/178] Update stripe.php --- htdocs/stripe/admin/stripe.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htdocs/stripe/admin/stripe.php b/htdocs/stripe/admin/stripe.php index 06f417e48df..77c8d9a03b2 100644 --- a/htdocs/stripe/admin/stripe.php +++ b/htdocs/stripe/admin/stripe.php @@ -390,6 +390,20 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code print ''; } +// Activate Klarna +if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code + print ''; +} + // Activate Bancontact if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { // TODO Not used by current code print '
    '.$formproduct->selectWarehouses('', 'fk_entrepot').'
    '.$formproduct->selectWarehouses('', 'fk_entrepot').'
    '.$langs->trans("Warehouse").'
    '.$langs->trans("Warehouse").''.$langs->trans("StockLimit").''.$langs->trans("DesiredStock").'
    '.$ent->getNomUrl(3).'
    '.$ent->getNomUrl(3).''.$line['seuil_stock_alerte'].''.$line['desiredstock'].'
    '; + print $langs->trans("STRIPE_KLARNA").''; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('STRIPE_KLARNA'); + } else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + print $form->selectarray("STRIPE_KLARNA", $arrval, $conf->global->STRIPE_KLARNA); + } + print '   '.$langs->trans("ExampleOnlyForKlarnaCustomers").''; + print '
    '; From 9e5a20545d0ec684de52963ff770d9213d76a8c3 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 12 Nov 2021 13:23:11 +0100 Subject: [PATCH 146/178] FIX dolGetLdapPasswordHash use your own random salt --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index ec3d73f2f72..58d69842f66 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -122,7 +122,7 @@ function dol_hash($chain, $type = '0') } elseif ($type == '3' || $type == 'md5') { return md5($chain); } elseif ($type == '4' || $type == 'openldap') { - return dolGetLdapPasswordHash($chain, getDolGlobalString('LDAP_PASSWORD_HASH_TYPE', 'md5'), getDolGlobalString('MAIN_SECURITY_SALT')); + return dolGetLdapPasswordHash($chain, getDolGlobalString('LDAP_PASSWORD_HASH_TYPE', 'md5')); } elseif ($type == '5' || $type == 'sha256') { return hash('sha256', $chain); } elseif ($type == '6' || $type == 'password_hash') { From daadcf2fc36662aeb8985771fbbe26c90aedaa2d Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 12 Nov 2021 12:23:40 +0000 Subject: [PATCH 147/178] Fixing style errors. --- htdocs/stripe/class/stripe.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index d60b084ff39..a520e83f0ee 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -411,7 +411,7 @@ class Stripe extends CommonObject } if (!empty($conf->global->STRIPE_KLARNA)) { $paymentmethodtypes[] = "klarna"; - } + } if (!empty($conf->global->STRIPE_BANCONTACT)) { $paymentmethodtypes[] = "bancontact"; } @@ -609,7 +609,7 @@ class Stripe extends CommonObject } if (!empty($conf->global->STRIPE_KLARNA)) { $paymentmethodtypes[] = "klarna"; - } + } if (!empty($conf->global->STRIPE_IDEAL)) { $paymentmethodtypes[] = "ideal"; } From 715a65eab25ef3fdb932c0c31763dc1be5bd62d1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 12 Nov 2021 13:33:59 +0100 Subject: [PATCH 148/178] Clean code for md theme --- htdocs/admin/modulehelp.php | 3 +++ htdocs/core/class/html.form.class.php | 3 ++- htdocs/main.inc.php | 2 +- htdocs/theme/md/style.css.php | 5 +++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/htdocs/admin/modulehelp.php b/htdocs/admin/modulehelp.php index f0211d1b795..da76f01fd6c 100644 --- a/htdocs/admin/modulehelp.php +++ b/htdocs/admin/modulehelp.php @@ -70,6 +70,9 @@ print ''."\n".''; $arrayofnatures = array('core'=>$langs->transnoentitiesnoconv("Core"), 'external'=>$langs->transnoentitiesnoconv("External").' - '.$langs->trans("AllPublishers")); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index fb0bba95ac4..92dba4d4de0 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -4905,8 +4905,9 @@ class Form $formconfirm .= ($question ? '
    '.img_help('', '').' '.$question.'
    ' : ''); $formconfirm .= ''."\n"; - $formconfirm .= "\n\n"; + $formconfirm .= "\n\n"; $formconfirm .= '