From f6e53b40dac2138cb700ffa1279df640527d56e0 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 2 Jun 2022 15:20:00 +0200 Subject: [PATCH 01/21] fix: actioncomm.code have to be updated with correct c_actioncomm code (like in create) until we decide to remove this column --- htdocs/comm/action/class/actioncomm.class.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 1e640f7afbe..6369fe82cb7 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1128,6 +1128,12 @@ class ActionComm extends CommonObject $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; if ($this->type_id > 0) { $sql .= ", fk_action = '".$this->db->escape($this->type_id)."'"; + $cactioncomm = new CActionComm($this->db); + $result = $cactioncomm->fetch($this->type_id); + if ($result>=0) { + $sql .= ", code = '" . $this->db->escape($cactioncomm->code) . "'"; + } + } $sql .= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "null"); $sql .= ", datep = ".(strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : 'null'); From d73982d1eb6f551856f2a15b4be9629388b085bf Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 2 Jun 2022 13:26:06 +0000 Subject: [PATCH 02/21] Fixing style errors. --- htdocs/comm/action/class/actioncomm.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 6369fe82cb7..2c130117154 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1133,7 +1133,6 @@ class ActionComm extends CommonObject if ($result>=0) { $sql .= ", code = '" . $this->db->escape($cactioncomm->code) . "'"; } - } $sql .= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "null"); $sql .= ", datep = ".(strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : 'null'); From 43207429aefda6537385e2ff157cc17642ae945f Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 2 Jun 2022 15:32:16 +0200 Subject: [PATCH 03/21] fix: actioncomm.code have to be updated with correct c_actioncomm code (like in create) until we decide to remove this column --- htdocs/comm/action/class/actioncomm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 6369fe82cb7..f21face045f 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1127,7 +1127,7 @@ class ActionComm extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; if ($this->type_id > 0) { - $sql .= ", fk_action = '".$this->db->escape($this->type_id)."'"; + $sql .= ", fk_action = ".(int)$this->type_id; $cactioncomm = new CActionComm($this->db); $result = $cactioncomm->fetch($this->type_id); if ($result>=0) { From 19dc0f124ce65b1c1f5a320b6471bccbec9b65e9 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 2 Jun 2022 13:37:55 +0000 Subject: [PATCH 04/21] Fixing style errors. --- htdocs/comm/action/class/actioncomm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index c92adc0a413..efb6d618e6f 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1127,7 +1127,7 @@ class ActionComm extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; if ($this->type_id > 0) { - $sql .= ", fk_action = ".(int)$this->type_id; + $sql .= ", fk_action = ".(int) $this->type_id; $cactioncomm = new CActionComm($this->db); $result = $cactioncomm->fetch($this->type_id); if ($result>=0) { From d0101fdc90434bf9f0a8f7f21fe44bdfaa7f9fc9 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Thu, 2 Jun 2022 18:57:52 +0200 Subject: [PATCH 05/21] errors is an array --- htdocs/emailcollector/class/emailcollector.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index e2493a338fd..0a8b17d56d4 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -1911,7 +1911,7 @@ class EmailCollector extends CommonObject $sql = "SELECT rowid as id FROM " . MAIN_DB_PREFIX . "user WHERE email LIKE '%" . $from . "%'"; $resql = $this->db->query($sql); if ($resql->num_rows == 0) { - $this->errors = 'User Not allowed to add documents'; + $this->errors[] = 'User Not allowed to add documents'; } $arrayobject = array( 'propale' => array('table' => 'propal', @@ -2043,7 +2043,7 @@ class EmailCollector extends CommonObject $path = ($objectmanaged->entity > 1 ? "/" . $objectmanaged->entity : ''); $dirs[] = DOL_DATA_ROOT . $path . "/" . $elementpath . '/' . dol_sanitizeFileName($objectmanaged->ref) . '/'; } else { - $this->errors = 'object not found'; + $this->errors[] = 'object not found'; } } } @@ -2053,12 +2053,12 @@ class EmailCollector extends CommonObject $resr = saveAttachment($target, $prefix . '_' . $filename, $content); if ($resr == -1) { - $this->errors = 'Doc not saved'; + $this->errors[] = 'Doc not saved'; } } } } else { - $this->errors = 'no joined piece'; + $this->errors[] = 'no joined piece'; } } elseif ($operation['type'] == 'project') { // Create project / lead From 6f6d7d7f48c0b196698b9b01eb4ceff7c4c641f6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 2 Jun 2022 20:15:49 +0200 Subject: [PATCH 06/21] Fix ODT tags in BOM template Conflicts: htdocs/core/class/commonobjectline.class.php --- htdocs/core/class/commondocgenerator.class.php | 1 + .../modules/bom/doc/doc_generic_bom_odt.modules.php | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 5d0242657ef..3d94469759b 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -586,6 +586,7 @@ abstract class CommonDocGenerator 'line_product_label'=>(empty($line->product_label) ? '' : $line->product_label), 'line_product_type'=>(empty($line->product_type) ? '' : $line->product_type), 'line_product_barcode'=>(empty($line->product_barcode) ? '' : $line->product_barcode), + 'line_product_desc'=>(empty($line->product_desc) ? '' : $line->product_desc), 'line_desc'=>$line->desc, 'line_vatrate'=>vatrate($line->tva_tx, true, $line->info_bits), diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index 946d9f32649..31c20cf1ecd 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -89,7 +89,7 @@ class doc_generic_bom_odt extends ModelePDFBom $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 0; // Support add of a watermark on drafts - // Recupere emetteur + // Get source company $this->emetteur = $mysoc; if (!$this->emetteur->country_code) { $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined @@ -113,7 +113,7 @@ class doc_generic_bom_odt extends ModelePDFBom $form = new Form($this->db); $texte = $this->description.".
\n"; - $texte .= '
'; + $texte .= ''; $texte .= ''; $texte .= ''; $texte .= ''; @@ -173,6 +173,11 @@ class doc_generic_bom_odt extends ModelePDFBom } $texte .= ''; } + // Add input to upload a new template file. + $texte .= '
'.$langs->trans("UploadNewTemplate").' '; + $texte .= ''; + $texte .= ''; + $texte .= '
'; $texte .= ''; @@ -225,6 +230,7 @@ class doc_generic_bom_odt extends ModelePDFBom $sav_charset_output = $outputlangs->charset_output; $outputlangs->charset_output = 'UTF-8'; + // Load translation files required by the page $outputlangs->loadLangs(array("main", "dict", "companies", "bills")); if ($conf->bom->dir_output) { From 7f38d556485883f142f442292f1675b83b743531 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 2 Jun 2022 21:28:17 +0200 Subject: [PATCH 07/21] better fix --- htdocs/comm/action/class/actioncomm.class.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index c92adc0a413..b9cd825ad49 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1128,12 +1128,15 @@ class ActionComm extends CommonObject $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; if ($this->type_id > 0) { $sql .= ", fk_action = ".(int)$this->type_id; - $cactioncomm = new CActionComm($this->db); - $result = $cactioncomm->fetch($this->type_id); - if ($result>=0) { - $sql .= ", code = '" . $this->db->escape($cactioncomm->code) . "'"; + if (empty($this->type_code)) { + $cactioncomm = new CActionComm($this->db); + $result = $cactioncomm->fetch($this->type_id); + if ($result>=0) { + $this->type_code = $cactioncomm->code; + } } } + $sql .= ", code = " . (isset($this->type_code)? "'".$this->db->escape($this->type_code) . "'":"null"); $sql .= ", label = ".($this->label ? "'".$this->db->escape($this->label)."'" : "null"); $sql .= ", datep = ".(strval($this->datep) != '' ? "'".$this->db->idate($this->datep)."'" : 'null'); $sql .= ", datep2 = ".(strval($this->datef) != '' ? "'".$this->db->idate($this->datef)."'" : 'null'); From e48ce5b159c7d14dce501821de393505dee2ce41 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Thu, 2 Jun 2022 19:34:39 +0000 Subject: [PATCH 08/21] Fixing style errors. --- htdocs/comm/action/class/actioncomm.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index fe5769473c7..a5c8a11ade0 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -1127,7 +1127,7 @@ class ActionComm extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."actioncomm "; $sql .= " SET percent = '".$this->db->escape($this->percentage)."'"; if ($this->type_id > 0) { - $sql .= ", fk_action = ".(int)$this->type_id; + $sql .= ", fk_action = ".(int) $this->type_id; if (empty($this->type_code)) { $cactioncomm = new CActionComm($this->db); $result = $cactioncomm->fetch($this->type_id); From d15dee282e1880d6a3efd4c8fb6a856d17db0ad7 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Thu, 2 Jun 2022 21:08:25 +0200 Subject: [PATCH 09/21] fix hookmanager is null --- htdocs/emailcollector/class/emailcollector.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index e2493a338fd..9762e3faa39 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -2008,6 +2008,7 @@ class EmailCollector extends CommonObject 'object' => 'Mo'), ); + global $hookmanager; $hookmanager->initHooks(array('emailcolector')); $parameters = array('arrayobject' => $arrayobject); $reshook = $hookmanager->executeHooks('addmoduletoeamailcollectorjoinpiece', $parameters); // Note that $action and $object may have been modified by some hooks From d950533bdb3e369698a0bef308a8fd968ae5bcd9 Mon Sep 17 00:00:00 2001 From: Eric Seigne Date: Thu, 2 Jun 2022 23:55:58 +0200 Subject: [PATCH 10/21] fix #21118: undefined function getAttachments --- htdocs/emailcollector/class/emailcollector.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index e2493a338fd..eda6383dd38 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -37,6 +37,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; // require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; // supplier order require_once DOL_DOCUMENT_ROOT.'/supplier_proposal/class/supplier_proposal.class.php'; // supplier proposal require_once DOL_DOCUMENT_ROOT."/reception/class/reception.class.php"; // reception +include_once DOL_DOCUMENT_ROOT.'/emailcollector/lib/emailcollector.lib.php'; //require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; // Holidays (leave request) //require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php'; // expernse report From 303b6d6e9e06889d22904fa45e31fa940b526d04 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Jun 2022 11:23:10 +0200 Subject: [PATCH 11/21] Fix object not defined --- .../class/emailcollector.class.php | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/htdocs/emailcollector/class/emailcollector.class.php b/htdocs/emailcollector/class/emailcollector.class.php index f00ec802b39..ea8913bae23 100644 --- a/htdocs/emailcollector/class/emailcollector.class.php +++ b/htdocs/emailcollector/class/emailcollector.class.php @@ -504,7 +504,7 @@ class EmailCollector extends CommonObject */ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1) { - global $conf, $langs, $hookmanager; + global $conf, $langs, $action, $hookmanager; if (!empty($conf->dol_no_mouse_hover)) { $notooltip = 1; // Force disable tooltips @@ -537,13 +537,6 @@ class EmailCollector extends CommonObject } $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"'; - - /* - $hookmanager->initHooks(array('myobjectdao')); - $parameters=array('id'=>$this->id); - $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $linkclose = $hookmanager->resPrint; - */ } else { $linkclose = ($morecss ? ' class="'.$morecss.'"' : ''); } @@ -562,7 +555,6 @@ class EmailCollector extends CommonObject $result .= $linkend; //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : ''); - global $action, $hookmanager; $hookmanager->initHooks(array('emailcollectordao')); $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 @@ -965,6 +957,7 @@ class EmailCollector extends CommonObject public function doCollectOneCollector() { global $conf, $langs, $user; + global $hookmanager; //$conf->global->SYSLOG_FILE = 'DOL_DATA_ROOT/dolibarr_mydedicatedlofile.log'; @@ -2009,11 +2002,16 @@ class EmailCollector extends CommonObject 'object' => 'Mo'), ); - global $hookmanager; + if (!is_object($hookmanager)) { + include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; + $hookmanager = new HookManager($this->db); + } $hookmanager->initHooks(array('emailcolector')); $parameters = array('arrayobject' => $arrayobject); $reshook = $hookmanager->executeHooks('addmoduletoeamailcollectorjoinpiece', $parameters); // Note that $action and $object may have been modified by some hooks - if ($reshook > 0) $arrayobject = $hookmanager->resArray; + if ($reshook > 0) { + $arrayobject = $hookmanager->resArray; + } $resultobj = array(); @@ -2365,8 +2363,6 @@ class EmailCollector extends CommonObject } elseif (substr($operation['type'], 0, 4) == 'hook') { // Create event specific on hook // this code action is hook..... for support this call - global $hookmanager; - if (!is_object($hookmanager)) { include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; $hookmanager = new HookManager($this->db); @@ -2391,9 +2387,9 @@ class EmailCollector extends CommonObject 'header'=>$header, 'attachments'=>$attachments, ); - $res = $hookmanager->executeHooks('doCollectOneCollector', $parameters, $this, $operation['type']); + $reshook = $hookmanager->executeHooks('doCollectOneCollector', $parameters, $this, $operation['type']); - if ($res < 0) { + if ($reshook < 0) { $errorforthisaction++; $this->error = $hookmanager->resPrint; } From 0146be0d157198eb1f6f65419e3cbdb2388e8a3d Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 7 Jun 2022 18:13:21 +0200 Subject: [PATCH 12/21] fix: filter status do not work on peruser action comm --- htdocs/comm/action/peruser.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index f74974a26d9..5adf5946f35 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -99,7 +99,7 @@ $month = GETPOST("month", "int") ?GETPOST("month", "int") : date("m"); $week = GETPOST("week", "int") ?GETPOST("week", "int") : date("W"); $day = GETPOST("day", "int") ?GETPOST("day", "int") : date("d"); $pid = GETPOST("search_projectid", "int", 3) ?GETPOST("search_projectid", "int", 3) : GETPOST("projectid", "int", 3); -$status = GETPOST("search_status", 'alpha') ?GETPOST("search_status", 'alpha') : GETPOST("status", 'alpha'); +$status = GETPOSTISSET("search_status") ? GETPOST("search_status", 'aZ09') : GETPOST("status", 'aZ09'); // status may be 0, 50, 100, 'todo' $type = GETPOST("search_type", 'alpha') ?GETPOST("search_type", 'alpha') : GETPOST("type", 'alpha'); $maxprint = ((GETPOST("maxprint", 'int') != '') ?GETPOST("maxprint", 'int') : $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW); $optioncss = GETPOST('optioncss', 'aZ'); // Option for the css output (always '' except when 'print') @@ -153,9 +153,10 @@ if ($end_d < $begin_d) { $end_d = $begin_d + 1; } -if ($status == '' && !GETPOSTISSET('status')) { +if ($status == '' && !GETPOSTISSET('search_status')) { $status = (empty($conf->global->AGENDA_DEFAULT_FILTER_STATUS) ? '' : $conf->global->AGENDA_DEFAULT_FILTER_STATUS); } + if (empty($mode) && !GETPOSTISSET('mode')) { $mode = (empty($conf->global->AGENDA_DEFAULT_VIEW) ? 'show_month' : $conf->global->AGENDA_DEFAULT_VIEW); } @@ -512,7 +513,7 @@ print '
'; if (empty($search_status)) { $search_status = ''; } -print_actions_filter($form, $canedit, $search_status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); +print_actions_filter($form, $canedit, $status, $year, $month, $day, $showbirthday, 0, $filtert, 0, $pid, $socid, $action, -1, $actioncode, $usergroup, '', $resourceid); print '
'; @@ -623,6 +624,7 @@ if ($type) { $sql .= " AND ca.id = ".((int) $type); } if ($status == '0') { + $sql .= " AND a.percent = 0"; } if ($status == '-1') { From 70892c18c5e7f1163bf8c05701be20d3c28cb65a Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Tue, 7 Jun 2022 18:14:15 +0200 Subject: [PATCH 13/21] fix: filter status do not work on peruser action comm --- htdocs/comm/action/peruser.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 5adf5946f35..82c15392349 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -624,7 +624,6 @@ if ($type) { $sql .= " AND ca.id = ".((int) $type); } if ($status == '0') { - $sql .= " AND a.percent = 0"; } if ($status == '-1') { From 48fdfe26fa78c0066d3896a3b257d505757a9e2e Mon Sep 17 00:00:00 2001 From: antonin_tdj <50403308+ibuiv@users.noreply.github.com> Date: Tue, 7 Jun 2022 18:44:00 +0200 Subject: [PATCH 14/21] Fix: rollback on success create_individual Fix: Societe::create_individual rollback on success --- htdocs/societe/class/societe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 0f7ad23acb0..beb0f699246 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1078,7 +1078,7 @@ class Societe extends CommonObject } } - if (!empty($error)) { + if (empty($error)) { dol_syslog(get_class($this)."::create_individual success"); $this->db->commit(); } else { From 648a8f5c18f9cded56c362201ab6a03bdd676d8f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Jun 2022 18:58:53 +0200 Subject: [PATCH 15/21] FIX xml file for company with special chars in name --- .../class/bonprelevement.class.php | 40 +++++++++---------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index afd6b5e075c..fcf13fe8c0e 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1489,7 +1489,7 @@ class BonPrelevement extends CommonObject fputs($this->file, ' '.$i.''.$CrLf); fputs($this->file, ' '.$this->total.''.$CrLf); fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf); + fputs($this->file, ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale)))).''.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); @@ -1605,7 +1605,7 @@ class BonPrelevement extends CommonObject fputs($this->file, ' '.$i.''.$CrLf); fputs($this->file, ' '.$this->total.''.$CrLf); fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf); + fputs($this->file, ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale)))).''.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); @@ -1855,16 +1855,16 @@ class BonPrelevement extends CommonObject $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; - $XML_DEBITOR .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).''.$CrLf; + $XML_DEBITOR .= ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($row_nom)))).''.$CrLf; $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$row_country_code.''.$CrLf; $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")); if (trim($addressline1)) { - $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline1), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1)), 70, 'right', 'UTF-8', 1)).''.$CrLf; } if (trim($addressline2)) { - $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline2), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_DEBITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline2)), 70, 'right', 'UTF-8', 1)).''.$CrLf; } $XML_DEBITOR .= ' '.$CrLf; $XML_DEBITOR .= ' '.$CrLf; @@ -1906,16 +1906,16 @@ class BonPrelevement extends CommonObject $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; - $XML_CREDITOR .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).''.$CrLf; + $XML_CREDITOR .= ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($row_nom)))).''.$CrLf; $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$row_country_code.''.$CrLf; $addressline1 = strtr($row_address, array(CHR(13) => ", ", CHR(10) => "")); $addressline2 = strtr($row_zip.(($row_zip && $row_town) ? ' ' : ''.$row_town), array(CHR(13) => ", ", CHR(10) => "")); if (trim($addressline1)) { - $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline1), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1)), 70, 'right', 'UTF-8', 1)).''.$CrLf; } if (trim($addressline2)) { - $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline2), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_CREDITOR .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline2)), 70, 'right', 'UTF-8', 1)).''.$CrLf; } $XML_CREDITOR .= ' '.$CrLf; $XML_CREDITOR .= ' '.$CrLf; @@ -2078,16 +2078,16 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$dateTime_ETAD.''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale)))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; $addressline1 = strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => "")); $addressline2 = strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => "")); if ($addressline1) { - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline1), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1)), 70, 'right', 'UTF-8', 1)).''.$CrLf; } if ($addressline2) { - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline2), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline2)), 70, 'right', 'UTF-8', 1)).''.$CrLf; } $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; @@ -2102,11 +2102,11 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; /* $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale)))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ADDRESS.'').$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ADDRESS))).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN)).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf;*/ $XML_SEPA_INFO .= ' SLEV'.$CrLf; // Field "Responsible of fees". Must be SLEV @@ -2144,16 +2144,16 @@ class BonPrelevement extends CommonObject */ $XML_SEPA_INFO .= ' '.dol_print_date($dateTime_ETAD, 'dayrfc').''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale)))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; $addressline1 = strtr($configuration->global->MAIN_INFO_SOCIETE_ADDRESS, array(CHR(13) => ", ", CHR(10) => "")); $addressline2 = strtr($configuration->global->MAIN_INFO_SOCIETE_ZIP.(($configuration->global->MAIN_INFO_SOCIETE_ZIP || ' '.$configuration->global->MAIN_INFO_SOCIETE_TOWN) ? ' ' : '').$configuration->global->MAIN_INFO_SOCIETE_TOWN, array(CHR(13) => ", ", CHR(10) => "")); if ($addressline1) { - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline1), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline1)), 70, 'right', 'UTF-8', 1)).''.$CrLf; } if ($addressline2) { - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_unaccent($addressline2), 70, 'right', 'UTF-8', 1)).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_trunc(dol_string_nospecial(dol_string_unaccent($addressline2)), 70, 'right', 'UTF-8', 1)).''.$CrLf; } $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; @@ -2168,11 +2168,11 @@ class BonPrelevement extends CommonObject $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; /* $XML_SEPA_INFO .= ' '.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_unaccent($this->raison_sociale))).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(strtoupper(dol_string_nospecial(dol_string_unaccent($this->raison_sociale)))).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$country[1].''.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ADDRESS).''.$CrLf; - $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ADDRESS))).''.$CrLf; + $XML_SEPA_INFO .= ' '.dolEscapeXML(dol_string_nospecial(dol_string_unaccent($conf->global->MAIN_INFO_SOCIETE_ZIP.' '.$conf->global->MAIN_INFO_SOCIETE_TOWN)).''.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf; $XML_SEPA_INFO .= ' '.$CrLf;*/ $XML_SEPA_INFO .= ' SLEV'.$CrLf; // Field "Responsible of fees". Must be SLEV From 8303347ab8c7136247221d9c170377d0027d14b1 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Jun 2022 19:27:43 +0200 Subject: [PATCH 16/21] FIX label and get_substitutionarray_each_var_object on ODT generation --- htdocs/core/class/commondocgenerator.class.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 3d94469759b..3167bd0c64c 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -421,8 +421,9 @@ abstract class CommonDocGenerator $resarray = array( $array_key.'_id'=>$object->id, - $array_key.'_ref'=>$object->ref, - $array_key.'_ref_ext'=>$object->ref_ext, + $array_key.'_ref' => (property_exists($object, 'ref') ? $object->ref : ''), + $array_key.'_label' => (property_exists($object, 'label') ? $object->label : ''), + $array_key.'_ref_ext' => (property_exists($object, '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, @@ -443,7 +444,7 @@ abstract class CommonDocGenerator $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, @@ -820,8 +821,9 @@ abstract class CommonDocGenerator if (!empty($value)) { if (!is_array($value) && !is_object($value)) { $array_other['object_'.$key] = $value; - } - if (is_array($value) && $recursive) { + } elseif (is_array($value) && $recursive) { + $array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value, $outputlangs, false); + } elseif (is_object($value) && $recursive) { $array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value, $outputlangs, false); } } From 7ee4cccc840e2faeb3ad23d8222891bb6feab5c2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 7 Jun 2022 19:59:33 +0200 Subject: [PATCH 17/21] FIX ODT tags for subobjects {object_subobject_yyy} was not working. --- .../core/class/commondocgenerator.class.php | 20 +++++++++++++++---- .../bom/doc/doc_generic_bom_odt.modules.php | 1 + 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 3167bd0c64c..21c1cce4cfd 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -809,26 +809,38 @@ abstract class CommonDocGenerator * * @param Object $object Dolibarr Object * @param Translate $outputlangs Language object for output - * @param boolean $recursive Want to fetch child array or child object + * @param boolean|int $recursive Want to fetch child array or child object. * @return array Array of substitution key->code */ - public function get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive = true) + public function get_substitutionarray_each_var_object(&$object, $outputlangs, $recursive = 1) { // phpcs:enable $array_other = array(); if (!empty($object)) { foreach ($object as $key => $value) { + if (in_array($key, array('db', 'fields', 'lines', 'modelpdf', 'model_pdf'))) { // discard some properties + continue; + } if (!empty($value)) { if (!is_array($value) && !is_object($value)) { $array_other['object_'.$key] = $value; } elseif (is_array($value) && $recursive) { - $array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value, $outputlangs, false); + $tmparray = $this->get_substitutionarray_each_var_object($value, $outputlangs, 0); + foreach ($tmparray as $key2 => $value2) { + $array_other['object_'.$key.'_'.preg_replace('/^object_/', '', $key2)] = $value2; + } } elseif (is_object($value) && $recursive) { - $array_other['object_'.$key] = $this->get_substitutionarray_each_var_object($value, $outputlangs, false); + $tmparray = $this->get_substitutionarray_each_var_object($value, $outputlangs, 0); + foreach ($tmparray as $key2 => $value2) { + $array_other['object_'.$key.'_'.preg_replace('/^object_/', '', $key2)] = $value2; + } } } } } + + //var_dump($array_other); + return $array_other; } diff --git a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php index 31c20cf1ecd..c070e3b1058 100644 --- a/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php +++ b/htdocs/core/modules/bom/doc/doc_generic_bom_odt.modules.php @@ -246,6 +246,7 @@ class doc_generic_bom_odt extends ModelePDFBom } $object->fetch_thirdparty(); + $object->fetch_product(); $dir = $conf->bom->multidir_output[isset($object->entity) ? $object->entity : 1]; $objectref = dol_sanitizeFileName($object->ref); From c9049a9c85fac248c6cdf81f70298c90c0d619c2 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Wed, 8 Jun 2022 12:35:31 +0200 Subject: [PATCH 18/21] Fix non numeric warning --- htdocs/product/class/productcustomerprice.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index a9444d1c569..64db4a4eb55 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -135,7 +135,7 @@ class Productcustomerprice extends CommonObject $this->price_base_type = trim($this->price_base_type); } if (isset($this->tva_tx)) { - $this->tva_tx = trim($this->tva_tx); + $this->tva_tx = (float) $this->tva_tx; } if (isset($this->recuperableonly)) { $this->recuperableonly = trim($this->recuperableonly); @@ -621,7 +621,7 @@ class Productcustomerprice extends CommonObject $this->price_base_type = trim($this->price_base_type); } if (isset($this->tva_tx)) { - $this->tva_tx = trim($this->tva_tx); + $this->tva_tx = (float) $this->tva_tx; } if (isset($this->recuperableonly)) { $this->recuperableonly = trim($this->recuperableonly); From 636d59430146ccc398a93dbca61c1af724454ab7 Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Wed, 8 Jun 2022 17:26:30 +0200 Subject: [PATCH 19/21] Fix reception set-draft with stock rule enabled. --- htdocs/reception/class/reception.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 9f0a6342a24..7263a20dde7 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -1944,7 +1944,7 @@ class Reception extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record $inventorycode = ''; - $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref), '', '', '', '', 0, $inventorycode); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref), '', '', '', '', 0, $inventorycode); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -1956,7 +1956,7 @@ class Reception extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record $inventorycode = ''; - $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', 0, $inventorycode); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', 0, $inventorycode); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; From 48142c69bd2c9e1cabf5322249922ffe299eb40a Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Wed, 8 Jun 2022 17:20:48 +0200 Subject: [PATCH 20/21] Fix reception re-open with stock rule enabled. --- htdocs/reception/class/reception.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 7263a20dde7..8cd1387152e 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -1813,7 +1813,7 @@ class Reception extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record $inventorycode = ''; - $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref), '', '', '', '', 0, $inventorycode); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref), '', '', '', '', 0, $inventorycode); if ($result < 0) { $this->error = $mouvS->error; @@ -1825,7 +1825,7 @@ class Reception extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record $inventorycode = ''; - $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, -$qty, $obj->subprice, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', $obj->fk_origin_stock, $inventorycode); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', $obj->fk_origin_stock, $inventorycode); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; From e1f4d99aa62618287a03a634ee1e7b6e603117be Mon Sep 17 00:00:00 2001 From: Francis Appels Date: Wed, 8 Jun 2022 18:27:47 +0200 Subject: [PATCH 21/21] Debug #18770 edit buy price for WAP update. --- htdocs/reception/class/reception.class.php | 39 ++++++++-------------- 1 file changed, 14 insertions(+), 25 deletions(-) diff --git a/htdocs/reception/class/reception.class.php b/htdocs/reception/class/reception.class.php index 8cd1387152e..d1d448b8dcb 100644 --- a/htdocs/reception/class/reception.class.php +++ b/htdocs/reception/class/reception.class.php @@ -593,22 +593,12 @@ class Reception extends CommonObject $mouvS->origin = &$this; $mouvS->setOrigin($this->element, $this->id); - // get unit price with discount - $up_ht_disc = $obj->subprice; - if (!empty($obj->remise_percent) && empty($conf->global->STOCK_EXCLUDE_DISCOUNT_FOR_PMP)) { - $up_ht_disc = price2num($up_ht_disc * (100 - $obj->remise_percent) / 100, 'MU'); - } - if (empty($obj->batch)) { // line without batch detail // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. $inventorycode = ''; - if (!empty($conf->global->STOCK_CALCULATE_ON_RECEPTION || $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) { - $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans("ReceptionValidatedInDolibarr", $numref), '', '', '', '', 0, $inventorycode); - } else { - $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $up_ht_disc, $langs->trans("ReceptionValidatedInDolibarr", $numref), '', '', '', '', 0, $inventorycode); - } + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans("ReceptionValidatedInDolibarr", $numref), '', '', '', '', 0, $inventorycode); if ($result < 0) { $error++; @@ -622,11 +612,7 @@ class Reception extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record. // Note: ->fk_origin_stock = id into table llx_product_batch (may be rename into llx_product_stock_batch in another version) $inventorycode = ''; - if (!empty($conf->global->STOCK_CALCULATE_ON_RECEPTION || $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE)) { - $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans("ReceptionValidatedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', 0, $inventorycode); - } else { - $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $up_ht_disc, $langs->trans("ReceptionValidatedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', 0, $inventorycode); - } + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans("ReceptionValidatedInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', 0, $inventorycode); if ($result < 0) { $error++; @@ -1618,7 +1604,8 @@ class Reception extends CommonObject // TODO possibilite de receptionner a partir d'une propale ou autre origine ? $sql = "SELECT cd.fk_product, cd.subprice,"; $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; - $sql .= " ed.eatby, ed.sellby, ed.batch"; + $sql .= " ed.eatby, ed.sellby, ed.batch,"; + $sql .= " ed.cost_price"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; $sql .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; $sql .= " WHERE ed.fk_reception = ".((int) $this->id); @@ -1648,7 +1635,7 @@ class Reception extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record $inventorycode = ''; - $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionClassifyClosedInDolibarr", $this->ref), '', '', '', '', 0, $inventorycode); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans("ReceptionClassifyClosedInDolibarr", $this->ref), '', '', '', '', 0, $inventorycode); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -1659,7 +1646,7 @@ class Reception extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record $inventorycode = ''; - $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionClassifyClosedInDolibarr", $this->ref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', 0, $inventorycode); + $result = $mouvS->reception($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans("ReceptionClassifyClosedInDolibarr", $this->ref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', 0, $inventorycode); if ($result < 0) { $this->error = $mouvS->error; @@ -1782,7 +1769,8 @@ class Reception extends CommonObject // TODO possibilite de receptionner a partir d'une propale ou autre origine $sql = "SELECT ed.fk_product, cd.subprice,"; $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; - $sql .= " ed.eatby, ed.sellby, ed.batch"; + $sql .= " ed.eatby, ed.sellby, ed.batch,"; + $sql .= " ed.cost_price"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; $sql .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; $sql .= " WHERE ed.fk_reception = ".((int) $this->id); @@ -1813,7 +1801,7 @@ class Reception extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record $inventorycode = ''; - $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref), '', '', '', '', 0, $inventorycode); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref), '', '', '', '', 0, $inventorycode); if ($result < 0) { $this->error = $mouvS->error; @@ -1825,7 +1813,7 @@ class Reception extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record $inventorycode = ''; - $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', $obj->fk_origin_stock, $inventorycode); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans("ReceptionUnClassifyCloseddInDolibarr", $numref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', $obj->fk_origin_stock, $inventorycode); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -1913,7 +1901,8 @@ class Reception extends CommonObject // TODO possibilite de receptionner a partir d'une propale ou autre origine $sql = "SELECT cd.fk_product, cd.subprice,"; $sql .= " ed.rowid, ed.qty, ed.fk_entrepot,"; - $sql .= " ed.eatby, ed.sellby, ed.batch"; + $sql .= " ed.eatby, ed.sellby, ed.batch,"; + $sql .= " ed.cost_price"; $sql .= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as cd,"; $sql .= " ".MAIN_DB_PREFIX."commande_fournisseur_dispatch as ed"; $sql .= " WHERE ed.fk_reception = ".((int) $this->id); @@ -1944,7 +1933,7 @@ class Reception extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record $inventorycode = ''; - $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref), '', '', '', '', 0, $inventorycode); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref), '', '', '', '', 0, $inventorycode); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors; @@ -1956,7 +1945,7 @@ class Reception extends CommonObject // We decrement stock of product (and sub-products) -> update table llx_product_stock (key of this table is fk_product+fk_entrepot) and add a movement record $inventorycode = ''; - $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->subprice, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', 0, $inventorycode); + $result = $mouvS->livraison($user, $obj->fk_product, $obj->fk_entrepot, $qty, $obj->cost_price, $langs->trans("ReceptionBackToDraftInDolibarr", $this->ref), $this->db->jdate($obj->eatby), $this->db->jdate($obj->sellby), $obj->batch, '', 0, $inventorycode); if ($result < 0) { $this->error = $mouvS->error; $this->errors = $mouvS->errors;