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();
366if (!empty($tabfac)) {
370 COUNT(fd.rowid) as nb
372 " . MAIN_DB_PREFIX .
"facture_fourn_det as fd
375 AND fd.fk_code_ventilation <= 0
376 AND fd.total_ttc <> 0
377 AND fk_facture_fourn IN (".$db->sanitize(implode(
",", array_keys($tabfac))).
")
378 GROUP BY fk_facture_fourn
380 $resql = $db->query($sql);
382 $num = $db->num_rows($resql);
385 $obj = $db->fetch_object($resql);
387 $errorforinvoice[$obj->fk_facture_fourn] =
'somelinesarenotbound';
397if ($action ==
'writebookkeeping' && !$error && $user->hasRight(
'accounting',
'bind',
'write')) {
401 $companystatic =
new Societe($db);
405 $accountingaccountsupplier->fetch(
null,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER'),
true);
407 foreach ($tabfac as $key => $val) {
415 $companystatic->id = $tabcompany[$key][
'id'];
416 $companystatic->name = $tabcompany[$key][
'name'];
417 $companystatic->code_compta_fournisseur = $tabcompany[$key][
'code_compta_fournisseur'];
418 $companystatic->code_fournisseur = $tabcompany[$key][
'code_fournisseur'];
419 $companystatic->fournisseur = 1;
421 $invoicestatic->id = $key;
422 $invoicestatic->ref = (string) $val[
"refsologest"];
423 $invoicestatic->ref_supplier = $val[
"refsuppliersologest"];
424 $invoicestatic->type = $val[
"type"];
425 $invoicestatic->description = html_entity_decode(
dol_trunc($val[
"description"], 32));
426 $invoicestatic->close_code = $val[
"close_code"];
431 $replacedinvoice = 0;
432 if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
433 $replacedinvoice = 1;
434 $alreadydispatched = $invoicestatic->getVentilExportCompta();
435 if ($alreadydispatched) {
436 $replacedinvoice = 2;
441 if ($replacedinvoice == 1) {
447 if (isset($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
450 setEventMessages($langs->trans(
'ErrorInvoiceContainsLinesNotYetBounded', $val[
'ref']),
null,
'errors');
454 if (!$errorforline) {
455 foreach ($tabttc[$key] as $k => $mt) {
457 $bookkeeping->doc_date = $val[
"date"];
458 $bookkeeping->date_lim_reglement = $val[
"datereg"];
459 $bookkeeping->doc_ref = $val[
"refsologest"];
460 $bookkeeping->date_creation = $now;
461 $bookkeeping->doc_type =
'supplier_invoice';
462 $bookkeeping->fk_doc = $key;
463 $bookkeeping->fk_docdet = 0;
464 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
466 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta_fournisseur'];
467 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
470 $bookkeeping->label_compte = $accountingaccountsupplier->label;
472 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"SubledgerAccount");
473 $bookkeeping->montant = $mt;
474 $bookkeeping->sens = ($mt >= 0) ?
'C' :
'D';
475 $bookkeeping->debit = ($mt <= 0) ? -$mt : 0;
476 $bookkeeping->credit = ($mt > 0) ? $mt : 0;
477 $bookkeeping->code_journal = $journal;
478 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
479 $bookkeeping->fk_user_author = $user->id;
480 $bookkeeping->entity = $conf->entity;
482 $totaldebit += $bookkeeping->debit;
483 $totalcredit += $bookkeeping->credit;
485 $result = $bookkeeping->create($user);
487 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
490 $errorforinvoice[$key] =
'alreadyjournalized';
495 $errorforinvoice[$key] =
'other';
500 require_once DOL_DOCUMENT_ROOT .
'/accountancy/class/lettering.class.php';
503 $nb_lettering = $lettering_static->bookkeepingLettering(array($bookkeeping->id));
510 if (!$errorforline) {
511 foreach ($tabht[$key] as $k => $mt) {
512 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
514 $accountingaccount->fetch(0, $k,
true);
515 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
517 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
520 $label_account = $accountingaccount->label;
523 if ($accountingaccount->id > 0) {
525 $bookkeeping->doc_date = $val[
"date"];
526 $bookkeeping->date_lim_reglement = $val[
"datereg"];
527 $bookkeeping->doc_ref = $val[
"refsologest"];
528 $bookkeeping->date_creation = $now;
529 $bookkeeping->doc_type =
'supplier_invoice';
530 $bookkeeping->fk_doc = $key;
531 $bookkeeping->fk_docdet = 0;
532 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
536 $bookkeeping->subledger_account = $tabcompany[$key][
'code_compta'];
537 $bookkeeping->subledger_label = $tabcompany[$key][
'name'];
539 $bookkeeping->subledger_account =
'';
540 $bookkeeping->subledger_label =
'';
543 $bookkeeping->subledger_account =
'';
544 $bookkeeping->subledger_label =
'';
547 $bookkeeping->numero_compte = $k;
548 $bookkeeping->label_compte = $label_account;
550 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref_supplier.
' - '.$label_account;
551 $bookkeeping->montant = $mt;
552 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
553 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
554 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
555 $bookkeeping->code_journal = $journal;
556 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
557 $bookkeeping->fk_user_author = $user->id;
558 $bookkeeping->entity = $conf->entity;
560 $totaldebit += $bookkeeping->debit;
561 $totalcredit += $bookkeeping->credit;
563 $result = $bookkeeping->create($user);
565 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
568 $errorforinvoice[$key] =
'alreadyjournalized';
573 $errorforinvoice[$key] =
'other';
583 if (!$errorforline) {
584 $listoftax = array(0, 1, 2);
585 foreach ($listoftax as $numtax) {
586 $arrayofvat = $tabtva;
588 $arrayofvat = $tablocaltax1;
591 $arrayofvat = $tablocaltax2;
595 if ($mysoc->country_code ==
'FR' ||
getDolGlobalString(
'ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
597 foreach ($arrayofvat[$key] as $k => $mt) {
604 $arrayofvat = $tabrctva;
606 $arrayofvat = $tabrclocaltax1;
609 $arrayofvat = $tabrclocaltax2;
611 if (!isset($arrayofvat[$key]) || !is_array($arrayofvat[$key])) {
612 $arrayofvat[$key] = array();
617 foreach ($arrayofvat[$key] as $k => $mt) {
619 $accountingaccount->fetch(
null, $k,
true);
620 $label_account = $accountingaccount->label;
623 $bookkeeping->doc_date = $val[
"date"];
624 $bookkeeping->date_lim_reglement = $val[
"datereg"];
625 $bookkeeping->doc_ref = $val[
"refsologest"];
626 $bookkeeping->date_creation = $now;
627 $bookkeeping->doc_type =
'supplier_invoice';
628 $bookkeeping->fk_doc = $key;
629 $bookkeeping->fk_docdet = 0;
630 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
632 $bookkeeping->subledger_account =
'';
633 $bookkeeping->subledger_label =
'';
635 $bookkeeping->numero_compte = $k;
636 $bookkeeping->label_compte = $label_account;
638 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"VAT").
' '.implode(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'');
639 $bookkeeping->montant = $mt;
640 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
641 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
642 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
643 $bookkeeping->code_journal = $journal;
644 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
645 $bookkeeping->fk_user_author = $user->id;
646 $bookkeeping->entity = $conf->entity;
648 $totaldebit += $bookkeeping->debit;
649 $totalcredit += $bookkeeping->credit;
651 $result = $bookkeeping->create($user);
653 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
656 $errorforinvoice[$key] =
'alreadyjournalized';
661 $errorforinvoice[$key] =
'other';
672 if (!$errorforline && isset($tabother[$key]) && is_array($tabother[$key])) {
673 foreach ($tabother[$key] as $k => $mt) {
676 $bookkeeping->doc_date = $val[
"date"];
677 $bookkeeping->date_lim_reglement = $val[
"datereg"];
678 $bookkeeping->doc_ref = $val[
"refsologest"];
679 $bookkeeping->date_creation = $now;
680 $bookkeeping->doc_type =
'supplier_invoice';
681 $bookkeeping->fk_doc = $key;
682 $bookkeeping->fk_docdet = 0;
683 $bookkeeping->thirdparty_code = $companystatic->code_fournisseur;
685 $bookkeeping->subledger_account =
'';
686 $bookkeeping->subledger_label =
'';
688 $bookkeeping->numero_compte = $k;
690 $bookkeeping->label_operation =
dol_trunc($companystatic->name, 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"VAT").
' NPR';
691 $bookkeeping->montant = $mt;
692 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
693 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
694 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
695 $bookkeeping->code_journal = $journal;
696 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
697 $bookkeeping->fk_user_author = $user->id;
698 $bookkeeping->entity = $conf->entity;
700 $totaldebit += $bookkeeping->debit;
701 $totalcredit += $bookkeeping->credit;
703 $result = $bookkeeping->create($user);
705 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
708 $errorforinvoice[$key] =
'alreadyjournalized';
713 $errorforinvoice[$key] =
'other';
722 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
725 $errorforinvoice[$key] =
'amountsnotbalanced';
726 setEventMessages(
'We tried to insert a non balanced transaction in book for '.$invoicestatic->ref.
'. Canceled. Surely a bug.',
null,
'errors');
729 if (!$errorforline) {
735 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
743 if (empty($error) && count($tabpay) > 0) {
745 } elseif (count($tabpay) == $error) {
748 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
754 if (count($tabpay) != $error) {
755 $param =
'id_journal='.$id_journal;
756 $param .=
'&date_startday='.$date_startday;
757 $param .=
'&date_startmonth='.$date_startmonth;
758 $param .=
'&date_startyear='.$date_startyear;
759 $param .=
'&date_endday='.$date_endday;
760 $param .=
'&date_endmonth='.$date_endmonth;
761 $param .=
'&date_endyear='.$date_endyear;
762 $param .=
'&in_bookkeeping='.$in_bookkeeping;
763 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
772$form =
new Form($db);
775if ($action ==
'exportcsv' && !$error) {
778 $filename =
'journal';
779 $type_export =
'journal';
780 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
785 foreach ($tabfac as $key => $val) {
786 $companystatic->id = $tabcompany[$key][
'id'];
787 $companystatic->name = $tabcompany[$key][
'name'];
788 $companystatic->code_compta_fournisseur = $tabcompany[$key][
'code_compta_fournisseur'];
789 $companystatic->code_fournisseur = $tabcompany[$key][
'code_fournisseur'];
790 $companystatic->fournisseur = 1;
792 $invoicestatic->id = $key;
793 $invoicestatic->ref = $val[
"refsologest"];
794 $invoicestatic->ref_supplier = $val[
"refsuppliersologest"];
795 $invoicestatic->type = $val[
"type"];
796 $invoicestatic->description =
dol_trunc(html_entity_decode($val[
"description"]), 32);
797 $invoicestatic->close_code = $val[
"close_code"];
802 $replacedinvoice = 0;
803 if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
804 $replacedinvoice = 1;
805 $alreadydispatched = $invoicestatic->getVentilExportCompta();
806 if ($alreadydispatched) {
807 $replacedinvoice = 2;
812 if ($replacedinvoice == 1) {
817 foreach ($tabttc[$key] as $k => $mt) {
819 print
'"'.$key.
'"'.$sep;
820 print
'"'.$date.
'"'.$sep;
821 print
'"'.$val[
"refsologest"].
'"'.$sep;
822 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
823 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
824 print
'"'.length_accountg(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER')).
'"'.$sep;
825 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
826 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
827 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$val[
"refsuppliersologest"].
' - '.$langs->trans(
"Thirdparty").
'"'.$sep;
828 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
829 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
830 print
'"'.$journal.
'"';
836 foreach ($tabht[$key] as $k => $mt) {
838 $accountingaccount->fetch(
null, $k,
true);
840 print
'"'.$key.
'"'.$sep;
841 print
'"'.$date.
'"'.$sep;
842 print
'"'.$val[
"refsologest"].
'"'.$sep;
843 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
844 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
845 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
847 print
'"'.mb_convert_encoding(
dol_trunc($accountingaccount->label, 32),
'ISO-8859-1').
'"'.$sep;
848 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$val[
"refsuppliersologest"].
' - '.
dol_trunc($accountingaccount->label, 32).
'"'.$sep;
849 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
850 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
851 print
'"'.$journal.
'"';
857 $listoftax = array(0, 1, 2);
858 foreach ($listoftax as $numtax) {
859 $arrayofvat = $tabtva;
861 $arrayofvat = $tablocaltax1;
864 $arrayofvat = $tablocaltax2;
868 if ($mysoc->country_code ==
'FR' ||
getDolGlobalString(
'ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
870 foreach ($arrayofvat[$key] as $k => $mt) {
877 $arrayofvat = $tabrctva;
879 $arrayofvat = $tabrclocaltax1;
882 $arrayofvat = $tabrclocaltax2;
884 if (!isset($arrayofvat[$key]) || !is_array($arrayofvat[$key])) {
885 $arrayofvat[$key] = array();
890 foreach ($arrayofvat[$key] as $k => $mt) {
892 print
'"'.$key.
'"'.$sep;
893 print
'"'.$date.
'"'.$sep;
894 print
'"'.$val[
"refsologest"].
'"'.$sep;
895 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
896 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
897 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
899 print
'"'.$langs->trans(
"VAT").
' - '.implode(
', ', $def_tva[$key][$k]).
' %"'.$sep;
900 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;
901 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
902 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
903 print
'"'.$journal.
'"';
909 if (isset($tabother[$key]) && is_array($tabother[$key])) {
910 foreach ($tabother[$key] as $k => $mt) {
912 print
'"'.$key.
'"'.$sep;
913 print
'"'.$date.
'"'.$sep;
914 print
'"'.$val[
"refsologest"].
'"'.$sep;
915 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 32),
'ISO-8859-1').
'"'.$sep;
916 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
917 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
918 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
919 print
'"'.$langs->trans(
"Thirdparty").
'"'.$sep;
920 print
'"'.mb_convert_encoding(
dol_trunc($companystatic->name, 16),
'ISO-8859-1').
' - '.$val[
"refsuppliersologest"].
' - '.$langs->trans(
"VAT").
' NPR"'.$sep;
921 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
922 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
923 print
'"'.$journal.
'"';
932if (empty($action) || $action ==
'view') {
933 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
934 $help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité';
935 llxHeader(
'',
dol_string_nohtmltag($title), $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy accountancy-generation page-purchasesjournal');
942 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
944 $description .= $langs->trans(
"DepositsAreNotIncluded");
946 $description .= $langs->trans(
"DepositsAreIncluded");
949 $listofchoices = array(
'notyet' => $langs->trans(
"NotYetInGeneralLedger"),
'already' => $langs->trans(
"AlreadyInGeneralLedger"));
950 $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);
951 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
953 $varlink =
'id_journal='.$id_journal;
955 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
960 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int) $conf->entity);
961 $resql = $db->query($sql);
963 $obj = $db->fetch_object($resql);
965 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
966 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
967 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
977 $acctSupplierNotConfigured = in_array(
getDolGlobalString(
'ACCOUNTING_ACCOUNT_SUPPLIER'), [
'',
'-1']);
978 if ($acctSupplierNotConfigured) {
979 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
980 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
981 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
985 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
986 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
987 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
989 if ($acctSupplierNotConfigured) {
990 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
992 if ($in_bookkeeping ==
'notyet') {
993 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
995 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
1002 <script type="text/javascript">
1003 function launch_export() {
1004 $("div.fiche form input[name=\"action\"]").val("exportcsv");
1005 $("div.fiche form input[type=\"submit\"]").click();
1006 $("div.fiche form input[name=\"action\"]").val("");
1008 function writebookkeeping() {
1009 console.log("click on writebookkeeping");
1010 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
1011 $("div.fiche form input[type=\"submit\"]").click();
1012 $("div.fiche form input[name=\"action\"]").val("");
1021 print
'<div class="div-table-responsive">';
1022 print
"<table class=\"noborder\" width=\"100%\">";
1023 print
"<tr class=\"liste_titre\">";
1024 print
"<td>".$langs->trans(
"Date").
"</td>";
1025 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"InvoiceRef").
")</td>";
1026 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
1027 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
1028 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
1029 print
'<td class="center">'.$langs->trans(
"AccountingDebit").
"</td>";
1030 print
'<td class="center">'.$langs->trans(
"AccountingCredit").
"</td>";
1038 foreach ($tabfac as $key => $val) {
1039 $companystatic->id = $tabcompany[$key][
'id'];
1040 $companystatic->name = $tabcompany[$key][
'name'];
1041 $companystatic->code_compta_fournisseur = $tabcompany[$key][
'code_compta_fournisseur'];
1042 $companystatic->code_fournisseur = $tabcompany[$key][
'code_fournisseur'];
1043 $companystatic->fournisseur = 1;
1045 $invoicestatic->id = $key;
1046 $invoicestatic->ref = $val[
"refsologest"];
1047 $invoicestatic->ref_supplier = $val[
"refsuppliersologest"];
1048 $invoicestatic->type = $val[
"type"];
1049 $invoicestatic->description =
dol_trunc(html_entity_decode($val[
"description"]), 32);
1050 $invoicestatic->close_code = $val[
"close_code"];
1055 $replacedinvoice = 0;
1056 if ($invoicestatic->close_code == FactureFournisseur::CLOSECODE_REPLACED) {
1057 $replacedinvoice = 1;
1058 $alreadydispatched = $invoicestatic->getVentilExportCompta();
1059 if ($alreadydispatched) {
1060 $replacedinvoice = 2;
1065 if ($replacedinvoice == 1) {
1066 print
'<tr class="oddeven">';
1067 print
"<!-- Replaced invoice -->";
1068 print
"<td>".$date.
"</td>";
1069 print
"<td><strike>".$invoicestatic->getNomUrl(1).
"</strike></td>";
1072 print $langs->trans(
"Replaced");
1079 print
'<td class="right"></td>';
1080 print
'<td class="right"></td>';
1086 if (isset($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
1087 print
'<tr class="oddeven">';
1088 print
"<!-- Some lines are not bound -->";
1089 print
"<td>".$date.
"</td>";
1090 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1093 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $val[
'ref']).
'</span>';
1100 print
'<td class="right"></td>';
1101 print
'<td class="right"></td>';
1108 foreach ($tabttc[$key] as $k => $mt) {
1109 print
'<tr class="oddeven">';
1110 print
"<!-- Thirdparty -->";
1111 print
"<td>".$date.
"</td>";
1112 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1116 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1117 print
'<span class="error">'.$langs->trans(
"MainAccountForSuppliersNotDefined").
'</span>';
1119 print $accountoshow;
1125 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1126 print
'<span class="error">'.$langs->trans(
"ThirdpartyAccountNotDefined").
'</span>';
1128 print $accountoshow;
1131 print
"<td>".$companystatic->getNomUrl(0,
'supplier', 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"SubledgerAccount").
"</td>";
1132 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1133 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1140 foreach ($tabht[$key] as $k => $mt) {
1141 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
1143 $accountingaccount->fetch(0, $k,
true);
1144 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
1146 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
1149 print
'<tr class="oddeven">';
1150 print
"<!-- Product -->";
1151 print
"<td>".$date.
"</td>";
1152 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1156 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1157 print
'<span class="error">'.$langs->trans(
"ProductAccountNotDefined").
'</span>';
1159 print $accountoshow;
1168 } elseif (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1169 print
'<span class="error">' . $langs->trans(
"ThirdpartyAccountNotDefined") .
'</span>';
1172 $companystatic->id = $tabcompany[$key][
'id'];
1173 $companystatic->name = $tabcompany[$key][
'name'];
1174 print
"<td>".$companystatic->getNomUrl(0,
'supplier', 16).
' - '.$invoicestatic->ref_supplier.
' - '.$accountingaccount->label.
"</td>";
1175 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1176 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1183 $listoftax = array(0, 1, 2);
1184 foreach ($listoftax as $numtax) {
1185 $arrayofvat = $tabtva;
1187 $arrayofvat = $tablocaltax1;
1190 $arrayofvat = $tablocaltax2;
1194 if ($mysoc->country_code ==
'FR' ||
getDolGlobalString(
'ACCOUNTING_FORCE_ENABLE_VAT_REVERSE_CHARGE')) {
1196 foreach ($arrayofvat[$key] as $k => $mt) {
1203 $arrayofvat = $tabrctva;
1205 $arrayofvat = $tabrclocaltax1;
1208 $arrayofvat = $tabrclocaltax2;
1210 if (!isset($arrayofvat[$key]) || !is_array($arrayofvat[$key])) {
1211 $arrayofvat[$key] = array();
1216 foreach ($arrayofvat[$key] as $k => $mt) {
1218 print
'<tr class="oddeven">';
1219 print
"<!-- VAT -->";
1220 print
"<td>".$date.
"</td>";
1221 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1225 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
1226 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"AccountingJournalType3").
')</span>';
1228 print $accountoshow;
1235 print $companystatic->getNomUrl(0,
'supplier', 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"VAT").
' '.implode(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'');
1237 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1238 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1247 if (isset($tabother[$key]) && is_array($tabother[$key])) {
1248 foreach ($tabother[$key] as $k => $mt) {
1250 print
'<tr class="oddeven">';
1251 print
'<!-- VAT counterpart NPR -->';
1252 print
"<td>".$date.
"</td>";
1253 print
"<td>".$invoicestatic->getNomUrl(1).
"</td>";
1257 if ($accountoshow ==
'' || $accountoshow ==
'NotDefined') {
1258 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
' ('.$langs->trans(
"NPR counterpart").
'). Set ACCOUNTING_COUNTERPART_VAT_NPR to the subvention account</span>';
1260 print $accountoshow;
1266 print
"<td>".$companystatic->getNomUrl(0,
'supplier', 16).
' - '.$invoicestatic->ref_supplier.
' - '.$langs->trans(
"VAT").
" NPR (counterpart)</td>";
1267 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
1268 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
1278 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.