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