dolibarr 22.0.5
bankjournal.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
3 * Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
4 * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
5 * Copyright (C) 2012 Regis Houssin <regis.houssin@inodbox.com>
6 * Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
7 * Copyright (C) 2013-2022 Open-DSI <support@open-dsi.fr>
8 * Copyright (C) 2013-2025 Alexandre Spangaro <alexandre@inovea-conseil.com>
9 * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
10 * Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
11 * Copyright (C) 2017-2025 Frédéric France <frederic.france@free.fr>
12 * Copyright (C) 2018 Ferran Marcet <fmarcet@2byte.es>
13 * Copyright (C) 2018-2024 Eric Seigne <eric.seigne@cap-rel.fr>
14 * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
15 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
16 *
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 3 of the License, or
20 * (at your option) any later version.
21 *
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * You should have received a copy of the GNU General Public License
28 * along with this program. If not, see <https://www.gnu.org/licenses/>.
29 */
30
36require '../../main.inc.php';
37require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
38require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
39require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php';
40require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
41require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
42require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
43require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php';
44require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
45require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
46require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
47require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
48require_once DOL_DOCUMENT_ROOT.'/don/class/don.class.php';
49require_once DOL_DOCUMENT_ROOT.'/don/class/paymentdonation.class.php';
50require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
51require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
52require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
53require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
54require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
55require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php';
56require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
57require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
58require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
59require_once DOL_DOCUMENT_ROOT.'/expensereport/class/paymentexpensereport.class.php';
60require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/paymentvarious.class.php';
61require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
62require_once DOL_DOCUMENT_ROOT.'/loan/class/loan.class.php';
63require_once DOL_DOCUMENT_ROOT.'/loan/class/paymentloan.class.php';
64require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
65
74// Load translation files required by the page
75$langs->loadLangs(array("companies", "other", "compta", "banks", "bills", "donations", "loan", "accountancy", "trips", "salaries", "hrm", "members"));
76
77// Multi journal
78$id_journal = GETPOSTINT('id_journal');
79
80$date_startmonth = GETPOSTINT('date_startmonth');
81$date_startday = GETPOSTINT('date_startday');
82$date_startyear = GETPOSTINT('date_startyear');
83$date_endmonth = GETPOSTINT('date_endmonth');
84$date_endday = GETPOSTINT('date_endday');
85$date_endyear = GETPOSTINT('date_endyear');
86$in_bookkeeping = GETPOST('in_bookkeeping', 'aZ09');
87
88$only_rappro = GETPOSTINT('only_rappro');
89if ($only_rappro == 0) {
90 //GET page for the first time, use default settings
91 $only_rappro = getDolGlobalInt('ACCOUNTING_BANK_CONCILIATED');
92}
93
94$now = dol_now();
95
96$action = GETPOST('action', 'aZ09');
97
98if ($in_bookkeeping == '') {
99 $in_bookkeeping = 'notyet';
100}
101
102
103// Security check
104if (!isModEnabled('accounting')) {
106}
107if ($user->socid > 0) {
109}
110if (!$user->hasRight('accounting', 'bind', 'write')) {
112}
113
114
115/*
116 * Actions
117 */
118
119$error = 0;
120
121$date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
122$date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
123
124$pastmonth = null; // Initialise for static analysis (could be really unseg)
125$pastmonthyear = null;
126
127if (empty($date_startmonth)) {
128 // Period by default on transfer
130 $date_start = $dates['date_start'];
131 $pastmonthyear = $dates['pastmonthyear'];
132 $pastmonth = $dates['pastmonth'];
133}
134if (empty($date_endmonth)) {
135 // Period by default on transfer
137 $date_end = $dates['date_end'];
138 $pastmonthyear = $dates['pastmonthyear'];
139 $pastmonth = $dates['pastmonth'];
140}
141
142if (!GETPOSTISSET('date_startmonth') && (empty($date_start) || empty($date_end))) { // We define date_start and date_end, only if we did not submit the form
143 $date_start = dol_get_first_day((int) $pastmonthyear, (int) $pastmonth, false);
144 $date_end = dol_get_last_day((int) $pastmonthyear, (int) $pastmonth, false);
145}
146
147// Get all bank lines
148//-------------------------------------
149$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.amount_main_currency, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type, b.fk_account,";
150$sql .= " ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,";
151$sql .= " soc.rowid as socid, soc.nom as name, soc.email as email, bu1.type as typeop_company,";
152if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
153 $sql .= " spe.accountancy_code_customer_general,";
154 $sql .= " spe.accountancy_code_customer as code_compta_client,";
155 $sql .= " spe.accountancy_code_supplier_general,";
156 $sql .= " spe.accountancy_code_supplier as code_compta_fournisseur,";
157} else {
158 $sql .= " soc.accountancy_code_customer_general,";
159 $sql .= " soc.code_compta as code_compta_client,";
160 $sql .= " soc.accountancy_code_supplier_general,";
161 $sql .= " soc.code_compta_fournisseur,";
162}
163$sql .= " u.accountancy_code_user_general, u.accountancy_code, u.rowid as userid, u.lastname as lastname, u.firstname as firstname, u.email as useremail, u.statut as userstatus,";
164$sql .= " bu2.type as typeop_user,";
165$sql .= " bu3.type as typeop_payment, bu4.type as typeop_payment_supplier";
166$sql .= " FROM ".$db->prefix()."bank as b";
167$sql .= " JOIN ".$db->prefix()."bank_account as ba on b.fk_account = ba.rowid";
168$sql .= " LEFT JOIN ".$db->prefix()."bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
169$sql .= " LEFT JOIN ".$db->prefix()."bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='user'";
170$sql .= " LEFT JOIN ".$db->prefix()."bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment'";
171$sql .= " LEFT JOIN ".$db->prefix()."bank_url as bu4 ON bu4.fk_bank = b.rowid AND bu4.type='payment_supplier'";
172$sql .= " LEFT JOIN ".$db->prefix()."societe as soc on bu1.url_id=soc.rowid";
173if (getDolGlobalString('MAIN_COMPANY_PERENTITY_SHARED')) {
174 $sql .= " LEFT JOIN " . $db->prefix() . "societe_perentity as spe ON spe.fk_soc = soc.rowid AND spe.entity = " . ((int) $conf->entity);
175}
176$sql .= " LEFT JOIN ".$db->prefix()."user as u on bu2.url_id=u.rowid";
177$sql .= " WHERE ba.fk_accountancy_journal=".((int) $id_journal);
178$sql .= " AND b.amount <> 0 AND ba.entity IN (".getEntity('bank_account', 0).")"; // We don't share object for accountancy
179if ($date_start && $date_end) {
180 $sql .= " AND b.dateo >= '".$db->idate($date_start)."' AND b.dateo <= '".$db->idate($date_end)."'";
181}
182// Define begin binding date
183if (getDolGlobalInt('ACCOUNTING_DATE_START_BINDING')) {
184 $sql .= " AND b.dateo >= '".$db->idate(getDolGlobalInt('ACCOUNTING_DATE_START_BINDING'))."'";
185}
186// Already in bookkeeping or not
187if ($in_bookkeeping == 'already') {
188 $sql .= " AND (b.rowid IN (SELECT fk_doc FROM ".$db->prefix()."accounting_bookkeeping as ab WHERE ab.doc_type='bank') )";
189}
190if ($in_bookkeeping == 'notyet') {
191 $sql .= " AND (b.rowid NOT IN (SELECT fk_doc FROM ".$db->prefix()."accounting_bookkeeping as ab WHERE ab.doc_type='bank') )";
192}
193if ($only_rappro == 2) {
194 $sql .= " AND (b.rappro = '1')";
195}
196$sql .= " ORDER BY b.datev";
197//print $sql;
198
199$object = new Account($db);
200$paymentstatic = new Paiement($db);
201$paymentsupplierstatic = new PaiementFourn($db);
202$societestatic = new Societe($db);
203$userstatic = new User($db);
204$bankaccountstatic = new Account($db);
205$chargestatic = new ChargeSociales($db);
206$paymentdonstatic = new PaymentDonation($db);
207$paymentvatstatic = new Tva($db);
208$paymentsalstatic = new PaymentSalary($db);
209$paymentexpensereportstatic = new PaymentExpenseReport($db);
210$paymentvariousstatic = new PaymentVarious($db);
211$paymentloanstatic = new PaymentLoan($db);
212$accountLinestatic = new AccountLine($db);
213$paymentsubscriptionstatic = new Subscription($db);
214
215$tmppayment = new Paiement($db);
216$tmpinvoice = new Facture($db);
217
218$accountingaccount = new AccountingAccount($db);
219$account_transfer = 'NotDefined'; // For static analysis, NotDefined is a reserved word
220
221// Get code of finance journal
222$accountingjournalstatic = new AccountingJournal($db);
223$accountingjournalstatic->fetch($id_journal);
224$journal = $accountingjournalstatic->code;
225$journal_label = $accountingjournalstatic->label;
226
227$tabcompany = array();
228$tabuser = array();
229$tabpay = array();
230$tabbq = array();
231$tabtp = array();
232$tabtype = array();
233$tabmoreinfo = array();
234
235'
236@phan-var-force array<array{id:mixed,name:mixed,code_compta_client:string,email:string}> $tabcompany
237@phan-var-force array<array{id:int,name:string,lastname:string,firstname:string,email:string,accountancy_code:string,status:int> $tabuser
238@phan-var-force array<int,array{date:string,type_payment:string,ref:string,fk_bank:int,ban_account_ref:string,fk_bank_account:int,lib:string,type:string}> $tabpay
239@phan-var-force array<array{lib:string,date?:int|string,type_payment?:string,ref?:string,fk_bank?:int,ban_account_ref?:string,fk_bank_account?:int,type?:string,bank_account_ref?:string,paymentid?:int,paymentsupplierid?:int,soclib?:string,paymentscid?:int,paymentdonationid?:int,paymentsubscriptionid?:int,paymentvatid?:int,paymentsalid?:int,paymentexpensereport?:int,paymentvariousid?:int,account_various?:string,paymentloanid?:int}> $tabtp
240';
241
242$account_customer = 'NotDefined';
243$account_supplier = 'NotDefined';
244$account_employee = 'NotDefined';
245
246//print $sql;
247dol_syslog("accountancy/journal/bankjournal.php", LOG_DEBUG);
248$result = $db->query($sql);
249if ($result) {
250 $num = $db->num_rows($result);
251 //print $sql;
252
253 // Variables
254 $account_supplier = getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER', 'NotDefined'); // NotDefined is a reserved word
255 $account_customer = getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER', 'NotDefined'); // NotDefined is a reserved word
256 $account_employee = getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT', 'NotDefined'); // NotDefined is a reserved word
257 $account_expensereport = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT', 'NotDefined'); // NotDefined is a reserved word
258 $account_pay_vat = getDolGlobalString('ACCOUNTING_VAT_PAY_ACCOUNT', 'NotDefined'); // NotDefined is a reserved word
259 $account_pay_donation = getDolGlobalString('DONATION_ACCOUNTINGACCOUNT', 'NotDefined'); // NotDefined is a reserved word
260 $account_pay_subscription = getDolGlobalString('ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT', 'NotDefined'); // NotDefined is a reserved word
261 $account_transfer = getDolGlobalString('ACCOUNTING_ACCOUNT_TRANSFER_CASH', 'NotDefined'); // NotDefined is a reserved word
262
263 // Loop on each line into the llx_bank table. For each line, we should get:
264 // one line tabpay = line into bank
265 // one line for bank record = tabbq
266 // one line for thirdparty record = tabtp
267 // Note: tabcompany is used to store the subledger account
268 $i = 0;
269 while ($i < $num) {
270 $obj = $db->fetch_object($result);
271
272 $lineisapurchase = -1;
273 $lineisasale = -1;
274 // Old method to detect if it's a sale or purchase
275 if ($obj->label == '(SupplierInvoicePayment)' || $obj->label == '(SupplierInvoicePaymentBack)') {
276 $lineisapurchase = 1;
277 }
278 if ($obj->label == '(CustomerInvoicePayment)' || $obj->label == '(CustomerInvoicePaymentBack)') {
279 $lineisasale = 1;
280 }
281 // Try a more reliable method to detect if record is a supplier payment or a customer payment
282 if ($lineisapurchase < 0) {
283 if ($obj->typeop_payment_supplier == 'payment_supplier') {
284 $lineisapurchase = 1;
285 }
286 }
287 if ($lineisasale < 0) {
288 if ($obj->typeop_payment == 'payment') {
289 $lineisasale = 1;
290 }
291 }
292 //var_dump($obj->type_payment); //var_dump($obj->type_payment_supplier);
293 //var_dump($lineisapurchase); //var_dump($lineisasale);
294
295 // Set accountancy code for bank
296 $compta_bank = $obj->account_number;
297
298 // Set accountancy code for thirdparty (example: '411CU...' or '411' if no subledger account defined on customer)
299 $compta_soc = 'NotDefined';
300 $accountancy_code_general = 'NotDefined';
301 if ($lineisapurchase > 0) {
302 $accountancy_code_general = (!empty($obj->accountancy_code_supplier_general) && $obj->accountancy_code_supplier_general != '-1') ? $obj->accountancy_code_supplier_general : $account_supplier;
303 $compta_soc = (($obj->code_compta_fournisseur != "") ? $obj->code_compta_fournisseur : $account_supplier);
304 }
305 if ($lineisasale > 0) {
306 $accountancy_code_general = (!empty($obj->accountancy_code_customer_general) && $obj->accountancy_code_customer_general != '-1') ? $obj->accountancy_code_customer_general : $account_customer;
307 $compta_soc = (!empty($obj->code_compta_client) ? $obj->code_compta_client : $account_customer);
308 }
309
310 $tabcompany[$obj->rowid] = array(
311 'id' => $obj->socid,
312 'name' => $obj->name,
313 'code_compta' => $compta_soc,
314 'accountancy_code_general' => $accountancy_code_general,
315 'email' => $obj->email
316 );
317
318 // Set accountancy code for user
319 // $obj->accountancy_code is the accountancy_code of table u=user (but it is defined only if
320 // a link with type 'user' exists and user as a subledger account)
321 $accountancy_code_user_general = (!empty($obj->accountancy_code_user_general)) ? $obj->accountancy_code_user_general : $account_employee;
322 $compta_user = (!empty($obj->accountancy_code) ? $obj->accountancy_code : '');
323
324 $tabuser[$obj->rowid] = array(
325 'id' => $obj->userid,
326 'name' => dolGetFirstLastname($obj->firstname, $obj->lastname),
327 'lastname' => $obj->lastname,
328 'firstname' => $obj->firstname,
329 'email' => $obj->useremail,
330 'accountancy_code_general' => $accountancy_code_user_general,
331 'accountancy_code' => $compta_user,
332 'status' => $obj->userstatus
333 );
334
335 // Variable bookkeeping ($obj->rowid is Bank Id)
336 $tabpay[$obj->rowid]["date"] = $db->jdate($obj->do);
337 $tabpay[$obj->rowid]["type_payment"] = $obj->fk_type; // CHQ, VIR, LIQ, CB, ...
338 $tabpay[$obj->rowid]["ref"] = $obj->label; // By default. Not unique. May be changed later
339 $tabpay[$obj->rowid]["fk_bank"] = $obj->rowid;
340 $tabpay[$obj->rowid]["bank_account_ref"] = $obj->baref;
341 $tabpay[$obj->rowid]["fk_bank_account"] = $obj->fk_account;
342 $reg = array();
343 if (preg_match('/^\‍((.*)\‍)$/i', $obj->label, $reg)) {
344 $tabpay[$obj->rowid]["lib"] = $langs->trans($reg[1]);
345 } else {
346 $tabpay[$obj->rowid]["lib"] = dol_trunc($obj->label, 60);
347 }
348
349 // Load of url links to the line into llx_bank (so load llx_bank_url)
350 $links = $object->get_url($obj->rowid); // Get an array('url'=>, 'url_id'=>, 'label'=>, 'type'=> 'fk_bank'=> )
351 // print '<p>' . json_encode($object) . "</p>";//exit;
352 // print '<p>' . json_encode($links) . "</p>";//exit;
353
354 // By default
355 $tabpay[$obj->rowid]['type'] = 'unknown'; // Can be SOLD, miscellaneous entry, payment of patient, or any old record with no links in bank_url.
356 $tabtype[$obj->rowid] = 'unknown';
357 $tabmoreinfo[$obj->rowid] = array();
358
359 $amounttouse = $obj->amount;
360 if (!empty($obj->amount_main_currency)) {
361 // If $obj->amount_main_currency is set, it means that $obj->amount is not in same currency, we must use $obj->amount_main_currency
362 $amounttouse = $obj->amount_main_currency;
363 }
364
365 // get_url may return -1 which is not traversable
366 if (is_array($links) && count($links) > 0) {
367 // Test if entry is for a social contribution, salary or expense report.
368 // In such a case, we will ignore the bank url line for user
369 $is_sc = false;
370 $is_salary = false;
371 $is_expensereport = false;
372 foreach ($links as $v) {
373 if ($v['type'] == 'sc') {
374 $is_sc = true;
375 break;
376 }
377 if ($v['type'] == 'payment_salary') {
378 $is_salary = true;
379 break;
380 }
381 if ($v['type'] == 'payment_expensereport') {
382 $is_expensereport = true;
383 break;
384 }
385 }
386
387 // Now loop on each link of record in bank (code similar to bankentries_list.php)
388 foreach ($links as $key => $val) {
389 if ($links[$key]['type'] == 'user' && !$is_sc && !$is_salary && !$is_expensereport) {
390 // We must avoid as much as possible this "continue". If we want to jump to next loop, it means we don't want to process
391 // the case the link is user (often because managed by hard coded code into another link), and we must avoid this.
392 continue;
393 }
394 if (in_array($links[$key]['type'], array('sc', 'payment_sc', 'payment', 'payment_supplier', 'payment_vat', 'payment_expensereport', 'banktransfert', 'payment_donation', 'member', 'payment_loan', 'payment_salary', 'payment_various'))) {
395 // So we excluded 'company' and 'user' here. We want only payment lines
396
397 // We save tabtype for a future use, to remember what kind of payment it is
398 $tabpay[$obj->rowid]['type'] = $links[$key]['type'];
399 $tabtype[$obj->rowid] = $links[$key]['type'];
400 /* phpcs:disable -- Code does nothing at this moment -> commented
401 } elseif (in_array($links[$key]['type'], array('company', 'user'))) {
402 if ($tabpay[$obj->rowid]['type'] == 'unknown') {
403 // We can guess here it is a bank record for a thirdparty company or a user.
404 // But we won't be able to record somewhere else than into a waiting account, because there is no other journal to record the contreparty.
405 }
406 */ // phpcs::enable
407 }
408
409 // Special case to ask later to add more request to get information for old links without company link.
410 if ($links[$key]['type'] == 'withdraw') {
411 $tabmoreinfo[$obj->rowid]['withdraw'] = 1;
412 }
413
414 if ($links[$key]['type'] == 'payment') {
415 $paymentstatic->id = $links[$key]['url_id'];
416 $paymentstatic->ref = (string) $links[$key]['url_id'];
417 $tabpay[$obj->rowid]["lib"] .= ' '.$paymentstatic->getNomUrl(2, '', ''); // TODO Do not include list of invoice in tooltip, the dol_string_nohtmltag is ko with this
418 $tabpay[$obj->rowid]["paymentid"] = $paymentstatic->id;
419 } elseif ($links[$key]['type'] == 'payment_supplier') {
420 $paymentsupplierstatic->id = $links[$key]['url_id'];
421 $paymentsupplierstatic->ref = (string) $links[$key]['url_id'];
422 $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsupplierstatic->getNomUrl(2);
423 $tabpay[$obj->rowid]["paymentsupplierid"] = $paymentsupplierstatic->id;
424 } elseif ($links[$key]['type'] == 'company') {
425 $societestatic->id = $links[$key]['url_id'];
426 $societestatic->name = $links[$key]['label'];
427 $societestatic->email = $tabcompany[$obj->rowid]['email'];
428 $tabpay[$obj->rowid]["soclib"] = $societestatic->getNomUrl(1, '', 30);
429 if ($compta_soc) {
430 if (empty($tabtp[$obj->rowid][$compta_soc])) {
431 $tabtp[$obj->rowid][$compta_soc] = $amounttouse;
432 } else {
433 $tabtp[$obj->rowid][$compta_soc] += $amounttouse;
434 }
435 }
436 } elseif ($links[$key]['type'] == 'user') {
437 $userstatic->id = $links[$key]['url_id'];
438 $userstatic->name = $links[$key]['label'];
439 $userstatic->email = $tabuser[$obj->rowid]['email'];
440 $userstatic->firstname = $tabuser[$obj->rowid]['firstname'];
441 $userstatic->lastname = $tabuser[$obj->rowid]['lastname'];
442 $userstatic->status = $tabuser[$obj->rowid]['status'];
443 $userstatic->accountancy_code_user_general = $tabuser[$obj->rowid]['accountancy_code_general'];
444 $userstatic->accountancy_code = $tabuser[$obj->rowid]['accountancy_code'];
445
446 // For a payment of social contribution, we have a link sc + user.
447 // but we already fill the $tabpay[$obj->rowid]["soclib"] in the line 'sc'.
448 // If we fill it here to, we must concat.
449 if ($userstatic->id > 0) {
450 if ($is_sc) {
451 $tabpay[$obj->rowid]["soclib"] .= ' '.$userstatic->getNomUrl(-1, 'accountancy', 0);
452 } else {
453 $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(-1, 'accountancy', 0);
454 }
455 } else {
456 $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen, but happens with old data when id of user was not saved on expense report payment.
457 }
458
459 if ($compta_user) {
460 if ($is_sc) {
461 //$tabcompany[$obj->rowid][$compta_user] += $amounttouse;
462 } else {
463 if (empty($tabtp[$obj->rowid][$compta_user])) {
464 $tabtp[$obj->rowid][$compta_user] = $amounttouse;
465 } else {
466 $tabtp[$obj->rowid][$compta_user] += $amounttouse;
467 }
468 }
469 }
470 } elseif ($links[$key]['type'] == 'sc') {
471 $chargestatic->id = $links[$key]['url_id'];
472 $chargestatic->ref = (string) $links[$key]['url_id'];
473
474 $tabpay[$obj->rowid]["lib"] .= ' '.$chargestatic->getNomUrl(2);
475 $reg = array();
476 if (preg_match('/^\‍((.*)\‍)$/i', $links[$key]['label'], $reg)) {
477 if ($reg[1] == 'socialcontribution') {
478 $reg[1] = 'SocialContribution';
479 }
480 $chargestatic->label = $langs->trans($reg[1]);
481 } else {
482 $chargestatic->label = $links[$key]['label'];
483 }
484 $chargestatic->ref = $chargestatic->label;
485
486 // Retrieve the accounting code of the social contribution of the payment from link of payment.
487 // Note: We have the social contribution id, it can be faster to get accounting code from social contribution id.
488 /*
489 $sqlmid = "SELECT cchgsoc.accountancy_code";
490 $sqlmid .= " FROM ".MAIN_DB_PREFIX."c_chargesociales cchgsoc";
491 $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."chargesociales as chgsoc ON chgsoc.fk_type = cchgsoc.id";
492 $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."paiementcharge as paycharg ON paycharg.fk_charge = chgsoc.rowid";
493 $sqlmid .= " INNER JOIN ".MAIN_DB_PREFIX."bank_url as bkurl ON bkurl.url_id=paycharg.rowid AND bkurl.type = 'payment_sc'";
494 $sqlmid .= " WHERE bkurl.fk_bank = ".((int) $obj->rowid);
495
496 dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG);
497 $resultmid = $db->query($sqlmid);
498 if ($resultmid) {
499 $objmid = $db->fetch_object($resultmid);
500 $tabtp[$obj->rowid][$objmid->accountancy_code] = isset($tabtp[$obj->rowid][$objmid->accountancy_code]) ? $tabtp[$obj->rowid][$objmid->accountancy_code] + $amounttouse : $amounttouse;
501 }*/
502 $tmpcharge = new ChargeSociales($db);
503 $resultmid = $tmpcharge->fetch($chargestatic->id);
504 if ($resultmid) {
505 $chargestatic->type_label = $tmpcharge->type_label;
506 $chargestatic->type_code = $tmpcharge->type_code;
507 $chargestatic->type_accountancy_code = $tmpcharge->type_accountancy_code;
508
509 $tabtp[$obj->rowid][$tmpcharge->type_accountancy_code] = isset($tabtp[$obj->rowid][$tmpcharge->type_accountancy_code]) ? $tabtp[$obj->rowid][$tmpcharge->type_accountancy_code] + $amounttouse : $amounttouse;
510 }
511
512 $tabpay[$obj->rowid]["soclib"] = $chargestatic->getNomUrl(1, '30');
513 $tabpay[$obj->rowid]["paymentscid"] = $chargestatic->id;
514 } elseif ($links[$key]['type'] == 'payment_donation') {
515 $paymentdonstatic->id = $links[$key]['url_id'];
516 $paymentdonstatic->ref = (string) $links[$key]['url_id'];
517 $paymentdonstatic->fk_donation = $links[$key]['url_id'];
518 $tabpay[$obj->rowid]["lib"] .= ' '.$paymentdonstatic->getNomUrl(2);
519 $tabpay[$obj->rowid]["paymentdonationid"] = $paymentdonstatic->id;
520 $tabtp[$obj->rowid][$account_pay_donation] = isset($tabtp[$obj->rowid][$account_pay_donation]) ? $tabtp[$obj->rowid][$account_pay_donation] + $amounttouse : $amounttouse;
521 } elseif ($links[$key]['type'] == 'member') {
522 $paymentsubscriptionstatic->id = $links[$key]['url_id'];
523 $paymentsubscriptionstatic->ref = (string) $links[$key]['url_id'];
524 $paymentsubscriptionstatic->label = $links[$key]['label'];
525 $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsubscriptionstatic->getNomUrl(2);
526 $tabpay[$obj->rowid]["paymentsubscriptionid"] = $paymentsubscriptionstatic->id;
527 $paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id);
528 $tabtp[$obj->rowid][$account_pay_subscription] = isset($tabtp[$obj->rowid][$account_pay_subscription]) ? $tabtp[$obj->rowid][$account_pay_subscription] + $amounttouse : $amounttouse;
529 } elseif ($links[$key]['type'] == 'payment_vat') { // Payment VAT
530 $paymentvatstatic->id = $links[$key]['url_id'];
531 $paymentvatstatic->ref = (string) $links[$key]['url_id'];
532 $paymentvatstatic->label = $links[$key]['label'];
533 $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvatstatic->getNomUrl(2);
534 $tabpay[$obj->rowid]["paymentvatid"] = $paymentvatstatic->id;
535 $tabtp[$obj->rowid][$account_pay_vat] = isset($tabtp[$obj->rowid][$account_pay_vat]) ? $tabtp[$obj->rowid][$account_pay_vat] + $amounttouse : $amounttouse;
536 } elseif ($links[$key]['type'] == 'payment_salary') {
537 $paymentsalstatic->id = $links[$key]['url_id'];
538 $paymentsalstatic->ref = (string) $links[$key]['url_id'];
539 $paymentsalstatic->label = $links[$key]['label'];
540 $tabpay[$obj->rowid]["lib"] .= ' '.$paymentsalstatic->getNomUrl(2);
541 $tabpay[$obj->rowid]["paymentsalid"] = $paymentsalstatic->id;
542
543 // This part of code is no more required. it is here to solve case where a link were missing (with v14.0.0) and keep writing in accountancy complete.
544 // Note: A better way to fix this is to delete payment of salary and recreate it, or to fix the bookkeeping table manually after.
545 if (getDolGlobalString('ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USER_ON_SALARY_BANK_PAYMENT')) {
546 $tmpsalary = new Salary($db);
547 $tmpsalary->fetch($paymentsalstatic->id);
548 $tmpsalary->fetch_user($tmpsalary->fk_user);
549
550 $userstatic->id = $tmpsalary->user->id;
551 $userstatic->name = $tmpsalary->user->name;
552 $userstatic->email = $tmpsalary->user->email;
553 $userstatic->firstname = $tmpsalary->user->firstname;
554 $userstatic->lastname = $tmpsalary->user->lastname;
555 $userstatic->status = $tmpsalary->user->status;
556 $userstatic->accountancy_code = $tmpsalary->user->accountancy_code;
557
558 if ($userstatic->id > 0) {
559 $tabpay[$obj->rowid]["soclib"] = $userstatic->getNomUrl(1, 'accountancy', 0);
560 } else {
561 $tabpay[$obj->rowid]["soclib"] = '???'; // Should not happen
562 }
563
564 if (empty($obj->typeop_user)) { // Add test to avoid adding amount twice if a link already exists also on user.
565 $accountancy_code_user_general = (!empty($obj->accountancy_code_user_general)) ? $obj->accountancy_code_user_general : $account_employee;
566 $compta_user = $userstatic->accountancy_code;
567 if ($compta_user) {
568 if (empty($tabtp[$obj->rowid][$compta_user])) {
569 $tabtp[$obj->rowid][$compta_user] = $amounttouse;
570 } else {
571 $tabtp[$obj->rowid][$compta_user] += $amounttouse;
572 }
573 $tabuser[$obj->rowid] = array(
574 'id' => $userstatic->id,
575 'name' => dolGetFirstLastname($userstatic->firstname, $userstatic->lastname),
576 'lastname' => $userstatic->lastname,
577 'firstname' => $userstatic->firstname,
578 'email' => $userstatic->email,
579 'accountancy_code_general' => $accountancy_code_user_general,
580 'accountancy_code' => $compta_user,
581 'status' => $userstatic->status
582 );
583 }
584 }
585 }
586 } elseif ($links[$key]['type'] == 'payment_expensereport') {
587 $paymentexpensereportstatic->id = $links[$key]['url_id'];
588 $tabpay[$obj->rowid]["lib"] .= $paymentexpensereportstatic->getNomUrl(2);
589 $tabpay[$obj->rowid]["paymentexpensereport"] = $paymentexpensereportstatic->id;
590 } elseif ($links[$key]['type'] == 'payment_various') {
591 $paymentvariousstatic->id = $links[$key]['url_id'];
592 $paymentvariousstatic->ref = (string) $links[$key]['url_id'];
593 $paymentvariousstatic->label = $links[$key]['label'];
594 $tabpay[$obj->rowid]["lib"] .= ' '.$paymentvariousstatic->getNomUrl(2);
595 $tabpay[$obj->rowid]["paymentvariousid"] = $paymentvariousstatic->id;
596 $paymentvariousstatic->fetch($paymentvariousstatic->id);
597 $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : 'NotDefined'); // NotDefined is a reserved word
598 $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account : ''); // NotDefined is a reserved word
599 $tabpay[$obj->rowid]["account_various"] = $account_various;
600 $tabtp[$obj->rowid][$account_subledger] = isset($tabtp[$obj->rowid][$account_subledger]) ? $tabtp[$obj->rowid][$account_subledger] + $amounttouse : $amounttouse;
601 } elseif ($links[$key]['type'] == 'payment_loan') {
602 $paymentloanstatic->id = $links[$key]['url_id'];
603 $paymentloanstatic->ref = (string) $links[$key]['url_id'];
604 $paymentloanstatic->fk_loan = $links[$key]['url_id'];
605 $tabpay[$obj->rowid]["lib"] .= ' '.$paymentloanstatic->getNomUrl(2);
606 $tabpay[$obj->rowid]["paymentloanid"] = $paymentloanstatic->id;
607 //$tabtp[$obj->rowid][$account_pay_loan] += $amounttouse;
608 $sqlmid = 'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest';
609 $sqlmid .= ' FROM '.MAIN_DB_PREFIX.'payment_loan as pl, '.MAIN_DB_PREFIX.'loan as l';
610 $sqlmid .= ' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.((int) $obj->rowid);
611
612 dol_syslog("accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG);
613 $resultmid = $db->query($sqlmid);
614 if ($resultmid) {
615 $objmid = $db->fetch_object($resultmid);
616 $tabtp[$obj->rowid][$objmid->accountancy_account_capital] = isset($objmid->amount_capital) ? ($tabtp[$obj->rowid][$objmid->accountancy_account_capital] ?? 0) - $objmid->amount_capital : 0;
617 $tabtp[$obj->rowid][$objmid->accountancy_account_insurance] = isset($objmid->amount_insurance) ? ($tabtp[$obj->rowid][$objmid->accountancy_account_insurance] ?? 0) - $objmid->amount_insurance : 0;
618 $tabtp[$obj->rowid][$objmid->accountancy_account_interest] = isset($objmid->amount_interest) ? ($tabtp[$obj->rowid][$objmid->accountancy_account_interest] ?? 0) - $objmid->amount_interest : 0;
619 }
620 } elseif ($links[$key]['type'] == 'banktransfert') {
621 $accountLinestatic->fetch($links[$key]['url_id']);
622 $tabpay[$obj->rowid]["lib"] .= ' '.$langs->trans("BankTransfer").' '.$accountLinestatic ->getNomUrl(1);
623 $tabtp[$obj->rowid][$account_transfer] = isset($tabtp[$obj->rowid][$account_transfer]) ? $tabtp[$obj->rowid][$account_transfer] + $amounttouse : $amounttouse;
624 $bankaccountstatic->fetch($tabpay[$obj->rowid]['fk_bank_account']);
625 $tabpay[$obj->rowid]["soclib"] = $bankaccountstatic->getNomUrl(2);
626 }
627 }
628 }
629
630 if (empty($tabbq[$obj->rowid][$compta_bank])) {
631 $tabbq[$obj->rowid][$compta_bank] = $amounttouse;
632 } else {
633 $tabbq[$obj->rowid][$compta_bank] += $amounttouse;
634 }
635
636 // If no links were found to know the amount on thirdparty, we try to guess it.
637 // This may happens on bank entries without the links lines to 'company'.
638 if (empty($tabtp[$obj->rowid]) && !empty($tabmoreinfo[$obj->rowid]['withdraw'])) { // If we don't find 'company' link because it is an old 'withdraw' record
639 foreach ($links as $key => $val) {
640 if ($links[$key]['type'] == 'payment') {
641 // Get thirdparty
642 $tmppayment->fetch($links[$key]['url_id']);
643 $arrayofamounts = $tmppayment->getAmountsArray();
644 if (is_array($arrayofamounts)) {
645 foreach ($arrayofamounts as $invoiceid => $amount) {
646 $tmpinvoice->fetch($invoiceid);
647 $tmpinvoice->fetch_thirdparty();
648 if ($tmpinvoice->thirdparty->code_compta_client) {
649 $tabtp[$obj->rowid][$tmpinvoice->thirdparty->code_compta_client] += $amount;
650 }
651 }
652 }
653 }
654 }
655 }
656
657 // If no links were found to know the amount on thirdparty/user, we init it to account 'NotDefined'.
658 if (empty($tabtp[$obj->rowid])) {
659 $tabtp[$obj->rowid]['NotDefined'] = $tabbq[$obj->rowid][$compta_bank];
660 }
661
662 // if($obj->socid)$tabtp[$obj->rowid][$compta_soc] += $amounttouse;
663
664 $i++;
665 }
666} else {
667 dol_print_error($db);
668}
669
670// Write bookkeeping
671if (!$error && $action == 'writebookkeeping' && $user->hasRight('accounting', 'bind', 'write')) {
672 $now = dol_now();
673
674 $accountingaccountcustomer = new AccountingAccount($db);
675 $accountingaccountcustomer->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER'), true);
676
677 $accountingaccountsupplier = new AccountingAccount($db);
678 $accountingaccountsupplier->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER'), true);
679
680 $accountingaccountpayment = new AccountingAccount($db);
681 $accountingaccountpayment->fetch(0, getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'), true);
682
683 $accountingaccountexpensereport = new AccountingAccount($db);
684 $accountingaccountexpensereport->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT'), true);
685
686 $accountingaccountsuspense = new AccountingAccount($db);
687 $accountingaccountsuspense->fetch(0, getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'), true);
688
689 $error = 0;
690 foreach ($tabpay as $key => $val) { // $key is rowid into llx_bank
691 $date = dol_print_date($val["date"], 'day');
692
693 $ref = getSourceDocRef($val, $tabtype[$key]);
694
695 $errorforline = 0;
696
697 $totalcredit = 0;
698 $totaldebit = 0;
699
700 $db->begin();
701
702 // Introduce a protection. Total of tabtp must be total of tabbq
703
704 // Bank
705 if (is_array($tabbq[$key])) {
706 // Line into bank account
707 foreach ($tabbq[$key] as $k => $mt) {
708 if ($mt) {
709 if (empty($conf->cache['accountingaccountincurrententity'][$k])) {
710 $accountingaccount = new AccountingAccount($db);
711 $accountingaccount->fetch(0, $k, true); // $k is accounting account of the bank.
712 $conf->cache['accountingaccountincurrententity'][$k] = $accountingaccount;
713 } else {
714 $accountingaccount = $conf->cache['accountingaccountincurrententity'][$k];
715 }
716
717 $account_label = $accountingaccount->label;
718
719 $reflabel = '';
720 if (!empty($val['lib'])) {
721 $reflabel .= dol_string_nohtmltag($val['lib'])." / ";
722 }
723 $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']);
724 if (!empty($val['soclib'])) {
725 $reflabel .= " / ".dol_string_nohtmltag($val['soclib']);
726 }
727
728 $bookkeeping = new BookKeeping($db);
729 $bookkeeping->doc_date = $val["date"];
730 $bookkeeping->doc_ref = $ref;
731 $bookkeeping->doc_type = 'bank';
732 $bookkeeping->fk_doc = $key;
733 $bookkeeping->fk_docdet = $val["fk_bank"];
734
735 $bookkeeping->numero_compte = $k;
736 $bookkeeping->label_compte = $account_label;
737
738 $bookkeeping->label_operation = $reflabel;
739 $bookkeeping->montant = $mt;
740 $bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
741 $bookkeeping->debit = ($mt >= 0 ? $mt : 0);
742 $bookkeeping->credit = ($mt < 0 ? -$mt : 0);
743 $bookkeeping->code_journal = $journal;
744 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
745 $bookkeeping->fk_user_author = $user->id;
746 $bookkeeping->date_creation = $now;
747
748 // No subledger_account value for the bank line but add a specific label_operation
749 $bookkeeping->subledger_account = '';
750 $bookkeeping->label_operation = $reflabel;
751 $bookkeeping->entity = $conf->entity;
752
753 $totaldebit += $bookkeeping->debit;
754 $totalcredit += $bookkeeping->credit;
755
756 $result = $bookkeeping->create($user);
757 if ($result < 0) {
758 if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists
759 $error++;
760 $errorforline++;
761 setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
762 } else {
763 $error++;
764 $errorforline++;
765 setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
766 }
767 }
768 }
769 }
770 }
771
772 // Third party
773 if (!$errorforline) {
774 if (is_array($tabtp[$key])) {
775 // Line into thirdparty account
776 foreach ($tabtp[$key] as $k => $mt) {
777 if ($mt) {
778 $lettering = false;
779
780 $reflabel = '';
781 if (!empty($val['lib'])) {
782 $reflabel .= dol_string_nohtmltag($val['lib']).(!empty($val['soclib']) ? " / " : "");
783 }
784 if ($tabtype[$key] == 'banktransfert') {
785 $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer);
786 } else {
787 $reflabel .= dol_string_nohtmltag($val['soclib'] ?? '');
788 }
789
790 $bookkeeping = new BookKeeping($db);
791 $bookkeeping->doc_date = $val["date"];
792 $bookkeeping->doc_ref = $ref;
793 $bookkeeping->doc_type = 'bank';
794 $bookkeeping->fk_doc = $key;
795 $bookkeeping->fk_docdet = $val["fk_bank"];
796
797 $bookkeeping->label_operation = $reflabel;
798 $bookkeeping->montant = $mt;
799 $bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
800 $bookkeeping->debit = ($mt < 0 ? -$mt : 0);
801 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
802 $bookkeeping->code_journal = $journal;
803 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
804 $bookkeeping->fk_user_author = $user->id;
805 $bookkeeping->date_creation = $now;
806
807 if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice
808 $lettering = true;
809 $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp
810 $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction
811 $bookkeeping->numero_compte = $tabcompany[$key]['accountancy_code_general'];
812 $bookkeeping->label_compte = $accountingaccountcustomer->label;
813 } elseif ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice
814 $lettering = true;
815 $bookkeeping->subledger_account = $k; // For payment, the subledger account is stored as $key of $tabtp
816 $bookkeeping->subledger_label = $tabcompany[$key]['name']; // $tabcompany is defined only if we are sure there is 1 thirdparty for the bank transaction
817 $bookkeeping->numero_compte = $tabcompany[$key]['accountancy_code_general'];
818 $bookkeeping->label_compte = $accountingaccountsupplier->label;
819 } elseif ($tabtype[$key] == 'payment_expensereport') {
820 $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code'];
821 $bookkeeping->subledger_label = $tabuser[$key]['name'];
822 $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT');
823 $bookkeeping->label_compte = $accountingaccountexpensereport->label;
824 } elseif ($tabtype[$key] == 'payment_salary') {
825 $bookkeeping->subledger_account = $tabuser[$key]['accountancy_code'];
826 $bookkeeping->subledger_label = $tabuser[$key]['name'];
827 $bookkeeping->numero_compte = $tabuser[$key]['accountancy_code_general'];
828 $bookkeeping->label_compte = $accountingaccountpayment->label;
829 } elseif (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution
830 $bookkeeping->subledger_account = '';
831 $bookkeeping->subledger_label = '';
832 if (empty($conf->cache['accountingaccountincurrententity'][$k])) {
833 $accountingaccount = new AccountingAccount($db);
834 $accountingaccount->fetch(0, $k, true);
835 $conf->cache['accountingaccountincurrententity'][$k] = $accountingaccount;
836 } else {
837 $accountingaccount = $conf->cache['accountingaccountincurrententity'][$k];
838 }
839 $bookkeeping->numero_compte = $k;
840 $bookkeeping->label_compte = $accountingaccount->label;
841 } elseif ($tabtype[$key] == 'payment_vat') {
842 $bookkeeping->subledger_account = '';
843 $bookkeeping->subledger_label = '';
844 if (empty($conf->cache['accountingaccountincurrententity'][$k])) {
845 $accountingaccount = new AccountingAccount($db);
846 $accountingaccount->fetch(0, $k, true);
847 $conf->cache['accountingaccountincurrententity'][$k] = $accountingaccount;
848 } else {
849 $accountingaccount = $conf->cache['accountingaccountincurrententity'][$k];
850 }
851 $bookkeeping->numero_compte = $k;
852 $bookkeeping->label_compte = $accountingaccount->label;
853 } elseif ($tabtype[$key] == 'payment_donation') {
854 $bookkeeping->subledger_account = '';
855 $bookkeeping->subledger_label = '';
856 if (empty($conf->cache['accountingaccountincurrententity'][$k])) {
857 $accountingaccount = new AccountingAccount($db);
858 $accountingaccount->fetch(0, $k, true);
859 $conf->cache['accountingaccountincurrententity'][$k] = $accountingaccount;
860 } else {
861 $accountingaccount = $conf->cache['accountingaccountincurrententity'][$k];
862 }
863 $bookkeeping->numero_compte = $k;
864 $bookkeeping->label_compte = $accountingaccount->label;
865 } elseif ($tabtype[$key] == 'member') {
866 $bookkeeping->subledger_account = '';
867 $bookkeeping->subledger_label = '';
868 if (empty($conf->cache['accountingaccountincurrententity'][$k])) {
869 $accountingaccount = new AccountingAccount($db);
870 $accountingaccount->fetch(0, $k, true);
871 $conf->cache['accountingaccountincurrententity'][$k] = $accountingaccount;
872 } else {
873 $accountingaccount = $conf->cache['accountingaccountincurrententity'][$k];
874 }
875 $bookkeeping->numero_compte = $k;
876 $bookkeeping->label_compte = $accountingaccount->label;
877 } elseif ($tabtype[$key] == 'payment_loan') {
878 $bookkeeping->subledger_account = '';
879 $bookkeeping->subledger_label = '';
880 if (empty($conf->cache['accountingaccountincurrententity'][$k])) {
881 $accountingaccount = new AccountingAccount($db);
882 $accountingaccount->fetch(0, $k, true);
883 $conf->cache['accountingaccountincurrententity'][$k] = $accountingaccount;
884 } else {
885 $accountingaccount = $conf->cache['accountingaccountincurrententity'][$k];
886 }
887 $bookkeeping->numero_compte = $k;
888 $bookkeeping->label_compte = $accountingaccount->label;
889 } elseif ($tabtype[$key] == 'payment_various') {
890 $bookkeeping->subledger_account = $k;
891 $bookkeeping->subledger_label = $tabcompany[$key]['name'];
892 if (empty($conf->cache['accountingaccountincurrententity'][$tabpay[$key]["account_various"]])) {
893 $accountingaccount = new AccountingAccount($db);
894 $accountingaccount->fetch(0, $tabpay[$key]["account_various"], true);
895 $conf->cache['accountingaccountincurrententity'][$tabpay[$key]["account_various"]] = $accountingaccount;
896 } else {
897 $accountingaccount = $conf->cache['accountingaccountincurrententity'][$tabpay[$key]["account_various"]];
898 }
899 $bookkeeping->numero_compte = $tabpay[$key]["account_various"];
900 $bookkeeping->label_compte = $accountingaccount->label;
901 } elseif ($tabtype[$key] == 'banktransfert') {
902 $bookkeeping->subledger_account = '';
903 $bookkeeping->subledger_label = '';
904 if (empty($conf->cache['accountingaccountincurrententity'][$k])) {
905 $accountingaccount = new AccountingAccount($db);
906 $accountingaccount->fetch(0, $k, true);
907 $conf->cache['accountingaccountincurrententity'][$k] = $accountingaccount;
908 } else {
909 $accountingaccount = $conf->cache['accountingaccountincurrententity'][$k];
910 }
911 $bookkeeping->numero_compte = $k;
912 $bookkeeping->label_compte = $accountingaccount->label;
913 } else {
914 if ($tabtype[$key] == 'unknown') { // Unknown transaction, we will use a waiting account for thirdparty.
915 // Temporary account
916 $bookkeeping->subledger_account = '';
917 $bookkeeping->subledger_label = '';
918 $bookkeeping->numero_compte = getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE');
919 $bookkeeping->label_compte = $accountingaccountsuspense->label;
920 }
921 }
922 $bookkeeping->label_operation = $reflabel;
923 $bookkeeping->entity = $conf->entity;
924
925 $totaldebit += $bookkeeping->debit;
926 $totalcredit += $bookkeeping->credit;
927
928 $result = $bookkeeping->create($user);
929 if ($result < 0) {
930 if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists
931 $error++;
932 $errorforline++;
933 setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
934 } else {
935 $error++;
936 $errorforline++;
937 setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
938 }
939 } else {
940 if ($lettering && getDolGlobalInt('ACCOUNTING_ENABLE_LETTERING') && getDolGlobalInt('ACCOUNTING_ENABLE_AUTOLETTERING')) {
941 require_once DOL_DOCUMENT_ROOT . '/accountancy/class/lettering.class.php';
942 $lettering_static = new Lettering($db);
943 $nb_lettering = $lettering_static->bookkeepingLetteringAll(array($bookkeeping->id));
944 }
945 }
946 }
947 }
948 } else { // If thirdparty unknown, output the waiting account
949 foreach ($tabbq[$key] as $k => $mt) {
950 if ($mt) {
951 $reflabel = '';
952 if (!empty($val['lib'])) {
953 $reflabel .= dol_string_nohtmltag($val['lib'])." / ";
954 }
955 $reflabel .= dol_string_nohtmltag('WaitingAccount');
956
957 $bookkeeping = new BookKeeping($db);
958 $bookkeeping->doc_date = $val["date"];
959 $bookkeeping->doc_ref = $ref;
960 $bookkeeping->doc_type = 'bank';
961 $bookkeeping->fk_doc = $key;
962 $bookkeeping->fk_docdet = $val["fk_bank"];
963 $bookkeeping->montant = $mt;
964 $bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
965 $bookkeeping->debit = ($mt < 0 ? -$mt : 0);
966 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
967 $bookkeeping->code_journal = $journal;
968 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
969 $bookkeeping->fk_user_author = $user->id;
970 $bookkeeping->date_creation = $now;
971 $bookkeeping->label_compte = '';
972 $bookkeeping->label_operation = $reflabel;
973 $bookkeeping->entity = $conf->entity;
974
975 $totaldebit += $bookkeeping->debit;
976 $totalcredit += $bookkeeping->credit;
977
978 $result = $bookkeeping->create($user);
979
980 if ($result < 0) {
981 if ($bookkeeping->error == 'BookkeepingRecordAlreadyExists') { // Already exists
982 $error++;
983 $errorforline++;
984 setEventMessages('Transaction for ('.$bookkeeping->doc_type.', '.$bookkeeping->fk_doc.', '.$bookkeeping->fk_docdet.') were already recorded', null, 'warnings');
985 } else {
986 $error++;
987 $errorforline++;
988 setEventMessages($bookkeeping->error, $bookkeeping->errors, 'errors');
989 }
990 }
991 }
992 }
993 }
994 }
995
996 if (price2num($totaldebit, 'MT') != price2num($totalcredit, 'MT')) {
997 $error++;
998 $errorforline++;
999 setEventMessages('We tried to insert a non balanced transaction in book for '.$ref.'. Canceled. Surely a bug.', null, 'errors');
1000 }
1001
1002 if (!$errorforline) {
1003 $db->commit();
1004 } else {
1005 //print 'KO for line '.$key.' '.$error.'<br>';
1006 $db->rollback();
1007
1008 $MAXNBERRORS = 5;
1009 if ($error >= $MAXNBERRORS) {
1010 setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped").' (>'.$MAXNBERRORS.')', null, 'errors');
1011 break; // Break in the foreach
1012 }
1013 }
1014 }
1015
1016 if (empty($error) && count($tabpay) > 0) {
1017 setEventMessages($langs->trans("GeneralLedgerIsWritten"), null, 'mesgs');
1018 } elseif (count($tabpay) == $error) {
1019 setEventMessages($langs->trans("NoNewRecordSaved"), null, 'warnings');
1020 } else {
1021 setEventMessages($langs->trans("GeneralLedgerSomeRecordWasNotRecorded"), null, 'warnings');
1022 }
1023
1024 $action = '';
1025
1026 // Must reload data, so we make a redirect
1027 if (count($tabpay) != $error) {
1028 $param = 'id_journal='.$id_journal;
1029 $param .= '&date_startday='.$date_startday;
1030 $param .= '&date_startmonth='.$date_startmonth;
1031 $param .= '&date_startyear='.$date_startyear;
1032 $param .= '&date_endday='.$date_endday;
1033 $param .= '&date_endmonth='.$date_endmonth;
1034 $param .= '&date_endyear='.$date_endyear;
1035 $param .= '&in_bookkeeping='.$in_bookkeeping;
1036 header("Location: ".$_SERVER['PHP_SELF'].($param ? '?'.$param : ''));
1037 exit;
1038 }
1039}
1040
1041
1042
1043// Export
1044if ($action == 'exportcsv' && $user->hasRight('accounting', 'bind', 'write')) { // ISO and not UTF8 !
1045 $sep = getDolGlobalString('ACCOUNTING_EXPORT_SEPARATORCSV');
1046
1047 $filename = 'journal';
1048 $type_export = 'journal';
1049 include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
1050
1051 // CSV header line
1052 print '"'.$langs->transnoentitiesnoconv("BankId").'"'.$sep;
1053 print '"'.$langs->transnoentitiesnoconv("Date").'"'.$sep;
1054 print '"'.$langs->transnoentitiesnoconv("PaymentMode").'"'.$sep;
1055 print '"'.$langs->transnoentitiesnoconv("AccountAccounting").'"'.$sep;
1056 print '"'.$langs->transnoentitiesnoconv("SubledgerAccount").'"'.$sep;
1057 print '"'.$langs->transnoentitiesnoconv("Label").'"'.$sep;
1058 print '"'.$langs->transnoentitiesnoconv("AccountingDebit").'"'.$sep;
1059 print '"'.$langs->transnoentitiesnoconv("AccountingCredit").'"'.$sep;
1060 print '"'.$langs->transnoentitiesnoconv("Journal").'"'.$sep;
1061 print '"'.$langs->transnoentitiesnoconv("Note").'"'.$sep;
1062 print "\n";
1063
1064 foreach ($tabpay as $key => $val) {
1065 $date = dol_print_date($val["date"], 'day');
1066
1067 $ref = getSourceDocRef($val, $tabtype[$key]);
1068
1069 // Bank
1070 foreach ($tabbq[$key] as $k => $mt) {
1071 if ($mt) {
1072 $reflabel = '';
1073 if (!empty($val['lib'])) {
1074 $reflabel .= dol_string_nohtmltag($val['lib'])." / ";
1075 }
1076 $reflabel .= $langs->trans("Bank").' '.dol_string_nohtmltag($val['bank_account_ref']);
1077 if (!empty($val['soclib'])) {
1078 $reflabel .= " / ".dol_string_nohtmltag($val['soclib']);
1079 }
1080
1081 print '"'.$key.'"'.$sep;
1082 print '"'.$date.'"'.$sep;
1083 print '"'.$val["type_payment"].'"'.$sep;
1084 print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
1085 print " ".$sep;
1086 print '"'.$reflabel.'"'.$sep;
1087 print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
1088 print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
1089 print '"'.$journal.'"'.$sep;
1090 print '"'.dol_string_nohtmltag($ref).'"'.$sep;
1091 print "\n";
1092 }
1093 }
1094
1095 // Third party
1096 if (is_array($tabtp[$key])) {
1097 foreach ($tabtp[$key] as $k => $mt) {
1098 if ($mt) {
1099 $reflabel = '';
1100 if (!empty($val['lib'])) {
1101 $reflabel .= dol_string_nohtmltag($val['lib']).(!empty($val['soclib']) ? " / " : "");
1102 }
1103 if ($tabtype[$key] == 'banktransfert') {
1104 $reflabel .= dol_string_nohtmltag($langs->transnoentitiesnoconv('TransitionalAccount').' '.$account_transfer);
1105 } else {
1106 $reflabel .= dol_string_nohtmltag($val['soclib'] ?? '');
1107 }
1108
1109 print '"'.$key.'"'.$sep;
1110 print '"'.$date.'"'.$sep;
1111 print '"'.$val["type_payment"].'"'.$sep;
1112 if ($tabtype[$key] == 'payment_supplier') {
1113 $account_ledger = (!empty($obj->accountancy_code_supplier_general)) ? $obj->accountancy_code_supplier_general : $account_supplier;
1114 print '"'.length_accountg($account_ledger).'"'.$sep;
1115 } elseif ($tabtype[$key] == 'payment') {
1116 $account_ledger = (!empty($obj->accountancy_code_customer_general)) ? $obj->accountancy_code_customer_general : $account_customer;
1117 print '"'.length_accountg($account_ledger).'"'.$sep;
1118 } elseif ($tabtype[$key] == 'payment_expensereport') {
1119 print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT')).'"'.$sep;
1120 } elseif ($tabtype[$key] == 'payment_salary') {
1121 $account_ledger = (!empty($obj->accountancy_code_user_general)) ? $obj->accountancy_code_user_general : $account_employee;
1122 print '"'.length_accountg($account_ledger).'"'.$sep;
1123 } else {
1124 print '"'.length_accountg(html_entity_decode($k)).'"'.$sep;
1125 }
1126 print '"'.length_accounta(html_entity_decode($k)).'"'.$sep;
1127 print '"'.$reflabel.'"'.$sep;
1128 print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
1129 print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
1130 print '"'.$journal.'"'.$sep;
1131 print '"'.dol_string_nohtmltag($ref).'"'.$sep;
1132 print "\n";
1133 }
1134 }
1135 } else { // If thirdparty unknown, output the waiting account
1136 foreach ($tabbq[$key] as $k => $mt) {
1137 if ($mt) {
1138 $reflabel = '';
1139 if (!empty($val['lib'])) {
1140 $reflabel .= dol_string_nohtmltag($val['lib'])." / ";
1141 }
1142 $reflabel .= dol_string_nohtmltag('WaitingAccount');
1143
1144 print '"'.$key.'"'.$sep;
1145 print '"'.$date.'"'.$sep;
1146 print '"'.$val["type_payment"].'"'.$sep;
1147 print '"'.length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE')).'"'.$sep;
1148 print $sep;
1149 print '"'.$reflabel.'"'.$sep;
1150 print '"'.($mt < 0 ? price(-$mt) : '').'"'.$sep;
1151 print '"'.($mt >= 0 ? price($mt) : '').'"'.$sep;
1152 print '"'.$journal.'"'.$sep;
1153 print '"'.dol_string_nohtmltag($ref).'"'.$sep;
1154 print "\n";
1155 }
1156 }
1157 }
1158 }
1159}
1160
1161
1162/*
1163 * View
1164 */
1165
1166$form = new Form($db);
1167
1168if (empty($action) || $action == 'view') {
1169 $invoicestatic = new Facture($db);
1170 $invoicesupplierstatic = new FactureFournisseur($db);
1171 $expensereportstatic = new ExpenseReport($db);
1172 $vatstatic = new Tva($db);
1173 $donationstatic = new Don($db);
1174 $loanstatic = new Loan($db);
1175 $salarystatic = new Salary($db);
1176 $variousstatic = new PaymentVarious($db);
1177
1178 $title = $langs->trans("GenerationOfAccountingEntries").' - '.$accountingjournalstatic->getNomUrl(0, 2, 1, '', 1);
1179 $help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#G&eacute;n&eacute;ration_des_&eacute;critures_en_comptabilit&eacute;';
1180 llxHeader('', dol_string_nohtmltag($title), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-generation page-bankjournal');
1181
1182 $nom = $title;
1183 $builddate = dol_now();
1184 //$description = $langs->trans("DescFinanceJournal") . '<br>';
1185 $description = $langs->trans("DescJournalOnlyBindedVisible").'<br>';
1186
1187 $listofchoices = array(
1188 'notyet' => $langs->trans("NotYetInGeneralLedger"),
1189 'already' => $langs->trans("AlreadyInGeneralLedger")
1190 );
1191 $period = $form->selectDate($date_start ? $date_start : -1, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end ? $date_end : -1, 'date_end', 0, 0, 0, '', 1, 0);
1192 $period .= '<span class="valignmiddle"> - '.$langs->trans("JournalizationInLedgerStatus").' </span>'.$form->selectarray('in_bookkeeping', $listofchoices, $in_bookkeeping, 1, 0, 0, '', 0, 0, 0, '', 'minwidth75 valignmiddle');
1193
1194 $varlink = 'id_journal='.$id_journal;
1195 $periodlink = '';
1196 $exportlink = '';
1197
1198 $listofchoices = array(
1199 1 => $langs->trans("TransfertAllBankLines"),
1200 2 => $langs->trans("TransfertOnlyConciliatedBankLine")
1201 );
1202 $moreoptions = [ "BankLineConciliated" => $form->selectarray('only_rappro', $listofchoices, $only_rappro, 0, 0, 0, '', 0, 0, 0, '', 'minwidth75 valignmiddle')];
1203
1204 journalHead($nom, '', $period, $periodlink, $description, $builddate, $exportlink, array('action' => ''), '', $varlink, $moreoptions);
1205
1206 $desc = '';
1207
1208 if (getDolGlobalString('ACCOUNTANCY_FISCAL_PERIOD_MODE') != 'blockedonclosed') {
1209 // Test that setup is complete (we are in accounting, so test on entity is always on $conf->entity only, no sharing allowed)
1210 // Fiscal period test
1211 $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."accounting_fiscalyear WHERE entity = ".((int) $conf->entity);
1212 $resql = $db->query($sql);
1213 if ($resql) {
1214 $obj = $db->fetch_object($resql);
1215 if ($obj->nb == 0) {
1216 print '<br><div class="warning">'.img_warning().' '.$langs->trans("TheFiscalPeriodIsNotDefined");
1217 $desc = ' : '.$langs->trans("AccountancyAreaDescFiscalPeriod", 4, '{link}');
1218 $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("FiscalPeriod").'</strong>', $desc);
1219 print $desc;
1220 print '</div>';
1221 }
1222 } else {
1223 dol_print_error($db);
1224 }
1225 }
1226
1227 // Bank test
1228 $sql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."bank_account WHERE entity = ".((int) $conf->entity)." AND fk_accountancy_journal IS NULL AND clos=0";
1229 $resql = $db->query($sql);
1230 if ($resql) {
1231 $obj = $db->fetch_object($resql);
1232 if ($obj->nb > 0) {
1233 print '<br><div class="warning">'.img_warning().' '.$langs->trans("TheJournalCodeIsNotDefinedOnSomeBankAccount");
1234 $desc = ' : '.$langs->trans("AccountancyAreaDescBank", 6, '{link}');
1235 $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("BankAccounts").'</strong>', $desc);
1236 print $desc;
1237 print '</div>';
1238 }
1239 } else {
1240 dol_print_error($db);
1241 }
1242
1243
1244 // Button to write into Ledger
1245 if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1'
1246 || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1'
1247 || (isModEnabled("salaries") && (getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == "" || getDolGlobalString('SALARIES_ACCOUNTING_ACCOUNT_PAYMENT') == '-1'))
1248 || (isModEnabled("expensereport") && (getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT') == '-1'))) {
1249
1250
1251 print($desc ? '' : '<br>').'<div class="warning">'.img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
1252 $desc = ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '{link}');
1253 $desc = str_replace('{link}', '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>', $desc);
1254 print $desc;
1255 print '</div>';
1256 }
1257
1258
1259 print '<br><div class="tabsAction tabsActionNoBottom centerimp">';
1260
1261 if (getDolGlobalString('ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping == 'notyet') {
1262 print '<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans("ExportDraftJournal").'" onclick="launch_export();" />';
1263 }
1264
1265 if (getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_CUSTOMER') == '-1'
1266 || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == "" || getDolGlobalString('ACCOUNTING_ACCOUNT_SUPPLIER') == '-1') {
1267 print '<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="'.$langs->trans("WriteBookKeeping").'" />';
1268 } else {
1269 if ($in_bookkeeping == 'notyet') {
1270 print '<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans("WriteBookKeeping").'" onclick="writebookkeeping();" />';
1271 } else {
1272 print '<a class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans("WriteBookKeeping").'</a>';
1273 }
1274 }
1275
1276 print '</div>';
1277
1278 // TODO Avoid using js. We can use a direct link with $param
1279 print '
1280 <script type="text/javascript">
1281 function launch_export() {
1282 console.log("Set value into form and submit");
1283 $("div.fiche form input[name=\"action\"]").val("exportcsv");
1284 $("div.fiche form input[type=\"submit\"]").click();
1285 $("div.fiche form input[name=\"action\"]").val("");
1286 }
1287 function writebookkeeping() {
1288 console.log("Set value into form and submit");
1289 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
1290 $("div.fiche form input[type=\"submit\"]").click();
1291 $("div.fiche form input[name=\"action\"]").val("");
1292 }
1293 </script>';
1294
1295 /*
1296 * Show result array
1297 */
1298 print '<br>';
1299
1300 $i = 0;
1301 print '<div class="div-table-responsive">';
1302 print '<table class="noborder centpercent">';
1303 print '<tr class="liste_titre">';
1304 print "<td>".$langs->trans("Date")."</td>";
1305 print "<td>".$langs->trans("Piece").' ('.$langs->trans("ObjectsRef").")</td>";
1306 print "<td>".$langs->trans("AccountAccounting")."</td>";
1307 print "<td>".$langs->trans("SubledgerAccount")."</td>";
1308 print "<td>".$langs->trans("LabelOperation")."</td>";
1309 print '<td class="center">'.$langs->trans("PaymentMode")."</td>";
1310 print '<td class="right">'.$langs->trans("AccountingDebit")."</td>";
1311 print '<td class="right">'.$langs->trans("AccountingCredit")."</td>";
1312 print "</tr>\n";
1313
1314 foreach ($tabpay as $key => $val) { // $key is rowid in llx_bank
1315 $date = dol_print_date($val["date"], 'day');
1316
1317 $ref = getSourceDocRef($val, $tabtype[$key]);
1318
1319 // Bank
1320 foreach ($tabbq[$key] as $k => $mt) {
1321 if ($mt) {
1322 $reflabel = '';
1323 if (!empty($val['lib'])) {
1324 $reflabel .= $val['lib']." / ";
1325 }
1326 $reflabel .= $langs->trans("Bank").' '.$val['bank_account_ref'];
1327 if (!empty($val['soclib'])) {
1328 $reflabel .= " / ".$val['soclib'];
1329 }
1330
1331 //var_dump($tabpay[$key]);
1332 print '<!-- Bank bank.rowid='.$key.'=accounting_bookkeeping.fk_doc (accounting_bookkeeping.doc_type=\'bank\') type='.$tabpay[$key]['type'].' ref='.$tabpay[$key]['ref'].' -->';
1333 print '<tr class="oddeven">';
1334
1335 // Date
1336 print "<td>".$date."</td>";
1337
1338 // Ref
1339 print '<td class="maxwidth300 nopaddingtopimp nopaddingbottomimp">'.dol_escape_htmltag($ref)."</td>";
1340
1341 // Ledger account
1342 $accounttoshow = length_accountg($k);
1343 if (empty($accounttoshow) || $accounttoshow == 'NotDefined') {
1344 $accounttoshow = '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>';
1345 }
1346 print '<td class="maxwidth300" title="'.dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)).'">';
1347 print $accounttoshow;
1348 print "</td>";
1349
1350 // Subledger account
1351 print '<td class="maxwidth300">';
1352 /*$accounttoshow = length_accountg($k);
1353 if (empty($accounttoshow) || $accounttoshow == 'NotDefined')
1354 {
1355 print '<span class="error">'.$langs->trans("BankAccountNotDefined").'</span>';
1356 }
1357 else print $accounttoshow;*/
1358 print "</td>";
1359
1360 // Label operation
1361 print '<td class="maxwidth300 nopaddingtopimp nopaddingbottomimp">';
1362 print $reflabel; // This is already html escaped content
1363 print "</td>";
1364
1365 print '<td class="center">'.$val["type_payment"]."</td>";
1366 print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
1367 print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
1368 print "</tr>";
1369
1370 $i++;
1371 }
1372 }
1373
1374 // Third party
1375 if (is_array($tabtp[$key])) {
1376 foreach ($tabtp[$key] as $k => $mt) {
1377 if ($mt) {
1378 $reflabel = '';
1379 if (!empty($val['lib'])) {
1380 $reflabel .= $val['lib'].(!empty($val['soclib']) ? " / " : "");
1381 }
1382 if ($tabtype[$key] == 'banktransfert') {
1383 $reflabel .= $langs->trans('TransitionalAccount').' '.$account_transfer;
1384 } else {
1385 $reflabel .= isset($val['soclib']) ? $val['soclib'] : "";
1386 }
1387
1388 print '<!-- Thirdparty bank.rowid='.$key.'=accounting_bookkeeping.fk_doc (accounting_bookkeeping.doc_type=\'bank\') type='.$tabpay[$key]['type'].' ref='.$tabpay[$key]['ref'].' -->';
1389 print '<tr class="oddeven">';
1390
1391 // Date
1392 print "<td>".$date."</td>";
1393
1394 // Ref / Piece
1395 print '<td class="nopaddingtopimp nopaddingbottomimp">'.dol_escape_htmltag($ref)."</td>";
1396
1397
1398 // Ledger account
1399 $account_ledger = $k;
1400 // Try to force general ledger account depending on type
1401 if ($tabtype[$key] == 'payment') {
1402 $account_ledger = (!empty($obj->accountancy_code_customer_general)) ? $obj->accountancy_code_customer_general : $account_customer;
1403 }
1404 if ($tabtype[$key] == 'payment_supplier') {
1405 $account_ledger = (!empty($obj->accountancy_code_supplier_general)) ? $obj->accountancy_code_supplier_general : $account_supplier;
1406 }
1407 if ($tabtype[$key] == 'payment_expensereport') {
1408 $account_ledger = getDolGlobalString('ACCOUNTING_ACCOUNT_EXPENSEREPORT');
1409 }
1410 if ($tabtype[$key] == 'payment_salary') {
1411 $account_ledger = (!empty($obj->accountancy_code_user_general)) ? $obj->accountancy_code_user_general : $account_employee;
1412 }
1413 if ($tabtype[$key] == 'payment_vat') {
1414 $account_ledger = getDolGlobalString('ACCOUNTING_VAT_PAY_ACCOUNT');
1415 }
1416 if ($tabtype[$key] == 'member') {
1417 $account_ledger = getDolGlobalString('ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT');
1418 }
1419 if ($tabtype[$key] == 'payment_various') {
1420 $account_ledger = $tabpay[$key]["account_various"];
1421 }
1422 $accounttoshow = length_accountg($account_ledger);
1423 if (empty($accounttoshow) || $accounttoshow == 'NotDefined') {
1424 if ($tabtype[$key] == 'unknown') {
1425 // We will accept writing, but into a waiting account
1426 if (!getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE') || getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE') == '-1') {
1427 $accounttoshow = '<span class="error small">'.$langs->trans('UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').'</span>';
1428 } else {
1429 $accounttoshow = '<span class="warning small">'.$langs->trans('UnknownAccountForThirdparty', length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'))).'</span>'; // We will use a waiting account
1430 }
1431 } else {
1432 // We will refuse writing
1433 $errorstring = 'UnknownAccountForThirdpartyBlocking';
1434 if ($tabtype[$key] == 'payment') {
1435 $errorstring = 'MainAccountForCustomersNotDefined';
1436 }
1437 if ($tabtype[$key] == 'payment_supplier') {
1438 $errorstring = 'MainAccountForSuppliersNotDefined';
1439 }
1440 if ($tabtype[$key] == 'payment_expensereport') {
1441 $errorstring = 'MainAccountForUsersNotDefined';
1442 }
1443 if ($tabtype[$key] == 'payment_salary') {
1444 $errorstring = 'MainAccountForUsersNotDefined';
1445 }
1446 if ($tabtype[$key] == 'payment_vat') {
1447 $errorstring = 'MainAccountForVatPaymentNotDefined';
1448 }
1449 if ($tabtype[$key] == 'member') {
1450 $errorstring = 'MainAccountForSubscriptionPaymentNotDefined';
1451 }
1452 $accounttoshow = '<span class="error small">'.$langs->trans($errorstring).'</span>';
1453 }
1454 }
1455 print '<td class="maxwidth300" title="'.dol_escape_htmltag(dol_string_nohtmltag($accounttoshow)).'">';
1456 print $accounttoshow; // This is a HTML string
1457 print "</td>";
1458
1459 // Subledger account
1460 $accounttoshowsubledger = '';
1461 if (in_array($tabtype[$key], array('payment', 'payment_supplier', 'payment_expensereport', 'payment_salary', 'payment_various'))) { // Type of payments that uses a subledger
1462 $accounttoshowsubledger = length_accounta($k);
1463 if ($accounttoshow != $accounttoshowsubledger) {
1464 if (empty($accounttoshowsubledger) || $accounttoshowsubledger == 'NotDefined') {
1465 //print '<span class="error">'.$langs->trans("ThirdpartyAccountNotDefined").'</span>';
1466 if (!empty($tabcompany[$key]['code_compta'])) {
1467 if (in_array($tabtype[$key], array('payment_various'))) {
1468 // For such case, if subledger is not defined, we won't use subledger accounts.
1469 $accounttoshowsubledger = '<span class="warning small twolinesmax">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").'</span>';
1470 } elseif (in_array($tabtype[$key], array('payment_salary'))) {
1471 $accounttoshowsubledger = '<span class="warning small twolinesmax">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored2").'</span>';
1472 } else {
1473 $accounttoshowsubledger = '<span class="warning small twolinesmax">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key]['code_compta']).'</span>';
1474 }
1475 } else {
1476 $accounttoshowsubledger = '<span class="error small twolinesmax">'.$langs->trans("ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").'</span>';
1477 }
1478 }
1479 } else {
1480 $accounttoshowsubledger = '';
1481 }
1482 }
1483 print '<td class="maxwidth300 nopaddingtopimp nopaddingbottomimp" title="'.dolPrintHTMLForAttribute(dol_string_nohtmltag($accounttoshowsubledger)).'">';
1484 print $accounttoshowsubledger; // This is a html string
1485 print "</td>";
1486
1487 // Label operation
1488 print '<td class="nopaddingtopimpo paddingbottomimp">';
1489 print $reflabel; // This is a html string
1490 print "</td>";
1491
1492 print '<td class="center">'.$val["type_payment"]."</td>";
1493
1494 print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
1495
1496 print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
1497
1498 print "</tr>";
1499
1500 $i++;
1501 }
1502 }
1503 } else { // Waiting account
1504 foreach ($tabbq[$key] as $k => $mt) {
1505 if ($mt) {
1506 $reflabel = '';
1507 if (!empty($val['lib'])) {
1508 $reflabel .= $val['lib']." / ";
1509 }
1510 $reflabel .= 'WaitingAccount';
1511
1512 print '<!-- Wait bank.rowid='.$key.' -->';
1513 print '<tr class="oddeven">';
1514 print "<td>".$date."</td>";
1515 print "<td>".$ref."</td>";
1516 // Ledger account
1517 print "<td>";
1518 /*if (empty($accounttoshow) || $accounttoshow == 'NotDefined')
1519 {
1520 print '<span class="error">'.$langs->trans("WaitAccountNotDefined").'</span>';
1521 }
1522 else */
1523 print length_accountg(getDolGlobalString('ACCOUNTING_ACCOUNT_SUSPENSE'));
1524 print "</td>";
1525 // Subledger account
1526 print "<td>";
1527 print "</td>";
1528 print "<td>".dol_escape_htmltag($reflabel)."</td>";
1529 print '<td class="center">'.$val["type_payment"]."</td>";
1530 print '<td class="right nowraponall amount">'.($mt < 0 ? price(-$mt) : '')."</td>";
1531 print '<td class="right nowraponall amount">'.($mt >= 0 ? price($mt) : '')."</td>";
1532 print "</tr>";
1533
1534 $i++;
1535 }
1536 }
1537 }
1538 }
1539
1540 if (!$i) {
1541 $colspan = 8;
1542 print '<tr class="oddeven"><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span></td></tr>';
1543 }
1544
1545 print "</table>";
1546 print '</div>';
1547
1548 llxFooter();
1549}
1550
1551$db->close();
1552
1553
1554
1562function getSourceDocRef($val, $typerecord)
1563{
1564 global $db, $langs;
1565
1566 // Defined the docref into $ref (We start with $val['ref'] by default and we complete according to other data)
1567 // WE MUST HAVE SAME REF FOR ALL LINES WE WILL RECORD INTO THE BOOKKEEPING
1568 $ref = $val['ref'];
1569 if ($ref == '(SupplierInvoicePayment)' || $ref == '(SupplierInvoicePaymentBack)') {
1570 $ref = $langs->transnoentitiesnoconv('Supplier');
1571 }
1572 if ($ref == '(CustomerInvoicePayment)' || $ref == '(CustomerInvoicePaymentBack)') {
1573 $ref = $langs->transnoentitiesnoconv('Customer');
1574 }
1575 if ($ref == '(SocialContributionPayment)') {
1576 $ref = $langs->transnoentitiesnoconv('SocialContribution');
1577 }
1578 if ($ref == '(DonationPayment)') {
1579 $ref = $langs->transnoentitiesnoconv('Donation');
1580 }
1581 if ($ref == '(SubscriptionPayment)') {
1582 $ref = $langs->transnoentitiesnoconv('Subscription');
1583 }
1584 if ($ref == '(ExpenseReportPayment)') {
1585 $ref = $langs->transnoentitiesnoconv('Employee');
1586 }
1587 if ($ref == '(LoanPayment)') {
1588 $ref = $langs->transnoentitiesnoconv('Loan');
1589 }
1590 if ($ref == '(payment_salary)') {
1591 $ref = $langs->transnoentitiesnoconv('Employee');
1592 }
1593
1594 $sqlmid = '';
1595 if ($typerecord == 'payment') {
1596 if (getDolGlobalInt('FACTURE_DEPOSITS_ARE_JUST_PAYMENTS')) {
1597 $sqlmid = "SELECT payfac.fk_facture as id, ".$db->ifsql('f1.rowid IS NULL', 'f.ref', 'f1.ref')." as ref";
1598 $sqlmid .= " FROM ".$db->prefix()."paiement_facture as payfac";
1599 $sqlmid .= " LEFT JOIN ".$db->prefix()."facture as f ON f.rowid = payfac.fk_facture";
1600 $sqlmid .= " LEFT JOIN ".$db->prefix()."societe_remise_except as sre ON sre.fk_facture_source = payfac.fk_facture";
1601 $sqlmid .= " LEFT JOIN ".$db->prefix()."facture as f1 ON f1.rowid = sre.fk_facture";
1602 $sqlmid .= " WHERE payfac.fk_paiement=".((int) $val['paymentid']);
1603 } else {
1604 $sqlmid = "SELECT payfac.fk_facture as id, f.ref as ref";
1605 $sqlmid .= " FROM ".$db->prefix()."paiement_facture as payfac";
1606 $sqlmid .= " INNER JOIN ".$db->prefix()."facture as f ON f.rowid = payfac.fk_facture";
1607 $sqlmid .= " WHERE payfac.fk_paiement=".((int) $val['paymentid']);
1608 }
1609 $ref = $langs->transnoentitiesnoconv("Invoice");
1610 } elseif ($typerecord == 'payment_supplier') {
1611 $sqlmid = 'SELECT payfac.fk_facturefourn as id, f.ref';
1612 $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX."facture_fourn as f";
1613 $sqlmid .= " WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=".((int) $val["paymentsupplierid"]);
1614 $ref = $langs->transnoentitiesnoconv("SupplierInvoice");
1615 } elseif ($typerecord == 'payment_expensereport') {
1616 $sqlmid = 'SELECT e.rowid as id, e.ref';
1617 $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_expensereport as pe, ".MAIN_DB_PREFIX."expensereport as e";
1618 $sqlmid .= " WHERE pe.rowid=".((int) $val["paymentexpensereport"])." AND pe.fk_expensereport = e.rowid";
1619 $ref = $langs->transnoentitiesnoconv("ExpenseReport");
1620 } elseif ($typerecord == 'payment_salary') {
1621 $sqlmid = 'SELECT s.rowid as ref';
1622 $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_salary as s";
1623 $sqlmid .= " WHERE s.rowid=".((int) $val["paymentsalid"]);
1624 $ref = $langs->transnoentitiesnoconv("SalaryPayment");
1625 } elseif ($typerecord == 'sc') {
1626 $sqlmid = 'SELECT sc.rowid as ref';
1627 $sqlmid .= " FROM ".MAIN_DB_PREFIX."paiementcharge as sc";
1628 $sqlmid .= " WHERE sc.rowid=".((int) $val["paymentscid"]);
1629 $ref = $langs->transnoentitiesnoconv("SocialContribution");
1630 } elseif ($typerecord == 'payment_vat') {
1631 $sqlmid = 'SELECT v.rowid as ref';
1632 $sqlmid .= " FROM ".MAIN_DB_PREFIX."tva as v";
1633 $sqlmid .= " WHERE v.rowid=".((int) $val["paymentvatid"]);
1634 $ref = $langs->transnoentitiesnoconv("PaymentVat");
1635 } elseif ($typerecord == 'payment_donation') {
1636 $sqlmid = 'SELECT payd.fk_donation as ref';
1637 $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_donation as payd";
1638 $sqlmid .= " WHERE payd.fk_donation=".((int) $val["paymentdonationid"]);
1639 $ref = $langs->transnoentitiesnoconv("Donation");
1640 } elseif ($typerecord == 'payment_loan') {
1641 $sqlmid = 'SELECT l.rowid as ref';
1642 $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_loan as l";
1643 $sqlmid .= " WHERE l.rowid=".((int) $val["paymentloanid"]);
1644 $ref = $langs->transnoentitiesnoconv("LoanPayment");
1645 } elseif ($typerecord == 'payment_various') {
1646 $sqlmid = 'SELECT v.rowid as ref';
1647 $sqlmid .= " FROM ".MAIN_DB_PREFIX."payment_various as v";
1648 $sqlmid .= " WHERE v.rowid=".((int) $val["paymentvariousid"]);
1649 $ref = $langs->transnoentitiesnoconv("VariousPayment");
1650 }
1651 // Add warning
1652 if (empty($sqlmid)) {
1653 dol_syslog("Found a typerecord=".$typerecord." not supported", LOG_WARNING);
1654 }
1655
1656 if ($sqlmid) {
1657 dol_syslog("accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG);
1658 $resultmid = $db->query($sqlmid);
1659 if ($resultmid) {
1660 while ($objmid = $db->fetch_object($resultmid)) {
1661 $ref .= ' '.$objmid->ref;
1662 }
1663 } else {
1664 dol_print_error($db);
1665 }
1666 }
1667
1668 $ref = dol_trunc($langs->transnoentitiesnoconv("BankId").' '.$val['fk_bank'].' - '.$ref, 295); // 295 + 3 dots (...) is < than max size of 300
1669 return $ref;
1670}
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
Definition card.php:67
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
journalHead($nom, $variant, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='', $moreoptions=array())
Show header of a page used to transfer/dispatch data in accounting.
getDefaultDatesForTransfer()
Return Default dates for transfer based on periodicity option in accountancy setup.
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
getSourceDocRef($val, $typerecord)
Return source for doc_ref of a bank transaction.
Class to manage bank accounts.
Class to manage bank transaction lines.
Class to manage accounting accounts.
Class to manage accounting journals.
Class to manage Ledger (General Ledger and Subledger)
Class for managing the social charges.
Class to manage donations.
Definition don.class.php:41
Class to manage Trips and Expenses.
Class to manage suppliers invoices.
Class to manage invoices.
Class to manage generation of HTML components Only common components must be here.
Class Lettering.
Loan.
Class to manage payments for supplier invoices.
Class to manage payments of customer invoices.
Class to manage payments of donations.
Class to manage payments of expense report.
Class to manage payments of loans.
Class to manage payments of salaries.
Class to manage various payments.
Class to manage salary payments.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage subscriptions of foundation members.
Class to manage VAT - Value-added tax (also known in French as TVA - Taxe sur la valeur ajoutée)
Definition tva.class.php:38
Class to manage Dolibarr users.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition date.lib.php:600
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition date.lib.php:619
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.