From d3e0e1f6958f44d6430d6849a4080748bdedfaaa Mon Sep 17 00:00:00 2001 From: atm-steve Date: Mon, 4 Jul 2022 17:14:01 +0200 Subject: [PATCH 1/8] fix ndf validate with main entity --- htdocs/expensereport/class/expensereport.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 9eaa2f96cb5..1d63ce997d3 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1256,7 +1256,7 @@ class ExpenseReport extends CommonObject // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'expensereport/".$this->db->escape($this->newref)."'"; - $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'expensereport/".$this->db->escape($this->ref)."' and entity = ".$conf->entity; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'expensereport/".$this->db->escape($this->ref)."' and entity = ".$this->entity; $resql = $this->db->query($sql); if (!$resql) { $error++; $this->error = $this->db->lasterror(); @@ -1265,15 +1265,15 @@ class ExpenseReport extends CommonObject // We rename directory ($this->ref = old ref, $num = new ref) in order not to lose the attachments $oldref = dol_sanitizeFileName($this->ref); $newref = dol_sanitizeFileName($num); - $dirsource = $conf->expensereport->dir_output.'/'.$oldref; - $dirdest = $conf->expensereport->dir_output.'/'.$newref; + $dirsource = $conf->expensereport->multidir_output[$this->entity].'/'.$oldref; + $dirdest = $conf->expensereport->multidir_output[$this->entity].'/'.$newref; if (!$error && file_exists($dirsource)) { dol_syslog(get_class($this)."::setValidate() rename dir ".$dirsource." into ".$dirdest); if (@rename($dirsource, $dirdest)) { dol_syslog("Rename ok"); // Rename docs starting with $oldref with $newref - $listoffiles = dol_dir_list($conf->expensereport->dir_output.'/'.$newref, 'files', 1, '^'.preg_quote($oldref, '/')); + $listoffiles = dol_dir_list($dirdest, 'files', 1, '^'.preg_quote($oldref, '/')); foreach ($listoffiles as $fileentry) { $dirsource = $fileentry['name']; $dirdest = preg_replace('/^'.preg_quote($oldref, '/').'/', $newref, $dirsource); From fe7c71d1c23cbefe700a74418ebaa8e82a9e63ba Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Tue, 29 Aug 2023 11:45:26 +0200 Subject: [PATCH 2/8] FIX product list accounting length --- htdocs/product/list.php | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index b2f7489cbfe..017a2cf8200 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -43,6 +43,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +if (!empty($conf->accounting->enabled)) + require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'suppliers', 'companies', 'margins')); @@ -410,12 +412,12 @@ if ($fourn_id > 0) $sql .= " AND pfp.fk_soc = ".((int) $fourn_id); if ($search_country) $sql .= " AND p.fk_country = ".$search_country; if ($search_state) $sql .= " AND p.fk_state = ".$search_state; if ($search_finished >= 0 && $search_finished !== '') $sql .= " AND p.finished = ".$search_finished; -if ($search_accountancy_code_sell) $sql .= natural_search('p.accountancy_code_sell', $search_accountancy_code_sell); -if ($search_accountancy_code_sell_intra) $sql .= natural_search('p.accountancy_code_sell_intra', $search_accountancy_code_sell_intra); -if ($search_accountancy_code_sell_export) $sql .= natural_search('p.accountancy_code_sell_export', $search_accountancy_code_sell_export); -if ($search_accountancy_code_buy) $sql .= natural_search('p.accountancy_code_buy', $search_accountancy_code_buy); -if ($search_accountancy_code_buy_intra) $sql .= natural_search('p.accountancy_code_buy_intra', $search_accountancy_code_buy_intra); -if ($search_accountancy_code_buy_export) $sql .= natural_search('p.accountancy_code_buy_export', $search_accountancy_code_buy_export); +if ($search_accountancy_code_sell) $sql .= natural_search('p.accountancy_code_sell', clean_account($search_accountancy_code_sell)); +if ($search_accountancy_code_sell_intra) $sql .= natural_search('p.accountancy_code_sell_intra', clean_account($search_accountancy_code_sell_intra)); +if ($search_accountancy_code_sell_export) $sql .= natural_search('p.accountancy_code_sell_export', clean_account($search_accountancy_code_sell_export)); +if ($search_accountancy_code_buy) $sql .= natural_search('p.accountancy_code_buy', clean_account($search_accountancy_code_buy)); +if ($search_accountancy_code_buy_intra) $sql .= natural_search('p.accountancy_code_buy_intra', clean_account($search_accountancy_code_buy_intra)); +if ($search_accountancy_code_buy_export) $sql .= natural_search('p.accountancy_code_buy_export', clean_account($search_accountancy_code_buy_export)); // Add where from extra fields include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php'; @@ -1481,33 +1483,33 @@ if ($resql) // Accountancy code sell if (!empty($arrayfields['p.accountancy_code_sell']['checked'])) { - print ''.$obj->accountancy_code_sell.''; + print ''.length_accountg($obj->accountancy_code_sell).''; if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['p.accountancy_code_sell_intra']['checked'])) { - print ''.$obj->accountancy_code_sell_intra.''; + print ''.length_accountg($obj->accountancy_code_sell_intra).''; if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['p.accountancy_code_sell_export']['checked'])) { - print ''.$obj->accountancy_code_sell_export.''; + print ''.length_accountg($obj->accountancy_code_sell_export).''; if (!$i) $totalarray['nbfield']++; } // Accountancy code buy if (!empty($arrayfields['p.accountancy_code_buy']['checked'])) { - print ''.$obj->accountancy_code_buy.''; + print ''.length_accountg($obj->accountancy_code_buy).''; if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['p.accountancy_code_buy_intra']['checked'])) { - print ''.$obj->accountancy_code_buy_intra.''; + print ''.length_accountg($obj->accountancy_code_buy_intra).''; if (!$i) $totalarray['nbfield']++; } if (!empty($arrayfields['p.accountancy_code_buy_export']['checked'])) { - print ''.$obj->accountancy_code_buy_export.''; + print ''.length_accountg($obj->accountancy_code_buy_export).''; if (!$i) $totalarray['nbfield']++; } // Extra fields From bbca5118b7a613a06df0aca6afc895a37ea200dd Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Tue, 29 Aug 2023 12:12:21 +0200 Subject: [PATCH 3/8] FIX export FEC --- htdocs/accountancy/class/accountancyexport.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 0c698c5059c..08ced92348f 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -882,7 +882,7 @@ class AccountancyExport print $date_document . $separator; // FEC:CompteNum - print $line->numero_compte . $separator; + print length_accountg($line->numero_compte) . $separator; // FEC:CompteLib print dol_string_unaccent($line->label_compte) . $separator; From 5001cc6de541d605e9896b0ad5e0b2522f860a9f Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Wed, 6 Sep 2023 14:23:16 +0200 Subject: [PATCH 4/8] same fix for fec2 --- htdocs/accountancy/class/accountancyexport.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/accountancy/class/accountancyexport.class.php b/htdocs/accountancy/class/accountancyexport.class.php index 08ced92348f..f48be1fc238 100644 --- a/htdocs/accountancy/class/accountancyexport.class.php +++ b/htdocs/accountancy/class/accountancyexport.class.php @@ -888,7 +888,7 @@ class AccountancyExport print dol_string_unaccent($line->label_compte) . $separator; // FEC:CompAuxNum - print $line->subledger_account . $separator; + print length_accounta($line->subledger_account) . $separator; // FEC:CompAuxLib print dol_string_unaccent($line->subledger_label) . $separator; @@ -983,13 +983,13 @@ class AccountancyExport print $date_creation . $separator; // FEC:CompteNum - print $line->numero_compte . $separator; + print length_accountg($line->numero_compte) . $separator; // FEC:CompteLib print dol_string_unaccent($line->label_compte) . $separator; // FEC:CompAuxNum - print $line->subledger_account . $separator; + print length_accounta($line->subledger_account) . $separator; // FEC:CompAuxLib print dol_string_unaccent($line->subledger_label) . $separator; From df4df7ab1b471849333c4bb6f3aa2cc8c6001438 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 11 Sep 2023 17:51:38 +0200 Subject: [PATCH 5/8] Update expensereport.class.php --- htdocs/expensereport/class/expensereport.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index f8b19c14b13..c34d1171125 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -1234,9 +1234,9 @@ class ExpenseReport extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element; $sql .= " SET ref = '".$this->db->escape($num)."',"; $sql .= " fk_statut = ".self::STATUS_VALIDATED.","; - $sql .= " date_valid='".$this->db->idate($this->date_valid)."',"; - $sql .= " fk_user_valid = ".$user->id; - $sql .= " WHERE rowid = ".$this->id; + $sql .= " date_valid = '".$this->db->idate($this->date_valid)."',"; + $sql .= " fk_user_valid = ".((int) $user->id); + $sql .= " WHERE rowid = ".((int) $this->id); $resql = $this->db->query($sql); if ($resql) { @@ -1258,7 +1258,7 @@ class ExpenseReport extends CommonObject // Now we rename also files into index $sql = 'UPDATE '.MAIN_DB_PREFIX."ecm_files set filename = CONCAT('".$this->db->escape($this->newref)."', SUBSTR(filename, ".(strlen($this->ref) + 1).")), filepath = 'expensereport/".$this->db->escape($this->newref)."'"; - $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'expensereport/".$this->db->escape($this->ref)."' and entity = ".$this->entity; + $sql .= " WHERE filename LIKE '".$this->db->escape($this->ref)."%' AND filepath = 'expensereport/".$this->db->escape($this->ref)."' AND entity = ".((int) $this->entity); $resql = $this->db->query($sql); if (!$resql) { $error++; $this->error = $this->db->lasterror(); From 3dad9d0899c63fad1ed2536945d4a36b6794b653 Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Thu, 14 Sep 2023 10:03:28 +0200 Subject: [PATCH 6/8] FIX : bad check return for sendfile --- 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 b323b4b3e01..e6606eb152b 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -508,7 +508,7 @@ if (!$error && $massaction == 'confirm_presend') { $resaction .= '
'.$mailfile->error.'
'; } else { $result = $mailfile->sendfile(); - if ($result) { + if ($result > 0) { $resaction .= $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)).'
'; // Must not contain " $error = 0; From ed4a8e88c0773fe98579237bfe31b7ff086bf0f7 Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Thu, 14 Sep 2023 10:21:16 +0200 Subject: [PATCH 7/8] FIX : bad from and to --- 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 e6606eb152b..225e118b2a0 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -509,7 +509,7 @@ if (!$error && $massaction == 'confirm_presend') { } else { $result = $mailfile->sendfile(); if ($result > 0) { - $resaction .= $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($from, 2), $mailfile->getValidAddress($sendto, 2)).'
'; // Must not contain " + $resaction .= $langs->trans('MailSuccessfulySent', $mailfile->getValidAddress($mailfile->addr_from, 2), $mailfile->getValidAddress($mailfile->addr_to, 2)).'
'; // Must not contain " $error = 0; From 48a2fd3c615a46f86c2c29f60f1eb1ef09b3bb2a Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Thu, 14 Sep 2023 14:03:23 +0200 Subject: [PATCH 8/8] FIX include --- htdocs/product/list.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 017a2cf8200..218d260bfe7 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -43,8 +43,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; if (!empty($conf->categorie->enabled)) require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; -if (!empty($conf->accounting->enabled)) - require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; // Load translation files required by the page $langs->loadLangs(array('products', 'stocks', 'suppliers', 'companies', 'margins'));