dolibarr 25.0.0-alpha
modBanque.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
5 * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
6 * Copyright (C) 2008-2011 Regis Houssin <regis.houssin@inodbox.com>
7 * Copyright (C) 2026 Solution Libre SAS <contact@solution-libre.fr>
8 * Copyright (C) 2026 Frédéric France <frederic.france@free.fr>
9 * Copyright (C) 2026 Alexandre Spangaro <alexandre@inovea-conseil.com>
10 *
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <https://www.gnu.org/licenses/>.
23 */
24
33include_once DOL_DOCUMENT_ROOT.'/core/modules/DolibarrModules.class.php';
34
35
40{
46 public function __construct($db)
47 {
48 global $conf;
49
50 $this->db = $db;
51 $this->numero = 85;
52
53 $this->family = "financial";
54 $this->module_position = '51';
55 // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
56 $this->name = preg_replace('/^mod/i', '', get_class($this));
57 $this->description = "Gestion des comptes financiers de type Comptes bancaires ou postaux";
58
59 // Possible values for version are: 'development', 'experimental', 'dolibarr' or version
60 $this->version = 'dolibarr';
61
62 $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
63 $this->picto = 'account';
64
65 // Data directories to create when module is enabled
66 $this->dirs = array("/bank/temp");
67
68 // Config pages
69 //-------------
70 $this->config_page_url = array("bank.php");
71
72 // Dependencies
73 $this->depends = array();
74 $this->requiredby = array("modComptabilite", "modAccounting", "modPrelevement");
75 $this->conflictwith = array();
76 $this->langfiles = array("banks", "compta", "bills", "companies", "accounting");
77
78 // Constants
79 $this->const = array();
80
81 // Boxes
82 $this->boxes = array(0=>array('file'=>'box_comptes.php', 'enabledbydefaulton'=>'Home'));
83
84 // Permissions
85 $this->rights = array();
86 $this->rights_class = 'banque';
87 $r = 0;
88
89 $r++;
90 $this->rights[$r][0] = 111; // Permission id (must not be already used)
91 $this->rights[$r][1] = 'Read bank account and transactions';
92 $this->rights[$r][2] = 'r';
93 $this->rights[$r][3] = 0;
94 $this->rights[$r][4] = 'lire';
95
96 $r++;
97 $this->rights[$r][0] = 112; // Permission id (must not be already used)
98 $this->rights[$r][1] = 'Creer/modifier montant/supprimer ecriture bancaire';
99 $this->rights[$r][2] = 'w';
100 $this->rights[$r][3] = 0;
101 $this->rights[$r][4] = 'modifier';
102
103 $r++;
104 $this->rights[$r][0] = 113; // Permission id (must not be already used)
105 $this->rights[$r][1] = 'Configurer les comptes bancaires (creer, gerer categories)';
106 $this->rights[$r][2] = 'a';
107 $this->rights[$r][3] = 0;
108 $this->rights[$r][4] = 'configurer';
109
110 $r++;
111 $this->rights[$r][0] = 114; // Permission id (must not be already used)
112 $this->rights[$r][1] = 'Rapprocher les ecritures bancaires';
113 $this->rights[$r][2] = 'w';
114 $this->rights[$r][3] = 0;
115 $this->rights[$r][4] = 'consolidate';
116
117 $r++;
118 $this->rights[$r][0] = 115; // Permission id (must not be already used)
119 $this->rights[$r][1] = 'Exporter transactions et releves';
120 $this->rights[$r][2] = 'r';
121 $this->rights[$r][3] = 0;
122 $this->rights[$r][4] = 'export';
123
124 $r++;
125 $this->rights[$r][0] = 116; // Permission id (must not be already used)
126 $this->rights[$r][1] = 'Virements entre comptes';
127 $this->rights[$r][2] = 'w';
128 $this->rights[$r][3] = 0;
129 $this->rights[$r][4] = 'transfer';
130
131 $r++;
132 $this->rights[$r][0] = 117; // Permission id (must not be already used)
133 $this->rights[$r][1] = 'Gerer les envois de cheques';
134 $this->rights[$r][2] = 'w';
135 $this->rights[$r][3] = 0;
136 $this->rights[$r][4] = 'cheque';
137
138
139 // Menus
140 //-------
141 $this->menu = 1; // This module add menu entries. They are coded into menu manager.
142
143
144 // Exports
145 //--------
146 $r = 0;
147
148 // Bank lines
149 $r++;
150 $this->export_code[$r] = $this->rights_class.'_'.$r;
151 $this->export_label[$r] = 'Ecritures bancaires et releves';
152 $this->export_permission[$r] = array(array("banque", "export"));
153 $this->export_fields_array[$r] = array(
154 'b.rowid'=>'IdTransaction', 'ba.ref'=>'AccountRef', 'ba.label'=>'AccountLabel', 'b.datev'=>'DateValue', 'b.dateo'=>'DateOperation', 'b.label'=>'Label',
155 'b.num_chq'=>'ChequeOrTransferNumber', 'b.fk_bordereau'=>'ChequeBordereau', '-b.amount'=>'Debit', 'b.amount'=>'Credit',
156 'b.num_releve'=>'AccountStatement', 'b.rappro'=>'BankLineReconciled', 'b.datec'=>"DateCreation", "bu.url_id"=>"IdThirdParty",
157 "s.nom"=>"ThirdParty", "s.code_compta"=>"CustomerAccountancyCode", "s.code_compta_fournisseur"=>"SupplierAccountancyCode"
158 );
159 $this->export_TypeFields_array[$r] = array('ba.ref'=>'Text', 'ba.label'=>'Text', 'b.datev'=>'Date', 'b.dateo'=>'Date', 'b.label'=>'Text', 'b.num_chq'=>'Text', 'b.fk_bordereau'=>'Text', '-b.amount'=>'Numeric', 'b.amount'=>'Numeric', 'b.num_releve'=>'Text', 'b.rappro'=>'Boolean', 'b.datec'=>"Date", "bu.url_id"=>"Text", "s.nom"=>"Text", "s.code_compta"=>"Text", "s.code_compta_fournisseur"=>"Text");
160 $this->export_entities_array[$r] = array(
161 'b.rowid'=>'account', 'ba.ref'=>'account', 'ba.label'=>'account', 'b.datev'=>'account', 'b.dateo'=>'account', 'b.label'=>'account',
162 'b.num_chq'=>'account', 'b.fk_bordereau'=>'account', '-b.amount'=>'account', 'b.amount'=>'account',
163 'b.num_releve'=>'account', 'b.rappro'=>'account', 'b.datec'=>"account", "bu.url_id"=>"company",
164 "s.nom"=>"company", "s.code_compta"=>"company", "s.code_compta_fournisseur"=>"company"
165 );
166 $this->export_special_array[$r] = array('-b.amount'=>'NULLIFNEG', 'b.amount'=>'NULLIFNEG');
167 if (!isModEnabled('supplier_order') && !isModEnabled('supplier_invoice')) {
168 unset($this->export_fields_array[$r]['s.code_compta_fournisseur']);
169 unset($this->export_entities_array[$r]['s.code_compta_fournisseur']);
170 }
171 $this->export_sql_start[$r] = 'SELECT DISTINCT ';
172 $this->export_sql_end[$r] = ' FROM ('.MAIN_DB_PREFIX.'bank_account as ba, '.MAIN_DB_PREFIX.'bank as b)';
173 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')";
174 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON bu.url_id = s.rowid';
175 $this->export_sql_end[$r] .= ' WHERE ba.rowid = b.fk_account';
176 $this->export_sql_end[$r] .= ' AND ba.entity IN ('.getEntity('bank_account').')';
177 $this->export_sql_order[$r] = ' ORDER BY b.datev, b.num_releve';
178
179 //
180 $r++;
181 $this->export_code[$r] = $this->rights_class.'_'.$r;
182 $this->export_label[$r] = 'Bordereaux remise Chq/Fact';
183 $this->export_permission[$r] = array(array("banque", "export"));
184 $this->export_fields_array[$r] = array("bch.rowid"=>"DepositId", "bch.ref"=>"Numero", "bch.ref_ext"=>"RefExt", 'ba.ref'=>'AccountRef', 'ba.label'=>'AccountLabel', 'b.datev'=>'DateValue', 'b.num_chq'=>'ChequeOrTransferNumber', 'b.amount'=>'Credit', 'b.num_releve'=>'AccountStatement', 'b.datec'=>"DateCreation",
185 "bch.date_bordereau"=>"Date", "bch.amount"=>"Total", "bch.nbcheque"=>"NbCheque", "bu.url_id"=>"IdThirdParty", "s.nom"=>"ThirdParty", "s.code_compta"=>"CustomerAccountancyCode", "f.ref"=>"InvoiceRef"
186 );
187 $this->export_TypeFields_array[$r] = array('ba.ref'=>'Text', 'ba.label'=>'Text', 'b.datev'=>'Date', 'b.num_chq'=>'Text', 'b.amount'=>'Numeric', 'b.num_releve'=>'Text', 'b.datec'=>"Date",
188 "bch.date_bordereau"=>"Date", "bch.rowid"=>"Numeric", "bch.ref"=>"Numeric", "bch.ref_ext"=>"Text", "bch.amount"=>"Numeric", "bch.nbcheque"=>"Numeric", "bu.url_id"=>"Text", "s.nom"=>"Text", "s.code_compta"=>"Text", "f.ref"=>"Text"
189 );
190 $this->export_entities_array[$r] = array('ba.ref'=>'account', 'ba.label'=>'account', 'b.datev'=>'account', 'b.num_chq'=>'account', 'b.amount'=>'account', 'b.num_releve'=>'account', 'b.datec'=>"account",
191 "bu.url_id"=>"company", "s.nom"=>"company", "s.code_compta"=>"company", "s.code_compta_fournisseur"=>"company", "f.ref"=>"invoice");
192 $this->export_special_array[$r] = array('b.amount'=>'NULLIFNEG');
193
194 $this->export_sql_start[$r] = 'SELECT DISTINCT ';
195 $this->export_sql_end[$r] = ' FROM ('.MAIN_DB_PREFIX.'bordereau_cheque as bch, '.MAIN_DB_PREFIX.'bank_account as ba, '.MAIN_DB_PREFIX.'bank as b)';
196 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."bank_url as bu ON (bu.fk_bank = b.rowid AND bu.type = 'company')";
197 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement as p ON b.rowid = p.fk_bank';
198 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiement_facture as pf ON p.rowid = pf.fk_paiement';
199 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'facture as f ON f.rowid = pf.fk_facture';
200 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON f.fk_soc = s.rowid';
201 $this->export_sql_end[$r] .= ' WHERE ba.rowid = b.fk_account AND bch.rowid = b.fk_bordereau and bch.fk_bank_account=ba.rowid';
202 $this->export_sql_end[$r] .= " AND b.fk_type = 'CHQ'";
203 $this->export_sql_end[$r] .= ' AND p.fk_paiement = 7';
204 $this->export_sql_end[$r] .= ' AND ba.entity IN ('.getEntity('bank_account').')';
205 $this->export_sql_order[$r] = ' ORDER BY b.datev, b.num_releve';
206
207 // Various Payment
208 $r++;
209 $this->export_code[$r] = $this->rights_class.'_'.$r;
210 $this->export_label[$r] = 'VariousPayment';
211 $this->export_permission[$r] = array(array("banque", "export"));
212 $this->export_fields_array[$r] = array(
213 'v.rowid'=>'VariousPaymentId', 'v.label'=>'VariousPaymentLabel', 'v.datev'=>'DateValue', 'v.datep'=>'DateOperation',
214 'v.num_payment'=>'ChequeOrTransferNumber', 'v.amount'=>'Amount', 'v.sens'=>'Sens',
215 'cp.id'=>"PaymentMode",
216 'v.accountancy_code'=>'AccountAccounting', 'v.subledger_account'=>'SubledgerAccount',
217 'v.note'=>'Note', 'v.datec'=>'DateCreation',
218 'p.ref'=>'ProjectRef', 'p.title'=>'ProjectLabel',
219 'v.fk_soc'=>'IdThirdParty', 's.nom'=>'ThirdParty'
220 );
221 $this->export_TypeFields_array[$r] = array(
222 'v.rowid'=>'Text', 'v.label'=>'Text', 'v.datep'=>'Date', 'v.datev'=>'Date',
223 'v.num_payment'=>'Text', 'v.amount'=>'Numeric', 'v.sens'=>'Numeric',
224 'cp.id'=>'List:c_paiement:code:id:code',
225 "v.accountancy_code"=>"Text", "v.subledger_account"=>"Text",
226 "v.note"=>"Text", 'v.datec'=>"Date",
227 "p.ref"=>"Text", "p.title"=>"Text",
228 "v.fk_soc"=>"Numeric", "s.nom"=>"Text"
229 );
230 $this->export_entities_array[$r] = array(
231 'v.rowid'=>'payment', 'v.label'=>'payment', 'v.datev'=>'payment', 'v.datep'=>'payment',
232 'v.num_payment'=>'payment', 'v.amount'=>'payment', 'v.sens'=>'payment',
233 'cp.id'=>'payment',
234 'v.accountancy_code'=>'payment', 'v.subledger_account'=>'payment',
235 'v.note'=>'payment', 'v.datec'=>'payment',
236 'p.ref'=>'project', 'p.title'=>'project',
237 'v.fk_soc'=>'company', 's.nom'=>'company'
238 );
239 // Hide thirdparty fields if the option is not enabled
240 $keystounset = array();
241 if (!getDolGlobalString('BANK_VARIOUS_PAYMENT_USE_THIRDPARTY')) {
242 $keystounset = array('v.fk_soc', 's.nom');
243 }
244 foreach ($keystounset as $key) {
245 unset($this->export_fields_array[$r][$key], $this->export_TypeFields_array[$r][$key], $this->export_entities_array[$r][$key]);
246 }
247 // Add extra fields
248 $keyforselect = 'payment_various';
249 $keyforelement = 'payment';
250 $keyforaliasextra = 'extra';
251 include DOL_DOCUMENT_ROOT.'/core/extrafieldsinexport.inc.php';
252 $this->export_sql_start[$r] = 'SELECT ';
253 $this->export_sql_end[$r] = ' FROM '.MAIN_DB_PREFIX.'payment_various as v';
254 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."projet as p ON v.fk_projet = p.rowid";
255 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX."c_paiement as cp ON v.fk_typepayment = cp.id";
256 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'payment_various_extrafields as extra ON v.rowid = extra.fk_object';
257 $this->export_sql_end[$r] .= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON v.fk_soc = s.rowid';
258 if (getDolGlobalString('BANK_VARIOUS_PAYMENT_USE_THIRDPARTY')) {
259 $this->export_sql_end[$r] .= ' WHERE v.entity IN (' . getEntity('payment_various') . ')';
260 }
261 $this->export_sql_order[$r] = ' ORDER BY v.datep';
262 }
263
264
273 public function init($options = '')
274 {
275 $this->_load_tables('/install/mysql/', 'bank');
276
277 // Permissions
278 $this->remove($options);
279
280 $sql = array();
281
282 return $this->_init($sql, $options);
283 }
284}
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
Class DolibarrModules.
_init($array_sql, $options='')
Enables a module.
_load_tables($reldir, $onlywithsuffix='')
Create tables and keys required by module:
Class to describe and enable module Banque.
__construct($db)
Constructor.
init($options='')
Function called when module is enabled.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
getEntity($element, $shared=1, $currentobject=null)
Get list of entity id to use.
$conf browser version
Definition main.inc.php:229
$conf db name
Only used if Module[ID]Name translation string is not found.
Definition repair.php:165