diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 8e23c258d88..8e6f34383b4 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -556,6 +556,21 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg .= $langs->trans("Reason") . ': '.$object->refuse_note; } + $object->sendtoid = 0; + } elseif ($action == 'ORDER_SUPPLIER_CANCEL') { + // Load translation files required by the page + $langs->loadLangs(array("agenda", "other", "orders", "main")); + + if (empty($object->actionmsg2)) { + $object->actionmsg2 = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref); + } + $object->actionmsg = $langs->transnoentities("OrderCanceledInDolibarr", $object->ref); + + if (!empty($object->cancel_note)) { + $object->actionmsg .= '
'; + $object->actionmsg .= $langs->trans("Reason") . ': '.$object->cancel_note; + } + $object->sendtoid = 0; } elseif ($action == 'ORDER_SUPPLIER_SUBMIT') { // Load translation files required by the page diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index cc0f67e4b4e..ed379b2783a 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1089,6 +1089,9 @@ if (empty($reshook)) { } if ($action == 'confirm_cancel' && $confirm == 'yes' && $usercanorder) { + if (GETPOST('cancel_note')) { + $object->cancel_note = GETPOST('cancel_note'); + } $result = $object->cancel($user); if ($result > 0) { header("Location: ".$_SERVER["PHP_SELF"]."?id=".$object->id); @@ -1903,9 +1906,18 @@ if ($action == 'create') { $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("DenyingThisOrder"), $langs->trans("ConfirmDenyingThisOrder", $object->ref), "confirm_refuse", $formquestion, 0, 1); } - // Confirmation de l'annulation + // Confirmation of cancellation if ($action == 'cancel') { - $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("Cancel"), $langs->trans("ConfirmCancelThisOrder", $object->ref), "confirm_cancel", '', 0, 1); + $formquestion = array( + array( + 'type' => 'text', + 'name' => 'cancel_note', + 'label' => $langs->trans("Reason"), + 'value' => '', + 'morecss' => 'minwidth300' + ) + ); + $formconfirm = $form->formconfirm($_SERVER['PHP_SELF']."?id=$object->id", $langs->trans("Cancel"), $langs->trans("ConfirmCancelThisOrder", $object->ref), "confirm_cancel", $formquestion, 0, 1); } // Confirmation de l'envoi de la commande diff --git a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql index 95de2ab7ba6..e319c6116f0 100644 --- a/htdocs/install/mysql/migration/14.0.0-15.0.0.sql +++ b/htdocs/install/mysql/migration/14.0.0-15.0.0.sql @@ -36,4 +36,6 @@ -- v15 +-- add action trigger +INSERT INTO llx_c_action_trigger (code,label,description,elementtype,rang) VALUES ('ORDER_SUPPLIER_CANCEL','Supplier order request canceled','Executed when a supplier order is canceled','order_supplier',13);