From a20ec7ba1eea98d87297cbe0b6b4699fb3eb584e Mon Sep 17 00:00:00 2001 From: atm-quentin Date: Wed, 2 May 2018 14:37:35 +0200 Subject: [PATCH] NEW cancel orders on massaction --- htdocs/commande/list.php | 3 +++ htdocs/core/actions_massactions.inc.php | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 872d6f02bfa..ee2fa05656d 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -208,6 +208,7 @@ if (empty($reshook)) $uploaddir = $conf->commande->dir_output; $trigger_name='ORDER_SENTBYMAIL'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + } @@ -419,6 +420,8 @@ if ($resql) $arrayofmassactions = array( 'presend'=>$langs->trans("SendByMail"), 'builddoc'=>$langs->trans("PDFMerge"), + 'cancelorders'=>$langs->trans("Cancel"), + ); if($user->rights->facture->creer) $arrayofmassactions['createbills']=$langs->trans("CreateInvoiceForThisCustomer"); if ($user->rights->commande->supprimer) $arrayofmassactions['predelete']=$langs->trans("Delete"); diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index 4894212fa07..6303d78d6ef 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -736,6 +736,20 @@ if ($massaction == 'confirm_createbills') } } +if ($massaction == 'cancelorders') +{ + $orders = GETPOST('toselect', 'array'); + foreach ($orders as $id_order) + { + + $cmd = new Commande($db); + if ($cmd->fetch($id_order) <= 0) + continue; + $cmd->cancel(); + } +} + + if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_search')) { if (empty($diroutputmassaction))