add agenda auto creation on supplier_order cancellation

This commit is contained in:
Christian Foellmann 2021-07-27 15:06:28 +02:00
parent 079b014b14
commit faf50a5aaa
3 changed files with 31 additions and 2 deletions

View File

@ -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 .= '<br>';
$object->actionmsg .= $langs->trans("Reason") . ': '.$object->cancel_note;
}
$object->sendtoid = 0;
} elseif ($action == 'ORDER_SUPPLIER_SUBMIT') {
// Load translation files required by the page

View File

@ -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

View File

@ -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);