From bcc97f8b9f857b375a2fdcc1d4e9454153b30436 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 26 Sep 2023 23:49:21 +0200 Subject: [PATCH 1/6] 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 2/6] 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 3/6] 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 4/6] 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 5/6] 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 6/6] 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;