34 require
'../../main.inc.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
39 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
40 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
41 require_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
42 require_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');
57 if ($in_bookkeeping ==
'') {
58 $in_bookkeeping =
'notyet';
63 $hookmanager->initHooks(array(
'sellsjournal'));
64 $parameters = array();
70 if ($user->socid > 0) {
73 if (!$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);
95 if (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'];
104 if (!
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)";
145 if ($date_start && $date_end) {
146 $sql .=
" AND f.datef >= '".$db->idate($date_start).
"' AND f.datef <= '".$db->idate($date_end).
"'";
153 if ($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')";
157 if ($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";
164 dol_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();
332 foreach ($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';
351 if ($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) {
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 foreach ($tabrevenuestamp[$key] as $k => $mt) {
654 $accountingaccount->fetch(
null, $k,
true);
655 $label_account = $accountingaccount->label;
658 $bookkeeping->doc_date = $val[
"date"];
659 $bookkeeping->date_lim_reglement = $val[
"datereg"];
660 $bookkeeping->doc_ref = $val[
"ref"];
661 $bookkeeping->date_creation = $now;
662 $bookkeeping->doc_type =
'customer_invoice';
663 $bookkeeping->fk_doc = $key;
664 $bookkeeping->fk_docdet = 0;
665 $bookkeeping->thirdparty_code = $companystatic->code_client;
667 $bookkeeping->subledger_account =
'';
668 $bookkeeping->subledger_label =
'';
670 $bookkeeping->numero_compte = $k;
671 $bookkeeping->label_compte = $label_account;
673 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"RevenueStamp");
674 $bookkeeping->montant = $mt;
675 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
676 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
677 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
678 $bookkeeping->code_journal = $journal;
679 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
680 $bookkeeping->fk_user_author = $user->id;
681 $bookkeeping->entity = $conf->entity;
683 $totaldebit += $bookkeeping->debit;
684 $totalcredit += $bookkeeping->credit;
686 $result = $bookkeeping->create($user);
688 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
691 $errorforinvoice[$key] =
'alreadyjournalized';
696 $errorforinvoice[$key] =
'other';
705 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
708 $errorforinvoice[$key] =
'amountsnotbalanced';
709 setEventMessages(
'We Tried to insert a non balanced transaction in book for '.$invoicestatic->ref.
'. Canceled. Surely a bug.',
null,
'errors');
712 if (!$errorforline) {
718 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
726 if (empty($error) && count($tabpay) > 0) {
728 } elseif (count($tabpay) == $error) {
731 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
737 if (count($tabpay) != $error) {
738 $param =
'id_journal='.$id_journal;
739 $param .=
'&date_startday='.$date_startday;
740 $param .=
'&date_startmonth='.$date_startmonth;
741 $param .=
'&date_startyear='.$date_startyear;
742 $param .=
'&date_endday='.$date_endday;
743 $param .=
'&date_endmonth='.$date_endmonth;
744 $param .=
'&date_endyear='.$date_endyear;
745 $param .=
'&in_bookkeeping='.$in_bookkeeping;
746 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
760 if ($action ==
'exportcsv') {
764 $filename =
'journal';
765 $type_export =
'journal';
766 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
768 $companystatic =
new Client($db);
769 $invoicestatic =
new Facture($db);
771 foreach ($tabfac as $key => $val) {
772 $companystatic->id = $tabcompany[$key][
'id'];
773 $companystatic->name = $tabcompany[$key][
'name'];
774 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
775 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
776 $companystatic->code_client = $tabcompany[$key][
'code_client'];
777 $companystatic->client = 3;
779 $invoicestatic->id = $key;
780 $invoicestatic->ref = (string) $val[
"ref"];
781 $invoicestatic->type = $val[
"type"];
782 $invoicestatic->close_code = $val[
"close_code"];
787 $replacedinvoice = 0;
788 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
789 $replacedinvoice = 1;
790 $alreadydispatched = $invoicestatic->getVentilExportCompta();
791 if ($alreadydispatched) {
792 $replacedinvoice = 2;
797 if ($replacedinvoice == 1) {
802 foreach ($tabwarranty[$key] as $k => $mt) {
804 print
'"'.$key.
'"'.$sep;
805 print
'"'.$date.
'"'.$sep;
806 print
'"'.$val[
"ref"].
'"'.$sep;
807 print
'"'.utf8_decode(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
808 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
809 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY')).
'"'.$sep;
810 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
811 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
812 print
'"'.utf8_decode(
dol_trunc($companystatic->name, 16)).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"Retainedwarranty").
'"'.$sep;
813 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
814 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
815 print
'"'.$journal.
'"';
821 foreach ($tabttc[$key] as $k => $mt) {
823 print
'"'.$key.
'"'.$sep;
824 print
'"'.$date.
'"'.$sep;
825 print
'"'.$val[
"ref"].
'"'.$sep;
826 print
'"'.utf8_decode(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
827 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
828 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER')).
'"'.$sep;
829 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
830 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
831 print
'"'.utf8_decode(
dol_trunc($companystatic->name, 16)).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"Thirdparty").
'"'.$sep;
832 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
833 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
834 print
'"'.$journal.
'"';
840 foreach ($tabht[$key] as $k => $mt) {
842 $accountingaccount->fetch(
null, $k,
true);
844 print
'"'.$key.
'"'.$sep;
845 print
'"'.$date.
'"'.$sep;
846 print
'"'.$val[
"ref"].
'"'.$sep;
847 print
'"'.utf8_decode(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
848 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
849 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
851 print
'"'.utf8_decode(
dol_trunc($accountingaccount->label, 32)).
'"'.$sep;
852 print
'"'.utf8_decode(
dol_trunc($companystatic->name, 16)).
' - '.
dol_trunc($accountingaccount->label, 32).
'"'.$sep;
853 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
854 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
855 print
'"'.$journal.
'"';
861 $listoftax = array(0, 1, 2);
862 foreach ($listoftax as $numtax) {
863 $arrayofvat = $tabtva;
865 $arrayofvat = $tablocaltax1;
868 $arrayofvat = $tablocaltax2;
871 foreach ($arrayofvat[$key] as $k => $mt) {
873 print
'"'.$key.
'"'.$sep;
874 print
'"'.$date.
'"'.$sep;
875 print
'"'.$val[
"ref"].
'"'.$sep;
876 print
'"'.utf8_decode(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
877 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
878 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
880 print
'"'.$langs->trans(
"VAT").
' - '.join(
', ', $def_tva[$key][$k]).
' %"'.$sep;
881 print
'"'.utf8_decode(
dol_trunc($companystatic->name, 16)).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"VAT").join(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'').
'"'.$sep;
882 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
883 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
884 print
'"'.$journal.
'"';
891 foreach ($tabrevenuestamp[$key] as $k => $mt) {
893 print
'"'.$key.
'"'.$sep;
894 print
'"'.$date.
'"'.$sep;
895 print
'"'.$val[
"ref"].
'"'.$sep;
896 print
'"'.utf8_decode(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
897 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
898 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
900 print
'"'.$langs->trans(
"RevenueStamp").
'"'.$sep;
901 print
'"'.utf8_decode(
dol_trunc($companystatic->name, 16)).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"RevenueStamp").
'"'.$sep;
902 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
903 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
904 print
'"'.$journal.
'"';
913 if (empty($action) || $action ==
'view') {
914 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
923 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
925 $description .= $langs->trans(
"DepositsAreNotIncluded");
927 $description .= $langs->trans(
"DepositsAreIncluded");
930 $listofchoices = array(
'notyet'=>$langs->trans(
"NotYetInGeneralLedger"),
'already'=>$langs->trans(
"AlreadyInGeneralLedger"));
931 $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);
932 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.
$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
934 $varlink =
'id_journal='.$id_journal;
936 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
939 $acctCustomerNotConfigured = in_array(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'), [
'',
'-1']);
940 if ($acctCustomerNotConfigured) {
941 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
942 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
943 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
947 print
'<div class="tabsAction tabsActionNoBottom centerimp">';
948 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
949 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
951 if ($acctCustomerNotConfigured) {
952 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
954 if ($in_bookkeeping ==
'notyet') {
955 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
957 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
964 <script type="text/javascript">
965 function launch_export() {
966 $("div.fiche form input[name=\"action\"]").val("exportcsv");
967 $("div.fiche form input[type=\"submit\"]").click();
968 $("div.fiche form input[name=\"action\"]").val("");
970 function writebookkeeping() {
971 console.log("click on writebookkeeping");
972 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
973 $("div.fiche form input[type=\"submit\"]").click();
974 $("div.fiche form input[name=\"action\"]").val("");
983 print
'<div class="div-table-responsive">';
984 print
"<table class=\"noborder\" width=\"100%\">";
985 print
"<tr class=\"liste_titre\">";
986 print
"<td>".$langs->trans(
"Date").
"</td>";
987 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"InvoiceRef").
")</td>";
988 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
989 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
990 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
991 print
'<td class="center">'.$langs->trans(
"AccountingDebit").
"</td>";
992 print
'<td class="center">'.$langs->trans(
"AccountingCredit").
"</td>";
997 $companystatic =
new Client($db);
998 $invoicestatic =
new Facture($db);
1000 foreach ($tabfac as $key => $val) {
1001 $companystatic->id = $tabcompany[$key][
'id'];
1002 $companystatic->name = $tabcompany[$key][
'name'];
1003 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
1004 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
1005 $companystatic->code_client = $tabcompany[$key][
'code_client'];
1006 $companystatic->client = 3;
1008 $invoicestatic->id = $key;
1009 $invoicestatic->ref = (string) $val[
"ref"];
1010 $invoicestatic->type = $val[
"type"];
1011 $invoicestatic->close_code = $val[
"close_code"];
1016 $replacedinvoice = 0;
1017 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
1018 $replacedinvoice = 1;
1019 $alreadydispatched = $invoicestatic->getVentilExportCompta();
1020 if ($alreadydispatched) {
1021 $replacedinvoice = 2;
1026 if ($replacedinvoice == 1) {
1027 print
'<tr class="oddeven">';
1028 print
"<!-- Replaced invoice -->";
1029 print
"<td>".$date.
"</td>";
1030 print
"<td><strike>".$invoicestatic->getNomUrl(1).
"</strike></td>";
1033 print $langs->trans(
"Replaced");
1040 print
'<td class="right"></td>';
1041 print
'<td class="right"></td>';
1047 if ($errorforinvoice[$key] ==
'somelinesarenotbound') {
1048 print
'<tr class="oddeven">';
1049 print
"<!-- Some lines are not bound -->";
1050 print
"<td>".$date.
"</td>";
1051 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1054 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $val[
'ref']).
'</span>';
1061 print
'<td class="right"></td>';
1062 print
'<td class="right"></td>';
1069 foreach ($tabwarranty[$key] as $k => $mt) {
1070 print
'<tr class="oddeven">';
1071 print
"<!-- Thirdparty warranty -->";
1072 print
"<td>".$date.
"</td>";
1073 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1077 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1078 print
'<span class="error">'.$langs->trans(
"MainAccountForRetainedWarrantyNotDefined").
'</span>';
1080 print $accountoshow;
1086 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1087 print
'<span class="error">'.$langs->trans(
"ThirdpartyAccountNotDefined").
'</span>';
1089 print $accountoshow;
1092 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"Retainedwarranty").
"</td>";
1093 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1094 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1099 foreach ($tabttc[$key] as $k => $mt) {
1100 print
'<tr class="oddeven">';
1101 print
"<!-- Thirdparty -->";
1102 print
"<td>".$date.
"</td>";
1103 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1107 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1108 print
'<span class="error">'.$langs->trans(
"MainAccountForCustomersNotDefined").
'</span>';
1110 print $accountoshow;
1116 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1117 print
'<span class="error">'.$langs->trans(
"ThirdpartyAccountNotDefined").
'</span>';
1119 print $accountoshow;
1122 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"SubledgerAccount").
"</td>";
1123 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1124 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1131 foreach ($tabht[$key] as $k => $mt) {
1133 $accountingaccount->fetch(
null, $k,
true);
1135 print
'<tr class="oddeven">';
1136 print
"<!-- Product -->";
1137 print
"<td>".$date.
"</td>";
1138 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1142 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1143 print
'<span class="error">'.$langs->trans(
"ProductNotDefined").
'</span>';
1145 print $accountoshow;
1154 } elseif (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1155 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1158 $companystatic->id = $tabcompany[$key][
'id'];
1159 $companystatic->name = $tabcompany[$key][
'name'];
1160 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref.
' - '.$accountingaccount->label.
"</td>";
1161 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1162 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1169 $listoftax = array(0, 1, 2);
1170 foreach ($listoftax as $numtax) {
1171 $arrayofvat = $tabtva;
1173 $arrayofvat = $tablocaltax1;
1176 $arrayofvat = $tablocaltax2;
1180 foreach ($arrayofvat[$key] as $k => $mt) {
1182 print
'<tr class="oddeven">';
1183 print
"<!-- VAT -->";
1184 print
"<td>".$date.
"</td>";
1185 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1189 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1190 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"AccountingJournalType2").
')</span>';
1192 print $accountoshow;
1198 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref;
1201 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : join(
', ', $def_tva[$key][$k]));
1202 print
' - '.$langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
1203 print ($numtax ?
' - Localtax '.$numtax :
'');
1205 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1206 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1215 foreach ($tabrevenuestamp[$key] as $k => $mt) {
1216 print
'<tr class="oddeven">';
1217 print
"<!-- Thirdparty revenuestamp -->";
1218 print
"<td>".$date.
"</td>";
1219 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1223 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1224 print
'<span class="error">'.$langs->trans(
"MainAccountForRevenueStampSaleNotDefined").
'</span>';
1226 print $accountoshow;
1232 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"RevenueStamp").
"</td>";
1233 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1234 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1240 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...)
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.