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')) {
84$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $user, $action);
90$accountingjournalstatic->fetch($id_journal);
91$journal = $accountingjournalstatic->code;
92$journal_label = $accountingjournalstatic->label;
94$date_start =
dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
95$date_end =
dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
97if (empty($date_startmonth)) {
100 $date_start = $dates[
'date_start'];
101 $pastmonthyear = $dates[
'pastmonthyear'];
102 $pastmonth = $dates[
'pastmonth'];
104if (empty($date_endmonth)) {
107 $date_end = $dates[
'date_end'];
108 $pastmonthyear = $dates[
'pastmonthyear'];
109 $pastmonth = $dates[
'pastmonth'];
115if (!GETPOSTISSET(
'date_startmonth') && (empty($date_start) || empty($date_end))) {
120$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,";
121$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,";
122$sql .=
" s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur,";
124 $sql .=
" spe.accountancy_code_customer as code_compta,";
125 $sql .=
" spe.accountancy_code_supplier as code_compta_fournisseur,";
127 $sql .=
" s.code_compta as code_compta,";
128 $sql .=
" s.code_compta_fournisseur,";
130$sql .=
" p.rowid as pid, p.ref as pref, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,";
132 $sql .=
" ppe.accountancy_code_sell";
134 $sql .=
" p.accountancy_code_sell";
136$parameters = array();
137$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
138$sql .= $hookmanager->resPrint;
139$sql .=
" FROM ".MAIN_DB_PREFIX.
"facturedet as fd";
140$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = fd.fk_product";
142 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
144$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
145$sql .=
" JOIN ".MAIN_DB_PREFIX.
"facture as f ON f.rowid = fd.fk_facture";
146$sql .=
" JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = f.fk_soc";
148 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
150$parameters = array();
151$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters);
152$sql .= $hookmanager->resPrint;
153$sql .=
" WHERE fd.fk_code_ventilation > 0";
154$sql .=
" AND f.entity IN (".getEntity(
'invoice', 0).
')';
155$sql .=
" AND f.fk_statut > 0";
161$sql .=
" AND fd.product_type IN (0,1)";
162if ($date_start && $date_end) {
163 $sql .=
" AND f.datef >= '".$db->idate($date_start).
"' AND f.datef <= '".$db->idate($date_end).
"'";
167 $sql .=
" AND f.datef >= '".$db->idate(
getDolGlobalString(
'ACCOUNTING_DATE_START_BINDING')).
"'";
170if ($in_bookkeeping ==
'already') {
171 $sql .=
" AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
174if ($in_bookkeeping ==
'notyet') {
175 $sql .=
" AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
178$parameters = array();
179$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
180$sql .= $hookmanager->resPrint;
181$sql .=
" ORDER BY f.datef, f.ref";
184dol_syslog(
'accountancy/journal/sellsjournal.php', LOG_DEBUG);
185$result = $db->query($sql);
191 $tabwarranty = array();
192 $tabrevenuestamp = array();
194 $tablocaltax1 = array();
195 $tablocaltax2 = array();
196 $tabcompany = array();
197 $vatdata_cache = array();
199 $num = $db->num_rows($result);
207 $obj = $db->fetch_object($result);
210 $compta_soc = (!empty($obj->code_compta)) ? $obj->code_compta : $cptcli;
212 $compta_prod = $obj->compte;
213 if (empty($compta_prod)) {
214 if ($obj->product_type == 0) {
223 $tax_id = $obj->tva_tx . ($obj->vat_src_code ?
' (' . $obj->vat_src_code .
')' :
'');
224 if (array_key_exists($tax_id, $vatdata_cache)) {
225 $vatdata = $vatdata_cache[$tax_id];
230 $buyer->fetch($obj->socid);
236 $vatdata_cache[$tax_id] = $vatdata;
238 $compta_tva = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
239 $compta_localtax1 = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
240 $compta_localtax2 = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
243 if (
price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
244 $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.
')' :
''));
248 $situation_ratio = 1;
250 if ($obj->situation_cycle_ref) {
252 if ($obj->situation_percent == 0) {
253 $situation_ratio = 0;
256 $line->fetch($obj->fdid);
259 $prev_progress = $line->get_prev_progress($obj->rowid);
261 $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
266 $revenuestamp = (float)
price2num($obj->revenuestamp,
'MT');
269 $tabfac[$obj->rowid][
"date"] = $db->jdate($obj->df);
270 $tabfac[$obj->rowid][
"datereg"] = $db->jdate($obj->dlr);
271 $tabfac[$obj->rowid][
"ref"] = $obj->ref;
272 $tabfac[$obj->rowid][
"type"] = $obj->type;
273 $tabfac[$obj->rowid][
"description"] = $obj->label_compte;
274 $tabfac[$obj->rowid][
"close_code"] = $obj->close_code;
275 $tabfac[$obj->rowid][
"revenuestamp"] = $revenuestamp;
279 if (!isset($tabttc[$obj->rowid][$compta_soc])) {
280 $tabttc[$obj->rowid][$compta_soc] = 0;
282 if (!isset($tabht[$obj->rowid][$compta_prod])) {
283 $tabht[$obj->rowid][$compta_prod] = 0;
285 if (!isset($tabtva[$obj->rowid][$compta_tva])) {
286 $tabtva[$obj->rowid][$compta_tva] = 0;
288 if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
289 $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
291 if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) {
292 $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
301 $total_ttc = $obj->total_ttc * $situation_ratio;
303 $total_ttc = $obj->total_ttc;
307 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && $obj->retained_warranty > 0) {
308 $retained_warranty = (float)
price2num($total_ttc * $obj->retained_warranty / 100,
'MT');
309 $tabwarranty[$obj->rowid][$compta_soc] += $retained_warranty;
310 $total_ttc -= $retained_warranty;
313 $tabttc[$obj->rowid][$compta_soc] += $total_ttc;
314 $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
315 $tva_npr = (($obj->info_bits & 1 == 1) ? 1 : 0);
317 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio;
319 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio;
320 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio;
322 $compta_revenuestamp =
'NotDefined';
323 if (!empty($revenuestamp)) {
324 $sqlrevenuestamp =
"SELECT accountancy_code_sell FROM ".MAIN_DB_PREFIX.
"c_revenuestamp";
325 $sqlrevenuestamp .=
" WHERE fk_pays = ".((int) $mysoc->country_id);
326 $sqlrevenuestamp .=
" AND taux = ".((float) $revenuestamp);
327 $sqlrevenuestamp .=
" AND active = 1";
328 $resqlrevenuestamp = $db->query($sqlrevenuestamp);
330 if ($resqlrevenuestamp) {
331 $num_rows_revenuestamp = $db->num_rows($resqlrevenuestamp);
332 if ($num_rows_revenuestamp > 1) {
333 dol_print_error($db,
'Failed 2 or more lines for the revenue stamp of your country. Check the dictionary of revenue stamp.');
335 $objrevenuestamp = $db->fetch_object($resqlrevenuestamp);
336 if ($objrevenuestamp) {
337 $compta_revenuestamp = $objrevenuestamp->accountancy_code_sell;
343 if (empty($tabrevenuestamp[$obj->rowid][$compta_revenuestamp]) && !empty($revenuestamp)) {
345 $tabttc[$obj->rowid][$compta_soc] += $obj->revenuestamp;
346 $tabrevenuestamp[$obj->rowid][$compta_revenuestamp] = $obj->revenuestamp;
349 $tabcompany[$obj->rowid] = array(
351 'name' => $obj->name,
352 'code_client' => $obj->code_client,
353 'code_compta' => $compta_soc
365if (count($tabfac) > 10000) {
367 setEventMessages(
"TooManyInvoicesToProcessPleaseUseAMoreSelectiveFilter",
null,
'errors');
370$errorforinvoice = array();
393if (!empty($tabfac)) {
397 COUNT(fd.rowid) as nb
399 ".MAIN_DB_PREFIX.
"facturedet as fd
402 AND fd.fk_code_ventilation <= 0
403 AND fd.total_ttc <> 0
404 AND fk_facture IN (".$db->sanitize(join(
",", array_keys($tabfac))).
")
407 $resql = $db->query($sql);
409 $num = $db->num_rows($resql);
412 $obj = $db->fetch_object($resql);
414 $errorforinvoice[$obj->fk_facture] =
'somelinesarenotbound';
423if ($action ==
'writebookkeeping' && !$error) {
427 $companystatic =
new Societe($db);
428 $invoicestatic =
new Facture($db);
431 $accountingaccountcustomer->fetch(
null,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'),
true);
435 $accountingaccountcustomerwarranty->fetch(
null,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'),
true);
437 foreach ($tabfac as $key => $val) {
445 $companystatic->id = $tabcompany[$key][
'id'];
446 $companystatic->name = $tabcompany[$key][
'name'];
447 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
448 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
449 $companystatic->code_client = $tabcompany[$key][
'code_client'];
450 $companystatic->client = 3;
452 $invoicestatic->id = $key;
453 $invoicestatic->ref = (string) $val[
"ref"];
454 $invoicestatic->type = $val[
"type"];
455 $invoicestatic->close_code = $val[
"close_code"];
460 $replacedinvoice = 0;
461 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
462 $replacedinvoice = 1;
463 $alreadydispatched = $invoicestatic->getVentilExportCompta();
464 if ($alreadydispatched) {
465 $replacedinvoice = 2;
470 if ($replacedinvoice == 1) {
476 if ($errorforinvoice[$key] ==
'somelinesarenotbound') {
479 setEventMessages($langs->trans(
'ErrorInvoiceContainsLinesNotYetBounded', $val[
'ref']),
null,
'errors');
483 if (!$errorforline &&
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key])) {
484 if (is_array($tabwarranty[$key])) {
485 foreach ($tabwarranty[$key] as $k => $mt) {
487 $bookkeeping->doc_date = $val[
"date"];
488 $bookkeeping->date_lim_reglement = $val[
"datereg"];
489 $bookkeeping->doc_ref = $val[
"ref"];
490 $bookkeeping->date_creation = $now;
491 $bookkeeping->doc_type =
'customer_invoice';
492 $bookkeeping->fk_doc = $key;
493 $bookkeeping->fk_docdet = 0;
494 $bookkeeping->thirdparty_code = $companystatic->code_client;
496 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
497 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
499 $bookkeeping->numero_compte =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY');
500 $bookkeeping->label_compte = $accountingaccountcustomerwarranty->label;
502 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"Retainedwarranty");
503 $bookkeeping->montant = $mt;
504 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
505 $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
506 $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
507 $bookkeeping->code_journal = $journal;
508 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
509 $bookkeeping->fk_user_author = $user->id;
510 $bookkeeping->entity = $conf->entity;
512 $totaldebit += $bookkeeping->debit;
513 $totalcredit += $bookkeeping->credit;
515 $result = $bookkeeping->create($user);
517 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
520 $errorforinvoice[$key] =
'alreadyjournalized';
525 $errorforinvoice[$key] =
'other';
534 if (!$errorforline) {
535 foreach ($tabttc[$key] as $k => $mt) {
537 $bookkeeping->doc_date = $val[
"date"];
538 $bookkeeping->date_lim_reglement = $val[
"datereg"];
539 $bookkeeping->doc_ref = $val[
"ref"];
540 $bookkeeping->date_creation = $now;
541 $bookkeeping->doc_type =
'customer_invoice';
542 $bookkeeping->fk_doc = $key;
543 $bookkeeping->fk_docdet = 0;
544 $bookkeeping->thirdparty_code = $companystatic->code_client;
546 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
547 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
550 $bookkeeping->label_compte = $accountingaccountcustomer->label;
552 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"SubledgerAccount");
553 $bookkeeping->montant = $mt;
554 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
555 $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
556 $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
557 $bookkeeping->code_journal = $journal;
558 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
559 $bookkeeping->fk_user_author = $user->id;
560 $bookkeeping->entity = $conf->entity;
562 $totaldebit += $bookkeeping->debit;
563 $totalcredit += $bookkeeping->credit;
565 $result = $bookkeeping->create($user);
567 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
570 $errorforinvoice[$key] =
'alreadyjournalized';
575 $errorforinvoice[$key] =
'other';
580 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
583 $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id));
590 if (!$errorforline) {
591 foreach ($tabht[$key] as $k => $mt) {
592 $resultfetch = $accountingaccount->fetch(
null, $k,
true);
593 $label_account = $accountingaccount->label;
596 if ($resultfetch > 0) {
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;
609 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
610 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
612 $bookkeeping->subledger_account =
'';
613 $bookkeeping->subledger_label =
'';
616 $bookkeeping->subledger_account =
'';
617 $bookkeeping->subledger_label =
'';
620 $bookkeeping->numero_compte = $k;
621 $bookkeeping->label_compte = $label_account;
623 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref.
' - '.$label_account;
624 $bookkeeping->montant = $mt;
625 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
626 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
627 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
628 $bookkeeping->code_journal = $journal;
629 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
630 $bookkeeping->fk_user_author = $user->id;
631 $bookkeeping->entity = $conf->entity;
633 $totaldebit += $bookkeeping->debit;
634 $totalcredit += $bookkeeping->credit;
636 $result = $bookkeeping->create($user);
638 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
641 $errorforinvoice[$key] =
'alreadyjournalized';
646 $errorforinvoice[$key] =
'other';
655 if (!$errorforline) {
656 $listoftax = array(0, 1, 2);
657 foreach ($listoftax as $numtax) {
658 $arrayofvat = $tabtva;
660 $arrayofvat = $tablocaltax1;
663 $arrayofvat = $tablocaltax2;
666 foreach ($arrayofvat[$key] as $k => $mt) {
668 $accountingaccount->fetch(
null, $k,
true);
669 $label_account = $accountingaccount->label;
672 $bookkeeping->doc_date = $val[
"date"];
673 $bookkeeping->date_lim_reglement = $val[
"datereg"];
674 $bookkeeping->doc_ref = $val[
"ref"];
675 $bookkeeping->date_creation = $now;
676 $bookkeeping->doc_type =
'customer_invoice';
677 $bookkeeping->fk_doc = $key;
678 $bookkeeping->fk_docdet = 0;
679 $bookkeeping->thirdparty_code = $companystatic->code_client;
681 $bookkeeping->subledger_account =
'';
682 $bookkeeping->subledger_label =
'';
684 $bookkeeping->numero_compte = $k;
685 $bookkeeping->label_compte = $label_account;
688 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref;
689 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : join(
', ', $def_tva[$key][$k]));
690 $bookkeeping->label_operation .=
' - '.$langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
691 $bookkeeping->label_operation .= ($numtax ?
' - Localtax '.$numtax :
'');
693 $bookkeeping->montant = $mt;
694 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
695 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
696 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
697 $bookkeeping->code_journal = $journal;
698 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
699 $bookkeeping->fk_user_author = $user->id;
700 $bookkeeping->entity = $conf->entity;
702 $totaldebit += $bookkeeping->debit;
703 $totalcredit += $bookkeeping->credit;
705 $result = $bookkeeping->create($user);
707 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
710 $errorforinvoice[$key] =
'alreadyjournalized';
715 $errorforinvoice[$key] =
'other';
725 if (!$errorforline) {
726 if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) {
727 foreach ($tabrevenuestamp[$key] as $k => $mt) {
729 $accountingaccount->fetch(
null, $k,
true);
730 $label_account = $accountingaccount->label;
733 $bookkeeping->doc_date = $val[
"date"];
734 $bookkeeping->date_lim_reglement = $val[
"datereg"];
735 $bookkeeping->doc_ref = $val[
"ref"];
736 $bookkeeping->date_creation = $now;
737 $bookkeeping->doc_type =
'customer_invoice';
738 $bookkeeping->fk_doc = $key;
739 $bookkeeping->fk_docdet = 0;
740 $bookkeeping->thirdparty_code = $companystatic->code_client;
742 $bookkeeping->subledger_account =
'';
743 $bookkeeping->subledger_label =
'';
745 $bookkeeping->numero_compte = $k;
746 $bookkeeping->label_compte = $label_account;
748 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"RevenueStamp");
749 $bookkeeping->montant = $mt;
750 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
751 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
752 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
753 $bookkeeping->code_journal = $journal;
754 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
755 $bookkeeping->fk_user_author = $user->id;
756 $bookkeeping->entity = $conf->entity;
758 $totaldebit += $bookkeeping->debit;
759 $totalcredit += $bookkeeping->credit;
761 $result = $bookkeeping->create($user);
763 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
766 $errorforinvoice[$key] =
'alreadyjournalized';
771 $errorforinvoice[$key] =
'other';
781 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
784 $errorforinvoice[$key] =
'amountsnotbalanced';
785 setEventMessages(
'We Tried to insert a non balanced transaction in book for '.$invoicestatic->ref.
'. Canceled. Surely a bug.',
null,
'errors');
788 if (!$errorforline) {
794 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
802 if (empty($error) && count($tabpay) > 0) {
804 } elseif (count($tabpay) == $error) {
807 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
813 if (count($tabpay) != $error) {
814 $param =
'id_journal='.$id_journal;
815 $param .=
'&date_startday='.$date_startday;
816 $param .=
'&date_startmonth='.$date_startmonth;
817 $param .=
'&date_startyear='.$date_startyear;
818 $param .=
'&date_endday='.$date_endday;
819 $param .=
'&date_endmonth='.$date_endmonth;
820 $param .=
'&date_endyear='.$date_endyear;
821 $param .=
'&in_bookkeeping='.$in_bookkeeping;
822 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
833$form =
new Form($db);
836if ($action ==
'exportcsv' && !$error) {
840 $filename =
'journal';
841 $type_export =
'journal';
842 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
844 $companystatic =
new Client($db);
845 $invoicestatic =
new Facture($db);
847 foreach ($tabfac as $key => $val) {
848 $companystatic->id = $tabcompany[$key][
'id'];
849 $companystatic->name = $tabcompany[$key][
'name'];
850 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
851 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
852 $companystatic->code_client = $tabcompany[$key][
'code_client'];
853 $companystatic->client = 3;
855 $invoicestatic->id = $key;
856 $invoicestatic->ref = (string) $val[
"ref"];
857 $invoicestatic->type = $val[
"type"];
858 $invoicestatic->close_code = $val[
"close_code"];
863 $replacedinvoice = 0;
864 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
865 $replacedinvoice = 1;
866 $alreadydispatched = $invoicestatic->getVentilExportCompta();
867 if ($alreadydispatched) {
868 $replacedinvoice = 2;
873 if ($replacedinvoice == 1) {
878 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key])) {
879 foreach ($tabwarranty[$key] as $k => $mt) {
881 print
'"'.$key.
'"'.$sep;
882 print
'"'.$date.
'"'.$sep;
883 print
'"'.$val[
"ref"].
'"'.$sep;
884 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
885 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
886 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY')).
'"'.$sep;
887 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
888 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
889 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"Retainedwarranty").
'"'.$sep;
890 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
891 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
892 print
'"'.$journal.
'"';
899 foreach ($tabttc[$key] as $k => $mt) {
901 print
'"'.$key.
'"'.$sep;
902 print
'"'.$date.
'"'.$sep;
903 print
'"'.$val[
"ref"].
'"'.$sep;
904 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
905 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
906 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER')).
'"'.$sep;
907 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
908 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
909 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"Thirdparty").
'"'.$sep;
910 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
911 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
912 print
'"'.$journal.
'"';
918 foreach ($tabht[$key] as $k => $mt) {
920 $accountingaccount->fetch(
null, $k,
true);
922 print
'"'.$key.
'"'.$sep;
923 print
'"'.$date.
'"'.$sep;
924 print
'"'.$val[
"ref"].
'"'.$sep;
925 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
926 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
927 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
929 print
'"'.mb_convert_encoding(
dol_trunc($accountingaccount->label, 32),
'ISO-8859-1').
'"'.$sep;
930 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.
dol_trunc($accountingaccount->label, 32).
'"'.$sep;
931 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
932 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
933 print
'"'.$journal.
'"';
939 $listoftax = array(0, 1, 2);
940 foreach ($listoftax as $numtax) {
941 $arrayofvat = $tabtva;
943 $arrayofvat = $tablocaltax1;
946 $arrayofvat = $tablocaltax2;
949 foreach ($arrayofvat[$key] as $k => $mt) {
951 print
'"'.$key.
'"'.$sep;
952 print
'"'.$date.
'"'.$sep;
953 print
'"'.$val[
"ref"].
'"'.$sep;
954 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
955 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
956 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
958 print
'"'.$langs->trans(
"VAT").
' - '.join(
', ', $def_tva[$key][$k]).
' %"'.$sep;
959 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"VAT").join(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'').
'"'.$sep;
960 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
961 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
962 print
'"'.$journal.
'"';
969 if (isset($tabrevenuestamp[$key])) {
970 foreach ($tabrevenuestamp[$key] as $k => $mt) {
972 print
'"'.$key.
'"'.$sep;
973 print
'"'.$date.
'"'.$sep;
974 print
'"'.$val[
"ref"].
'"'.$sep;
975 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
976 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
977 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
979 print
'"'.$langs->trans(
"RevenueStamp").
'"'.$sep;
980 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"RevenueStamp").
'"'.$sep;
981 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
982 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
983 print
'"'.$journal.
'"';
993if (empty($action) || $action ==
'view') {
994 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
1003 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
1005 $description .= $langs->trans(
"DepositsAreNotIncluded");
1007 $description .= $langs->trans(
"DepositsAreIncluded");
1010 $listofchoices = array(
'notyet'=>$langs->trans(
"NotYetInGeneralLedger"),
'already'=>$langs->trans(
"AlreadyInGeneralLedger"));
1011 $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);
1012 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
1014 $varlink =
'id_journal='.$id_journal;
1016 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
1021 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int) $conf->entity);
1022 $resql = $db->query($sql);
1024 $obj = $db->fetch_object($resql);
1025 if ($obj->nb == 0) {
1026 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
1027 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
1028 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
1038 $acctCustomerNotConfigured = in_array(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'), [
'',
'-1']);
1039 if ($acctCustomerNotConfigured) {
1040 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
1041 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
1042 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
1046 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
1047 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
1048 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
1050 if ($acctCustomerNotConfigured) {
1051 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
1053 if ($in_bookkeeping ==
'notyet') {
1054 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
1056 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
1063 <script type="text/javascript">
1064 function launch_export() {
1065 $("div.fiche form input[name=\"action\"]").val("exportcsv");
1066 $("div.fiche form input[type=\"submit\"]").click();
1067 $("div.fiche form input[name=\"action\"]").val("");
1069 function writebookkeeping() {
1070 console.log("click on writebookkeeping");
1071 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
1072 $("div.fiche form input[type=\"submit\"]").click();
1073 $("div.fiche form input[name=\"action\"]").val("");
1082 print
'<div class="div-table-responsive">';
1083 print
"<table class=\"noborder\" width=\"100%\">";
1084 print
"<tr class=\"liste_titre\">";
1085 print
"<td>".$langs->trans(
"Date").
"</td>";
1086 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"InvoiceRef").
")</td>";
1087 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
1088 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
1089 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
1090 print
'<td class="center">'.$langs->trans(
"AccountingDebit").
"</td>";
1091 print
'<td class="center">'.$langs->trans(
"AccountingCredit").
"</td>";
1096 $companystatic =
new Client($db);
1097 $invoicestatic =
new Facture($db);
1099 foreach ($tabfac as $key => $val) {
1100 $companystatic->id = $tabcompany[$key][
'id'];
1101 $companystatic->name = $tabcompany[$key][
'name'];
1102 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
1103 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
1104 $companystatic->code_client = $tabcompany[$key][
'code_client'];
1105 $companystatic->client = 3;
1107 $invoicestatic->id = $key;
1108 $invoicestatic->ref = (string) $val[
"ref"];
1109 $invoicestatic->type = $val[
"type"];
1110 $invoicestatic->close_code = $val[
"close_code"];
1115 $replacedinvoice = 0;
1116 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
1117 $replacedinvoice = 1;
1118 $alreadydispatched = $invoicestatic->getVentilExportCompta();
1119 if ($alreadydispatched) {
1120 $replacedinvoice = 2;
1125 if ($replacedinvoice == 1) {
1126 print
'<tr class="oddeven">';
1127 print
"<!-- Replaced invoice -->";
1128 print
"<td>".$date.
"</td>";
1129 print
"<td><strike>".$invoicestatic->getNomUrl(1).
"</strike></td>";
1132 print $langs->trans(
"Replaced");
1139 print
'<td class="right"></td>';
1140 print
'<td class="right"></td>';
1146 if ($errorforinvoice[$key] ==
'somelinesarenotbound') {
1147 print
'<tr class="oddeven">';
1148 print
"<!-- Some lines are not bound -->";
1149 print
"<td>".$date.
"</td>";
1150 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1153 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $val[
'ref']).
'</span>';
1160 print
'<td class="right"></td>';
1161 print
'<td class="right"></td>';
1168 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key]) && is_array($tabwarranty[$key])) {
1169 foreach ($tabwarranty[$key] as $k => $mt) {
1170 print
'<tr class="oddeven">';
1171 print
"<!-- Thirdparty warranty -->";
1172 print
"<td>" . $date .
"</td>";
1173 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1177 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1178 print
'<span class="error">' . $langs->trans(
"MainAccountForRetainedWarrantyNotDefined") .
'</span>';
1180 print $accountoshow;
1186 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1187 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1189 print $accountoshow;
1192 print
"<td>" . $companystatic->getNomUrl(0,
'customer', 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"Retainedwarranty") .
"</td>";
1193 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1194 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1200 foreach ($tabttc[$key] as $k => $mt) {
1201 print
'<tr class="oddeven">';
1202 print
"<!-- Thirdparty -->";
1203 print
"<td>".$date.
"</td>";
1204 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1208 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1209 print
'<span class="error">'.$langs->trans(
"MainAccountForCustomersNotDefined").
'</span>';
1211 print $accountoshow;
1217 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1218 print
'<span class="error">'.$langs->trans(
"ThirdpartyAccountNotDefined").
'</span>';
1220 print $accountoshow;
1223 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref.
' - '.$langs->trans(
"SubledgerAccount").
"</td>";
1224 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1225 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1232 foreach ($tabht[$key] as $k => $mt) {
1234 $accountingaccount->fetch(
null, $k,
true);
1236 print
'<tr class="oddeven">';
1237 print
"<!-- Product -->";
1238 print
"<td>".$date.
"</td>";
1239 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1243 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1244 print
'<span class="error">'.$langs->trans(
"ProductNotDefined").
'</span>';
1246 print $accountoshow;
1255 } elseif (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1256 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1259 $companystatic->id = $tabcompany[$key][
'id'];
1260 $companystatic->name = $tabcompany[$key][
'name'];
1261 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref.
' - '.$accountingaccount->label.
"</td>";
1262 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1263 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1270 $listoftax = array(0, 1, 2);
1271 foreach ($listoftax as $numtax) {
1272 $arrayofvat = $tabtva;
1274 $arrayofvat = $tablocaltax1;
1277 $arrayofvat = $tablocaltax2;
1281 foreach ($arrayofvat[$key] as $k => $mt) {
1283 print
'<tr class="oddeven">';
1284 print
"<!-- VAT -->";
1285 print
"<td>".$date.
"</td>";
1286 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1290 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1291 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"AccountingJournalType2").
')</span>';
1293 print $accountoshow;
1299 print
"<td>".$companystatic->getNomUrl(0,
'customer', 16).
' - '.$invoicestatic->ref;
1302 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : join(
', ', $def_tva[$key][$k]));
1303 print
' - '.$langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
1304 print($numtax ?
' - Localtax '.$numtax :
'');
1306 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1307 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1316 if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) {
1317 foreach ($tabrevenuestamp[$key] as $k => $mt) {
1318 print
'<tr class="oddeven">';
1319 print
"<!-- Thirdparty revenuestamp -->";
1320 print
"<td>" . $date .
"</td>";
1321 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1325 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1326 print
'<span class="error">' . $langs->trans(
"MainAccountForRevenueStampSaleNotDefined") .
'</span>';
1328 print $accountoshow;
1334 print
"<td>" . $companystatic->getNomUrl(0,
'customer', 16) .
' - ' . $invoicestatic->ref .
' - ' . $langs->trans(
"RevenueStamp") .
"</td>";
1335 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1336 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1343 print
'<tr class="oddeven"><td colspan="7"><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 journals.
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 a 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.