dolibarr 23.0.3
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
52 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/compta/prelevement/card.php', ['id' => $object->id]);
53 $head[$h][1] = $langs->trans($titleoftab);
54 $head[$h][2] = 'prelevement';
55 $h++;
56
57 $titleoftab = $langs->trans("Bills");
58 if ($object->type == 'bank-transfer') {
59 $titleoftab = $langs->trans("SupplierBills");
60 }
61 if ($salary > 0) {
62 $titleoftab = $langs->trans("Salaries");
63 }
64
65 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/compta/prelevement/factures.php', ['id' => $object->id]);
66 $head[$h][1] = $titleoftab;
67 $head[$h][2] = 'invoices';
68 $h++;
69
70 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/compta/prelevement/fiche-rejet.php', ['id' => $object->id]);
71 $head[$h][1] = $langs->trans("Rejects");
72 $head[$h][2] = 'rejects';
73 $h++;
74
75 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/compta/prelevement/fiche-stat.php', ['id' => $object->id]);
76 $head[$h][1] = $langs->trans("Statistics");
77 $head[$h][2] = 'statistics';
78 $h++;
79
80 // Show more tabs from modules
81 // Entries must be declared in modules descriptor with line
82 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
83 // $this->tabs = array('entity:-tabname); to remove a tab
84 complete_head_from_modules($conf, $langs, $object, $head, $h, 'prelevement');
85
86 complete_head_from_modules($conf, $langs, $object, $head, $h, 'prelevement', 'remove');
87
88 return $head;
89}
90
98function prelevement_check_config($type = 'direct-debit')
99{
100 global $conf, $db;
101 if ($type == 'bank-transfer') {
102 if (!getDolGlobalString('PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT')) {
103 return -1;
104 }
105 //if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
106 if (!getDolGlobalString('PAYMENTBYBANKTRANSFER_USER')) {
107 return -1;
108 }
109 } else {
110 if (!getDolGlobalString('PRELEVEMENT_ID_BANKACCOUNT')) {
111 return -1;
112 }
113 //if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
114 if (!getDolGlobalString('PRELEVEMENT_USER')) {
115 return -1;
116 }
117 }
118 return 0;
119}
120
129function bon_prelevement_prepare_head(BonPrelevement $object, $nbOfInvoices, $nbOfSalaryInvoice)
130{
131 global $langs, $conf;
132
133 $h = 0;
134 $head = array();
135
136 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/compta/prelevement/create.php', ['type' => 'bank-transfer']);
137 $head[$h][1] = ($nbOfInvoices <= 0 ? $langs->trans("Invoices") : $langs->trans("Invoices").'<span class="badge marginleftonlyshort">'.$nbOfInvoices.'</span>');
138 $head[$h][2] = 'invoice';
139 $h++;
140
141 // Salaries
142
143 $head[$h][0] = dolBuildUrl(DOL_URL_ROOT.'/compta/prelevement/create.php', ['type' => 'bank-transfer', 'sourcetype' => 'salary']);
144 $head[$h][1] = ($nbOfSalaryInvoice <= 0 ? $langs->trans("Salaries") : $langs->trans("Salaries").'<span class="badge marginleftonlyshort">'.$nbOfSalaryInvoice.'</span>');
145 $head[$h][2] = 'salary';
146 $h++;
147
148 // Show more tabs from modules
149 // Entries must be declared in modules descriptor with line
150 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
151 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
152 complete_head_from_modules($conf, $langs, $object, $head, $h, 'prelevement');
153
154 complete_head_from_modules($conf, $langs, $object, $head, $h, 'prelevement', 'remove');
155 return $head;
156}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
Class to manage withdrawal receipts.
dolBuildUrl($url, $params=[], $addtoken=false)
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.