From ff7727466ad129070c0b56965eb0457f0ddf1795 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 14 Oct 2021 17:13:44 +0200 Subject: [PATCH 01/14] Function updateExtrafield : replace empty value to null --- htdocs/core/class/commonobject.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5a5e1a58928..50c6f1893ea 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5492,7 +5492,6 @@ abstract class CommonObject } $sql .= ")"; - $resql = $this->db->query($sql); if (!$resql) { @@ -5792,7 +5791,7 @@ abstract class CommonObject } if ($linealreadyfound) { - if ($this->array_options["options_".$key] === null) { + if ($this->array_options["options_".$key] === '') { $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = null"; } else { $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = '".$this->db->escape($this->array_options["options_".$key])."'"; From 02bb39d4384933a052e38e551f73c6c7b109d985 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 21 Oct 2021 05:06:50 +0200 Subject: [PATCH 02/14] FIX Accountancy simplified - Salaries are not present in report --- htdocs/compta/resultat/clientfourn.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index f2f192271ac..0b38a8f66c9 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -862,7 +862,8 @@ if ($modecompta == 'BOOKKEEPING') { $sql = "SELECT u.rowid, u.firstname, u.lastname, p.fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; - $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."salary as s ON s.rowid=p.fk_salary"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=s.fk_user"; $sql .= " WHERE p.entity IN (".getEntity('payment_salary').")"; if (!empty($date_start) && !empty($date_end)) { $sql .= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'"; From be7c1c8a235a58ca8300cd7b0c765fc7010e85b2 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 21 Oct 2021 05:18:56 +0200 Subject: [PATCH 03/14] Typo & translation --- htdocs/compta/resultat/clientfourn.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 0b38a8f66c9..2de55d1801f 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -9,6 +9,7 @@ * Copyright (C) 2014 Florian Henry * Copyright (C) 2018 Frédéric France * Copyright (C) 2020 Maxime DEMAREST + * Copyright (C) 2021 Alexandre Spangaro * * 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 @@ -366,7 +367,7 @@ if ($modecompta == 'BOOKKEEPING') { } } else { /* - * Factures clients + * Customer invoices */ print ''.$langs->trans("CustomersInvoices").''; @@ -386,8 +387,8 @@ if ($modecompta == 'BOOKKEEPING') { } } elseif ($modecompta == 'RECETTES-DEPENSES') { /* - * Liste des paiements (les anciens paiements ne sont pas vus par cette requete car, sur les - * vieilles versions, ils n'etaient pas lies via paiement_facture. On les ajoute plus loin) + * List of payments (old payments are not seen by this query because, on older versions, they were not linked via payment_invoice. + * old versions, they were not linked via payment_invoice. They are added later) */ $sql = "SELECT s.nom as name, s.rowid as socid, sum(pf.amount) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."societe as s"; @@ -434,7 +435,7 @@ if ($modecompta == 'BOOKKEEPING') { dol_print_error($db); } - // On ajoute les paiements clients anciennes version, non lie par paiement_facture + // We add the old customer payments, not linked by payment_invoice if ($modecompta == 'RECETTES-DEPENSES') { $sql = "SELECT 'Autres' as name, '0' as idp, sum(p.amount) as amount_ttc"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; @@ -673,7 +674,7 @@ if ($modecompta == 'BOOKKEEPING') { /* - * Charges sociales non deductibles + * Social / Fiscal contributions who are not deductible */ print ''.$langs->trans("SocialContributionsNondeductibles").''; @@ -760,7 +761,7 @@ if ($modecompta == 'BOOKKEEPING') { /* - * Charges sociales deductibles + * Social / Fiscal contributions who are deductible */ print ''.$langs->trans("SocialContributionsDeductibles").''; @@ -932,7 +933,7 @@ if ($modecompta == 'BOOKKEEPING') { /* - * Expense + * Expense report */ if (!empty($conf->expensereport->enabled)) { @@ -1088,7 +1089,7 @@ if ($modecompta == 'BOOKKEEPING') { } /* - * Payement Loan + * Payment Loan */ if (!empty($conf->global->ACCOUNTING_REPORTS_INCLUDE_LOAN) && !empty($conf->loan->enabled) && ($modecompta == 'CREANCES-DETTES' || $modecompta == "RECETTES-DEPENSES")) { @@ -1209,7 +1210,7 @@ if ($modecompta == 'BOOKKEEPING') { print ''.price($amount)."\n"; print "\n"; - // VAT to retreive + // VAT to retrieve $amount = 0; $sql = "SELECT date_format(f.datef,'%Y-%m') as dm, sum(f.total_tva) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; From a1c0e1ad1f4fae5d30c929e6b042450b655a2bcb Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 21 Oct 2021 05:45:37 +0200 Subject: [PATCH 04/14] Better fix with backward compatibility with old salary module --- htdocs/compta/resultat/clientfourn.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 2de55d1801f..e5984e527ae 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -869,8 +869,19 @@ if ($modecompta == 'BOOKKEEPING') { if (!empty($date_start) && !empty($date_end)) { $sql .= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'"; } + $sql .= " GROUP BY u.rowid, u.firstname, u.lastname, s.fk_user, p.label, dm"; + // For backward compatibility with old module salary + $sql .= " UNION "; + $sql .= " SELECT u.rowid, u.firstname, u.lastname, p.fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user"; + $sql .= " WHERE p.entity IN (".getEntity('payment_salary').")"; + if (!empty($date_start) && !empty($date_end)) { + $sql .= " AND $column >= '".$db->idate($date_start)."' AND $column <= '".$db->idate($date_end)."'"; + } $sql .= " GROUP BY u.rowid, u.firstname, u.lastname, p.fk_user, p.label, dm"; + $newsortfield = $sortfield; if ($newsortfield == 's.nom, s.rowid') { $newsortfield = 'u.firstname, u.lastname'; From d2b96fe0f64a7bf3563ece5fe3c8051ad8a1398c Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Thu, 21 Oct 2021 06:08:48 +0200 Subject: [PATCH 05/14] Correct link to salary list with user search --- htdocs/compta/resultat/clientfourn.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index e5984e527ae..1d2edd5c918 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -34,6 +34,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/tax.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; @@ -861,7 +862,7 @@ if ($modecompta == 'BOOKKEEPING') { $column = 'p.datep'; } - $sql = "SELECT u.rowid, u.firstname, u.lastname, p.fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; + $sql = "SELECT u.rowid, u.firstname, u.lastname, s.fk_user as fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."salary as s ON s.rowid=p.fk_salary"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=s.fk_user"; @@ -873,7 +874,7 @@ if ($modecompta == 'BOOKKEEPING') { // For backward compatibility with old module salary $sql .= " UNION "; - $sql .= " SELECT u.rowid, u.firstname, u.lastname, p.fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; + $sql .= " SELECT u.rowid, u.firstname, u.lastname, p.fk_user as fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=p.fk_user"; $sql .= " WHERE p.entity IN (".getEntity('payment_salary').")"; @@ -913,7 +914,10 @@ if ($modecompta == 'BOOKKEEPING') { print ' '; - print "".$langs->trans("Salary")." fk_user."\">".$obj->firstname." ".$obj->lastname."\n"; + $userstatic = new User($db); + $userstatic->fetch($obj->fk_user); + + print "".$langs->trans("Salary")." getFullName($langs)."\">".$obj->firstname." ".$obj->lastname."\n"; if ($modecompta == 'CREANCES-DETTES') { print ''.price(-$obj->amount).''; From 806c53d4c4c343299ffe4e6690f2889a9d50c2d8 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Thu, 21 Oct 2021 09:49:14 +0200 Subject: [PATCH 06/14] FIX Ret PR --- htdocs/core/class/commonobject.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 50c6f1893ea..a4fc828ef4b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5745,6 +5745,11 @@ abstract class CommonObject $this->array_options["options_".$key] = $this->db->idate($this->array_options["options_".$key]); } break; + case 'boolean': + if (empty($this->array_options["options_".$key])) { + $this->array_options["options_".$key] = null; + } + break; /* case 'link': $param_list = array_keys($attributeParam['options']); @@ -5791,7 +5796,7 @@ abstract class CommonObject } if ($linealreadyfound) { - if ($this->array_options["options_".$key] === '') { + if ($this->array_options["options_".$key] === null) { $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = null"; } else { $sql = "UPDATE ".MAIN_DB_PREFIX.$this->table_element."_extrafields SET ".$key." = '".$this->db->escape($this->array_options["options_".$key])."'"; From 0c8291b60fd4ecf936e221220b3a79d46c55a161 Mon Sep 17 00:00:00 2001 From: Alexandre SPANGARO Date: Fri, 22 Oct 2021 04:35:23 +0200 Subject: [PATCH 07/14] Fix INNER JOIN & Add urlencode() --- htdocs/compta/resultat/clientfourn.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/resultat/clientfourn.php b/htdocs/compta/resultat/clientfourn.php index 1d2edd5c918..b5aca49aaae 100644 --- a/htdocs/compta/resultat/clientfourn.php +++ b/htdocs/compta/resultat/clientfourn.php @@ -864,7 +864,7 @@ if ($modecompta == 'BOOKKEEPING') { $sql = "SELECT u.rowid, u.firstname, u.lastname, s.fk_user as fk_user, p.label as label, date_format($column,'%Y-%m') as dm, sum(p.amount) as amount"; $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as p"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."salary as s ON s.rowid=p.fk_salary"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."salary as s ON s.rowid=p.fk_salary"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."user as u ON u.rowid=s.fk_user"; $sql .= " WHERE p.entity IN (".getEntity('payment_salary').")"; if (!empty($date_start) && !empty($date_end)) { @@ -917,7 +917,7 @@ if ($modecompta == 'BOOKKEEPING') { $userstatic = new User($db); $userstatic->fetch($obj->fk_user); - print "".$langs->trans("Salary")." getFullName($langs)."\">".$obj->firstname." ".$obj->lastname."\n"; + print "".$langs->trans("Salary")." getFullName($langs))."\">".$obj->firstname." ".$obj->lastname."\n"; if ($modecompta == 'CREANCES-DETTES') { print ''.price(-$obj->amount).''; From fa21b27cedc3c67a5097932bae90114156820fa8 Mon Sep 17 00:00:00 2001 From: atm-lena Date: Fri, 22 Oct 2021 15:27:16 +0200 Subject: [PATCH 08/14] Validate Holiday : keep files --- htdocs/holiday/card.php | 1 + htdocs/holiday/class/holiday.class.php | 39 ++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 150a9c0754b..93e748a51d2 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -266,6 +266,7 @@ if (empty($reshook)) { // If update and we are an approver, we can update with another approver if ($action == 'update' && GETPOSTISSET('savevalidator') && !empty($user->rights->holiday->approve)) { + $object->fetch($id); $object->oldcopy = dol_clone($object); diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 5ecc4d7325a..665e43c6ffd 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -701,6 +701,7 @@ class Holiday extends CommonObject public function validate($user = null, $notrigger = 0) { global $conf, $langs; + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; $error = 0; // Define new ref @@ -740,6 +741,44 @@ class Holiday extends CommonObject } } + if (!$error) { + $this->oldref = $this->ref; + + // Rename directory if dir was a temporary ref + if (preg_match('/^[\(]?PROV/i', $this->ref)) { + // 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 = 'holiday/" . $this->db->escape($this->newref) . "'"; + $sql .= " WHERE filename LIKE '" . $this->db->escape($this->ref) . "%' AND filepath = 'holiday/" . $this->db->escape($this->ref) . "' and entity = " . ((int)$conf->entity); + $resql = $this->db->query($sql); + if (!$resql) { + $error++; + $this->error = $this->db->lasterror(); + } + + // 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->holiday->multidir_output[$this->entity] . '/' . $oldref; + $dirdest = $conf->holiday->multidir_output[$this->entity] . '/' . $newref; + if (!$error && file_exists($dirsource)) { + dol_syslog(get_class($this) . "::validate rename dir " . $dirsource . " into " . $dirdest); + if (@rename($dirsource, $dirdest)) { + dol_syslog("Rename ok"); + // Rename docs starting with $oldref with $newref + $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); + $dirsource = $fileentry['path'] . '/' . $dirsource; + $dirdest = $fileentry['path'] . '/' . $dirdest; + @rename($dirsource, $dirdest); + } + } + } + } + } + + // Commit or rollback if ($error) { foreach ($this->errors as $errmsg) { From 87b4805bc041237a87ab3da8788020a1306e40cf Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Fri, 22 Oct 2021 13:35:30 +0000 Subject: [PATCH 09/14] Fixing style errors. --- htdocs/holiday/card.php | 1 - htdocs/holiday/class/holiday.class.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/holiday/card.php b/htdocs/holiday/card.php index 93e748a51d2..150a9c0754b 100644 --- a/htdocs/holiday/card.php +++ b/htdocs/holiday/card.php @@ -266,7 +266,6 @@ if (empty($reshook)) { // If update and we are an approver, we can update with another approver if ($action == 'update' && GETPOSTISSET('savevalidator') && !empty($user->rights->holiday->approve)) { - $object->fetch($id); $object->oldcopy = dol_clone($object); diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index 665e43c6ffd..6271f1d43e8 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -748,7 +748,7 @@ class Holiday extends CommonObject if (preg_match('/^[\(]?PROV/i', $this->ref)) { // 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 = 'holiday/" . $this->db->escape($this->newref) . "'"; - $sql .= " WHERE filename LIKE '" . $this->db->escape($this->ref) . "%' AND filepath = 'holiday/" . $this->db->escape($this->ref) . "' and entity = " . ((int)$conf->entity); + $sql .= " WHERE filename LIKE '" . $this->db->escape($this->ref) . "%' AND filepath = 'holiday/" . $this->db->escape($this->ref) . "' and entity = " . ((int) $conf->entity); $resql = $this->db->query($sql); if (!$resql) { $error++; From 5275d3cd48411596ce600546c98e68ef7deadd67 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 23 Oct 2021 02:20:06 +0200 Subject: [PATCH 10/14] Fix #19083 : wrong field list in sql request --- htdocs/recruitment/recruitmentcandidature_list.php | 6 ++---- htdocs/recruitment/recruitmentjobposition_list.php | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/htdocs/recruitment/recruitmentcandidature_list.php b/htdocs/recruitment/recruitmentcandidature_list.php index 7a5a88bc6c4..30e147f355d 100644 --- a/htdocs/recruitment/recruitmentcandidature_list.php +++ b/htdocs/recruitment/recruitmentcandidature_list.php @@ -237,13 +237,11 @@ $title = $langs->trans('ListOfCandidatures'); // Build and execute select // -------------------------------------------------------------------- $sql = 'SELECT '; -foreach ($object->fields as $key => $val) { - $sql .= 't.'.$key.', '; -} +$sql .= $object->getFieldList('t'); // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? "ef.".$key.' as options_'.$key.', ' : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } } // Add fields from hooks diff --git a/htdocs/recruitment/recruitmentjobposition_list.php b/htdocs/recruitment/recruitmentjobposition_list.php index c82c8312b40..de4905aa337 100644 --- a/htdocs/recruitment/recruitmentjobposition_list.php +++ b/htdocs/recruitment/recruitmentjobposition_list.php @@ -243,10 +243,11 @@ $title = $langs->trans('ListOfPositionsToBeFilled'); // -------------------------------------------------------------------- $sql = 'SELECT '; $sql .= $object->getFieldList('t'); + // Add fields from extrafields if (!empty($extrafields->attributes[$object->table_element]['label'])) { foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val) { - $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key.', ' : ''); + $sql .= ($extrafields->attributes[$object->table_element]['type'][$key] != 'separate' ? ", ef.".$key.' as options_'.$key : ''); } } // Add fields from hooks From 604052d1a1bf4e80359fcac9489e74dfd4f4ae38 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Sat, 23 Oct 2021 02:28:53 +0200 Subject: [PATCH 11/14] Fix #19070 : Api subproducts was returning false --- htdocs/product/class/api_products.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 189161712d5..2d6c627ec41 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -405,7 +405,7 @@ class Products extends DolibarrApi $childsArbo = $this->product->getChildsArbo($id, 1); - $keys = ['rowid', 'qty', 'fk_product_type', 'label', 'incdec']; + $keys = ['rowid', 'qty', 'fk_product_type', 'label', 'incdec', 'ref']; $childs = []; foreach ($childsArbo as $values) { $childs[] = array_combine($keys, $values); From 452a8cfe18199dc81c80cd95cc667b4e9600bf80 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 23 Oct 2021 10:27:24 +0200 Subject: [PATCH 12/14] FIX wrong position of error message --- htdocs/societe/card.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php index 5c9c0f63e94..e5a624ec07f 100644 --- a/htdocs/societe/card.php +++ b/htdocs/societe/card.php @@ -2509,7 +2509,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { print ''; print ''; print showValueWithClipboardCPButton(dol_escape_htmltag($object->code_client)); - print ''; $tmpcheck = $object->check_codeclient(); if ($tmpcheck != 0 && $tmpcheck != -5) { print ' ('.$langs->trans("WrongCustomerCode").')'; From b027db49b505c4f85206ec763496c9bc47cdb607 Mon Sep 17 00:00:00 2001 From: Jean Date: Sat, 23 Oct 2021 22:21:50 +0200 Subject: [PATCH 13/14] FIX #18934 Non-registration in the extrafieldsline database for deliveries --- htdocs/delivery/card.php | 13 ++++++++---- htdocs/delivery/class/delivery.class.php | 27 ++++++++++++++++++------ 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php index a845b7aff95..67a80084710 100644 --- a/htdocs/delivery/card.php +++ b/htdocs/delivery/card.php @@ -114,7 +114,7 @@ if ($action == 'add') { $idl = "idl".$i; $qtytouse = price2num(GETPOST($qty)); if ($qtytouse > 0) { - $object->addline(GETPOST($idl), price2num($qtytouse)); + $object->addline(GETPOST($idl), price2num($qtytouse), $arrayoptions); } } @@ -603,7 +603,7 @@ if ($action == 'create') { // Create. Seems to no be used print ""; // Display lines extrafields - if (!empty($extrafields)) { + //if (!empty($extrafields)) { $colspan = 2; $mode = ($object->statut == 0) ? 'edit' : 'view'; @@ -618,8 +618,13 @@ if ($action == 'create') { // Create. Seems to no be used $object->lines[$i]->array_options = array_merge($object->lines[$i]->array_options, $srcLine->array_options); } - print $object->lines[$i]->showOptionals($extrafields, $mode, array('style' => 'class="oddeven"', 'colspan' => $colspan), $i); - } + else { + $srcLine = new DeliveryLine($db); + $extrafields->fetch_name_optionals_label($srcLine->table_element); + + } + print $object->lines[$i]->showOptionals($extrafields, $mode, array('style' => 'class="oddeven"', 'colspan' => $colspan), ''); + //} } $i++; diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 019187fca28..775cd96e2c3 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -211,7 +211,7 @@ class Delivery extends CommonObject $origin_id = $this->lines[$i]->commande_ligne_id; // For backward compatibility } - if (!$this->create_line($origin_id, $this->lines[$i]->qty, $this->lines[$i]->fk_product, $this->lines[$i]->description)) { + if (!$this->create_line($origin_id, $this->lines[$i]->qty, $this->lines[$i]->fk_product, $this->lines[$i]->description, $this->lines[$i]->array_options)) { $error++; } } @@ -264,7 +264,7 @@ class Delivery extends CommonObject * @param string $description Description * @return int <0 if KO, >0 if OK */ - public function create_line($origin_id, $qty, $fk_product, $description) + public function create_line($origin_id, $qty, $fk_product, $description, $array_options = 0) { // phpcs:enable $error = 0; @@ -282,6 +282,15 @@ class Delivery extends CommonObject if (!$this->db->query($sql)) { $error++; } + + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."deliverydet"); + + if (is_array($array_options) && count($array_options) > 0) { + $line = new DeliveryLine($this->db); + $line->id = $id; + $line->array_options = $array_options; + $result = $line->insertExtraFields(); + } if ($error == 0) { return 1; @@ -531,7 +540,9 @@ class Delivery extends CommonObject $line->description = $expedition->lines[$i]->description; $line->qty = $expedition->lines[$i]->qty_shipped; $line->fk_product = $expedition->lines[$i]->fk_product; - + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($expedition->lines[$i]->array_options) && count($expedition->lines[$i]->array_options) > 0) { // For avoid conflicts if trigger used + $line->array_options = $expedition->lines[$i]->array_options; + } $this->lines[$i] = $line; } @@ -593,14 +604,18 @@ class Delivery extends CommonObject * @param int $qty Qty * @return void */ - public function addline($origin_id, $qty) + public function addline($origin_id, $qty, $array_options = 0) { - $num = count($this->lines); + global $conf; + + $num = count($this->lines); $line = new DeliveryLine($this->db); $line->origin_id = $origin_id; $line->qty = $qty; - + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) { // For avoid conflicts if trigger used + $line->array_options = $array_options; + } $this->lines[$num] = $line; } From 53e9da4748bcf9a8493ad0a30a3cf5a471a11686 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Sat, 23 Oct 2021 20:37:07 +0000 Subject: [PATCH 14/14] Fixing style errors. --- htdocs/delivery/card.php | 22 ++++++++++------------ htdocs/delivery/class/delivery.class.php | 18 +++++++++--------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/htdocs/delivery/card.php b/htdocs/delivery/card.php index 67a80084710..ee41019d218 100644 --- a/htdocs/delivery/card.php +++ b/htdocs/delivery/card.php @@ -609,20 +609,18 @@ if ($action == 'create') { // Create. Seems to no be used $object->lines[$i]->fetch_optionals(); - if ($action == 'create_delivery') { - $srcLine = new ExpeditionLigne($db); + if ($action == 'create_delivery') { + $srcLine = new ExpeditionLigne($db); + $extrafields->fetch_name_optionals_label($srcLine->table_element); + $srcLine->id = $expedition->lines[$i]->id; + $srcLine->fetch_optionals(); + + $object->lines[$i]->array_options = array_merge($object->lines[$i]->array_options, $srcLine->array_options); + } else { + $srcLine = new DeliveryLine($db); $extrafields->fetch_name_optionals_label($srcLine->table_element); - $srcLine->id = $expedition->lines[$i]->id; - $srcLine->fetch_optionals(); - - $object->lines[$i]->array_options = array_merge($object->lines[$i]->array_options, $srcLine->array_options); - } - else { - $srcLine = new DeliveryLine($db); - $extrafields->fetch_name_optionals_label($srcLine->table_element); - - } + } print $object->lines[$i]->showOptionals($extrafields, $mode, array('style' => 'class="oddeven"', 'colspan' => $colspan), ''); //} } diff --git a/htdocs/delivery/class/delivery.class.php b/htdocs/delivery/class/delivery.class.php index 775cd96e2c3..dee6d021e17 100644 --- a/htdocs/delivery/class/delivery.class.php +++ b/htdocs/delivery/class/delivery.class.php @@ -282,14 +282,14 @@ class Delivery extends CommonObject if (!$this->db->query($sql)) { $error++; } - + $id = $this->db->last_insert_id(MAIN_DB_PREFIX."deliverydet"); - + if (is_array($array_options) && count($array_options) > 0) { - $line = new DeliveryLine($this->db); - $line->id = $id; - $line->array_options = $array_options; - $result = $line->insertExtraFields(); + $line = new DeliveryLine($this->db); + $line->id = $id; + $line->array_options = $array_options; + $result = $line->insertExtraFields(); } if ($error == 0) { @@ -541,7 +541,7 @@ class Delivery extends CommonObject $line->qty = $expedition->lines[$i]->qty_shipped; $line->fk_product = $expedition->lines[$i]->fk_product; if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($expedition->lines[$i]->array_options) && count($expedition->lines[$i]->array_options) > 0) { // For avoid conflicts if trigger used - $line->array_options = $expedition->lines[$i]->array_options; + $line->array_options = $expedition->lines[$i]->array_options; } $this->lines[$i] = $line; } @@ -608,13 +608,13 @@ class Delivery extends CommonObject { global $conf; - $num = count($this->lines); + $num = count($this->lines); $line = new DeliveryLine($this->db); $line->origin_id = $origin_id; $line->qty = $qty; if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && is_array($array_options) && count($array_options) > 0) { // For avoid conflicts if trigger used - $line->array_options = $array_options; + $line->array_options = $array_options; } $this->lines[$num] = $line; }