36require
'../../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeeping.class.php';
55$langs->loadLangs(array(
"commercial",
"compta",
"bills",
"other",
"accountancy",
"errors"));
58$action =
GETPOST(
'action',
'aZ09');
60$date_startmonth =
GETPOSTINT(
'date_startmonth');
66$in_bookkeeping =
GETPOST(
'in_bookkeeping');
67if ($in_bookkeeping ==
'') {
68 $in_bookkeeping =
'notyet';
73$hookmanager->initHooks(array(
'sellsjournal'));
80if ($user->socid > 0) {
83if (!$user->hasRight(
'accounting',
'bind',
'write')) {
92$tabwarranty = array();
94$tablocaltax1 = array();
95$tablocaltax2 = array();
96$tabCustomerDiscountHT = array();
97$tabCustomerDiscountVAT = array();
98$tabCustomerDiscountTTC = array();
100$manageCustomerDepositInInvoice =
getDolGlobalInt(
'ACCOUNTING_MANAGE_CUSTOMER_DEPOSIT_IN_INVOICE');
101$labelCustomerDiscountExtension =
' (AC)';
103$cptcli =
'NotDefined';
104$accountCustomerDeposit =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT',
'NotDefined');
105$accountCustomerDepositVAT =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT_FOR_VAT',
'NotDefined');
111$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $user, $action);
117$accountingjournalstatic->fetch($id_journal);
118$journal = $accountingjournalstatic->code;
119$journal_label = $accountingjournalstatic->label;
122$date_end =
dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
125$pastmonthyear =
null;
127if (empty($date_startmonth)) {
131 $pastmonthyear = $dates[
'pastmonthyear'];
132 $pastmonth = $dates[
'pastmonth'];
134if (empty($date_endmonth)) {
137 $date_end = $dates[
'date_end'];
138 $pastmonthyear = $dates[
'pastmonthyear'];
139 $pastmonth = $dates[
'pastmonth'];
145if (!
GETPOSTISSET(
'date_startmonth') && (empty($date_start) || empty($date_end))) {
147 $date_end =
dol_get_last_day((
int) $pastmonthyear, (
int) $pastmonth,
false);
150$sql =
"SELECT f.rowid, f.ref, f.type, f.module_source, 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, f.situation_final,";
151$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.localtax1_tx, fd.localtax2_tx, fd.total_ttc, fd.situation_percent, fd.vat_src_code, fd.info_bits,";
152$sql .=
" s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.fk_pays,";
154 $sql .=
" spe.accountancy_code_customer_general,";
155 $sql .=
" spe.accountancy_code_customer as code_compta_client,";
156 $sql .=
" spe.accountancy_code_supplier_general,";
157 $sql .=
" spe.accountancy_code_supplier as code_compta_fournisseur,";
159 $sql .=
" s.accountancy_code_customer_general,";
160 $sql .=
" s.code_compta as code_compta_client,";
161 $sql .=
" s.accountancy_code_supplier_general,";
162 $sql .=
" s.code_compta_fournisseur,";
164$sql .=
" p.rowid as pid, p.ref as pref, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,";
166 $sql .=
" ppe.accountancy_code_sell";
168 $sql .=
" p.accountancy_code_sell";
170$parameters = array();
171$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
172$sql .= $hookmanager->resPrint;
173$sql .=
" FROM ".MAIN_DB_PREFIX.
"facturedet as fd";
174$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = fd.fk_product";
176 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int)
$conf->entity);
178$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
179$sql .=
" JOIN ".MAIN_DB_PREFIX.
"facture as f ON f.rowid = fd.fk_facture";
180$sql .=
" JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = f.fk_soc";
182 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int)
$conf->entity);
184$parameters = array();
185$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters);
186$sql .= $hookmanager->resPrint;
187$sql .=
" WHERE fd.fk_code_ventilation > 0";
188$sql .=
" AND f.entity IN (".getEntity(
'invoice', 0).
')';
189$sql .=
" AND f.fk_statut > 0";
195$sql .=
" AND fd.product_type IN (0,1)";
196if ($date_start && $date_end) {
197 $sql .=
" AND f.datef >= '".$db->idate($date_start).
"' AND f.datef <= '".
$db->idate($date_end).
"'";
200 $sql .=
" AND (f.module_source IS NULL OR f.module_source <> 'takepos')";
204 $sql .=
" AND f.datef >= '".$db->idate(
getDolGlobalInt(
'ACCOUNTING_DATE_START_BINDING')).
"'";
207if ($in_bookkeeping ==
'already') {
208 $sql .=
" AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
211if ($in_bookkeeping ==
'notyet') {
212 $sql .=
" AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
215if ($manageCustomerDepositInInvoice) {
216 $sql .=
" AND (fd.description != '(DEPOSIT)' OR COALESCE(fd.fk_remise_except, 0) = 0)";
218$parameters = array();
219$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
220$sql .= $hookmanager->resPrint;
221$sql .=
" ORDER BY f.datef, f.ref";
224dol_syslog(
'accountancy/journal/sellsjournal.php', LOG_DEBUG);
229$tabwarranty = array();
230$tabrevenuestamp = array();
232$tablocaltax1 = array();
233$tablocaltax2 = array();
234$tabcompany = array();
235$vatdata_cache = array();
236$tabCustomerDiscountHT = array();
237$tabCustomerDiscountVAT = array();
238$tabCustomerDiscountTTC = array();
246$result =
$db->query($sql);
248 $num =
$db->num_rows($result);
252 $obj =
$db->fetch_object($result);
255 $accountancy_code_customer_general = (!empty($obj->accountancy_code_customer_general) && $obj->accountancy_code_customer_general !=
'-1') ? $obj->accountancy_code_customer_general : $cptcli;
256 $compta_soc = (!empty($obj->code_compta_client)) ? $obj->code_compta_client : $cptcli;
258 $compta_prod = $obj->compte;
259 if (empty($compta_prod)) {
260 if ($obj->product_type == 0) {
269 $tax_id = $obj->tva_tx . ($obj->vat_src_code ?
' (' . $obj->vat_src_code .
')' :
'');
273 $vatdata_cache_key = $tax_id.
'_'.(int) $obj->fk_pays;
275 $vatdata_cache_key = $tax_id;
277 if (array_key_exists($vatdata_cache_key, $vatdata_cache)) {
278 $vatdata = $vatdata_cache[$vatdata_cache_key];
282 $buyer->fetch($obj->socid);
288 $vatdata_cache[$vatdata_cache_key] = $vatdata;
292 $compta_tva = $accountCustomerDepositVAT;
294 $compta_tva = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
296 $compta_localtax1 = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cptlocaltax1);
297 $compta_localtax2 = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cptlocaltax2);
300 if (
price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
301 $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.
')' :
''));
302 if ($obj->localtax1_tx > 0.0) {
303 $def_tva[$obj->rowid][$compta_localtax1][
vatrate($obj->localtax1_tx).($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
'').
' LT1'] = (
vatrate($obj->localtax1_tx).($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''));
305 if ($obj->localtax2_tx > 0.0) {
306 $def_tva[$obj->rowid][$compta_localtax2][
vatrate($obj->localtax2_tx).($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
'').
' LT2'] = (
vatrate($obj->localtax2_tx).($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''));
311 $situation_ratio = 1;
313 if ($obj->situation_cycle_ref) {
315 if ($obj->situation_percent == 0) {
316 $situation_ratio = 0;
319 $line->fetch($obj->fdid);
322 $prev_progress = $line->get_prev_progress($obj->rowid);
324 $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
329 $revenuestamp = (float)
price2num($obj->revenuestamp,
'MT');
331 if ($manageCustomerDepositInInvoice && $obj->type ==
Facture::TYPE_STANDARD && !isset($tabfac[$obj->rowid])) {
333 $sql2 =
"SELECT re.rowid";
334 $sql2 .=
" FROM " .
$db->prefix() .
"societe_remise_except as re";
335 $sql2 .=
" WHERE (re.fk_facture = " . ((int) $obj->rowid);
336 $sql2 .=
" OR re.fk_facture_line IN (SELECT rowid FROM " .
$db->prefix() .
"facturedet WHERE fk_facture = " . ((int) $obj->rowid) .
")";
339 $resql2 =
$db->query($sql2);
341 if (
$db->num_rows($resql2) > 0) {
342 if (!isset($tabCustomerDiscountHT[$obj->rowid][$accountCustomerDeposit])) {
343 $tabCustomerDiscountHT[$obj->rowid][$accountCustomerDeposit] = 0;
345 if (!isset($tabCustomerDiscountVAT[$obj->rowid][$accountCustomerDepositVAT])) {
346 $tabCustomerDiscountVAT[$obj->rowid][$accountCustomerDepositVAT] = 0;
348 if (!isset($tabCustomerDiscountTTC[$obj->rowid][$compta_soc])) {
349 $tabCustomerDiscountTTC[$obj->rowid][$compta_soc] = 0;
352 while ($obj2 =
$db->fetch_object($resql2)) {
354 $customerDiscount->fetch($obj2->rowid);
357 $tabCustomerDiscountHT[$obj->rowid][$accountCustomerDeposit] -= $customerDiscount->total_ht;
358 $tabCustomerDiscountVAT[$obj->rowid][$accountCustomerDepositVAT] -= $customerDiscount->total_tva;
359 $tabCustomerDiscountTTC[$obj->rowid][$compta_soc] -= $customerDiscount->total_ttc;
369 $tabfac[$obj->rowid][
"date"] =
$db->jdate($obj->df);
370 $tabfac[$obj->rowid][
"datereg"] =
$db->jdate($obj->dlr);
371 $tabfac[$obj->rowid][
"ref"] = $obj->ref;
372 $tabfac[$obj->rowid][
"type"] = $obj->type;
373 $tabfac[$obj->rowid][
"description"] = $obj->label_compte;
374 $tabfac[$obj->rowid][
"close_code"] = $obj->close_code;
375 $tabfac[$obj->rowid][
"revenuestamp"] = $revenuestamp;
379 if (!isset($tabttc[$obj->rowid][$compta_soc])) {
380 $tabttc[$obj->rowid][$compta_soc] = 0;
382 if (!isset($tabht[$obj->rowid][$compta_prod])) {
383 $tabht[$obj->rowid][$compta_prod] = 0;
385 if (!isset($tabtva[$obj->rowid][$compta_tva])) {
386 $tabtva[$obj->rowid][$compta_tva] = 0;
388 if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
389 $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
391 if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) {
392 $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
401 $total_ttc = $obj->total_ttc * $situation_ratio;
403 $total_ttc = $obj->total_ttc;
407 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && $obj->retained_warranty > 0 && (!
getDolGlobalString(
'INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION') || !empty($obj->situation_final))) {
408 $retained_warranty = (float)
price2num($total_ttc * $obj->retained_warranty / 100,
'MT');
409 $tabwarranty[$obj->rowid][$compta_soc] += $retained_warranty;
410 $total_ttc -= $retained_warranty;
413 $tabttc[$obj->rowid][$compta_soc] += $total_ttc;
414 $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
415 $tva_npr = ((($obj->info_bits & 1) == 1) ? 1 : 0);
418 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
419 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
420 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
422 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio;
423 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio;
424 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio;
428 $compta_revenuestamp =
'NotDefined';
429 if (!empty($revenuestamp)) {
430 $sqlrevenuestamp =
"SELECT accountancy_code_sell FROM ".MAIN_DB_PREFIX.
"c_revenuestamp";
431 $sqlrevenuestamp .=
" WHERE fk_pays = ".((int)
$mysoc->country_id);
432 $sqlrevenuestamp .=
" AND taux = ".((float) $revenuestamp);
433 $sqlrevenuestamp .=
" AND active = 1";
434 $resqlrevenuestamp =
$db->query($sqlrevenuestamp);
436 if ($resqlrevenuestamp) {
437 $num_rows_revenuestamp =
$db->num_rows($resqlrevenuestamp);
438 if ($num_rows_revenuestamp > 1) {
439 dol_print_error(
$db,
'Failed 2 or more lines for the revenue stamp of your country. Check the dictionary of revenue stamp.');
441 $objrevenuestamp =
$db->fetch_object($resqlrevenuestamp);
442 if ($objrevenuestamp) {
443 $compta_revenuestamp = $objrevenuestamp->accountancy_code_sell;
449 if (empty($tabrevenuestamp[$obj->rowid][$compta_revenuestamp]) && !empty($revenuestamp)) {
451 $tabttc[$obj->rowid][$compta_soc] += $obj->revenuestamp;
452 $tabrevenuestamp[$obj->rowid][$compta_revenuestamp] = $obj->revenuestamp;
455 $tabcompany[$obj->rowid] = array(
457 'name' => $obj->name,
458 'code_client' => $obj->code_client,
459 'accountancy_code_customer_general' => $accountancy_code_customer_general,
460 'code_compta' => $compta_soc
466 'tabfac' => &$tabfac,
468 'tabtva' => &$tabtva,
469 'def_tva' => &$def_tva,
470 'tabwarranty' => &$tabwarranty,
471 'tabrevenuestamp' => &$tabrevenuestamp,
472 'tabttc' => &$tabttc,
473 'tablocaltax1' => &$tablocaltax1,
474 'tablocaltax2' => &$tablocaltax2,
475 'tabcompany' => &$tabcompany,
476 'vatdata_cache' => &$vatdata_cache,
478 $reshook = $hookmanager->executeHooks(
'processingJournalData', $parameters);
483 if ($i >
getDolGlobalInt(
'ACCOUNTANCY_MAX_TOO_MANY_LINES_TO_PROCESS', 10000)) {
485 setEventMessages(
"ErrorTooManyLinesToProcessPleaseUseAMoreSelectiveFilter",
null,
'errors');
492 'tabfac' => &$tabfac,
494 'tabtva' => &$tabtva,
495 'def_tva' => &$def_tva,
496 'tabwarranty' => &$tabwarranty,
497 'tabrevenuestamp' => &$tabrevenuestamp,
498 'tabttc' => &$tabttc,
499 'tablocaltax1' => &$tablocaltax1,
500 'tablocaltax2' => &$tablocaltax2,
501 'tabcompany' => &$tabcompany,
502 'vatdata_cache' => &$vatdata_cache,
504 $reshook = $hookmanager->executeHooks(
'processedJournalData', $parameters);
510$errorforinvoice = array();
532if (!empty($tabfac)) {
536 COUNT(fd.rowid) as nb
538 ".MAIN_DB_PREFIX.
"facturedet as fd
541 AND fd.fk_code_ventilation <= 0
542 AND fd.total_ttc <> 0
543 AND fk_facture IN (".
$db->sanitize(implode(
",", array_keys($tabfac))).
")
546 $resql =
$db->query($sql);
548 $num =
$db->num_rows($resql);
551 $obj =
$db->fetch_object($resql);
553 $errorforinvoice[$obj->fk_facture] =
'somelinesarenotbound';
562if ($action ==
'writebookkeeping' && !$error && $user->hasRight(
'accounting',
'bind',
'write')) {
571 $accountingaccountcustomer->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'),
true);
574 $accountingaccountcustomerwarranty->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'),
true);
576 foreach ($tabfac as $key => $val) {
584 $companystatic->id = $tabcompany[$key][
'id'];
585 $companystatic->name = $tabcompany[$key][
'name'];
586 $companystatic->accountancy_code_customer_general = $tabcompany[$key][
'accountancy_code_customer_general'];
587 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
588 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
589 $companystatic->code_client = $tabcompany[$key][
'code_client'];
590 $companystatic->client = 3;
592 $invoicestatic->id = (int) $key;
593 $invoicestatic->ref = (
string) $val[
"ref"];
594 $invoicestatic->type = (int) ($val[
"type"] ?? 0);
595 $invoicestatic->close_code = (
string) ($val[
"close_code"] ??
'');
600 $replacedinvoice = 0;
601 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
602 $replacedinvoice = 1;
603 $alreadydispatched = $invoicestatic->getVentilExportCompta();
604 if ($alreadydispatched) {
605 $replacedinvoice = 2;
610 if ($replacedinvoice == 1) {
616 if (isset($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
619 setEventMessages($langs->trans(
'ErrorInvoiceContainsLinesNotYetBounded', (
string) ($val[
'ref'] ??
'')),
null,
'errors');
624 if (isset($tabwarranty[$key]) && is_array($tabwarranty[$key])) {
625 foreach ($tabwarranty[$key] as $k => $mt) {
627 $bookkeeping->doc_date = $val[
"date"];
628 $bookkeeping->date_lim_reglement = $val[
"datereg"];
629 $bookkeeping->doc_ref = $val[
"ref"];
630 $bookkeeping->date_creation = $now;
631 $bookkeeping->doc_type =
'customer_invoice';
632 $bookkeeping->fk_doc = (int) $key;
633 $bookkeeping->fk_docdet = 0;
634 $bookkeeping->thirdparty_code = $companystatic->code_client;
636 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
637 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
639 $bookkeeping->numero_compte =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY');
640 $bookkeeping->label_compte = $accountingaccountcustomerwarranty->label;
642 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"RetainedWarranty"));
643 $bookkeeping->montant = $mt;
644 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
645 $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
646 $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
647 $bookkeeping->code_journal = $journal;
648 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
649 $bookkeeping->fk_user_author = $user->id;
650 $bookkeeping->entity =
$conf->entity;
652 $totaldebit += $bookkeeping->debit;
653 $totalcredit += $bookkeeping->credit;
655 $result = $bookkeeping->create($user);
657 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
660 $errorforinvoice[$key] =
'alreadyjournalized';
665 $errorforinvoice[$key] =
'other';
674 if (!$errorforline) {
675 foreach ($tabttc[$key] as $k => $mt) {
677 $bookkeeping->doc_date = $val[
"date"];
678 $bookkeeping->date_lim_reglement = $val[
"datereg"];
679 $bookkeeping->doc_ref = $val[
"ref"];
680 $bookkeeping->date_creation = $now;
681 $bookkeeping->doc_type =
'customer_invoice';
682 $bookkeeping->fk_doc = (int) $key;
683 $bookkeeping->fk_docdet = 0;
684 $bookkeeping->thirdparty_code = $companystatic->code_client;
686 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
687 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
689 $bookkeeping->numero_compte = (!empty($tabcompany[$key][
'accountancy_code_customer_general']) && $tabcompany[$key][
'accountancy_code_customer_general'] !=
'-1') ? $tabcompany[$key][
'accountancy_code_customer_general'] : $cptcli;
690 $bookkeeping->label_compte = $accountingaccountcustomer->label;
692 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"SubledgerAccount"));
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';
720 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
723 $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id));
730 if (!$errorforline) {
731 foreach ($tabht[$key] as $k => $mt) {
732 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
734 $accountingaccount->fetch(0, $k,
true);
735 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
737 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
740 $label_account = $accountingaccount->label;
743 if ($accountingaccount->id > 0) {
745 $bookkeeping->doc_date = $val[
"date"];
746 $bookkeeping->date_lim_reglement = $val[
"datereg"];
747 $bookkeeping->doc_ref = $val[
"ref"];
748 $bookkeeping->date_creation = $now;
749 $bookkeeping->doc_type =
'customer_invoice';
750 $bookkeeping->fk_doc = (int) $key;
751 $bookkeeping->fk_docdet = 0;
752 $bookkeeping->thirdparty_code = $companystatic->code_client;
756 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
757 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
759 $bookkeeping->subledger_account =
'';
760 $bookkeeping->subledger_label =
'';
763 $bookkeeping->subledger_account =
'';
764 $bookkeeping->subledger_label =
'';
767 $bookkeeping->numero_compte = $k;
768 $bookkeeping->label_compte = $label_account;
770 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $label_account);
771 $bookkeeping->montant = $mt;
772 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
773 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
774 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
775 $bookkeeping->code_journal = $journal;
776 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
777 $bookkeeping->fk_user_author = $user->id;
778 $bookkeeping->entity =
$conf->entity;
780 $totaldebit += $bookkeeping->debit;
781 $totalcredit += $bookkeeping->credit;
783 $result = $bookkeeping->create($user);
785 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
788 $errorforinvoice[$key] =
'alreadyjournalized';
793 $errorforinvoice[$key] =
'other';
802 if (!$errorforline) {
803 $listoftax = array(0, 1, 2);
804 foreach ($listoftax as $numtax) {
805 $arrayofvat = $tabtva;
807 $arrayofvat = $tablocaltax1;
810 $arrayofvat = $tablocaltax2;
813 foreach ($arrayofvat[$key] as $k => $mt) {
815 if (empty(
$conf->cache[
'accountingaccountincurrententity_vat'][$k])) {
817 $accountingaccount->fetch(0, $k,
true);
818 $conf->cache[
'accountingaccountincurrententity_vat'][$k] = $accountingaccount;
820 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity_vat'][$k];
823 $label_account = $accountingaccount->label;
826 $bookkeeping->doc_date = $val[
"date"];
827 $bookkeeping->date_lim_reglement = $val[
"datereg"];
828 $bookkeeping->doc_ref = $val[
"ref"];
829 $bookkeeping->date_creation = $now;
830 $bookkeeping->doc_type =
'customer_invoice';
831 $bookkeeping->fk_doc = (int) $key;
832 $bookkeeping->fk_docdet = 0;
833 $bookkeeping->thirdparty_code = $companystatic->code_client;
835 $bookkeeping->subledger_account =
'';
836 $bookkeeping->subledger_label =
'';
838 $bookkeeping->numero_compte = $k;
839 $bookkeeping->label_compte = $label_account;
842 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : implode(
', ', $def_tva[$key][$k]));
843 $labelvataccount = $langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
844 $labelvataccount .= ($numtax ?
' - Localtax '.$numtax :
'');
845 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $labelvataccount);
847 $bookkeeping->montant = $mt;
848 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
849 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
850 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
851 $bookkeeping->code_journal = $journal;
852 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
853 $bookkeeping->fk_user_author = $user->id;
854 $bookkeeping->entity =
$conf->entity;
856 $totaldebit += $bookkeeping->debit;
857 $totalcredit += $bookkeeping->credit;
859 $result = $bookkeeping->create($user);
861 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
864 $errorforinvoice[$key] =
'alreadyjournalized';
869 $errorforinvoice[$key] =
'other';
879 if (!$errorforline) {
880 if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) {
881 foreach ($tabrevenuestamp[$key] as $k => $mt) {
883 if (empty(
$conf->cache[
'accountingaccountincurrententity_rs'][$k])) {
885 $accountingaccount->fetch(0, $k,
true);
886 $conf->cache[
'accountingaccountincurrententity_rs'][$k] = $accountingaccount;
888 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity_rs'][$k];
891 $label_account = $accountingaccount->label;
894 $bookkeeping->doc_date = $val[
"date"];
895 $bookkeeping->date_lim_reglement = $val[
"datereg"];
896 $bookkeeping->doc_ref = $val[
"ref"];
897 $bookkeeping->date_creation = $now;
898 $bookkeeping->doc_type =
'customer_invoice';
899 $bookkeeping->fk_doc = (int) $key;
900 $bookkeeping->fk_docdet = 0;
901 $bookkeeping->thirdparty_code = $companystatic->code_client;
903 $bookkeeping->subledger_account =
'';
904 $bookkeeping->subledger_label =
'';
906 $bookkeeping->numero_compte = $k;
907 $bookkeeping->label_compte = $label_account;
909 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"RevenueStamp"));
910 $bookkeeping->montant = $mt;
911 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
912 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
913 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
914 $bookkeeping->code_journal = $journal;
915 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
916 $bookkeeping->fk_user_author = $user->id;
917 $bookkeeping->entity =
$conf->entity;
919 $totaldebit += $bookkeeping->debit;
920 $totalcredit += $bookkeeping->credit;
922 $result = $bookkeeping->create($user);
924 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
927 $errorforinvoice[$key] =
'alreadyjournalized';
932 $errorforinvoice[$key] =
'other';
941 if ($manageCustomerDepositInInvoice) {
943 if (!$errorforline && isset($tabCustomerDiscountTTC[$key])) {
944 foreach ($tabCustomerDiscountTTC[$key] as $k => $mt) {
946 $bookkeeping->doc_date = $val[
"date"];
947 $bookkeeping->date_lim_reglement = $val[
"datereg"];
948 $bookkeeping->doc_ref = $val[
"ref"];
949 $bookkeeping->date_creation = $now;
950 $bookkeeping->doc_type =
'customer_invoice';
951 $bookkeeping->fk_doc = $key;
952 $bookkeeping->fk_docdet = 0;
953 $bookkeeping->thirdparty_code = $companystatic->code_client;
955 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
956 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
960 $bookkeeping->label_compte = $accountingaccountcustomer->label;
962 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"SubledgerAccount") . $labelCustomerDiscountExtension);
963 $bookkeeping->montant = $mt;
964 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
965 $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
966 $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
967 $bookkeeping->code_journal = $journal;
968 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
969 $bookkeeping->fk_user_author = $user->id;
970 $bookkeeping->entity =
$conf->entity;
972 $totaldebit += $bookkeeping->debit;
973 $totalcredit += $bookkeeping->credit;
975 $result = $bookkeeping->create($user);
977 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
980 $errorforinvoice[$key] =
'alreadyjournalized';
984 $errorforinvoice[$key] =
'other';
989 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
992 $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id));
999 if (!$errorforline && isset($tabCustomerDiscountHT[$key])) {
1000 foreach ($tabCustomerDiscountHT[$key] as $k => $mt) {
1001 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
1003 $accountingaccount->fetch(0, $k,
true);
1004 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
1006 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
1009 $label_account = $accountingaccount->label;
1012 if ($accountingaccount->id > 0) {
1014 $bookkeeping->doc_date = $val[
"date"];
1015 $bookkeeping->date_lim_reglement = $val[
"datereg"];
1016 $bookkeeping->doc_ref = $val[
"ref"];
1017 $bookkeeping->date_creation = $now;
1018 $bookkeeping->doc_type =
'customer_invoice';
1019 $bookkeeping->fk_doc = $key;
1020 $bookkeeping->fk_docdet = 0;
1021 $bookkeeping->thirdparty_code = $companystatic->code_client;
1025 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
1026 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
1028 $bookkeeping->subledger_account =
'';
1029 $bookkeeping->subledger_label =
'';
1032 $bookkeeping->subledger_account =
'';
1033 $bookkeeping->subledger_label =
'';
1036 $bookkeeping->numero_compte = $k;
1037 $bookkeeping->label_compte = $label_account;
1039 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $label_account) . $labelCustomerDiscountExtension;
1040 $bookkeeping->montant = $mt;
1041 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
1042 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
1043 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
1044 $bookkeeping->code_journal = $journal;
1045 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
1046 $bookkeeping->fk_user_author = $user->id;
1047 $bookkeeping->entity =
$conf->entity;
1049 $totaldebit += $bookkeeping->debit;
1050 $totalcredit += $bookkeeping->credit;
1052 $result = $bookkeeping->create($user);
1054 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
1057 $errorforinvoice[$key] =
'alreadyjournalized';
1061 $errorforinvoice[$key] =
'other';
1070 if (!$errorforline && isset($tabCustomerDiscountVAT[$key])) {
1071 foreach ($tabCustomerDiscountVAT[$key] as $k => $mt) {
1072 if (empty(
$conf->cache[
'accountingaccountincurrententity_vat'][$k])) {
1074 $accountingaccount->fetch(0, $k,
true);
1075 $conf->cache[
'accountingaccountincurrententity_vat'][$k] = $accountingaccount;
1077 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity_vat'][$k];
1080 $label_account = $accountingaccount->label;
1083 $bookkeeping->doc_date = $val[
"date"];
1084 $bookkeeping->date_lim_reglement = $val[
"datereg"];
1085 $bookkeeping->doc_ref = $val[
"ref"];
1086 $bookkeeping->date_creation = $now;
1087 $bookkeeping->doc_type =
'customer_invoice';
1088 $bookkeeping->fk_doc = $key;
1089 $bookkeeping->fk_docdet = 0;
1090 $bookkeeping->thirdparty_code = $companystatic->code_client;
1092 $bookkeeping->subledger_account =
'';
1093 $bookkeeping->subledger_label =
'';
1095 $bookkeeping->numero_compte = $k;
1096 $bookkeeping->label_compte = $label_account;
1098 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : implode(
', ', $def_tva[$key][$k]));
1099 $labelvataccount = $langs->trans(
"Taxes") .
' ' . $tmpvatrate .
' %';
1100 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $labelvataccount) . $labelCustomerDiscountExtension;
1102 $bookkeeping->montant = $mt;
1103 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
1104 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
1105 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
1106 $bookkeeping->code_journal = $journal;
1107 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
1108 $bookkeeping->fk_user_author = $user->id;
1109 $bookkeeping->entity =
$conf->entity;
1111 $totaldebit += $bookkeeping->debit;
1112 $totalcredit += $bookkeeping->credit;
1114 $result = $bookkeeping->create($user);
1116 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
1119 $errorforinvoice[$key] =
'alreadyjournalized';
1123 $errorforinvoice[$key] =
'other';
1132 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
1135 $errorforinvoice[$key] =
'amountsnotbalanced';
1136 setEventMessages(
'We Tried to insert a non balanced transaction in book for '.$invoicestatic->ref.
'. Canceled. Surely a bug.',
null,
'errors');
1139 if (!$errorforline) {
1145 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
1153 if (empty($error) && count($tabpay) > 0) {
1155 } elseif (count($tabpay) == $error) {
1158 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
1164 if (count($tabpay) != $error) {
1165 $param =
'id_journal='.$id_journal;
1166 $param .=
'&date_startday='.$date_startday;
1167 $param .=
'&date_startmonth='.$date_startmonth;
1168 $param .=
'&date_startyear='.$date_startyear;
1169 $param .=
'&date_endday='.$date_endday;
1170 $param .=
'&date_endmonth='.$date_endmonth;
1171 $param .=
'&date_endyear='.$date_endyear;
1172 $param .=
'&in_bookkeeping='.$in_bookkeeping;
1173 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
1187if ($action ==
'exportcsv' && !$error) {
1191 $filename =
'journal';
1192 $type_export =
'journal';
1193 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
1199 foreach ($tabfac as $key => $val) {
1200 $companystatic->id = $tabcompany[$key][
'id'];
1201 $companystatic->name = $tabcompany[$key][
'name'];
1202 $companystatic->accountancy_code_customer_general = (!empty($tabcompany[$key][
'accountancy_code_customer_general']) && $tabcompany[$key][
'accountancy_code_customer_general'] !=
'-1') ? $tabcompany[$key][
'accountancy_code_customer_general'] : $cptcli;
1203 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
1204 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
1205 $companystatic->code_client = $tabcompany[$key][
'code_client'];
1206 $companystatic->client = 3;
1208 $invoicestatic->id = (int) $key;
1209 $invoicestatic->ref = (
string) $val[
"ref"];
1210 $invoicestatic->type = (int) ($val[
"type"] ?? 0);
1211 $invoicestatic->close_code = (
string) ($val[
"close_code"] ??
'');
1216 $replacedinvoice = 0;
1217 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
1218 $replacedinvoice = 1;
1219 $alreadydispatched = $invoicestatic->getVentilExportCompta();
1220 if ($alreadydispatched) {
1221 $replacedinvoice = 2;
1226 if ($replacedinvoice == 1) {
1231 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key])) {
1232 foreach ($tabwarranty[$key] as $k => $mt) {
1234 print
'"'.$key.
'"'.$sep;
1235 print
'"'.$date.
'"'.$sep;
1236 print
'"'.((string) ($val[
"ref"] ??
'')).
'"'.$sep;
1237 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
1238 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
1239 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY')).
'"'.$sep;
1240 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
1241 print
'"'.$langs->trans(
"ThirdParty").
'"'.$sep;
1242 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"RetainedWarranty"))).
'"'.$sep;
1243 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1244 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1245 print
'"'.$journal.
'"';
1252 foreach ($tabttc[$key] as $k => $mt) {
1254 print
'"'.$key.
'"'.$sep;
1255 print
'"'.$date.
'"'.$sep;
1256 print
'"'.((string) ($val[
"ref"] ??
'')).
'"'.$sep;
1257 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
1258 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
1259 print
'"'.length_accountg($companystatic->accountancy_code_customer_general).
'"'.$sep;
1260 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
1261 print
'"'.$langs->trans(
"ThirdParty").
'"'.$sep;
1262 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"ThirdParty"))).
'"'.$sep;
1263 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1264 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1265 print
'"'.$journal.
'"';
1271 foreach ($tabht[$key] as $k => $mt) {
1273 $accountingaccount->fetch(0, $k,
true);
1275 print
'"'.$key.
'"'.$sep;
1276 print
'"'.$date.
'"'.$sep;
1277 print
'"'.((string) ($val[
"ref"] ??
'')).
'"'.$sep;
1278 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
1279 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1280 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1282 print
'"'.csvClean(
dol_trunc($accountingaccount->label, 32)).
'"'.$sep;
1283 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $accountingaccount->label)).
'"'.$sep;
1284 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1285 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1286 print
'"'.$journal.
'"';
1292 $listoftax = array(0, 1, 2);
1293 foreach ($listoftax as $numtax) {
1294 $arrayofvat = $tabtva;
1296 $arrayofvat = $tablocaltax1;
1299 $arrayofvat = $tablocaltax2;
1302 foreach ($arrayofvat[$key] as $k => $mt) {
1304 print
'"'.$key.
'"'.$sep;
1305 print
'"'.$date.
'"'.$sep;
1306 print
'"'.((string) ($val[
"ref"] ??
'')).
'"'.$sep;
1307 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
1308 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1309 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1311 print
'"'.$langs->trans(
"VAT").
' - '.implode(
', ', $def_tva[$key][$k]).
' %"'.$sep;
1312 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"VAT").implode($def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
''))).
'"'.$sep;
1313 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1314 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1315 print
'"'.$journal.
'"';
1322 if (isset($tabrevenuestamp[$key])) {
1323 foreach ($tabrevenuestamp[$key] as $k => $mt) {
1325 print
'"'.$key.
'"'.$sep;
1326 print
'"'.$date.
'"'.$sep;
1327 print
'"'.((string) ($val[
"ref"] ??
'')).
'"'.$sep;
1328 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
1329 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1330 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1332 print
'"'.$langs->trans(
"RevenueStamp").
'"'.$sep;
1333 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"RevenueStamp"))).
'"'.$sep;
1334 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1335 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1336 print
'"'.$journal.
'"';
1342 if ($manageCustomerDepositInInvoice) {
1344 if (isset($tabCustomerDiscountTTC[$key])) {
1345 foreach ($tabCustomerDiscountTTC[$key] as $k => $mt) {
1347 print
'"' . $key .
'"' . $sep;
1348 print
'"' . $date .
'"' . $sep;
1349 print
'"' . ((
string) ($val[
"ref"] ??
'')) .
'"' . $sep;
1352 print
'"' .
length_accountg($companystatic->accountancy_code_customer_general) .
'"' . $sep;
1354 print
'"' . $langs->trans(
"ThirdParty") .
'"' . $sep;
1355 print
'"' .
csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"ThirdParty")) . $labelCustomerDiscountExtension) .
'"' . $sep;
1356 print
'"' . ($mt >= 0 ?
price($mt) :
'') .
'"' . $sep;
1357 print
'"' . ($mt < 0 ?
price(-$mt) :
'') .
'"' . $sep;
1358 print
'"' . $journal .
'"';
1365 if (isset($tabCustomerDiscountHT[$key])) {
1366 foreach ($tabCustomerDiscountHT[$key] as $k => $mt) {
1368 $accountingaccount->fetch(0, $k,
true);
1370 print
'"' . $key .
'"' . $sep;
1371 print
'"' . $date .
'"' . $sep;
1372 print
'"' . ((
string) ($val[
"ref"] ??
'')) .
'"' . $sep;
1378 print
'"' .
csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $accountingaccount->label) . $labelCustomerDiscountExtension) .
'"' . $sep;
1379 print
'"' . ($mt < 0 ?
price(-$mt) :
'') .
'"' . $sep;
1380 print
'"' . ($mt >= 0 ?
price($mt) :
'') .
'"' . $sep;
1381 print
'"' . $journal .
'"';
1388 if (isset($tabCustomerDiscountVAT[$key])) {
1389 foreach ($tabCustomerDiscountVAT[$key] as $k => $mt) {
1391 print
'"' . $key .
'"' . $sep;
1392 print
'"' . $date .
'"' . $sep;
1393 print
'"' . ((
string) ($val[
"ref"] ??
'')) .
'"' . $sep;
1398 print
'"' . $langs->trans(
"VAT") .
' - ' . implode(
', ', $def_tva[$key][$k]) .
' %"' . $sep;
1399 print
'"' .
csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"VAT") . implode($def_tva[$key][$k]) .
' %') . $labelCustomerDiscountExtension) .
'"' . $sep;
1400 print
'"' . ($mt < 0 ?
price(-$mt) :
'') .
'"' . $sep;
1401 print
'"' . ($mt >= 0 ?
price($mt) :
'') .
'"' . $sep;
1402 print
'"' . $journal .
'"';
1413if (empty($action) || $action ==
'view') {
1414 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
1415 $help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité';
1423 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
1425 $description .= $langs->trans(
"DepositsAreNotIncluded");
1427 $description .= $langs->trans(
"DepositsAreIncluded");
1430 $listofchoices = array(
'notyet' => $langs->trans(
"NotYetInGeneralLedger"),
'already' => $langs->trans(
"AlreadyInGeneralLedger"));
1431 $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);
1432 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
1434 $varlink =
'id_journal='.$id_journal;
1436 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
1441 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int)
$conf->entity);
1442 $resql =
$db->query($sql);
1444 $obj =
$db->fetch_object($resql);
1445 if ($obj->nb == 0) {
1446 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
1447 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
1448 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
1458 $acctCustomerNotConfigured = in_array(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'), [
'',
'-1']);
1459 if ($acctCustomerNotConfigured) {
1460 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
1461 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
1462 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
1466 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
1467 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
1468 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
1470 if ($acctCustomerNotConfigured) {
1471 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
1473 if ($in_bookkeeping ==
'notyet') {
1474 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
1476 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
1483 <script type="text/javascript">
1484 function launch_export() {
1485 $("div.fiche form input[name=\"action\"]").val("exportcsv");
1486 $("div.fiche form input[type=\"submit\"]").click();
1487 $("div.fiche form input[name=\"action\"]").val("");
1489 function writebookkeeping() {
1490 console.log("click on writebookkeeping");
1491 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
1492 $("div.fiche form input[type=\"submit\"]").click();
1493 $("div.fiche form input[name=\"action\"]").val("");
1502 print
'<div class="div-table-responsive">';
1503 print
"<table class=\"noborder\" width=\"100%\">";
1504 print
"<tr class=\"liste_titre\">";
1505 print
"<td>".$langs->trans(
"Date").
"</td>";
1506 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"InvoiceRef").
")</td>";
1507 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
1508 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
1509 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
1510 print
'<td class="center">'.$langs->trans(
"AccountingDebit").
"</td>";
1511 print
'<td class="center">'.$langs->trans(
"AccountingCredit").
"</td>";
1520 foreach ($tabfac as $key => $val) {
1521 $companystatic->id = $tabcompany[$key][
'id'];
1522 $companystatic->name = $tabcompany[$key][
'name'];
1523 $companystatic->accountancy_code_customer_general = (!empty($tabcompany[$key][
'accountancy_code_customer_general']) && $tabcompany[$key][
'accountancy_code_customer_general'] !=
'-1') ? $tabcompany[$key][
'accountancy_code_customer_general'] : $cptcli;
1524 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
1525 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
1526 $companystatic->code_client = $tabcompany[$key][
'code_client'];
1527 $companystatic->client = 3;
1529 $invoicestatic->id = (int) $key;
1530 $invoicestatic->ref = (
string) $val[
"ref"];
1531 $invoicestatic->type = (int) ($val[
"type"] ?? 0);
1532 $invoicestatic->close_code = (
string) ($val[
"close_code"] ??
'');
1537 $replacedinvoice = 0;
1538 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
1539 $replacedinvoice = 1;
1540 $alreadydispatched = $invoicestatic->getVentilExportCompta();
1541 if ($alreadydispatched) {
1542 $replacedinvoice = 2;
1547 if ($replacedinvoice == 1) {
1548 print
'<tr class="oddeven">';
1549 print
"<!-- Replaced invoice -->";
1550 print
"<td>".$date.
"</td>";
1551 print
"<td><strike>".$invoicestatic->getNomUrl(1).
"</strike></td>";
1554 print $langs->trans(
"Replaced");
1561 print
'<td class="right"></td>';
1562 print
'<td class="right"></td>';
1568 if (isset($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
1569 print
'<tr class="oddeven">';
1570 print
"<!-- Some lines are not bound -->";
1571 print
"<td>".$date.
"</td>";
1572 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1575 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $invoicestatic->ref).
'</span>';
1582 print
'<td class="right"></td>';
1583 print
'<td class="right"></td>';
1590 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key]) && is_array($tabwarranty[$key])) {
1591 foreach ($tabwarranty[$key] as $k => $mt) {
1592 print
'<tr class="oddeven">';
1593 print
"<!-- Thirdparty warranty -->";
1594 print
"<td>" . $date .
"</td>";
1595 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1599 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1600 print
'<span class="error">' . $langs->trans(
"MainAccountForRetainedWarrantyNotDefined") .
'</span>';
1602 print $accountoshow;
1608 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1609 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1611 print $accountoshow;
1614 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0), $invoicestatic->ref, $langs->trans(
"RetainedWarranty"), 1) .
"</td>";
1615 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1616 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1622 foreach ($tabttc[$key] as $k => $mt) {
1623 print
'<tr class="oddeven">';
1624 print
"<!-- Thirdparty -->";
1625 print
"<td>".$date.
"</td>";
1626 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1629 $accountoshow =
length_accountg($companystatic->accountancy_code_customer_general);
1630 if (($accountoshow ==
"") || $accountoshow ==
"-1" || $accountoshow ==
'NotDefined') {
1631 print
'<span class="error">'.$langs->trans(
"MainAccountForCustomersNotDefined").
'</span>';
1633 print $accountoshow;
1639 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1640 print
'<span class="error">'.$langs->trans(
"ThirdpartyAccountNotDefined").
'</span>';
1642 print $accountoshow;
1645 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $langs->trans(
"SubledgerAccount"), 1) .
"</td>";
1646 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1647 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1654 foreach ($tabht[$key] as $k => $mt) {
1655 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
1657 $accountingaccount->fetch(0, $k,
true);
1658 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
1660 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
1663 print
'<tr class="oddeven">';
1664 print
"<!-- Product -->";
1665 print
"<td>".$date.
"</td>";
1666 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1670 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1671 print
'<span class="error">'.$langs->trans(
"ProductNotDefined").
'</span>';
1673 print $accountoshow;
1682 } elseif (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1683 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1686 $companystatic->id = $tabcompany[$key][
'id'];
1687 $companystatic->name = $tabcompany[$key][
'name'];
1688 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $accountingaccount->label, 1) .
"</td>";
1689 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1690 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1697 $listoftax = array(0, 1, 2);
1698 foreach ($listoftax as $numtax) {
1699 $arrayofvat = $tabtva;
1701 $arrayofvat = $tablocaltax1;
1704 $arrayofvat = $tablocaltax2;
1708 foreach ($arrayofvat[$key] as $k => $mt) {
1710 print
'<tr class="oddeven">';
1711 print
"<!-- VAT -->";
1712 print
"<td>".$date.
"</td>";
1713 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1717 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1718 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"AccountingJournalType2").
')</span>';
1720 print $accountoshow;
1728 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : implode(
', ', $def_tva[$key][$k]));
1729 $labelvatrate = $langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
1730 $labelvatrate .= ($numtax ?
' - Localtax '.$numtax :
'');
1731 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $labelvatrate, 1) .
"</td>";
1732 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1733 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1742 if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) {
1743 foreach ($tabrevenuestamp[$key] as $k => $mt) {
1744 print
'<tr class="oddeven">';
1745 print
"<!-- Thirdparty revenuestamp -->";
1746 print
"<td>" . $date .
"</td>";
1747 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1751 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1752 print
'<span class="error">' . $langs->trans(
"MainAccountForRevenueStampSaleNotDefined") .
'</span>';
1754 print $accountoshow;
1760 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $langs->trans(
"RevenueStamp"), 1) .
"</td>";
1761 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1762 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1767 if ($manageCustomerDepositInInvoice) {
1769 if (isset($tabCustomerDiscountTTC[$key])) {
1770 foreach ($tabCustomerDiscountTTC[$key] as $k => $mt) {
1771 print
'<tr class="oddeven">';
1772 print
"<!-- Discount TTC -->";
1773 print
"<td>" . $date .
"</td>";
1774 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1778 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1779 print
'<span class="error">' . $langs->trans(
"MainAccountForCustomersNotDefined") .
'</span>';
1781 print $accountoshow;
1787 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1788 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1790 print $accountoshow;
1793 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $langs->trans(
"SubledgerAccount") . $labelCustomerDiscountExtension, 1) .
"</td>";
1794 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1795 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1803 if (isset($tabCustomerDiscountHT[$key])) {
1804 foreach ($tabCustomerDiscountHT[$key] as $k => $mt) {
1805 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
1807 $accountingaccount->fetch(0, $k,
true);
1808 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
1810 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
1813 print
'<tr class="oddeven">';
1814 print
"<!-- Discount HT -->";
1815 print
"<td>" . $date .
"</td>";
1816 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1820 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1821 print
'<span class="error">' . $langs->trans(
"ProductNotDefined") .
'</span>';
1823 print $accountoshow;
1832 } elseif (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1833 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1836 $companystatic->id = $tabcompany[$key][
'id'];
1837 $companystatic->name = $tabcompany[$key][
'name'];
1838 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $accountingaccount->label, 1) . $labelCustomerDiscountExtension .
"</td>";
1839 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1840 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1848 if (isset($tabCustomerDiscountVAT[$key])) {
1849 foreach ($tabCustomerDiscountVAT[$key] as $k => $mt) {
1850 print
'<tr class="oddeven">';
1851 print
"<!-- Discount VAT -->";
1852 print
"<td>" . $date .
"</td>";
1853 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1857 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1858 print
'<span class="error">' . $langs->trans(
"VATAccountNotDefined") .
' (' . $langs->trans(
"AccountingJournalType2") .
')</span>';
1860 print $accountoshow;
1866 $tmpvatrate = (empty($def_tva[$key][$k]) ?
'' : implode(
', ', $def_tva[$key][$k]));
1867 $labelvatrate = $langs->trans(
"Taxes") .
' ' . $tmpvatrate .
' %';
1868 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $labelvatrate, 1) . $labelCustomerDiscountExtension .
"</td>";
1869 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1870 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1880 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)
journalHead($nom, $variant, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='', $moreoptions=array())
Show header of a page used to transfer/dispatch data in accounting.
getDefaultDatesForTransfer()
Return Default dates for transfer based on periodicity option in accountancy setup.
length_accounta($accounta)
Return Auxiliary accounting account of thirdparties with defined length.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
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 absolute discounts.
Class to manage invoices.
const TYPE_REPLACEMENT
Replacement invoice.
const TYPE_STANDARD
Standard 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.
$date_start
Variables from include:
csvClean($newvalue, $charset='', $separator='')
Clean a cell to respect rules of CSV file cells.
dol_now($mode='gmt')
Return date for now.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formatted 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 '.
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.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.