Skip to content

Commit

Permalink
Fix:move mass action code from generic files to specific list file
Browse files Browse the repository at this point in the history
  • Loading branch information
abb committed Nov 8, 2024
1 parent 6f8d450 commit 1b3a205
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
28 changes: 28 additions & 0 deletions htdocs/compta/cashcontrol/cashcontrol_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
}


Expand Down Expand Up @@ -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) {
Expand Down
24 changes: 0 additions & 24 deletions htdocs/core/actions_massactions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 0 additions & 4 deletions htdocs/core/tpl/massactions_pre.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1b3a205

Please sign in to comment.