32require
'../../main.inc.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
36require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
37require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.facture.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.class.php';
41require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeeping.class.php';
44$langs->loadLangs(array(
"commercial",
"compta",
"bills",
"other",
"accountancy",
"errors"));
47$action =
GETPOST(
'action',
'aZ09');
49$date_startmonth =
GETPOST(
'date_startmonth');
50$date_startday =
GETPOST(
'date_startday');
51$date_startyear =
GETPOST(
'date_startyear');
52$date_endmonth =
GETPOST(
'date_endmonth');
53$date_endday =
GETPOST(
'date_endday');
54$date_endyear =
GETPOST(
'date_endyear');
55$in_bookkeeping =
GETPOST(
'in_bookkeeping');
56if ($in_bookkeeping ==
'') {
57 $in_bookkeeping =
'notyet';
62$hookmanager->initHooks(array(
'purchasesjournal'));
66if (!isModEnabled(
'accounting')) {
69if ($user->socid > 0) {
72if (!$user->hasRight(
'accounting',
'bind',
'write')) {
83$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $user, $action);
89$accountingjournalstatic->fetch($id_journal);
90$journal = $accountingjournalstatic->code;
91$journal_label = $accountingjournalstatic->label;
93$date_start =
dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
94$date_end =
dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
96if (empty($date_startmonth)) {
99 $date_start = $dates[
'date_start'];
100 $pastmonthyear = $dates[
'pastmonthyear'];
101 $pastmonth = $dates[
'pastmonth'];
103if (empty($date_endmonth)) {
106 $date_end = $dates[
'date_end'];
107 $pastmonthyear = $dates[
'pastmonthyear'];
108 $pastmonth = $dates[
'pastmonth'];
111if (!GETPOSTISSET(
'date_startmonth') && (empty($date_start) || empty($date_end))) {
116$sql =
"SELECT f.rowid, f.ref as ref, f.type, f.datef as df, f.libelle as label, f.ref_supplier, f.date_lim_reglement as dlr, f.close_code, f.vat_reverse_charge,";
117$sql .=
" fd.rowid as fdid, fd.description, fd.product_type, fd.total_ht, fd.tva as total_tva, fd.total_localtax1, fd.total_localtax2, fd.tva_tx, fd.total_ttc, fd.vat_src_code, fd.info_bits,";
118$sql .=
" p.default_vat_code AS product_buy_default_vat_code, p.tva_tx as product_buy_vat, p.localtax1_tx as product_buy_localvat1, p.localtax2_tx as product_buy_localvat2,";
119$sql .=
" co.code as country_code, co.label as country_label,";
120$sql .=
" s.rowid as socid, s.nom as name, s.fournisseur, s.code_client, s.code_fournisseur, s.fk_pays,";
122 $sql .=
" spe.accountancy_code_customer as code_compta,";
123 $sql .=
" spe.accountancy_code_supplier as code_compta_fournisseur,";
125 $sql .=
" s.code_compta as code_compta,";
126 $sql .=
" s.code_compta_fournisseur,";
129 $sql .=
" ppe.accountancy_code_buy,";
131 $sql .=
" p.accountancy_code_buy,";
133$sql .=
" aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
134$parameters = array();
135$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
136$sql .= $hookmanager->resPrint;
137$sql .=
" FROM ".MAIN_DB_PREFIX.
"facture_fourn_det as fd";
138$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product as p ON p.rowid = fd.fk_product";
140 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"product_perentity as ppe ON ppe.fk_product = p.rowid AND ppe.entity = " . ((int) $conf->entity);
142$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON aa.rowid = fd.fk_code_ventilation";
143$sql .=
" JOIN ".MAIN_DB_PREFIX.
"facture_fourn as f ON f.rowid = fd.fk_facture_fourn";
144$sql .=
" JOIN ".MAIN_DB_PREFIX.
"societe as s ON s.rowid = f.fk_soc";
145$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as co ON co.rowid = s.fk_pays ";
147 $sql .=
" LEFT JOIN " . MAIN_DB_PREFIX .
"societe_perentity as spe ON spe.fk_soc = s.rowid AND spe.entity = " . ((int) $conf->entity);
149$parameters = array();
150$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters);
151$sql .= $hookmanager->resPrint;
152$sql .=
" WHERE f.fk_statut > 0";
153$sql .=
" AND fd.fk_code_ventilation > 0";
154$sql .=
" AND f.entity IN (".getEntity(
'facture_fourn', 0).
")";
160if ($date_start && $date_end) {
161 $sql .=
" AND f.datef >= '".$db->idate($date_start).
"' AND f.datef <= '".$db->idate($date_end).
"'";
165 $sql .=
" AND f.datef >= '".$db->idate(
getDolGlobalString(
'ACCOUNTING_DATE_START_BINDING')).
"'";
168if ($in_bookkeeping ==
'already') {
169 $sql .=
" AND f.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
171if ($in_bookkeeping ==
'notyet') {
172 $sql .=
" AND f.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='supplier_invoice')";
174$parameters = array();
175$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
176$sql .= $hookmanager->resPrint;
177$sql .=
" ORDER BY f.datef";
179dol_syslog(
'accountancy/journal/purchasesjournal.php', LOG_DEBUG);
180$result = $db->query($sql);
187 $tablocaltax1 = array();
188 $tablocaltax2 = array();
189 $tabcompany = array();
192 $tabrclocaltax1 = array();
193 $tabrclocaltax2 = array();
194 $vatdata_cache = array();
196 $num = $db->num_rows($result);
201 $rcctva =
getDolGlobalString(
'ACCOUNTING_VAT_BUY_REVERSE_CHARGES_CREDIT',
'NotDefined');
202 $rcdtva =
getDolGlobalString(
'ACCOUNTING_VAT_BUY_REVERSE_CHARGES_DEBIT',
'NotDefined');
207 $obj = $db->fetch_object($result);
210 $compta_soc = ($obj->code_compta_fournisseur !=
"") ? $obj->code_compta_fournisseur : $cptfour;
212 $compta_prod = $obj->compte;
213 if (empty($compta_prod)) {
214 if ($obj->product_type == 0) {
221 $tax_id = $obj->tva_tx . ($obj->vat_src_code ?
' (' . $obj->vat_src_code .
')' :
'');
222 if (array_key_exists($tax_id, $vatdata_cache)) {
223 $vatdata = $vatdata_cache[$tax_id];
226 $vatdata_cache[$tax_id] = $vatdata;
228 $compta_tva = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $cpttva);
229 $compta_localtax1 = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $cpttva);
230 $compta_localtax2 = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $cpttva);
231 $compta_counterpart_tva_npr =
getDolGlobalString(
'ACCOUNTING_COUNTERPART_VAT_NPR',
'NotDefined');
234 if (
price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
235 $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.
')' :
''));
241 $tabfac[$obj->rowid][
"date"] = $db->jdate($obj->df);
242 $tabfac[$obj->rowid][
"datereg"] = $db->jdate($obj->dlr);
243 $tabfac[$obj->rowid][
"ref"] = $obj->ref_supplier.
' ('.$obj->ref.
')';
244 $tabfac[$obj->rowid][
"refsologest"] = $obj->ref;
245 $tabfac[$obj->rowid][
"refsuppliersologest"] = $obj->ref_supplier;
246 $tabfac[$obj->rowid][
"type"] = $obj->type;
247 $tabfac[$obj->rowid][
"description"] = $obj->description;
248 $tabfac[$obj->rowid][
"close_code"] = $obj->close_code;
252 if (!isset($tabttc[$obj->rowid][$compta_soc])) {
253 $tabttc[$obj->rowid][$compta_soc] = 0;
255 if (!isset($tabht[$obj->rowid][$compta_prod])) {
256 $tabht[$obj->rowid][$compta_prod] = 0;
258 if (!isset($tabtva[$obj->rowid][$compta_tva])) {
259 $tabtva[$obj->rowid][$compta_tva] = 0;
261 if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
262 $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
264 if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) {
265 $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
269 if (($mysoc->country_code ==
'FR' ||
getDolGlobalString(
'ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) && $obj->vat_reverse_charge == 1 && in_array($obj->country_code, $country_code_in_EEC)) {
270 $rcvatdata =
getTaxesFromId($obj->product_buy_vat . ($obj->product_buy_default_vat_code ?
' (' . $obj->product_buy_default_vat_code .
')' :
''), $mysoc, $mysoc, 0);
271 $rcc_compta_tva = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_credit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_credit'] : $rcctva);
272 $rcd_compta_tva = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_debit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_debit'] : $rcdtva);
273 $rcc_compta_localtax1 = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_credit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_credit'] : $rcctva);
274 $rcd_compta_localtax1 = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_debit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_debit'] : $rcdtva);
275 $rcc_compta_localtax2 = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_credit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_credit'] : $rcctva);
276 $rcd_compta_localtax2 = (!empty($vatdata[
'accountancy_code_vat_reverse_charge_debit']) ? $vatdata[
'accountancy_code_vat_reverse_charge_debit'] : $rcdtva);
277 if (
price2num($obj->product_buy_vat) || !empty($obj->product_buy_default_vat_code)) {
278 $vat_key =
vatrate($obj->product_buy_vat) . ($obj->product_buy_default_vat_code ?
' (' . $obj->product_buy_default_vat_code .
')' :
'');
279 $val_value = $vat_key;
280 $def_tva[$obj->rowid][$rcc_compta_tva][$vat_key] = $val_value;
281 $def_tva[$obj->rowid][$rcd_compta_tva][$vat_key] = $val_value;
284 if (!isset($tabrctva[$obj->rowid][$rcc_compta_tva])) {
285 $tabrctva[$obj->rowid][$rcc_compta_tva] = 0;
287 if (!isset($tabrctva[$obj->rowid][$rcd_compta_tva])) {
288 $tabrctva[$obj->rowid][$rcd_compta_tva] = 0;
290 if (!isset($tabrclocaltax1[$obj->rowid][$rcc_compta_localtax1])) {
291 $tabrclocaltax1[$obj->rowid][$rcc_compta_localtax1] = 0;
293 if (!isset($tabrclocaltax1[$obj->rowid][$rcd_compta_localtax1])) {
294 $tabrclocaltax1[$obj->rowid][$rcd_compta_localtax1] = 0;
296 if (!isset($tabrclocaltax2[$obj->rowid][$rcc_compta_localtax2])) {
297 $tabrclocaltax2[$obj->rowid][$rcc_compta_localtax2] = 0;
299 if (!isset($tabrclocaltax2[$obj->rowid][$rcd_compta_localtax2])) {
300 $tabrclocaltax2[$obj->rowid][$rcd_compta_localtax2] = 0;
303 $rcvat = (float)
price2num($obj->total_ttc * $obj->product_buy_vat / 100,
'MT');
304 $rclocalvat1 = (float)
price2num($obj->total_ttc * $obj->product_buy_localvat1 / 100,
'MT');
305 $rclocalvat2 = (float)
price2num($obj->total_ttc * $obj->product_buy_localvat2 / 100,
'MT');
307 $tabrctva[$obj->rowid][$rcd_compta_tva] += $rcvat;
308 $tabrctva[$obj->rowid][$rcc_compta_tva] -= $rcvat;
309 $tabrclocaltax1[$obj->rowid][$rcd_compta_localtax1] += $rclocalvat1;
310 $tabrclocaltax1[$obj->rowid][$rcc_compta_localtax1] -= $rclocalvat1;
311 $tabrclocaltax2[$obj->rowid][$rcd_compta_localtax2] += $rclocalvat2;
312 $tabrclocaltax2[$obj->rowid][$rcc_compta_localtax2] -= $rclocalvat2;
315 $tabttc[$obj->rowid][$compta_soc] += $obj->total_ttc;
316 $tabht[$obj->rowid][$compta_prod] += $obj->total_ht;
317 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
318 $tva_npr = ((($obj->info_bits & 1) == 1) ? 1 : 0);
320 $tabother[$obj->rowid][$compta_counterpart_tva_npr] += $obj->total_tva;
322 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
323 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
324 $tabcompany[$obj->rowid] = array(
326 'name' => $obj->name,
327 'code_fournisseur' => $obj->code_fournisseur,
328 'code_compta_fournisseur' => $compta_soc
334 if ($i >
getDolGlobalInt(
'ACCOUNTANCY_MAX_TOO_MANY_LINES_TO_PROCESS', 10000)) {
336 setEventMessages(
"ErrorTooManyLinesToProcessPleaseUseAMoreSelectiveFilter",
null,
'errors');
344$errorforinvoice = array();
369 COUNT(fd.rowid) as nb
371 " . MAIN_DB_PREFIX .
"facture_fourn_det as fd
374 AND fd.fk_code_ventilation <= 0
375 AND fd.total_ttc <> 0
376 AND fk_facture_fourn IN (".$db->sanitize(implode(
",", array_keys($tabfac))).
")
377GROUP BY fk_facture_fourn
379$resql = $db->query($sql);
381$num = $db->num_rows($resql);
384 $obj = $db->fetch_object($resql);
386 $errorforinvoice[$obj->fk_facture_fourn] =
'somelinesarenotbound';
395if ($action ==
'writebookkeeping' && !$error && $user->hasRight(
'accounting',
'bind',
'write')) {
399 $companystatic =
new Societe($db);
403 $accountingaccountsupplier->fetch(
null,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER'),
true);
405 foreach ($tabfac as $key => $val) {
413 $companystatic->id = $tabcompany[$key][
'id'];
414 $companystatic->name = $tabcompany[$key][
'name'];
415 $companystatic->code_compta_fournisseur = $tabcompany[$key][
'code_compta_fournisseur'];
416 $companystatic->code_fournisseur = $tabcompany[$key][
'code_fournisseur'];
417 $companystatic->fournisseur = 1;
419 $invoicestatic->id = $key;
420 $invoicestatic->ref = (string) $val[
"refsologest"];
421 $invoicestatic->ref_supplier = $val[
"refsuppliersologest"];
422 $invoicestatic->type = $val[
"type"];
423 $invoicestatic->description = html_entity_decode(
dol_trunc($val[
"description"], 32));
424 $invoicestatic->close_code = $val[
"close_code"];
429 $replacedinvoice = 0;
430 if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
431 $replacedinvoice = 1;
432 $alreadydispatched = $invoicestatic->getVentilExportCompta();
433 if ($alreadydispatched) {
434 $replacedinvoice = 2;
439 if ($replacedinvoice == 1) {
445 if (isset($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
448 setEventMessages($langs->trans(
'ErrorInvoiceContainsLinesNotYetBounded', $val[
'ref']),
null,
'errors');
452 if (!$errorforline) {
453 foreach ($tabttc[$key] as $k => $mt) {
455 $bookkeeping->doc_date = $val[
"date"];
456 $bookkeeping->date_lim_reglement = $val[
"datereg"];
457 $bookkeeping->doc_ref = $val[
"refsologest"];
458 $bookkeeping->date_creation = $now;
459 $bookkeeping->doc_type =
'supplier_invoice';
460 $bookkeeping->fk_doc = $key;
461 $bookkeeping->fk_docdet = 0;
462 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
464 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta_fournisseur'];
465 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
468 $bookkeeping->label_compte = $accountingaccountsupplier->label;
470 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"SubledgerAccount");
471 $bookkeeping->montant = $mt;
472 $bookkeeping->sens = ($mt >= 0) ?
'C' :
'D';
473 $bookkeeping->debit = ($mt <= 0) ? -$mt : 0;
474 $bookkeeping->credit = ($mt > 0) ? $mt : 0;
475 $bookkeeping->code_journal = $journal;
476 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
477 $bookkeeping->fk_user_author = $user->id;
478 $bookkeeping->entity = $conf->entity;
480 $totaldebit += $bookkeeping->debit;
481 $totalcredit += $bookkeeping->credit;
483 $result = $bookkeeping->create($user);
485 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
488 $errorforinvoice[$key] =
'alreadyjournalized';
493 $errorforinvoice[$key] =
'other';
498 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
501 $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id));
508 if (!$errorforline) {
509 foreach ($tabht[$key] as $k => $mt) {
510 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
512 $accountingaccount->fetch(0, $k,
true);
513 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
515 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
518 $label_account = $accountingaccount->label;
521 if ($accountingaccount->id > 0) {
523 $bookkeeping->doc_date = $val[
"date"];
524 $bookkeeping->date_lim_reglement = $val[
"datereg"];
525 $bookkeeping->doc_ref = $val[
"refsologest"];
526 $bookkeeping->date_creation = $now;
527 $bookkeeping->doc_type =
'supplier_invoice';
528 $bookkeeping->fk_doc = $key;
529 $bookkeeping->fk_docdet = 0;
530 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
534 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
535 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
537 $bookkeeping->subledger_account =
'';
538 $bookkeeping->subledger_label =
'';
541 $bookkeeping->subledger_account =
'';
542 $bookkeeping->subledger_label =
'';
545 $bookkeeping->numero_compte = $k;
546 $bookkeeping->label_compte = $label_account;
548 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref_supplier.
' - '.$label_account;
549 $bookkeeping->montant = $mt;
550 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
551 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
552 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
553 $bookkeeping->code_journal = $journal;
554 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
555 $bookkeeping->fk_user_author = $user->id;
556 $bookkeeping->entity = $conf->entity;
558 $totaldebit += $bookkeeping->debit;
559 $totalcredit += $bookkeeping->credit;
561 $result = $bookkeeping->create($user);
563 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
566 $errorforinvoice[$key] =
'alreadyjournalized';
571 $errorforinvoice[$key] =
'other';
581 if (!$errorforline) {
582 $listoftax = array(0, 1, 2);
583 foreach ($listoftax as $numtax) {
584 $arrayofvat = $tabtva;
586 $arrayofvat = $tablocaltax1;
589 $arrayofvat = $tablocaltax2;
593 if ($mysoc->country_code ==
'FR' ||
getDolGlobalString(
'ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
595 foreach ($arrayofvat[$key] as $k => $mt) {
602 $arrayofvat = $tabrctva;
604 $arrayofvat = $tabrclocaltax1;
607 $arrayofvat = $tabrclocaltax2;
609 if (!isset($arrayofvat[$key]) || !is_array($arrayofvat[$key])) {
610 $arrayofvat[$key] = array();
615 foreach ($arrayofvat[$key] as $k => $mt) {
617 $accountingaccount->fetch(
null, $k,
true);
618 $label_account = $accountingaccount->label;
621 $bookkeeping->doc_date = $val[
"date"];
622 $bookkeeping->date_lim_reglement = $val[
"datereg"];
623 $bookkeeping->doc_ref = $val[
"refsologest"];
624 $bookkeeping->date_creation = $now;
625 $bookkeeping->doc_type =
'supplier_invoice';
626 $bookkeeping->fk_doc = $key;
627 $bookkeeping->fk_docdet = 0;
628 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
630 $bookkeeping->subledger_account =
'';
631 $bookkeeping->subledger_label =
'';
633 $bookkeeping->numero_compte = $k;
634 $bookkeeping->label_compte = $label_account;
636 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"VAT").
' '.implode(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'');
637 $bookkeeping->montant = $mt;
638 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
639 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
640 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
641 $bookkeeping->code_journal = $journal;
642 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
643 $bookkeeping->fk_user_author = $user->id;
644 $bookkeeping->entity = $conf->entity;
646 $totaldebit += $bookkeeping->debit;
647 $totalcredit += $bookkeeping->credit;
649 $result = $bookkeeping->create($user);
651 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
654 $errorforinvoice[$key] =
'alreadyjournalized';
659 $errorforinvoice[$key] =
'other';
670 if (!$errorforline && isset($tabother[$key]) && is_array($tabother[$key])) {
671 foreach ($tabother[$key] as $k => $mt) {
674 $bookkeeping->doc_date = $val[
"date"];
675 $bookkeeping->date_lim_reglement = $val[
"datereg"];
676 $bookkeeping->doc_ref = $val[
"refsologest"];
677 $bookkeeping->date_creation = $now;
678 $bookkeeping->doc_type =
'supplier_invoice';
679 $bookkeeping->fk_doc = $key;
680 $bookkeeping->fk_docdet = 0;
681 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
683 $bookkeeping->subledger_account =
'';
684 $bookkeeping->subledger_label =
'';
686 $bookkeeping->numero_compte = $k;
688 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"VAT").
' NPR';
689 $bookkeeping->montant = $mt;
690 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
691 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
692 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
693 $bookkeeping->code_journal = $journal;
694 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
695 $bookkeeping->fk_user_author = $user->id;
696 $bookkeeping->entity = $conf->entity;
698 $totaldebit += $bookkeeping->debit;
699 $totalcredit += $bookkeeping->credit;
701 $result = $bookkeeping->create($user);
703 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
706 $errorforinvoice[$key] =
'alreadyjournalized';
711 $errorforinvoice[$key] =
'other';
720 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
723 $errorforinvoice[$key] =
'amountsnotbalanced';
724 setEventMessages(
'We tried to insert a non balanced transaction in book for '.$invoicestatic->ref.
'. Canceled. Surely a bug.',
null,
'errors');
727 if (!$errorforline) {
733 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
741 if (empty($error) && count($tabpay) > 0) {
743 } elseif (count($tabpay) == $error) {
746 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
752 if (count($tabpay) != $error) {
753 $param =
'id_journal='.$id_journal;
754 $param .=
'&date_startday='.$date_startday;
755 $param .=
'&date_startmonth='.$date_startmonth;
756 $param .=
'&date_startyear='.$date_startyear;
757 $param .=
'&date_endday='.$date_endday;
758 $param .=
'&date_endmonth='.$date_endmonth;
759 $param .=
'&date_endyear='.$date_endyear;
760 $param .=
'&in_bookkeeping='.$in_bookkeeping;
761 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
770$form =
new Form($db);
773if ($action ==
'exportcsv' && !$error) {
776 $filename =
'journal';
777 $type_export =
'journal';
778 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
783 foreach ($tabfac as $key => $val) {
784 $companystatic->id = $tabcompany[$key][
'id'];
785 $companystatic->name = $tabcompany[$key][
'name'];
786 $companystatic->code_compta_fournisseur = $tabcompany[$key][
'code_compta_fournisseur'];
787 $companystatic->code_fournisseur = $tabcompany[$key][
'code_fournisseur'];
788 $companystatic->fournisseur = 1;
790 $invoicestatic->id = $key;
791 $invoicestatic->ref = $val[
"refsologest"];
792 $invoicestatic->ref_supplier = $val[
"refsuppliersologest"];
793 $invoicestatic->type = $val[
"type"];
794 $invoicestatic->description =
dol_trunc(html_entity_decode($val[
"description"]), 32);
795 $invoicestatic->close_code = $val[
"close_code"];
800 $replacedinvoice = 0;
801 if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
802 $replacedinvoice = 1;
803 $alreadydispatched = $invoicestatic->getVentilExportCompta();
804 if ($alreadydispatched) {
805 $replacedinvoice = 2;
810 if ($replacedinvoice == 1) {
815 foreach ($tabttc[$key] as $k => $mt) {
817 print
'"'.$key.
'"'.$sep;
818 print
'"'.$date.
'"'.$sep;
819 print
'"'.$val[
"refsologest"].
'"'.$sep;
820 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
821 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
822 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER')).
'"'.$sep;
823 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
824 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
825 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$val[
"refsuppliersologest"].
' - '.$langs->trans(
"Thirdparty").
'"'.$sep;
826 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
827 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
828 print
'"'.$journal.
'"';
834 foreach ($tabht[$key] as $k => $mt) {
836 $accountingaccount->fetch(
null, $k,
true);
838 print
'"'.$key.
'"'.$sep;
839 print
'"'.$date.
'"'.$sep;
840 print
'"'.$val[
"refsologest"].
'"'.$sep;
841 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
842 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
843 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
845 print
'"'.mb_convert_encoding(
dol_trunc($accountingaccount->label, 32),
'ISO-8859-1').
'"'.$sep;
846 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$val[
"refsuppliersologest"].
' - '.
dol_trunc($accountingaccount->label, 32).
'"'.$sep;
847 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
848 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
849 print
'"'.$journal.
'"';
855 $listoftax = array(0, 1, 2);
856 foreach ($listoftax as $numtax) {
857 $arrayofvat = $tabtva;
859 $arrayofvat = $tablocaltax1;
862 $arrayofvat = $tablocaltax2;
866 if ($mysoc->country_code ==
'FR' ||
getDolGlobalString(
'ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
868 foreach ($arrayofvat[$key] as $k => $mt) {
875 $arrayofvat = $tabrctva;
877 $arrayofvat = $tabrclocaltax1;
880 $arrayofvat = $tabrclocaltax2;
882 if (!isset($arrayofvat[$key]) || !is_array($arrayofvat[$key])) {
883 $arrayofvat[$key] = array();
888 foreach ($arrayofvat[$key] as $k => $mt) {
890 print
'"'.$key.
'"'.$sep;
891 print
'"'.$date.
'"'.$sep;
892 print
'"'.$val[
"refsologest"].
'"'.$sep;
893 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
894 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
895 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
897 print
'"'.$langs->trans(
"VAT").
' - '.implode(
', ', $def_tva[$key][$k]).
' %"'.$sep;
898 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$val[
"refsuppliersologest"].
' - '.$langs->trans(
"VAT").implode(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'').
'"'.$sep;
899 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
900 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
901 print
'"'.$journal.
'"';
907 if (isset($tabother[$key]) && is_array($tabother[$key])) {
908 foreach ($tabother[$key] as $k => $mt) {
910 print
'"'.$key.
'"'.$sep;
911 print
'"'.$date.
'"'.$sep;
912 print
'"'.$val[
"refsologest"].
'"'.$sep;
913 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
914 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
915 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
916 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
917 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
918 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$val[
"refsuppliersologest"].
' - '.$langs->trans(
"VAT").
' NPR"'.$sep;
919 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
920 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
921 print
'"'.$journal.
'"';
930if (empty($action) || $action ==
'view') {
931 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
932 $help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité';
933 llxHeader(
'',
dol_string_nohtmltag($title), $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy accountancy-generation page-purchasesjournal');
940 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
942 $description .= $langs->trans(
"DepositsAreNotIncluded");
944 $description .= $langs->trans(
"DepositsAreIncluded");
947 $listofchoices = array(
'notyet' => $langs->trans(
"NotYetInGeneralLedger"),
'already' => $langs->trans(
"AlreadyInGeneralLedger"));
948 $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);
949 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
951 $varlink =
'id_journal='.$id_journal;
953 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
958 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int) $conf->entity);
959 $resql = $db->query($sql);
961 $obj = $db->fetch_object($resql);
963 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
964 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
965 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
975 $acctSupplierNotConfigured = in_array(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER'), [
'',
'-1']);
976 if ($acctSupplierNotConfigured) {
977 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
978 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
979 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
983 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
984 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
985 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
987 if ($acctSupplierNotConfigured) {
988 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
990 if ($in_bookkeeping ==
'notyet') {
991 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
993 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
1000 <script type="text/javascript">
1001 function launch_export() {
1002 $("div.fiche form input[name=\"action\"]").val("exportcsv");
1003 $("div.fiche form input[type=\"submit\"]").click();
1004 $("div.fiche form input[name=\"action\"]").val("");
1006 function writebookkeeping() {
1007 console.log("click on writebookkeeping");
1008 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
1009 $("div.fiche form input[type=\"submit\"]").click();
1010 $("div.fiche form input[name=\"action\"]").val("");
1019 print
'<div class="div-table-responsive">';
1020 print
"<table class=\"noborder\" width=\"100%\">";
1021 print
"<tr class=\"liste_titre\">";
1022 print
"<td>".$langs->trans(
"Date").
"</td>";
1023 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"InvoiceRef").
")</td>";
1024 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
1025 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
1026 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
1027 print
'<td class="center">'.$langs->trans(
"AccountingDebit").
"</td>";
1028 print
'<td class="center">'.$langs->trans(
"AccountingCredit").
"</td>";
1036 foreach ($tabfac as $key => $val) {
1037 $companystatic->id = $tabcompany[$key][
'id'];
1038 $companystatic->name = $tabcompany[$key][
'name'];
1039 $companystatic->code_compta_fournisseur = $tabcompany[$key][
'code_compta_fournisseur'];
1040 $companystatic->code_fournisseur = $tabcompany[$key][
'code_fournisseur'];
1041 $companystatic->fournisseur = 1;
1043 $invoicestatic->id = $key;
1044 $invoicestatic->ref = $val[
"refsologest"];
1045 $invoicestatic->ref_supplier = $val[
"refsuppliersologest"];
1046 $invoicestatic->type = $val[
"type"];
1047 $invoicestatic->description =
dol_trunc(html_entity_decode($val[
"description"]), 32);
1048 $invoicestatic->close_code = $val[
"close_code"];
1053 $replacedinvoice = 0;
1054 if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
1055 $replacedinvoice = 1;
1056 $alreadydispatched = $invoicestatic->getVentilExportCompta();
1057 if ($alreadydispatched) {
1058 $replacedinvoice = 2;
1063 if ($replacedinvoice == 1) {
1064 print
'<tr class="oddeven">';
1065 print
"<!-- Replaced invoice -->";
1066 print
"<td>".$date.
"</td>";
1067 print
"<td><strike>".$invoicestatic->getNomUrl(1).
"</strike></td>";
1070 print $langs->trans(
"Replaced");
1077 print
'<td class="right"></td>';
1078 print
'<td class="right"></td>';
1084 if (isset($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
1085 print
'<tr class="oddeven">';
1086 print
"<!-- Some lines are not bound -->";
1087 print
"<td>".$date.
"</td>";
1088 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1091 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $val[
'ref']).
'</span>';
1098 print
'<td class="right"></td>';
1099 print
'<td class="right"></td>';
1106 foreach ($tabttc[$key] as $k => $mt) {
1107 print
'<tr class="oddeven">';
1108 print
"<!-- Thirdparty -->";
1109 print
"<td>".$date.
"</td>";
1110 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1114 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1115 print
'<span class="error">'.$langs->trans(
"MainAccountForSuppliersNotDefined").
'</span>';
1117 print $accountoshow;
1123 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1124 print
'<span class="error">'.$langs->trans(
"ThirdpartyAccountNotDefined").
'</span>';
1126 print $accountoshow;
1129 print
"<td>".$companystatic->getNomUrl(0,
'supplier', 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"SubledgerAccount").
"</td>";
1130 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1131 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1138 foreach ($tabht[$key] as $k => $mt) {
1139 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
1141 $accountingaccount->fetch(0, $k,
true);
1142 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
1144 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
1147 print
'<tr class="oddeven">';
1148 print
"<!-- Product -->";
1149 print
"<td>".$date.
"</td>";
1150 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1154 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1155 print
'<span class="error">'.$langs->trans(
"ProductAccountNotDefined").
'</span>';
1157 print $accountoshow;
1166 } elseif (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1167 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1170 $companystatic->id = $tabcompany[$key][
'id'];
1171 $companystatic->name = $tabcompany[$key][
'name'];
1172 print
"<td>".$companystatic->getNomUrl(0,
'supplier', 16).
' - '.$invoicestatic->ref_supplier.
' - '.$accountingaccount->label.
"</td>";
1173 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1174 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1181 $listoftax = array(0, 1, 2);
1182 foreach ($listoftax as $numtax) {
1183 $arrayofvat = $tabtva;
1185 $arrayofvat = $tablocaltax1;
1188 $arrayofvat = $tablocaltax2;
1192 if ($mysoc->country_code ==
'FR' ||
getDolGlobalString(
'ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
1194 foreach ($arrayofvat[$key] as $k => $mt) {
1201 $arrayofvat = $tabrctva;
1203 $arrayofvat = $tabrclocaltax1;
1206 $arrayofvat = $tabrclocaltax2;
1208 if (!isset($arrayofvat[$key]) || !is_array($arrayofvat[$key])) {
1209 $arrayofvat[$key] = array();
1214 foreach ($arrayofvat[$key] as $k => $mt) {
1216 print
'<tr class="oddeven">';
1217 print
"<!-- VAT -->";
1218 print
"<td>".$date.
"</td>";
1219 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1223 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1224 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"AccountingJournalType3").
')</span>';
1226 print $accountoshow;
1233 print $companystatic->getNomUrl(0,
'supplier', 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"VAT").
' '.implode(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'');
1235 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1236 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1245 if (isset($tabother[$key]) && is_array($tabother[$key])) {
1246 foreach ($tabother[$key] as $k => $mt) {
1248 print
'<tr class="oddeven">';
1249 print
'<!-- VAT counterpart NPR -->';
1250 print
"<td>".$date.
"</td>";
1251 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1255 if ($accountoshow ==
'' || $accountoshow ==
'NotDefined') {
1256 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"NPR counterpart").
'). Set ACCOUNTING_COUNTERPART_VAT_NPR to the subvention account</span>';
1258 print $accountoshow;
1264 print
"<td>".$companystatic->getNomUrl(0,
'supplier', 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"VAT").
" NPR (counterpart)</td>";
1265 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1266 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1276 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.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage accounting accounts.
Class to manage accounting journals.
Class to manage Ledger (General Ledger and Subledger)
const TYPE_SITUATION
Situation invoice.
Class to manage suppliers invoices.
const TYPE_DEPOSIT
Deposit invoice.
const TYPE_CREDIT_NOTE
Credit note invoice.
const TYPE_REPLACEMENT
Replacement invoice.
Class to manage suppliers.
Class to manage third parties objects (customers, suppliers, prospects...)
getCountriesInEEC()
Return list of countries that are inside the EEC (European Economic Community) Note: Try to keep this...
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
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.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
dol_now($mode='auto')
Return date for now.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_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.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.