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.
'/accountancy/class/accountingjournal.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
40require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeeping.class.php';
43$langs->loadLangs(array(
"commercial",
"compta",
"bills",
"other",
"accountancy",
"trips",
"errors"));
46$action =
GETPOST(
'action',
'aZ09');
48$date_startmonth =
GETPOST(
'date_startmonth');
49$date_startday =
GETPOST(
'date_startday');
50$date_startyear =
GETPOST(
'date_startyear');
51$date_endmonth =
GETPOST(
'date_endmonth');
52$date_endday =
GETPOST(
'date_endday');
53$date_endyear =
GETPOST(
'date_endyear');
54$in_bookkeeping =
GETPOST(
'in_bookkeeping');
55if ($in_bookkeeping ==
'') {
56 $in_bookkeeping =
'notyet';
61$hookmanager->initHooks(array(
'expensereportsjournal'));
68$tablocaltax1 = array();
69$tablocaltax2 = array();
72if (!isModEnabled(
'accounting')) {
75if ($user->socid > 0) {
78if (!$user->hasRight(
'accounting',
'bind',
'write')) {
83$errorforinvoice = array();
94$accountingjournalstatic->fetch($id_journal);
95$journal = $accountingjournalstatic->code;
96$journal_label = $accountingjournalstatic->label;
98$date_start =
dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
99$date_end =
dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
102$pastmonthyear =
null;
104if (empty($date_startmonth)) {
107 $date_start = $dates[
'date_start'];
108 $pastmonthyear = $dates[
'pastmonthyear'];
109 $pastmonth = $dates[
'pastmonth'];
111if (empty($date_endmonth)) {
114 $date_end = $dates[
'date_end'];
115 $pastmonthyear = $dates[
'pastmonthyear'];
116 $pastmonth = $dates[
'pastmonth'];
119if (!GETPOSTISSET(
'date_startmonth') && (empty($date_start) || empty($date_end))) {
124$sql =
"SELECT er.rowid, er.ref, er.date_debut as de, er.date_fin as df,";
125$sql .=
" erd.rowid as erdid, erd.comments, erd.total_ht, erd.total_tva, erd.total_localtax1, erd.total_localtax2, erd.tva_tx, erd.total_ttc, erd.fk_code_ventilation, erd.vat_src_code, ";
126$sql .=
" u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,";
127$sql .=
" f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
128$parameters = array();
129$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
130$sql .= $hookmanager->resPrint;
131$sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport_det as erd";
132$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_type_fees as f ON f.id = erd.fk_c_type_fees";
133$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
134$sql .=
" JOIN ".MAIN_DB_PREFIX.
"expensereport as er ON er.rowid = erd.fk_expensereport";
135$sql .=
" JOIN ".MAIN_DB_PREFIX.
"user as u ON u.rowid = er.fk_user_author";
136$parameters = array();
137$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters);
138$sql .= $hookmanager->resPrint;
139$sql .=
" WHERE er.fk_statut > 0";
140$sql .=
" AND erd.fk_code_ventilation > 0";
141$sql .=
" AND er.entity IN (".getEntity(
'expensereport', 0).
")";
142if ($date_start && $date_end) {
143 $sql .=
" AND er.date_debut >= '".$db->idate($date_start).
"' AND er.date_debut <= '".$db->idate($date_end).
"'";
147 $sql .=
" AND er.date_debut >= '".$db->idate(
getDolGlobalString(
'ACCOUNTING_DATE_START_BINDING')).
"'";
150if ($in_bookkeeping ==
'already') {
151 $sql .=
" AND er.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
153if ($in_bookkeeping ==
'notyet') {
154 $sql .=
" AND er.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
156$parameters = array();
157$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
158$sql .= $hookmanager->resPrint;
159$sql .=
" ORDER BY er.date_debut";
161dol_syslog(
'accountancy/journal/expensereportsjournal.php', LOG_DEBUG);
162$result = $db->query($sql);
169 $tablocaltax1 = array();
170 $tablocaltax2 = array();
173 $num = $db->num_rows($result);
176 $account_salary =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_EXPENSEREPORT',
'NotDefined');
181 $obj = $db->fetch_object($result);
184 $compta_user = (!empty($obj->user_accountancy_account)) ? $obj->user_accountancy_account : $account_salary;
185 $compta_fees = $obj->compte;
187 $vatdata =
getTaxesFromId($obj->tva_tx.($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''), $mysoc, $mysoc, 0);
188 $compta_tva = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $account_vat);
189 $compta_localtax1 = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $account_vat);
190 $compta_localtax2 = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $account_vat);
193 if (
price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
194 $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.
')' :
''));
198 $taber[$obj->rowid][
"date"] = $db->jdate($obj->df);
200 $taber[$obj->rowid][
"date"] = $db->jdate($obj->de);
202 $taber[$obj->rowid][
"ref"] = $obj->ref;
203 $taber[$obj->rowid][
"comments"] = $obj->comments;
204 $taber[$obj->rowid][
"fk_expensereportdet"] = $obj->erdid;
207 if (!isset($tabttc[$obj->rowid][$compta_user])) {
208 $tabttc[$obj->rowid][$compta_user] = 0;
210 if (!isset($tabht[$obj->rowid][$compta_fees])) {
211 $tabht[$obj->rowid][$compta_fees] = 0;
213 if (!isset($tabtva[$obj->rowid][$compta_tva])) {
214 $tabtva[$obj->rowid][$compta_tva] = 0;
216 if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
217 $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
219 if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) {
220 $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
223 $tabttc[$obj->rowid][$compta_user] += $obj->total_ttc;
224 $tabht[$obj->rowid][$compta_fees] += $obj->total_ht;
225 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
226 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
227 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
228 $tabuser[$obj->rowid] = array(
231 'user_accountancy_code' => $obj->user_accountancy_account
241$sql =
"SELECT fk_expensereport, COUNT(erd.rowid) as nb";
242$sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport_det as erd";
243$sql .=
" WHERE erd.fk_code_ventilation <= 0";
244$sql .=
" AND erd.total_ttc <> 0";
245$sql .=
" AND fk_expensereport IN (".$db->sanitize(implode(
",", array_keys($taber))).
")";
246$sql .=
" GROUP BY fk_expensereport";
247$resql = $db->query($sql);
249$num = $db->num_rows($resql);
252 $obj = $db->fetch_object($resql);
254 $errorforinvoice[$obj->fk_expensereport] =
'somelinesarenotbound';
260if ($action ==
'writebookkeeping' && !$error && $user->hasRight(
'accounting',
'bind',
'write')) {
265 $accountingaccountexpense->fetch(0,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_EXPENSEREPORT'),
true);
267 foreach ($taber as $key => $val) {
276 if (!empty($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
279 setEventMessages($langs->trans(
'ErrorInvoiceContainsLinesNotYetBounded', $val[
'ref']),
null,
'errors');
283 if (!$errorforline) {
284 foreach ($tabttc[$key] as $k => $mt) {
287 $bookkeeping->doc_date = $val[
"date"];
288 $bookkeeping->doc_ref = $val[
"ref"];
289 $bookkeeping->date_creation = $now;
290 $bookkeeping->doc_type =
'expense_report';
291 $bookkeeping->fk_doc = $key;
292 $bookkeeping->fk_docdet = $val[
"fk_expensereportdet"];
294 $bookkeeping->subledger_account = $tabuser[$key][
'user_accountancy_code'];
295 $bookkeeping->subledger_label = $tabuser[$key][
'name'];
298 $bookkeeping->label_compte = $accountingaccountexpense->label;
300 $bookkeeping->label_operation = $tabuser[$key][
'name'];
301 $bookkeeping->montant = $mt;
302 $bookkeeping->sens = ($mt >= 0) ?
'C' :
'D';
303 $bookkeeping->debit = ($mt <= 0) ? -$mt : 0;
304 $bookkeeping->credit = ($mt > 0) ? $mt : 0;
305 $bookkeeping->code_journal = $journal;
306 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
307 $bookkeeping->fk_user_author = $user->id;
308 $bookkeeping->entity = $conf->entity;
310 $totaldebit += $bookkeeping->debit;
311 $totalcredit += $bookkeeping->credit;
313 $result = $bookkeeping->create($user);
315 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
318 $errorforinvoice[$key] =
'alreadyjournalized';
323 $errorforinvoice[$key] =
'other';
332 if (!$errorforline) {
333 foreach ($tabht[$key] as $k => $mt) {
336 if ($accountingaccount->fetch(0, $k,
true)) {
338 $bookkeeping->doc_date = $val[
"date"];
339 $bookkeeping->doc_ref = $val[
"ref"];
340 $bookkeeping->date_creation = $now;
341 $bookkeeping->doc_type =
'expense_report';
342 $bookkeeping->fk_doc = $key;
343 $bookkeeping->fk_docdet = $val[
"fk_expensereportdet"];
345 $bookkeeping->subledger_account =
'';
346 $bookkeeping->subledger_label =
'';
348 $bookkeeping->numero_compte = $k;
349 $bookkeeping->label_compte = $accountingaccount->label;
351 $bookkeeping->label_operation = $accountingaccount->label;
352 $bookkeeping->montant = $mt;
353 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
354 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
355 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
356 $bookkeeping->code_journal = $journal;
357 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
358 $bookkeeping->fk_user_author = $user->id;
359 $bookkeeping->entity = $conf->entity;
361 $totaldebit += $bookkeeping->debit;
362 $totalcredit += $bookkeeping->credit;
364 $result = $bookkeeping->create($user);
366 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
369 $errorforinvoice[$key] =
'alreadyjournalized';
374 $errorforinvoice[$key] =
'other';
384 if (!$errorforline) {
385 $listoftax = array(0, 1, 2);
386 foreach ($listoftax as $numtax) {
387 $arrayofvat = $tabtva;
389 $arrayofvat = $tablocaltax1;
392 $arrayofvat = $tablocaltax2;
395 foreach ($arrayofvat[$key] as $k => $mt) {
397 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
399 $accountingaccount->fetch(0, $k,
true);
400 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
402 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
405 $account_label = $accountingaccount->label;
409 $bookkeeping->doc_date = $val[
"date"];
410 $bookkeeping->doc_ref = $val[
"ref"];
411 $bookkeeping->date_creation = $now;
412 $bookkeeping->doc_type =
'expense_report';
413 $bookkeeping->fk_doc = $key;
414 $bookkeeping->fk_docdet = $val[
"fk_expensereportdet"];
416 $bookkeeping->subledger_account =
'';
417 $bookkeeping->subledger_label =
'';
419 $bookkeeping->numero_compte = $k;
420 $bookkeeping->label_compte = $account_label;
422 $bookkeeping->label_operation = $langs->trans(
"VAT").
' '.implode(
', ', $def_tva[$key][$k]).
' %';
423 $bookkeeping->montant = $mt;
424 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
425 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
426 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
427 $bookkeeping->code_journal = $journal;
428 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
429 $bookkeeping->fk_user_author = $user->id;
430 $bookkeeping->entity = $conf->entity;
432 $totaldebit += $bookkeeping->debit;
433 $totalcredit += $bookkeeping->credit;
435 $result = $bookkeeping->create($user);
437 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
440 $errorforinvoice[$key] =
'alreadyjournalized';
445 $errorforinvoice[$key] =
'other';
455 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
458 $errorforinvoice[$key] =
'amountsnotbalanced';
459 setEventMessages(
'We tried to insert a non balanced transaction in book for '.$val[
"ref"].
'. Canceled. Surely a bug.',
null,
'errors');
462 if (!$errorforline) {
468 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
476 if (empty($error) && count($tabpay) > 0) {
478 } elseif (count($tabpay) == $error) {
481 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
487 if (count($tabpay) != $error) {
488 $param =
'id_journal='.$id_journal;
489 $param .=
'&date_startday='.$date_startday;
490 $param .=
'&date_startmonth='.$date_startmonth;
491 $param .=
'&date_startyear='.$date_startyear;
492 $param .=
'&date_endday='.$date_endday;
493 $param .=
'&date_endmonth='.$date_endmonth;
494 $param .=
'&date_endyear='.$date_endyear;
495 $param .=
'&in_bookkeeping='.$in_bookkeeping;
497 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
507$form =
new Form($db);
509$userstatic =
new User($db);
512if ($action ==
'exportcsv' && !$error) {
515 $filename =
'journal';
516 $type_export =
'journal';
517 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
520 print
'"'.$langs->transnoentitiesnoconv(
"Date").
'"'.$sep;
521 print
'"'.$langs->transnoentitiesnoconv(
"Piece").
'"'.$sep;
522 print
'"'.$langs->transnoentitiesnoconv(
"AccountAccounting").
'"'.$sep;
523 print
'"'.$langs->transnoentitiesnoconv(
"LabelOperation").
'"'.$sep;
524 print
'"'.$langs->transnoentitiesnoconv(
"AccountingDebit").
'"'.$sep;
525 print
'"'.$langs->transnoentitiesnoconv(
"AccountingCredit").
'"'.$sep;
528 foreach ($taber as $key => $val) {
531 $userstatic->id = $tabuser[$key][
'id'];
532 $userstatic->name = $tabuser[$key][
'name'];
535 foreach ($tabht[$key] as $k => $mt) {
537 $accountingaccount->fetch(0, $k,
true);
539 print
'"'.$date.
'"'.$sep;
540 print
'"'.$val[
"ref"].
'"'.$sep;
541 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
542 print
'"'.dol_trunc($accountingaccount->label, 32).
'"'.$sep;
543 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
544 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"';
550 foreach ($tabtva[$key] as $k => $mt) {
552 print
'"'.$date.
'"'.$sep;
553 print
'"'.$val[
"ref"].
'"'.$sep;
554 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
555 print
'"'.dol_trunc($langs->trans(
"VAT")).
'"'.$sep;
556 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
557 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"';
563 foreach ($tabttc[$key] as $k => $mt) {
564 print
'"'.$date.
'"'.$sep;
565 print
'"'.$val[
"ref"].
'"'.$sep;
566 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
567 print
'"'.dol_trunc($userstatic->name).
'"'.$sep;
568 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
569 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"';
575if (empty($action) || $action ==
'view') {
576 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
577 $help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité';
578 llxHeader(
'',
dol_string_nohtmltag($title), $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy accountancy-generation page-expensereportsjournal');
585 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
587 $listofchoices = array(
'notyet' => $langs->trans(
"NotYetInGeneralLedger"),
'already' => $langs->trans(
"AlreadyInGeneralLedger"));
588 $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);
589 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
591 $varlink =
'id_journal='.$id_journal;
593 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
598 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int) $conf->entity);
599 $resql = $db->query($sql);
601 $obj = $db->fetch_object($resql);
603 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
604 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
605 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
616 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
617 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
618 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
622 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
624 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
625 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
628 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
630 if ($in_bookkeeping ==
'notyet') {
631 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
633 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
640 <script type="text/javascript">
641 function launch_export() {
642 $("div.fiche form input[name=\"action\"]").val("exportcsv");
643 $("div.fiche form input[type=\"submit\"]").click();
644 $("div.fiche form input[name=\"action\"]").val("");
646 function writebookkeeping() {
647 console.log("click on writebookkeeping");
648 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
649 $("div.fiche form input[type=\"submit\"]").click();
650 $("div.fiche form input[name=\"action\"]").val("");
660 print
'<div class="div-table-responsive">';
661 print
"<table class=\"noborder\" width=\"100%\">";
662 print
"<tr class=\"liste_titre\">";
663 print
"<td>".$langs->trans(
"Date").
"</td>";
664 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"ExpenseReportRef").
")</td>";
665 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
666 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
667 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
668 print
'<td class="right">'.$langs->trans(
"AccountingDebit").
"</td>";
669 print
'<td class="right">'.$langs->trans(
"AccountingCredit").
"</td>";
677 foreach ($taber as $key => $val) {
678 $expensereportstatic->id = $key;
679 $expensereportstatic->ref = $val[
"ref"];
680 $expensereportlinestatic->comments = html_entity_decode(
dol_trunc($val[
"comments"], 32));
684 if ($errorforinvoice[$key] ==
'somelinesarenotbound') {
685 print
'<tr class="oddeven">';
686 print
"<!-- Some lines are not bound -->";
687 print
"<td>".$date.
"</td>";
688 print
"<td>".$expensereportstatic->getNomUrl(1).
"</td>";
691 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $val[
'ref']).
'</span>';
698 print
'<td class="right"></td>';
699 print
'<td class="right"></td>';
706 foreach ($tabht[$key] as $k => $mt) {
707 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
709 $accountingaccount->fetch(0, $k,
true);
710 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
712 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
716 print
'<tr class="oddeven">';
717 print
"<!-- Fees -->";
718 print
"<td>".$date.
"</td>";
719 print
"<td>".$expensereportstatic->getNomUrl(1).
"</td>";
720 $userstatic->id = $tabuser[$key][
'id'];
721 $userstatic->name = $tabuser[$key][
'name'];
725 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
726 print
'<span class="error">'.$langs->trans(
"FeeAccountNotDefined").
'</span>';
734 $userstatic->id = $tabuser[$key][
'id'];
735 $userstatic->name = $tabuser[$key][
'name'];
736 print
"<td>".$userstatic->getNomUrl(0,
'user', 16).
' - '.$accountingaccount->label.
"</td>";
737 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
738 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
746 foreach ($tabttc[$key] as $k => $mt) {
747 $userstatic->id = $tabuser[$key][
'id'];
748 $userstatic->name = $tabuser[$key][
'name'];
750 print
'<tr class="oddeven">';
751 print
"<!-- Thirdparty -->";
752 print
"<td>".$date.
"</td>";
753 print
"<td>".$expensereportstatic->getNomUrl(1).
"</td>";
757 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
758 print
'<span class="error">'.$langs->trans(
"MainAccountForUsersNotDefined").
'</span>';
766 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
767 print
'<span class="error">'.$langs->trans(
"UserAccountNotDefined").
'</span>';
772 print
"<td>".$userstatic->getNomUrl(0,
'user', 16).
' - '.$langs->trans(
"SubledgerAccount").
"</td>";
773 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
774 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
781 $listoftax = array(0, 1, 2);
782 foreach ($listoftax as $numtax) {
783 $arrayofvat = $tabtva;
785 $arrayofvat = $tablocaltax1;
788 $arrayofvat = $tablocaltax2;
791 foreach ($arrayofvat[$key] as $k => $mt) {
793 print
'<tr class="oddeven">';
794 print
"<!-- VAT -->";
795 print
"<td>".$date.
"</td>";
796 print
"<td>".$expensereportstatic->getNomUrl(1).
"</td>";
800 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
801 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
'</span>';
809 print
"<td>".$userstatic->getNomUrl(0,
'user', 16).
' - '.$langs->trans(
"VAT").
' '.implode(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'');
811 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
812 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
823 print
'<tr class="oddeven"><td colspan="'.$colspan.
'"><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($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 Trips and Expenses.
Class of expense report details lines.
Class to manage Dolibarr users.
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...
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.
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).
dolGetFirstLastname($firstname, $lastname, $nameorder=-1)
Return firstname and lastname in correct order.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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 a 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.