Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New : Mass action for closing cash controls #31704

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions htdocs/compta/cashcontrol/cashcontrol_list.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
/* Copyright (C) 2007-2017 Laurent Destailleur <[email protected]>
* Copyright (C) 2024 Abbes Bahfir <[email protected]>
* Copyright (C) ---Put here your own copyright and developer email---
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -380,6 +381,8 @@
if (!empty($permissiontodelete)) {
$arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete");
}
if (!empty($permissiontoadd)) $arrayofmassactions['preclose'] = img_picto('', 'close', 'class="pictofixedwidth"').$langs->trans("Close");

$massactionbutton = $form->selectMassAction('', $arrayofmassactions);

print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
Expand Down
25 changes: 25 additions & 0 deletions htdocs/core/actions_massactions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* Copyright (C) 2019 Ferran Marcet <[email protected]>
* Copyright (C) 2019-2024 Frédéric France <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024 Abbes Bahfir <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -1133,6 +1134,30 @@
//var_dump($listofobjectthirdparties);exit;
}

// close cashpoint from mass action
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you need to add a mass action that is specific to a page/object, you must add it into the file compta/cashcontrol/cashcontrol_list.php
You can add this test just before the include of the generic 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
7 changes: 6 additions & 1 deletion htdocs/core/tpl/massactions_pre.tpl.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
/* Copyright (C) 2013 Cédric Salvador <[email protected]>
* Copyright (C) 2013-2014 Laurent Destailleur <[email protected]>
* Copyright (C) 2015 Marcos García <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024 MDW <[email protected]>
* Copyright (C) 2024 Abbes Bahfir <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -47,6 +48,10 @@
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
3 changes: 3 additions & 0 deletions htdocs/langs/en_US/banks.lang
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,6 @@ SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation=SEPA fi
SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp=Yes = Store 'Payment Type' in 'Credit Transfer' section of SEPA file<br><br>When generating a SEPA XML file for Credit transfers, the section "PaymentTypeInformation" can now be placed inside the "CreditTransferTransactionInformation" section (instead of "Payment" section). We strongly recommend to keep this unchecked to place PaymentTypeInformation at Payment level, as all banks will not necessarily accept it at CreditTransferTransactionInformation level. Contact your bank before placing PaymentTypeInformation at CreditTransferTransactionInformation level.
ToCreateRelatedRecordIntoBank=To create missing related bank record
XNewLinesConciliated=%s new line(s) conciliated
ConfirmMassClosing= Mass Closing Confirm
ConfirmMassClosingQuestion = Are you sure you want to close the selected %s record(s)?
CashpointAlreadyClosed = Cash control %s is already closed
3 changes: 3 additions & 0 deletions htdocs/langs/fr_FR/banks.lang
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,6 @@ SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformation=Variant
SEPAXMLPlacePaymentTypeInformationInCreditTransfertransactionInformationHelp=Oui = Stocker le « Type de paiement » dans la section « Virement de crédit » du fichier SEPA<br><br>Lors de la génération d'un fichier XML SEPA pour les virements, la section "PaymentTypeInformation" peut désormais être placée dans la section "CreditTransferTransactionInformation" (au lieu de la section "Payment"). Nous vous recommandons fortement de laisser cette case décochée pour placer PaymentTypeInformation au niveau Payment, car toutes les banques ne l'accepteront pas nécessairement au niveau CreditTransferTransactionInformation. Contactez votre banque avant de placer PaymentTypeInformation au niveau CreditTransferTransactionInformation.
ToCreateRelatedRecordIntoBank=Pour créer un enregistrement bancaire associé manquant
XNewLinesConciliated=%s nouvelle(s) ligne(s) rapprochée(s)
ConfirmMassClosing= Confirmation de la clôture de masse
ConfirmMassClosingQuestion = Etes-vous sûr de vouloir clôturer le(s) %s enregistrement(s) sélectionné(s)?
CashpointAlreadyClosed= Le contrôle de caisse %s est déja clôturé