37require
'../../main.inc.php';
46require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
49require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/societe/class/client.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeeping.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/class/discount.class.php';
57$langs->loadLangs(array(
"commercial",
"compta",
"bills",
"other",
"accountancy",
"errors"));
60$action =
GETPOST(
'action',
'aZ09');
62$date_startmonth =
GETPOSTINT(
'date_startmonth');
68$in_bookkeeping =
GETPOST(
'in_bookkeeping');
69if ($in_bookkeeping ==
'') {
70 $in_bookkeeping =
'notyet';
75$hookmanager->initHooks(array(
'sellsjournal'));
82if ($user->socid > 0) {
85if (!$user->hasRight(
'accounting',
'bind',
'write')) {
94$tabwarranty = array();
96$tablocaltax1 = array();
97$tablocaltax2 = array();
98$tabCustomerDiscountHT = array();
99$tabCustomerDiscountVAT = array();
100$tabCustomerDiscountTTC = array();
103$manageCustomerDepositInInvoice = (
getDolGlobalInt(
'ACCOUNTING_MANAGE_CUSTOMER_DEPOSIT_IN_INVOICE') && !
getDolGlobalString(
'FACTURE_DEPOSITS_ARE_JUST_PAYMENTS'));
104$labelCustomerDiscountExtension =
' (AC)';
106$cptcli =
'NotDefined';
107$accountCustomerDeposit =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT',
'NotDefined');
108$accountCustomerDepositVAT =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_DEPOSIT_FOR_VAT',
'NotDefined');
114$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $user, $action);
120$accountingjournalstatic->fetch($id_journal);
121$journal = $accountingjournalstatic->code;
122$journal_label = $accountingjournalstatic->label;
125$date_end =
dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
128$pastmonthyear =
null;
130if (empty($date_startmonth)) {
134 $pastmonthyear = $dates[
'pastmonthyear'];
135 $pastmonth = $dates[
'pastmonth'];
137if (empty($date_endmonth)) {
140 $date_end = $dates[
'date_end'];
141 $pastmonthyear = $dates[
'pastmonthyear'];
142 $pastmonth = $dates[
'pastmonth'];
148if (!
GETPOSTISSET(
'date_startmonth') && (empty($date_start) || empty($date_end))) {
150 $date_end =
dol_get_last_day((
int) $pastmonthyear, (
int) $pastmonth,
false);
153$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,";
154$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,";
155$sql .=
" s.rowid as socid, s.nom as name, s.code_client, s.code_fournisseur, s.fk_pays,";
157 $sql .=
" spe.accountancy_code_customer_general,";
158 $sql .=
" spe.accountancy_code_customer as code_compta_client,";
159 $sql .=
" spe.accountancy_code_supplier_general,";
160 $sql .=
" spe.accountancy_code_supplier as code_compta_fournisseur,";
162 $sql .=
" s.accountancy_code_customer_general,";
163 $sql .=
" s.code_compta as code_compta_client,";
164 $sql .=
" s.accountancy_code_supplier_general,";
165 $sql .=
" s.code_compta_fournisseur,";
167$sql .=
" p.rowid as pid, p.ref as pref, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte,";
169 $sql .=
" ppe.accountancy_code_sell";
171 $sql .=
" p.accountancy_code_sell";
173$parameters = array();
174$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
175$sql .= $hookmanager->resPrint;
176$sql .=
" FROM ".MAIN_DB_PREFIX.
"facturedet as fd";
177$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = fd.fk_product";
179 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int)
$conf->entity);
181$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
182$sql .=
" JOIN ".MAIN_DB_PREFIX.
"facture as f ON f.rowid = fd.fk_facture";
183$sql .=
" JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = f.fk_soc";
185 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int)
$conf->entity);
187$parameters = array();
188$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters);
189$sql .= $hookmanager->resPrint;
190$sql .=
" WHERE fd.fk_code_ventilation > 0";
191$sql .=
" AND f.entity IN (".getEntity(
'invoice', 0).
')';
192$sql .=
" AND f.fk_statut > 0";
198$sql .=
" AND fd.product_type IN (0,1)";
199if ($date_start && $date_end) {
200 $sql .=
" AND f.datef >= '".$db->idate($date_start).
"' AND f.datef <= '".
$db->idate($date_end).
"'";
203 $sql .=
" AND (f.module_source IS NULL OR f.module_source <> 'takepos')";
207 $sql .=
" AND f.datef >= '".$db->idate(
getDolGlobalInt(
'ACCOUNTING_DATE_START_BINDING')).
"'";
210if ($in_bookkeeping ==
'already') {
211 $sql .=
" AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
214if ($in_bookkeeping ==
'notyet') {
215 $sql .=
" AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='customer_invoice')";
218if ($manageCustomerDepositInInvoice) {
221 $sql .=
" AND COALESCE(fd.fk_remise_except, 0) NOT IN (SELECT re.rowid FROM ".$db->prefix().
"societe_remise_except as re";
222 $sql .=
" INNER JOIN ".$db->prefix().
"facture as fs ON fs.rowid = re.fk_facture_source";
223 $sql .=
" WHERE fs.type = ".Facture::TYPE_DEPOSIT.
" AND re.description LIKE '(DEPOSIT)%')";
225$parameters = array();
226$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
227$sql .= $hookmanager->resPrint;
228$sql .=
" ORDER BY f.datef, f.ref";
231dol_syslog(
'accountancy/journal/sellsjournal.php', LOG_DEBUG);
236$tabwarranty = array();
237$tabrevenuestamp = array();
239$tablocaltax1 = array();
240$tablocaltax2 = array();
241$tabcompany = array();
242$vatdata_cache = array();
243$tabCustomerDiscountHT = array();
244$tabCustomerDiscountVAT = array();
245$tabCustomerDiscountTTC = array();
253$result =
$db->query($sql);
255 $num =
$db->num_rows($result);
259 $obj =
$db->fetch_object($result);
262 $accountancy_code_customer_general = (!empty($obj->accountancy_code_customer_general) && $obj->accountancy_code_customer_general !=
'-1') ? $obj->accountancy_code_customer_general : $cptcli;
263 $compta_soc = (!empty($obj->code_compta_client)) ? $obj->code_compta_client : $cptcli;
265 $compta_prod = $obj->compte;
266 if (empty($compta_prod)) {
267 if ($obj->product_type == 0) {
276 $tax_id = $obj->tva_tx . ($obj->vat_src_code ?
' (' . $obj->vat_src_code .
')' :
'');
280 $vatdata_cache_key = $tax_id.
'_'.(int) $obj->fk_pays;
282 $vatdata_cache_key = $tax_id;
284 if (array_key_exists($vatdata_cache_key, $vatdata_cache)) {
285 $vatdata = $vatdata_cache[$vatdata_cache_key];
289 $buyer->fetch($obj->socid);
295 $vatdata_cache[$vatdata_cache_key] = $vatdata;
299 $compta_tva = $accountCustomerDepositVAT;
301 $compta_tva = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cpttva);
303 $compta_localtax1 = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cptlocaltax1);
304 $compta_localtax2 = (!empty($vatdata[
'accountancy_code_sell']) ? $vatdata[
'accountancy_code_sell'] : $cptlocaltax2);
307 if (
price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
308 $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.
')' :
''));
309 if ($obj->localtax1_tx > 0.0) {
310 $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.
')' :
''));
312 if ($obj->localtax2_tx > 0.0) {
313 $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.
')' :
''));
318 $situation_ratio = 1;
320 if ($obj->situation_cycle_ref) {
322 if ($obj->situation_percent == 0) {
323 $situation_ratio = 0;
326 $line->fetch($obj->fdid);
329 $prev_progress = $line->get_prev_progress($obj->rowid);
331 $situation_ratio = ($obj->situation_percent - $prev_progress) / $obj->situation_percent;
336 $revenuestamp = (float)
price2num($obj->revenuestamp,
'MT');
338 if ($manageCustomerDepositInInvoice && $obj->type ==
Facture::TYPE_STANDARD && !isset($tabfac[$obj->rowid])) {
341 $sql2 =
"SELECT re.rowid";
342 $sql2 .=
" FROM " .
$db->prefix() .
"societe_remise_except as re";
343 $sql2 .=
" INNER JOIN " .
$db->prefix() .
"facture as fs ON fs.rowid = re.fk_facture_source";
345 $sql2 .=
" AND (re.fk_facture = " . ((int) $obj->rowid);
346 $sql2 .=
" OR re.fk_facture_line IN (SELECT rowid FROM " .
$db->prefix() .
"facturedet WHERE fk_facture = " . ((int) $obj->rowid) .
")";
349 $resql2 =
$db->query($sql2);
351 if (
$db->num_rows($resql2) > 0) {
352 if (!isset($tabCustomerDiscountHT[$obj->rowid][$accountCustomerDeposit])) {
353 $tabCustomerDiscountHT[$obj->rowid][$accountCustomerDeposit] = 0;
355 if (!isset($tabCustomerDiscountVAT[$obj->rowid][$accountCustomerDepositVAT])) {
356 $tabCustomerDiscountVAT[$obj->rowid][$accountCustomerDepositVAT] = 0;
358 if (!isset($tabCustomerDiscountTTC[$obj->rowid][$compta_soc])) {
359 $tabCustomerDiscountTTC[$obj->rowid][$compta_soc] = 0;
362 while ($obj2 =
$db->fetch_object($resql2)) {
364 $customerDiscount->fetch($obj2->rowid);
367 $tabCustomerDiscountHT[$obj->rowid][$accountCustomerDeposit] -= $customerDiscount->total_ht;
368 $tabCustomerDiscountVAT[$obj->rowid][$accountCustomerDepositVAT] -= $customerDiscount->total_tva;
369 $tabCustomerDiscountTTC[$obj->rowid][$compta_soc] -= $customerDiscount->total_ttc;
379 $tabfac[$obj->rowid][
"date"] =
$db->jdate($obj->df);
380 $tabfac[$obj->rowid][
"datereg"] =
$db->jdate($obj->dlr);
381 $tabfac[$obj->rowid][
"ref"] = $obj->ref;
382 $tabfac[$obj->rowid][
"type"] = $obj->type;
383 $tabfac[$obj->rowid][
"description"] = $obj->label_compte;
384 $tabfac[$obj->rowid][
"close_code"] = $obj->close_code;
385 $tabfac[$obj->rowid][
"revenuestamp"] = $revenuestamp;
389 if (!isset($tabttc[$obj->rowid][$compta_soc])) {
390 $tabttc[$obj->rowid][$compta_soc] = 0;
392 if (!isset($tabht[$obj->rowid][$compta_prod])) {
393 $tabht[$obj->rowid][$compta_prod] = 0;
395 if (!isset($tabtva[$obj->rowid][$compta_tva])) {
396 $tabtva[$obj->rowid][$compta_tva] = 0;
398 if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
399 $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
401 if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) {
402 $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
411 $total_ttc = $obj->total_ttc * $situation_ratio;
413 $total_ttc = $obj->total_ttc;
417 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && $obj->retained_warranty > 0 && (!
getDolGlobalString(
'INVOICE_RETAINED_WARRANTY_LIMITED_TO_FINAL_SITUATION') || !empty($obj->situation_final))) {
418 $retained_warranty = (float)
price2num($total_ttc * $obj->retained_warranty / 100,
'MT');
419 $tabwarranty[$obj->rowid][$compta_soc] += $retained_warranty;
420 $total_ttc -= $retained_warranty;
423 $tabttc[$obj->rowid][$compta_soc] += $total_ttc;
424 $tabht[$obj->rowid][$compta_prod] += $obj->total_ht * $situation_ratio;
425 $tva_npr = ((($obj->info_bits & 1) == 1) ? 1 : 0);
428 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
429 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
430 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
432 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva * $situation_ratio;
433 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1 * $situation_ratio;
434 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2 * $situation_ratio;
438 $compta_revenuestamp =
'NotDefined';
439 if (!empty($revenuestamp)) {
440 $sqlrevenuestamp =
"SELECT accountancy_code_sell FROM ".MAIN_DB_PREFIX.
"c_revenuestamp";
441 $sqlrevenuestamp .=
" WHERE fk_pays = ".((int)
$mysoc->country_id);
442 $sqlrevenuestamp .=
" AND taux = ".((float) $revenuestamp);
443 $sqlrevenuestamp .=
" AND active = 1";
444 $resqlrevenuestamp =
$db->query($sqlrevenuestamp);
446 if ($resqlrevenuestamp) {
447 $num_rows_revenuestamp =
$db->num_rows($resqlrevenuestamp);
448 if ($num_rows_revenuestamp > 1) {
449 dol_print_error(
$db,
'Failed 2 or more lines for the revenue stamp of your country. Check the dictionary of revenue stamp.');
451 $objrevenuestamp =
$db->fetch_object($resqlrevenuestamp);
452 if ($objrevenuestamp) {
453 $compta_revenuestamp = $objrevenuestamp->accountancy_code_sell;
459 if (empty($tabrevenuestamp[$obj->rowid][$compta_revenuestamp]) && !empty($revenuestamp)) {
461 $tabttc[$obj->rowid][$compta_soc] += $obj->revenuestamp;
462 $tabrevenuestamp[$obj->rowid][$compta_revenuestamp] = $obj->revenuestamp;
465 $tabcompany[$obj->rowid] = array(
467 'name' => $obj->name,
468 'code_client' => $obj->code_client,
469 'accountancy_code_customer_general' => $accountancy_code_customer_general,
470 'code_compta' => $compta_soc
476 'tabfac' => &$tabfac,
478 'tabtva' => &$tabtva,
479 'def_tva' => &$def_tva,
480 'tabwarranty' => &$tabwarranty,
481 'tabrevenuestamp' => &$tabrevenuestamp,
482 'tabttc' => &$tabttc,
483 'tablocaltax1' => &$tablocaltax1,
484 'tablocaltax2' => &$tablocaltax2,
485 'tabcompany' => &$tabcompany,
486 'vatdata_cache' => &$vatdata_cache,
488 $reshook = $hookmanager->executeHooks(
'processingJournalData', $parameters);
493 if ($i >
getDolGlobalInt(
'ACCOUNTANCY_MAX_TOO_MANY_LINES_TO_PROCESS', 10000)) {
495 setEventMessages(
"ErrorTooManyLinesToProcessPleaseUseAMoreSelectiveFilter",
null,
'errors');
502 'tabfac' => &$tabfac,
504 'tabtva' => &$tabtva,
505 'def_tva' => &$def_tva,
506 'tabwarranty' => &$tabwarranty,
507 'tabrevenuestamp' => &$tabrevenuestamp,
508 'tabttc' => &$tabttc,
509 'tablocaltax1' => &$tablocaltax1,
510 'tablocaltax2' => &$tablocaltax2,
511 'tabcompany' => &$tabcompany,
512 'vatdata_cache' => &$vatdata_cache,
514 $reshook = $hookmanager->executeHooks(
'processedJournalData', $parameters);
520$errorforinvoice = array();
542if (!empty($tabfac)) {
546 COUNT(fd.rowid) as nb
548 ".MAIN_DB_PREFIX.
"facturedet as fd
551 AND fd.fk_code_ventilation <= 0
552 AND fd.total_ttc <> 0
553 AND fk_facture IN (".
$db->sanitize(implode(
",", array_keys($tabfac))).
")
556 $resql =
$db->query($sql);
558 $num =
$db->num_rows($resql);
561 $obj =
$db->fetch_object($resql);
563 $errorforinvoice[$obj->fk_facture] =
'somelinesarenotbound';
572if ($action ==
'writebookkeeping' && !$error && $user->hasRight(
'accounting',
'bind',
'write')) {
581 $accountingaccountcustomer->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'),
true);
584 $accountingaccountcustomerwarranty->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY'),
true);
586 foreach ($tabfac as $key => $val) {
594 $companystatic->id = $tabcompany[$key][
'id'];
595 $companystatic->name = $tabcompany[$key][
'name'];
596 $companystatic->accountancy_code_customer_general = $tabcompany[$key][
'accountancy_code_customer_general'];
597 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
598 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
599 $companystatic->code_client = $tabcompany[$key][
'code_client'];
600 $companystatic->client = 3;
602 $invoicestatic->id = (int) $key;
603 $invoicestatic->ref = (
string) $val[
"ref"];
604 $invoicestatic->type = (int) ($val[
"type"] ?? 0);
605 $invoicestatic->close_code = (
string) ($val[
"close_code"] ??
'');
610 $replacedinvoice = 0;
611 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
612 $replacedinvoice = 1;
613 $alreadydispatched = $invoicestatic->getVentilExportCompta();
614 if ($alreadydispatched) {
615 $replacedinvoice = 2;
620 if ($replacedinvoice == 1) {
626 if (isset($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
629 setEventMessages($langs->trans(
'ErrorInvoiceContainsLinesNotYetBounded', (
string) ($val[
'ref'] ??
'')),
null,
'errors');
634 if (isset($tabwarranty[$key]) && is_array($tabwarranty[$key])) {
635 foreach ($tabwarranty[$key] as $k => $mt) {
637 $bookkeeping->doc_date = $val[
"date"];
638 $bookkeeping->date_lim_reglement = $val[
"datereg"];
639 $bookkeeping->doc_ref = $val[
"ref"];
640 $bookkeeping->date_creation = $now;
641 $bookkeeping->doc_type =
'customer_invoice';
642 $bookkeeping->fk_doc = (int) $key;
643 $bookkeeping->fk_docdet = 0;
644 $bookkeeping->thirdparty_code = $companystatic->code_client;
646 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
647 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
649 $bookkeeping->numero_compte =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY');
650 $bookkeeping->label_compte = $accountingaccountcustomerwarranty->label;
652 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"RetainedWarranty"));
653 $bookkeeping->montant = $mt;
654 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
655 $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
656 $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
657 $bookkeeping->code_journal = $journal;
658 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
659 $bookkeeping->fk_user_author = $user->id;
660 $bookkeeping->entity =
$conf->entity;
662 $totaldebit += $bookkeeping->debit;
663 $totalcredit += $bookkeeping->credit;
665 $result = $bookkeeping->create($user);
667 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
670 $errorforinvoice[$key] =
'alreadyjournalized';
675 $errorforinvoice[$key] =
'other';
684 if (!$errorforline) {
685 foreach ($tabttc[$key] as $k => $mt) {
687 $bookkeeping->doc_date = $val[
"date"];
688 $bookkeeping->date_lim_reglement = $val[
"datereg"];
689 $bookkeeping->doc_ref = $val[
"ref"];
690 $bookkeeping->date_creation = $now;
691 $bookkeeping->doc_type =
'customer_invoice';
692 $bookkeeping->fk_doc = (int) $key;
693 $bookkeeping->fk_docdet = 0;
694 $bookkeeping->thirdparty_code = $companystatic->code_client;
696 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
697 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
699 $bookkeeping->numero_compte = (!empty($tabcompany[$key][
'accountancy_code_customer_general']) && $tabcompany[$key][
'accountancy_code_customer_general'] !=
'-1') ? $tabcompany[$key][
'accountancy_code_customer_general'] : $cptcli;
700 $bookkeeping->label_compte = $accountingaccountcustomer->label;
702 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"SubledgerAccount"));
703 $bookkeeping->montant = $mt;
704 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
705 $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
706 $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
707 $bookkeeping->code_journal = $journal;
708 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
709 $bookkeeping->fk_user_author = $user->id;
710 $bookkeeping->entity =
$conf->entity;
712 $totaldebit += $bookkeeping->debit;
713 $totalcredit += $bookkeeping->credit;
715 $result = $bookkeeping->create($user);
717 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
720 $errorforinvoice[$key] =
'alreadyjournalized';
725 $errorforinvoice[$key] =
'other';
730 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
733 $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id));
740 if (!$errorforline) {
741 foreach ($tabht[$key] as $k => $mt) {
742 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
744 $accountingaccount->fetch(0, $k,
true);
745 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
747 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
750 $label_account = $accountingaccount->label;
753 if ($accountingaccount->id > 0) {
755 $bookkeeping->doc_date = $val[
"date"];
756 $bookkeeping->date_lim_reglement = $val[
"datereg"];
757 $bookkeeping->doc_ref = $val[
"ref"];
758 $bookkeeping->date_creation = $now;
759 $bookkeeping->doc_type =
'customer_invoice';
760 $bookkeeping->fk_doc = (int) $key;
761 $bookkeeping->fk_docdet = 0;
762 $bookkeeping->thirdparty_code = $companystatic->code_client;
766 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
767 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
769 $bookkeeping->subledger_account =
'';
770 $bookkeeping->subledger_label =
'';
773 $bookkeeping->subledger_account =
'';
774 $bookkeeping->subledger_label =
'';
777 $bookkeeping->numero_compte = $k;
778 $bookkeeping->label_compte = $label_account;
780 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $label_account);
781 $bookkeeping->montant = $mt;
782 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
783 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
784 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
785 $bookkeeping->code_journal = $journal;
786 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
787 $bookkeeping->fk_user_author = $user->id;
788 $bookkeeping->entity =
$conf->entity;
790 $totaldebit += $bookkeeping->debit;
791 $totalcredit += $bookkeeping->credit;
793 $result = $bookkeeping->create($user);
795 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
798 $errorforinvoice[$key] =
'alreadyjournalized';
803 $errorforinvoice[$key] =
'other';
812 if (!$errorforline) {
813 $listoftax = array(0, 1, 2);
814 foreach ($listoftax as $numtax) {
815 $arrayofvat = $tabtva;
817 $arrayofvat = $tablocaltax1;
820 $arrayofvat = $tablocaltax2;
823 foreach ($arrayofvat[$key] as $k => $mt) {
825 if (empty(
$conf->cache[
'accountingaccountincurrententity_vat'][$k])) {
827 $accountingaccount->fetch(0, $k,
true);
828 $conf->cache[
'accountingaccountincurrententity_vat'][$k] = $accountingaccount;
830 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity_vat'][$k];
833 $label_account = $accountingaccount->label;
836 $bookkeeping->doc_date = $val[
"date"];
837 $bookkeeping->date_lim_reglement = $val[
"datereg"];
838 $bookkeeping->doc_ref = $val[
"ref"];
839 $bookkeeping->date_creation = $now;
840 $bookkeeping->doc_type =
'customer_invoice';
841 $bookkeeping->fk_doc = (int) $key;
842 $bookkeeping->fk_docdet = 0;
843 $bookkeeping->thirdparty_code = $companystatic->code_client;
845 $bookkeeping->subledger_account =
'';
846 $bookkeeping->subledger_label =
'';
848 $bookkeeping->numero_compte = $k;
849 $bookkeeping->label_compte = $label_account;
852 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : implode(
', ', $def_tva[$key][$k]));
853 $labelvataccount = $langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
854 $labelvataccount .= ($numtax ?
' - Localtax '.$numtax :
'');
855 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $labelvataccount);
857 $bookkeeping->montant = $mt;
858 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
859 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
860 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
861 $bookkeeping->code_journal = $journal;
862 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
863 $bookkeeping->fk_user_author = $user->id;
864 $bookkeeping->entity =
$conf->entity;
866 $totaldebit += $bookkeeping->debit;
867 $totalcredit += $bookkeeping->credit;
869 $result = $bookkeeping->create($user);
871 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
874 $errorforinvoice[$key] =
'alreadyjournalized';
879 $errorforinvoice[$key] =
'other';
889 if (!$errorforline) {
890 if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) {
891 foreach ($tabrevenuestamp[$key] as $k => $mt) {
893 if (empty(
$conf->cache[
'accountingaccountincurrententity_rs'][$k])) {
895 $accountingaccount->fetch(0, $k,
true);
896 $conf->cache[
'accountingaccountincurrententity_rs'][$k] = $accountingaccount;
898 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity_rs'][$k];
901 $label_account = $accountingaccount->label;
904 $bookkeeping->doc_date = $val[
"date"];
905 $bookkeeping->date_lim_reglement = $val[
"datereg"];
906 $bookkeeping->doc_ref = $val[
"ref"];
907 $bookkeeping->date_creation = $now;
908 $bookkeeping->doc_type =
'customer_invoice';
909 $bookkeeping->fk_doc = (int) $key;
910 $bookkeeping->fk_docdet = 0;
911 $bookkeeping->thirdparty_code = $companystatic->code_client;
913 $bookkeeping->subledger_account =
'';
914 $bookkeeping->subledger_label =
'';
916 $bookkeeping->numero_compte = $k;
917 $bookkeeping->label_compte = $label_account;
919 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"RevenueStamp"));
920 $bookkeeping->montant = $mt;
921 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
922 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
923 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
924 $bookkeeping->code_journal = $journal;
925 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
926 $bookkeeping->fk_user_author = $user->id;
927 $bookkeeping->entity =
$conf->entity;
929 $totaldebit += $bookkeeping->debit;
930 $totalcredit += $bookkeeping->credit;
932 $result = $bookkeeping->create($user);
934 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
937 $errorforinvoice[$key] =
'alreadyjournalized';
942 $errorforinvoice[$key] =
'other';
951 if ($manageCustomerDepositInInvoice) {
953 if (!$errorforline && isset($tabCustomerDiscountTTC[$key])) {
954 foreach ($tabCustomerDiscountTTC[$key] as $k => $mt) {
956 $bookkeeping->doc_date = $val[
"date"];
957 $bookkeeping->date_lim_reglement = $val[
"datereg"];
958 $bookkeeping->doc_ref = $val[
"ref"];
959 $bookkeeping->date_creation = $now;
960 $bookkeeping->doc_type =
'customer_invoice';
961 $bookkeeping->fk_doc = $key;
962 $bookkeeping->fk_docdet = 0;
963 $bookkeeping->thirdparty_code = $companystatic->code_client;
965 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
966 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
970 $bookkeeping->label_compte = $accountingaccountcustomer->label;
972 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"SubledgerAccount") . $labelCustomerDiscountExtension);
973 $bookkeeping->montant = $mt;
974 $bookkeeping->sens = ($mt >= 0) ?
'D' :
'C';
975 $bookkeeping->debit = ($mt >= 0) ? $mt : 0;
976 $bookkeeping->credit = ($mt < 0) ? -$mt : 0;
977 $bookkeeping->code_journal = $journal;
978 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
979 $bookkeeping->fk_user_author = $user->id;
980 $bookkeeping->entity =
$conf->entity;
982 $totaldebit += $bookkeeping->debit;
983 $totalcredit += $bookkeeping->credit;
985 $result = $bookkeeping->create($user);
987 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
990 $errorforinvoice[$key] =
'alreadyjournalized';
994 $errorforinvoice[$key] =
'other';
999 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
1002 $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id));
1009 if (!$errorforline && isset($tabCustomerDiscountHT[$key])) {
1010 foreach ($tabCustomerDiscountHT[$key] as $k => $mt) {
1011 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
1013 $accountingaccount->fetch(0, $k,
true);
1014 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
1016 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
1019 $label_account = $accountingaccount->label;
1022 if ($accountingaccount->id > 0) {
1024 $bookkeeping->doc_date = $val[
"date"];
1025 $bookkeeping->date_lim_reglement = $val[
"datereg"];
1026 $bookkeeping->doc_ref = $val[
"ref"];
1027 $bookkeeping->date_creation = $now;
1028 $bookkeeping->doc_type =
'customer_invoice';
1029 $bookkeeping->fk_doc = $key;
1030 $bookkeeping->fk_docdet = 0;
1031 $bookkeeping->thirdparty_code = $companystatic->code_client;
1035 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
1036 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
1038 $bookkeeping->subledger_account =
'';
1039 $bookkeeping->subledger_label =
'';
1042 $bookkeeping->subledger_account =
'';
1043 $bookkeeping->subledger_label =
'';
1046 $bookkeeping->numero_compte = $k;
1047 $bookkeeping->label_compte = $label_account;
1049 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $label_account) . $labelCustomerDiscountExtension;
1050 $bookkeeping->montant = $mt;
1051 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
1052 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
1053 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
1054 $bookkeeping->code_journal = $journal;
1055 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
1056 $bookkeeping->fk_user_author = $user->id;
1057 $bookkeeping->entity =
$conf->entity;
1059 $totaldebit += $bookkeeping->debit;
1060 $totalcredit += $bookkeeping->credit;
1062 $result = $bookkeeping->create($user);
1064 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
1067 $errorforinvoice[$key] =
'alreadyjournalized';
1071 $errorforinvoice[$key] =
'other';
1080 if (!$errorforline && isset($tabCustomerDiscountVAT[$key])) {
1081 foreach ($tabCustomerDiscountVAT[$key] as $k => $mt) {
1082 if (empty(
$conf->cache[
'accountingaccountincurrententity_vat'][$k])) {
1084 $accountingaccount->fetch(0, $k,
true);
1085 $conf->cache[
'accountingaccountincurrententity_vat'][$k] = $accountingaccount;
1087 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity_vat'][$k];
1090 $label_account = $accountingaccount->label;
1093 $bookkeeping->doc_date = $val[
"date"];
1094 $bookkeeping->date_lim_reglement = $val[
"datereg"];
1095 $bookkeeping->doc_ref = $val[
"ref"];
1096 $bookkeeping->date_creation = $now;
1097 $bookkeeping->doc_type =
'customer_invoice';
1098 $bookkeeping->fk_doc = $key;
1099 $bookkeeping->fk_docdet = 0;
1100 $bookkeeping->thirdparty_code = $companystatic->code_client;
1102 $bookkeeping->subledger_account =
'';
1103 $bookkeeping->subledger_label =
'';
1105 $bookkeeping->numero_compte = $k;
1106 $bookkeeping->label_compte = $label_account;
1108 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : implode(
', ', $def_tva[$key][$k]));
1109 $labelvataccount = $langs->trans(
"Taxes") .
' ' . $tmpvatrate .
' %';
1110 $bookkeeping->label_operation = $bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $labelvataccount) . $labelCustomerDiscountExtension;
1112 $bookkeeping->montant = $mt;
1113 $bookkeeping->sens = ($mt < 0) ?
'D' :
'C';
1114 $bookkeeping->debit = ($mt < 0) ? -$mt : 0;
1115 $bookkeeping->credit = ($mt >= 0) ? $mt : 0;
1116 $bookkeeping->code_journal = $journal;
1117 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
1118 $bookkeeping->fk_user_author = $user->id;
1119 $bookkeeping->entity =
$conf->entity;
1121 $totaldebit += $bookkeeping->debit;
1122 $totalcredit += $bookkeeping->credit;
1124 $result = $bookkeeping->create($user);
1126 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
1129 $errorforinvoice[$key] =
'alreadyjournalized';
1133 $errorforinvoice[$key] =
'other';
1142 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
1145 $errorforinvoice[$key] =
'amountsnotbalanced';
1146 setEventMessages(
'We Tried to insert a non balanced transaction in book for '.$invoicestatic->ref.
'. Canceled. Surely a bug.',
null,
'errors');
1149 if (!$errorforline) {
1155 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
1163 if (empty($error) && count($tabpay) > 0) {
1165 } elseif (count($tabpay) == $error) {
1168 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
1174 if (count($tabpay) != $error) {
1175 $param =
'id_journal='.$id_journal;
1176 $param .=
'&date_startday='.$date_startday;
1177 $param .=
'&date_startmonth='.$date_startmonth;
1178 $param .=
'&date_startyear='.$date_startyear;
1179 $param .=
'&date_endday='.$date_endday;
1180 $param .=
'&date_endmonth='.$date_endmonth;
1181 $param .=
'&date_endyear='.$date_endyear;
1182 $param .=
'&in_bookkeeping='.$in_bookkeeping;
1183 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
1197if ($action ==
'exportcsv' && !$error) {
1201 $filename =
'journal';
1202 $type_export =
'journal';
1203 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
1209 foreach ($tabfac as $key => $val) {
1210 $companystatic->id = $tabcompany[$key][
'id'];
1211 $companystatic->name = $tabcompany[$key][
'name'];
1212 $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;
1213 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
1214 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
1215 $companystatic->code_client = $tabcompany[$key][
'code_client'];
1216 $companystatic->client = 3;
1218 $invoicestatic->id = (int) $key;
1219 $invoicestatic->ref = (
string) $val[
"ref"];
1220 $invoicestatic->type = (int) ($val[
"type"] ?? 0);
1221 $invoicestatic->close_code = (
string) ($val[
"close_code"] ??
'');
1226 $replacedinvoice = 0;
1227 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
1228 $replacedinvoice = 1;
1229 $alreadydispatched = $invoicestatic->getVentilExportCompta();
1230 if ($alreadydispatched) {
1231 $replacedinvoice = 2;
1236 if ($replacedinvoice == 1) {
1241 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key])) {
1242 foreach ($tabwarranty[$key] as $k => $mt) {
1244 print
'"'.$key.
'"'.$sep;
1245 print
'"'.$date.
'"'.$sep;
1246 print
'"'.((string) ($val[
"ref"] ??
'')).
'"'.$sep;
1247 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
1248 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
1249 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER_RETAINED_WARRANTY')).
'"'.$sep;
1250 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
1251 print
'"'.$langs->trans(
"ThirdParty").
'"'.$sep;
1252 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"RetainedWarranty"))).
'"'.$sep;
1253 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1254 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1255 print
'"'.$journal.
'"';
1262 foreach ($tabttc[$key] as $k => $mt) {
1264 print
'"'.$key.
'"'.$sep;
1265 print
'"'.$date.
'"'.$sep;
1266 print
'"'.((string) ($val[
"ref"] ??
'')).
'"'.$sep;
1267 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
1268 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
1269 print
'"'.length_accountg($companystatic->accountancy_code_customer_general).
'"'.$sep;
1270 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
1271 print
'"'.$langs->trans(
"ThirdParty").
'"'.$sep;
1272 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"ThirdParty"))).
'"'.$sep;
1273 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1274 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1275 print
'"'.$journal.
'"';
1281 foreach ($tabht[$key] as $k => $mt) {
1283 $accountingaccount->fetch(0, $k,
true);
1285 print
'"'.$key.
'"'.$sep;
1286 print
'"'.$date.
'"'.$sep;
1287 print
'"'.((string) ($val[
"ref"] ??
'')).
'"'.$sep;
1288 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
1289 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1290 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1292 print
'"'.csvClean(
dol_trunc($accountingaccount->label, 32)).
'"'.$sep;
1293 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $accountingaccount->label)).
'"'.$sep;
1294 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1295 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1296 print
'"'.$journal.
'"';
1302 $listoftax = array(0, 1, 2);
1303 foreach ($listoftax as $numtax) {
1304 $arrayofvat = $tabtva;
1306 $arrayofvat = $tablocaltax1;
1309 $arrayofvat = $tablocaltax2;
1312 foreach ($arrayofvat[$key] as $k => $mt) {
1314 print
'"'.$key.
'"'.$sep;
1315 print
'"'.$date.
'"'.$sep;
1316 print
'"'.((string) ($val[
"ref"] ??
'')).
'"'.$sep;
1317 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
1318 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1319 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1321 print
'"'.$langs->trans(
"VAT").
' - '.implode(
', ', $def_tva[$key][$k]).
' %"'.$sep;
1322 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"VAT").implode($def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
''))).
'"'.$sep;
1323 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1324 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1325 print
'"'.$journal.
'"';
1332 if (isset($tabrevenuestamp[$key])) {
1333 foreach ($tabrevenuestamp[$key] as $k => $mt) {
1335 print
'"'.$key.
'"'.$sep;
1336 print
'"'.$date.
'"'.$sep;
1337 print
'"'.((string) ($val[
"ref"] ??
'')).
'"'.$sep;
1338 print
'"'.csvClean(
dol_trunc($companystatic->name, 32)).
'"'.$sep;
1339 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1340 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
1342 print
'"'.$langs->trans(
"RevenueStamp").
'"'.$sep;
1343 print
'"'.csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"RevenueStamp"))).
'"'.$sep;
1344 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
1345 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
1346 print
'"'.$journal.
'"';
1352 if ($manageCustomerDepositInInvoice) {
1354 if (isset($tabCustomerDiscountTTC[$key])) {
1355 foreach ($tabCustomerDiscountTTC[$key] as $k => $mt) {
1357 print
'"' . $key .
'"' . $sep;
1358 print
'"' . $date .
'"' . $sep;
1359 print
'"' . ((
string) ($val[
"ref"] ??
'')) .
'"' . $sep;
1362 print
'"' .
length_accountg($companystatic->accountancy_code_customer_general) .
'"' . $sep;
1364 print
'"' . $langs->trans(
"ThirdParty") .
'"' . $sep;
1365 print
'"' .
csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"ThirdParty")) . $labelCustomerDiscountExtension) .
'"' . $sep;
1366 print
'"' . ($mt >= 0 ?
price($mt) :
'') .
'"' . $sep;
1367 print
'"' . ($mt < 0 ?
price(-$mt) :
'') .
'"' . $sep;
1368 print
'"' . $journal .
'"';
1375 if (isset($tabCustomerDiscountHT[$key])) {
1376 foreach ($tabCustomerDiscountHT[$key] as $k => $mt) {
1378 $accountingaccount->fetch(0, $k,
true);
1380 print
'"' . $key .
'"' . $sep;
1381 print
'"' . $date .
'"' . $sep;
1382 print
'"' . ((
string) ($val[
"ref"] ??
'')) .
'"' . $sep;
1388 print
'"' .
csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $accountingaccount->label) . $labelCustomerDiscountExtension) .
'"' . $sep;
1389 print
'"' . ($mt < 0 ?
price(-$mt) :
'') .
'"' . $sep;
1390 print
'"' . ($mt >= 0 ?
price($mt) :
'') .
'"' . $sep;
1391 print
'"' . $journal .
'"';
1398 if (isset($tabCustomerDiscountVAT[$key])) {
1399 foreach ($tabCustomerDiscountVAT[$key] as $k => $mt) {
1401 print
'"' . $key .
'"' . $sep;
1402 print
'"' . $date .
'"' . $sep;
1403 print
'"' . ((
string) ($val[
"ref"] ??
'')) .
'"' . $sep;
1408 print
'"' . $langs->trans(
"VAT") .
' - ' . implode(
', ', $def_tva[$key][$k]) .
' %"' . $sep;
1409 print
'"' .
csvClean($bookkeepingstatic->accountingLabelForOperation($companystatic->name, $invoicestatic->ref, $langs->trans(
"VAT") . implode($def_tva[$key][$k]) .
' %') . $labelCustomerDiscountExtension) .
'"' . $sep;
1410 print
'"' . ($mt < 0 ?
price(-$mt) :
'') .
'"' . $sep;
1411 print
'"' . ($mt >= 0 ?
price($mt) :
'') .
'"' . $sep;
1412 print
'"' . $journal .
'"';
1423if (empty($action) || $action ==
'view') {
1424 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
1425 $help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité';
1433 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
1435 $description .= $langs->trans(
"DepositsAreNotIncluded");
1437 $description .= $langs->trans(
"DepositsAreIncluded");
1440 $listofchoices = array(
'notyet' => $langs->trans(
"NotYetInGeneralLedger"),
'already' => $langs->trans(
"AlreadyInGeneralLedger"));
1441 $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);
1442 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
1444 $varlink =
'id_journal='.$id_journal;
1446 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
1451 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int)
$conf->entity);
1452 $resql =
$db->query($sql);
1454 $obj =
$db->fetch_object($resql);
1455 if ($obj->nb == 0) {
1456 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
1457 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
1458 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
1468 $acctCustomerNotConfigured = in_array(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_CUSTOMER'), [
'',
'-1']);
1469 if ($acctCustomerNotConfigured) {
1470 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
1471 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
1472 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
1476 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
1477 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
1478 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
1480 if ($acctCustomerNotConfigured) {
1481 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
1483 if ($in_bookkeeping ==
'notyet') {
1484 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
1486 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
1493 <script type="text/javascript">
1494 function launch_export() {
1495 $("div.fiche form input[name=\"action\"]").val("exportcsv");
1496 $("div.fiche form input[type=\"submit\"]").click();
1497 $("div.fiche form input[name=\"action\"]").val("");
1499 function writebookkeeping() {
1500 console.log("click on writebookkeeping");
1501 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
1502 $("div.fiche form input[type=\"submit\"]").click();
1503 $("div.fiche form input[name=\"action\"]").val("");
1512 print
'<div class="div-table-responsive">';
1513 print
"<table class=\"noborder\" width=\"100%\">";
1514 print
"<tr class=\"liste_titre\">";
1515 print
"<td>".$langs->trans(
"Date").
"</td>";
1516 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"InvoiceRef").
")</td>";
1517 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
1518 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
1519 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
1520 print
'<td class="center">'.$langs->trans(
"AccountingDebit").
"</td>";
1521 print
'<td class="center">'.$langs->trans(
"AccountingCredit").
"</td>";
1530 foreach ($tabfac as $key => $val) {
1531 $companystatic->id = $tabcompany[$key][
'id'];
1532 $companystatic->name = $tabcompany[$key][
'name'];
1533 $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;
1534 $companystatic->code_compta = $tabcompany[$key][
'code_compta'];
1535 $companystatic->code_compta_client = $tabcompany[$key][
'code_compta'];
1536 $companystatic->code_client = $tabcompany[$key][
'code_client'];
1537 $companystatic->client = 3;
1539 $invoicestatic->id = (int) $key;
1540 $invoicestatic->ref = (
string) $val[
"ref"];
1541 $invoicestatic->type = (int) ($val[
"type"] ?? 0);
1542 $invoicestatic->close_code = (
string) ($val[
"close_code"] ??
'');
1547 $replacedinvoice = 0;
1548 if ($invoicestatic->close_code == Facture::CLOSECODE_REPLACED) {
1549 $replacedinvoice = 1;
1550 $alreadydispatched = $invoicestatic->getVentilExportCompta();
1551 if ($alreadydispatched) {
1552 $replacedinvoice = 2;
1557 if ($replacedinvoice == 1) {
1558 print
'<tr class="oddeven">';
1559 print
"<!-- Replaced invoice -->";
1560 print
"<td>".$date.
"</td>";
1561 print
"<td><strike>".$invoicestatic->getNomUrl(1).
"</strike></td>";
1564 print $langs->trans(
"Replaced");
1571 print
'<td class="right"></td>';
1572 print
'<td class="right"></td>';
1578 if (isset($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
1579 print
'<tr class="oddeven">';
1580 print
"<!-- Some lines are not bound -->";
1581 print
"<td>".$date.
"</td>";
1582 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1585 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $invoicestatic->ref).
'</span>';
1592 print
'<td class="right"></td>';
1593 print
'<td class="right"></td>';
1600 if (
getDolGlobalString(
'INVOICE_USE_RETAINED_WARRANTY') && isset($tabwarranty[$key]) && is_array($tabwarranty[$key])) {
1601 foreach ($tabwarranty[$key] as $k => $mt) {
1602 print
'<tr class="oddeven">';
1603 print
"<!-- Thirdparty warranty -->";
1604 print
"<td>" . $date .
"</td>";
1605 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1609 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1610 print
'<span class="error">' . $langs->trans(
"MainAccountForRetainedWarrantyNotDefined") .
'</span>';
1612 print $accountoshow;
1618 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1619 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1621 print $accountoshow;
1624 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0), $invoicestatic->ref, $langs->trans(
"RetainedWarranty"), 1) .
"</td>";
1625 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1626 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1632 foreach ($tabttc[$key] as $k => $mt) {
1633 print
'<tr class="oddeven">';
1634 print
"<!-- Thirdparty -->";
1635 print
"<td>".$date.
"</td>";
1636 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1639 $accountoshow =
length_accountg($companystatic->accountancy_code_customer_general);
1640 if (($accountoshow ==
"") || $accountoshow ==
"-1" || $accountoshow ==
'NotDefined') {
1641 print
'<span class="error">'.$langs->trans(
"MainAccountForCustomersNotDefined").
'</span>';
1643 print $accountoshow;
1649 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1650 print
'<span class="error">'.$langs->trans(
"ThirdpartyAccountNotDefined").
'</span>';
1652 print $accountoshow;
1655 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $langs->trans(
"SubledgerAccount"), 1) .
"</td>";
1656 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1657 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1664 foreach ($tabht[$key] as $k => $mt) {
1665 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
1667 $accountingaccount->fetch(0, $k,
true);
1668 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
1670 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
1673 print
'<tr class="oddeven">';
1674 print
"<!-- Product -->";
1675 print
"<td>".$date.
"</td>";
1676 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1680 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1681 print
'<span class="error">'.$langs->trans(
"ProductNotDefined").
'</span>';
1683 print $accountoshow;
1692 } elseif (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1693 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1696 $companystatic->id = $tabcompany[$key][
'id'];
1697 $companystatic->name = $tabcompany[$key][
'name'];
1698 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $accountingaccount->label, 1) .
"</td>";
1699 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1700 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1707 $listoftax = array(0, 1, 2);
1708 foreach ($listoftax as $numtax) {
1709 $arrayofvat = $tabtva;
1711 $arrayofvat = $tablocaltax1;
1714 $arrayofvat = $tablocaltax2;
1718 foreach ($arrayofvat[$key] as $k => $mt) {
1720 print
'<tr class="oddeven">';
1721 print
"<!-- VAT -->";
1722 print
"<td>".$date.
"</td>";
1723 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1727 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1728 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"AccountingJournalType2").
')</span>';
1730 print $accountoshow;
1738 $tmpvatrate = (empty($def_tva[$key][$k]) ? (empty($arrayofvat[$key][$k]) ?
'' : $arrayofvat[$key][$k]) : implode(
', ', $def_tva[$key][$k]));
1739 $labelvatrate = $langs->trans(
"Taxes").
' '.$tmpvatrate.
' %';
1740 $labelvatrate .= ($numtax ?
' - Localtax '.$numtax :
'');
1741 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $labelvatrate, 1) .
"</td>";
1742 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1743 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1752 if (isset($tabrevenuestamp[$key]) && is_array($tabrevenuestamp[$key])) {
1753 foreach ($tabrevenuestamp[$key] as $k => $mt) {
1754 print
'<tr class="oddeven">';
1755 print
"<!-- Thirdparty revenuestamp -->";
1756 print
"<td>" . $date .
"</td>";
1757 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1761 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1762 print
'<span class="error">' . $langs->trans(
"MainAccountForRevenueStampSaleNotDefined") .
'</span>';
1764 print $accountoshow;
1770 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $langs->trans(
"RevenueStamp"), 1) .
"</td>";
1771 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1772 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1777 if ($manageCustomerDepositInInvoice) {
1779 if (isset($tabCustomerDiscountTTC[$key])) {
1780 foreach ($tabCustomerDiscountTTC[$key] as $k => $mt) {
1781 print
'<tr class="oddeven">';
1782 print
"<!-- Discount TTC -->";
1783 print
"<td>" . $date .
"</td>";
1784 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1788 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1789 print
'<span class="error">' . $langs->trans(
"MainAccountForCustomersNotDefined") .
'</span>';
1791 print $accountoshow;
1797 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1798 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1800 print $accountoshow;
1803 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $langs->trans(
"SubledgerAccount") . $labelCustomerDiscountExtension, 1) .
"</td>";
1804 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1805 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1813 if (isset($tabCustomerDiscountHT[$key])) {
1814 foreach ($tabCustomerDiscountHT[$key] as $k => $mt) {
1815 if (empty(
$conf->cache[
'accountingaccountincurrententity'][$k])) {
1817 $accountingaccount->fetch(0, $k,
true);
1818 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
1820 $accountingaccount =
$conf->cache[
'accountingaccountincurrententity'][$k];
1823 print
'<tr class="oddeven">';
1824 print
"<!-- Discount HT -->";
1825 print
"<td>" . $date .
"</td>";
1826 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1830 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1831 print
'<span class="error">' . $langs->trans(
"ProductNotDefined") .
'</span>';
1833 print $accountoshow;
1842 } elseif (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1843 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1846 $companystatic->id = $tabcompany[$key][
'id'];
1847 $companystatic->name = $tabcompany[$key][
'name'];
1848 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $accountingaccount->label, 1) . $labelCustomerDiscountExtension .
"</td>";
1849 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1850 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1858 if (isset($tabCustomerDiscountVAT[$key])) {
1859 foreach ($tabCustomerDiscountVAT[$key] as $k => $mt) {
1860 print
'<tr class="oddeven">';
1861 print
"<!-- Discount VAT -->";
1862 print
"<td>" . $date .
"</td>";
1863 print
"<td>" . $invoicestatic->getNomUrl(1) .
"</td>";
1867 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1868 print
'<span class="error">' . $langs->trans(
"VATAccountNotDefined") .
' (' . $langs->trans(
"AccountingJournalType2") .
')</span>';
1870 print $accountoshow;
1876 $tmpvatrate = (empty($def_tva[$key][$k]) ?
'' : implode(
', ', $def_tva[$key][$k]));
1877 $labelvatrate = $langs->trans(
"Taxes") .
' ' . $tmpvatrate .
' %';
1878 print
"<td>" . $bookkeepingstatic->accountingLabelForOperation($companystatic->getNomUrl(0,
'customer'), $invoicestatic->ref, $labelvatrate, 1) . $labelCustomerDiscountExtension .
"</td>";
1879 print
'<td class="right nowraponall amount">' . ($mt < 0 ?
price(-$mt) :
'') .
"</td>";
1880 print
'<td class="right nowraponall amount">' . ($mt >= 0 ?
price($mt) :
'') .
"</td>";
1890 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.