From a1c31310a28e16047741fc2b7b902a4f27d4ee92 Mon Sep 17 00:00:00 2001 From: atm-GregM <85485123+atm-GregM@users.noreply.github.com> Date: Tue, 1 Apr 2025 20:35:34 +0200 Subject: [PATCH 1/2] Add Massactions Validate/Cancel/RegeneratePDF/MergePDF/EditStartDate/EditeEndDate on Mo List (#33548) * Add Massaction Mo List * add langs en_US * fix for precommit * langs * langs+ * int param * space * Update mo_list.php --------- Co-authored-by: Laurent Destailleur --- htdocs/langs/en_US/main.lang | 1 + htdocs/langs/en_US/mrp.lang | 18 +++++ htdocs/langs/fr_FR/main.lang | 1 + htdocs/langs/fr_FR/mrp.lang | 19 +++++ htdocs/mrp/mo_list.php | 136 ++++++++++++++++++++++++++++++++++- 5 files changed, 172 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 1c3260c1e7b..7f81114e55f 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -931,6 +931,7 @@ MassFilesArea=Area for files built by mass actions ShowTempMassFilesArea=Show area of files built by mass actions ConfirmMassDeletion=Bulk Delete confirmation ConfirmMassDeletionQuestion=Are you sure you want to delete the %s selected record(s)? +ConfirmMassCancellationQuestion = Are you sure you want to cancel the %s selected record(s)? ConfirmMassClone=Bulk clone confirmation ConfirmMassCloneQuestion=Select project to clone to ConfirmMassCloneToOneProject=Clone to project %s diff --git a/htdocs/langs/en_US/mrp.lang b/htdocs/langs/en_US/mrp.lang index 68fd785c460..3b001370270 100644 --- a/htdocs/langs/en_US/mrp.lang +++ b/htdocs/langs/en_US/mrp.lang @@ -147,3 +147,21 @@ NoRemainQtyToDispatch=No quantity remaining to divide THMOperatorEstimatedHelp=Estimated cost of operator per hour. Will be used to estimate cost of a BOM using this workstation. THMMachineEstimatedHelp=Estimated cost of machine per hour. Will be used to estimate cost of a BOM using this workstation. BadValueForquantityToConsume=Quantity to consume for a material cannot be 0 or negative +NoValidatedStatusMo = Manufacturing order %s cannot be canceled because it is not validated +CancelMoValidated = Manufacturing order %s canceled +ErrorObjectMustHaveStatusValidatedToBeCanceled = The object %s must have the 'Validated' status to be canceled +ErrorObjectMustHaveStatusDraftToModifyDate = The object %s must have the 'Draft' status to be modified +MoChangeDateStart = Modify start date +MoChangeDateEnd = Modify end date +ConfirmMassChangeDateStart = Confirmation of mass modification of the planned start date +ConfirmMassChangeDateStartQuestion = Are you sure you want to modify the %s selected record(s)? +ConfirmMassChangeDateEndQuestion = Are you sure you want to modify the %s selected record(s)? +ModifyDateStart = New planned start date +ModifyDateEnd = New planned end date +ModifyMoDate = Date modification validated for %s +ErrorEmptyChangeDate = Please define a date +ConfirmMassChangeDateEnd = Confirmation of mass modification of the planned end date +ErrorModifyMoDateStart = You must choose a start date earlier than the current start date. %s +ErrorModifyMoDateEnd = You must choose an end date later than the start date. %s +ErrorCancelMo=Error updating cancellation +ErrorModifyMoDate=Error updating date modification diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 60d23a09d72..09d20134b9a 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -929,6 +929,7 @@ MassFilesArea=Zone des fichiers générés en masse ShowTempMassFilesArea=Afficher la zone des fichiers générés en masse ConfirmMassDeletion=Confirmation de suppression en masse ConfirmMassDeletionQuestion=Êtes-vous sur de vouloir supprimer les %s enregistrement(s) sélectionné(s) ? +ConfirmMassCancellationQuestion=Êtes-vous sûr de vouloir annuler les %s enregistrement(s) sélectionné(s) ? ConfirmMassClone=Confirmation de clonage en masse ConfirmMassCloneQuestion=Sélectionner le projet vers lequel cloner ConfirmMassCloneToOneProject=Cloner vers le projet %s diff --git a/htdocs/langs/fr_FR/mrp.lang b/htdocs/langs/fr_FR/mrp.lang index 190103e277a..1f132c98471 100644 --- a/htdocs/langs/fr_FR/mrp.lang +++ b/htdocs/langs/fr_FR/mrp.lang @@ -146,3 +146,22 @@ NoRemainQtyToDispatch=Aucune quantité restant à fractionner THMOperatorEstimatedHelp=Coût estimé de l'opérateur par heure. Sera utilisé pour estimer le coût d'une nomenclature utilisant ce poste de travail. THMMachineEstimatedHelp=Coût estimé de la machine par heure. Sera utilisé pour estimer le coût d'une nomenclature utilisant ce poste de travail. BadValueForquantityToConsume=La quantité à consommer pour un matériau ne peut pas être 0 ou négative +NoValidatedStatusMo = Ordre de fabrication %s ne peut être annulé car il n'est pas validé +CancelMoValidated = Ordre de fabrication %s annulé +ErrorObjectMustHaveStatusValidatedToBeCanceled=L'objet %s doit être au statut 'Validé' pour être annulé +ErrorObjectMustHaveStatusDraftToModifyDate=L'objet %s doit être au statut 'Brouillon' pour être modifié +MoChangeDateStart = Modifier date de début +MoChangeDateEnd = Modifier date de fin +ConfirmMassChangeDateStart=Confirmation de modification de la date de début prévue en masse +ConfirmMassChangeDateStartQuestion=Êtes-vous sur de vouloir modifier les %s enregistrement(s) sélectionné(s) ? +ConfirmMassChangeDateEndQuestion=Êtes-vous sur de vouloir modifier les %s enregistrement(s) sélectionné(s) ? +ModifyDateStart=Nouvelle date de début prévue +ModifyDateEnd=Nouvelle date de fin prévue +ModifyMoDate=Modification de date validé pour %s +ErrorEmptyChangeDate= Veuillez définir une date +ConfirmMassChangeDateEnd=Confirmation de modification de la date de fin prévue en masse +ErrorModifyMoDateStart=Vous devez choisir une date de début inférieur à la date de début. %s +ErrorModifyMoDateEnd=Vous devez choisir une date de fin supérieur à la date de début. %s +ErrorCancelMo=Erreur lors de la mise à jour de l'annulation +ErrorModifyMoDate=Erreur lors de la mise à jour de la modification de la date. + diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php index da3b60f5033..57e47ff3ad9 100644 --- a/htdocs/mrp/mo_list.php +++ b/htdocs/mrp/mo_list.php @@ -66,6 +66,16 @@ $limit = GETPOSTINT('limit') ? GETPOSTINT('limit') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'aZ09comma'); $sortorder = GETPOST('sortorder', 'aZ09comma'); $page = GETPOSTISSET('pageplusone') ? (GETPOSTINT('pageplusone') - 1) : GETPOSTINT("page"); +$also_cancel_consumed_and_produced_lines = (GETPOST('alsoCancelConsumedAndProducedLines', 'alpha') ? 1 : 0); +$changeDate = GETPOST('change_date', 'alpha'); + +//Data request for date +$year = GETPOST('change_dateyear', 'int'); +$month = GETPOST('change_datemonth', 'int'); +$day = GETPOST('change_dateday', 'int'); +$hour = GETPOST('change_datehour', 'int'); +$min = GETPOST('change_datemin', 'int'); + if (empty($page) || $page < 0 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // If $page is not defined, or '' or -1 or if we click on clear filters $page = 0; @@ -207,6 +217,74 @@ if (empty($reshook)) { $objectlabel = 'Mo'; $uploaddir = $conf->mrp->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + $objMo = new Mo($db); + + if ($action == 'confirm_cancel' && $confirm == 'yes' && $permissiontoadd) { + if (!empty($toselect)) { + foreach ($toselect as $key => $idMo) { + if ($objMo->fetch($idMo)) { + if ($objMo->status == Mo::STATUS_VALIDATED || $objMo->status == Mo::STATUS_INPROGRESS) { + if ($also_cancel_consumed_and_produced_lines) { + if ($objMo->cancelConsumedAndProducedLines($user, 0, true, 1)) { + $objMo->status = Mo::STATUS_CANCELED; + } + } else { + $objMo->status = Mo::STATUS_CANCELED; + } + if ($objMo->update($user)) { + setEventMessages($langs->trans('CancelMoValidated', $objMo->ref), null, 'mesgs'); + } else { + setEventMessages($langs->trans('ErrorCancelMo', $objMo->ref), null, 'errors'); + } + } else { + setEventMessages($langs->trans('ErrorObjectMustHaveStatusValidatedToBeCanceled', $objMo->ref), null, 'errors'); + } + } + } + } + } + + if (($action == 'changedatestart_confirm' || $action == 'changedateend_confirm') && $permissiontoadd) { + if ($confirm == 'yes') { + $newDate = dol_mktime((int) $hour, (int) $min, (int) 0, (int) $month, (int) $day, (int) $year); + + if (!empty($toselect)) { + foreach ($toselect as $key => $idMo) { + if ($objMo->fetch($idMo)) { + if ($objMo->status == Mo::STATUS_DRAFT) { + if (!empty($changeDate)) { + if ($action == 'changedatestart_confirm') { + if ($newDate < $objMo->date_end_planned) { + $objMo->date_start_planned = $newDate; + } else { + setEventMessages($langs->trans('ErrorModifyMoDateStart', $objMo->ref), null, 'errors'); + break; + } + } elseif ($action == 'changedateend_confirm') { + if ($newDate > $objMo->date_start_planned) { + $objMo->date_end_planned = $newDate; + } else { + setEventMessages($langs->trans('ErrorModifyMoDateEnd', $objMo->ref), null, 'errors'); + break; + } + } + if ($objMo->update($user)) { + setEventMessages($langs->trans('ModifyMoDate', $objMo->ref), null, 'mesgs'); + } else { + setEventMessages($langs->trans('ErrorModifyMoDate', $objMo->ref), null, 'errors'); + } + } else { + setEventMessages($langs->trans('ErrorEmptyChangeDate'), null, 'errors'); + break; + } + } else { + setEventMessages($langs->trans('ErrorObjectMustHaveStatusDraftToModifyDate', $objMo->ref), null, 'errors'); + } + } + } + } + } + } } @@ -418,9 +496,12 @@ $param .= $hookmanager->resPrint; // List of mass actions available $arrayofmassactions = array( - //'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"), - //'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), - //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), + 'validate'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Validate"), + 'precancel'=>img_picto('', 'close_title', 'class="pictofixedwidth"').$langs->trans("Cancel"), + 'generate_doc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("ReGeneratePDF"), + 'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), + 'predatestart'=>img_picto('', 'object_calendar', 'class="pictofixedwidth"').$langs->trans("MoChangeDateStart"), + 'predateend'=>img_picto('', 'object_calendar', 'class="pictofixedwidth"').$langs->trans("MoChangeDateEnd"), //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), ); if (!empty($permissiontodelete)) { @@ -460,6 +541,55 @@ $objecttmp = new Mo($db); $trackid = 'mo'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; +if ($massaction == 'precancel') { + $formquestion = array( + array( + 'label' => $langs->trans('MoCancelConsumedAndProducedLines'), + 'name' => 'alsoCancelConsumedAndProducedLines', + 'type' => 'checkbox', + 'value' => 0 + ), + ); + + print $formconfirm = $form->formconfirm($_SERVER['PHP_SELF'], + $langs->trans('CancelMo'), + $langs->trans('ConfirmCancelMo'), + 'confirm_cancel', $formquestion, + 1, 0, 200, 500, 1); +} + +if ($massaction == 'predatestart') { + $formquestion = array( + array( + 'type' => 'datetime', + 'tdclass' => 'fieldrequired', + 'name' => 'change_date', + 'label' => $langs->trans('ModifyDateStart'), + 'value' => -1), + ); + print $form->formconfirm($_SERVER['PHP_SELF'], + $langs->trans('ConfirmMassChangeDateStart'), + $langs->trans('ConfirmMassChangeDateStartQuestion', + count($toselect)), 'changedatestart_confirm', $formquestion, + '', 0, 200, 500, 1); +} + +if ($massaction == 'predateend') { + $formquestion = array( + array( + 'type' => 'datetime', + 'tdclass' => 'fieldrequired', + 'name' => 'change_date', + 'label' => $langs->trans('ModifyDateEnd'), + 'value' => -1), + ); + print $form->formconfirm($_SERVER['PHP_SELF'], + $langs->trans('ConfirmMassChangeDateEnd'), + $langs->trans('ConfirmMassChangeDateEndQuestion', + count($toselect)), 'changedateend_confirm', $formquestion, + '', 0, 200, 500, 1); +} + if ($search_all) { foreach ($fieldstosearchall as $key => $val) { $fieldstosearchall[$key] = $langs->trans($val); From 387e3b1da7a73383ae13de917787b53a0c51da86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 1 Apr 2025 20:47:40 +0200 Subject: [PATCH 2/2] shipping can manage its contacts (#33680) * shipping can manage its contacts * shipping can manage its contacts * fix * add contacts from origin * clean code * apply changes * apply changes --- htdocs/commande/card.php | 5 +- htdocs/core/class/commonobject.class.php | 2 +- htdocs/core/lib/sendings.lib.php | 12 +++-- htdocs/core/tpl/contacts.tpl.php | 6 +-- htdocs/expedition/class/expedition.class.php | 48 +++++++++++++------ htdocs/expedition/contact.php | 7 +-- htdocs/expedition/dispatch.php | 4 +- htdocs/expedition/index.php | 4 +- htdocs/expedition/shipment.php | 12 ++--- .../doc/pdf_standard_myobject.modules.php | 2 +- 10 files changed, 63 insertions(+), 39 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 44682e1d45f..d38a4dfc0ae 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -390,11 +390,12 @@ if (empty($reshook)) { $element = $subelement = 'contrat'; } - $object->origin = $origin; + $object->origin = $origin; // deprecated + $object->origin_type = $origin; $object->origin_id = $originid; // Possibility to add external linked objects with hooks - $object->linked_objects [$object->origin] = $object->origin_id; + $object->linked_objects [$object->origin_type] = $object->origin_id; $other_linked_objects = GETPOST('other_linked_objects', 'array'); if (!empty($other_linked_objects)) { $object->linked_objects = array_merge($object->linked_objects, $other_linked_objects); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index cc9bde1ce21..de8e173855d 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1794,7 +1794,7 @@ abstract class CommonObject $result = array(); $i = 0; // Particular case for shipping - if ($this->element == 'shipping' && $this->origin_id != 0) { + if (!getDolGlobalInt('SHIPPING_USE_ITS_OWN_CONTACTS') && $this->element == 'shipping' && $this->origin_id != 0) { $id = $this->origin_id; $element = 'commande'; } elseif ($this->element == 'reception' && $this->origin_id != 0) { diff --git a/htdocs/core/lib/sendings.lib.php b/htdocs/core/lib/sendings.lib.php index a10a8805a3e..2d787cda10e 100644 --- a/htdocs/core/lib/sendings.lib.php +++ b/htdocs/core/lib/sendings.lib.php @@ -2,6 +2,7 @@ /* Copyright (C) 2008-2012 Laurent Destailleur * Copyright (C) 2012 Regis Houssin * Copyright (C) 2024-2025 MDW + * Copyright (C) 2025 Frédéric France * * 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 @@ -48,7 +49,7 @@ function shipping_prepare_head($object) $head[$h][2] = 'shipping'; $h++; - if ($object->statut == Expedition::STATUS_DRAFT) { + if ($object->status == Expedition::STATUS_DRAFT) { $head[$h][0] = DOL_URL_ROOT."/expedition/dispatch.php?id=".$object->id; $head[$h][1] = $langs->trans("ShipmentDistribution"); $head[$h][2] = 'dispatch'; @@ -71,7 +72,7 @@ function shipping_prepare_head($object) if (!getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) { $objectsrc = $object; - if ($object->origin == 'commande' && $object->origin_id > 0) { + if (!getDolGlobalInt('SHIPPING_USE_ITS_OWN_CONTACTS') && $object->origin_type == 'commande' && $object->origin_id > 0) { $objectsrc = new Commande($db); $objectsrc->fetch($object->origin_id); } @@ -128,7 +129,7 @@ function shipping_prepare_head($object) /** * Prepare array with list of tabs * - * @param Object $object Object related to tabs + * @param Delivery $object Object related to tabs * @return array Array of tabs to show */ function delivery_prepare_head($object) @@ -163,7 +164,7 @@ function delivery_prepare_head($object) // Get parent object $tmpobject = null; - if ($object->origin) { + if ($object->origin_type) { $tmpobject = new Expedition($db); $tmpobject->fetch($object->origin_id); } else { @@ -172,7 +173,7 @@ function delivery_prepare_head($object) if (!getDolGlobalString('MAIN_DISABLE_CONTACTS_TAB')) { $objectsrc = $tmpobject; - if ($tmpobject->origin == 'commande' && $tmpobject->origin_id > 0) { + if ($tmpobject->origin_type == 'commande' && $tmpobject->origin_id > 0) { $objectsrc = new Commande($db); $objectsrc->fetch($tmpobject->origin_id); } @@ -454,6 +455,7 @@ function show_list_sending_receive($origin, $origin_id, $filter = '') } if (!empty($receiving)) { + /** @var Delivery $receiving */ '@phan-var-force Delivery $receiving'; // $expedition->fk_elementdet = id of det line of order // $receiving->fk_origin_line = id of det line of order diff --git a/htdocs/core/tpl/contacts.tpl.php b/htdocs/core/tpl/contacts.tpl.php index 23a33ba546d..28c352963a0 100644 --- a/htdocs/core/tpl/contacts.tpl.php +++ b/htdocs/core/tpl/contacts.tpl.php @@ -156,7 +156,7 @@ if ($permission) {
element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) { + if (((!getDolGlobalInt('SHIPPING_USE_ITS_OWN_CONTACTS') && $object->element == 'shipping') || $object->element == 'reception') && is_object($objectsrc)) { $tmpobject = $objectsrc; } $formcompany->selectTypeContact($tmpobject, '', 'type', 'internal', 'position', 0, 'minwidth150imp widthcentpercentminusx maxwidth200'); ?>
@@ -201,7 +201,7 @@ if ($permission) {
element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) { + if (((!getDolGlobalInt('SHIPPING_USE_ITS_OWN_CONTACTS') && $object->element == 'shipping') || $object->element == 'reception') && is_object($objectsrc)) { '@phan-var-force Commande|Facture $objectsrc'; $tmpobject = $objectsrc; } @@ -230,7 +230,7 @@ if ($permission) { // TODO: replace this with 1 single direct SQL (for both internal and external string to use $db->sort($sortfield, $sortorder) $list = array(); foreach (array('internal', 'external') as $source) { - if (($object->element == 'shipping' || $object->element == 'reception') && is_object($objectsrc)) { + if (((!getDolGlobalInt('SHIPPING_USE_ITS_OWN_CONTACTS') && $object->element == 'shipping') || $object->element == 'reception') && is_object($objectsrc)) { '@phan-var-force Commande|Facture $objectsrc'; $contactlist = $objectsrc->liste_contact(-1, $source); } else { diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 3403e9d1612..b8111939c2f 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -517,6 +517,23 @@ class Expedition extends CommonObject } } + if (!$error && $this->id && getDolGlobalInt('SHIPPING_USE_ITS_OWN_CONTACTS') && getDolGlobalString('MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN') && !empty($this->origin_type) && !empty($this->origin_id)) { // Get contact from origin object + $originforcontact = $this->origin_type; + $originidforcontact = $this->origin_id; + + $sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc"; + $sqlcontact .= " WHERE element_id = ".((int) $originidforcontact)." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$this->db->escape($originforcontact)."'"; + + $resqlcontact = $this->db->query($sqlcontact); + if ($resqlcontact) { + while ($objcontact = $this->db->fetch_object($resqlcontact)) { + $this->add_contact($objcontact->fk_socpeople, $objcontact->code, $objcontact->source); // May failed because of duplicate key or because code of contact type does not exists for new object + } + } else { + dol_print_error($this->db); + } + } + // Actions on extra fields if (!$error) { $result = $this->insertExtraFields(); @@ -949,7 +966,7 @@ class Expedition extends CommonObject global $conf; if (getDolGlobalInt('MAIN_SUBMODULE_DELIVERY')) { - if ($this->statut == self::STATUS_VALIDATED || $this->statut == self::STATUS_CLOSED) { + if ($this->status == self::STATUS_VALIDATED || $this->status == self::STATUS_CLOSED) { // Expedition validee include_once DOL_DOCUMENT_ROOT.'/delivery/class/delivery.class.php'; $delivery = new Delivery($this->db); @@ -1172,6 +1189,9 @@ class Expedition extends CommonObject if (isset($this->statut)) { $this->statut = (int) $this->statut; } + if (isset($this->status)) { + $this->status = (int) $this->status; + } if (isset($this->trueDepth)) { $this->trueDepth = trim($this->trueDepth); } @@ -1221,7 +1241,7 @@ class Expedition extends CommonObject $sql .= " fk_address = ".(isset($this->fk_delivery_address) ? $this->fk_delivery_address : "null").","; $sql .= " fk_shipping_method = ".((isset($this->shipping_method_id) && $this->shipping_method_id > 0) ? $this->shipping_method_id : "null").","; $sql .= " tracking_number = ".(isset($this->tracking_number) ? "'".$this->db->escape($this->tracking_number)."'" : "null").","; - $sql .= " fk_statut = ".(isset($this->statut) ? $this->statut : "null").","; + $sql .= " fk_statut = ".(isset($this->status) ? $this->status : "null").","; $sql .= " fk_projet = ".(isset($this->fk_project) ? $this->fk_project : "null").","; $sql .= " height = ".(($this->trueHeight != '') ? $this->trueHeight : "null").","; $sql .= " width = ".(($this->trueWidth != '') ? $this->trueWidth : "null").","; @@ -1312,8 +1332,8 @@ class Expedition extends CommonObject // Stock control if (!$error && isModEnabled('stock') && - ((getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT') && $this->statut > self::STATUS_DRAFT) || - (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE') && $this->statut == self::STATUS_CLOSED && $also_update_stock))) { + ((getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT') && $this->status > self::STATUS_DRAFT) || + (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE') && $this->status == self::STATUS_CLOSED && $also_update_stock))) { require_once DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"; $langs->load("agenda"); @@ -1412,7 +1432,7 @@ class Expedition extends CommonObject $this->fetch_origin(); $origin_object = $this->origin_object; '@phan-var-force Facture|Commande $origin_object'; - if ($origin_object->statut == Commande::STATUS_SHIPMENTONPROCESS) { // If order source of shipment is "shipment in progress" + if ($origin_object->status == Commande::STATUS_SHIPMENTONPROCESS) { // If order source of shipment is "shipment in progress" // Check if there is no more shipment. If not, we can move back status of order to "validated" instead of "shipment in progress" $origin_object->loadExpeditions(); //var_dump($this->$origin->expeditions);exit; @@ -1511,8 +1531,8 @@ class Expedition extends CommonObject // Stock control if (!$error && isModEnabled('stock') && - ((getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT') && $this->statut > self::STATUS_DRAFT) || - (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE') && $this->statut == self::STATUS_CLOSED && $also_update_stock))) { + ((getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT') && $this->status > self::STATUS_DRAFT) || + (getDolGlobalString('STOCK_CALCULATE_ON_SHIPMENT_CLOSE') && $this->status == self::STATUS_CLOSED && $also_update_stock))) { require_once DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"; $langs->load("agenda"); @@ -1622,7 +1642,7 @@ class Expedition extends CommonObject $this->fetch_origin(); $origin_object = $this->origin_object; '@phan-var-force Facture|Commande $origin_object'; - if ($origin_object->statut == Commande::STATUS_SHIPMENTONPROCESS) { // If order source of shipment is "shipment in progress" + if ($origin_object->status == Commande::STATUS_SHIPMENTONPROCESS) { // If order source of shipment is "shipment in progress" // Check if there is no more shipment. If not, we can move back status of order to "validated" instead of "shipment in progress" $origin_object->loadExpeditions(); //var_dump($this->$origin->expeditions);exit; @@ -1905,7 +1925,7 @@ class Expedition extends CommonObject { global $user; - if ($this->statut == self::STATUS_DRAFT) { + if ($this->status == self::STATUS_DRAFT) { $this->db->begin(); $line = new ExpeditionLigne($this->db); @@ -1945,7 +1965,7 @@ class Expedition extends CommonObject $datas = array(); $datas['picto'] = img_picto('', $this->picto).' '.$langs->trans("Shipment").''; - if (isset($this->statut)) { + if (isset($this->status)) { $datas['picto'] .= ' '.$this->getLibStatut(5); } $datas['ref'] = '
'.$langs->trans('Ref').': '.$this->ref; @@ -2052,7 +2072,7 @@ class Expedition extends CommonObject */ public function getLibStatut($mode = 0) { - return $this->LibStatut($this->statut, $mode); + return $this->LibStatut($this->status, $mode); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps @@ -2369,7 +2389,7 @@ class Expedition extends CommonObject $error = 0; // Protection. This avoid to move stock later when we should not - if ($this->statut == self::STATUS_CLOSED) { + if ($this->status == self::STATUS_CLOSED) { return 0; } @@ -2583,7 +2603,7 @@ class Expedition extends CommonObject public function setDraft($user, $notrigger = 0) { // Protection - if ($this->statut <= self::STATUS_DRAFT) { + if ($this->status <= self::STATUS_DRAFT) { return 0; } @@ -2602,7 +2622,7 @@ class Expedition extends CommonObject $error = 0; // Protection. This avoid to move stock later when we should not - if ($this->statut == self::STATUS_VALIDATED) { + if ($this->status == self::STATUS_VALIDATED) { return 0; } diff --git a/htdocs/expedition/contact.php b/htdocs/expedition/contact.php index 534515a84f6..fb79ea4abd8 100644 --- a/htdocs/expedition/contact.php +++ b/htdocs/expedition/contact.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2011 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2023 Christian Foellmann - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024-2025 Frédéric France * Copyright (C) 2025 MDW * * This program is free software; you can redistribute it and/or modify @@ -58,6 +58,7 @@ $object = new Expedition($db); if ($id > 0 || !empty($ref)) { $object->fetch($id, $ref); $object->fetch_thirdparty(); + $objectsrc = clone $object; if (!empty($object->origin)) { $typeobject = $object->origin; @@ -66,11 +67,11 @@ if ($id > 0 || !empty($ref)) { } // Linked documents - if ($typeobject == 'commande' && $object->origin_object->id && isModEnabled('order')) { + if (!getDolGlobalInt('SHIPPING_USE_ITS_OWN_CONTACTS') && $typeobject == 'commande' && $object->origin_object->id && isModEnabled('order')) { $objectsrc = new Commande($db); $objectsrc->fetch($object->origin_object->id); } - if ($typeobject == 'propal' && $object->origin_object->id && isModEnabled("propal")) { + if (!getDolGlobalInt('SHIPPING_USE_ITS_OWN_CONTACTS') && $typeobject == 'propal' && $object->origin_object->id && isModEnabled("propal")) { $objectsrc = new Propal($db); $objectsrc->fetch($object->origin_object->id); } diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php index 8ea56808822..a96f628aeba 100644 --- a/htdocs/expedition/dispatch.php +++ b/htdocs/expedition/dispatch.php @@ -7,7 +7,7 @@ * Copyright (C) 2014 Cedric Gross * Copyright (C) 2016 Florian Henry * Copyright (C) 2017-2022 Ferran Marcet - * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2018-2025 Frédéric France * Copyright (C) 2019-2020 Christophe Battarel * Copyright (C) 2024-2025 MDW * @@ -547,7 +547,7 @@ if ($object->id > 0 || !empty($object->ref)) { print '
'; $disabled = 0; // This is used to disable or not the bulk selection of target warehouse. No reason to have it disabled so forced to 0. - if ($object->statut == Expedition::STATUS_DRAFT) { + if ($object->status == Expedition::STATUS_DRAFT) { require_once DOL_DOCUMENT_ROOT.'/product/class/html.formproduct.class.php'; $formproduct = new FormProduct($db); $formproduct->loadWarehouses(); diff --git a/htdocs/expedition/index.php b/htdocs/expedition/index.php index 07e2db26b81..418c1906106 100644 --- a/htdocs/expedition/index.php +++ b/htdocs/expedition/index.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2019 Nicolas ZABOURI * Copyright (C) 2020 Tobias Sekan - * Copyright (C) 2024 Frédéric France + * Copyright (C) 2024-2025 Frédéric France * * 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 @@ -258,7 +258,7 @@ if ($resql) { $orderstatic->id = $obj->rowid; $orderstatic->ref = $obj->ref; $orderstatic->ref_customer = $obj->ref_customer; - $orderstatic->statut = $obj->status; + $orderstatic->status = $obj->status; $orderstatic->billed = $obj->billed; $companystatic->name = $obj->name; diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index fd65e232701..3c012575de4 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -3,7 +3,7 @@ * Copyright (C) 2005-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2012-2015 Juanjo Menent - * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2018-2025 Frédéric France * Copyright (C) 2018-2022 Philippe Grand * Copyright (C) 2024-2025 MDW * @@ -470,7 +470,7 @@ if ($order_id > 0 || !empty($ref)) { print $langs->trans('PaymentConditionsShort'); print ''; - if ($action != 'editconditions' && $object->statut == Expedition::STATUS_VALIDATED) print 'id.'">'.img_edit($langs->trans('SetConditions'),1).''; + if ($action != 'editconditions' && $object->status == Expedition::STATUS_VALIDATED) print 'id.'">'.img_edit($langs->trans('SetConditions'),1).''; print ''; print ''; if ($action == 'editconditions') @@ -488,7 +488,7 @@ if ($order_id > 0 || !empty($ref)) { print ''; - if ($action != 'editmode' && $object->statut == Expedition::STATUS_VALIDATED) print ''; + if ($action != 'editmode' && $object->status == Expedition::STATUS_VALIDATED) print ''; print '
'; print $langs->trans('PaymentMode'); print 'id.'">'.img_edit($langs->trans('SetMode'),1).'id.'">'.img_edit($langs->trans('SetMode'),1).'
'; print ''; if ($action == 'editmode') @@ -864,7 +864,7 @@ if ($order_id > 0 || !empty($ref)) { print '
'; // Bouton expedier sans gestion des stocks - if (!isModEnabled('stock') && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED)) { + if (!isModEnabled('stock') && ($object->status > Commande::STATUS_DRAFT && $object->status < Commande::STATUS_CLOSED)) { if ($user->hasRight('expedition', 'creer')) { print ''.$langs->trans("CreateShipment").''; if ($toBeShippedTotal <= 0) { @@ -880,11 +880,11 @@ if ($order_id > 0 || !empty($ref)) { // Button to create a shipment - if (isModEnabled('stock') && $object->statut == Commande::STATUS_DRAFT) { + if (isModEnabled('stock') && $object->status == Commande::STATUS_DRAFT) { print $langs->trans("ValidateOrderFirstBeforeShipment"); } - if (isModEnabled('stock') && ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED)) { + if (isModEnabled('stock') && ($object->status > Commande::STATUS_DRAFT && $object->status < Commande::STATUS_CLOSED)) { if ($user->hasRight('expedition', 'creer')) { //print load_fiche_titre($langs->trans("CreateShipment")); print '
'; diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index b008d76ae10..320c4af2dfd 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -8,7 +8,7 @@ * Copyright (C) 2012-2014 Raphaël Doursenaud * Copyright (C) 2015 Marcos García * Copyright (C) 2017 Ferran Marcet - * Copyright (C) 2018-2024 Frédéric France + * Copyright (C) 2018-2025 Frédéric France * Copyright (C) 2024-2025 MDW * Copyright (C) 2024 Alexandre Spangaro * Copyright (C) ---Replace with your own copyright and developer email---