From 156922fc51ff9b273940d191df360ab788f27f16 Mon Sep 17 00:00:00 2001 From: FLIO Date: Tue, 14 Feb 2023 14:09:56 +0100 Subject: [PATCH 1/8] Fix (qodana) Incompatible return type --- htdocs/accountancy/class/bookkeeping.class.php | 2 +- htdocs/commande/class/api_orders.class.php | 2 +- htdocs/commande/class/commande.class.php | 2 +- htdocs/contact/class/contact.class.php | 2 +- htdocs/contrat/class/contrat.class.php | 2 +- htdocs/debugbar/class/DataCollector/DolLogsCollector.php | 2 +- htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php | 2 +- htdocs/expensereport/class/expensereport.class.php | 2 +- htdocs/holiday/class/holiday.class.php | 2 +- htdocs/install/upgrade2.php | 2 +- .../core/modules/mymodule/doc/pdf_standard_myobject.modules.php | 2 +- htdocs/product/class/productbatch.class.php | 2 +- htdocs/product/dynamic_price/class/price_expression.class.php | 2 +- .../product/dynamic_price/class/price_global_variable.class.php | 2 +- htdocs/product/stock/class/productstockentrepot.class.php | 2 +- htdocs/projet/class/api_tasks.class.php | 2 +- .../doc/pdf_standard_recruitmentjobposition.modules.php | 2 +- htdocs/resource/class/html.formresource.class.php | 2 +- htdocs/ticket/class/ticket.class.php | 2 +- htdocs/webservices/server_order.php | 2 +- htdocs/webservices/server_other.php | 2 +- htdocs/webservices/server_project.php | 2 +- htdocs/zapier/class/api_zapier.class.php | 2 +- 23 files changed, 23 insertions(+), 23 deletions(-) diff --git a/htdocs/accountancy/class/bookkeeping.class.php b/htdocs/accountancy/class/bookkeeping.class.php index 897f60e8aaa..7e2cdc56543 100644 --- a/htdocs/accountancy/class/bookkeeping.class.php +++ b/htdocs/accountancy/class/bookkeeping.class.php @@ -2088,7 +2088,7 @@ class BookKeeping extends CommonObject * FIXME: This function takes the parent of parent to get the root account ! * * @param string $account Accounting account - * @return array Array with root account information (max 2 upper level) + * @return array|int Array with root account information (max 2 upper level), <0 if KO */ public function getRootAccount($account = null) { diff --git a/htdocs/commande/class/api_orders.class.php b/htdocs/commande/class/api_orders.class.php index 0318cbcd5bf..766637550c2 100644 --- a/htdocs/commande/class/api_orders.class.php +++ b/htdocs/commande/class/api_orders.class.php @@ -713,7 +713,7 @@ class Orders extends DolibarrApi * @throws RestException 404 * @throws RestException 500 System error * - * @return array + * @return object */ public function validate($id, $idwarehouse = 0, $notrigger = 0) { diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 5b111f67e6c..60cefaf4b52 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2724,7 +2724,7 @@ class Commande extends CommonOrder * @param int $offset For pagination * @param string $sortfield Sort criteria * @param string $sortorder Sort order - * @return int -1 if KO, array with result if OK + * @return int|array -1 if KO, array with result if OK */ public function liste_array($shortlist = 0, $draft = 0, $excluser = '', $socid = 0, $limit = 0, $offset = 0, $sortfield = 'c.date_commande', $sortorder = 'DESC') { diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index b44d22da312..aa86c3f4077 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1868,7 +1868,7 @@ class Contact extends CommonObject * Updates all roles (default contact for companies) according to values inside the ->roles array. * This is called by update of contact. * - * @return float|int + * @return void|int * @see fetchRoles() */ public function updateRoles() diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index 97b586a2cde..cfd2dd3b292 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -758,7 +758,7 @@ class Contrat extends CommonObject * * @param int $only_services 0=Default, 1=Force only services (depending on setup, we may also have physical products in a contract) * @param int $loadalsotranslation 0=Default, 1=Load also translations of product descriptions - * @return ContratLigne[] Return array of contract lines + * @return array|int Return array of contract lines */ public function fetch_lines($only_services = 0, $loadalsotranslation = 0) { diff --git a/htdocs/debugbar/class/DataCollector/DolLogsCollector.php b/htdocs/debugbar/class/DataCollector/DolLogsCollector.php index 3d3b3b25a0e..0d166a23a6b 100644 --- a/htdocs/debugbar/class/DataCollector/DolLogsCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolLogsCollector.php @@ -138,7 +138,7 @@ class DolLogsCollector extends MessagesCollector * Get logs * * @param string $path Path - * @return array + * @return void */ public function getStorageLogs($path) { diff --git a/htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php b/htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php index 4ddcac9af7c..a74669e5238 100644 --- a/htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php +++ b/htdocs/debugbar/class/DataCollector/DolRequestDataCollector.php @@ -62,7 +62,7 @@ class DolRequestDataCollector extends RequestDataCollector /** * Return widget settings * - * @return void + * @return array */ public function getWidgets() { diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index a3c726ef521..2d3e20c3a3e 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -2340,7 +2340,7 @@ class ExpenseReport extends CommonObject * Return list of people with permission to validate expense reports. * Search for permission "approve expense report" * - * @return array Array of user ids + * @return array|int Array of user ids, <0 if KO */ public function fetch_users_approver_expensereport() { diff --git a/htdocs/holiday/class/holiday.class.php b/htdocs/holiday/class/holiday.class.php index e3a605a09aa..bcb686ef66a 100644 --- a/htdocs/holiday/class/holiday.class.php +++ b/htdocs/holiday/class/holiday.class.php @@ -1996,7 +1996,7 @@ class Holiday extends CommonObject * Return list of people with permission to validate leave requests. * Search for permission "approve leave requests" * - * @return array Array of user ids + * @return array|int Array of user ids, <0 if ko */ public function fetch_users_approver_holiday() { diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index 7f76261bcea..f934d24d0fc 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -4222,7 +4222,7 @@ function migrate_delete_old_dir($db, $langs, $conf) * @param Conf $conf Object conf * @param array $listofmodule List of modules, like array('MODULE_KEY_NAME'=>', $reloadmode) * @param int $force 1=Reload module even if not already loaded - * @return int <0 if KO, >0 if OK + * @return int|void <0 if KO, >0 if OK */ function migrate_reload_modules($db, $langs, $conf, $listofmodule = array(), $force = 0) { diff --git a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php index b78a2a5f4d7..ba93f036c0a 100644 --- a/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php +++ b/htdocs/modulebuilder/template/core/modules/mymodule/doc/pdf_standard_myobject.modules.php @@ -884,7 +884,7 @@ class pdf_standard_myobject extends ModelePDFMyObject * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output * @param Translate $outputlangsbis Object lang for output bis - * @return void + * @return float|int */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null) { diff --git a/htdocs/product/class/productbatch.class.php b/htdocs/product/class/productbatch.class.php index 52a39205b14..750e5d5bd7c 100644 --- a/htdocs/product/class/productbatch.class.php +++ b/htdocs/product/class/productbatch.class.php @@ -431,7 +431,7 @@ class Productbatch extends CommonObject * @param int $fk_product_stock id product_stock for objet * @param int $with_qty 1 = doesn't return line with 0 quantity * @param int $fk_product If set to a product id, get eatby and sellby from table llx_product_lot - * @return array <0 if KO, array of batch + * @return array|int <0 if KO, array of batch */ public static function findAll($dbs, $fk_product_stock, $with_qty = 0, $fk_product = 0) { diff --git a/htdocs/product/dynamic_price/class/price_expression.class.php b/htdocs/product/dynamic_price/class/price_expression.class.php index b9010f60f18..d38851e0eaa 100644 --- a/htdocs/product/dynamic_price/class/price_expression.class.php +++ b/htdocs/product/dynamic_price/class/price_expression.class.php @@ -162,7 +162,7 @@ class PriceExpression /** * List all price expressions * - * @return array Array of price expressions + * @return array|int Array of price expressions, <0 if ko */ public function list_price_expression() { diff --git a/htdocs/product/dynamic_price/class/price_global_variable.class.php b/htdocs/product/dynamic_price/class/price_global_variable.class.php index 336fb024470..99407851174 100644 --- a/htdocs/product/dynamic_price/class/price_global_variable.class.php +++ b/htdocs/product/dynamic_price/class/price_global_variable.class.php @@ -311,7 +311,7 @@ class PriceGlobalVariable /** * List all price global variables * - * @return array Array of price global variables + * @return array|int Array of price global variables, <0 if ko */ public function listGlobalVariables() { diff --git a/htdocs/product/stock/class/productstockentrepot.class.php b/htdocs/product/stock/class/productstockentrepot.class.php index a0310a16359..1151890a4b1 100644 --- a/htdocs/product/stock/class/productstockentrepot.class.php +++ b/htdocs/product/stock/class/productstockentrepot.class.php @@ -242,7 +242,7 @@ class ProductStockEntrepot extends CommonObject * @param array $filter filter array * @param string $filtermode filter mode (AND or OR) * - * @return int <0 if KO, >0 if OK + * @return int|array <0 if KO, array if OK */ public function fetchAll($fk_product = '', $fk_entrepot = '', $sortorder = '', $sortfield = '', $limit = 0, $offset = 0, array $filter = array(), $filtermode = 'AND') { diff --git a/htdocs/projet/class/api_tasks.class.php b/htdocs/projet/class/api_tasks.class.php index eb7e1579261..cd294aafd4f 100644 --- a/htdocs/projet/class/api_tasks.class.php +++ b/htdocs/projet/class/api_tasks.class.php @@ -272,7 +272,7 @@ class Tasks extends DolibarrApi * * @url GET {id}/roles * - * @return int + * @return array */ public function getRoles($id, $userid = 0) { diff --git a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php index 61c2eb3ff20..f98eac047e7 100644 --- a/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php +++ b/htdocs/recruitment/core/modules/recruitment/doc/pdf_standard_recruitmentjobposition.modules.php @@ -803,7 +803,7 @@ class pdf_standard_recruitmentjobposition extends ModelePDFRecruitmentJobPositio * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output * @param Translate $outputlangsbis Object lang for output bis - * @return void + * @return float|int */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null) { diff --git a/htdocs/resource/class/html.formresource.class.php b/htdocs/resource/class/html.formresource.class.php index 8b4e32c05d2..5f8c27dab4f 100644 --- a/htdocs/resource/class/html.formresource.class.php +++ b/htdocs/resource/class/html.formresource.class.php @@ -77,7 +77,7 @@ class FormResource * @param int $limit Limit number of answers * @param string $morecss More css * @param bool $multiple add [] in the name of element and add 'multiple' attribut - * @return string HTML string with + * @return string|array HTML string with */ public function select_resource_list($selected = '', $htmlname = 'fk_resource', $filter = '', $showempty = 0, $showtype = 0, $forcecombo = 0, $event = array(), $filterkey = '', $outputmode = 0, $limit = 20, $morecss = '', $multiple = false) { diff --git a/htdocs/ticket/class/ticket.class.php b/htdocs/ticket/class/ticket.class.php index bc50c0e31f8..e6688fc7642 100644 --- a/htdocs/ticket/class/ticket.class.php +++ b/htdocs/ticket/class/ticket.class.php @@ -2873,7 +2873,7 @@ class Ticket extends CommonObject * * @param User $user Object user * @param int $mode "opened" for askprice to close, "signed" for proposal to invoice - * @return int <0 if KO, >0 if OK + * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ public function load_board($user, $mode) { diff --git a/htdocs/webservices/server_order.php b/htdocs/webservices/server_order.php index 0f0eb79d10e..bed089abea1 100644 --- a/htdocs/webservices/server_order.php +++ b/htdocs/webservices/server_order.php @@ -654,7 +654,7 @@ function getOrdersForThirdParty($authentication, $idthirdparty) * * @param array $authentication Array of authentication information * @param array $order Order info - * @return int Id of new order + * @return array array of new order */ function createOrder($authentication, $order) { diff --git a/htdocs/webservices/server_other.php b/htdocs/webservices/server_other.php index ae1a480710f..c51ca01639e 100644 --- a/htdocs/webservices/server_other.php +++ b/htdocs/webservices/server_other.php @@ -185,7 +185,7 @@ function getVersions($authentication) * @param string $modulepart Properties of document * @param string $file Relative path * @param string $refname Ref of object to check permission for external users (autodetect if not provided) - * @return void + * @return array */ function getDocument($authentication, $modulepart, $file, $refname = '') { diff --git a/htdocs/webservices/server_project.php b/htdocs/webservices/server_project.php index b64ccc94d59..16aef76c699 100644 --- a/htdocs/webservices/server_project.php +++ b/htdocs/webservices/server_project.php @@ -235,7 +235,7 @@ $server->register( * * @param array $authentication Array of authentication information * @param array $project Project info - * @return int Id of new order + * @return array array of new order */ function createProject($authentication, $project) { diff --git a/htdocs/zapier/class/api_zapier.class.php b/htdocs/zapier/class/api_zapier.class.php index aac72a281f7..62652d9f4b5 100644 --- a/htdocs/zapier/class/api_zapier.class.php +++ b/htdocs/zapier/class/api_zapier.class.php @@ -240,7 +240,7 @@ class Zapier extends DolibarrApi * Create hook object * * @param array $request_data Request datas - * @return int ID of hook + * @return array ID of hook * * @url POST /hook/ */ From 45ba2016aa38e2851214320a18fd63fa04bc4206 Mon Sep 17 00:00:00 2001 From: FLIO Date: Wed, 22 Feb 2023 13:29:47 +0100 Subject: [PATCH 2/8] fix (qodana) fix pr --- htdocs/contact/class/contact.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index aa86c3f4077..cc64445fe7c 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -1868,7 +1868,7 @@ class Contact extends CommonObject * Updates all roles (default contact for companies) according to values inside the ->roles array. * This is called by update of contact. * - * @return void|int + * @return int * @see fetchRoles() */ public function updateRoles() @@ -1878,7 +1878,7 @@ class Contact extends CommonObject $error = 0; if (!isset($this->roles)) { - return; // Avoid to loose roles when property not set + return 0; // Avoid to loose roles when property not set } $this->db->begin(); From c75dc107e7def6485297db0866b7b998ba25dc36 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Mar 2023 12:20:35 +0100 Subject: [PATCH 3/8] Doc --- htdocs/compta/prelevement/class/bonprelevement.class.php | 1 + htdocs/modulebuilder/index.php | 2 +- htdocs/public/stripe/ipn.php | 6 ++++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index deaa78397c8..3618817e19a 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -426,6 +426,7 @@ class BonPrelevement extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set direct debit or credit transfer order to "paid" status. + * Then create the payment for each invoice of the prelemevement_bon. * * @param User $user Id of user * @param int $date date of action diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 2d11218ee48..04d0f290732 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -1910,7 +1910,7 @@ if ($dirins && $action == 'confirm_deleteobject' && $objectname) { setEventMessages($result, null, 'errors'); $error++; } else { - /* TODO ALI Header reidrect must be at end after actions. Also tab=pemrissions looks strange + /* TODO ALI Header redirect must be at end after actions. Also tab=pemrissions looks strange header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=permissions&module='.$module); */ setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null, 'warnings'); diff --git a/htdocs/public/stripe/ipn.php b/htdocs/public/stripe/ipn.php index 7a956e07ec5..9b33f5f39dd 100644 --- a/htdocs/public/stripe/ipn.php +++ b/htdocs/public/stripe/ipn.php @@ -345,8 +345,6 @@ if ($event->type == 'payout.created') { // TODO LMR Enable this only if this is a payment of a Dolibarr llx_prelevement_demande only - // TODO LMR The payment ID is $event->data->latest_charge. check that payment does not exists (it may have been created by Dolibarr) to avoid to create payment twice. - $paiement = new Paiement($db); $paiement->datepaye = $now; $paiement->date = $now; @@ -369,6 +367,10 @@ if ($event->type == 'payout.created') { $paiement->ext_payment_id = $TRANSACTIONID.':'.$customer_id.'@'.$stripearrayofkeysbyenv[$servicestatus]['publishable_key']; // May be we should store py_... instead of pi_... but we started with pi_... so we continue. $paiement->ext_payment_site = $service; // 'StripeLive' or 'Stripe' if test + + $db->begin(); + + if (!$errorforinvoice) { dol_syslog('* Record payment for invoice id ' . $invoice_id . '. It includes closing of invoice and regenerating document'); From a7077b756aed3887a27c5c3c9fb45653804797c4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Mar 2023 16:37:01 +0100 Subject: [PATCH 4/8] Add language --- htdocs/langs/en_US/languages.lang | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/langs/en_US/languages.lang b/htdocs/langs/en_US/languages.lang index e94b6bbafe4..1e924d96448 100644 --- a/htdocs/langs/en_US/languages.lang +++ b/htdocs/langs/en_US/languages.lang @@ -32,6 +32,7 @@ Language_en_AU=English (Australia) Language_en_CA=English (Canada) Language_en_GB=English (United Kingdom) Language_en_IN=English (India) +Language_en_MY=English (Myanmar) Language_en_NZ=English (New Zealand) Language_en_SA=English (Saudi Arabia) Language_en_SG=English (Singapore) From 16fc7d512ba7afd2d0945994989ccf51e653d059 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Mar 2023 20:24:18 +0100 Subject: [PATCH 5/8] WIP Work on deposit for other payment mode than CHQ. --- htdocs/compta/paiement/cheque/card.php | 55 ++++-- .../cheque/class/remisecheque.class.php | 42 +++-- htdocs/compta/paiement/cheque/index.php | 166 ++++++++++-------- .../install/mysql/migration/17.0.0-18.0.0.sql | 2 + .../mysql/tables/llx_bordereau_cheque.sql | 1 + 5 files changed, 171 insertions(+), 95 deletions(-) diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 1aebdace757..a4deeb51b90 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -42,6 +42,11 @@ $ref = GETPOST('ref', 'alpha'); $action = GETPOST('action', 'aZ09'); $confirm = GETPOST('confirm', 'alpha'); +$type = GETPOST('type'); +if (empty($type)) { + $type = 'CHQ'; +} + $object = new RemiseCheque($db); $sortfield = GETPOST('sortfield', 'aZ09comma'); @@ -60,6 +65,7 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; $offset = $limit * $page; $upload_dir = $conf->bank->multidir_output[$object->entity ? $object->entity : $conf->entity]."/checkdeposits"; + // filter by dates from / to $search_date_start_day = GETPOST('search_date_start_day', 'int'); $search_date_start_month = GETPOST('search_date_start_month', 'int'); @@ -132,8 +138,8 @@ if ($action == 'setref' && $user->rights->banque->cheque) { } if ($action == 'create' && GETPOST("accountid", "int") > 0 && $user->rights->banque->cheque) { - if (is_array(GETPOST('toRemise'))) { - $result = $object->create($user, GETPOST("accountid", "int"), 0, GETPOST('toRemise')); + if (GETPOSTISARRAY('toRemise')) { + $result = $object->create($user, GETPOST("accountid", "int"), 0, GETPOST('toRemise', 'array:int')); if ($result > 0) { if ($object->statut == 1) { // If statut is validated, we build doc $object->fetch($object->id); // To force to reload all properties in correct property name @@ -286,7 +292,12 @@ if (GETPOST('removefilter')) { $filteraccountid = 0; } -$title = $langs->trans("Cheques")." - ".$langs->trans("Card"); +if ($type == 'CHQ') { + $title = $langs->trans("Cheques"); +} else { + $title = $type; +} + $helpurl = ""; llxHeader("", $title, $helpurl); @@ -302,7 +313,7 @@ if ($action == 'new') { $hselected = $h; $h++; - print load_fiche_titre($langs->trans("Cheques"), '', 'bank_account'); + print load_fiche_titre($title, '', 'bank_account'); } else { $result = $object->fetch($id, $ref); if ($result < 0) { @@ -357,18 +368,29 @@ if ($action == 'new') { $now = dol_now(); - print ''.$langs->trans("SelectChequeTransactionAndGenerate").'

'."\n"; + if ($type == 'CHQ') { + print ''.$langs->trans("SelectChequeTransactionAndGenerate").'

'."\n"; + } else { + print ''.$langs->trans("SelectPaymentTransactionAndGenerate", $type).'

'."\n"; + } print '
'; print ''; print ''; + print ''; print dol_get_fiche_head(); print ''; //print ''; // Filter - print '
'.$langs->trans('Date').''.dol_print_date($now,'day').'
'.$langs->trans("DateChequeReceived").''; + print '
'; + if ($type == 'CHQ') { + print $langs->trans("DateChequeReceived"); + } else { + print $langs->trans("DatePaymentForDeposit"); + } + print ''; // filter by dates from / to print '
'; print $form->selectDate($search_date_start, 'search_date_start_', 0, 0, 1, '', 1, 1, 0, '', '', '', '', 1, '', $langs->trans('From')); @@ -402,7 +424,7 @@ if ($action == 'new') { $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON (b.fk_account = ba.rowid)"; - $sql .= " WHERE b.fk_type = 'CHQ'"; + $sql .= " WHERE b.fk_type = '".$db->escape($type)."'"; $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; $sql .= " AND b.fk_bordereau = 0"; $sql .= " AND b.amount > 0"; @@ -437,7 +459,11 @@ if ($action == 'new') { } if ($i == 0) { - print '
'.$langs->trans("NoWaitingChecks").'

'; + if ($type == 'CHQ') { + print '
'.$langs->trans("NoWaitingChecks").'

'; + } else { + print '
'.$langs->trans("NoWaitingPaymentForDeposit", $type).'

'; + } } } @@ -462,6 +488,7 @@ if ($action == 'new') { print ''; print ''; print ''; + print ''; print ''; $moreforfilter = ''; @@ -469,11 +496,17 @@ if ($action == 'new') { print ''."\n"; print ''; - print ''."\n"; + print ''."\n"; print '\n"; print '\n"; print '\n"; - print '\n"; + print '\n"; print '\n"; print '\n"; print '
'.$langs->trans("DateChequeReceived").''; + if ($type == 'CHQ') { + print $langs->trans("DateChequeReceived"); + } else { + print $langs->trans("DatePaymentForDepositReceived", $type); + } + print ''.$langs->trans("ChequeNumber")."'.$langs->trans("CheckTransmitter")."'.$langs->trans("Bank")."'.$langs->trans("Amount")."'.$langs->trans("Amount")."'.$langs->trans("Payment")."'.$langs->trans("LineRecord")."'.$langs->trans("Select")."
"; @@ -632,7 +665,7 @@ if ($action == 'new') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON (b.fk_account = ba.rowid)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid"; $sql .= " WHERE ba.entity IN (".getEntity('bank_account').")"; - $sql .= " AND b.fk_type= 'CHQ'"; + $sql .= " AND b.fk_type= '".$db->escape($type)."'"; $sql .= " AND b.fk_bordereau = ".((int) $object->id); $sql .= $db->order($sortfield, $sortorder); diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index eb70c9cebaf..ceed5a98a61 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -53,6 +53,8 @@ class RemiseCheque extends CommonObject //! Numero d'erreur Plage 1024-1279 public $errno; + public $type = 'CHQ'; // 'CHQ', 'TRA', ... + public $amount; public $date_bordereau; public $account_id; @@ -92,9 +94,9 @@ class RemiseCheque extends CommonObject { global $conf; - $sql = "SELECT bc.rowid, bc.datec, bc.fk_user_author, bc.fk_bank_account, bc.amount, bc.ref, bc.statut, bc.nbcheque, bc.ref_ext"; - $sql .= ", bc.date_bordereau as date_bordereau"; - $sql .= ", ba.label as account_label"; + $sql = "SELECT bc.rowid, bc.datec, bc.fk_user_author, bc.fk_bank_account, bc.amount, bc.ref, bc.statut, bc.nbcheque, bc.ref_ext,"; + $sql .= " bc.date_bordereau as date_bordereau, bc.type,"; + $sql .= " ba.label as account_label"; $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON bc.fk_bank_account = ba.rowid"; $sql .= " WHERE bc.entity = ".$conf->entity; @@ -118,6 +120,7 @@ class RemiseCheque extends CommonObject $this->nbcheque = $obj->nbcheque; $this->statut = $obj->statut; $this->ref_ext = $obj->ref_ext; + $this->type = $obj->type; if ($this->statut == 0) { $this->ref = "(PROV".$this->id.")"; @@ -154,6 +157,11 @@ class RemiseCheque extends CommonObject dol_syslog("RemiseCheque::Create start", LOG_DEBUG); + // Clean parameters + if (empty($this->type)) { + $this->type = 'CHQ'; + } + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."bordereau_cheque ("; @@ -167,6 +175,7 @@ class RemiseCheque extends CommonObject $sql .= ", entity"; $sql .= ", nbcheque"; $sql .= ", ref_ext"; + $sql .= ", type"; $sql .= ") VALUES ("; $sql .= "'".$this->db->idate($now)."'"; $sql .= ", '".$this->db->idate($now)."'"; @@ -178,6 +187,7 @@ class RemiseCheque extends CommonObject $sql .= ", ".((int) $conf->entity); $sql .= ", 0"; $sql .= ", ''"; + $sql .= ", '".$this->db->escape($this->type)."'"; $sql .= ")"; $resql = $this->db->query($sql); @@ -278,9 +288,9 @@ class RemiseCheque extends CommonObject } /** - * Supprime la remise en base + * Delete deposit from database * - * @param User $user Utilisateur qui effectue l'operation + * @param User $user User that delete * @return int */ public function delete($user = '') @@ -464,10 +474,11 @@ class RemiseCheque extends CommonObject /** * Load indicators for dashboard (this->nbtodo and this->nbtodolate) * - * @param User $user Objet user + * @param User $user Objet user + * @param string $type Type of payment mode deposit ('CHQ', 'TRA', ...) * @return WorkboardResponse|int <0 if KO, WorkboardResponse if OK */ - public function load_board($user) + public function load_board($user, $type = 'CHQ') { // phpcs:enable global $conf, $langs; @@ -481,7 +492,7 @@ class RemiseCheque extends CommonObject $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql .= " WHERE b.fk_account = ba.rowid"; $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql .= " AND b.fk_type = 'CHQ'"; + $sql .= " AND b.fk_type = '".$this->db->escape($type)."'"; $sql .= " AND b.fk_bordereau = 0"; $sql .= " AND b.amount > 0"; @@ -518,9 +529,10 @@ class RemiseCheque extends CommonObject /** * Charge indicateurs this->nb de tableau de bord * - * @return int <0 if ko, >0 if ok + * @param string $type Type of payment mode deposit ('CHQ', 'TRA', ...) + * @return int <0 if ko, >0 if ok */ - public function load_state_board() + public function load_state_board($type = 'CHQ') { // phpcs:enable global $user; @@ -534,7 +546,7 @@ class RemiseCheque extends CommonObject $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; $sql .= " WHERE b.fk_account = ba.rowid"; $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; - $sql .= " AND b.fk_type = 'CHQ'"; + $sql .= " AND b.fk_type = '".$this->db->escape($type)."'"; $sql .= " AND b.amount > 0"; $resql = $this->db->query($sql); @@ -615,7 +627,7 @@ class RemiseCheque extends CommonObject // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. - $sav_charseSupprimert_output = $outputlangs->charset_output; + $sav_charset_output = $outputlangs->charset_output; $result = $docmodel->write_file($this, $conf->bank->dir_output.'/checkdeposits', $this->ref, $outputlangs); if ($result > 0) { @@ -664,7 +676,7 @@ class RemiseCheque extends CommonObject $sql .= " SET amount = ".price2num($total); $sql .= ", nbcheque = ".((int) $nb); $sql .= " WHERE rowid = ".((int) $this->id); - $sql .= " AND entity = ".$conf->entity; + $sql .= " AND entity = ".((int) $conf->entity); $resql = $this->db->query($sql); if (!$resql) { @@ -813,7 +825,7 @@ class RemiseCheque extends CommonObject $sql = "SELECT MAX(rowid)"; $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque"; - $sql .= " WHERE rowid < ".$this->id; + $sql .= " WHERE rowid < ".((int) $this->id); $sql .= " AND entity = ".$conf->entity; $result = $this->db->query($sql); @@ -825,7 +837,7 @@ class RemiseCheque extends CommonObject $sql = "SELECT MIN(rowid)"; $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque"; - $sql .= " WHERE rowid > ".$this->id; + $sql .= " WHERE rowid > ".((int) $this->id); $sql .= " AND entity = ".$conf->entity; $result = $this->db->query($sql); diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php index 394de095104..5e1b69f655d 100644 --- a/htdocs/compta/paiement/cheque/index.php +++ b/htdocs/compta/paiement/cheque/index.php @@ -66,16 +66,11 @@ print load_fiche_titre($langs->trans("ChequesArea"), $newcardbutton, $checkdepos print '
'; -$sql = "SELECT count(b.rowid) as nb"; -$sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; -$sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; -$sql .= " WHERE ba.rowid = b.fk_account"; -$sql .= " AND ba.entity IN (".getEntity('bank_account').")"; -$sql .= " AND b.fk_type = 'CHQ'"; -$sql .= " AND b.fk_bordereau = 0"; -$sql .= " AND b.amount > 0"; +// List of payment mode to support +// Example: BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT = 'CHQ','TRA' +$conf->global->BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT = 'CHQ,TRA'; +$arrayofpaymentmodetomanage = explode(',', getDolGlobalString('BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 'CHQ')); -$resql = $db->query($sql); print '
'; print ''; @@ -83,19 +78,38 @@ print ''; print '\n"; print "\n"; -if ($resql) { - $num = ''; - if ($obj = $db->fetch_object($resql)) { - $num = $obj->nb; +foreach ($arrayofpaymentmodetomanage as $val) { + $sql = "SELECT count(b.rowid) as nb"; + $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; + $sql .= ", ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " WHERE ba.rowid = b.fk_account"; + $sql .= " AND ba.entity IN (".getEntity('bank_account').")"; + $sql .= " AND b.fk_type = '".$db->escape($val)."'"; + $sql .= " AND b.fk_bordereau = 0"; + $sql .= " AND b.amount > 0"; + + $resql = $db->query($sql); + if ($resql) { + $num = ''; + if ($obj = $db->fetch_object($resql)) { + $num = $obj->nb; + } + print ''; + print ''; + print ''; + } else { + dol_print_error($db); } - print ''; - print ''; - print ''; -} else { - dol_print_error($db); } + print "
'.$langs->trans("BankChecks")."
'; + if ($val == 'CHQ') { + print $langs->trans("BankChecksToReceipt"); + } else { + print $val; + } + print ''; + print ''.dol_escape_htmltag($num).''; + print '
'.$langs->trans("BankChecksToReceipt").''; - print ''.$num.''; - print '
\n"; @@ -103,64 +117,78 @@ print '
'; $max = 10; -$sql = "SELECT bc.rowid, bc.date_bordereau as db, bc.amount, bc.ref as ref,"; -$sql .= " bc.statut, bc.nbcheque,"; -$sql .= " ba.ref as bref, ba.label, ba.rowid as bid, ba.number, ba.currency_code, ba.account_number, ba.fk_accountancy_journal,"; -$sql .= " aj.code"; -$sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc, ".MAIN_DB_PREFIX."bank_account as ba"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_journal as aj ON aj.rowid = ba.fk_accountancy_journal"; -$sql .= " WHERE ba.rowid = bc.fk_bank_account"; -$sql .= " AND bc.entity = ".$conf->entity; -$sql .= " ORDER BY bc.date_bordereau DESC, rowid DESC"; -$sql .= $db->plimit($max); +foreach ($arrayofpaymentmodetomanage as $val) { + $sql = "SELECT bc.rowid, bc.date_bordereau as db, bc.amount, bc.ref as ref,"; + $sql .= " bc.statut, bc.nbcheque, bc.type,"; + $sql .= " ba.ref as bref, ba.label, ba.rowid as bid, ba.number, ba.currency_code, ba.account_number, ba.fk_accountancy_journal,"; + $sql .= " aj.code"; + $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc, ".MAIN_DB_PREFIX."bank_account as ba"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_journal as aj ON aj.rowid = ba.fk_accountancy_journal"; + $sql .= " WHERE ba.rowid = bc.fk_bank_account"; + $sql .= " AND bc.entity = ".((int) $conf->entity); + $sql .= " AND bc.type = '".$db->escape($type)."'"; + $sql .= " ORDER BY bc.date_bordereau DESC, rowid DESC"; + $sql .= $db->plimit($max); -$resql = $db->query($sql); -if ($resql) { - print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - print ''; - print ''; - print ''; - print '"; - print ''; - print ''; - print ''; - print ''; - print "\n"; + $resql = $db->query($sql); + if ($resql) { + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'.$langs->trans("LastCheckReceiptShort", $max).''.$langs->trans("Date")."'.$langs->trans("Account").''.$langs->trans("NbOfCheques").''.$langs->trans("Amount").''.$langs->trans("Status").'
'; + print ''; + print ''; + print '"; + print ''; + print ''; + print ''; + print ''; + print "\n"; - while ($objp = $db->fetch_object($resql)) { - $checkdepositstatic->id = $objp->rowid; - $checkdepositstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid); - $checkdepositstatic->statut = $objp->statut; + $i = 0; + while ($objp = $db->fetch_object($resql)) { + $i++; - $accountstatic->id = $objp->bid; - $accountstatic->ref = $objp->bref; - $accountstatic->label = $objp->label; - $accountstatic->number = $objp->number; - $accountstatic->currency_code = $objp->currency_code; - $accountstatic->account_number = $objp->account_number; - $accountstatic->accountancy_journal = $objp->code; - $accountstatic->fk_accountancy_journal = $objp->fk_accountancy_journal; + $checkdepositstatic->id = $objp->rowid; + $checkdepositstatic->ref = ($objp->ref ? $objp->ref : $objp->rowid); + $checkdepositstatic->statut = $objp->statut; - print ''."\n"; + $accountstatic->id = $objp->bid; + $accountstatic->ref = $objp->bref; + $accountstatic->label = $objp->label; + $accountstatic->number = $objp->number; + $accountstatic->currency_code = $objp->currency_code; + $accountstatic->account_number = $objp->account_number; + $accountstatic->accountancy_journal = $objp->code; + $accountstatic->fk_accountancy_journal = $objp->fk_accountancy_journal; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; + print ''."\n"; - print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + } + if ($i == 0) { + print ''; + } + print "
'; + if ($val == 'CHQ') { + print $langs->trans("LastCheckReceiptShort", $max); + } else { + print $langs->trans("LastPaymentForDepositShort", $max, $val); + } + print ''.$langs->trans("Date")."'.$langs->trans("Account").''.$langs->trans("NbOfCheques").''.$langs->trans("Amount").''.$langs->trans("Status").'
'.$checkdepositstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->db), 'day').''.$accountstatic->getNomUrl(1).''.$objp->nbcheque.''.price($objp->amount).''.$checkdepositstatic->LibStatut($objp->statut, 3).'
'.$checkdepositstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->db), 'day').''.$accountstatic->getNomUrl(1).''.$objp->nbcheque.''.price($objp->amount).''.$checkdepositstatic->LibStatut($objp->statut, 3).'
'.$langs->trans("None").'
"; + print '
'; + + $db->free($resql); + } else { + dol_print_error($db); } - print "
"; - print '
'; - - $db->free($resql); -} else { - dol_print_error($db); } - print ''; // End of page diff --git a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql index 6ae41a359dc..0f16c182e73 100644 --- a/htdocs/install/mysql/migration/17.0.0-18.0.0.sql +++ b/htdocs/install/mysql/migration/17.0.0-18.0.0.sql @@ -98,3 +98,5 @@ UPDATE llx_prelevement_demande SET type = 'ban' WHERE ext_payment_id IS NULL AND ALTER TABLE llx_recruitment_recruitmentcandidature ADD COLUMN fk_user integer; +ALTER TABLE llx_bordereau_cheque ADD COLUMN type VARCHAR(6) DEFAULT 'CHQ'; + diff --git a/htdocs/install/mysql/tables/llx_bordereau_cheque.sql b/htdocs/install/mysql/tables/llx_bordereau_cheque.sql index 9b1d6e24ad4..65100ccaae1 100644 --- a/htdocs/install/mysql/tables/llx_bordereau_cheque.sql +++ b/htdocs/install/mysql/tables/llx_bordereau_cheque.sql @@ -26,6 +26,7 @@ create table llx_bordereau_cheque rowid integer AUTO_INCREMENT PRIMARY KEY, ref varchar(30) NOT NULL, -- ref ref_ext varchar(255), -- ref_ext + type varchar(6) DEFAULT 'CHQ', -- 'CHQ', 'TRA', ... datec datetime NOT NULL, date_bordereau date, amount double(24,8) NOT NULL, From 2f5c841f4a817a187a720fa07eda90671ced4d92 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 8 Mar 2023 21:45:19 +0100 Subject: [PATCH 6/8] NEW Option to manage deposit slips for more payment modes (not only CHQ). Option BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT. --- htdocs/compta/paiement/cheque/card.php | 58 ++++++++++++++----- .../cheque/class/remisecheque.class.php | 2 +- htdocs/compta/paiement/cheque/index.php | 29 ++++++---- htdocs/compta/paiement/cheque/list.php | 32 +++++++--- htdocs/langs/en_US/banks.lang | 2 + htdocs/langs/en_US/bills.lang | 13 +++-- htdocs/langs/en_US/compta.lang | 11 ++-- 7 files changed, 104 insertions(+), 43 deletions(-) diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index a4deeb51b90..e3293718784 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -90,6 +90,10 @@ $usercandelete = $user->rights->banque->cheque; $permissiontodelete = $user->rights->banque->cheque; +// List of payment mode to support +// Example: BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT = 'CHQ','TRA' +$arrayofpaymentmodetomanage = explode(',', getDolGlobalString('BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 'CHQ')); + /* * Actions @@ -139,6 +143,10 @@ if ($action == 'setref' && $user->rights->banque->cheque) { if ($action == 'create' && GETPOST("accountid", "int") > 0 && $user->rights->banque->cheque) { if (GETPOSTISARRAY('toRemise')) { + $object->type = $type; + $arrayofid = GETPOST('toRemise', 'array:int'); + var_dump($arrayofid); + $result = $object->create($user, GETPOST("accountid", "int"), 0, GETPOST('toRemise', 'array:int')); if ($result > 0) { if ($object->statut == 1) { // If statut is validated, we build doc @@ -292,10 +300,14 @@ if (GETPOST('removefilter')) { $filteraccountid = 0; } -if ($type == 'CHQ') { - $title = $langs->trans("Cheques"); +if ($action == 'new') { + $title = $langs->trans("NewChequeDeposit"); } else { - $title = $type; + if ($type == 'CHQ') { + $title = $langs->trans("Cheques"); + } else { + $title = ($langs->trans("PaymentType".$type) != "PaymentType".$type ? $langs->trans("PaymentType".$type) : $langs->trans("PaymentMode").' '.$type); + } } $helpurl = ""; @@ -368,27 +380,40 @@ if ($action == 'new') { $now = dol_now(); + $labeltype = ($langs->trans("PaymentType".$type) != "PaymentType".$type ? $langs->trans("PaymentType".$type) : $type); if ($type == 'CHQ') { print ''.$langs->trans("SelectChequeTransactionAndGenerate").'

'."\n"; } else { - print ''.$langs->trans("SelectPaymentTransactionAndGenerate", $type).'

'."\n"; + print ''.$langs->trans("SelectPaymentTransactionAndGenerate", $labeltype).'

'."\n"; } print ''; print ''; print ''; - print ''; print dol_get_fiche_head(); print ''; - //print ''; - // Filter + + if (count($arrayofpaymentmodetomanage) > 1) { + $arrayoflabels = array(); + foreach ($arrayofpaymentmodetomanage as $key => $val) { + $labelval = ($langs->trans("PaymentType".$val) != "PaymentType".$val ? $langs->trans("PaymentType".$val) : $val); + $arrayoflabels[$key] = $labelval; + } + // Type + print ''; + } + // Date print ''; + print ''; } print "
'.$langs->trans('Date').''.dol_print_date($now,'day').'
'; + print $langs->trans("Type"); + print ''; + print $form->selectarray('type', $arrayoflabels, $type); + print '
'; if ($type == 'CHQ') { print $langs->trans("DateChequeReceived"); } else { - print $langs->trans("DatePaymentForDeposit"); + print $langs->trans("DatePaymentReceived"); } print ''; // filter by dates from / to @@ -462,7 +487,7 @@ if ($action == 'new') { if ($type == 'CHQ') { print '
'.$langs->trans("NoWaitingChecks").'

'; } else { - print '
'.$langs->trans("NoWaitingPaymentForDeposit", $type).'

'; + print '
'.$langs->trans("NoWaitingPaymentForDeposit", $labeltype).'

'; } } } @@ -485,6 +510,7 @@ if ($action == 'new') { '; $num = $db->num_rows($resql); + print ''; print ''; print ''; @@ -574,7 +600,13 @@ if ($action == 'new') { $linkback = ''.$langs->trans("BackToList").''; $morehtmlref = ''; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + $morehtmlleft = ''; + $moreghtmlright = ''; + + $labelval = ($langs->trans("PaymentType".$object->type) != "PaymentType".$object->type ? $langs->trans("PaymentType".$object->type) : $object->type); + $morehtmlref = '
'.$langs->trans("Type").' : '.$labelval.'
'; + + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, $morehtmlleft, '', 0, $moreghtmlright); print '
'; @@ -665,7 +697,7 @@ if ($action == 'new') { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON (b.fk_account = ba.rowid)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiement as p ON p.fk_bank = b.rowid"; $sql .= " WHERE ba.entity IN (".getEntity('bank_account').")"; - $sql .= " AND b.fk_type= '".$db->escape($type)."'"; + $sql .= " AND b.fk_type= '".$db->escape($object->type)."'"; $sql .= " AND b.fk_bordereau = ".((int) $object->id); $sql .= $db->order($sortfield, $sortorder); @@ -739,9 +771,9 @@ if ($action == 'new') { $i++; } } else { - print '
'; + print ''; print $langs->trans("None"); - print '
"; diff --git a/htdocs/compta/paiement/cheque/class/remisecheque.class.php b/htdocs/compta/paiement/cheque/class/remisecheque.class.php index ceed5a98a61..e84b0004564 100644 --- a/htdocs/compta/paiement/cheque/class/remisecheque.class.php +++ b/htdocs/compta/paiement/cheque/class/remisecheque.class.php @@ -215,7 +215,7 @@ class RemiseCheque extends CommonObject if ($this->id > 0 && $this->errno == 0) { $sql = "SELECT b.rowid"; $sql .= " FROM ".MAIN_DB_PREFIX."bank as b"; - $sql .= " WHERE b.fk_type = 'CHQ'"; + $sql .= " WHERE b.fk_type = '".$this->db->escape($this->type)."'"; $sql .= " AND b.amount > 0"; $sql .= " AND b.fk_bordereau = 0"; $sql .= " AND b.fk_account = ".((int) $account_id); diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php index 5e1b69f655d..5acdf8f5401 100644 --- a/htdocs/compta/paiement/cheque/index.php +++ b/htdocs/compta/paiement/cheque/index.php @@ -43,6 +43,10 @@ $result = restrictedArea($user, 'banque', '', ''); $usercancreate = $user->hasRight('banque', 'cheque'); +// List of payment mode to support +// Example: BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT = 'CHQ','TRA' +$arrayofpaymentmodetomanage = explode(',', getDolGlobalString('BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 'CHQ')); + /* * Actions @@ -55,27 +59,27 @@ $usercancreate = $user->hasRight('banque', 'cheque'); * View */ -llxHeader('', $langs->trans("ChequesArea")); +if (getDolGlobalString('BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 'CHQ') == 'CHQ') { + $title = $langs->trans("ChequesArea"); +} else { + $title = $langs->trans("DocumentsDepositArea"); +} + +llxHeader('', $title); $newcardbutton = ''; if ($usercancreate) { $newcardbutton .= dolGetButtonTitle($langs->trans('NewDeposit'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/compta/paiement/cheque/card.php?action=new'); } -print load_fiche_titre($langs->trans("ChequesArea"), $newcardbutton, $checkdepositstatic->picto); +print load_fiche_titre($title, $newcardbutton, $checkdepositstatic->picto); print '
'; -// List of payment mode to support -// Example: BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT = 'CHQ','TRA' -$conf->global->BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT = 'CHQ,TRA'; -$arrayofpaymentmodetomanage = explode(',', getDolGlobalString('BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 'CHQ')); - - print '
'; print ''; print ''; -print '\n"; +print '\n"; print "\n"; foreach ($arrayofpaymentmodetomanage as $val) { @@ -97,9 +101,9 @@ foreach ($arrayofpaymentmodetomanage as $val) { print ''; print ''; print '"; diff --git a/htdocs/compta/paiement/cheque/list.php b/htdocs/compta/paiement/cheque/list.php index 3c617a2db0c..11748c5c870 100644 --- a/htdocs/compta/paiement/cheque/list.php +++ b/htdocs/compta/paiement/cheque/list.php @@ -73,6 +73,16 @@ $formother = new FormOther($db); $checkdepositstatic = new RemiseCheque($db); $accountstatic = new Account($db); +// List of payment mode to support +// Example: BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT = 'CHQ','TRA' +$arrayofpaymentmodetomanage = explode(',', getDolGlobalString('BANK_PAYMENT_MODES_FOR_DEPOSIT_MANAGEMENT', 'CHQ')); + +$arrayoflabels = array(); +foreach ($arrayofpaymentmodetomanage as $key => $val) { + $labelval = ($langs->trans("PaymentType".$val) != "PaymentType".$val ? $langs->trans("PaymentType".$val) : $val); + $arrayoflabels[$key] = $labelval; +} + /* * Actions @@ -93,10 +103,10 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' * View */ -llxHeader('', $langs->trans("ChequesReceipts")); +llxHeader('', $langs->trans("ChequeDeposits")); $sql = "SELECT bc.rowid, bc.ref, bc.date_bordereau,"; -$sql .= " bc.nbcheque, bc.amount, bc.statut,"; +$sql .= " bc.nbcheque, bc.amount, bc.statut, bc.type,"; $sql .= " ba.rowid as bid, ba.label"; $sqlfields = $sql; // $sql fields to remove for count total @@ -104,7 +114,7 @@ $sqlfields = $sql; // $sql fields to remove for count total $sql .= " FROM ".MAIN_DB_PREFIX."bordereau_cheque as bc,"; $sql .= " ".MAIN_DB_PREFIX."bank_account as ba"; $sql .= " WHERE bc.fk_bank_account = ba.rowid"; -$sql .= " AND bc.entity = ".$conf->entity; +$sql .= " AND bc.entity = ".((int) $conf->entity); // Search criteria if ($search_ref) { @@ -191,10 +201,13 @@ if ($resql) { // Fields title search print ''; - print ''; - print ''; + print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "bc.ref", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "bc.type", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("DateCreation", $_SERVER["PHP_SELF"], "bc.date_bordereau", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("NbOfCheques", $_SERVER["PHP_SELF"], "bc.nbcheque", "", $param, 'class="right"', $sortfield, $sortorder); @@ -236,6 +250,7 @@ if ($resql) { $checkdepositstatic->nbcheque = $objp->nbcheque; $checkdepositstatic->amount = $objp->amount; $checkdepositstatic->date_bordereau = $objp->date_bordereau; + $checkdepositstatic->type = $objp->type; $account = new Account($db); $account->fetch($objp->bid); @@ -257,12 +272,15 @@ if ($resql) { // Num ref cheque print ''; + // Type + $labelpaymentmode = ($langs->transnoentitiesnoconv("PaymentType".$checkdepositstatic->type) != "PaymentType".$checkdepositstatic->type ? $langs->transnoentitiesnoconv("PaymentType".$checkdepositstatic->type) : $checkdepositstatic->type); + print ''; + // Date - print ''; // TODO Use date hour + print ''; // Bank print '
'.$langs->trans("BankChecks")."'.$langs->trans("DocumentsForDeposit")."
'; if ($val == 'CHQ') { - print $langs->trans("BankChecksToReceipt"); + print $langs->trans("BankChecks"); } else { - print $val; + print ($langs->trans("PaymentType".$val) != "PaymentType".$val ? $langs->trans("PaymentType".$val) : $langs->trans("PaymentMode").' '.$val); } print ''; @@ -139,7 +143,8 @@ foreach ($arrayofpaymentmodetomanage as $val) { if ($val == 'CHQ') { print $langs->trans("LastCheckReceiptShort", $max); } else { - print $langs->trans("LastPaymentForDepositShort", $max, $val); + $labelpaymentmode = ($langs->trans("PaymentType".$val) != "PaymentType".$val ? $langs->trans("PaymentType".$val) : $val); + print $langs->trans("LastPaymentForDepositShort", $max, $labelpaymentmode); } print ''; print ''.$langs->trans("Date")."
'; + print ''; print ''; print ''; + // Type + print ''; + print ''; if (!empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) { print ''; } @@ -217,6 +230,7 @@ if ($resql) { print '
'; - print $checkdepositstatic->getNomUrl(1); print ''.dol_escape_htmltag($labelpaymentmode).''.dol_print_date($db->jdate($objp->date_bordereau), 'day').''.dol_print_date($db->jdate($objp->date_bordereau), 'dayhour', 'tzuser').''; diff --git a/htdocs/langs/en_US/banks.lang b/htdocs/langs/en_US/banks.lang index 7be02da2c27..2c895b48034 100644 --- a/htdocs/langs/en_US/banks.lang +++ b/htdocs/langs/en_US/banks.lang @@ -120,6 +120,7 @@ ValidateCheckReceipt=Validate this check receipt? ConfirmValidateCheckReceipt=Are you sure that you want to submit this check receipt for validation? No changes will be possible once validated. DeleteCheckReceipt=Delete this check receipt? ConfirmDeleteCheckReceipt=Are you sure you want to delete this check receipt? +DocumentsForDeposit=Documents to deposit at the bank BankChecks=Bank checks BankChecksToReceipt=Checks awaiting deposit BankChecksToReceiptShort=Checks awaiting deposit @@ -145,6 +146,7 @@ BackToAccount=Back to account ShowAllAccounts=Show for all accounts FutureTransaction=Future transaction. Unable to reconcile. SelectChequeTransactionAndGenerate=Select/filter the checks which are to be included in the check deposit receipt. Then, click on "Create". +SelectPaymentTransactionAndGenerate=Select/filter the documents which are to be included in the %s deposit receipt. Then, click on "Create". InputReceiptNumber=Choose the bank statement related with the conciliation. Use a sortable numeric value: YYYYMM or YYYYMMDD EventualyAddCategory=Eventually, specify a category in which to classify the records ToConciliate=To reconcile? diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index 7ad897ab0e2..798ba129288 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -509,13 +509,14 @@ UseLine=Apply UseDiscount=Use discount UseCredit=Use credit UseCreditNoteInInvoicePayment=Reduce amount to pay with this credit -MenuChequeDeposits=Check Deposits +MenuChequeDeposits=Deposits slips MenuCheques=Checks -MenuChequesReceipts=Check receipts -NewChequeDeposit=New deposit -ChequesReceipts=Check receipts -ChequesArea=Check deposits area -ChequeDeposits=Check deposits +MenuChequesReceipts=Deposit slips +NewChequeDeposit=New deposit slip +ChequesReceipts=Cheque deposit slips +DocumentsDepositArea=Deposit slip area +ChequesArea=Deposit slips area +ChequeDeposits=Deposit slips Cheques=Checks DepositId=Id deposit NbCheque=Number of checks diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index b3d5f675830..0d286fb3104 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -130,14 +130,17 @@ SalesTurnoverMinimum=Minimum turnover ByExpenseIncome=By expenses & incomes ByThirdParties=By third parties ByUserAuthorOfInvoice=By invoice author -CheckReceipt=Check deposit -CheckReceiptShort=Check deposit -LastCheckReceiptShort=Latest %s check receipts +CheckReceipt=Deposit slip +CheckReceiptShort=Deposit slip +LastCheckReceiptShort=Latest %s deposit slips +LastPaymentForDepositShort=Latest %s %s deposit slips NewCheckReceipt=New discount -NewCheckDeposit=New check deposit +NewCheckDeposit=New deposit slip NewCheckDepositOn=Create receipt for deposit on account: %s NoWaitingChecks=No checks awaiting deposit. +NoWaitingPaymentForDeposit=No %s payment awaiting deposit. DateChequeReceived=Check receiving date +DatePaymentReceived=Date of document reception NbOfCheques=No. of checks PaySocialContribution=Pay a social/fiscal tax PayVAT=Pay a VAT declaration From 9a811415ae4dfbbfe162d23fcc7a47de4c02a638 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Mar 2023 14:58:25 +0100 Subject: [PATCH 7/8] Fix regression --- htdocs/compta/paiement/cheque/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/cheque/index.php b/htdocs/compta/paiement/cheque/index.php index 5acdf8f5401..073fd90944e 100644 --- a/htdocs/compta/paiement/cheque/index.php +++ b/htdocs/compta/paiement/cheque/index.php @@ -130,7 +130,7 @@ foreach ($arrayofpaymentmodetomanage as $val) { $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_journal as aj ON aj.rowid = ba.fk_accountancy_journal"; $sql .= " WHERE ba.rowid = bc.fk_bank_account"; $sql .= " AND bc.entity = ".((int) $conf->entity); - $sql .= " AND bc.type = '".$db->escape($type)."'"; + $sql .= " AND bc.type = '".$db->escape($val)."'"; $sql .= " ORDER BY bc.date_bordereau DESC, rowid DESC"; $sql .= $db->plimit($max); From f1e6ac522d68aeb08cb5f87802e995d313f8b9d4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 9 Mar 2023 15:54:56 +0100 Subject: [PATCH 8/8] Fix var_dump --- htdocs/compta/paiement/cheque/card.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index e3293718784..9135f2d2eb5 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -145,9 +145,8 @@ if ($action == 'create' && GETPOST("accountid", "int") > 0 && $user->rights->ban if (GETPOSTISARRAY('toRemise')) { $object->type = $type; $arrayofid = GETPOST('toRemise', 'array:int'); - var_dump($arrayofid); - $result = $object->create($user, GETPOST("accountid", "int"), 0, GETPOST('toRemise', 'array:int')); + $result = $object->create($user, GETPOST("accountid", "int"), 0, $arrayofid); if ($result > 0) { if ($object->statut == 1) { // If statut is validated, we build doc $object->fetch($object->id); // To force to reload all properties in correct property name