31require
'../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
35require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
36require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
37require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
38require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
39require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/bookkeeping.class.php';
42$langs->loadLangs(array(
"commercial",
"compta",
"bills",
"other",
"accountancy",
"trips",
"errors"));
45$action =
GETPOST(
'action',
'aZ09');
47$date_startmonth =
GETPOST(
'date_startmonth');
48$date_startday =
GETPOST(
'date_startday');
49$date_startyear =
GETPOST(
'date_startyear');
50$date_endmonth =
GETPOST(
'date_endmonth');
51$date_endday =
GETPOST(
'date_endday');
52$date_endyear =
GETPOST(
'date_endyear');
53$in_bookkeeping =
GETPOST(
'in_bookkeeping');
54if ($in_bookkeeping ==
'') {
55 $in_bookkeeping =
'notyet';
60$hookmanager->initHooks(array(
'expensereportsjournal'));
64if (!isModEnabled(
'accounting')) {
67if ($user->socid > 0) {
70if (!$user->hasRight(
'accounting',
'bind',
'write')) {
75$errorforinvoice = array();
86$accountingjournalstatic->fetch($id_journal);
87$journal = $accountingjournalstatic->code;
88$journal_label = $accountingjournalstatic->label;
90$date_start =
dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
91$date_end =
dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
93if (empty($date_startmonth)) {
96 $date_start = $dates[
'date_start'];
97 $pastmonthyear = $dates[
'pastmonthyear'];
98 $pastmonth = $dates[
'pastmonth'];
100if (empty($date_endmonth)) {
103 $date_end = $dates[
'date_end'];
104 $pastmonthyear = $dates[
'pastmonthyear'];
105 $pastmonth = $dates[
'pastmonth'];
108if (!GETPOSTISSET(
'date_startmonth') && (empty($date_start) || empty($date_end))) {
113$sql =
"SELECT er.rowid, er.ref, er.date_debut as de, er.date_fin as df,";
114$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, ";
115$sql .=
" u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,";
116$sql .=
" f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
117$parameters = array();
118$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
119$sql .= $hookmanager->resPrint;
120$sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport_det as erd";
121$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_type_fees as f ON f.id = erd.fk_c_type_fees";
122$sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
123$sql .=
" JOIN ".MAIN_DB_PREFIX.
"expensereport as er ON er.rowid = erd.fk_expensereport";
124$sql .=
" JOIN ".MAIN_DB_PREFIX.
"user as u ON u.rowid = er.fk_user_author";
125$parameters = array();
126$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters);
127$sql .= $hookmanager->resPrint;
128$sql .=
" WHERE er.fk_statut > 0";
129$sql .=
" AND erd.fk_code_ventilation > 0";
130$sql .=
" AND er.entity IN (".getEntity(
'expensereport', 0).
")";
131if ($date_start && $date_end) {
132 $sql .=
" AND er.date_debut >= '".$db->idate($date_start).
"' AND er.date_debut <= '".$db->idate($date_end).
"'";
136 $sql .=
" AND er.date_debut >= '".$db->idate(
getDolGlobalString(
'ACCOUNTING_DATE_START_BINDING')).
"'";
139if ($in_bookkeeping ==
'already') {
140 $sql .=
" AND er.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
142if ($in_bookkeeping ==
'notyet') {
143 $sql .=
" AND er.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
145$parameters = array();
146$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
147$sql .= $hookmanager->resPrint;
148$sql .=
" ORDER BY er.date_debut";
150dol_syslog(
'accountancy/journal/expensereportsjournal.php', LOG_DEBUG);
151$result = $db->query($sql);
158 $tablocaltax1 = array();
159 $tablocaltax2 = array();
162 $num = $db->num_rows($result);
165 $account_salary =
getDolGlobalString(
'ACCOUNTING_ACCOUNT_EXPENSEREPORT',
'NotDefined');
170 $obj = $db->fetch_object($result);
173 $compta_user = (!empty($obj->user_accountancy_account)) ? $obj->user_accountancy_account : $account_salary;
174 $compta_fees = $obj->compte;
176 $vatdata =
getTaxesFromId($obj->tva_tx.($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''), $mysoc, $mysoc, 0);
177 $compta_tva = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $account_vat);
178 $compta_localtax1 = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $account_vat);
179 $compta_localtax2 = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $account_vat);
182 if (
price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
183 $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.
')' :
''));
187 $taber[$obj->rowid][
"date"] = $db->jdate($obj->df);
189 $taber[$obj->rowid][
"date"] = $db->jdate($obj->de);
191 $taber[$obj->rowid][
"ref"] = $obj->ref;
192 $taber[$obj->rowid][
"comments"] = $obj->comments;
193 $taber[$obj->rowid][
"fk_expensereportdet"] = $obj->erdid;
196 if (!isset($tabttc[$obj->rowid][$compta_user])) {
197 $tabttc[$obj->rowid][$compta_user] = 0;
199 if (!isset($tabht[$obj->rowid][$compta_fees])) {
200 $tabht[$obj->rowid][$compta_fees] = 0;
202 if (!isset($tabtva[$obj->rowid][$compta_tva])) {
203 $tabtva[$obj->rowid][$compta_tva] = 0;
205 if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
206 $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
208 if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) {
209 $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
212 $tabttc[$obj->rowid][$compta_user] += $obj->total_ttc;
213 $tabht[$obj->rowid][$compta_fees] += $obj->total_ht;
214 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
215 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
216 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
217 $tabuser[$obj->rowid] = array(
220 'user_accountancy_code' => $obj->user_accountancy_account
230$sql =
"SELECT fk_expensereport, COUNT(erd.rowid) as nb";
231$sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport_det as erd";
232$sql .=
" WHERE erd.fk_code_ventilation <= 0";
233$sql .=
" AND erd.total_ttc <> 0";
234$sql .=
" AND fk_expensereport IN (".$db->sanitize(implode(
",", array_keys($taber))).
")";
235$sql .=
" GROUP BY fk_expensereport";
236$resql = $db->query($sql);
238$num = $db->num_rows($resql);
241 $obj = $db->fetch_object($resql);
243 $errorforinvoice[$obj->fk_expensereport] =
'somelinesarenotbound';
249if ($action ==
'writebookkeeping' && !$error && $user->hasRight(
'accounting',
'bind',
'write')) {
254 $accountingaccountexpense->fetch(
null,
getDolGlobalString(
'ACCOUNTING_ACCOUNT_EXPENSEREPORT'),
true);
256 foreach ($taber as $key => $val) {
265 if (!empty($errorforinvoice[$key]) && $errorforinvoice[$key] ==
'somelinesarenotbound') {
268 setEventMessages($langs->trans(
'ErrorInvoiceContainsLinesNotYetBounded', $val[
'ref']),
null,
'errors');
272 if (!$errorforline) {
273 foreach ($tabttc[$key] as $k => $mt) {
276 $bookkeeping->doc_date = $val[
"date"];
277 $bookkeeping->doc_ref = $val[
"ref"];
278 $bookkeeping->date_creation = $now;
279 $bookkeeping->doc_type =
'expense_report';
280 $bookkeeping->fk_doc = $key;
281 $bookkeeping->fk_docdet = $val[
"fk_expensereportdet"];
283 $bookkeeping->subledger_account = $tabuser[$key][
'user_accountancy_code'];
284 $bookkeeping->subledger_label = $tabuser[$key][
'name'];
287 $bookkeeping->label_compte = $accountingaccountexpense->label;
289 $bookkeeping->label_operation = $tabuser[$key][
'name'];
290 $bookkeeping->montant = $mt;
291 $bookkeeping->sens = ($mt >= 0) ?
'C' :
'D';
292 $bookkeeping->debit = ($mt <= 0) ? -$mt : 0;
293 $bookkeeping->credit = ($mt > 0) ? $mt : 0;
294 $bookkeeping->code_journal = $journal;
295 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
296 $bookkeeping->fk_user_author = $user->id;
297 $bookkeeping->entity = $conf->entity;
299 $totaldebit += $bookkeeping->debit;
300 $totalcredit += $bookkeeping->credit;
302 $result = $bookkeeping->create($user);
304 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
307 $errorforinvoice[$key] =
'alreadyjournalized';
312 $errorforinvoice[$key] =
'other';
321 if (!$errorforline) {
322 foreach ($tabht[$key] as $k => $mt) {
325 if ($accountingaccount->fetch(
null, $k,
true)) {
327 $bookkeeping->doc_date = $val[
"date"];
328 $bookkeeping->doc_ref = $val[
"ref"];
329 $bookkeeping->date_creation = $now;
330 $bookkeeping->doc_type =
'expense_report';
331 $bookkeeping->fk_doc = $key;
332 $bookkeeping->fk_docdet = $val[
"fk_expensereportdet"];
334 $bookkeeping->subledger_account =
'';
335 $bookkeeping->subledger_label =
'';
337 $bookkeeping->numero_compte = $k;
338 $bookkeeping->label_compte = $accountingaccount->label;
340 $bookkeeping->label_operation = $accountingaccount->label;
341 $bookkeeping->montant = $mt;
342 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
343 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
344 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
345 $bookkeeping->code_journal = $journal;
346 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
347 $bookkeeping->fk_user_author = $user->id;
348 $bookkeeping->entity = $conf->entity;
350 $totaldebit += $bookkeeping->debit;
351 $totalcredit += $bookkeeping->credit;
353 $result = $bookkeeping->create($user);
355 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
358 $errorforinvoice[$key] =
'alreadyjournalized';
363 $errorforinvoice[$key] =
'other';
373 if (!$errorforline) {
374 $listoftax = array(0, 1, 2);
375 foreach ($listoftax as $numtax) {
376 $arrayofvat = $tabtva;
378 $arrayofvat = $tablocaltax1;
381 $arrayofvat = $tablocaltax2;
384 foreach ($arrayofvat[$key] as $k => $mt) {
386 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
388 $accountingaccount->fetch(0, $k,
true);
389 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
391 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
394 $account_label = $accountingaccount->label;
398 $bookkeeping->doc_date = $val[
"date"];
399 $bookkeeping->doc_ref = $val[
"ref"];
400 $bookkeeping->date_creation = $now;
401 $bookkeeping->doc_type =
'expense_report';
402 $bookkeeping->fk_doc = $key;
403 $bookkeeping->fk_docdet = $val[
"fk_expensereportdet"];
405 $bookkeeping->subledger_account =
'';
406 $bookkeeping->subledger_label =
'';
408 $bookkeeping->numero_compte = $k;
409 $bookkeeping->label_compte = $account_label;
411 $bookkeeping->label_operation = $langs->trans(
"VAT").
' '.implode(
', ', $def_tva[$key][$k]).
' %';
412 $bookkeeping->montant = $mt;
413 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
414 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
415 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
416 $bookkeeping->code_journal = $journal;
417 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
418 $bookkeeping->fk_user_author = $user->id;
419 $bookkeeping->entity = $conf->entity;
421 $totaldebit += $bookkeeping->debit;
422 $totalcredit += $bookkeeping->credit;
424 $result = $bookkeeping->create($user);
426 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
429 $errorforinvoice[$key] =
'alreadyjournalized';
434 $errorforinvoice[$key] =
'other';
444 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
447 $errorforinvoice[$key] =
'amountsnotbalanced';
448 setEventMessages(
'We tried to insert a non balanced transaction in book for '.$val[
"ref"].
'. Canceled. Surely a bug.',
null,
'errors');
451 if (!$errorforline) {
457 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
465 if (empty($error) && count($tabpay) > 0) {
467 } elseif (count($tabpay) == $error) {
470 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
476 if (count($tabpay) != $error) {
477 $param =
'id_journal='.$id_journal;
478 $param .=
'&date_startday='.$date_startday;
479 $param .=
'&date_startmonth='.$date_startmonth;
480 $param .=
'&date_startyear='.$date_startyear;
481 $param .=
'&date_endday='.$date_endday;
482 $param .=
'&date_endmonth='.$date_endmonth;
483 $param .=
'&date_endyear='.$date_endyear;
484 $param .=
'&in_bookkeeping='.$in_bookkeeping;
486 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
496$form =
new Form($db);
498$userstatic =
new User($db);
501if ($action ==
'exportcsv' && !$error) {
504 $filename =
'journal';
505 $type_export =
'journal';
506 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
509 print
'"'.$langs->transnoentitiesnoconv(
"Date").
'"'.$sep;
510 print
'"'.$langs->transnoentitiesnoconv(
"Piece").
'"'.$sep;
511 print
'"'.$langs->transnoentitiesnoconv(
"AccountAccounting").
'"'.$sep;
512 print
'"'.$langs->transnoentitiesnoconv(
"LabelOperation").
'"'.$sep;
513 print
'"'.$langs->transnoentitiesnoconv(
"AccountingDebit").
'"'.$sep;
514 print
'"'.$langs->transnoentitiesnoconv(
"AccountingCredit").
'"'.$sep;
517 foreach ($taber as $key => $val) {
520 $userstatic->id = $tabuser[$key][
'id'];
521 $userstatic->name = $tabuser[$key][
'name'];
524 foreach ($tabht[$key] as $k => $mt) {
526 $accountingaccount->fetch(
null, $k,
true);
528 print
'"'.$date.
'"'.$sep;
529 print
'"'.$val[
"ref"].
'"'.$sep;
530 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
531 print
'"'.dol_trunc($accountingaccount->label, 32).
'"'.$sep;
532 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
533 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"';
539 foreach ($tabtva[$key] as $k => $mt) {
541 print
'"'.$date.
'"'.$sep;
542 print
'"'.$val[
"ref"].
'"'.$sep;
543 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
544 print
'"'.dol_trunc($langs->trans(
"VAT")).
'"'.$sep;
545 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
546 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"';
552 foreach ($tabttc[$key] as $k => $mt) {
553 print
'"'.$date.
'"'.$sep;
554 print
'"'.$val[
"ref"].
'"'.$sep;
555 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
556 print
'"'.dol_trunc($userstatic->name).
'"'.$sep;
557 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
558 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"';
564if (empty($action) || $action ==
'view') {
565 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
566 $help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité';
567 llxHeader(
'',
dol_string_nohtmltag($title), $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy accountancy-generation page-expensereportsjournal');
574 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
576 $listofchoices = array(
'notyet'=>$langs->trans(
"NotYetInGeneralLedger"),
'already'=>$langs->trans(
"AlreadyInGeneralLedger"));
577 $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);
578 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
580 $varlink =
'id_journal='.$id_journal;
582 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
587 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int) $conf->entity);
588 $resql = $db->query($sql);
590 $obj = $db->fetch_object($resql);
592 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
593 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
594 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
605 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
606 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
607 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
611 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
613 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
614 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
617 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
619 if ($in_bookkeeping ==
'notyet') {
620 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
622 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
629 <script type="text/javascript">
630 function launch_export() {
631 $("div.fiche form input[name=\"action\"]").val("exportcsv");
632 $("div.fiche form input[type=\"submit\"]").click();
633 $("div.fiche form input[name=\"action\"]").val("");
635 function writebookkeeping() {
636 console.log("click on writebookkeeping");
637 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
638 $("div.fiche form input[type=\"submit\"]").click();
639 $("div.fiche form input[name=\"action\"]").val("");
649 print
'<div class="div-table-responsive">';
650 print
"<table class=\"noborder\" width=\"100%\">";
651 print
"<tr class=\"liste_titre\">";
652 print
"<td>".$langs->trans(
"Date").
"</td>";
653 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"ExpenseReportRef").
")</td>";
654 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
655 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
656 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
657 print
'<td class="right">'.$langs->trans(
"AccountingDebit").
"</td>";
658 print
'<td class="right">'.$langs->trans(
"AccountingCredit").
"</td>";
666 foreach ($taber as $key => $val) {
667 $expensereportstatic->id = $key;
668 $expensereportstatic->ref = $val[
"ref"];
669 $expensereportlinestatic->comments = html_entity_decode(
dol_trunc($val[
"comments"], 32));
673 if ($errorforinvoice[$key] ==
'somelinesarenotbound') {
674 print
'<tr class="oddeven">';
675 print
"<!-- Some lines are not bound -->";
676 print
"<td>".$date.
"</td>";
677 print
"<td>".$expensereportstatic->getNomUrl(1).
"</td>";
680 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $val[
'ref']).
'</span>';
687 print
'<td class="right"></td>';
688 print
'<td class="right"></td>';
695 foreach ($tabht[$key] as $k => $mt) {
696 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
698 $accountingaccount->fetch(0, $k,
true);
699 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
701 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
705 print
'<tr class="oddeven">';
706 print
"<!-- Fees -->";
707 print
"<td>".$date.
"</td>";
708 print
"<td>".$expensereportstatic->getNomUrl(1).
"</td>";
709 $userstatic->id = $tabuser[$key][
'id'];
710 $userstatic->name = $tabuser[$key][
'name'];
714 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
715 print
'<span class="error">'.$langs->trans(
"FeeAccountNotDefined").
'</span>';
723 $userstatic->id = $tabuser[$key][
'id'];
724 $userstatic->name = $tabuser[$key][
'name'];
725 print
"<td>".$userstatic->getNomUrl(0,
'user', 16).
' - '.$accountingaccount->label.
"</td>";
726 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
727 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
735 foreach ($tabttc[$key] as $k => $mt) {
736 $userstatic->id = $tabuser[$key][
'id'];
737 $userstatic->name = $tabuser[$key][
'name'];
739 print
'<tr class="oddeven">';
740 print
"<!-- Thirdparty -->";
741 print
"<td>".$date.
"</td>";
742 print
"<td>".$expensereportstatic->getNomUrl(1).
"</td>";
746 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
747 print
'<span class="error">'.$langs->trans(
"MainAccountForUsersNotDefined").
'</span>';
755 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
756 print
'<span class="error">'.$langs->trans(
"UserAccountNotDefined").
'</span>';
761 print
"<td>".$userstatic->getNomUrl(0,
'user', 16).
' - '.$langs->trans(
"SubledgerAccount").
"</td>";
762 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
763 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
770 $listoftax = array(0, 1, 2);
771 foreach ($listoftax as $numtax) {
772 $arrayofvat = $tabtva;
774 $arrayofvat = $tablocaltax1;
777 $arrayofvat = $tablocaltax2;
780 foreach ($arrayofvat[$key] as $k => $mt) {
782 print
'<tr class="oddeven">';
783 print
"<!-- VAT -->";
784 print
"<td>".$date.
"</td>";
785 print
"<td>".$expensereportstatic->getNomUrl(1).
"</td>";
789 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
790 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
'</span>';
798 print
"<td>".$userstatic->getNomUrl(0,
'user', 16).
' - '.$langs->trans(
"VAT").
' '.implode(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'');
800 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
801 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
812 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()
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...
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.
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.