diff --git a/ChangeLog b/ChangeLog index 2e20e5a63a8..1c7e4933f98 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2021,6 +2021,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/comm/propal/card.php b/htdocs/comm/propal/card.php index de0b96cc1a8..7eb2cbedc9c 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -2168,9 +2168,12 @@ if ($action == 'create') { /* * Show object in view mode */ - - $soc = new Societe($db); - $soc->fetch($object->socid); + $object->fetch_thirdparty(); + if ($object->thirdparty) { + $soc = $object->thirdparty; + } else { + $soc = new Societe($db); + } $head = propal_prepare_head($object); print dol_get_fiche_head($head, 'comm', $langs->trans('Proposal'), -1, 'propal'); @@ -2420,9 +2423,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'.(isset($conf->global->THIRDPARTY_REF_INPUT_SIZE) ? ':'.$conf->global->THIRDPARTY_REF_INPUT_SIZE : ''), '', null, null, '', 1); // Thirdparty - $morehtmlref .= '
'.$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 (isModEnabled('project')) { diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 35894001394..ce0664c1f79 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -1943,6 +1943,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 96882f51d4f..5965ad514a2 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1152,6 +1152,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; diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php index a5dcad63ee9..a6227ef8ae4 100644 --- a/htdocs/core/class/commondocgenerator.class.php +++ b/htdocs/core/class/commondocgenerator.class.php @@ -1162,8 +1162,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); } /** diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 28703bdb3f3..fe04d8f931b 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1217,22 +1217,34 @@ abstract class CommonObject // phpcs:enable global $user; + $error = 0; $this->db->begin(); - $sql = "DELETE FROM ".$this->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 + $this->context['contact_id'] = ((int) $rowid); + $result = $this->call_trigger(strtoupper($this->element).'_DELETE_CONTACT', $user); + if ($result < 0) { + $error++; } + // End call triggers + } + if (!$error) { + dol_syslog(get_class($this)."::delete_contact", LOG_DEBUG); + + $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 { diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php index 56b02b41676..587f8fd0612 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 $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; diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 19862b2b4f2..cd8224e4567 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -2571,7 +2571,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)) { diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 63afff8e863..73ddde7d896 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3301,7 +3301,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/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index be71c10b169..5dbf7b179e7 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -2226,6 +2226,7 @@ class FactureFournisseur extends CommonInvoice $supplierinvoiceline->info_bits = $info_bits; $supplierinvoiceline->fk_remise_except = $fk_remise_except; + $supplierinvoiceline->special_code = ((string) $special_code != '' ? $special_code : $this->special_code); $supplierinvoiceline->fk_parent_line = $fk_parent_line; $supplierinvoiceline->origin = $this->origin; diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 2a395c6a390..7920b21cdd7 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -694,7 +694,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'); } } diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php index 55a7e606110..0258622e476 100644 --- a/htdocs/fourn/commande/list.php +++ b/htdocs/fourn/commande/list.php @@ -511,7 +511,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, @@ -1237,7 +1238,7 @@ if ($resql) { //var_dump($_REQUEST); print ''; - print ''; + print '
'; print ''; print ''; print '
'; print $langs->trans('DateInvoice'); @@ -1264,12 +1265,12 @@ if ($resql) { print '
'; - print '
'; print '
'; print ' '; print ''; print '
'; print '
'; + print '
'; } if ($sall) { 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; }