From 43a3783e79bc62ebc6088755ce35a287e4872e45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 20 Sep 2023 09:25:39 +0200 Subject: [PATCH 01/16] fix line rank in massaction supplier order to supplier invoice --- htdocs/fourn/commande/list.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 5560f251e6f..9ac77e0e17c 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -502,7 +502,8 @@ if (empty($reshook)) { $lines[$i]->info_bits, 'HT', $product_type, - $lines[$i]->rang, + // we dont use the rank from orderline because we may have lines from several orders + -1, false, $lines[$i]->array_options, $lines[$i]->fk_unit, From 97c77e611e4a8e7032aa3e17594cae6679be38c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 20 Sep 2023 11:15:42 +0200 Subject: [PATCH 02/16] Update list.php --- htdocs/fourn/commande/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 9ac77e0e17c..7b43cb93285 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -507,8 +507,8 @@ if (empty($reshook)) { false, $lines[$i]->array_options, $lines[$i]->fk_unit, - // we use the id of each order, not the id of the first one stored in $objecttmp->origin_id - $lines[$i]->fk_commande, + // we use the id of each orderline, not the id of the first one stored in $objecttmp->origin_id + $lines[$i]->id, $lines[$i]->pa_ht, $lines[$i]->ref_supplier, $lines[$i]->special_code, From 257a961a93c4dd33d7277baac1dfa37a5de3994d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 22 Sep 2023 02:32:23 +0200 Subject: [PATCH 03/16] Fix error management --- htdocs/core/class/commonobject.class.php | 2 +- htdocs/fourn/class/fournisseur.commande.class.php | 3 ++- htdocs/fourn/commande/card.php | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index b6c273cc54b..ce2f9a54bba 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -5535,7 +5535,7 @@ abstract class CommonObject if (in_array(get_class($this), array('Adherent'))) { $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, 'tmp_cards', $moreparams); } else { - $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams); + $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams); } // After call of write_file $obj->result['fullpath'] is set with generated file. It will be used to update the ECM database index. diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 7592012c83a..6ca9fc7415e 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3215,7 +3215,8 @@ class CommandeFournisseur extends CommonOrder $outputlangs->load("products"); $modelpath = "core/modules/supplier_order/doc/"; - return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + $result = $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams); + return $result; } } diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 252faba5954..000982f07b7 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -698,7 +698,7 @@ if (empty($reshook)) { $result = $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref); if ($result < 0) { - dol_print_error($db, $result); + setEventMessages($object->error, $object->errors, 'errors'); } } From 68f90319e0fbcf553041cb8d82dc4dedfacbc945 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 22 Sep 2023 03:24:48 +0200 Subject: [PATCH 04/16] Clean code --- htdocs/fourn/class/fournisseur.facture.class.php | 2 ++ htdocs/fourn/commande/list.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index e5c7c0097e5..9baa566768a 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2214,6 +2214,8 @@ class FactureFournisseur extends CommonInvoice $this->line->origin = $this->origin; $this->line->origin_id = $origin_id; $this->line->fk_unit = $fk_unit; + //var_dump($this->line->origin); + //var_dump($this->line->origin_id); // Multicurrency $this->line->fk_multicurrency = $this->fk_multicurrency; diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 5560f251e6f..541680dc1e3 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -1217,7 +1217,7 @@ if ($resql) { //var_dump($_REQUEST); print ''; - print ''; + print '
'; print ''; print ''; print '
'; print $langs->trans('DateInvoice'); @@ -1244,12 +1244,12 @@ if ($resql) { print '
'; - print '
'; print '
'; print ' '; print ''; print '
'; print '
'; + print '
'; } if ($sall) { From 058736a944594236832e2184415410a87f38eefc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 22 Sep 2023 08:58:27 +0200 Subject: [PATCH 05/16] Update list.php --- htdocs/fourn/commande/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 7b43cb93285..9ac77e0e17c 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -507,8 +507,8 @@ if (empty($reshook)) { false, $lines[$i]->array_options, $lines[$i]->fk_unit, - // we use the id of each orderline, not the id of the first one stored in $objecttmp->origin_id - $lines[$i]->id, + // we use the id of each order, not the id of the first one stored in $objecttmp->origin_id + $lines[$i]->fk_commande, $lines[$i]->pa_ht, $lines[$i]->ref_supplier, $lines[$i]->special_code, From 1543e68f096f03636e7eb5d99fe0f47b5b34c2d9 Mon Sep 17 00:00:00 2001 From: priojk Date: Fri, 22 Sep 2023 16:17:55 +0200 Subject: [PATCH 06/16] Fix: inventory card missing ability to add tabs --- htdocs/product/inventory/lib/inventory.lib.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/htdocs/product/inventory/lib/inventory.lib.php b/htdocs/product/inventory/lib/inventory.lib.php index 95bcfcd1fe5..a3534229246 100644 --- a/htdocs/product/inventory/lib/inventory.lib.php +++ b/htdocs/product/inventory/lib/inventory.lib.php @@ -68,10 +68,17 @@ function inventoryAdminPrepareHead() */ function inventoryPrepareHead(&$inventory, $title = 'Inventory', $get = '') { - global $langs; + global $langs, $conf; - return array( + $head = array( array(dol_buildpath('/product/inventory/card.php?id='.$inventory->id.$get, 1), $langs->trans('Card'), 'card'), array(dol_buildpath('/product/inventory/inventory.php?id='.$inventory->id.$get, 1), $langs->trans('Inventory'), 'inventory') ); + + $h=2; + + complete_head_from_modules($conf, $langs, $inventory, $head, $h, 'inventory'); + complete_head_from_modules($conf, $langs, $inventory, $head, $h, 'inventory', 'remove'); + + return $head; } From eed96efc9b694957695b2ffdbd716716d995bff6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 26 Sep 2023 13:04:03 +0200 Subject: [PATCH 07/16] Add log to try to debug trouble with triggers --- htdocs/core/class/interfaces.class.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index d069bb0da23..f983d487883 100644 --- a/htdocs/core/class/interfaces.class.php +++ b/htdocs/core/class/interfaces.class.php @@ -68,6 +68,12 @@ class Interfaces public function run_triggers($action, $object, $user, $langs, $conf) { // phpcs:enable + + if (getDolGlobalInt('MAIN_TRIGGER_DEBUG')) { + // This his too much verbose, enabled if const enabled only + dol_syslog(get_class($this)."::run_triggers action=".$action." Launch run_triggers", LOG_DEBUG); + } + // Check parameters if (!is_object($object) || !is_object($conf)) { // Error $this->error = 'function run_triggers called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf); @@ -82,7 +88,6 @@ class Interfaces dol_syslog(get_class($this).'::run_triggers was called with wrong parameters action='.$action.' object='.is_object($object).' user='.is_object($user).' langs='.is_object($langs).' conf='.is_object($conf), LOG_WARNING); $user = new User($this->db); } - //dol_syslog(get_class($this)."::run_triggers action=".$action." Launch run_triggers", LOG_DEBUG); $nbfile = $nbtotal = $nbok = $nbko = 0; From bcc97f8b9f857b375a2fdcc1d4e9454153b30436 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 26 Sep 2023 23:49:21 +0200 Subject: [PATCH 08/16] FIX wrong place of trigger delete --- htdocs/core/class/commonobject.class.php | 31 +++++++++++++++--------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 58a057834f8..ee69aa6b313 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1170,22 +1170,31 @@ abstract class CommonObject // phpcs:enable global $user; + $error = 0; $this->db->begin(); - $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; - $sql .= " WHERE rowid = ".((int) $rowid); - - dol_syslog(get_class($this)."::delete_contact", LOG_DEBUG); - if ($this->db->query($sql)) { - if (!$notrigger) { - $result = $this->call_trigger(strtoupper($this->element).'_DELETE_CONTACT', $user); - if ($result < 0) { - $this->db->rollback(); - return -1; - } + if (!$error && empty($notrigger)) { + // Call trigger + $result = $this->call_trigger(strtoupper($this->element).'_DELETE_CONTACT', $user); + if ($result < 0) { + $error++; } + // End call triggers + } + if (!$error) { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; + $sql .= " WHERE rowid = ".((int) $rowid); + + $result = $this->db->query($sql); + if (!$result) { + $error++; + $this->errors[] = $this->db->lasterror(); + } + } + + if (!$error) { $this->db->commit(); return 1; } else { From 19e2f0c75c47e0ac495e41980015d76ae4d40b26 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 27 Sep 2023 08:54:54 +0200 Subject: [PATCH 09/16] FIX missing contact_id for the trigger --- htdocs/core/class/commonobject.class.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index ee69aa6b313..0e980e4b05d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1172,6 +1172,8 @@ abstract class CommonObject $error = 0; + $this->context['contact_id'] = ((int) $rowid); + $this->db->begin(); if (!$error && empty($notrigger)) { @@ -1184,6 +1186,8 @@ abstract class CommonObject } if (!$error) { + dol_syslog(get_class($this)."::delete_contact", LOG_DEBUG); + $sql = "DELETE FROM ".MAIN_DB_PREFIX."element_contact"; $sql .= " WHERE rowid = ".((int) $rowid); From 9eb4c93c1cbde92c778f4187f18f8b5dd3dd798d Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Wed, 27 Sep 2023 09:44:58 +0200 Subject: [PATCH 10/16] FIX add warning in the changelog --- ChangeLog | 2 ++ htdocs/core/class/commonobject.class.php | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a0091c2c42a..f9ef3ac25b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -512,6 +512,8 @@ Following changes may create regressions for some external modules, but were nec * v14 seems to work correctly on PHP v8 but it generates a lot of verbose warnings. Currently, v14 i snot yet officialy supported with PHP 8. * To execute shell or command line command, your code must never use method like exec, shell_exec, popen, .. but must use the built-in method executeCLI() available into core/class/utils.class.php +* the trigger "*_DELETE_CONTACT" inside "delete_contact()" function from commonobject.class.php is call before delete the object element + and a $object->context['contact_id'] is now available for this trigger ***** ChangeLog for 13.0.5 compared to 13.0.4 ***** diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 0e980e4b05d..72603fdca95 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1172,12 +1172,11 @@ abstract class CommonObject $error = 0; - $this->context['contact_id'] = ((int) $rowid); - $this->db->begin(); if (!$error && empty($notrigger)) { // Call trigger + $this->context['contact_id'] = ((int) $rowid); $result = $this->call_trigger(strtoupper($this->element).'_DELETE_CONTACT', $user); if ($result < 0) { $error++; From afe71305fadaaaa71d8f13606847d06848ca0d6c Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Wed, 27 Sep 2023 12:15:44 +0200 Subject: [PATCH 11/16] FIX thirdparty object in proposal card is not loaded --- htdocs/comm/propal/card.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index e575195799c..10ada40f820 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1895,6 +1895,7 @@ if ($action == 'create') { $soc = new Societe($db); $soc->fetch($object->socid); + $object->fetch_thirdparty(); $head = propal_prepare_head($object); print dol_get_fiche_head($head, 'comm', $langs->trans('Proposal'), -1, 'propal'); From 2980d90bdda26281945f78fe762ce1bf4e7a5ae6 Mon Sep 17 00:00:00 2001 From: VESSILLER Date: Thu, 28 Sep 2023 08:49:13 +0200 Subject: [PATCH 12/16] Fix load thirdparty object once time --- htdocs/comm/propal/card.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 10ada40f820..3a2424f55e3 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -1892,10 +1892,8 @@ if ($action == 'create') { /* * Show object in view mode */ - - $soc = new Societe($db); - $soc->fetch($object->socid); $object->fetch_thirdparty(); + $soc = $object->thirdparty; $head = propal_prepare_head($object); print dol_get_fiche_head($head, 'comm', $langs->trans('Proposal'), -1, 'propal'); @@ -1994,9 +1992,9 @@ if ($action == 'create') { $morehtmlref .= $form->editfieldkey("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', 0, 1); $morehtmlref .= $form->editfieldval("RefCustomer", 'ref_client', $object->ref_client, $object, $usercancreate, 'string', '', null, null, '', 1); // Thirdparty - $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$object->thirdparty->getNomUrl(1, 'customer'); - if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $object->thirdparty->id > 0) { - $morehtmlref .= ' ('.$langs->trans("OtherProposals").')'; + $morehtmlref .= '
'.$langs->trans('ThirdParty').' : '.$soc->getNomUrl(1, 'customer'); + if (empty($conf->global->MAIN_DISABLE_OTHER_LINK) && $soc->id > 0) { + $morehtmlref .= ' ('.$langs->trans("OtherProposals").')'; } // Project if (!empty($conf->projet->enabled)) { From ad188c98044b9bea24057b126234d45f21245caa Mon Sep 17 00:00:00 2001 From: Quentin VIAL-GOUTEYRON Date: Fri, 29 Sep 2023 14:38:30 +0200 Subject: [PATCH 13/16] FIX missing fk_account situation invoice --- htdocs/compta/facture/card.php | 2 ++ htdocs/compta/facture/class/facture.class.php | 1 + 2 files changed, 3 insertions(+) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 77bd654147d..0cd79962e57 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1895,6 +1895,8 @@ if (empty($reshook)) { $object->mode_reglement_id = GETPOST('mode_reglement_id', 'int'); $object->remise_absolue =price2num(GETPOST('remise_absolue'), 'MU', 2); $object->remise_percent = price2num(GETPOST('remise_percent'), '', 2); + $object->fk_account = GETPOST('fk_account', 'int'); + // Proprietes particulieres a facture de remplacement diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ec36314c999..e95704832bb 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1147,6 +1147,7 @@ class Facture extends CommonInvoice $facture->origin = $this->origin; $facture->origin_id = $this->origin_id; + $facture->fk_account = $this->fk_account; $facture->lines = $this->lines; // Array of lines of invoice $facture->situation_counter = $this->situation_counter; From 7d69ea717b1fede476b3b9ca627db852bf3198e8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 30 Sep 2023 11:37:53 +0200 Subject: [PATCH 14/16] FIX avoid php8 warning --- htdocs/core/class/commondocgenerator.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index 76e104be4ea..70f859dd487 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1164,8 +1164,8 @@ abstract class CommonDocGenerator */ public function getColumnContentXStart($colKey) { - $colDef = $this->cols[$colKey]; - return (isset($colDef['xStartPos']) ? $colDef['xStartPos'] : 0) + $colDef['content']['padding'][3]; + $colDef = (isset($this->cols[$colKey]) ? $this->cols[$colKey] : null); + return (is_array($colDef) ? ((isset($colDef['xStartPos']) ? $colDef['xStartPos'] : 0) + $colDef['content']['padding'][3]) : 0); } /** From a0c1553420145581ffe95ea8e4d2fdeb3e252cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Champlon?= <85104766+Kazimir42@users.noreply.github.com> Date: Fri, 29 Sep 2023 09:30:08 +0200 Subject: [PATCH 15/16] Fix order on saving inventory --- htdocs/product/inventory/inventory.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/product/inventory/inventory.php b/htdocs/product/inventory/inventory.php index 8f595abcc53..a275847b9d3 100644 --- a/htdocs/product/inventory/inventory.php +++ b/htdocs/product/inventory/inventory.php @@ -265,6 +265,7 @@ if (empty($reshook)) { $sql .= ' id.fk_product, id.batch, id.qty_stock, id.qty_view, id.qty_regulated'; $sql .= ' FROM '.MAIN_DB_PREFIX.'inventorydet as id'; $sql .= ' WHERE id.fk_inventory = '.((int) $object->id); + $sql .= $db->order('id.rowid', 'ASC'); $sql .= $db->plimit($limit, $offset); $db->begin(); From 6e27a6517a05de3c597dec05c35417136f83f296 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 1 Oct 2023 03:19:34 +0200 Subject: [PATCH 16/16] FIX avoid excess line breaks --- htdocs/core/lib/functions.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 289d4e227a9..2a89b730be4 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2565,7 +2565,7 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs // See format of addresses on https://en.wikipedia.org/wiki/Address // Address if (empty($mode)) { - $ret .= ($extralangcode ? $object->array_languages['address'][$extralangcode] : (empty($object->address) ? '' : preg_replace('/[\n\r]/', $sep, $object->address))); + $ret .= ($extralangcode ? $object->array_languages['address'][$extralangcode] : (empty($object->address) ? '' : preg_replace('/(\r\n|\r|\n)+/', $sep, $object->address))); } // Zip/Town/State if (isset($object->country_code) && in_array($object->country_code, array('AU', 'CA', 'US', 'CN')) || !empty($conf->global->MAIN_FORCE_STATE_INTO_ADDRESS)) {