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';
104if (!isModEnabled(
'accounting')) {
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))) {
147$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,";
148$sql .=
" ba.courant, ba.ref as baref, ba.account_number, ba.fk_accountancy_journal,";
149$sql .=
" soc.rowid as socid, soc.nom as name, soc.email as email, bu1.type as typeop_company,";
151 $sql .=
" spe.accountancy_code_customer_general,";
152 $sql .=
" spe.accountancy_code_customer as code_compta_client,";
153 $sql .=
" spe.accountancy_code_supplier_general,";
154 $sql .=
" spe.accountancy_code_supplier as code_compta_fournisseur,";
156 $sql .=
" soc.accountancy_code_customer_general,";
157 $sql .=
" soc.code_compta as code_compta_client,";
158 $sql .=
" soc.accountancy_code_supplier_general,";
159 $sql .=
" soc.code_compta_fournisseur,";
161$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,";
162$sql .=
" bu2.type as typeop_user,";
163$sql .=
" bu3.type as typeop_payment, bu4.type as typeop_payment_supplier";
164$sql .=
" FROM ".MAIN_DB_PREFIX.
"bank as b";
165$sql .=
" JOIN ".MAIN_DB_PREFIX.
"bank_account as ba on b.fk_account=ba.rowid";
166$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_url as bu1 ON bu1.fk_bank = b.rowid AND bu1.type='company'";
167$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_url as bu2 ON bu2.fk_bank = b.rowid AND bu2.type='user'";
168$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_url as bu3 ON bu3.fk_bank = b.rowid AND bu3.type='payment'";
169$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"bank_url as bu4 ON bu4.fk_bank = b.rowid AND bu4.type='payment_supplier'";
170$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"societe as soc on bu1.url_id=soc.rowid";
172 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = soc.rowid AND spe.entity = " . ((int)
$conf->entity);
174$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u on bu2.url_id=u.rowid";
175$sql .=
" WHERE ba.fk_accountancy_journal=".((int) $id_journal);
176$sql .=
' AND b.amount <> 0 AND ba.entity IN ('.getEntity(
'bank_account', 0).
')';
177if ($date_start && $date_end) {
178 $sql .=
" AND b.dateo >= '".$db->idate($date_start).
"' AND b.dateo <= '".$db->idate($date_end).
"'";
182 $sql .=
" AND b.dateo >= '".$db->idate(
getDolGlobalInt(
'ACCOUNTING_DATE_START_BINDING')).
"'";
185if ($in_bookkeeping ==
'already') {
186 $sql .=
" AND (b.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='bank') )";
188if ($in_bookkeeping ==
'notyet') {
189 $sql .=
" AND (b.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='bank') )";
191if ($only_rappro == 2) {
192 $sql .=
" AND (b.rappro = '1')";
194$sql .=
" ORDER BY b.datev";
200$societestatic =
new Societe($db);
201$userstatic =
new User($db);
202$bankaccountstatic =
new Account($db);
205$paymentvatstatic =
new Tva($db);
217$account_transfer =
'NotDefined';
221$accountingjournalstatic->fetch($id_journal);
222$journal = $accountingjournalstatic->code;
223$journal_label = $accountingjournalstatic->label;
225$tabcompany = array();
231$tabmoreinfo = array();
234@phan-var-force array<array{id:mixed,name:mixed,code_compta_client:string,email:string}> $tabcompany
235@phan-var-force array<array{id:int,name:string,lastname:string,firstname:string,email:string,accountancy_code:string,status:int> $tabuser
236@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
237@phan-var-force array<array{lib:string,date?:int|string,type_payment?:string,ref?:string,fk_bank?:int,ban_account_ref?:string,fk_bank_account?:int,type?:string,bank_account_ref?:string,paymentid?:int,paymentsupplierid?:int,soclib?:string,paymentscid?:int,paymentdonationid?:int,paymentsubscriptionid?:int,paymentvatid?:int,paymentsalid?:int,paymentexpensereport?:int,paymentvariousid?:int,account_various?:string,paymentloanid?:int}> $tabtp
240$account_customer =
'NotDefined';
241$account_supplier =
'NotDefined';
242$account_employee =
'NotDefined';
245dol_syslog(
"accountancy/journal/bankjournal.php", LOG_DEBUG);
246$result = $db->query($sql);
248 $num = $db->num_rows($result);
254 $account_employee =
getDolGlobalString(
'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT',
'NotDefined');
255 $account_expensereport =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_EXPENSEREPORT',
'NotDefined');
257 $account_pay_donation =
getDolGlobalString(
'DONATION_ACCOUNTINGACCOUNT',
'NotDefined');
258 $account_pay_subscription =
getDolGlobalString(
'ADHERENT_SUBSCRIPTION_ACCOUNTINGACCOUNT',
'NotDefined');
259 $account_transfer =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_TRANSFER_CASH',
'NotDefined');
268 $obj = $db->fetch_object($result);
270 $lineisapurchase = -1;
273 if ($obj->label ==
'(SupplierInvoicePayment)' || $obj->label ==
'(SupplierInvoicePaymentBack)') {
274 $lineisapurchase = 1;
276 if ($obj->label ==
'(CustomerInvoicePayment)' || $obj->label ==
'(CustomerInvoicePaymentBack)') {
280 if ($lineisapurchase < 0) {
281 if ($obj->typeop_payment_supplier ==
'payment_supplier') {
282 $lineisapurchase = 1;
285 if ($lineisasale < 0) {
286 if ($obj->typeop_payment ==
'payment') {
294 $compta_bank = $obj->account_number;
297 $compta_soc =
'NotDefined';
298 $accountancy_code_general =
'NotDefined';
299 if ($lineisapurchase > 0) {
300 $accountancy_code_general = (!empty($obj->accountancy_code_supplier_general) && $obj->accountancy_code_supplier_general !=
'-1') ? $obj->accountancy_code_supplier_general : $account_supplier;
301 $compta_soc = (($obj->code_compta_fournisseur !=
"") ? $obj->code_compta_fournisseur : $account_supplier);
303 if ($lineisasale > 0) {
304 $accountancy_code_general = (!empty($obj->accountancy_code_customer_general) && $obj->accountancy_code_customer_general !=
'-1') ? $obj->accountancy_code_customer_general : $account_customer;
305 $compta_soc = (!empty($obj->code_compta_client) ? $obj->code_compta_client : $account_customer);
308 $tabcompany[$obj->rowid] = array(
310 'name' => $obj->name,
311 'code_compta' => $compta_soc,
312 'accountancy_code_general' => $accountancy_code_general,
313 'email' => $obj->email
319 $accountancy_code_user_general = (!empty($obj->accountancy_code_user_general)) ? $obj->accountancy_code_user_general : $account_employee;
320 $compta_user = (!empty($obj->accountancy_code) ? $obj->accountancy_code :
'');
322 $tabuser[$obj->rowid] = array(
323 'id' => $obj->userid,
325 'lastname' => $obj->lastname,
326 'firstname' => $obj->firstname,
327 'email' => $obj->useremail,
328 'accountancy_code_general' => $accountancy_code_user_general,
329 'accountancy_code' => $compta_user,
330 'status' => $obj->userstatus
334 $tabpay[$obj->rowid][
"date"] = $db->jdate($obj->do);
335 $tabpay[$obj->rowid][
"type_payment"] = $obj->fk_type;
336 $tabpay[$obj->rowid][
"ref"] = $obj->label;
337 $tabpay[$obj->rowid][
"fk_bank"] = $obj->rowid;
338 $tabpay[$obj->rowid][
"bank_account_ref"] = $obj->baref;
339 $tabpay[$obj->rowid][
"fk_bank_account"] = $obj->fk_account;
341 if (preg_match(
'/^\((.*)\)$/i', $obj->label, $reg)) {
342 $tabpay[$obj->rowid][
"lib"] = $langs->trans($reg[1]);
344 $tabpay[$obj->rowid][
"lib"] =
dol_trunc($obj->label, 60);
348 $links =
$object->get_url($obj->rowid);
353 $tabpay[$obj->rowid][
'type'] =
'unknown';
354 $tabtype[$obj->rowid] =
'unknown';
355 $tabmoreinfo[$obj->rowid] = array();
357 $amounttouse = $obj->amount;
358 if (!empty($obj->amount_main_currency)) {
360 $amounttouse = $obj->amount_main_currency;
364 if (is_array($links) && count($links) > 0) {
369 $is_expensereport =
false;
370 foreach ($links as $v) {
371 if ($v[
'type'] ==
'sc') {
375 if ($v[
'type'] ==
'payment_salary') {
379 if ($v[
'type'] ==
'payment_expensereport') {
380 $is_expensereport =
true;
386 foreach ($links as $key => $val) {
387 if ($links[$key][
'type'] ==
'user' && !$is_sc && !$is_salary && !$is_expensereport) {
392 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'))) {
396 $tabpay[$obj->rowid][
'type'] = $links[$key][
'type'];
397 $tabtype[$obj->rowid] = $links[$key][
'type'];
408 if ($links[$key][
'type'] ==
'withdraw') {
409 $tabmoreinfo[$obj->rowid][
'withdraw'] = 1;
412 if ($links[$key][
'type'] ==
'payment') {
413 $paymentstatic->id = $links[$key][
'url_id'];
414 $paymentstatic->ref = (string) $links[$key][
'url_id'];
415 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentstatic->getNomUrl(2,
'',
'');
416 $tabpay[$obj->rowid][
"paymentid"] = $paymentstatic->id;
417 } elseif ($links[$key][
'type'] ==
'payment_supplier') {
418 $paymentsupplierstatic->id = $links[$key][
'url_id'];
419 $paymentsupplierstatic->ref = (string) $links[$key][
'url_id'];
420 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentsupplierstatic->getNomUrl(2);
421 $tabpay[$obj->rowid][
"paymentsupplierid"] = $paymentsupplierstatic->id;
422 } elseif ($links[$key][
'type'] ==
'company') {
423 $societestatic->id = $links[$key][
'url_id'];
424 $societestatic->name = $links[$key][
'label'];
425 $societestatic->email = $tabcompany[$obj->rowid][
'email'];
426 $tabpay[$obj->rowid][
"soclib"] = $societestatic->getNomUrl(1,
'', 30);
428 if (empty($tabtp[$obj->rowid][$compta_soc])) {
429 $tabtp[$obj->rowid][$compta_soc] = $amounttouse;
431 $tabtp[$obj->rowid][$compta_soc] += $amounttouse;
434 } elseif ($links[$key][
'type'] ==
'user') {
435 $userstatic->id = $links[$key][
'url_id'];
436 $userstatic->name = $links[$key][
'label'];
437 $userstatic->email = $tabuser[$obj->rowid][
'email'];
438 $userstatic->firstname = $tabuser[$obj->rowid][
'firstname'];
439 $userstatic->lastname = $tabuser[$obj->rowid][
'lastname'];
440 $userstatic->status = $tabuser[$obj->rowid][
'status'];
441 $userstatic->accountancy_code_user_general = $tabuser[$obj->rowid][
'accountancy_code_general'];
442 $userstatic->accountancy_code = $tabuser[$obj->rowid][
'accountancy_code'];
447 if ($userstatic->id > 0) {
449 $tabpay[$obj->rowid][
"soclib"] .=
' '.$userstatic->getNomUrl(-1,
'accountancy', 0);
451 $tabpay[$obj->rowid][
"soclib"] = $userstatic->getNomUrl(-1,
'accountancy', 0);
454 $tabpay[$obj->rowid][
"soclib"] =
'???';
461 $tabtp[$obj->rowid][$compta_user] += $amounttouse;
464 } elseif ($links[$key][
'type'] ==
'sc') {
465 $chargestatic->id = $links[$key][
'url_id'];
466 $chargestatic->ref = (string) $links[$key][
'url_id'];
468 $tabpay[$obj->rowid][
"lib"] .=
' '.$chargestatic->getNomUrl(2);
470 if (preg_match(
'/^\((.*)\)$/i', $links[$key][
'label'], $reg)) {
471 if ($reg[1] ==
'socialcontribution') {
472 $reg[1] =
'SocialContribution';
474 $chargestatic->label = $langs->trans($reg[1]);
476 $chargestatic->label = $links[$key][
'label'];
478 $chargestatic->ref = $chargestatic->label;
497 $resultmid = $tmpcharge->fetch($chargestatic->id);
499 $chargestatic->type_label = $tmpcharge->type_label;
500 $chargestatic->type_code = $tmpcharge->type_code;
501 $chargestatic->type_accountancy_code = $tmpcharge->type_accountancy_code;
503 $tabtp[$obj->rowid][$tmpcharge->type_accountancy_code] = isset($tabtp[$obj->rowid][$tmpcharge->type_accountancy_code]) ? $tabtp[$obj->rowid][$tmpcharge->type_accountancy_code] + $amounttouse : $amounttouse;
506 $tabpay[$obj->rowid][
"soclib"] = $chargestatic->getNomUrl(1, 30);
507 $tabpay[$obj->rowid][
"paymentscid"] = $chargestatic->id;
508 } elseif ($links[$key][
'type'] ==
'payment_donation') {
509 $paymentdonstatic->id = $links[$key][
'url_id'];
510 $paymentdonstatic->ref = (string) $links[$key][
'url_id'];
511 $paymentdonstatic->fk_donation = $links[$key][
'url_id'];
512 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentdonstatic->getNomUrl(2);
513 $tabpay[$obj->rowid][
"paymentdonationid"] = $paymentdonstatic->id;
514 $tabtp[$obj->rowid][$account_pay_donation] = isset($tabtp[$obj->rowid][$account_pay_donation]) ? $tabtp[$obj->rowid][$account_pay_donation] + $amounttouse : $amounttouse;
515 } elseif ($links[$key][
'type'] ==
'member') {
516 $paymentsubscriptionstatic->id = $links[$key][
'url_id'];
517 $paymentsubscriptionstatic->ref = (string) $links[$key][
'url_id'];
518 $paymentsubscriptionstatic->label = $links[$key][
'label'];
519 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentsubscriptionstatic->getNomUrl(2);
520 $tabpay[$obj->rowid][
"paymentsubscriptionid"] = $paymentsubscriptionstatic->id;
521 $paymentsubscriptionstatic->fetch($paymentsubscriptionstatic->id);
522 $tabtp[$obj->rowid][$account_pay_subscription] = isset($tabtp[$obj->rowid][$account_pay_subscription]) ? $tabtp[$obj->rowid][$account_pay_subscription] + $amounttouse : $amounttouse;
523 } elseif ($links[$key][
'type'] ==
'payment_vat') {
524 $paymentvatstatic->id = $links[$key][
'url_id'];
525 $paymentvatstatic->ref = (string) $links[$key][
'url_id'];
526 $paymentvatstatic->label = $links[$key][
'label'];
527 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentvatstatic->getNomUrl(2);
528 $tabpay[$obj->rowid][
"paymentvatid"] = $paymentvatstatic->id;
529 $tabtp[$obj->rowid][$account_pay_vat] = isset($tabtp[$obj->rowid][$account_pay_vat]) ? $tabtp[$obj->rowid][$account_pay_vat] + $amounttouse : $amounttouse;
530 } elseif ($links[$key][
'type'] ==
'payment_salary') {
531 $paymentsalstatic->id = $links[$key][
'url_id'];
532 $paymentsalstatic->ref = (string) $links[$key][
'url_id'];
533 $paymentsalstatic->label = $links[$key][
'label'];
534 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentsalstatic->getNomUrl(2);
535 $tabpay[$obj->rowid][
"paymentsalid"] = $paymentsalstatic->id;
539 if (
getDolGlobalString(
'ACCOUNTANCY_AUTOFIX_MISSING_LINK_TO_USER_ON_SALARY_BANK_PAYMENT')) {
540 $tmpsalary =
new Salary($db);
541 $tmpsalary->fetch($paymentsalstatic->id);
542 $tmpsalary->fetch_user($tmpsalary->fk_user);
544 $userstatic->id = $tmpsalary->user->id;
545 $userstatic->name = $tmpsalary->user->name;
546 $userstatic->email = $tmpsalary->user->email;
547 $userstatic->firstname = $tmpsalary->user->firstname;
548 $userstatic->lastname = $tmpsalary->user->lastname;
549 $userstatic->status = $tmpsalary->user->status;
550 $userstatic->accountancy_code = $tmpsalary->user->accountancy_code;
552 if ($userstatic->id > 0) {
553 $tabpay[$obj->rowid][
"soclib"] = $userstatic->getNomUrl(1,
'accountancy', 0);
555 $tabpay[$obj->rowid][
"soclib"] =
'???';
558 if (empty($obj->typeop_user)) {
559 $accountancy_code_user_general = (!empty($obj->accountancy_code_user_general)) ? $obj->accountancy_code_user_general : $account_employee;
560 $compta_user = $userstatic->accountancy_code;
562 $tabtp[$obj->rowid][$compta_user] += $amounttouse;
563 $tabuser[$obj->rowid] = array(
564 'id' => $userstatic->id,
566 'lastname' => $userstatic->lastname,
567 'firstname' => $userstatic->firstname,
568 'email' => $userstatic->email,
569 'accountancy_code_general' => $accountancy_code_user_general,
570 'accountancy_code' => $compta_user,
571 'status' => $userstatic->status
576 } elseif ($links[$key][
'type'] ==
'payment_expensereport') {
577 $paymentexpensereportstatic->id = $links[$key][
'url_id'];
578 $tabpay[$obj->rowid][
"lib"] .= $paymentexpensereportstatic->getNomUrl(2);
579 $tabpay[$obj->rowid][
"paymentexpensereport"] = $paymentexpensereportstatic->id;
580 } elseif ($links[$key][
'type'] ==
'payment_various') {
581 $paymentvariousstatic->id = $links[$key][
'url_id'];
582 $paymentvariousstatic->ref = (string) $links[$key][
'url_id'];
583 $paymentvariousstatic->label = $links[$key][
'label'];
584 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentvariousstatic->getNomUrl(2);
585 $tabpay[$obj->rowid][
"paymentvariousid"] = $paymentvariousstatic->id;
586 $paymentvariousstatic->fetch($paymentvariousstatic->id);
587 $account_various = (!empty($paymentvariousstatic->accountancy_code) ? $paymentvariousstatic->accountancy_code :
'NotDefined');
588 $account_subledger = (!empty($paymentvariousstatic->subledger_account) ? $paymentvariousstatic->subledger_account :
'');
589 $tabpay[$obj->rowid][
"account_various"] = $account_various;
590 $tabtp[$obj->rowid][$account_subledger] = isset($tabtp[$obj->rowid][$account_subledger]) ? $tabtp[$obj->rowid][$account_subledger] + $amounttouse : $amounttouse;
591 } elseif ($links[$key][
'type'] ==
'payment_loan') {
592 $paymentloanstatic->id = $links[$key][
'url_id'];
593 $paymentloanstatic->ref = (string) $links[$key][
'url_id'];
594 $paymentloanstatic->fk_loan = $links[$key][
'url_id'];
595 $tabpay[$obj->rowid][
"lib"] .=
' '.$paymentloanstatic->getNomUrl(2);
596 $tabpay[$obj->rowid][
"paymentloanid"] = $paymentloanstatic->id;
598 $sqlmid =
'SELECT pl.amount_capital, pl.amount_insurance, pl.amount_interest, l.accountancy_account_capital, l.accountancy_account_insurance, l.accountancy_account_interest';
599 $sqlmid .=
' FROM '.MAIN_DB_PREFIX.
'payment_loan as pl, '.MAIN_DB_PREFIX.
'loan as l';
600 $sqlmid .=
' WHERE l.rowid = pl.fk_loan AND pl.fk_bank = '.((int) $obj->rowid);
602 dol_syslog(
"accountancy/journal/bankjournal.php:: sqlmid=".$sqlmid, LOG_DEBUG);
603 $resultmid = $db->query($sqlmid);
605 $objmid = $db->fetch_object($resultmid);
606 $tabtp[$obj->rowid][$objmid->accountancy_account_capital] = isset($objmid->amount_capital) ? $tabtp[$obj->rowid][$objmid->accountancy_account_capital] - $objmid->amount_capital : 0;
607 $tabtp[$obj->rowid][$objmid->accountancy_account_insurance] = isset($objmid->amount_insurance) ? $tabtp[$obj->rowid][$objmid->accountancy_account_insurance] - $objmid->amount_insurance : 0;
608 $tabtp[$obj->rowid][$objmid->accountancy_account_interest] = isset($objmid->amount_interest) ? $tabtp[$obj->rowid][$objmid->accountancy_account_interest] - $objmid->amount_interest : 0;
610 } elseif ($links[$key][
'type'] ==
'banktransfert') {
611 $accountLinestatic->fetch($links[$key][
'url_id']);
612 $tabpay[$obj->rowid][
"lib"] .=
' '.$langs->trans(
"BankTransfer").
' '.$accountLinestatic ->getNomUrl(1);
613 $tabtp[$obj->rowid][$account_transfer] = isset($tabtp[$obj->rowid][$account_transfer]) ? $tabtp[$obj->rowid][$account_transfer] + $amounttouse : $amounttouse;
614 $bankaccountstatic->fetch($tabpay[$obj->rowid][
'fk_bank_account']);
615 $tabpay[$obj->rowid][
"soclib"] = $bankaccountstatic->getNomUrl(2);
620 if (empty($tabbq[$obj->rowid][$compta_bank])) {
621 $tabbq[$obj->rowid][$compta_bank] = $amounttouse;
623 $tabbq[$obj->rowid][$compta_bank] += $amounttouse;
628 if (empty($tabtp[$obj->rowid]) && !empty($tabmoreinfo[$obj->rowid][
'withdraw'])) {
629 foreach ($links as $key => $val) {
630 if ($links[$key][
'type'] ==
'payment') {
632 $tmppayment->fetch($links[$key][
'url_id']);
633 $arrayofamounts = $tmppayment->getAmountsArray();
634 if (is_array($arrayofamounts)) {
635 foreach ($arrayofamounts as $invoiceid => $amount) {
636 $tmpinvoice->fetch($invoiceid);
637 $tmpinvoice->fetch_thirdparty();
638 if ($tmpinvoice->thirdparty->code_compta_client) {
639 $tabtp[$obj->rowid][$tmpinvoice->thirdparty->code_compta_client] += $amount;
648 if (empty($tabtp[$obj->rowid])) {
649 $tabtp[$obj->rowid][
'NotDefined'] = $tabbq[$obj->rowid][$compta_bank];
661if (!$error && $action ==
'writebookkeeping' && $user->hasRight(
'accounting',
'bind',
'write')) {
665 $accountingaccountcustomer->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'),
true);
668 $accountingaccountsupplier->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER'),
true);
671 $accountingaccountpayment->fetch(0,
getDolGlobalString(
'SALARIES_ACCOUNTING_ACCOUNT_PAYMENT'),
true);
674 $accountingaccountexpensereport->fetch(0,
$conf->global->ACCOUNTING_ACCOUNT_EXPENSEREPORT,
true);
677 $accountingaccountsuspense->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUSPENSE'),
true);
680 foreach ($tabpay as $key => $val) {
695 if (!$errorforline && is_array($tabbq[$key])) {
697 foreach ($tabbq[$key] as $k => $mt) {
699 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
701 $accountingaccount->fetch(0, $k,
true);
702 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
704 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
707 $account_label = $accountingaccount->label;
710 if (!empty($val[
'lib'])) {
714 if (!empty($val[
'soclib'])) {
715 $reflabel .=
" / ".dol_string_nohtmltag($val[
'soclib']);
719 $bookkeeping->doc_date = $val[
"date"];
720 $bookkeeping->doc_ref = $ref;
721 $bookkeeping->doc_type =
'bank';
722 $bookkeeping->fk_doc = $key;
723 $bookkeeping->fk_docdet = $val[
"fk_bank"];
725 $bookkeeping->numero_compte = $k;
726 $bookkeeping->label_compte = $account_label;
728 $bookkeeping->label_operation = $reflabel;
729 $bookkeeping->montant = $mt;
730 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
731 $bookkeeping->debit = ($mt >= 0 ? $mt : 0);
732 $bookkeeping->credit = ($mt < 0 ? -$mt : 0);
733 $bookkeeping->code_journal = $journal;
734 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
735 $bookkeeping->fk_user_author = $user->id;
736 $bookkeeping->date_creation = $now;
739 $bookkeeping->subledger_account =
'';
740 $bookkeeping->label_operation = $reflabel;
741 $bookkeeping->entity =
$conf->entity;
743 $totaldebit += $bookkeeping->debit;
744 $totalcredit += $bookkeeping->credit;
746 $result = $bookkeeping->create($user);
748 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
751 setEventMessages(
'Transaction for ('.$bookkeeping->doc_type.
', '.$bookkeeping->fk_doc.
', '.$bookkeeping->fk_docdet.
') were already recorded',
null,
'warnings');
763 if (!$errorforline) {
764 if (is_array($tabtp[$key])) {
766 foreach ($tabtp[$key] as $k => $mt) {
771 if (!empty($val[
'lib'])) {
774 if ($tabtype[$key] ==
'banktransfert') {
775 $reflabel .=
dol_string_nohtmltag($langs->transnoentitiesnoconv(
'TransitionalAccount').
' '.$account_transfer);
781 $bookkeeping->doc_date = $val[
"date"];
782 $bookkeeping->doc_ref = $ref;
783 $bookkeeping->doc_type =
'bank';
784 $bookkeeping->fk_doc = $key;
785 $bookkeeping->fk_docdet = $val[
"fk_bank"];
787 $bookkeeping->label_operation = $reflabel;
788 $bookkeeping->montant = $mt;
789 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
790 $bookkeeping->debit = ($mt < 0 ? -$mt : 0);
791 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
792 $bookkeeping->code_journal = $journal;
793 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
794 $bookkeeping->fk_user_author = $user->id;
795 $bookkeeping->date_creation = $now;
797 if ($tabtype[$key] ==
'payment') {
799 $bookkeeping->subledger_account = $k;
800 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
801 $bookkeeping->numero_compte = $tabcompany[$key][
'accountancy_code_general'];
802 $bookkeeping->label_compte = $accountingaccountcustomer->label;
803 } elseif ($tabtype[$key] ==
'payment_supplier') {
805 $bookkeeping->subledger_account = $k;
806 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
807 $bookkeeping->numero_compte = $tabcompany[$key][
'accountancy_code_general'];
808 $bookkeeping->label_compte = $accountingaccountsupplier->label;
809 } elseif ($tabtype[$key] ==
'payment_expensereport') {
810 $bookkeeping->subledger_account = $tabuser[$key][
'accountancy_code'];
811 $bookkeeping->subledger_label = $tabuser[$key][
'name'];
813 $bookkeeping->label_compte = $accountingaccountexpensereport->label;
814 } elseif ($tabtype[$key] ==
'payment_salary') {
815 $bookkeeping->subledger_account = $tabuser[$key][
'accountancy_code'];
816 $bookkeeping->subledger_label = $tabuser[$key][
'name'];
817 $bookkeeping->numero_compte = $tabuser[$key][
'accountancy_code_general'];
818 $bookkeeping->label_compte = $accountingaccountpayment->label;
819 } elseif (in_array($tabtype[$key], array(
'sc',
'payment_sc'))) {
820 $bookkeeping->subledger_account =
'';
821 $bookkeeping->subledger_label =
'';
822 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
824 $accountingaccount->fetch(0, $k,
true);
825 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
827 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
829 $bookkeeping->numero_compte = $k;
830 $bookkeeping->label_compte = $accountingaccount->label;
831 } elseif ($tabtype[$key] ==
'payment_vat') {
832 $bookkeeping->subledger_account =
'';
833 $bookkeeping->subledger_label =
'';
834 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
836 $accountingaccount->fetch(0, $k,
true);
837 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
839 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
841 $bookkeeping->numero_compte = $k;
842 $bookkeeping->label_compte = $accountingaccount->label;
843 } elseif ($tabtype[$key] ==
'payment_donation') {
844 $bookkeeping->subledger_account =
'';
845 $bookkeeping->subledger_label =
'';
846 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
848 $accountingaccount->fetch(0, $k,
true);
849 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
851 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
853 $bookkeeping->numero_compte = $k;
854 $bookkeeping->label_compte = $accountingaccount->label;
855 } elseif ($tabtype[$key] ==
'member') {
856 $bookkeeping->subledger_account =
'';
857 $bookkeeping->subledger_label =
'';
858 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
860 $accountingaccount->fetch(0, $k,
true);
861 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
863 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
865 $bookkeeping->numero_compte = $k;
866 $bookkeeping->label_compte = $accountingaccount->label;
867 } elseif ($tabtype[$key] ==
'payment_loan') {
868 $bookkeeping->subledger_account =
'';
869 $bookkeeping->subledger_label =
'';
870 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
872 $accountingaccount->fetch(0, $k,
true);
873 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
875 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
877 $bookkeeping->numero_compte = $k;
878 $bookkeeping->label_compte = $accountingaccount->label;
879 } elseif ($tabtype[$key] ==
'payment_various') {
880 $bookkeeping->subledger_account = $k;
881 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
882 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$tabpay[$key][
"account_various"]])) {
884 $accountingaccount->fetch(0, $tabpay[$key][
"account_various"],
true);
885 $conf->cache[
'accountingaccountincurrententity'][$tabpay[$key][
"account_various"]] = $accountingaccount;
887 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$tabpay[$key][
"account_various"]];
889 $bookkeeping->numero_compte = $tabpay[$key][
"account_various"];
890 $bookkeeping->label_compte = $accountingaccount->label;
891 } elseif ($tabtype[$key] ==
'banktransfert') {
892 $bookkeeping->subledger_account =
'';
893 $bookkeeping->subledger_label =
'';
894 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
896 $accountingaccount->fetch(0, $k,
true);
897 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
899 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
901 $bookkeeping->numero_compte = $k;
902 $bookkeeping->label_compte = $accountingaccount->label;
904 if ($tabtype[$key] ==
'unknown') {
906 $bookkeeping->subledger_account =
'';
907 $bookkeeping->subledger_label =
'';
909 $bookkeeping->label_compte = $accountingaccountsuspense->label;
912 $bookkeeping->label_operation = $reflabel;
913 $bookkeeping->entity =
$conf->entity;
915 $totaldebit += $bookkeeping->debit;
916 $totalcredit += $bookkeeping->credit;
918 $result = $bookkeeping->create($user);
920 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
923 setEventMessages(
'Transaction for ('.$bookkeeping->doc_type.
', '.$bookkeeping->fk_doc.
', '.$bookkeeping->fk_docdet.
') were already recorded',
null,
'warnings');
931 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
933 $nb_lettering = $lettering_static->bookkeepingLetteringAll(array($bookkeeping->id));
939 foreach ($tabbq[$key] as $k => $mt) {
942 if (!empty($val[
'lib'])) {
948 $bookkeeping->doc_date = $val[
"date"];
949 $bookkeeping->doc_ref = $ref;
950 $bookkeeping->doc_type =
'bank';
951 $bookkeeping->fk_doc = $key;
952 $bookkeeping->fk_docdet = $val[
"fk_bank"];
953 $bookkeeping->montant = $mt;
954 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
955 $bookkeeping->debit = ($mt < 0 ? -$mt : 0);
956 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
957 $bookkeeping->code_journal = $journal;
958 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
959 $bookkeeping->fk_user_author = $user->id;
960 $bookkeeping->date_creation = $now;
961 $bookkeeping->label_compte =
'';
962 $bookkeeping->label_operation = $reflabel;
963 $bookkeeping->entity =
$conf->entity;
965 $totaldebit += $bookkeeping->debit;
966 $totalcredit += $bookkeeping->credit;
968 $result = $bookkeeping->create($user);
971 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
974 setEventMessages(
'Transaction for ('.$bookkeeping->doc_type.
', '.$bookkeeping->fk_doc.
', '.$bookkeeping->fk_docdet.
') were already recorded',
null,
'warnings');
989 setEventMessages(
'We tried to insert a non balanced transaction in book for '.$ref.
'. Canceled. Surely a bug.',
null,
'errors');
992 if (!$errorforline) {
999 if ($error >= $MAXNBERRORS) {
1000 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped").
' (>'.$MAXNBERRORS.
')',
null,
'errors');
1006 if (empty($error) && count($tabpay) > 0) {
1008 } elseif (count($tabpay) == $error) {
1011 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
1017 if (count($tabpay) != $error) {
1018 $param =
'id_journal='.$id_journal;
1019 $param .=
'&date_startday='.$date_startday;
1020 $param .=
'&date_startmonth='.$date_startmonth;
1021 $param .=
'&date_startyear='.$date_startyear;
1022 $param .=
'&date_endday='.$date_endday;
1023 $param .=
'&date_endmonth='.$date_endmonth;
1024 $param .=
'&date_endyear='.$date_endyear;
1025 $param .=
'&in_bookkeeping='.$in_bookkeeping;
1026 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
1034if ($action ==
'exportcsv' && $user->hasRight(
'accounting',
'bind',
'write')) {
1037 $filename =
'journal';
1038 $type_export =
'journal';
1039 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
1042 print
'"'.$langs->transnoentitiesnoconv(
"BankId").
'"'.$sep;
1043 print
'"'.$langs->transnoentitiesnoconv(
"Date").
'"'.$sep;
1044 print
'"'.$langs->transnoentitiesnoconv(
"PaymentMode").
'"'.$sep;
1045 print
'"'.$langs->transnoentitiesnoconv(
"AccountAccounting").
'"'.$sep;
1046 print
'"'.$langs->transnoentitiesnoconv(
"SubledgerAccount").
'"'.$sep;
1047 print
'"'.$langs->transnoentitiesnoconv(
"Label").
'"'.$sep;
1048 print
'"'.$langs->transnoentitiesnoconv(
"AccountingDebit").
'"'.$sep;
1049 print
'"'.$langs->transnoentitiesnoconv(
"AccountingCredit").
'"'.$sep;
1050 print
'"'.$langs->transnoentitiesnoconv(
"Journal").
'"'.$sep;
1051 print
'"'.$langs->transnoentitiesnoconv(
"Note").
'"'.$sep;
1054 foreach ($tabpay as $key => $val) {
1060 foreach ($tabbq[$key] as $k => $mt) {
1063 if (!empty($val[
'lib'])) {
1067 if (!empty($val[
'soclib'])) {
1068 $reflabel .=
" / ".dol_string_nohtmltag($val[
'soclib']);
1071 print
'"'.$key.
'"'.$sep;
1072 print
'"'.$date.
'"'.$sep;
1073 print
'"'.$val[
"type_payment"].
'"'.$sep;
1074 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1076 print
'"'.$reflabel.
'"'.$sep;
1077 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1078 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1079 print
'"'.$journal.
'"'.$sep;
1080 print
'"'.dol_string_nohtmltag($ref).
'"'.$sep;
1086 if (is_array($tabtp[$key])) {
1087 foreach ($tabtp[$key] as $k => $mt) {
1090 if (!empty($val[
'lib'])) {
1093 if ($tabtype[$key] ==
'banktransfert') {
1094 $reflabel .=
dol_string_nohtmltag($langs->transnoentitiesnoconv(
'TransitionalAccount').
' '.$account_transfer);
1099 print
'"'.$key.
'"'.$sep;
1100 print
'"'.$date.
'"'.$sep;
1101 print
'"'.$val[
"type_payment"].
'"'.$sep;
1102 if ($tabtype[$key] ==
'payment_supplier') {
1103 $account_ledger = (!empty($obj->accountancy_code_supplier_general)) ? $obj->accountancy_code_supplier_general : $account_supplier;
1104 print
'"'.length_accountg($account_ledger).
'"'.$sep;
1105 } elseif ($tabtype[$key] ==
'payment') {
1106 $account_ledger = (!empty($obj->accountancy_code_customer_general)) ? $obj->accountancy_code_customer_general : $account_customer;
1107 print
'"'.length_accountg($account_ledger).
'"'.$sep;
1108 } elseif ($tabtype[$key] ==
'payment_expensereport') {
1109 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_EXPENSEREPORT')).
'"'.$sep;
1110 } elseif ($tabtype[$key] ==
'payment_salary') {
1111 $account_ledger = (!empty($obj->accountancy_code_user_general)) ? $obj->accountancy_code_user_general : $account_employee;
1112 print
'"'.length_accountg($account_ledger).
'"'.$sep;
1114 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1116 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
1117 print
'"'.$reflabel.
'"'.$sep;
1118 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1119 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1120 print
'"'.$journal.
'"'.$sep;
1121 print
'"'.dol_string_nohtmltag($ref).
'"'.$sep;
1126 foreach ($tabbq[$key] as $k => $mt) {
1129 if (!empty($val[
'lib'])) {
1134 print
'"'.$key.
'"'.$sep;
1135 print
'"'.$date.
'"'.$sep;
1136 print
'"'.$val[
"type_payment"].
'"'.$sep;
1137 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUSPENSE')).
'"'.$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;
1156$form =
new Form($db);
1158if (empty($action) || $action ==
'view') {
1159 $invoicestatic =
new Facture($db);
1162 $vatstatic =
new Tva($db);
1163 $donationstatic =
new Don($db);
1164 $loanstatic =
new Loan($db);
1165 $salarystatic =
new Salary($db);
1168 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
1169 $help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité';
1175 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
1177 $listofchoices = array(
1178 'notyet' => $langs->trans(
"NotYetInGeneralLedger"),
1179 'already' => $langs->trans(
"AlreadyInGeneralLedger")
1181 $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);
1182 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
1184 $varlink =
'id_journal='.$id_journal;
1188 $listofchoices = array(
1189 1 => $langs->trans(
"TransfertAllBankLines"),
1190 2 => $langs->trans(
"TransfertOnlyConciliatedBankLine")
1192 $moreoptions = [
"BankLineConciliated" => $form->selectarray(
'only_rappro', $listofchoices, $only_rappro)];
1194 journalHead($nom,
'', $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink, $moreoptions);
1201 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int)
$conf->entity);
1202 $resql = $db->query($sql);
1204 $obj = $db->fetch_object($resql);
1205 if ($obj->nb == 0) {
1206 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
1207 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
1208 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
1218 $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";
1219 $resql = $db->query($sql);
1221 $obj = $db->fetch_object($resql);
1223 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheJournalCodeIsNotDefinedOnSomeBankAccount");
1224 $desc =
' : '.$langs->trans(
"AccountancyAreaDescBank", 6,
'{link}');
1225 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"BankAccounts").
'</strong>', $desc);
1241 print($desc ?
'' :
'<br>').
'<div class="warning">'.
img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
1242 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
1243 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
1249 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
1251 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
1252 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
1257 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
1259 if ($in_bookkeeping ==
'notyet') {
1260 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
1262 print
'<a class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
1270 <script type="text/javascript">
1271 function launch_export() {
1272 console.log("Set value into form and submit");
1273 $("div.fiche form input[name=\"action\"]").val("exportcsv");
1274 $("div.fiche form input[type=\"submit\"]").click();
1275 $("div.fiche form input[name=\"action\"]").val("");
1277 function writebookkeeping() {
1278 console.log("Set value into form and submit");
1279 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
1280 $("div.fiche form input[type=\"submit\"]").click();
1281 $("div.fiche form input[name=\"action\"]").val("");
1291 print
'<div class="div-table-responsive">';
1292 print
'<table class="noborder centpercent">';
1293 print
'<tr class="liste_titre">';
1294 print
"<td>".$langs->trans(
"Date").
"</td>";
1295 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"ObjectsRef").
")</td>";
1296 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
1297 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
1298 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
1299 print
'<td class="center">'.$langs->trans(
"PaymentMode").
"</td>";
1300 print
'<td class="right">'.$langs->trans(
"AccountingDebit").
"</td>";
1301 print
'<td class="right">'.$langs->trans(
"AccountingCredit").
"</td>";
1304 foreach ($tabpay as $key => $val) {
1310 foreach ($tabbq[$key] as $k => $mt) {
1313 if (!empty($val[
'lib'])) {
1314 $reflabel .= $val[
'lib'].
" / ";
1316 $reflabel .= $langs->trans(
"Bank").
' '.$val[
'bank_account_ref'];
1317 if (!empty($val[
'soclib'])) {
1318 $reflabel .=
" / ".$val[
'soclib'];
1322 print
'<!-- Bank bank.rowid='.$key.
'=accounting_bookkeeping.fk_doc (accounting_bookkeeping.doc_type=\'bank\') type='.$tabpay[$key][
'type'].
' ref='.$tabpay[$key][
'ref'].
' -->';
1323 print
'<tr class="oddeven">';
1326 print
"<td>".$date.
"</td>";
1329 print
'<td class="maxwidth300 nopaddingtopimp nopaddingbottomimp">'.dol_escape_htmltag($ref).
"</td>";
1333 if (empty($accounttoshow) || $accounttoshow ==
'NotDefined') {
1334 $accounttoshow =
'<span class="error">'.$langs->trans(
"BankAccountNotDefined").
'</span>';
1336 print
'<td class="maxwidth300" title="'.dol_escape_htmltag(
dol_string_nohtmltag($accounttoshow)).
'">';
1337 print $accounttoshow;
1341 print
'<td class="maxwidth300">';
1351 print
'<td class="maxwidth300 nopaddingtopimp nopaddingbottomimp">';
1355 print
'<td class="center">'.$val[
"type_payment"].
"</td>";
1356 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1357 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1365 if (is_array($tabtp[$key])) {
1366 foreach ($tabtp[$key] as $k => $mt) {
1369 if (!empty($val[
'lib'])) {
1370 $reflabel .= $val[
'lib'].(isset($val[
'soclib']) ?
" / " :
"");
1372 if ($tabtype[$key] ==
'banktransfert') {
1373 $reflabel .= $langs->trans(
'TransitionalAccount').
' '.$account_transfer;
1375 $reflabel .= isset($val[
'soclib']) ? $val[
'soclib'] :
"";
1378 print
'<!-- Thirdparty bank.rowid='.$key.
'=accounting_bookkeeping.fk_doc (accounting_bookkeeping.doc_type=\'bank\') type='.$tabpay[$key][
'type'].
' ref='.$tabpay[$key][
'ref'].
' -->';
1379 print
'<tr class="oddeven">';
1382 print
"<td>".$date.
"</td>";
1385 print
'<td class="nopaddingtopimp nopaddingbottomimp">'.dol_escape_htmltag($ref).
"</td>";
1389 $account_ledger = $k;
1391 if ($tabtype[$key] ==
'payment') {
1392 $account_ledger = (!empty($obj->accountancy_code_customer_general)) ? $obj->accountancy_code_customer_general : $account_customer;
1394 if ($tabtype[$key] ==
'payment_supplier') {
1395 $account_ledger = (!empty($obj->accountancy_code_supplier_general)) ? $obj->accountancy_code_supplier_general : $account_supplier;
1397 if ($tabtype[$key] ==
'payment_expensereport') {
1400 if ($tabtype[$key] ==
'payment_salary') {
1401 $account_ledger = (!empty($obj->accountancy_code_user_general)) ? $obj->accountancy_code_user_general : $account_employee;
1403 if ($tabtype[$key] ==
'payment_vat') {
1406 if ($tabtype[$key] ==
'member') {
1409 if ($tabtype[$key] ==
'payment_various') {
1410 $account_ledger = $tabpay[$key][
"account_various"];
1413 if (empty($accounttoshow) || $accounttoshow ==
'NotDefined') {
1414 if ($tabtype[$key] ==
'unknown') {
1417 $accounttoshow =
'<span class="error small">'.$langs->trans(
'UnknownAccountForThirdpartyAndWaitingAccountNotDefinedBlocking').
'</span>';
1419 $accounttoshow =
'<span class="warning small">'.$langs->trans(
'UnknownAccountForThirdparty',
length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUSPENSE'))).
'</span>';
1423 $errorstring =
'UnknownAccountForThirdpartyBlocking';
1424 if ($tabtype[$key] ==
'payment') {
1425 $errorstring =
'MainAccountForCustomersNotDefined';
1427 if ($tabtype[$key] ==
'payment_supplier') {
1428 $errorstring =
'MainAccountForSuppliersNotDefined';
1430 if ($tabtype[$key] ==
'payment_expensereport') {
1431 $errorstring =
'MainAccountForUsersNotDefined';
1433 if ($tabtype[$key] ==
'payment_salary') {
1434 $errorstring =
'MainAccountForUsersNotDefined';
1436 if ($tabtype[$key] ==
'payment_vat') {
1437 $errorstring =
'MainAccountForVatPaymentNotDefined';
1439 if ($tabtype[$key] ==
'member') {
1440 $errorstring =
'MainAccountForSubscriptionPaymentNotDefined';
1442 $accounttoshow =
'<span class="error small">'.$langs->trans($errorstring).
'</span>';
1445 print
'<td class="maxwidth300" title="'.dol_escape_htmltag(
dol_string_nohtmltag($accounttoshow)).
'">';
1446 print $accounttoshow;
1450 $accounttoshowsubledger =
'';
1451 if (in_array($tabtype[$key], array(
'payment',
'payment_supplier',
'payment_expensereport',
'payment_salary',
'payment_various'))) {
1453 if ($accounttoshow != $accounttoshowsubledger) {
1454 if (empty($accounttoshowsubledger) || $accounttoshowsubledger ==
'NotDefined') {
1456 if (!empty($tabcompany[$key][
'code_compta'])) {
1457 if (in_array($tabtype[$key], array(
'payment_various'))) {
1459 $accounttoshowsubledger =
'<span class="warning small">'.$langs->trans(
"ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored").
'</span>';
1460 } elseif (in_array($tabtype[$key], array(
'payment_salary'))) {
1461 $accounttoshowsubledger =
'<span class="warning small">'.$langs->trans(
"ThirdpartyAccountNotDefinedOrThirdPartyUnknownSubledgerIgnored2").
'</span>';
1463 $accounttoshowsubledger =
'<span class="warning small">'.$langs->trans(
"ThirdpartyAccountNotDefinedOrThirdPartyUnknown", $tabcompany[$key][
'code_compta']).
'</span>';
1466 $accounttoshowsubledger =
'<span class="error small">'.$langs->trans(
"ThirdpartyAccountNotDefinedOrThirdPartyUnknownBlocking").
'</span>';
1470 $accounttoshowsubledger =
'';
1473 print
'<td class="maxwidth300 nopaddingtopimp nopaddingbottomimp">';
1474 print $accounttoshowsubledger;
1478 print
'<td class="nopaddingtopimpo paddingbottomimp">';
1482 print
'<td class="center">'.$val[
"type_payment"].
"</td>";
1484 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1486 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1494 foreach ($tabbq[$key] as $k => $mt) {
1497 if (!empty($val[
'lib'])) {
1498 $reflabel .= $val[
'lib'].
" / ";
1500 $reflabel .=
'WaitingAccount';
1502 print
'<!-- Wait bank.rowid='.$key.
' -->';
1503 print
'<tr class="oddeven">';
1504 print
"<td>".$date.
"</td>";
1505 print
"<td>".$ref.
"</td>";
1518 print
"<td>".dol_escape_htmltag($reflabel).
"</td>";
1519 print
'<td class="center">'.$val[
"type_payment"].
"</td>";
1520 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1521 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1532 print
'<tr class="oddeven"><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
1559 if ($ref ==
'(SupplierInvoicePayment)' || $ref ==
'(SupplierInvoicePaymentBack)') {
1560 $ref = $langs->transnoentitiesnoconv(
'Supplier');
1562 if ($ref ==
'(CustomerInvoicePayment)' || $ref ==
'(CustomerInvoicePaymentBack)') {
1563 $ref = $langs->transnoentitiesnoconv(
'Customer');
1565 if ($ref ==
'(SocialContributionPayment)') {
1566 $ref = $langs->transnoentitiesnoconv(
'SocialContribution');
1568 if ($ref ==
'(DonationPayment)') {
1569 $ref = $langs->transnoentitiesnoconv(
'Donation');
1571 if ($ref ==
'(SubscriptionPayment)') {
1572 $ref = $langs->transnoentitiesnoconv(
'Subscription');
1574 if ($ref ==
'(ExpenseReportPayment)') {
1575 $ref = $langs->transnoentitiesnoconv(
'Employee');
1577 if ($ref ==
'(LoanPayment)') {
1578 $ref = $langs->transnoentitiesnoconv(
'Loan');
1580 if ($ref ==
'(payment_salary)') {
1581 $ref = $langs->transnoentitiesnoconv(
'Employee');
1585 if ($typerecord ==
'payment') {
1587 $sqlmid =
"SELECT payfac.fk_facture as id, ".$db->ifsql(
'f1.rowid IS NULL',
'f.ref',
'f1.ref').
" as ref";
1588 $sqlmid .=
" FROM ".$db->prefix().
"paiement_facture as payfac";
1589 $sqlmid .=
" LEFT JOIN ".$db->prefix().
"facture as f ON f.rowid = payfac.fk_facture";
1590 $sqlmid .=
" LEFT JOIN ".$db->prefix().
"societe_remise_except as sre ON sre.fk_facture_source = payfac.fk_facture";
1591 $sqlmid .=
" LEFT JOIN ".$db->prefix().
"facture as f1 ON f1.rowid = sre.fk_facture";
1592 $sqlmid .=
" WHERE payfac.fk_paiement=".((int) $val[
'paymentid']);
1594 $sqlmid =
"SELECT payfac.fk_facture as id, f.ref as ref";
1595 $sqlmid .=
" FROM ".$db->prefix().
"paiement_facture as payfac";
1596 $sqlmid .=
" INNER JOIN ".$db->prefix().
"facture as f ON f.rowid = payfac.fk_facture";
1597 $sqlmid .=
" WHERE payfac.fk_paiement=".((int) $val[
'paymentid']);
1599 $ref = $langs->transnoentitiesnoconv(
"Invoice");
1600 } elseif ($typerecord ==
'payment_supplier') {
1601 $sqlmid =
'SELECT payfac.fk_facturefourn as id, f.ref';
1602 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"paiementfourn_facturefourn as payfac, ".MAIN_DB_PREFIX.
"facture_fourn as f";
1603 $sqlmid .=
" WHERE payfac.fk_facturefourn = f.rowid AND payfac.fk_paiementfourn=".((int) $val[
"paymentsupplierid"]);
1604 $ref = $langs->transnoentitiesnoconv(
"SupplierInvoice");
1605 } elseif ($typerecord ==
'payment_expensereport') {
1606 $sqlmid =
'SELECT e.rowid as id, e.ref';
1607 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"payment_expensereport as pe, ".MAIN_DB_PREFIX.
"expensereport as e";
1608 $sqlmid .=
" WHERE pe.rowid=".((int) $val[
"paymentexpensereport"]).
" AND pe.fk_expensereport = e.rowid";
1609 $ref = $langs->transnoentitiesnoconv(
"ExpenseReport");
1610 } elseif ($typerecord ==
'payment_salary') {
1611 $sqlmid =
'SELECT s.rowid as ref';
1612 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"payment_salary as s";
1613 $sqlmid .=
" WHERE s.rowid=".((int) $val[
"paymentsalid"]);
1614 $ref = $langs->transnoentitiesnoconv(
"SalaryPayment");
1615 } elseif ($typerecord ==
'sc') {
1616 $sqlmid =
'SELECT sc.rowid as ref';
1617 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"paiementcharge as sc";
1618 $sqlmid .=
" WHERE sc.rowid=".((int) $val[
"paymentscid"]);
1619 $ref = $langs->transnoentitiesnoconv(
"SocialContribution");
1620 } elseif ($typerecord ==
'payment_vat') {
1621 $sqlmid =
'SELECT v.rowid as ref';
1622 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"tva as v";
1623 $sqlmid .=
" WHERE v.rowid=".((int) $val[
"paymentvatid"]);
1624 $ref = $langs->transnoentitiesnoconv(
"PaymentVat");
1625 } elseif ($typerecord ==
'payment_donation') {
1626 $sqlmid =
'SELECT payd.fk_donation as ref';
1627 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"payment_donation as payd";
1628 $sqlmid .=
" WHERE payd.fk_donation=".((int) $val[
"paymentdonationid"]);
1629 $ref = $langs->transnoentitiesnoconv(
"Donation");
1630 } elseif ($typerecord ==
'payment_loan') {
1631 $sqlmid =
'SELECT l.rowid as ref';
1632 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"payment_loan as l";
1633 $sqlmid .=
" WHERE l.rowid=".((int) $val[
"paymentloanid"]);
1634 $ref = $langs->transnoentitiesnoconv(
"LoanPayment");
1635 } elseif ($typerecord ==
'payment_various') {
1636 $sqlmid =
'SELECT v.rowid as ref';
1637 $sqlmid .=
" FROM ".MAIN_DB_PREFIX.
"payment_various as v";
1638 $sqlmid .=
" WHERE v.rowid=".((int) $val[
"paymentvariousid"]);
1639 $ref = $langs->transnoentitiesnoconv(
"VariousPayment");
1642 if (empty($sqlmid)) {
1643 dol_syslog(
"Found a typerecord=".$typerecord.
" not supported", LOG_WARNING);
1647 dol_syslog(
"accountancy/journal/bankjournal.php::sqlmid=".$sqlmid, LOG_DEBUG);
1648 $resultmid = $db->query($sqlmid);
1650 while ($objmid = $db->fetch_object($resultmid)) {
1651 $ref .=
' '.$objmid->ref;
1658 $ref =
dol_trunc($langs->transnoentitiesnoconv(
"BankId").
' '.$val[
'fk_bank'].
' - '.$ref, 295);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $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_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.