dolibarr 24.0.0-beta
prelevement.lib.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2010-2011 Juanjo Menent <jmenent@2byte.es>
3 * Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2011 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
6 * Copyright (C) 2025 Frédéric France <frederic.france@free.fr>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 * or see https://www.gnu.org/
21 */
22
37{
38 global $langs, $conf;
39
40 $salary = $object->checkIfSalaryBonPrelevement();
41
42 $langs->loadLangs(array("bills", "withdrawals"));
43
44 $h = 0;
45 $head = array();
46
47 $titleoftab = "WithdrawalsReceipts";
48 if ($object->type == 'bank-transfer') {
49 $titleoftab = "BankTransferReceipts";
50 }
51 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/compta/prelevement/card.php', ['id' => $object->id]);
52 $head[$h][1] = $langs->trans($titleoftab);
53 $head[$h][2] = 'prelevement';
54 $h++;
55
56 if (getDolGlobalString('PRELEVEMENT_SEPA_SHOW_REQUESTS') && $object->type != 'bank-transfer' && $object->type != 'salary') {
57 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/compta/prelevement/requests.php', ['id' => $object->id]);
58 $head[$h][1] = $langs->trans('Requests');
59 $head[$h][2] = 'requests';
60 $h++;
61 }
62
63 $titleoftab = $langs->trans("Bills");
64 if ($object->type == 'bank-transfer') {
65 $titleoftab = $langs->trans("SupplierBills");
66 }
67 if ($salary > 0) {
68 $titleoftab = $langs->trans("Salaries");
69 }
70
71 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/compta/prelevement/factures.php', ['id' => $object->id]);
72 $head[$h][1] = $titleoftab;
73 $head[$h][2] = 'invoices';
74 $h++;
75
76 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/compta/prelevement/fiche-rejet.php', ['id' => $object->id]);
77 $head[$h][1] = $langs->trans("Rejects");
78 $head[$h][2] = 'rejects';
79 $h++;
80
81 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/compta/prelevement/fiche-stat.php', ['id' => $object->id]);
82 $head[$h][1] = $langs->trans("Statistics");
83 $head[$h][2] = 'statistics';
84 $h++;
85
86 // Show more tabs from modules
87 // Entries must be declared in modules descriptor with line
88 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
89 // $this->tabs = array('entity:-tabname); to remove a tab
90 complete_head_from_modules($conf, $langs, $object, $head, $h, 'prelevement');
91
92 complete_head_from_modules($conf, $langs, $object, $head, $h, 'prelevement', 'remove');
93
94 return $head;
95}
96
104function prelevement_check_config($type = 'direct-debit')
105{
106 global $conf, $db;
107 if ($type == 'bank-transfer') {
108 if (!getDolGlobalString('PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT')) {
109 return -1;
110 }
111 //if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
112 if (!getDolGlobalString('PAYMENTBYBANKTRANSFER_USER')) {
113 return -1;
114 }
115 } else {
116 if (!getDolGlobalString('PRELEVEMENT_ID_BANKACCOUNT')) {
117 return -1;
118 }
119 //if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
120 if (!getDolGlobalString('PRELEVEMENT_USER')) {
121 return -1;
122 }
123 }
124 return 0;
125}
126
135function bon_prelevement_prepare_head(BonPrelevement $object, $nbOfInvoices, $nbOfSalaryInvoice)
136{
137 global $langs, $conf;
138
139 $h = 0;
140 $head = array();
141
142 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/compta/prelevement/create.php', ['type' => 'bank-transfer']);
143 $head[$h][1] = ($nbOfInvoices <= 0 ? $langs->trans("Invoices") : $langs->trans("Invoices").'<span class="badge marginleftonlyshort">'.$nbOfInvoices.'</span>');
144 $head[$h][2] = 'invoice';
145 $h++;
146
147 // Salaries
148
149 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/compta/prelevement/create.php', ['type' => 'bank-transfer', 'sourcetype' => 'salary']);
150 $head[$h][1] = ($nbOfSalaryInvoice <= 0 ? $langs->trans("Salaries") : $langs->trans("Salaries").'<span class="badge marginleftonlyshort">'.$nbOfSalaryInvoice.'</span>');
151 $head[$h][2] = 'salary';
152 $h++;
153
154 // Show more tabs from modules
155 // Entries must be declared in modules descriptor with line
156 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
157 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
158 complete_head_from_modules($conf, $langs, $object, $head, $h, 'prelevement');
159
160 complete_head_from_modules($conf, $langs, $object, $head, $h, 'prelevement', 'remove');
161 return $head;
162}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class to manage withdrawal receipts.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
dolBuildUrl($url, $params=[], $addtoken=false, $anchor='')
Return path of url.
complete_head_from_modules($conf, $langs, $object, &$head, &$h, $type, $mode='add', $filterorigmodule='')
Complete or removed entries into a head array (used to build tabs).
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
bon_prelevement_prepare_head(BonPrelevement $object, $nbOfInvoices, $nbOfSalaryInvoice)
Return array head with list of tabs to view object information.
prelevement_prepare_head(BonPrelevement $object)
Prepare array with list of tabs.
prelevement_check_config($type='direct-debit')
Check need data to create standigns orders receipt file.