From dd230575163f33cacb4b81d6936494ff38be72b6 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 15 Nov 2021 14:54:09 +0100 Subject: [PATCH] NEW : accountancy massaction preselect account (customer and supplier list) --- htdocs/accountancy/customer/list.php | 25 +++++++++++++++++++++++-- htdocs/accountancy/supplier/list.php | 25 +++++++++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/htdocs/accountancy/customer/list.php b/htdocs/accountancy/customer/list.php index b61e2e74ad8..b55ec2b41a1 100644 --- a/htdocs/accountancy/customer/list.php +++ b/htdocs/accountancy/customer/list.php @@ -5,6 +5,7 @@ * Copyright (C) 2013-2021 Florian Henry * Copyright (C) 2014 Juanjo Menent * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2021 Gauthier VERDOL * * 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 @@ -46,6 +47,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $optioncss = GETPOST('optioncss', 'alpha'); +$default_account = GETPOST('default_account', 'int'); // Select Box $mesCasesCochees = GETPOST('toselect', 'array'); @@ -434,12 +436,15 @@ if ($result) { $arrayofmassactions = array( 'ventil'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Ventilate") + ,'set_default_account'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ConfirmPreselectAccount") //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); + if ($massaction !== 'set_default_account') { + $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); + } print '
'."\n"; print ''; @@ -454,6 +459,14 @@ if ($result) { print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); + if ($massaction == 'set_default_account') { + $formquestion[]=array('type' => 'other', + 'name' => 'set_default_account', + 'label' => $langs->trans("AccountancyCode"), + 'value' => $formaccounting->select_account('', 'default_account', 1, array(), 0, 0, 'maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone')); + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmPreselectAccount"), $langs->trans("ConfirmPreselectAccountQuestion", count($toselect)), "confirm_set_default_account", $formquestion, 1, 0, 200, 500, 1); + } + print ''.$langs->trans("DescVentilTodoCustomer").'

'; if ($msg) { @@ -728,7 +741,7 @@ if ($result) { // Suggested accounting account print ''; - print $formaccounting->select_account($suggestedid, 'codeventil'.$facture_static_det->id, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone'); + print $formaccounting->select_account(($default_account > 0 && $confirm === 'yes' && in_array($objp->rowid."_".$i, $toselect)) ? $default_account : $suggestedid, 'codeventil'.$facture_static_det->id, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone'); print ''; // Column with checkbox @@ -737,6 +750,14 @@ if ($result) { if (!empty($suggestedid) && $suggestedaccountingaccountfor != '' && $suggestedaccountingaccountfor != 'eecwithoutvatnumber') { $ischecked = 1; } + + if (!empty($toselect)) { + $ischecked = 0; + if (in_array($objp->rowid."_".$i, $toselect)) { + $ischecked=1; + } + } + print ''; print ''; diff --git a/htdocs/accountancy/supplier/list.php b/htdocs/accountancy/supplier/list.php index 18cb15d61a5..7638f14375e 100644 --- a/htdocs/accountancy/supplier/list.php +++ b/htdocs/accountancy/supplier/list.php @@ -5,6 +5,7 @@ * Copyright (C) 2013-2021 Florian Henry * Copyright (C) 2014 Juanjo Menent s * Copyright (C) 2016 Laurent Destailleur + * Copyright (C) 2021 Gauthier VERDOL * * 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 @@ -47,6 +48,7 @@ $show_files = GETPOST('show_files', 'int'); $confirm = GETPOST('confirm', 'alpha'); $toselect = GETPOST('toselect', 'array'); $optioncss = GETPOST('optioncss', 'alpha'); +$default_account = GETPOST('default_account', 'int'); // Select Box $mesCasesCochees = GETPOST('toselect', 'array'); @@ -434,12 +436,15 @@ if ($result) { $arrayofmassactions = array( 'ventil'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("Ventilate") + ,'set_default_account'=>img_picto('', 'check', 'class="pictofixedwidth"').$langs->trans("ConfirmPreselectAccount") //'presend'=>img_picto('', 'email', 'class="pictofixedwidth"').$langs->trans("SendByMail"), //'builddoc'=>img_picto('', 'pdf', 'class="pictofixedwidth"').$langs->trans("PDFMerge"), ); //if ($user->rights->mymodule->supprimer) $arrayofmassactions['predelete'] = img_picto('', 'delete', 'class="pictofixedwidth"').$langs->trans("Delete"); //if (in_array($massaction, array('presend','predelete'))) $arrayofmassactions=array(); - $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); + if ($massaction !== 'set_default_account') { + $massactionbutton = $form->selectMassAction('ventil', $arrayofmassactions, 1); + } print ''."\n"; print ''; @@ -454,6 +459,14 @@ if ($result) { print_barre_liste($langs->trans("InvoiceLines"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num_lines, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit); + if ($massaction == 'set_default_account') { + $formquestion[]=array('type' => 'other', + 'name' => 'set_default_account', + 'label' => $langs->trans("AccountancyCode"), + 'value' => $formaccounting->select_account('', 'default_account', 1, array(), 0, 0, 'maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone')); + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmPreselectAccount"), $langs->trans("ConfirmPreselectAccountQuestion", count($toselect)), "confirm_set_default_account", $formquestion, 1, 0, 200, 500, 1); + } + print ''.$langs->trans("DescVentilTodoCustomer").'

'; if ($msg) { @@ -719,7 +732,7 @@ if ($result) { // Suggested accounting account print ''; - print $formaccounting->select_account($suggestedid, 'codeventil'.$facturefourn_static_det->id, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone'); + print $formaccounting->select_account(($default_account > 0 && $confirm === 'yes' && in_array($objp->rowid."_".$i, $toselect)) ? $default_account : $suggestedid, 'codeventil'.$facturefourn_static_det->id, 1, array(), 0, 0, 'codeventil maxwidth200 maxwidthonsmartphone', 'cachewithshowemptyone'); print ''; // Column with checkbox @@ -728,6 +741,14 @@ if ($result) { if (!empty($suggestedid) && $suggestedaccountingaccountfor != '' && $suggestedaccountingaccountfor != 'eecwithoutvatnumber') { $ischecked = 1; } + + if (!empty($toselect)) { + $ischecked = 0; + if (in_array($objp->rowid."_".$i, $toselect)) { + $ischecked=1; + } + } + print ''; print '';