From 1b3a205a548036f1588d64671df87f8e876fb037 Mon Sep 17 00:00:00 2001 From: abb Date: Fri, 8 Nov 2024 08:59:53 +0100 Subject: [PATCH] Fix:move mass action code from generic files to specific list file --- .../compta/cashcontrol/cashcontrol_list.php | 28 +++++++++++++++++++ htdocs/core/actions_massactions.inc.php | 24 ---------------- htdocs/core/tpl/massactions_pre.tpl.php | 4 --- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 7aed7b4f20000..0fd6743361c2a 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -181,6 +181,30 @@ $objectlabel = 'CashControl'; $uploaddir = $conf->bank->dir_output; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; + +// close cashpoints mass action + if (($action == 'close' && $confirm == 'yes') && $permissiontoadd) { + $objecttmp = new $objectclass($db); + $db->begin(); + $unique_arr = array_unique($toselect); + foreach ($unique_arr as $toselectid) { + $result = $objecttmp->fetch($toselectid); + if ($result > 0) { + $objecttmp->cash = price2num(GETPOST('cash_amount', 'alpha')); + $objecttmp->card = price2num(GETPOST('card_amount', 'alpha')); + $objecttmp->cheque = price2num(GETPOST('cheque_amount', 'alpha')); + + $result = $objecttmp->valid($user); + } + if ($result <= 0) { + setEventMessages($langs->trans("CashpointAlreadyClosed",$objecttmp->id), null, 'errors'); + $db->rollback(); + } else { + setEventMessages($langs->trans("CashFenceDone"), null); + $db->commit(); + } + } + } } @@ -415,6 +439,10 @@ $trackid = 'cashfence'.$object->id; include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php'; +if ($massaction == 'preclose') { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassClosing"), $langs->trans("ConfirmMassClosingQuestion", count($toselect)), "close", null, '', 0, 200, 500, 1); +} + if ($search_all) { $setupstring = ''; foreach ($fieldstosearchall as $key => $val) { diff --git a/htdocs/core/actions_massactions.inc.php b/htdocs/core/actions_massactions.inc.php index f1f946d93b6bf..6590d2bf24945 100644 --- a/htdocs/core/actions_massactions.inc.php +++ b/htdocs/core/actions_massactions.inc.php @@ -1134,30 +1134,6 @@ //var_dump($listofobjectthirdparties);exit; } -// close cashpoint from mass action -if (!$error && $objectclass=='CashControl' && ($massaction == 'close' || ($action == 'close' && $confirm == 'yes')) && $permissiontoadd) { - $objecttmp = new $objectclass($db); - $db->begin(); - $unique_arr = array_unique($toselect); - foreach ($unique_arr as $toselectid) { - $result = $objecttmp->fetch($toselectid); - if ($result > 0) { - $objecttmp->cash = price2num(GETPOST('cash_amount', 'alpha')); - $objecttmp->card = price2num(GETPOST('card_amount', 'alpha')); - $objecttmp->cheque = price2num(GETPOST('cheque_amount', 'alpha')); - - $result = $objecttmp->valid($user); - } - if ($result <= 0) { - setEventMessages($langs->trans("CashpointAlreadyClosed",$objecttmp->id), null, 'errors'); - $db->rollback(); - } else { - setEventMessages($langs->trans("CashFenceDone"), null); - $db->commit(); - } - } -} - // Generate document foreach object according to model linked to object // @todo : propose model selection if (!$error && $massaction == 'generate_doc' && $permissiontoread) { diff --git a/htdocs/core/tpl/massactions_pre.tpl.php b/htdocs/core/tpl/massactions_pre.tpl.php index be7d6e72f5ee1..09e683ffcd9ed 100644 --- a/htdocs/core/tpl/massactions_pre.tpl.php +++ b/htdocs/core/tpl/massactions_pre.tpl.php @@ -48,10 +48,6 @@ print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassDeletion"), $langs->trans("ConfirmMassDeletionQuestion", count($toselect)), "delete", null, '', 0, 200, 500, 1); } -if ($massaction == 'preclose') { - print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassClosing"), $langs->trans("ConfirmMassClosingQuestion", count($toselect)), "close", null, '', 0, 200, 500, 1); -} - if ($massaction == 'preclonetasks') { $selected = ''; foreach (GETPOST('toselect') as $tmpselected) {