38require
'../../main.inc.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/bank.lib.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
50require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/societe/class/societe.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/adherents/class/adherent.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/compta/sociales/class/chargesociales.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/compta/paiement/class/paiement.class.php';
57require_once DOL_DOCUMENT_ROOT.
'/don/class/don.class.php';
58require_once DOL_DOCUMENT_ROOT.
'/don/class/paymentdonation.class.php';
59require_once DOL_DOCUMENT_ROOT.
'/compta/tva/class/tva.class.php';
60require_once DOL_DOCUMENT_ROOT.
'/salaries/class/paymentsalary.class.php';
61require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
62require_once DOL_DOCUMENT_ROOT.
'/fourn/class/paiementfourn.class.php';
63require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
64require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
65require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeeping.class.php';
66require_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
67require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
68require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/paymentexpensereport.class.php';
69require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/paymentvarious.class.php';
70require_once DOL_DOCUMENT_ROOT.
'/compta/bank/class/account.class.php';
71require_once DOL_DOCUMENT_ROOT.
'/loan/class/loan.class.php';
72require_once DOL_DOCUMENT_ROOT.
'/loan/class/paymentloan.class.php';
73require_once DOL_DOCUMENT_ROOT.
'/adherents/class/subscription.class.php';
78$langs->loadLangs(array(
"companies",
"other",
"compta",
"banks",
"bills",
"donations",
"loan",
"accountancy",
"trips",
"salaries",
"hrm",
"members"));
83$date_startmonth =
GETPOSTINT(
'date_startmonth');
89$in_bookkeeping =
GETPOST(
'in_bookkeeping',
'aZ09');
92if ($only_rappro == 0) {
99$action =
GETPOST(
'action',
'aZ09');
101if ($in_bookkeeping ==
'' || $action ==
'writebookkeeping') {
102 $in_bookkeeping =
'notyet';
110if ($user->socid > 0) {
113if (!$user->hasRight(
'accounting',
'bind',
'write')) {
125$date_end =
dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
128$pastmonthyear =
null;
130if (empty($date_startmonth)) {
134 $pastmonthyear = $dates[
'pastmonthyear'];
135 $pastmonth = $dates[
'pastmonth'];
137if (empty($date_endmonth)) {
140 $date_end = $dates[
'date_end'];
141 $pastmonthyear = $dates[
'pastmonthyear'];
142 $pastmonth = $dates[
'pastmonth'];
145if (!
GETPOSTISSET(
'date_startmonth') && (empty($date_start) || empty($date_end))) {
147 $date_end =
dol_get_last_day((
int) $pastmonthyear, (
int) $pastmonth,
false);
152$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, b.numero_compte,";
153$sql .=
" ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,";
154$sql .=
" soc.rowid as socid, soc.nom as name, soc.email as email, bu1.type as typeop_company,";
156 $sql .=
" spe.accountancy_code_customer_general,";
157 $sql .=
" spe.accountancy_code_customer as code_compta_client,";
158 $sql .=
" spe.accountancy_code_supplier_general,";
159 $sql .=
" spe.accountancy_code_supplier as code_compta_fournisseur,";
161 $sql .=
" soc.accountancy_code_customer_general,";
162 $sql .=
" soc.code_compta as code_compta_client,";
163 $sql .=
" soc.accountancy_code_supplier_general,";
164 $sql .=
" soc.code_compta_fournisseur,";
166$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,";
167$sql .=
" bu2.type as typeop_user,";
168$sql .=
" bu3.type as typeop_payment, bu4.type as typeop_payment_supplier";
169$sql .=
" FROM ".$db->prefix().
"bank as b";
170$sql .=
" JOIN ".$db->prefix().
"bank_account as ba on b.fk_account = ba.rowid";
171$sql .=
" LEFT JOIN ".$db->prefix().
"bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
172$sql .=
" LEFT JOIN ".$db->prefix().
"bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='user'";
173$sql .=
" LEFT JOIN ".$db->prefix().
"bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment'";
174$sql .=
" LEFT JOIN ".$db->prefix().
"bank_url as bu4 ON bu4.fk_bank = b.rowid AND bu4.type='payment_supplier'";
175$sql .=
" LEFT JOIN ".$db->prefix().
"societe as soc on bu1.url_id=soc.rowid";
177 $sql .=
" LEFT JOIN " . $db->prefix() .
"societe_perentity as spe ON spe.fk_soc = soc.rowid AND spe.entity = " . ((int)
$conf->entity);
179$sql .=
" LEFT JOIN ".$db->prefix().
"user as u on bu2.url_id=u.rowid";
180$sql .=
" WHERE ba.fk_accountancy_journal=".((int) $id_journal);
181$sql .=
" AND b.amount <> 0 AND ba.entity IN (".getEntity(
'bank_account', 0).
")";
182if ($date_start && $date_end) {
183 $sql .=
" AND b.dateo >= '".$db->idate($date_start).
"' AND b.dateo <= '".$db->idate($date_end).
"'";
187 $sql .=
" AND b.dateo >= '".$db->idate(
getDolGlobalInt(
'ACCOUNTING_DATE_START_BINDING')).
"'";
190if ($in_bookkeeping ==
'already') {
191 $sql .=
" AND (b.rowid IN (SELECT fk_doc FROM ".$db->prefix().
"accounting_bookkeeping as ab WHERE ab.doc_type='bank') )";
193if ($in_bookkeeping ==
'notyet') {
194 $sql .=
" AND (b.rowid NOT IN (SELECT fk_doc FROM ".$db->prefix().
"accounting_bookkeeping as ab WHERE ab.doc_type='bank') )";
196if ($only_rappro == 2) {
197 $sql .=
" AND (b.rappro = '1')";
199$sql .=
" ORDER BY b.datev";
203$accountancy_code_by_payment = array();
204$sql2 =
"SELECT code, accountancy_code";
205$sql2 .=
" FROM ".MAIN_DB_PREFIX.
"c_paiement";
206$sql2 .=
" WHERE entity IN (".getEntity(
'c_paiement').
")";
207$sql2 .=
" AND active = 1";
208$resql = $db->query($sql2);
210 while ($objp = $db->fetch_object($resql)) {
211 if (!empty($objp->code) && !empty($objp->accountancy_code)) {
212 $accountancy_code_by_payment[$objp->code] = $objp->accountancy_code;
220$societestatic =
new Societe($db);
221$userstatic =
new User($db);
222$bankaccountstatic =
new Account($db);
225$paymentvatstatic =
new Tva($db);
237$account_transfer =
'NotDefined';
241$accountingjournalstatic->fetch($id_journal);
242$journal = $accountingjournalstatic->code;
243$journal_label = $accountingjournalstatic->label;
245$tabcompany = array();
251$tabmoreinfo = array();
254@phan-var-force array<array{id:mixed,name:mixed,code_compta_client:string,email:string}> $tabcompany
255@phan-var-force array<array{id:int,name:string,lastname:string,firstname:string,email:string,accountancy_code:string,status:int> $tabuser
256@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
257@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
260$account_customer =
'NotDefined';
261$account_supplier =
'NotDefined';
262$account_employee =
'NotDefined';
265dol_syslog(
"accountancy/journal/bankjournal.php", LOG_DEBUG);
266$result = $db->query($sql);
268 $num = $db->num_rows($result);
274 $account_employee =
getDolGlobalString(
'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
'NotDefined');
275 $account_expensereport =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_EXPENSEREPORT',
'NotDefined');
277 $account_pay_donation =
getDolGlobalString(
'DONATION_ACCOUNTINGACCOUNT',
'NotDefined');
278 $account_pay_subscription =
getDolGlobalString(
'ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT',
'NotDefined');
279 $account_transfer =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_TRANSFER_CASH',
'NotDefined');
288 $obj = $db->fetch_object($result);
290 $lineisapurchase = -1;
293 if ($obj->label ==
'(SupplierInvoicePayment)' || $obj->label ==
'(SupplierInvoicePaymentBack)') {
294 $lineisapurchase = 1;
296 if ($obj->label ==
'(CustomerInvoicePayment)' || $obj->label ==
'(CustomerInvoicePaymentBack)') {
300 if ($lineisapurchase < 0) {
301 if ($obj->typeop_payment_supplier ==
'payment_supplier') {
302 $lineisapurchase = 1;
305 if ($lineisasale < 0) {
306 if ($obj->typeop_payment ==
'payment') {
314 $compta_bank = $obj->account_number;
317 if (!empty($obj->fk_type) && !empty($accountancy_code_by_payment[$obj->fk_type])) {
318 $compta_bank = $accountancy_code_by_payment[$obj->fk_type];
322 $compta_soc =
'NotDefined';
323 $accountancy_code_general =
'NotDefined';
324 if ($lineisapurchase > 0) {
325 $accountancy_code_general = (!empty($obj->accountancy_code_supplier_general) && $obj->accountancy_code_supplier_general !=
'-1') ? $obj->accountancy_code_supplier_general : $account_supplier;
328 if ($lineisasale > 0) {
329 $accountancy_code_general = (!empty($obj->accountancy_code_customer_general) && $obj->accountancy_code_customer_general !=
'-1') ? $obj->accountancy_code_customer_general : $account_customer;
333 $tabcompany[$obj->rowid] = array(
335 'name' => $obj->name,
336 'code_compta' => $compta_soc,
337 'accountancy_code_general' => $accountancy_code_general,
338 'email' => $obj->email
344 $accountancy_code_user_general = (!empty($obj->accountancy_code_user_general)) ? $obj->accountancy_code_user_general : $account_employee;
345 $compta_user = (!empty($obj->accountancy_code) ? $obj->accountancy_code :
'');
347 $tabuser[$obj->rowid] = array(
348 'id' => $obj->userid,
350 'lastname' => $obj->lastname,
351 'firstname' => $obj->firstname,
352 'email' => $obj->useremail,
353 'accountancy_code_general' => $accountancy_code_user_general,
354 'accountancy_code' => $compta_user,
355 'status' => $obj->userstatus
359 $tabpay[$obj->rowid][
"date"] = $db->jdate($obj->do);
360 $tabpay[$obj->rowid][
"type_payment"] = $obj->fk_type;
361 $tabpay[$obj->rowid][
"ref"] = $obj->label;
362 $tabpay[$obj->rowid][
"fk_bank"] = $obj->rowid;
363 $tabpay[$obj->rowid][
"bank_account_ref"] = $obj->baref;
364 $tabpay[$obj->rowid][
"fk_bank_account"] = $obj->fk_account;
366 if (preg_match(
'/^\((.*)\)$/i', $obj->label, $reg)) {
367 $tabpay[$obj->rowid][
"lib"] = $langs->trans($reg[1]);
369 $tabpay[$obj->rowid][
"lib"] =
dol_trunc($obj->label, 60);
373 $links =
$object->get_url($obj->rowid);
378 $tabpay[$obj->rowid][
'type'] =
'unknown';
379 $tabtype[$obj->rowid] =
'unknown';
380 $tabmoreinfo[$obj->rowid] = array();
382 $amounttouse = $obj->amount;
383 if (!empty($obj->amount_main_currency)) {
385 $amounttouse = $obj->amount_main_currency;
391 if (
getDolGlobalString(
'FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS') && ($lineisapurchase == 1 || $lineisasale == 1)) {
392 if ($lineisapurchase == 1) {
393 $sqlamount =
"SELECT SUM(pf.amount) as amount";
394 $sqlamount .=
" FROM ".MAIN_DB_PREFIX.
"paiementfourn_facturefourn AS pf";
395 $sqlamount .=
" INNER JOIN ".MAIN_DB_PREFIX.
"paiementfourn AS p ON pf.fk_paiementfourn = p.rowid";
396 $sqlamount .=
" RIGHT JOIN ".MAIN_DB_PREFIX.
"facture AS f ON pf.fk_facturefourn = f.rowid";
397 $sqlamount .=
" WHERE p.fk_bank = ".((int) $obj->rowid);
398 $sqlamount .=
" AND f.fk_soc = ".((int) $obj->socid);
400 $sqlamount =
"SELECT SUM(pf.amount) as amount";
401 $sqlamount .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture AS pf";
402 $sqlamount .=
" INNER JOIN ".MAIN_DB_PREFIX.
"paiement AS p ON pf.fk_paiement = p.rowid";
403 $sqlamount .=
" RIGHT JOIN ".MAIN_DB_PREFIX.
"facture AS f ON pf.fk_facture = f.rowid";
404 $sqlamount .=
" WHERE p.fk_bank = ".((int) $obj->rowid);
405 $sqlamount .=
" AND f.fk_soc = ".((int) $obj->socid);
407 $resultamount = $db->query($sqlamount);
409 $objamount = $db->fetch_object($resultamount);
410 if (!empty($objamount->amount)) {
411 $amounttouse = $objamount->amount;
417 if (is_array($links) && count($links) > 0) {
422 $is_expensereport =
false;
424 foreach ($links as $v) {
425 if ($v[
'type'] ==
'sc') {
429 if ($v[
'type'] ==
'payment_salary') {
433 if ($v[
'type'] ==
'payment_expensereport') {
434 $is_expensereport =
true;
437 if ($v[
'type'] ==
'payment_various') {
444 foreach ($links as $key => $val) {
445 if ($links[$key][
'type'] ==
'user' && !$is_sc && !$is_salary && !$is_expensereport) {
450 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'))) {
454 $tabpay[$obj->rowid][
'type'] = $links[$key][
'type'];
455 $tabtype[$obj->rowid] = $links[$key][
'type'];
466 if ($links[$key][
'type'] ==
'withdraw') {
467 $tabmoreinfo[$obj->rowid][
'withdraw'] = 1;
470 if ($links[$key][
'type'] ==
'payment') {
471 $paymentstatic->id = $links[$key][
'url_id'];
472 $paymentstatic->ref = (string) $links[$key][
'url_id'];
473 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentstatic->getNomUrl(2,
'',
'');
474 $tabpay[$obj->rowid][
"paymentid"] = $paymentstatic->id;
475 } elseif ($links[$key][
'type'] ==
'payment_supplier') {
476 $paymentsupplierstatic->id = $links[$key][
'url_id'];
477 $paymentsupplierstatic->ref = (string) $links[$key][
'url_id'];
478 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentsupplierstatic->getNomUrl(2);
479 $tabpay[$obj->rowid][
"paymentsupplierid"] = $paymentsupplierstatic->id;
480 } elseif ($links[$key][
'type'] ==
'company') {
481 $societestatic->id = $links[$key][
'url_id'];
482 $societestatic->name = $links[$key][
'label'];
483 $societestatic->email = $tabcompany[$obj->rowid][
'email'];
484 $tabpay[$obj->rowid][
"soclib"] = $societestatic->getNomUrl(1,
'', 30);
485 if ($compta_soc && !$is_various) {
491 if (!
getDolGlobalString(
'FACTURE_PAYMENTS_ON_DIFFERENT_THIRDPARTIES_BILLS') || $obj->socid == $links[$key][
'url_id']) {
492 if (empty($tabtp[$obj->rowid][$compta_soc])) {
493 $tabtp[$obj->rowid][$compta_soc] = $amounttouse;
495 $tabtp[$obj->rowid][$compta_soc] += $amounttouse;
499 } elseif ($links[$key][
'type'] ==
'user') {
500 $userstatic->id = $links[$key][
'url_id'];
501 $userstatic->name = $links[$key][
'label'];
502 $userstatic->email = $tabuser[$obj->rowid][
'email'];
503 $userstatic->firstname = $tabuser[$obj->rowid][
'firstname'];
504 $userstatic->lastname = $tabuser[$obj->rowid][
'lastname'];
505 $userstatic->status = $tabuser[$obj->rowid][
'status'];
506 $userstatic->accountancy_code_user_general = $tabuser[$obj->rowid][
'accountancy_code_general'];
507 $userstatic->accountancy_code = $tabuser[$obj->rowid][
'accountancy_code'];
512 if ($userstatic->id > 0) {
514 $tabpay[$obj->rowid][
"soclib"] .=
' '.$userstatic->getNomUrl(-1,
'accountancy', 0);
516 $tabpay[$obj->rowid][
"soclib"] = $userstatic->getNomUrl(-1,
'accountancy', 0);
519 $tabpay[$obj->rowid][
"soclib"] =
'???';
526 $tabtp[$obj->rowid][$compta_user] = isset($tabtp[$obj->rowid][$compta_user]) ? $tabtp[$obj->rowid][$compta_user] + $amounttouse : $amounttouse;
529 } elseif ($links[$key][
'type'] ==
'sc') {
530 $chargestatic->id = $links[$key][
'url_id'];
531 $chargestatic->ref = (string) $links[$key][
'url_id'];
533 $tabpay[$obj->rowid][
"lib"] .=
' '.$chargestatic->getNomUrl(2);
535 if (preg_match(
'/^\((.*)\)$/i', $links[$key][
'label'], $reg)) {
536 if ($reg[1] ==
'socialcontribution') {
537 $reg[1] =
'SocialContribution';
539 $chargestatic->label = $langs->trans($reg[1]);
541 $chargestatic->label = $links[$key][
'label'];
543 $chargestatic->ref = $chargestatic->label;
562 $resultmid = $tmpcharge->fetch($chargestatic->id);
564 $chargestatic->type_label = $tmpcharge->type_label;
565 $chargestatic->type_code = $tmpcharge->type_code;
566 $chargestatic->type_accountancy_code = $tmpcharge->type_accountancy_code;
568 $tabtp[$obj->rowid][$tmpcharge->type_accountancy_code] = isset($tabtp[$obj->rowid][$tmpcharge->type_accountancy_code]) ? $tabtp[$obj->rowid][$tmpcharge->type_accountancy_code] + $amounttouse : $amounttouse;
571 $tabpay[$obj->rowid][
"soclib"] = $chargestatic->getNomUrl(1,
'30');
572 $tabpay[$obj->rowid][
"paymentscid"] = $chargestatic->id;
573 } elseif ($links[$key][
'type'] ==
'payment_donation') {
574 $paymentdonstatic->id = $links[$key][
'url_id'];
575 $paymentdonstatic->ref = (string) $links[$key][
'url_id'];
576 $paymentdonstatic->fk_donation = $links[$key][
'url_id'];
577 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentdonstatic->getNomUrl(2);
578 $tabpay[$obj->rowid][
"paymentdonationid"] = $paymentdonstatic->id;
579 $tabtp[$obj->rowid][$account_pay_donation] = isset($tabtp[$obj->rowid][$account_pay_donation]) ? $tabtp[$obj->rowid][$account_pay_donation] + $amounttouse : $amounttouse;
580 } elseif ($links[$key][
'type'] ==
'member') {
581 $paymentsubscriptionstatic->id = $links[$key][
'url_id'];
582 $paymentsubscriptionstatic->ref = (string) $links[$key][
'url_id'];
583 $paymentsubscriptionstatic->label = $links[$key][
'label'];
584 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentsubscriptionstatic->getNomUrl(2);
585 $tabpay[$obj->rowid][
"paymentsubscriptionid"] = $paymentsubscriptionstatic->id;
586 $paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id);
587 $tabtp[$obj->rowid][$account_pay_subscription] = isset($tabtp[$obj->rowid][$account_pay_subscription]) ? $tabtp[$obj->rowid][$account_pay_subscription] + $amounttouse : $amounttouse;
588 } elseif ($links[$key][
'type'] ==
'payment_vat') {
589 $paymentvatstatic->id = $links[$key][
'url_id'];
590 $paymentvatstatic->ref = (string) $links[$key][
'url_id'];
591 $paymentvatstatic->label = $links[$key][
'label'];
592 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentvatstatic->getNomUrl(2);
593 $tabpay[$obj->rowid][
"paymentvatid"] = $paymentvatstatic->id;
594 $tabtp[$obj->rowid][$account_pay_vat] = isset($tabtp[$obj->rowid][$account_pay_vat]) ? $tabtp[$obj->rowid][$account_pay_vat] + $amounttouse : $amounttouse;
595 } elseif ($links[$key][
'type'] ==
'payment_salary') {
596 $paymentsalstatic->id = $links[$key][
'url_id'];
597 $paymentsalstatic->ref = (string) $links[$key][
'url_id'];
598 $paymentsalstatic->label = $links[$key][
'label'];
599 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentsalstatic->getNomUrl(2);
600 $tabpay[$obj->rowid][
"paymentsalid"] = $paymentsalstatic->id;
604 if (
getDolGlobalString(
'ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USER_ON_SALARY_BANK_PAYMENT')) {
605 $tmpsalary =
new Salary($db);
606 $tmpsalary->fetch($paymentsalstatic->id);
607 $tmpsalary->fetch_user($tmpsalary->fk_user);
609 $userstatic->id = $tmpsalary->user->id;
610 $userstatic->name = $tmpsalary->user->name;
611 $userstatic->email = $tmpsalary->user->email;
612 $userstatic->firstname = $tmpsalary->user->firstname;
613 $userstatic->lastname = $tmpsalary->user->lastname;
614 $userstatic->status = $tmpsalary->user->status;
615 $userstatic->accountancy_code = $tmpsalary->user->accountancy_code;
617 if ($userstatic->id > 0) {
618 $tabpay[$obj->rowid][
"soclib"] = $userstatic->getNomUrl(1,
'accountancy', 0);
620 $tabpay[$obj->rowid][
"soclib"] =
'???';
623 if (empty($obj->typeop_user)) {
624 $accountancy_code_user_general = (!empty($obj->accountancy_code_user_general)) ? $obj->accountancy_code_user_general : $account_employee;
625 $compta_user = $userstatic->accountancy_code;
627 $tabtp[$obj->rowid][$compta_user] = isset($tabtp[$obj->rowid][$compta_user]) ? $tabtp[$obj->rowid][$compta_user] + $amounttouse : $amounttouse;
628 $tabuser[$obj->rowid] = array(
629 'id' => $userstatic->id,
631 'lastname' => $userstatic->lastname,
632 'firstname' => $userstatic->firstname,
633 'email' => $userstatic->email,
634 'accountancy_code_general' => $accountancy_code_user_general,
635 'accountancy_code' => $compta_user,
636 'status' => $userstatic->status
641 } elseif ($links[$key][
'type'] ==
'payment_expensereport') {
642 $paymentexpensereportstatic->id = $links[$key][
'url_id'];
643 $tabpay[$obj->rowid][
"lib"] .= $paymentexpensereportstatic->getNomUrl(2);
644 $tabpay[$obj->rowid][
"paymentexpensereport"] = $paymentexpensereportstatic->id;
645 } elseif ($links[$key][
'type'] ==
'payment_various') {
646 $paymentvariousstatic->id = $links[$key][
'url_id'];
647 $paymentvariousstatic->ref = (string) $links[$key][
'url_id'];
648 $paymentvariousstatic->label = $links[$key][
'label'];
649 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentvariousstatic->getNomUrl(2);
650 $tabpay[$obj->rowid][
"paymentvariousid"] = $paymentvariousstatic->id;
651 $paymentvariousstatic->fetch($paymentvariousstatic->id);
652 $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code : (!empty($obj->numero_compte) ? $obj->numero_compte :
'NotDefined'));
653 $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account :
'');
654 $tabpay[$obj->rowid][
"account_various"] = $account_various;
655 $tabtp[$obj->rowid][$account_subledger] = isset($tabtp[$obj->rowid][$account_subledger]) ? $tabtp[$obj->rowid][$account_subledger] + $amounttouse : $amounttouse;
656 } elseif ($links[$key][
'type'] ==
'payment_loan') {
657 $paymentloanstatic->id = $links[$key][
'url_id'];
658 $paymentloanstatic->ref = (string) $links[$key][
'url_id'];
659 $paymentloanstatic->fk_loan = $links[$key][
'url_id'];
660 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentloanstatic->getNomUrl(2);
661 $tabpay[$obj->rowid][
"paymentloanid"] = $paymentloanstatic->id;
663 $sqlmid =
'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest';
664 $sqlmid .=
' FROM '.MAIN_DB_PREFIX.
'payment_loan as pl, '.MAIN_DB_PREFIX.
'loan as l';
665 $sqlmid .=
' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.((int) $obj->rowid);
667 dol_syslog(
"accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG);
668 $resultmid = $db->query($sqlmid);
670 $objmid = $db->fetch_object($resultmid);
671 $tabtp[$obj->rowid][$objmid->accountancy_account_capital] = isset($objmid->amount_capital) ? ($tabtp[$obj->rowid][$objmid->accountancy_account_capital] ?? 0) - $objmid->amount_capital : 0;
672 $tabtp[$obj->rowid][$objmid->accountancy_account_insurance] = isset($objmid->amount_insurance) ? ($tabtp[$obj->rowid][$objmid->accountancy_account_insurance] ?? 0) - $objmid->amount_insurance : 0;
673 $tabtp[$obj->rowid][$objmid->accountancy_account_interest] = isset($objmid->amount_interest) ? ($tabtp[$obj->rowid][$objmid->accountancy_account_interest] ?? 0) - $objmid->amount_interest : 0;
675 } elseif ($links[$key][
'type'] ==
'banktransfert') {
676 $accountLinestatic->fetch($links[$key][
'url_id']);
677 $tabpay[$obj->rowid][
"lib"] .=
' '.$langs->trans(
"BankTransfer").
' '.$accountLinestatic ->getNomUrl(1);
678 $tabtp[$obj->rowid][$account_transfer] = isset($tabtp[$obj->rowid][$account_transfer]) ? $tabtp[$obj->rowid][$account_transfer] + $amounttouse : $amounttouse;
679 $bankaccountstatic->fetch($tabpay[$obj->rowid][
'fk_bank_account']);
680 $tabpay[$obj->rowid][
"soclib"] = $bankaccountstatic->getNomUrl(2);
685 if (empty($tabbq[$obj->rowid][$compta_bank])) {
686 $tabbq[$obj->rowid][$compta_bank] = $amounttouse;
688 $tabbq[$obj->rowid][$compta_bank] += $amounttouse;
693 if (empty($tabtp[$obj->rowid]) && !empty($tabmoreinfo[$obj->rowid][
'withdraw'])) {
694 foreach ($links as $key => $val) {
695 if ($links[$key][
'type'] ==
'payment') {
697 $tmppayment->fetch($links[$key][
'url_id']);
698 $arrayofamounts = $tmppayment->getAmountsArray();
699 if (is_array($arrayofamounts)) {
700 foreach ($arrayofamounts as $invoiceid => $amount) {
701 $tmpinvoice->fetch($invoiceid);
702 $tmpinvoice->fetch_thirdparty();
703 if ($tmpinvoice->thirdparty->code_compta_client) {
704 $tabtp[$obj->rowid][$tmpinvoice->thirdparty->code_compta_client] = isset($tabtp[$obj->rowid][$tmpinvoice->thirdparty->code_compta_client]) ? $tabtp[$obj->rowid][$tmpinvoice->thirdparty->code_compta_client] + $amount : $amount;
713 if (empty($tabtp[$obj->rowid])) {
714 $tabtp[$obj->rowid][
'NotDefined'] = $tabbq[$obj->rowid][$compta_bank];
722 dol_print_error($db);
726if (!$error && $action ==
'writebookkeeping' && $user->hasRight(
'accounting',
'bind',
'write')) {
730 $accountingaccountcustomer->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'),
true);
733 $accountingaccountsupplier->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER'),
true);
736 $accountingaccountpayment->fetch(0,
getDolGlobalString(
'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'),
true);
739 $accountingaccountexpensereport->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_EXPENSEREPORT'),
true);
742 $accountingaccountsuspense->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUSPENSE'),
true);
745 foreach ($tabpay as $key => $val) {
760 if (is_array($tabbq[$key])) {
762 foreach ($tabbq[$key] as $k => $mt) {
764 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
766 $accountingaccount->fetch(0, $k,
true);
767 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
769 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
772 $account_label = $accountingaccount->label;
775 if (!empty($val[
'lib'])) {
779 if (!empty($val[
'soclib'])) {
780 $reflabel .=
" / ".dol_string_nohtmltag($val[
'soclib']);
784 $bookkeeping->doc_date = $val[
"date"];
785 $bookkeeping->doc_ref = $ref;
786 $bookkeeping->doc_type =
'bank';
787 $bookkeeping->fk_doc = (int) $key;
788 $bookkeeping->fk_docdet = $val[
"fk_bank"];
790 $bookkeeping->numero_compte = $k;
791 $bookkeeping->label_compte = $account_label;
793 $bookkeeping->label_operation = $reflabel;
794 $bookkeeping->montant = $mt;
795 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
796 $bookkeeping->debit = ($mt >= 0 ? $mt : 0);
797 $bookkeeping->credit = ($mt < 0 ? -$mt : 0);
798 $bookkeeping->code_journal = $journal;
799 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
800 $bookkeeping->fk_user_author = $user->id;
801 $bookkeeping->date_creation = $now;
804 $bookkeeping->subledger_account =
'';
805 $bookkeeping->label_operation = $reflabel;
806 $bookkeeping->entity =
$conf->entity;
808 $totaldebit += $bookkeeping->debit;
809 $totalcredit += $bookkeeping->credit;
811 $result = $bookkeeping->create($user);
813 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
816 setEventMessages(
'Transaction for ('.$bookkeeping->doc_type.
', '.$bookkeeping->fk_doc.
', '.$bookkeeping->fk_docdet.
') were already recorded',
null,
'warnings');
820 setEventMessages($bookkeeping->error, $bookkeeping->errors,
'errors');
828 if (!$errorforline) {
829 if (is_array($tabtp[$key])) {
831 foreach ($tabtp[$key] as $k => $mt) {
836 if (!empty($val[
'lib'])) {
839 if ($tabtype[$key] ==
'banktransfert') {
840 $reflabel .=
dol_string_nohtmltag($langs->transnoentitiesnoconv(
'TransitionalAccount').
' '.$account_transfer);
846 $bookkeeping->doc_date = $val[
"date"];
847 $bookkeeping->doc_ref = $ref;
848 $bookkeeping->doc_type =
'bank';
849 $bookkeeping->fk_doc = (int) $key;
850 $bookkeeping->fk_docdet = $val[
"fk_bank"];
852 $bookkeeping->label_operation = $reflabel;
853 $bookkeeping->montant = $mt;
854 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
855 $bookkeeping->debit = ($mt < 0 ? -$mt : 0);
856 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
857 $bookkeeping->code_journal = $journal;
858 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
859 $bookkeeping->fk_user_author = $user->id;
860 $bookkeeping->date_creation = $now;
862 if ($tabtype[$key] ==
'payment') {
864 $bookkeeping->subledger_account = $k;
865 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
866 $bookkeeping->numero_compte = $tabcompany[$key][
'accountancy_code_general'];
867 $bookkeeping->label_compte = $accountingaccountcustomer->label;
868 } elseif ($tabtype[$key] ==
'payment_supplier') {
870 $bookkeeping->subledger_account = $k;
871 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
872 $bookkeeping->numero_compte = $tabcompany[$key][
'accountancy_code_general'];
873 $bookkeeping->label_compte = $accountingaccountsupplier->label;
874 } elseif ($tabtype[$key] ==
'payment_expensereport') {
875 $bookkeeping->subledger_account = $tabuser[$key][
'accountancy_code'];
876 $bookkeeping->subledger_label = $tabuser[$key][
'name'];
878 $bookkeeping->label_compte = $accountingaccountexpensereport->label;
879 } elseif ($tabtype[$key] ==
'payment_salary') {
880 $bookkeeping->subledger_account = $tabuser[$key][
'accountancy_code'];
881 $bookkeeping->subledger_label = $tabuser[$key][
'name'];
882 $bookkeeping->numero_compte = $tabuser[$key][
'accountancy_code_general'];
883 $bookkeeping->label_compte = $accountingaccountpayment->label;
884 } elseif (in_array($tabtype[$key], array(
'sc',
'payment_sc'))) {
885 $bookkeeping->subledger_account =
'';
886 $bookkeeping->subledger_label =
'';
887 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
889 $accountingaccount->fetch(0, $k,
true);
890 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
892 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
894 $bookkeeping->numero_compte = $k;
895 $bookkeeping->label_compte = $accountingaccount->label;
896 } elseif ($tabtype[$key] ==
'payment_vat') {
897 $bookkeeping->subledger_account =
'';
898 $bookkeeping->subledger_label =
'';
899 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
901 $accountingaccount->fetch(0, $k,
true);
902 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
904 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
906 $bookkeeping->numero_compte = $k;
907 $bookkeeping->label_compte = $accountingaccount->label;
908 } elseif ($tabtype[$key] ==
'payment_donation') {
909 $bookkeeping->subledger_account =
'';
910 $bookkeeping->subledger_label =
'';
911 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
913 $accountingaccount->fetch(0, $k,
true);
914 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
916 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
918 $bookkeeping->numero_compte = $k;
919 $bookkeeping->label_compte = $accountingaccount->label;
920 } elseif ($tabtype[$key] ==
'member') {
921 $bookkeeping->subledger_account =
'';
922 $bookkeeping->subledger_label =
'';
923 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
925 $accountingaccount->fetch(0, $k,
true);
926 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
928 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
930 $bookkeeping->numero_compte = $k;
931 $bookkeeping->label_compte = $accountingaccount->label;
932 } elseif ($tabtype[$key] ==
'payment_loan') {
933 $bookkeeping->subledger_account =
'';
934 $bookkeeping->subledger_label =
'';
935 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
937 $accountingaccount->fetch(0, $k,
true);
938 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
940 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
942 $bookkeeping->numero_compte = $k;
943 $bookkeeping->label_compte = $accountingaccount->label;
944 } elseif ($tabtype[$key] ==
'payment_various') {
945 $bookkeeping->subledger_account = $k;
946 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
947 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$tabpay[$key][
"account_various"]])) {
949 $accountingaccount->fetch(0, $tabpay[$key][
"account_various"],
true);
950 $conf->cache[
'accountingaccountincurrententity'][$tabpay[$key][
"account_various"]] = $accountingaccount;
952 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$tabpay[$key][
"account_various"]];
954 $bookkeeping->numero_compte = $tabpay[$key][
"account_various"];
955 $bookkeeping->label_compte = $accountingaccount->label;
956 } elseif ($tabtype[$key] ==
'banktransfert') {
957 $bookkeeping->subledger_account =
'';
958 $bookkeeping->subledger_label =
'';
959 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
961 $accountingaccount->fetch(0, $k,
true);
962 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
964 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
966 $bookkeeping->numero_compte = $k;
967 $bookkeeping->label_compte = $accountingaccount->label;
969 if ($tabtype[$key] ==
'unknown') {
971 $bookkeeping->subledger_account =
'';
972 $bookkeeping->subledger_label =
'';
974 $bookkeeping->label_compte = $accountingaccountsuspense->label;
977 $bookkeeping->label_operation = $reflabel;
978 $bookkeeping->entity =
$conf->entity;
980 $totaldebit += $bookkeeping->debit;
981 $totalcredit += $bookkeeping->credit;
983 $result = $bookkeeping->create($user);
985 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
988 setEventMessages(
'Transaction for ('.$bookkeeping->doc_type.
', '.$bookkeeping->fk_doc.
', '.$bookkeeping->fk_docdet.
') were already recorded',
null,
'warnings');
992 setEventMessages($bookkeeping->error, $bookkeeping->errors,
'errors');
996 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
998 $nb_lettering = $lettering_static->bookkeepingLetteringAll(array($bookkeeping->id));
1004 foreach ($tabbq[$key] as $k => $mt) {
1007 if (!empty($val[
'lib'])) {
1013 $bookkeeping->doc_date = $val[
"date"];
1014 $bookkeeping->doc_ref = $ref;
1015 $bookkeeping->doc_type =
'bank';
1016 $bookkeeping->fk_doc = (int) $key;
1017 $bookkeeping->fk_docdet = $val[
"fk_bank"];
1018 $bookkeeping->montant = $mt;
1019 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
1020 $bookkeeping->debit = ($mt < 0 ? -$mt : 0);
1021 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
1022 $bookkeeping->code_journal = $journal;
1023 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
1024 $bookkeeping->fk_user_author = $user->id;
1025 $bookkeeping->date_creation = $now;
1026 $bookkeeping->label_compte =
'';
1027 $bookkeeping->label_operation = $reflabel;
1028 $bookkeeping->entity =
$conf->entity;
1030 $totaldebit += $bookkeeping->debit;
1031 $totalcredit += $bookkeeping->credit;
1033 $result = $bookkeeping->create($user);
1036 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
1039 setEventMessages(
'Transaction for ('.$bookkeeping->doc_type.
', '.$bookkeeping->fk_doc.
', '.$bookkeeping->fk_docdet.
') were already recorded',
null,
'warnings');
1043 setEventMessages($bookkeeping->error, $bookkeeping->errors,
'errors');
1054 setEventMessages(
'We tried to insert a non balanced transaction in book for '.$ref.
'. Canceled. Surely a bug.',
null,
'errors');
1057 if (!$errorforline) {
1064 if ($error >= $MAXNBERRORS) {
1065 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped").
' (>'.$MAXNBERRORS.
')',
null,
'errors');
1071 if (empty($error) && count($tabpay) > 0) {
1072 setEventMessages($langs->trans(
"GeneralLedgerIsWritten"),
null,
'mesgs');
1073 } elseif (count($tabpay) == $error) {
1074 setEventMessages($langs->trans(
"NoNewRecordSaved"),
null,
'warnings');
1076 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
1082 if (count($tabpay) != $error) {
1083 $param =
'id_journal='.$id_journal;
1084 $param .=
'&date_startday='.$date_startday;
1085 $param .=
'&date_startmonth='.$date_startmonth;
1086 $param .=
'&date_startyear='.$date_startyear;
1087 $param .=
'&date_endday='.$date_endday;
1088 $param .=
'&date_endmonth='.$date_endmonth;
1089 $param .=
'&date_endyear='.$date_endyear;
1090 $param .=
'&in_bookkeeping='.$in_bookkeeping;
1091 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
1099if ($action ==
'exportcsv' && $user->hasRight(
'accounting',
'bind',
'write')) {
1102 $filename =
'journal';
1103 $type_export =
'journal';
1104 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
1107 print
'"'.$langs->transnoentitiesnoconv(
"BankId").
'"'.$sep;
1108 print
'"'.$langs->transnoentitiesnoconv(
"Date").
'"'.$sep;
1109 print
'"'.$langs->transnoentitiesnoconv(
"PaymentMode").
'"'.$sep;
1110 print
'"'.$langs->transnoentitiesnoconv(
"AccountAccounting").
'"'.$sep;
1111 print
'"'.$langs->transnoentitiesnoconv(
"SubledgerAccount").
'"'.$sep;
1112 print
'"'.$langs->transnoentitiesnoconv(
"Label").
'"'.$sep;
1113 print
'"'.$langs->transnoentitiesnoconv(
"AccountingDebit").
'"'.$sep;
1114 print
'"'.$langs->transnoentitiesnoconv(
"AccountingCredit").
'"'.$sep;
1115 print
'"'.$langs->transnoentitiesnoconv(
"Journal").
'"'.$sep;
1116 print
'"'.$langs->transnoentitiesnoconv(
"Note").
'"'.$sep;
1119 foreach ($tabpay as $key => $val) {
1125 foreach ($tabbq[$key] as $k => $mt) {
1128 if (!empty($val[
'lib'])) {
1132 if (!empty($val[
'soclib'])) {
1133 $reflabel .=
" / ".dol_string_nohtmltag($val[
'soclib']);
1136 print
'"'.$key.
'"'.$sep;
1137 print
'"'.$date.
'"'.$sep;
1138 print
'"'.$val[
"type_payment"].
'"'.$sep;
1139 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1141 print
'"'.$reflabel.
'"'.$sep;
1142 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1143 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1144 print
'"'.$journal.
'"'.$sep;
1145 print
'"'.dol_string_nohtmltag($ref).
'"'.$sep;
1151 if (is_array($tabtp[$key])) {
1152 foreach ($tabtp[$key] as $k => $mt) {
1155 if (!empty($val[
'lib'])) {
1158 if ($tabtype[$key] ==
'banktransfert') {
1159 $reflabel .=
dol_string_nohtmltag($langs->transnoentitiesnoconv(
'TransitionalAccount').
' '.$account_transfer);
1164 print
'"'.$key.
'"'.$sep;
1165 print
'"'.$date.
'"'.$sep;
1166 print
'"'.$val[
"type_payment"].
'"'.$sep;
1167 if ($tabtype[$key] ==
'payment_supplier') {
1168 $account_ledger = (!empty($obj->accountancy_code_supplier_general)) ? $obj->accountancy_code_supplier_general : $account_supplier;
1169 print
'"'.length_accountg($account_ledger).
'"'.$sep;
1170 } elseif ($tabtype[$key] ==
'payment') {
1171 $account_ledger = (!empty($obj->accountancy_code_customer_general)) ? $obj->accountancy_code_customer_general : $account_customer;
1172 print
'"'.length_accountg($account_ledger).
'"'.$sep;
1173 } elseif ($tabtype[$key] ==
'payment_expensereport') {
1174 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_EXPENSEREPORT')).
'"'.$sep;
1175 } elseif ($tabtype[$key] ==
'payment_salary') {
1176 $account_ledger = (!empty($obj->accountancy_code_user_general)) ? $obj->accountancy_code_user_general : $account_employee;
1177 print
'"'.length_accountg($account_ledger).
'"'.$sep;
1179 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1181 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
1182 print
'"'.$reflabel.
'"'.$sep;
1183 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1184 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1185 print
'"'.$journal.
'"'.$sep;
1186 print
'"'.dol_string_nohtmltag($ref).
'"'.$sep;
1191 foreach ($tabbq[$key] as $k => $mt) {
1194 if (!empty($val[
'lib'])) {
1199 print
'"'.$key.
'"'.$sep;
1200 print
'"'.$date.
'"'.$sep;
1201 print
'"'.$val[
"type_payment"].
'"'.$sep;
1202 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUSPENSE')).
'"'.$sep;
1204 print
'"'.$reflabel.
'"'.$sep;
1205 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1206 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1207 print
'"'.$journal.
'"'.$sep;
1208 print
'"'.dol_string_nohtmltag($ref).
'"'.$sep;
1221$form =
new Form($db);
1223if (empty($action) || $action ==
'view') {
1224 $invoicestatic =
new Facture($db);
1227 $vatstatic =
new Tva($db);
1228 $donationstatic =
new Don($db);
1229 $loanstatic =
new Loan($db);
1230 $salarystatic =
new Salary($db);
1233 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
1234 $help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité';
1240 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
1242 $listofchoices = array(
1243 'notyet' => $langs->trans(
"NotYetInGeneralLedger"),
1244 'already' => $langs->trans(
"AlreadyInGeneralLedger")
1246 $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);
1247 $period .=
'<span class="valignmiddle"> - '.$langs->trans(
"JournalizationInLedgerStatus").
' </span>'.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1, 0, 0,
'', 0, 0, 0,
'',
'minwidth75 valignmiddle');
1249 $varlink =
'id_journal='.$id_journal;
1253 $listofchoices = array(
1254 1 => $langs->trans(
"TransfertAllBankLines"),
1255 2 => $langs->trans(
"TransfertOnlyConciliatedBankLine")
1257 $moreoptions = [
"BankLineConciliated" => $form->selectarray(
'only_rappro', $listofchoices, $only_rappro, 0, 0, 0,
'', 0, 0, 0,
'',
'minwidth75 valignmiddle')];
1259 journalHead($nom,
'', $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink, $moreoptions);
1266 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int)
$conf->entity);
1267 $resql = $db->query($sql);
1269 $obj = $db->fetch_object($resql);
1270 if ($obj->nb == 0) {
1271 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
1272 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
1273 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
1278 dol_print_error($db);
1283 $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";
1284 $resql = $db->query($sql);
1286 $obj = $db->fetch_object($resql);
1288 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheJournalCodeIsNotDefinedOnSomeBankAccount");
1289 $desc =
' : '.$langs->trans(
"AccountancyAreaDescBank", 6,
'{link}');
1290 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"BankAccounts").
'</strong>', $desc);
1295 dol_print_error($db);
1306 print($desc ?
'' :
'<br>').
'<div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
1307 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
1308 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
1314 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
1316 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
1317 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
1322 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
1324 if ($in_bookkeeping ==
'notyet') {
1325 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
1327 print
'<a class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
1335 <script type="text/javascript">
1336 function launch_export() {
1337 console.log("Set value into form and submit");
1338 $("div.fiche form input[name=\"action\"]").val("exportcsv");
1339 $("div.fiche form input[type=\"submit\"]").click();
1340 $("div.fiche form input[name=\"action\"]").val("");
1342 function writebookkeeping() {
1343 console.log("Set value into form and submit");
1344 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
1345 $("div.fiche form input[type=\"submit\"]").click();
1346 $("div.fiche form input[name=\"action\"]").val("");
1356 print
'<div class="div-table-responsive">';
1357 print
'<table class="noborder centpercent">';
1358 print
'<tr class="liste_titre">';
1359 print
"<td>".$langs->trans(
"Date").
"</td>";
1360 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"ObjectsRef").
")</td>";
1361 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
1362 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
1363 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
1364 print
'<td class="center">'.$langs->trans(
"PaymentMode").
"</td>";
1365 print
'<td class="right">'.$langs->trans(
"AccountingDebit").
"</td>";
1366 print
'<td class="right">'.$langs->trans(
"AccountingCredit").
"</td>";
1369 foreach ($tabpay as $key => $val) {
1375 foreach ($tabbq[$key] as $k => $mt) {
1378 if (!empty($val[
'lib'])) {
1379 $reflabel .= $val[
'lib'].
" / ";
1381 $reflabel .= $langs->trans(
"Bank").
' '.$val[
'bank_account_ref'];
1382 if (!empty($val[
'soclib'])) {
1383 $reflabel .=
" / ".$val[
'soclib'];
1387 print
'<!-- Bank bank.rowid='.$key.
'=accounting_bookkeeping.fk_doc (accounting_bookkeeping.doc_type=\'bank\') type='.$tabpay[$key][
'type'].
' ref='.$tabpay[$key][
'ref'].
' -->';
1388 print
'<tr class="oddeven">';
1391 print
"<td>".$date.
"</td>";
1394 print
'<td class="maxwidth300 nopaddingtopimp nopaddingbottomimp">'.dol_escape_htmltag($ref).
"</td>";
1398 if (empty($accounttoshow) || $accounttoshow ==
'NotDefined') {
1399 $accounttoshow =
'<span class="error">'.$langs->trans(
"BankAccountNotDefined").
'</span>';
1401 print
'<td class="maxwidth300" title="'.dol_escape_htmltag(
dol_string_nohtmltag($accounttoshow)).
'">';
1402 print $accounttoshow;
1406 print
'<td class="maxwidth300">';
1416 print
'<td class="maxwidth300 nopaddingtopimp nopaddingbottomimp">';
1420 print
'<td class="center">'.$val[
"type_payment"].
"</td>";
1421 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1422 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1430 if (is_array($tabtp[$key])) {
1431 foreach ($tabtp[$key] as $k => $mt) {
1434 if (!empty($val[
'lib'])) {
1435 $reflabel .= $val[
'lib'].(!empty($val[
'soclib']) ?
" / " :
"");
1437 if ($tabtype[$key] ==
'banktransfert') {
1438 $reflabel .= $langs->trans(
'TransitionalAccount').
' '.$account_transfer;
1440 $reflabel .= isset($val[
'soclib']) ? $val[
'soclib'] :
"";
1443 print
'<!-- Thirdparty bank.rowid='.$key.
'=accounting_bookkeeping.fk_doc (accounting_bookkeeping.doc_type=\'bank\') type='.$tabpay[$key][
'type'].
' ref='.$tabpay[$key][
'ref'].
' -->';
1444 print
'<tr class="oddeven">';
1447 print
"<td>".$date.
"</td>";
1450 print
'<td class="nopaddingtopimp nopaddingbottomimp">'.dol_escape_htmltag($ref).
"</td>";
1454 $account_ledger = $k;
1456 if ($tabtype[$key] ==
'payment') {
1457 $account_ledger = (!empty($obj->accountancy_code_customer_general)) ? $obj->accountancy_code_customer_general : $account_customer;
1459 if ($tabtype[$key] ==
'payment_supplier') {
1460 $account_ledger = (!empty($obj->accountancy_code_supplier_general)) ? $obj->accountancy_code_supplier_general : $account_supplier;
1462 if ($tabtype[$key] ==
'payment_expensereport') {
1465 if ($tabtype[$key] ==
'payment_salary') {
1466 $account_ledger = (!empty($obj->accountancy_code_user_general)) ? $obj->accountancy_code_user_general : $account_employee;
1468 if ($tabtype[$key] ==
'payment_vat') {
1471 if ($tabtype[$key] ==
'member') {
1474 if ($tabtype[$key] ==
'payment_various') {
1475 $account_ledger = $tabpay[$key][
"account_various"];
1478 if (empty($accounttoshow) || $accounttoshow ==
'NotDefined') {
1479 if ($tabtype[$key] ==
'unknown') {
1482 $accounttoshow =
'<span class="error small">'.$langs->trans(
'UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').
'</span>';
1484 $accounttoshow =
'<span class="warning small">'.$langs->trans(
'UnknownAccountForThirdparty',
length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUSPENSE'))).
'</span>';
1488 $errorstring =
'UnknownAccountForThirdpartyBlocking';
1489 if ($tabtype[$key] ==
'payment') {
1490 $errorstring =
'MainAccountForCustomersNotDefined';
1492 if ($tabtype[$key] ==
'payment_supplier') {
1493 $errorstring =
'MainAccountForSuppliersNotDefined';
1495 if ($tabtype[$key] ==
'payment_expensereport') {
1496 $errorstring =
'MainAccountForUsersNotDefined';
1498 if ($tabtype[$key] ==
'payment_salary') {
1499 $errorstring =
'MainAccountForUsersNotDefined';
1501 if ($tabtype[$key] ==
'payment_vat') {
1502 $errorstring =
'MainAccountForVatPaymentNotDefined';
1504 if ($tabtype[$key] ==
'member') {
1505 $errorstring =
'MainAccountForSubscriptionPaymentNotDefined';
1507 $accounttoshow =
'<span class="error small">'.$langs->trans($errorstring).
'</span>';
1510 print
'<td class="maxwidth300" title="'.dol_escape_htmltag(
dol_string_nohtmltag($accounttoshow)).
'">';
1511 print $accounttoshow;
1515 $accounttoshowsubledger =
'';
1516 if (in_array($tabtype[$key], array(
'payment',
'payment_supplier',
'payment_expensereport',
'payment_salary',
'payment_various'))) {
1518 if ($accounttoshow != $accounttoshowsubledger) {
1519 if (empty($accounttoshowsubledger) || $accounttoshowsubledger ==
'NotDefined') {
1521 if (!empty($tabcompany[$key][
'code_compta'])) {
1522 if (in_array($tabtype[$key], array(
'payment_various'))) {
1524 $accounttoshowsubledger =
'<span class="warning small twolinesmax">'.$langs->trans(
"ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").
'</span>';
1525 } elseif (in_array($tabtype[$key], array(
'payment_salary'))) {
1526 $accounttoshowsubledger =
'<span class="warning small twolinesmax">'.$langs->trans(
"ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored2").
'</span>';
1528 $accounttoshowsubledger =
'<span class="warning small twolinesmax">'.$langs->trans(
"ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key][
'code_compta']).
'</span>';
1531 $accounttoshowsubledger =
'<span class="error small twolinesmax">'.$langs->trans(
"ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").
'</span>';
1535 $accounttoshowsubledger =
'';
1538 print
'<td class="maxwidth300 nopaddingtopimp nopaddingbottomimp" title="'.dolPrintHTMLForAttribute(
dol_string_nohtmltag($accounttoshowsubledger)).
'">';
1539 print $accounttoshowsubledger;
1543 print
'<td class="nopaddingtopimpo paddingbottomimp">';
1547 print
'<td class="center">'.$val[
"type_payment"].
"</td>";
1549 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1551 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1559 foreach ($tabbq[$key] as $k => $mt) {
1562 if (!empty($val[
'lib'])) {
1563 $reflabel .= $val[
'lib'].
" / ";
1565 $reflabel .=
'WaitingAccount';
1567 print
'<!-- Wait bank.rowid='.$key.
' -->';
1568 print
'<tr class="oddeven">';
1569 print
"<td>".$date.
"</td>";
1570 print
"<td>".$ref.
"</td>";
1583 print
"<td>".dol_escape_htmltag($reflabel).
"</td>";
1584 print
'<td class="center">'.$val[
"type_payment"].
"</td>";
1585 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1586 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1597 print
'<tr class="oddeven"><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1624 if ($ref ==
'(SupplierInvoicePayment)' || $ref ==
'(SupplierInvoicePaymentBack)') {
1625 $ref = $langs->transnoentitiesnoconv(
'Supplier');
1627 if ($ref ==
'(CustomerInvoicePayment)' || $ref ==
'(CustomerInvoicePaymentBack)') {
1628 $ref = $langs->transnoentitiesnoconv(
'Customer');
1630 if ($ref ==
'(SocialContributionPayment)') {
1631 $ref = $langs->transnoentitiesnoconv(
'SocialContribution');
1633 if ($ref ==
'(DonationPayment)') {
1634 $ref = $langs->transnoentitiesnoconv(
'Donation');
1636 if ($ref ==
'(SubscriptionPayment)') {
1637 $ref = $langs->transnoentitiesnoconv(
'Subscription');
1639 if ($ref ==
'(ExpenseReportPayment)') {
1640 $ref = $langs->transnoentitiesnoconv(
'Employee');
1642 if ($ref ==
'(LoanPayment)') {
1643 $ref = $langs->transnoentitiesnoconv(
'Loan');
1645 if ($ref ==
'(payment_salary)') {
1646 $ref = $langs->transnoentitiesnoconv(
'Employee');
1650 if ($typerecord ==
'payment') {
1652 $sqlmid =
"SELECT payfac.fk_facture as id, ".$db->ifsql(
'f1.rowid IS NULL',
'f.ref',
'f1.ref').
" as ref";
1653 $sqlmid .=
" FROM ".$db->prefix().
"paiement_facture as payfac";
1654 $sqlmid .=
" LEFT JOIN ".$db->prefix().
"facture as f ON f.rowid = payfac.fk_facture";
1655 $sqlmid .=
" LEFT JOIN ".$db->prefix().
"societe_remise_except as sre ON sre.fk_facture_source = payfac.fk_facture";
1656 $sqlmid .=
" LEFT JOIN ".$db->prefix().
"facture as f1 ON f1.rowid = sre.fk_facture";
1657 $sqlmid .=
" WHERE payfac.fk_paiement=".((int) $val[
'paymentid']);
1659 $sqlmid =
"SELECT payfac.fk_facture as id, f.ref as ref";
1660 $sqlmid .=
" FROM ".$db->prefix().
"paiement_facture as payfac";
1661 $sqlmid .=
" INNER JOIN ".$db->prefix().
"facture as f ON f.rowid = payfac.fk_facture";
1662 $sqlmid .=
" WHERE payfac.fk_paiement=".((int) $val[
'paymentid']);
1664 $ref = $langs->transnoentitiesnoconv(
"Invoice");
1665 } elseif ($typerecord ==
'payment_supplier') {
1666 $sqlmid =
'SELECT payfac.fk_facturefourn as id, f.ref';
1667 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX.
"facture_fourn as f";
1668 $sqlmid .=
" WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=".((int) $val[
"paymentsupplierid"]);
1669 $ref = $langs->transnoentitiesnoconv(
"SupplierInvoice");
1670 } elseif ($typerecord ==
'payment_expensereport') {
1671 $sqlmid =
'SELECT e.rowid as id, e.ref';
1672 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"payment_expensereport as pe, ".MAIN_DB_PREFIX.
"expensereport as e";
1673 $sqlmid .=
" WHERE pe.rowid=".((int) $val[
"paymentexpensereport"]).
" AND pe.fk_expensereport = e.rowid";
1674 $ref = $langs->transnoentitiesnoconv(
"ExpenseReport");
1675 } elseif ($typerecord ==
'payment_salary') {
1676 $sqlmid =
'SELECT s.rowid as ref';
1677 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary as s";
1678 $sqlmid .=
" WHERE s.rowid=".((int) $val[
"paymentsalid"]);
1679 $ref = $langs->transnoentitiesnoconv(
"SalaryPayment");
1680 } elseif ($typerecord ==
'sc') {
1681 $sqlmid =
'SELECT sc.rowid as ref';
1682 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"paiementcharge as sc";
1683 $sqlmid .=
" WHERE sc.rowid=".((int) $val[
"paymentscid"]);
1684 $ref = $langs->transnoentitiesnoconv(
"SocialContribution");
1685 } elseif ($typerecord ==
'payment_vat') {
1686 $sqlmid =
'SELECT pv.fk_tva as ref';
1687 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"payment_vat as pv";
1688 $sqlmid .=
" WHERE pv.rowid=".((int) $val[
"paymentvatid"]);
1689 $ref = $langs->transnoentitiesnoconv(
"PaymentVat");
1690 } elseif ($typerecord ==
'payment_donation') {
1691 $sqlmid =
'SELECT payd.fk_donation as ref';
1692 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"payment_donation as payd";
1693 $sqlmid .=
" WHERE payd.fk_donation=".((int) $val[
"paymentdonationid"]);
1694 $ref = $langs->transnoentitiesnoconv(
"Donation");
1695 } elseif ($typerecord ==
'payment_loan') {
1696 $sqlmid =
'SELECT l.rowid as ref';
1697 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"payment_loan as l";
1698 $sqlmid .=
" WHERE l.rowid=".((int) $val[
"paymentloanid"]);
1699 $ref = $langs->transnoentitiesnoconv(
"LoanPayment");
1700 } elseif ($typerecord ==
'payment_various') {
1701 $sqlmid =
'SELECT v.rowid as ref';
1702 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"payment_various as v";
1703 $sqlmid .=
" WHERE v.rowid=".((int) $val[
"paymentvariousid"]);
1704 $ref = $langs->transnoentitiesnoconv(
"VariousPayment");
1707 if (empty($sqlmid)) {
1708 dol_syslog(
"Found a typerecord=".$typerecord.
" not supported", LOG_WARNING);
1712 dol_syslog(
"accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG);
1713 $resultmid = $db->query($sqlmid);
1715 while ($objmid = $db->fetch_object($resultmid)) {
1716 $ref .=
' '.$objmid->ref;
1719 dol_print_error($db);
1723 $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)
getSubledgerAccountWithDefault($thirdpartyCode, $type='customer')
Return the subledger account to use for a thirdparty.
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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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)
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.
$date_start
Variables from include:
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...
price2num($amount, $rounding='', $option=0, $currencycode='')
Function that return a number with universal decimal format (decimal separator is '.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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_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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.