dolibarr 21.0.0-alpha
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 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * or see https://www.gnu.org/
20 */
21
36{
37 global $langs, $conf;
38
39 $salary = $object->checkIfSalaryBonPrelevement();
40
41 $langs->loadLangs(array("bills", "withdrawals"));
42
43 $h = 0;
44 $head = array();
45
46 $titleoftab = "WithdrawalsReceipts";
47 if ($object->type == 'bank-transfer') {
48 $titleoftab = "BankTransferReceipts";
49 }
50
51 $head[$h][0] = 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 $titleoftab = $langs->trans("Bills");
57 if ($object->type == 'bank-transfer') {
58 $titleoftab = $langs->trans("SupplierBills");
59 }
60 if ($salary > 0) {
61 $titleoftab = $langs->trans("Salaries");
62 }
63
64 $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/factures.php?id='.$object->id;
65 $head[$h][1] = $titleoftab;
66 $head[$h][2] = 'invoices';
67 $h++;
68
69 $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche-rejet.php?id='.$object->id;
70 $head[$h][1] = $langs->trans("Rejects");
71 $head[$h][2] = 'rejects';
72 $h++;
73
74 $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/fiche-stat.php?id='.$object->id;
75 $head[$h][1] = $langs->trans("Statistics");
76 $head[$h][2] = 'statistics';
77 $h++;
78
79 // Show more tabs from modules
80 // Entries must be declared in modules descriptor with line
81 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
82 // $this->tabs = array('entity:-tabname); to remove a tab
83 complete_head_from_modules($conf, $langs, $object, $head, $h, 'prelevement');
84
85 complete_head_from_modules($conf, $langs, $object, $head, $h, 'prelevement', 'remove');
86
87 return $head;
88}
89
97function prelevement_check_config($type = 'direct-debit')
98{
99 global $conf, $db;
100 if ($type == 'bank-transfer') {
101 if (!getDolGlobalString('PAYMENTBYBANKTRANSFER_ID_BANKACCOUNT')) {
102 return -1;
103 }
104 //if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
105 if (!getDolGlobalString('PAYMENTBYBANKTRANSFER_USER')) {
106 return -1;
107 }
108 } else {
109 if (!getDolGlobalString('PRELEVEMENT_ID_BANKACCOUNT')) {
110 return -1;
111 }
112 //if (empty($conf->global->PRELEVEMENT_ICS)) return -1;
113 if (!getDolGlobalString('PRELEVEMENT_USER')) {
114 return -1;
115 }
116 }
117 return 0;
118}
119
128function bon_prelevement_prepare_head(BonPrelevement $object, $nbOfInvoices, $nbOfSalaryInvoice)
129{
130 global $langs, $conf;
131
132 $h = 0;
133 $head = array();
134
135 $head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/create.php?type=bank-transfer';
136 $head[$h][1] = ($nbOfInvoices <= 0 ? $langs->trans("Invoices") : $langs->trans("Invoices").'<span class="badge marginleftonlyshort">'.$nbOfInvoices.'</span>');
137 $head[$h][2] = 'invoice';
138 $h++;
139
140 // Salaries
141
142 $head[$h][0] = DOL_URL_ROOT."/compta/prelevement/create.php?type=bank-transfer&sourcetype=salary";
143 $head[$h][1] = ($nbOfSalaryInvoice <= 0 ? $langs->trans("Salaries") : $langs->trans("Salaries").'<span class="badge marginleftonlyshort">'.$nbOfSalaryInvoice.'</span>');
144 $head[$h][2] = 'salary';
145 $h++;
146
147 // Show more tabs from modules
148 // Entries must be declared in modules descriptor with line
149 // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
150 // $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
151 complete_head_from_modules($conf, $langs, $object, $head, $h, 'prelevement');
152
153 complete_head_from_modules($conf, $langs, $object, $head, $h, 'prelevement', 'remove');
154 return $head;
155}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:58
Class to manage withdrawal receipts.
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.