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';
75$langs->loadLangs(array(
"companies",
"other",
"compta",
"banks",
"bills",
"donations",
"loan",
"accountancy",
"trips",
"salaries",
"hrm",
"members"));
80$date_startmonth =
GETPOSTINT(
'date_startmonth');
86$in_bookkeeping =
GETPOST(
'in_bookkeeping',
'aZ09');
89if ($only_rappro == 0) {
96$action =
GETPOST(
'action',
'aZ09');
98if ($in_bookkeeping ==
'') {
99 $in_bookkeeping =
'notyet';
107if ($user->socid > 0) {
110if (!$user->hasRight(
'accounting',
'bind',
'write')) {
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);
125$pastmonthyear =
null;
127if (empty($date_startmonth)) {
130 $date_start = $dates[
'date_start'];
131 $pastmonthyear = $dates[
'pastmonthyear'];
132 $pastmonth = $dates[
'pastmonth'];
134if (empty($date_endmonth)) {
137 $date_end = $dates[
'date_end'];
138 $pastmonthyear = $dates[
'pastmonthyear'];
139 $pastmonth = $dates[
'pastmonth'];
142if (!GETPOSTISSET(
'date_startmonth') && (empty($date_start) || empty($date_end))) {
144 $date_end =
dol_get_last_day((
int) $pastmonthyear, (
int) $pastmonth,
false);
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,";
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,";
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,";
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";
174 $sql .=
" LEFT JOIN " . $db->prefix() .
"societe_perentity as spe ON spe.fk_soc = soc.rowid AND spe.entity = " . ((int) $conf->entity);
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).
")";
179if ($date_start && $date_end) {
180 $sql .=
" AND b.dateo >= '".$db->idate($date_start).
"' AND b.dateo <= '".$db->idate($date_end).
"'";
184 $sql .=
" AND b.dateo >= '".$db->idate(
getDolGlobalInt(
'ACCOUNTING_DATE_START_BINDING')).
"'";
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') )";
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') )";
193if ($only_rappro == 2) {
194 $sql .=
" AND (b.rappro = '1')";
196$sql .=
" ORDER BY b.datev";
200$accountancy_code_by_payment = array();
201$sql2 =
"SELECT code, accountancy_code";
202$sql2 .=
" FROM ".MAIN_DB_PREFIX.
"c_paiement";
203$sql2 .=
" WHERE entity IN (".getEntity(
'c_paiement').
")";
204$sql2 .=
" AND active = 1";
205$resql = $db->query($sql2);
207 while ($objp = $db->fetch_object($resql)) {
208 if (!empty($objp->code) && !empty($objp->accountancy_code)) {
209 $accountancy_code_by_payment[$objp->code] = $objp->accountancy_code;
217$societestatic =
new Societe($db);
218$userstatic =
new User($db);
219$bankaccountstatic =
new Account($db);
222$paymentvatstatic =
new Tva($db);
234$account_transfer =
'NotDefined';
238$accountingjournalstatic->fetch($id_journal);
239$journal = $accountingjournalstatic->code;
240$journal_label = $accountingjournalstatic->label;
242$tabcompany = array();
248$tabmoreinfo = array();
251@phan-var-force array<array{id:mixed,name:mixed,code_compta_client:string,email:string}> $tabcompany
252@phan-var-force array<array{id:int,name:string,lastname:string,firstname:string,email:string,accountancy_code:string,status:int> $tabuser
253@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
254@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
257$account_customer =
'NotDefined';
258$account_supplier =
'NotDefined';
259$account_employee =
'NotDefined';
262dol_syslog(
"accountancy/journal/bankjournal.php", LOG_DEBUG);
263$result = $db->query($sql);
265 $num = $db->num_rows($result);
271 $account_employee =
getDolGlobalString(
'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
'NotDefined');
272 $account_expensereport =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_EXPENSEREPORT',
'NotDefined');
274 $account_pay_donation =
getDolGlobalString(
'DONATION_ACCOUNTINGACCOUNT',
'NotDefined');
275 $account_pay_subscription =
getDolGlobalString(
'ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT',
'NotDefined');
276 $account_transfer =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_TRANSFER_CASH',
'NotDefined');
285 $obj = $db->fetch_object($result);
287 $lineisapurchase = -1;
290 if ($obj->label ==
'(SupplierInvoicePayment)' || $obj->label ==
'(SupplierInvoicePaymentBack)') {
291 $lineisapurchase = 1;
293 if ($obj->label ==
'(CustomerInvoicePayment)' || $obj->label ==
'(CustomerInvoicePaymentBack)') {
297 if ($lineisapurchase < 0) {
298 if ($obj->typeop_payment_supplier ==
'payment_supplier') {
299 $lineisapurchase = 1;
302 if ($lineisasale < 0) {
303 if ($obj->typeop_payment ==
'payment') {
311 $compta_bank = $obj->account_number;
314 if (!empty($obj->fk_type) && !empty($accountancy_code_by_payment[$obj->fk_type])) {
315 $compta_bank = $accountancy_code_by_payment[$obj->fk_type];
319 $compta_soc =
'NotDefined';
320 $accountancy_code_general =
'NotDefined';
321 if ($lineisapurchase > 0) {
322 $accountancy_code_general = (!empty($obj->accountancy_code_supplier_general) && $obj->accountancy_code_supplier_general !=
'-1') ? $obj->accountancy_code_supplier_general : $account_supplier;
323 $compta_soc = (($obj->code_compta_fournisseur !=
"") ? $obj->code_compta_fournisseur : $account_supplier);
325 if ($lineisasale > 0) {
326 $accountancy_code_general = (!empty($obj->accountancy_code_customer_general) && $obj->accountancy_code_customer_general !=
'-1') ? $obj->accountancy_code_customer_general : $account_customer;
327 $compta_soc = (!empty($obj->code_compta_client) ? $obj->code_compta_client : $account_customer);
330 $tabcompany[$obj->rowid] = array(
332 'name' => $obj->name,
333 'code_compta' => $compta_soc,
334 'accountancy_code_general' => $accountancy_code_general,
335 'email' => $obj->email
341 $accountancy_code_user_general = (!empty($obj->accountancy_code_user_general)) ? $obj->accountancy_code_user_general : $account_employee;
342 $compta_user = (!empty($obj->accountancy_code) ? $obj->accountancy_code :
'');
344 $tabuser[$obj->rowid] = array(
345 'id' => $obj->userid,
347 'lastname' => $obj->lastname,
348 'firstname' => $obj->firstname,
349 'email' => $obj->useremail,
350 'accountancy_code_general' => $accountancy_code_user_general,
351 'accountancy_code' => $compta_user,
352 'status' => $obj->userstatus
356 $tabpay[$obj->rowid][
"date"] = $db->jdate($obj->do);
357 $tabpay[$obj->rowid][
"type_payment"] = $obj->fk_type;
358 $tabpay[$obj->rowid][
"ref"] = $obj->label;
359 $tabpay[$obj->rowid][
"fk_bank"] = $obj->rowid;
360 $tabpay[$obj->rowid][
"bank_account_ref"] = $obj->baref;
361 $tabpay[$obj->rowid][
"fk_bank_account"] = $obj->fk_account;
363 if (preg_match(
'/^\((.*)\)$/i', $obj->label, $reg)) {
364 $tabpay[$obj->rowid][
"lib"] = $langs->trans($reg[1]);
366 $tabpay[$obj->rowid][
"lib"] =
dol_trunc($obj->label, 60);
370 $links =
$object->get_url($obj->rowid);
375 $tabpay[$obj->rowid][
'type'] =
'unknown';
376 $tabtype[$obj->rowid] =
'unknown';
377 $tabmoreinfo[$obj->rowid] = array();
379 $amounttouse = $obj->amount;
380 if (!empty($obj->amount_main_currency)) {
382 $amounttouse = $obj->amount_main_currency;
388 if (
getDolGlobalString(
'FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS') && ($lineisapurchase == 1 || $lineisasale == 1) ) {
389 if ($lineisapurchase == 1) {
390 $sqlamount =
"SELECT SUM(pf.amount) as amount";
391 $sqlamount .=
" FROM ".MAIN_DB_PREFIX.
"paiementfourn_facturefourn AS pf";
392 $sqlamount .=
" INNER JOIN ".MAIN_DB_PREFIX.
"paiementfourn AS p ON pf.fk_paiementfourn = p.rowid";
393 $sqlamount .=
" RIGHT JOIN ".MAIN_DB_PREFIX.
"facture AS f ON pf.fk_facturefourn = f.rowid";
394 $sqlamount .=
" WHERE p.fk_bank = ".((int) $obj->rowid);
395 $sqlamount .=
" AND f.fk_soc = ".((int) $obj->socid);
397 $sqlamount =
"SELECT SUM(pf.amount) as amount";
398 $sqlamount .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture AS pf";
399 $sqlamount .=
" INNER JOIN ".MAIN_DB_PREFIX.
"paiement AS p ON pf.fk_paiement = p.rowid";
400 $sqlamount .=
" RIGHT JOIN ".MAIN_DB_PREFIX.
"facture AS f ON pf.fk_facture = f.rowid";
401 $sqlamount .=
" WHERE p.fk_bank = ".((int) $obj->rowid);
402 $sqlamount .=
" AND f.fk_soc = ".((int) $obj->socid);
404 $resultamount = $db->query($sqlamount);
406 $objamount = $db->fetch_object($resultamount);
407 if (!empty($objamount->amount)) $amounttouse = $objamount->amount;
412 if (is_array($links) && count($links) > 0) {
417 $is_expensereport =
false;
418 foreach ($links as $v) {
419 if ($v[
'type'] ==
'sc') {
423 if ($v[
'type'] ==
'payment_salary') {
427 if ($v[
'type'] ==
'payment_expensereport') {
428 $is_expensereport =
true;
434 foreach ($links as $key => $val) {
435 if ($links[$key][
'type'] ==
'user' && !$is_sc && !$is_salary && !$is_expensereport) {
440 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'))) {
444 $tabpay[$obj->rowid][
'type'] = $links[$key][
'type'];
445 $tabtype[$obj->rowid] = $links[$key][
'type'];
456 if ($links[$key][
'type'] ==
'withdraw') {
457 $tabmoreinfo[$obj->rowid][
'withdraw'] = 1;
460 if ($links[$key][
'type'] ==
'payment') {
461 $paymentstatic->id = $links[$key][
'url_id'];
462 $paymentstatic->ref = (string) $links[$key][
'url_id'];
463 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentstatic->getNomUrl(2,
'',
'');
464 $tabpay[$obj->rowid][
"paymentid"] = $paymentstatic->id;
465 } elseif ($links[$key][
'type'] ==
'payment_supplier') {
466 $paymentsupplierstatic->id = $links[$key][
'url_id'];
467 $paymentsupplierstatic->ref = (string) $links[$key][
'url_id'];
468 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentsupplierstatic->getNomUrl(2);
469 $tabpay[$obj->rowid][
"paymentsupplierid"] = $paymentsupplierstatic->id;
470 } elseif ($links[$key][
'type'] ==
'company') {
471 $societestatic->id = $links[$key][
'url_id'];
472 $societestatic->name = $links[$key][
'label'];
473 $societestatic->email = $tabcompany[$obj->rowid][
'email'];
474 $tabpay[$obj->rowid][
"soclib"] = $societestatic->getNomUrl(1,
'', 30);
481 if (!
getDolGlobalString(
'FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS') || $obj->socid == $links[$key][
'url_id']){
482 if (empty($tabtp[$obj->rowid][$compta_soc])) {
483 $tabtp[$obj->rowid][$compta_soc] = $amounttouse;
485 $tabtp[$obj->rowid][$compta_soc] += $amounttouse;
489 } elseif ($links[$key][
'type'] ==
'user') {
490 $userstatic->id = $links[$key][
'url_id'];
491 $userstatic->name = $links[$key][
'label'];
492 $userstatic->email = $tabuser[$obj->rowid][
'email'];
493 $userstatic->firstname = $tabuser[$obj->rowid][
'firstname'];
494 $userstatic->lastname = $tabuser[$obj->rowid][
'lastname'];
495 $userstatic->status = $tabuser[$obj->rowid][
'status'];
496 $userstatic->accountancy_code_user_general = $tabuser[$obj->rowid][
'accountancy_code_general'];
497 $userstatic->accountancy_code = $tabuser[$obj->rowid][
'accountancy_code'];
502 if ($userstatic->id > 0) {
504 $tabpay[$obj->rowid][
"soclib"] .=
' '.$userstatic->getNomUrl(-1,
'accountancy', 0);
506 $tabpay[$obj->rowid][
"soclib"] = $userstatic->getNomUrl(-1,
'accountancy', 0);
509 $tabpay[$obj->rowid][
"soclib"] =
'???';
516 if (empty($tabtp[$obj->rowid][$compta_user])) {
517 $tabtp[$obj->rowid][$compta_user] = $amounttouse;
519 $tabtp[$obj->rowid][$compta_user] += $amounttouse;
523 } elseif ($links[$key][
'type'] ==
'sc') {
524 $chargestatic->id = $links[$key][
'url_id'];
525 $chargestatic->ref = (string) $links[$key][
'url_id'];
527 $tabpay[$obj->rowid][
"lib"] .=
' '.$chargestatic->getNomUrl(2);
529 if (preg_match(
'/^\((.*)\)$/i', $links[$key][
'label'], $reg)) {
530 if ($reg[1] ==
'socialcontribution') {
531 $reg[1] =
'SocialContribution';
533 $chargestatic->label = $langs->trans($reg[1]);
535 $chargestatic->label = $links[$key][
'label'];
537 $chargestatic->ref = $chargestatic->label;
556 $resultmid = $tmpcharge->fetch($chargestatic->id);
558 $chargestatic->type_label = $tmpcharge->type_label;
559 $chargestatic->type_code = $tmpcharge->type_code;
560 $chargestatic->type_accountancy_code = $tmpcharge->type_accountancy_code;
562 $tabtp[$obj->rowid][$tmpcharge->type_accountancy_code] = isset($tabtp[$obj->rowid][$tmpcharge->type_accountancy_code]) ? $tabtp[$obj->rowid][$tmpcharge->type_accountancy_code] + $amounttouse : $amounttouse;
565 $tabpay[$obj->rowid][
"soclib"] = $chargestatic->getNomUrl(1,
'30');
566 $tabpay[$obj->rowid][
"paymentscid"] = $chargestatic->id;
567 } elseif ($links[$key][
'type'] ==
'payment_donation') {
568 $paymentdonstatic->id = $links[$key][
'url_id'];
569 $paymentdonstatic->ref = (string) $links[$key][
'url_id'];
570 $paymentdonstatic->fk_donation = $links[$key][
'url_id'];
571 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentdonstatic->getNomUrl(2);
572 $tabpay[$obj->rowid][
"paymentdonationid"] = $paymentdonstatic->id;
573 $tabtp[$obj->rowid][$account_pay_donation] = isset($tabtp[$obj->rowid][$account_pay_donation]) ? $tabtp[$obj->rowid][$account_pay_donation] + $amounttouse : $amounttouse;
574 } elseif ($links[$key][
'type'] ==
'member') {
575 $paymentsubscriptionstatic->id = $links[$key][
'url_id'];
576 $paymentsubscriptionstatic->ref = (string) $links[$key][
'url_id'];
577 $paymentsubscriptionstatic->label = $links[$key][
'label'];
578 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentsubscriptionstatic->getNomUrl(2);
579 $tabpay[$obj->rowid][
"paymentsubscriptionid"] = $paymentsubscriptionstatic->id;
580 $paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id);
581 $tabtp[$obj->rowid][$account_pay_subscription] = isset($tabtp[$obj->rowid][$account_pay_subscription]) ? $tabtp[$obj->rowid][$account_pay_subscription] + $amounttouse : $amounttouse;
582 } elseif ($links[$key][
'type'] ==
'payment_vat') {
583 $paymentvatstatic->id = $links[$key][
'url_id'];
584 $paymentvatstatic->ref = (string) $links[$key][
'url_id'];
585 $paymentvatstatic->label = $links[$key][
'label'];
586 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentvatstatic->getNomUrl(2);
587 $tabpay[$obj->rowid][
"paymentvatid"] = $paymentvatstatic->id;
588 $tabtp[$obj->rowid][$account_pay_vat] = isset($tabtp[$obj->rowid][$account_pay_vat]) ? $tabtp[$obj->rowid][$account_pay_vat] + $amounttouse : $amounttouse;
589 } elseif ($links[$key][
'type'] ==
'payment_salary') {
590 $paymentsalstatic->id = $links[$key][
'url_id'];
591 $paymentsalstatic->ref = (string) $links[$key][
'url_id'];
592 $paymentsalstatic->label = $links[$key][
'label'];
593 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentsalstatic->getNomUrl(2);
594 $tabpay[$obj->rowid][
"paymentsalid"] = $paymentsalstatic->id;
598 if (
getDolGlobalString(
'ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USER_ON_SALARY_BANK_PAYMENT')) {
599 $tmpsalary =
new Salary($db);
600 $tmpsalary->fetch($paymentsalstatic->id);
601 $tmpsalary->fetch_user($tmpsalary->fk_user);
603 $userstatic->id = $tmpsalary->user->id;
604 $userstatic->name = $tmpsalary->user->name;
605 $userstatic->email = $tmpsalary->user->email;
606 $userstatic->firstname = $tmpsalary->user->firstname;
607 $userstatic->lastname = $tmpsalary->user->lastname;
608 $userstatic->status = $tmpsalary->user->status;
609 $userstatic->accountancy_code = $tmpsalary->user->accountancy_code;
611 if ($userstatic->id > 0) {
612 $tabpay[$obj->rowid][
"soclib"] = $userstatic->getNomUrl(1,
'accountancy', 0);
614 $tabpay[$obj->rowid][
"soclib"] =
'???';
617 if (empty($obj->typeop_user)) {
618 $accountancy_code_user_general = (!empty($obj->accountancy_code_user_general)) ? $obj->accountancy_code_user_general : $account_employee;
619 $compta_user = $userstatic->accountancy_code;
621 if (empty($tabtp[$obj->rowid][$compta_user])) {
622 $tabtp[$obj->rowid][$compta_user] = $amounttouse;
624 $tabtp[$obj->rowid][$compta_user] += $amounttouse;
626 $tabuser[$obj->rowid] = array(
627 'id' => $userstatic->id,
629 'lastname' => $userstatic->lastname,
630 'firstname' => $userstatic->firstname,
631 'email' => $userstatic->email,
632 'accountancy_code_general' => $accountancy_code_user_general,
633 'accountancy_code' => $compta_user,
634 'status' => $userstatic->status
639 } elseif ($links[$key][
'type'] ==
'payment_expensereport') {
640 $paymentexpensereportstatic->id = $links[$key][
'url_id'];
641 $tabpay[$obj->rowid][
"lib"] .= $paymentexpensereportstatic->getNomUrl(2);
642 $tabpay[$obj->rowid][
"paymentexpensereport"] = $paymentexpensereportstatic->id;
643 } elseif ($links[$key][
'type'] ==
'payment_various') {
644 $paymentvariousstatic->id = $links[$key][
'url_id'];
645 $paymentvariousstatic->ref = (string) $links[$key][
'url_id'];
646 $paymentvariousstatic->label = $links[$key][
'label'];
647 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentvariousstatic->getNomUrl(2);
648 $tabpay[$obj->rowid][
"paymentvariousid"] = $paymentvariousstatic->id;
649 $paymentvariousstatic->fetch($paymentvariousstatic->id);
650 $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code :
'NotDefined');
651 $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account :
'');
652 $tabpay[$obj->rowid][
"account_various"] = $account_various;
653 $tabtp[$obj->rowid][$account_subledger] = isset($tabtp[$obj->rowid][$account_subledger]) ? $tabtp[$obj->rowid][$account_subledger] + $amounttouse : $amounttouse;
654 } elseif ($links[$key][
'type'] ==
'payment_loan') {
655 $paymentloanstatic->id = $links[$key][
'url_id'];
656 $paymentloanstatic->ref = (string) $links[$key][
'url_id'];
657 $paymentloanstatic->fk_loan = $links[$key][
'url_id'];
658 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentloanstatic->getNomUrl(2);
659 $tabpay[$obj->rowid][
"paymentloanid"] = $paymentloanstatic->id;
661 $sqlmid =
'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest';
662 $sqlmid .=
' FROM '.MAIN_DB_PREFIX.
'payment_loan as pl, '.MAIN_DB_PREFIX.
'loan as l';
663 $sqlmid .=
' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.((int) $obj->rowid);
665 dol_syslog(
"accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG);
666 $resultmid = $db->query($sqlmid);
668 $objmid = $db->fetch_object($resultmid);
669 $tabtp[$obj->rowid][$objmid->accountancy_account_capital] = isset($objmid->amount_capital) ? ($tabtp[$obj->rowid][$objmid->accountancy_account_capital] ?? 0) - $objmid->amount_capital : 0;
670 $tabtp[$obj->rowid][$objmid->accountancy_account_insurance] = isset($objmid->amount_insurance) ? ($tabtp[$obj->rowid][$objmid->accountancy_account_insurance] ?? 0) - $objmid->amount_insurance : 0;
671 $tabtp[$obj->rowid][$objmid->accountancy_account_interest] = isset($objmid->amount_interest) ? ($tabtp[$obj->rowid][$objmid->accountancy_account_interest] ?? 0) - $objmid->amount_interest : 0;
673 } elseif ($links[$key][
'type'] ==
'banktransfert') {
674 $accountLinestatic->fetch($links[$key][
'url_id']);
675 $tabpay[$obj->rowid][
"lib"] .=
' '.$langs->trans(
"BankTransfer").
' '.$accountLinestatic ->getNomUrl(1);
676 $tabtp[$obj->rowid][$account_transfer] = isset($tabtp[$obj->rowid][$account_transfer]) ? $tabtp[$obj->rowid][$account_transfer] + $amounttouse : $amounttouse;
677 $bankaccountstatic->fetch($tabpay[$obj->rowid][
'fk_bank_account']);
678 $tabpay[$obj->rowid][
"soclib"] = $bankaccountstatic->getNomUrl(2);
683 if (empty($tabbq[$obj->rowid][$compta_bank])) {
684 $tabbq[$obj->rowid][$compta_bank] = $amounttouse;
686 $tabbq[$obj->rowid][$compta_bank] += $amounttouse;
691 if (empty($tabtp[$obj->rowid]) && !empty($tabmoreinfo[$obj->rowid][
'withdraw'])) {
692 foreach ($links as $key => $val) {
693 if ($links[$key][
'type'] ==
'payment') {
695 $tmppayment->fetch($links[$key][
'url_id']);
696 $arrayofamounts = $tmppayment->getAmountsArray();
697 if (is_array($arrayofamounts)) {
698 foreach ($arrayofamounts as $invoiceid => $amount) {
699 $tmpinvoice->fetch($invoiceid);
700 $tmpinvoice->fetch_thirdparty();
701 if ($tmpinvoice->thirdparty->code_compta_client) {
702 $tabtp[$obj->rowid][$tmpinvoice->thirdparty->code_compta_client] += $amount;
711 if (empty($tabtp[$obj->rowid])) {
712 $tabtp[$obj->rowid][
'NotDefined'] = $tabbq[$obj->rowid][$compta_bank];
724if (!$error && $action ==
'writebookkeeping' && $user->hasRight(
'accounting',
'bind',
'write')) {
728 $accountingaccountcustomer->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'),
true);
731 $accountingaccountsupplier->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER'),
true);
734 $accountingaccountpayment->fetch(0,
getDolGlobalString(
'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'),
true);
737 $accountingaccountexpensereport->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_EXPENSEREPORT'),
true);
740 $accountingaccountsuspense->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUSPENSE'),
true);
743 foreach ($tabpay as $key => $val) {
758 if (is_array($tabbq[$key])) {
760 foreach ($tabbq[$key] as $k => $mt) {
762 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
764 $accountingaccount->fetch(0, $k,
true);
765 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
767 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
770 $account_label = $accountingaccount->label;
773 if (!empty($val[
'lib'])) {
777 if (!empty($val[
'soclib'])) {
778 $reflabel .=
" / ".dol_string_nohtmltag($val[
'soclib']);
782 $bookkeeping->doc_date = $val[
"date"];
783 $bookkeeping->doc_ref = $ref;
784 $bookkeeping->doc_type =
'bank';
785 $bookkeeping->fk_doc = $key;
786 $bookkeeping->fk_docdet = $val[
"fk_bank"];
788 $bookkeeping->numero_compte = $k;
789 $bookkeeping->label_compte = $account_label;
791 $bookkeeping->label_operation = $reflabel;
792 $bookkeeping->montant = $mt;
793 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
794 $bookkeeping->debit = ($mt >= 0 ? $mt : 0);
795 $bookkeeping->credit = ($mt < 0 ? -$mt : 0);
796 $bookkeeping->code_journal = $journal;
797 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
798 $bookkeeping->fk_user_author = $user->id;
799 $bookkeeping->date_creation = $now;
802 $bookkeeping->subledger_account =
'';
803 $bookkeeping->label_operation = $reflabel;
804 $bookkeeping->entity = $conf->entity;
806 $totaldebit += $bookkeeping->debit;
807 $totalcredit += $bookkeeping->credit;
809 $result = $bookkeeping->create($user);
811 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
814 setEventMessages(
'Transaction for ('.$bookkeeping->doc_type.
', '.$bookkeeping->fk_doc.
', '.$bookkeeping->fk_docdet.
') were already recorded',
null,
'warnings');
826 if (!$errorforline) {
827 if (is_array($tabtp[$key])) {
829 foreach ($tabtp[$key] as $k => $mt) {
834 if (!empty($val[
'lib'])) {
837 if ($tabtype[$key] ==
'banktransfert') {
838 $reflabel .=
dol_string_nohtmltag($langs->transnoentitiesnoconv(
'TransitionalAccount').
' '.$account_transfer);
844 $bookkeeping->doc_date = $val[
"date"];
845 $bookkeeping->doc_ref = $ref;
846 $bookkeeping->doc_type =
'bank';
847 $bookkeeping->fk_doc = $key;
848 $bookkeeping->fk_docdet = $val[
"fk_bank"];
850 $bookkeeping->label_operation = $reflabel;
851 $bookkeeping->montant = $mt;
852 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
853 $bookkeeping->debit = ($mt < 0 ? -$mt : 0);
854 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
855 $bookkeeping->code_journal = $journal;
856 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
857 $bookkeeping->fk_user_author = $user->id;
858 $bookkeeping->date_creation = $now;
860 if ($tabtype[$key] ==
'payment') {
862 $bookkeeping->subledger_account = $k;
863 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
864 $bookkeeping->numero_compte = $tabcompany[$key][
'accountancy_code_general'];
865 $bookkeeping->label_compte = $accountingaccountcustomer->label;
866 } elseif ($tabtype[$key] ==
'payment_supplier') {
868 $bookkeeping->subledger_account = $k;
869 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
870 $bookkeeping->numero_compte = $tabcompany[$key][
'accountancy_code_general'];
871 $bookkeeping->label_compte = $accountingaccountsupplier->label;
872 } elseif ($tabtype[$key] ==
'payment_expensereport') {
873 $bookkeeping->subledger_account = $tabuser[$key][
'accountancy_code'];
874 $bookkeeping->subledger_label = $tabuser[$key][
'name'];
876 $bookkeeping->label_compte = $accountingaccountexpensereport->label;
877 } elseif ($tabtype[$key] ==
'payment_salary') {
878 $bookkeeping->subledger_account = $tabuser[$key][
'accountancy_code'];
879 $bookkeeping->subledger_label = $tabuser[$key][
'name'];
880 $bookkeeping->numero_compte = $tabuser[$key][
'accountancy_code_general'];
881 $bookkeeping->label_compte = $accountingaccountpayment->label;
882 } elseif (in_array($tabtype[$key], array(
'sc',
'payment_sc'))) {
883 $bookkeeping->subledger_account =
'';
884 $bookkeeping->subledger_label =
'';
885 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
887 $accountingaccount->fetch(0, $k,
true);
888 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
890 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
892 $bookkeeping->numero_compte = $k;
893 $bookkeeping->label_compte = $accountingaccount->label;
894 } elseif ($tabtype[$key] ==
'payment_vat') {
895 $bookkeeping->subledger_account =
'';
896 $bookkeeping->subledger_label =
'';
897 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
899 $accountingaccount->fetch(0, $k,
true);
900 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
902 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
904 $bookkeeping->numero_compte = $k;
905 $bookkeeping->label_compte = $accountingaccount->label;
906 } elseif ($tabtype[$key] ==
'payment_donation') {
907 $bookkeeping->subledger_account =
'';
908 $bookkeeping->subledger_label =
'';
909 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
911 $accountingaccount->fetch(0, $k,
true);
912 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
914 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
916 $bookkeeping->numero_compte = $k;
917 $bookkeeping->label_compte = $accountingaccount->label;
918 } elseif ($tabtype[$key] ==
'member') {
919 $bookkeeping->subledger_account =
'';
920 $bookkeeping->subledger_label =
'';
921 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
923 $accountingaccount->fetch(0, $k,
true);
924 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
926 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
928 $bookkeeping->numero_compte = $k;
929 $bookkeeping->label_compte = $accountingaccount->label;
930 } elseif ($tabtype[$key] ==
'payment_loan') {
931 $bookkeeping->subledger_account =
'';
932 $bookkeeping->subledger_label =
'';
933 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
935 $accountingaccount->fetch(0, $k,
true);
936 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
938 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
940 $bookkeeping->numero_compte = $k;
941 $bookkeeping->label_compte = $accountingaccount->label;
942 } elseif ($tabtype[$key] ==
'payment_various') {
943 $bookkeeping->subledger_account = $k;
944 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
945 if (empty($conf->cache[
'accountingaccountincurrententity'][$tabpay[$key][
"account_various"]])) {
947 $accountingaccount->fetch(0, $tabpay[$key][
"account_various"],
true);
948 $conf->cache[
'accountingaccountincurrententity'][$tabpay[$key][
"account_various"]] = $accountingaccount;
950 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$tabpay[$key][
"account_various"]];
952 $bookkeeping->numero_compte = $tabpay[$key][
"account_various"];
953 $bookkeeping->label_compte = $accountingaccount->label;
954 } elseif ($tabtype[$key] ==
'banktransfert') {
955 $bookkeeping->subledger_account =
'';
956 $bookkeeping->subledger_label =
'';
957 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
959 $accountingaccount->fetch(0, $k,
true);
960 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
962 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
964 $bookkeeping->numero_compte = $k;
965 $bookkeeping->label_compte = $accountingaccount->label;
967 if ($tabtype[$key] ==
'unknown') {
969 $bookkeeping->subledger_account =
'';
970 $bookkeeping->subledger_label =
'';
972 $bookkeeping->label_compte = $accountingaccountsuspense->label;
975 $bookkeeping->label_operation = $reflabel;
976 $bookkeeping->entity = $conf->entity;
978 $totaldebit += $bookkeeping->debit;
979 $totalcredit += $bookkeeping->credit;
981 $result = $bookkeeping->create($user);
983 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
986 setEventMessages(
'Transaction for ('.$bookkeeping->doc_type.
', '.$bookkeeping->fk_doc.
', '.$bookkeeping->fk_docdet.
') were already recorded',
null,
'warnings');
994 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
996 $nb_lettering = $lettering_static->bookkeepingLetteringAll(array($bookkeeping->id));
1002 foreach ($tabbq[$key] as $k => $mt) {
1005 if (!empty($val[
'lib'])) {
1011 $bookkeeping->doc_date = $val[
"date"];
1012 $bookkeeping->doc_ref = $ref;
1013 $bookkeeping->doc_type =
'bank';
1014 $bookkeeping->fk_doc = $key;
1015 $bookkeeping->fk_docdet = $val[
"fk_bank"];
1016 $bookkeeping->montant = $mt;
1017 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
1018 $bookkeeping->debit = ($mt < 0 ? -$mt : 0);
1019 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
1020 $bookkeeping->code_journal = $journal;
1021 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
1022 $bookkeeping->fk_user_author = $user->id;
1023 $bookkeeping->date_creation = $now;
1024 $bookkeeping->label_compte =
'';
1025 $bookkeeping->label_operation = $reflabel;
1026 $bookkeeping->entity = $conf->entity;
1028 $totaldebit += $bookkeeping->debit;
1029 $totalcredit += $bookkeeping->credit;
1031 $result = $bookkeeping->create($user);
1034 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
1037 setEventMessages(
'Transaction for ('.$bookkeeping->doc_type.
', '.$bookkeeping->fk_doc.
', '.$bookkeeping->fk_docdet.
') were already recorded',
null,
'warnings');
1052 setEventMessages(
'We tried to insert a non balanced transaction in book for '.$ref.
'. Canceled. Surely a bug.',
null,
'errors');
1055 if (!$errorforline) {
1062 if ($error >= $MAXNBERRORS) {
1063 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped").
' (>'.$MAXNBERRORS.
')',
null,
'errors');
1069 if (empty($error) && count($tabpay) > 0) {
1071 } elseif (count($tabpay) == $error) {
1074 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
1080 if (count($tabpay) != $error) {
1081 $param =
'id_journal='.$id_journal;
1082 $param .=
'&date_startday='.$date_startday;
1083 $param .=
'&date_startmonth='.$date_startmonth;
1084 $param .=
'&date_startyear='.$date_startyear;
1085 $param .=
'&date_endday='.$date_endday;
1086 $param .=
'&date_endmonth='.$date_endmonth;
1087 $param .=
'&date_endyear='.$date_endyear;
1088 $param .=
'&in_bookkeeping='.$in_bookkeeping;
1089 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
1097if ($action ==
'exportcsv' && $user->hasRight(
'accounting',
'bind',
'write')) {
1100 $filename =
'journal';
1101 $type_export =
'journal';
1102 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
1105 print
'"'.$langs->transnoentitiesnoconv(
"BankId").
'"'.$sep;
1106 print
'"'.$langs->transnoentitiesnoconv(
"Date").
'"'.$sep;
1107 print
'"'.$langs->transnoentitiesnoconv(
"PaymentMode").
'"'.$sep;
1108 print
'"'.$langs->transnoentitiesnoconv(
"AccountAccounting").
'"'.$sep;
1109 print
'"'.$langs->transnoentitiesnoconv(
"SubledgerAccount").
'"'.$sep;
1110 print
'"'.$langs->transnoentitiesnoconv(
"Label").
'"'.$sep;
1111 print
'"'.$langs->transnoentitiesnoconv(
"AccountingDebit").
'"'.$sep;
1112 print
'"'.$langs->transnoentitiesnoconv(
"AccountingCredit").
'"'.$sep;
1113 print
'"'.$langs->transnoentitiesnoconv(
"Journal").
'"'.$sep;
1114 print
'"'.$langs->transnoentitiesnoconv(
"Note").
'"'.$sep;
1117 foreach ($tabpay as $key => $val) {
1123 foreach ($tabbq[$key] as $k => $mt) {
1126 if (!empty($val[
'lib'])) {
1130 if (!empty($val[
'soclib'])) {
1131 $reflabel .=
" / ".dol_string_nohtmltag($val[
'soclib']);
1134 print
'"'.$key.
'"'.$sep;
1135 print
'"'.$date.
'"'.$sep;
1136 print
'"'.$val[
"type_payment"].
'"'.$sep;
1137 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1139 print
'"'.$reflabel.
'"'.$sep;
1140 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1141 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1142 print
'"'.$journal.
'"'.$sep;
1143 print
'"'.dol_string_nohtmltag($ref).
'"'.$sep;
1149 if (is_array($tabtp[$key])) {
1150 foreach ($tabtp[$key] as $k => $mt) {
1153 if (!empty($val[
'lib'])) {
1156 if ($tabtype[$key] ==
'banktransfert') {
1157 $reflabel .=
dol_string_nohtmltag($langs->transnoentitiesnoconv(
'TransitionalAccount').
' '.$account_transfer);
1162 print
'"'.$key.
'"'.$sep;
1163 print
'"'.$date.
'"'.$sep;
1164 print
'"'.$val[
"type_payment"].
'"'.$sep;
1165 if ($tabtype[$key] ==
'payment_supplier') {
1166 $account_ledger = (!empty($obj->accountancy_code_supplier_general)) ? $obj->accountancy_code_supplier_general : $account_supplier;
1167 print
'"'.length_accountg($account_ledger).
'"'.$sep;
1168 } elseif ($tabtype[$key] ==
'payment') {
1169 $account_ledger = (!empty($obj->accountancy_code_customer_general)) ? $obj->accountancy_code_customer_general : $account_customer;
1170 print
'"'.length_accountg($account_ledger).
'"'.$sep;
1171 } elseif ($tabtype[$key] ==
'payment_expensereport') {
1172 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_EXPENSEREPORT')).
'"'.$sep;
1173 } elseif ($tabtype[$key] ==
'payment_salary') {
1174 $account_ledger = (!empty($obj->accountancy_code_user_general)) ? $obj->accountancy_code_user_general : $account_employee;
1175 print
'"'.length_accountg($account_ledger).
'"'.$sep;
1177 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1179 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
1180 print
'"'.$reflabel.
'"'.$sep;
1181 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1182 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1183 print
'"'.$journal.
'"'.$sep;
1184 print
'"'.dol_string_nohtmltag($ref).
'"'.$sep;
1189 foreach ($tabbq[$key] as $k => $mt) {
1192 if (!empty($val[
'lib'])) {
1197 print
'"'.$key.
'"'.$sep;
1198 print
'"'.$date.
'"'.$sep;
1199 print
'"'.$val[
"type_payment"].
'"'.$sep;
1200 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUSPENSE')).
'"'.$sep;
1202 print
'"'.$reflabel.
'"'.$sep;
1203 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1204 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1205 print
'"'.$journal.
'"'.$sep;
1206 print
'"'.dol_string_nohtmltag($ref).
'"'.$sep;
1219$form =
new Form($db);
1221if (empty($action) || $action ==
'view') {
1222 $invoicestatic =
new Facture($db);
1225 $vatstatic =
new Tva($db);
1226 $donationstatic =
new Don($db);
1227 $loanstatic =
new Loan($db);
1228 $salarystatic =
new Salary($db);
1231 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
1232 $help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité';
1238 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
1240 $listofchoices = array(
1241 'notyet' => $langs->trans(
"NotYetInGeneralLedger"),
1242 'already' => $langs->trans(
"AlreadyInGeneralLedger")
1244 $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);
1245 $period .=
'<span class="valignmiddle"> - '.$langs->trans(
"JournalizationInLedgerStatus").
' </span>'.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth75 valignmiddle');
1247 $varlink =
'id_journal='.$id_journal;
1251 $listofchoices = array(
1252 1 => $langs->trans(
"TransfertAllBankLines"),
1253 2 => $langs->trans(
"TransfertOnlyConciliatedBankLine")
1255 $moreoptions = [
"BankLineConciliated" => $form->selectarray(
'only_rappro', $listofchoices, $only_rappro, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth75 valignmiddle')];
1257 journalHead($nom,
'', $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink, $moreoptions);
1264 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int) $conf->entity);
1265 $resql = $db->query($sql);
1267 $obj = $db->fetch_object($resql);
1268 if ($obj->nb == 0) {
1269 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
1270 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
1271 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
1281 $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";
1282 $resql = $db->query($sql);
1284 $obj = $db->fetch_object($resql);
1286 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheJournalCodeIsNotDefinedOnSomeBankAccount");
1287 $desc =
' : '.$langs->trans(
"AccountancyAreaDescBank", 6,
'{link}');
1288 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"BankAccounts").
'</strong>', $desc);
1304 print($desc ?
'' :
'<br>').
'<div class="warning">'.
img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
1305 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
1306 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
1312 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
1314 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
1315 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
1320 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
1322 if ($in_bookkeeping ==
'notyet') {
1323 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
1325 print
'<a class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
1333 <script type="text/javascript">
1334 function launch_export() {
1335 console.log("Set value into form and submit");
1336 $("div.fiche form input[name=\"action\"]").val("exportcsv");
1337 $("div.fiche form input[type=\"submit\"]").click();
1338 $("div.fiche form input[name=\"action\"]").val("");
1340 function writebookkeeping() {
1341 console.log("Set value into form and submit");
1342 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
1343 $("div.fiche form input[type=\"submit\"]").click();
1344 $("div.fiche form input[name=\"action\"]").val("");
1354 print
'<div class="div-table-responsive">';
1355 print
'<table class="noborder centpercent">';
1356 print
'<tr class="liste_titre">';
1357 print
"<td>".$langs->trans(
"Date").
"</td>";
1358 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"ObjectsRef").
")</td>";
1359 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
1360 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
1361 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
1362 print
'<td class="center">'.$langs->trans(
"PaymentMode").
"</td>";
1363 print
'<td class="right">'.$langs->trans(
"AccountingDebit").
"</td>";
1364 print
'<td class="right">'.$langs->trans(
"AccountingCredit").
"</td>";
1367 foreach ($tabpay as $key => $val) {
1373 foreach ($tabbq[$key] as $k => $mt) {
1376 if (!empty($val[
'lib'])) {
1377 $reflabel .= $val[
'lib'].
" / ";
1379 $reflabel .= $langs->trans(
"Bank").
' '.$val[
'bank_account_ref'];
1380 if (!empty($val[
'soclib'])) {
1381 $reflabel .=
" / ".$val[
'soclib'];
1385 print
'<!-- Bank bank.rowid='.$key.
'=accounting_bookkeeping.fk_doc (accounting_bookkeeping.doc_type=\'bank\') type='.$tabpay[$key][
'type'].
' ref='.$tabpay[$key][
'ref'].
' -->';
1386 print
'<tr class="oddeven">';
1389 print
"<td>".$date.
"</td>";
1392 print
'<td class="maxwidth300 nopaddingtopimp nopaddingbottomimp">'.dol_escape_htmltag($ref).
"</td>";
1396 if (empty($accounttoshow) || $accounttoshow ==
'NotDefined') {
1397 $accounttoshow =
'<span class="error">'.$langs->trans(
"BankAccountNotDefined").
'</span>';
1399 print
'<td class="maxwidth300" title="'.dol_escape_htmltag(
dol_string_nohtmltag($accounttoshow)).
'">';
1400 print $accounttoshow;
1404 print
'<td class="maxwidth300">';
1414 print
'<td class="maxwidth300 nopaddingtopimp nopaddingbottomimp">';
1418 print
'<td class="center">'.$val[
"type_payment"].
"</td>";
1419 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1420 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1428 if (is_array($tabtp[$key])) {
1429 foreach ($tabtp[$key] as $k => $mt) {
1432 if (!empty($val[
'lib'])) {
1433 $reflabel .= $val[
'lib'].(!empty($val[
'soclib']) ?
" / " :
"");
1435 if ($tabtype[$key] ==
'banktransfert') {
1436 $reflabel .= $langs->trans(
'TransitionalAccount').
' '.$account_transfer;
1438 $reflabel .= isset($val[
'soclib']) ? $val[
'soclib'] :
"";
1441 print
'<!-- Thirdparty bank.rowid='.$key.
'=accounting_bookkeeping.fk_doc (accounting_bookkeeping.doc_type=\'bank\') type='.$tabpay[$key][
'type'].
' ref='.$tabpay[$key][
'ref'].
' -->';
1442 print
'<tr class="oddeven">';
1445 print
"<td>".$date.
"</td>";
1448 print
'<td class="nopaddingtopimp nopaddingbottomimp">'.dol_escape_htmltag($ref).
"</td>";
1452 $account_ledger = $k;
1454 if ($tabtype[$key] ==
'payment') {
1455 $account_ledger = (!empty($obj->accountancy_code_customer_general)) ? $obj->accountancy_code_customer_general : $account_customer;
1457 if ($tabtype[$key] ==
'payment_supplier') {
1458 $account_ledger = (!empty($obj->accountancy_code_supplier_general)) ? $obj->accountancy_code_supplier_general : $account_supplier;
1460 if ($tabtype[$key] ==
'payment_expensereport') {
1463 if ($tabtype[$key] ==
'payment_salary') {
1464 $account_ledger = (!empty($obj->accountancy_code_user_general)) ? $obj->accountancy_code_user_general : $account_employee;
1466 if ($tabtype[$key] ==
'payment_vat') {
1469 if ($tabtype[$key] ==
'member') {
1472 if ($tabtype[$key] ==
'payment_various') {
1473 $account_ledger = $tabpay[$key][
"account_various"];
1476 if (empty($accounttoshow) || $accounttoshow ==
'NotDefined') {
1477 if ($tabtype[$key] ==
'unknown') {
1480 $accounttoshow =
'<span class="error small">'.$langs->trans(
'UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').
'</span>';
1482 $accounttoshow =
'<span class="warning small">'.$langs->trans(
'UnknownAccountForThirdparty',
length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUSPENSE'))).
'</span>';
1486 $errorstring =
'UnknownAccountForThirdpartyBlocking';
1487 if ($tabtype[$key] ==
'payment') {
1488 $errorstring =
'MainAccountForCustomersNotDefined';
1490 if ($tabtype[$key] ==
'payment_supplier') {
1491 $errorstring =
'MainAccountForSuppliersNotDefined';
1493 if ($tabtype[$key] ==
'payment_expensereport') {
1494 $errorstring =
'MainAccountForUsersNotDefined';
1496 if ($tabtype[$key] ==
'payment_salary') {
1497 $errorstring =
'MainAccountForUsersNotDefined';
1499 if ($tabtype[$key] ==
'payment_vat') {
1500 $errorstring =
'MainAccountForVatPaymentNotDefined';
1502 if ($tabtype[$key] ==
'member') {
1503 $errorstring =
'MainAccountForSubscriptionPaymentNotDefined';
1505 $accounttoshow =
'<span class="error small">'.$langs->trans($errorstring).
'</span>';
1508 print
'<td class="maxwidth300" title="'.dol_escape_htmltag(
dol_string_nohtmltag($accounttoshow)).
'">';
1509 print $accounttoshow;
1513 $accounttoshowsubledger =
'';
1514 if (in_array($tabtype[$key], array(
'payment',
'payment_supplier',
'payment_expensereport',
'payment_salary',
'payment_various'))) {
1516 if ($accounttoshow != $accounttoshowsubledger) {
1517 if (empty($accounttoshowsubledger) || $accounttoshowsubledger ==
'NotDefined') {
1519 if (!empty($tabcompany[$key][
'code_compta'])) {
1520 if (in_array($tabtype[$key], array(
'payment_various'))) {
1522 $accounttoshowsubledger =
'<span class="warning small twolinesmax">'.$langs->trans(
"ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").
'</span>';
1523 } elseif (in_array($tabtype[$key], array(
'payment_salary'))) {
1524 $accounttoshowsubledger =
'<span class="warning small twolinesmax">'.$langs->trans(
"ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored2").
'</span>';
1526 $accounttoshowsubledger =
'<span class="warning small twolinesmax">'.$langs->trans(
"ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key][
'code_compta']).
'</span>';
1529 $accounttoshowsubledger =
'<span class="error small twolinesmax">'.$langs->trans(
"ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").
'</span>';
1533 $accounttoshowsubledger =
'';
1536 print
'<td class="maxwidth300 nopaddingtopimp nopaddingbottomimp" title="'.dolPrintHTMLForAttribute(
dol_string_nohtmltag($accounttoshowsubledger)).
'">';
1537 print $accounttoshowsubledger;
1541 print
'<td class="nopaddingtopimpo paddingbottomimp">';
1545 print
'<td class="center">'.$val[
"type_payment"].
"</td>";
1547 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1549 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1557 foreach ($tabbq[$key] as $k => $mt) {
1560 if (!empty($val[
'lib'])) {
1561 $reflabel .= $val[
'lib'].
" / ";
1563 $reflabel .=
'WaitingAccount';
1565 print
'<!-- Wait bank.rowid='.$key.
' -->';
1566 print
'<tr class="oddeven">';
1567 print
"<td>".$date.
"</td>";
1568 print
"<td>".$ref.
"</td>";
1581 print
"<td>".dol_escape_htmltag($reflabel).
"</td>";
1582 print
'<td class="center">'.$val[
"type_payment"].
"</td>";
1583 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1584 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1595 print
'<tr class="oddeven"><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1622 if ($ref ==
'(SupplierInvoicePayment)' || $ref ==
'(SupplierInvoicePaymentBack)') {
1623 $ref = $langs->transnoentitiesnoconv(
'Supplier');
1625 if ($ref ==
'(CustomerInvoicePayment)' || $ref ==
'(CustomerInvoicePaymentBack)') {
1626 $ref = $langs->transnoentitiesnoconv(
'Customer');
1628 if ($ref ==
'(SocialContributionPayment)') {
1629 $ref = $langs->transnoentitiesnoconv(
'SocialContribution');
1631 if ($ref ==
'(DonationPayment)') {
1632 $ref = $langs->transnoentitiesnoconv(
'Donation');
1634 if ($ref ==
'(SubscriptionPayment)') {
1635 $ref = $langs->transnoentitiesnoconv(
'Subscription');
1637 if ($ref ==
'(ExpenseReportPayment)') {
1638 $ref = $langs->transnoentitiesnoconv(
'Employee');
1640 if ($ref ==
'(LoanPayment)') {
1641 $ref = $langs->transnoentitiesnoconv(
'Loan');
1643 if ($ref ==
'(payment_salary)') {
1644 $ref = $langs->transnoentitiesnoconv(
'Employee');
1648 if ($typerecord ==
'payment') {
1650 $sqlmid =
"SELECT payfac.fk_facture as id, ".$db->ifsql(
'f1.rowid IS NULL',
'f.ref',
'f1.ref').
" as ref";
1651 $sqlmid .=
" FROM ".$db->prefix().
"paiement_facture as payfac";
1652 $sqlmid .=
" LEFT JOIN ".$db->prefix().
"facture as f ON f.rowid = payfac.fk_facture";
1653 $sqlmid .=
" LEFT JOIN ".$db->prefix().
"societe_remise_except as sre ON sre.fk_facture_source = payfac.fk_facture";
1654 $sqlmid .=
" LEFT JOIN ".$db->prefix().
"facture as f1 ON f1.rowid = sre.fk_facture";
1655 $sqlmid .=
" WHERE payfac.fk_paiement=".((int) $val[
'paymentid']);
1657 $sqlmid =
"SELECT payfac.fk_facture as id, f.ref as ref";
1658 $sqlmid .=
" FROM ".$db->prefix().
"paiement_facture as payfac";
1659 $sqlmid .=
" INNER JOIN ".$db->prefix().
"facture as f ON f.rowid = payfac.fk_facture";
1660 $sqlmid .=
" WHERE payfac.fk_paiement=".((int) $val[
'paymentid']);
1662 $ref = $langs->transnoentitiesnoconv(
"Invoice");
1663 } elseif ($typerecord ==
'payment_supplier') {
1664 $sqlmid =
'SELECT payfac.fk_facturefourn as id, f.ref';
1665 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX.
"facture_fourn as f";
1666 $sqlmid .=
" WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=".((int) $val[
"paymentsupplierid"]);
1667 $ref = $langs->transnoentitiesnoconv(
"SupplierInvoice");
1668 } elseif ($typerecord ==
'payment_expensereport') {
1669 $sqlmid =
'SELECT e.rowid as id, e.ref';
1670 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"payment_expensereport as pe, ".MAIN_DB_PREFIX.
"expensereport as e";
1671 $sqlmid .=
" WHERE pe.rowid=".((int) $val[
"paymentexpensereport"]).
" AND pe.fk_expensereport = e.rowid";
1672 $ref = $langs->transnoentitiesnoconv(
"ExpenseReport");
1673 } elseif ($typerecord ==
'payment_salary') {
1674 $sqlmid =
'SELECT s.rowid as ref';
1675 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary as s";
1676 $sqlmid .=
" WHERE s.rowid=".((int) $val[
"paymentsalid"]);
1677 $ref = $langs->transnoentitiesnoconv(
"SalaryPayment");
1678 } elseif ($typerecord ==
'sc') {
1679 $sqlmid =
'SELECT sc.rowid as ref';
1680 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"paiementcharge as sc";
1681 $sqlmid .=
" WHERE sc.rowid=".((int) $val[
"paymentscid"]);
1682 $ref = $langs->transnoentitiesnoconv(
"SocialContribution");
1683 } elseif ($typerecord ==
'payment_vat') {
1684 $sqlmid =
'SELECT pv.fk_tva as ref';
1685 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"payment_vat as pv";
1686 $sqlmid .=
" WHERE pv.rowid=".((int) $val[
"paymentvatid"]);
1687 $ref = $langs->transnoentitiesnoconv(
"PaymentVat");
1688 } elseif ($typerecord ==
'payment_donation') {
1689 $sqlmid =
'SELECT payd.fk_donation as ref';
1690 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"payment_donation as payd";
1691 $sqlmid .=
" WHERE payd.fk_donation=".((int) $val[
"paymentdonationid"]);
1692 $ref = $langs->transnoentitiesnoconv(
"Donation");
1693 } elseif ($typerecord ==
'payment_loan') {
1694 $sqlmid =
'SELECT l.rowid as ref';
1695 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"payment_loan as l";
1696 $sqlmid .=
" WHERE l.rowid=".((int) $val[
"paymentloanid"]);
1697 $ref = $langs->transnoentitiesnoconv(
"LoanPayment");
1698 } elseif ($typerecord ==
'payment_various') {
1699 $sqlmid =
'SELECT v.rowid as ref';
1700 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"payment_various as v";
1701 $sqlmid .=
" WHERE v.rowid=".((int) $val[
"paymentvariousid"]);
1702 $ref = $langs->transnoentitiesnoconv(
"VariousPayment");
1705 if (empty($sqlmid)) {
1706 dol_syslog(
"Found a typerecord=".$typerecord.
" not supported", LOG_WARNING);
1710 dol_syslog(
"accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG);
1711 $resultmid = $db->query($sqlmid);
1713 while ($objmid = $db->fetch_object($resultmid)) {
1714 $ref .=
' '.$objmid->ref;
1721 $ref =
dol_trunc($langs->transnoentitiesnoconv(
"BankId").
' '.$val[
'fk_bank'].
' - '.$ref, 295);
if(! $sortfield) if(! $sortorder) $object
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.
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.
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.
Class to manage Trips and Expenses.
Class to manage suppliers invoices.
Class to manage invoices.
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)
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.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_now($mode='gmt')
Return date for now.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
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.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.