34require
'../../main.inc.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
38require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
42require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeeping.class.php';
45$langs->loadLangs(array(
"commercial",
"compta",
"bills",
"other",
"accountancy",
"errors"));
47$id_journal =
GETPOST(
'id_journal',
'int');
48$action =
GETPOST(
'action',
'aZ09');
50$date_startmonth =
GETPOST(
'date_startmonth');
51$date_startday =
GETPOST(
'date_startday');
52$date_startyear =
GETPOST(
'date_startyear');
53$date_endmonth =
GETPOST(
'date_endmonth');
54$date_endday =
GETPOST(
'date_endday');
55$date_endyear =
GETPOST(
'date_endyear');
56$in_bookkeeping =
GETPOST(
'in_bookkeeping');
57if ($in_bookkeeping ==
'') {
58 $in_bookkeeping =
'notyet';
63$hookmanager->initHooks(array(
'sellsjournal'));
67if (!isModEnabled(
'accounting')) {
70if ($user->socid > 0) {
73if (!$user->hasRight(
'accounting',
'mouvements',
'lire')) {
82$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $user, $action);
88$accountingjournalstatic->fetch($id_journal);
89$journal = $accountingjournalstatic->code;
90$journal_label = $accountingjournalstatic->label;
92$date_start =
dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
93$date_end =
dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
95if (empty($date_startmonth) || empty($date_endmonth)) {
98 $date_start = $dates[
'date_start'];
99 $date_end = $dates[
'date_end'];
100 $pastmonthyear = $dates[
'pastmonthyear'];
101 $pastmonth = $dates[
'pastmonth'];
104if (!GETPOSTISSET(
'date_startmonth') && (empty($date_start) || empty($date_end))) {
109$sql =
"SELECT f.rowid, f.ref, f.type, f.situation_cycle_ref, f.datef as df, f.ref_client, f.date_lim_reglement as dlr, f.close_code, f.retained_warranty, f.revenuestamp,";
110$sql .=
" fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code, fd.info_bits,";
111$sql .=
" s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur,";
113 $sql .=
" spe.accountancy_code_customer as code_compta,";
114 $sql .=
" spe.accountancy_code_supplier as code_compta_fournisseur,";
116 $sql .=
" s.code_compta as code_compta,";
117 $sql .=
" s.code_compta_fournisseur,";
119$sql .=
" p.rowid as pid, p.ref as pref, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,";
121 $sql .=
" ppe.accountancy_code_sell";
123 $sql .=
" p.accountancy_code_sell";
125$sql .=
" FROM ".MAIN_DB_PREFIX.
"facturedet as fd";
126$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = fd.fk_product";
128 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
130$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
131$sql .=
" JOIN ".MAIN_DB_PREFIX.
"facture as f ON f.rowid = fd.fk_facture";
132$sql .=
" JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = f.fk_soc";
134 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
136$sql .=
" WHERE fd.fk_code_ventilation > 0";
137$sql .=
" AND f.entity IN (".getEntity(
'invoice', 0).
')';
138$sql .=
" AND f.fk_statut > 0";
144$sql .=
" AND fd.product_type IN (0,1)";
145if ($date_start && $date_end) {
146 $sql .=
" AND f.datef >= '".$db->idate($date_start).
"' AND f.datef <= '".$db->idate($date_end).
"'";
150 $sql .=
" AND f.datef >= '".$db->idate(
getDolGlobalString(
'ACCOUNTING_DATE_START_BINDING')).
"'";
153if ($in_bookkeeping ==
'already') {
154 $sql .=
" AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
157if ($in_bookkeeping ==
'notyet') {
158 $sql .=
" AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
161$sql .=
" ORDER BY f.datef, f.ref";
164dol_syslog(
'accountancy/journal/sellsjournal.php', LOG_DEBUG);
165$result = $db->query($sql);
171 $tabwarranty = array();
172 $tabrevenuestamp = array();
174 $tablocaltax1 = array();
175 $tablocaltax2 = array();
176 $tabcompany = array();
178 $num = $db->num_rows($result);
186 $obj = $db->fetch_object($result);
189 $compta_soc = (!empty($obj->code_compta)) ? $obj->code_compta : $cptcli;
191 $compta_prod = $obj->compte;
192 if (empty($compta_prod)) {
193 if ($obj->product_type == 0) {
202 $vatdata =
getTaxesFromId($obj->tva_tx.($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''), $mysoc, $mysoc, 0);
203 $compta_tva = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
204 $compta_localtax1 = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
205 $compta_localtax2 = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
208 if (
price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
209 $def_tva[$obj->rowid][$compta_tva][
vatrate($obj->tva_tx).($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
'')] = (
vatrate($obj->tva_tx).($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''));
213 $situation_ratio = 1;
215 if ($obj->situation_cycle_ref) {
217 if ($obj->situation_percent == 0) {
218 $situation_ratio = 0;
221 $line->fetch($obj->fdid);
224 $prev_progress = $line->get_prev_progress($obj->rowid);
226 $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
231 $revenuestamp = (double)
price2num($obj->revenuestamp,
'MT');
234 $tabfac[$obj->rowid][
"date"] = $db->jdate($obj->df);
235 $tabfac[$obj->rowid][
"datereg"] = $db->jdate($obj->dlr);
236 $tabfac[$obj->rowid][
"ref"] = $obj->ref;
237 $tabfac[$obj->rowid][
"type"] = $obj->type;
238 $tabfac[$obj->rowid][
"description"] = $obj->label_compte;
239 $tabfac[$obj->rowid][
"close_code"] = $obj->close_code;
240 $tabfac[$obj->rowid][
"revenuestamp"] = $revenuestamp;
244 if (!isset($tabttc[$obj->rowid][$compta_soc])) {
245 $tabttc[$obj->rowid][$compta_soc] = 0;
247 if (!isset($tabht[$obj->rowid][$compta_prod])) {
248 $tabht[$obj->rowid][$compta_prod] = 0;
250 if (!isset($tabtva[$obj->rowid][$compta_tva])) {
251 $tabtva[$obj->rowid][$compta_tva] = 0;
253 if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
254 $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
256 if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) {
257 $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
266 $total_ttc = $obj->total_ttc * $situation_ratio;
268 $total_ttc = $obj->total_ttc;
272 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && $obj->retained_warranty > 0) {
273 $retained_warranty = (double)
price2num($total_ttc * $obj->retained_warranty / 100,
'MT');
274 $tabwarranty[$obj->rowid][$compta_soc] += $retained_warranty;
275 $total_ttc -= $retained_warranty;
278 $tabttc[$obj->rowid][$compta_soc] += $total_ttc;
279 $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
280 $tva_npr = (($obj->info_bits & 1 == 1) ? 1 : 0);
282 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio;
284 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio;
285 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio;
287 $compta_revenuestamp =
'NotDefined';
288 if (!empty($revenuestamp)) {
289 $sqlrevenuestamp =
"SELECT accountancy_code_sell FROM ".MAIN_DB_PREFIX.
"c_revenuestamp";
290 $sqlrevenuestamp .=
" WHERE fk_pays = ".((int) $mysoc->country_id);
291 $sqlrevenuestamp .=
" AND taux = ".((double) $revenuestamp);
292 $sqlrevenuestamp .=
" AND active = 1";
293 $resqlrevenuestamp = $db->query($sqlrevenuestamp);
295 if ($resqlrevenuestamp) {
296 $num_rows_revenuestamp = $db->num_rows($resqlrevenuestamp);
297 if ($num_rows_revenuestamp > 1) {
298 dol_print_error($db,
'Failed 2 or more lines for the revenue stamp of your country. Check the dictionary of revenue stamp.');
300 $objrevenuestamp = $db->fetch_object($resqlrevenuestamp);
301 if ($objrevenuestamp) {
302 $compta_revenuestamp = $objrevenuestamp->accountancy_code_sell;
308 if (empty($tabrevenuestamp[$obj->rowid][$compta_revenuestamp]) && !empty($revenuestamp)) {
310 $tabttc[$obj->rowid][$compta_soc] += $obj->revenuestamp;
311 $tabrevenuestamp[$obj->rowid][$compta_revenuestamp] = $obj->revenuestamp;
314 $tabcompany[$obj->rowid] = array(
316 'name' => $obj->name,
317 'code_client' => $obj->code_client,
318 'code_compta' => $compta_soc
329$errorforinvoice = array();
332foreach ($tabfac as $key => $val) {
333 $sql =
"SELECT COUNT(fd.rowid) as nb";
334 $sql .=
" FROM ".MAIN_DB_PREFIX.
"facturedet as fd";
335 $sql .=
" WHERE fd.product_type <= 2 AND fd.fk_code_ventilation <= 0";
336 $sql .=
" AND fd.total_ttc <> 0 AND fk_facture = ".((int) $key);
337 $resql = $db->query($sql);
339 $obj = $db->fetch_object($resql);
341 $errorforinvoice[$key] =
'somelinesarenotbound';
351if ($action ==
'writebookkeeping') {
355 $companystatic =
new Societe($db);
356 $invoicestatic =
new Facture($db);
359 $accountingaccountcustomer->fetch(
null,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'),
true);
363 $accountingaccountcustomerwarranty->fetch(
null,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'),
true);
365 foreach ($tabfac as $key => $val) {
373 $companystatic->id = $tabcompany[$key][
'id'];
374 $companystatic->name = $tabcompany[$key][
'name'];
375 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
376 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
377 $companystatic->code_client = $tabcompany[$key][
'code_client'];
378 $companystatic->client = 3;
380 $invoicestatic->id = $key;
381 $invoicestatic->ref = (string) $val[
"ref"];
382 $invoicestatic->type = $val[
"type"];
383 $invoicestatic->close_code = $val[
"close_code"];
388 $replacedinvoice = 0;
389 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
390 $replacedinvoice = 1;
391 $alreadydispatched = $invoicestatic->getVentilExportCompta();
392 if ($alreadydispatched) {
393 $replacedinvoice = 2;
398 if ($replacedinvoice == 1) {
404 if ($errorforinvoice[$key] ==
'somelinesarenotbound') {
407 setEventMessages($langs->trans(
'ErrorInvoiceContainsLinesNotYetBounded', $val[
'ref']),
null,
'errors');
411 if (!$errorforline &&
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key])) {
412 foreach ($tabwarranty[$key] as $k => $mt) {
414 $bookkeeping->doc_date = $val[
"date"];
415 $bookkeeping->date_lim_reglement = $val[
"datereg"];
416 $bookkeeping->doc_ref = $val[
"ref"];
417 $bookkeeping->date_creation = $now;
418 $bookkeeping->doc_type =
'customer_invoice';
419 $bookkeeping->fk_doc = $key;
420 $bookkeeping->fk_docdet = 0;
421 $bookkeeping->thirdparty_code = $companystatic->code_client;
423 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
424 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
426 $bookkeeping->numero_compte =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY');
427 $bookkeeping->label_compte = $accountingaccountcustomerwarranty->label;
429 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"Retainedwarranty");
430 $bookkeeping->montant = $mt;
431 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
432 $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
433 $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
434 $bookkeeping->code_journal = $journal;
435 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
436 $bookkeeping->fk_user_author = $user->id;
437 $bookkeeping->entity = $conf->entity;
439 $totaldebit += $bookkeeping->debit;
440 $totalcredit += $bookkeeping->credit;
442 $result = $bookkeeping->create($user);
444 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
447 $errorforinvoice[$key] =
'alreadyjournalized';
452 $errorforinvoice[$key] =
'other';
460 if (!$errorforline) {
461 foreach ($tabttc[$key] as $k => $mt) {
463 $bookkeeping->doc_date = $val[
"date"];
464 $bookkeeping->date_lim_reglement = $val[
"datereg"];
465 $bookkeeping->doc_ref = $val[
"ref"];
466 $bookkeeping->date_creation = $now;
467 $bookkeeping->doc_type =
'customer_invoice';
468 $bookkeeping->fk_doc = $key;
469 $bookkeeping->fk_docdet = 0;
470 $bookkeeping->thirdparty_code = $companystatic->code_client;
472 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
473 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
476 $bookkeeping->label_compte = $accountingaccountcustomer->label;
478 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"SubledgerAccount");
479 $bookkeeping->montant = $mt;
480 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
481 $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
482 $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
483 $bookkeeping->code_journal = $journal;
484 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
485 $bookkeeping->fk_user_author = $user->id;
486 $bookkeeping->entity = $conf->entity;
488 $totaldebit += $bookkeeping->debit;
489 $totalcredit += $bookkeeping->credit;
491 $result = $bookkeeping->create($user);
493 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
496 $errorforinvoice[$key] =
'alreadyjournalized';
501 $errorforinvoice[$key] =
'other';
506 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
509 $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id));
516 if (!$errorforline) {
517 foreach ($tabht[$key] as $k => $mt) {
518 $resultfetch = $accountingaccount->fetch(
null, $k,
true);
519 $label_account = $accountingaccount->label;
522 if ($resultfetch > 0) {
524 $bookkeeping->doc_date = $val[
"date"];
525 $bookkeeping->date_lim_reglement = $val[
"datereg"];
526 $bookkeeping->doc_ref = $val[
"ref"];
527 $bookkeeping->date_creation = $now;
528 $bookkeeping->doc_type =
'customer_invoice';
529 $bookkeeping->fk_doc = $key;
530 $bookkeeping->fk_docdet = 0;
531 $bookkeeping->thirdparty_code = $companystatic->code_client;
535 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
536 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
538 $bookkeeping->subledger_account =
'';
539 $bookkeeping->subledger_label =
'';
542 $bookkeeping->subledger_account =
'';
543 $bookkeeping->subledger_label =
'';
546 $bookkeeping->numero_compte = $k;
547 $bookkeeping->label_compte = $label_account;
549 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref.
' - '.$label_account;
550 $bookkeeping->montant = $mt;
551 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
552 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
553 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
554 $bookkeeping->code_journal = $journal;
555 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
556 $bookkeeping->fk_user_author = $user->id;
557 $bookkeeping->entity = $conf->entity;
559 $totaldebit += $bookkeeping->debit;
560 $totalcredit += $bookkeeping->credit;
562 $result = $bookkeeping->create($user);
564 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
567 $errorforinvoice[$key] =
'alreadyjournalized';
572 $errorforinvoice[$key] =
'other';
581 if (!$errorforline) {
582 $listoftax = array(0, 1, 2);
583 foreach ($listoftax as $numtax) {
584 $arrayofvat = $tabtva;
586 $arrayofvat = $tablocaltax1;
589 $arrayofvat = $tablocaltax2;
592 foreach ($arrayofvat[$key] as $k => $mt) {
594 $accountingaccount->fetch(
null, $k,
true);
595 $label_account = $accountingaccount->label;
598 $bookkeeping->doc_date = $val[
"date"];
599 $bookkeeping->date_lim_reglement = $val[
"datereg"];
600 $bookkeeping->doc_ref = $val[
"ref"];
601 $bookkeeping->date_creation = $now;
602 $bookkeeping->doc_type =
'customer_invoice';
603 $bookkeeping->fk_doc = $key;
604 $bookkeeping->fk_docdet = 0;
605 $bookkeeping->thirdparty_code = $companystatic->code_client;
607 $bookkeeping->subledger_account =
'';
608 $bookkeeping->subledger_label =
'';
610 $bookkeeping->numero_compte = $k;
611 $bookkeeping->label_compte = $label_account;
614 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref;
615 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : join(
', ', $def_tva[$key][$k]));
616 $bookkeeping->label_operation .=
' - '.$langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
617 $bookkeeping->label_operation .= ($numtax ?
' - Localtax '.$numtax :
'');
619 $bookkeeping->montant = $mt;
620 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
621 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
622 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
623 $bookkeeping->code_journal = $journal;
624 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
625 $bookkeeping->fk_user_author = $user->id;
626 $bookkeeping->entity = $conf->entity;
628 $totaldebit += $bookkeeping->debit;
629 $totalcredit += $bookkeeping->credit;
631 $result = $bookkeeping->create($user);
633 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
636 $errorforinvoice[$key] =
'alreadyjournalized';
641 $errorforinvoice[$key] =
'other';
651 if (!$errorforline) {
652 if (isset($tabrevenuestamp[$key])) {
653 foreach ($tabrevenuestamp[$key] as $k => $mt) {
655 $accountingaccount->fetch(
null, $k,
true);
656 $label_account = $accountingaccount->label;
659 $bookkeeping->doc_date = $val[
"date"];
660 $bookkeeping->date_lim_reglement = $val[
"datereg"];
661 $bookkeeping->doc_ref = $val[
"ref"];
662 $bookkeeping->date_creation = $now;
663 $bookkeeping->doc_type =
'customer_invoice';
664 $bookkeeping->fk_doc = $key;
665 $bookkeeping->fk_docdet = 0;
666 $bookkeeping->thirdparty_code = $companystatic->code_client;
668 $bookkeeping->subledger_account =
'';
669 $bookkeeping->subledger_label =
'';
671 $bookkeeping->numero_compte = $k;
672 $bookkeeping->label_compte = $label_account;
674 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"RevenueStamp");
675 $bookkeeping->montant = $mt;
676 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
677 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
678 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
679 $bookkeeping->code_journal = $journal;
680 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
681 $bookkeeping->fk_user_author = $user->id;
682 $bookkeeping->entity = $conf->entity;
684 $totaldebit += $bookkeeping->debit;
685 $totalcredit += $bookkeeping->credit;
687 $result = $bookkeeping->create($user);
689 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
692 $errorforinvoice[$key] =
'alreadyjournalized';
697 $errorforinvoice[$key] =
'other';
707 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
710 $errorforinvoice[$key] =
'amountsnotbalanced';
711 setEventMessages(
'We Tried to insert a non balanced transaction in book for '.$invoicestatic->ref.
'. Canceled. Surely a bug.',
null,
'errors');
714 if (!$errorforline) {
720 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
728 if (empty($error) && count($tabpay) > 0) {
730 } elseif (count($tabpay) == $error) {
733 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
739 if (count($tabpay) != $error) {
740 $param =
'id_journal='.$id_journal;
741 $param .=
'&date_startday='.$date_startday;
742 $param .=
'&date_startmonth='.$date_startmonth;
743 $param .=
'&date_startyear='.$date_startyear;
744 $param .=
'&date_endday='.$date_endday;
745 $param .=
'&date_endmonth='.$date_endmonth;
746 $param .=
'&date_endyear='.$date_endyear;
747 $param .=
'&in_bookkeeping='.$in_bookkeeping;
748 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
759$form =
new Form($db);
762if ($action ==
'exportcsv') {
766 $filename =
'journal';
767 $type_export =
'journal';
768 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
770 $companystatic =
new Client($db);
771 $invoicestatic =
new Facture($db);
773 foreach ($tabfac as $key => $val) {
774 $companystatic->id = $tabcompany[$key][
'id'];
775 $companystatic->name = $tabcompany[$key][
'name'];
776 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
777 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
778 $companystatic->code_client = $tabcompany[$key][
'code_client'];
779 $companystatic->client = 3;
781 $invoicestatic->id = $key;
782 $invoicestatic->ref = (string) $val[
"ref"];
783 $invoicestatic->type = $val[
"type"];
784 $invoicestatic->close_code = $val[
"close_code"];
789 $replacedinvoice = 0;
790 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
791 $replacedinvoice = 1;
792 $alreadydispatched = $invoicestatic->getVentilExportCompta();
793 if ($alreadydispatched) {
794 $replacedinvoice = 2;
799 if ($replacedinvoice == 1) {
804 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key])) {
805 foreach ($tabwarranty[$key] as $k => $mt) {
807 print
'"' . $key .
'"' . $sep;
808 print
'"' . $date .
'"' . $sep;
809 print
'"' . $val[
"ref"] .
'"' . $sep;
810 print
'"' . utf8_decode(
dol_trunc($companystatic->name, 32)) .
'"' . $sep;
814 print
'"' . $langs->trans(
"Thirdparty") .
'"' . $sep;
815 print
'"' . utf8_decode(
dol_trunc($companystatic->name, 16)) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"Retainedwarranty") .
'"' . $sep;
816 print
'"' . ($mt >= 0 ?
price($mt) :
'') .
'"' . $sep;
817 print
'"' . ($mt < 0 ?
price(-$mt) :
'') .
'"' . $sep;
818 print
'"' . $journal .
'"';
825 foreach ($tabttc[$key] as $k => $mt) {
827 print
'"'.$key.
'"'.$sep;
828 print
'"'.$date.
'"'.$sep;
829 print
'"'.$val[
"ref"].
'"'.$sep;
830 print
'"'.utf8_decode(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
831 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
832 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER')).
'"'.$sep;
833 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
834 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
835 print
'"'.utf8_decode(
dol_trunc($companystatic->name, 16)).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"Thirdparty").
'"'.$sep;
836 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
837 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
838 print
'"'.$journal.
'"';
844 foreach ($tabht[$key] as $k => $mt) {
846 $accountingaccount->fetch(
null, $k,
true);
848 print
'"'.$key.
'"'.$sep;
849 print
'"'.$date.
'"'.$sep;
850 print
'"'.$val[
"ref"].
'"'.$sep;
851 print
'"'.utf8_decode(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
852 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
853 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
855 print
'"'.utf8_decode(
dol_trunc($accountingaccount->label, 32)).
'"'.$sep;
856 print
'"'.utf8_decode(
dol_trunc($companystatic->name, 16)).
' - '.
dol_trunc($accountingaccount->label, 32).
'"'.$sep;
857 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
858 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
859 print
'"'.$journal.
'"';
865 $listoftax = array(0, 1, 2);
866 foreach ($listoftax as $numtax) {
867 $arrayofvat = $tabtva;
869 $arrayofvat = $tablocaltax1;
872 $arrayofvat = $tablocaltax2;
875 foreach ($arrayofvat[$key] as $k => $mt) {
877 print
'"'.$key.
'"'.$sep;
878 print
'"'.$date.
'"'.$sep;
879 print
'"'.$val[
"ref"].
'"'.$sep;
880 print
'"'.utf8_decode(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
881 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
882 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
884 print
'"'.$langs->trans(
"VAT").
' - '.join(
', ', $def_tva[$key][$k]).
' %"'.$sep;
885 print
'"'.utf8_decode(
dol_trunc($companystatic->name, 16)).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"VAT").join(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'').
'"'.$sep;
886 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
887 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
888 print
'"'.$journal.
'"';
895 if (isset($tabrevenuestamp[$key])) {
896 foreach ($tabrevenuestamp[$key] as $k => $mt) {
898 print
'"' . $key .
'"' . $sep;
899 print
'"' . $date .
'"' . $sep;
900 print
'"' . $val[
"ref"] .
'"' . $sep;
901 print
'"' . utf8_decode(
dol_trunc($companystatic->name, 32)) .
'"' . $sep;
905 print
'"' . $langs->trans(
"RevenueStamp") .
'"' . $sep;
906 print
'"' . utf8_decode(
dol_trunc($companystatic->name, 16)) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"RevenueStamp") .
'"' . $sep;
907 print
'"' . ($mt < 0 ?
price(-$mt) :
'') .
'"' . $sep;
908 print
'"' . ($mt >= 0 ?
price($mt) :
'') .
'"' . $sep;
909 print
'"' . $journal .
'"';
919if (empty($action) || $action ==
'view') {
920 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
929 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
931 $description .= $langs->trans(
"DepositsAreNotIncluded");
933 $description .= $langs->trans(
"DepositsAreIncluded");
936 $listofchoices = array(
'notyet'=>$langs->trans(
"NotYetInGeneralLedger"),
'already'=>$langs->trans(
"AlreadyInGeneralLedger"));
937 $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);
938 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
940 $varlink =
'id_journal='.$id_journal;
942 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
945 $acctCustomerNotConfigured = in_array(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'), [
'',
'-1']);
946 if ($acctCustomerNotConfigured) {
947 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
948 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
949 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
953 print
'<div class="tabsAction tabsActionNoBottom centerimp">';
954 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
955 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
957 if ($acctCustomerNotConfigured) {
958 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
960 if ($in_bookkeeping ==
'notyet') {
961 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
963 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
970 <script type="text/javascript">
971 function launch_export() {
972 $("div.fiche form input[name=\"action\"]").val("exportcsv");
973 $("div.fiche form input[type=\"submit\"]").click();
974 $("div.fiche form input[name=\"action\"]").val("");
976 function writebookkeeping() {
977 console.log("click on writebookkeeping");
978 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
979 $("div.fiche form input[type=\"submit\"]").click();
980 $("div.fiche form input[name=\"action\"]").val("");
989 print
'<div class="div-table-responsive">';
990 print
"<table class=\"noborder\" width=\"100%\">";
991 print
"<tr class=\"liste_titre\">";
992 print
"<td>".$langs->trans(
"Date").
"</td>";
993 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"InvoiceRef").
")</td>";
994 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
995 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
996 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
997 print
'<td class="center">'.$langs->trans(
"AccountingDebit").
"</td>";
998 print
'<td class="center">'.$langs->trans(
"AccountingCredit").
"</td>";
1003 $companystatic =
new Client($db);
1004 $invoicestatic =
new Facture($db);
1006 foreach ($tabfac as $key => $val) {
1007 $companystatic->id = $tabcompany[$key][
'id'];
1008 $companystatic->name = $tabcompany[$key][
'name'];
1009 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
1010 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
1011 $companystatic->code_client = $tabcompany[$key][
'code_client'];
1012 $companystatic->client = 3;
1014 $invoicestatic->id = $key;
1015 $invoicestatic->ref = (string) $val[
"ref"];
1016 $invoicestatic->type = $val[
"type"];
1017 $invoicestatic->close_code = $val[
"close_code"];
1022 $replacedinvoice = 0;
1023 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
1024 $replacedinvoice = 1;
1025 $alreadydispatched = $invoicestatic->getVentilExportCompta();
1026 if ($alreadydispatched) {
1027 $replacedinvoice = 2;
1032 if ($replacedinvoice == 1) {
1033 print
'<tr class="oddeven">';
1034 print
"<!-- Replaced invoice -->";
1035 print
"<td>".$date.
"</td>";
1036 print
"<td><strike>".$invoicestatic->getNomUrl(1).
"</strike></td>";
1039 print $langs->trans(
"Replaced");
1046 print
'<td class="right"></td>';
1047 print
'<td class="right"></td>';
1053 if ($errorforinvoice[$key] ==
'somelinesarenotbound') {
1054 print
'<tr class="oddeven">';
1055 print
"<!-- Some lines are not bound -->";
1056 print
"<td>".$date.
"</td>";
1057 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1060 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $val[
'ref']).
'</span>';
1067 print
'<td class="right"></td>';
1068 print
'<td class="right"></td>';
1075 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key])) {
1076 foreach ($tabwarranty[$key] as $k => $mt) {
1077 print
'<tr class="oddeven">';
1078 print
"<!-- Thirdparty warranty -->";
1079 print
"<td>" . $date .
"</td>";
1080 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1084 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1085 print
'<span class="error">' . $langs->trans(
"MainAccountForRetainedWarrantyNotDefined") .
'</span>';
1087 print $accountoshow;
1093 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1094 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1096 print $accountoshow;
1099 print
"<td>" . $companystatic->getNomUrl(0,
'customer', 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"Retainedwarranty") .
"</td>";
1100 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1101 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1107 foreach ($tabttc[$key] as $k => $mt) {
1108 print
'<tr class="oddeven">';
1109 print
"<!-- Thirdparty -->";
1110 print
"<td>".$date.
"</td>";
1111 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1115 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1116 print
'<span class="error">'.$langs->trans(
"MainAccountForCustomersNotDefined").
'</span>';
1118 print $accountoshow;
1124 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1125 print
'<span class="error">'.$langs->trans(
"ThirdpartyAccountNotDefined").
'</span>';
1127 print $accountoshow;
1130 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"SubledgerAccount").
"</td>";
1131 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1132 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1139 foreach ($tabht[$key] as $k => $mt) {
1141 $accountingaccount->fetch(
null, $k,
true);
1143 print
'<tr class="oddeven">';
1144 print
"<!-- Product -->";
1145 print
"<td>".$date.
"</td>";
1146 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1150 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1151 print
'<span class="error">'.$langs->trans(
"ProductNotDefined").
'</span>';
1153 print $accountoshow;
1162 } elseif (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1163 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1166 $companystatic->id = $tabcompany[$key][
'id'];
1167 $companystatic->name = $tabcompany[$key][
'name'];
1168 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref.
' - '.$accountingaccount->label.
"</td>";
1169 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1170 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1177 $listoftax = array(0, 1, 2);
1178 foreach ($listoftax as $numtax) {
1179 $arrayofvat = $tabtva;
1181 $arrayofvat = $tablocaltax1;
1184 $arrayofvat = $tablocaltax2;
1188 foreach ($arrayofvat[$key] as $k => $mt) {
1190 print
'<tr class="oddeven">';
1191 print
"<!-- VAT -->";
1192 print
"<td>".$date.
"</td>";
1193 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1197 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1198 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"AccountingJournalType2").
')</span>';
1200 print $accountoshow;
1206 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref;
1209 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : join(
', ', $def_tva[$key][$k]));
1210 print
' - '.$langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
1211 print ($numtax ?
' - Localtax '.$numtax :
'');
1213 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1214 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1223 if (isset($tabrevenuestamp[$key])) {
1224 foreach ($tabrevenuestamp[$key] as $k => $mt) {
1225 print
'<tr class="oddeven">';
1226 print
"<!-- Thirdparty revenuestamp -->";
1227 print
"<td>" . $date .
"</td>";
1228 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1232 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1233 print
'<span class="error">' . $langs->trans(
"MainAccountForRevenueStampSaleNotDefined") .
'</span>';
1235 print $accountoshow;
1241 print
"<td>" . $companystatic->getNomUrl(0,
'customer', 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"RevenueStamp") .
"</td>";
1242 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1243 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1250 print
'<tr class="oddeven"><td colspan="6"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
getDefaultDatesForTransfer()
Return Default dates for transfer based on periodicity option in accountancy setup.
journalHead($nom, $variante, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
Show header of a page used to transfer/dispatch data in accounting.
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage accounting accounts.
Class to manage accounting accounts.
Class to manage Ledger (General Ledger and Subledger)
Class to manage customers or prospects.
Class to manage invoices.
const TYPE_REPLACEMENT
Replacement invoice.
const TYPE_SITUATION
Situation invoice.
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
Class to manage invoice lines.
Class to manage third parties objects (customers, suppliers, prospects...)
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 informations (by default a local PHP server timestamp) Re...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages.
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 '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getTaxesFromId($vatrate, $buyer=null, $seller=null, $firstparamisid=1)
Get tax (VAT) main information from Id.
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_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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 dolibarr global constant string value.
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.