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) {
324 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
326 $accountingaccount->fetch(0, $k,
true);
327 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
329 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
332 $account_label = $accountingaccount->label;
335 if ($accountingaccount->fetch(
null, $k,
true)) {
337 $bookkeeping->doc_date = $val[
"date"];
338 $bookkeeping->doc_ref = $val[
"ref"];
339 $bookkeeping->date_creation = $now;
340 $bookkeeping->doc_type =
'expense_report';
341 $bookkeeping->fk_doc = $key;
342 $bookkeeping->fk_docdet = $val[
"fk_expensereportdet"];
344 $bookkeeping->subledger_account =
'';
345 $bookkeeping->subledger_label =
'';
347 $bookkeeping->numero_compte = $k;
348 $bookkeeping->label_compte = $account_label;
350 $bookkeeping->label_operation = $account_label;
351 $bookkeeping->montant = $mt;
352 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
353 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
354 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
355 $bookkeeping->code_journal = $journal;
356 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
357 $bookkeeping->fk_user_author = $user->id;
358 $bookkeeping->entity = $conf->entity;
360 $totaldebit += $bookkeeping->debit;
361 $totalcredit += $bookkeeping->credit;
363 $result = $bookkeeping->create($user);
365 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
368 $errorforinvoice[$key] =
'alreadyjournalized';
373 $errorforinvoice[$key] =
'other';
383 if (!$errorforline) {
384 $listoftax = array(0, 1, 2);
385 foreach ($listoftax as $numtax) {
386 $arrayofvat = $tabtva;
388 $arrayofvat = $tablocaltax1;
391 $arrayofvat = $tablocaltax2;
394 foreach ($arrayofvat[$key] as $k => $mt) {
396 if (empty($conf->cache[
'accountingaccountincurrententity_vat'][$k])) {
398 $accountingaccount->fetch(0, $k,
true);
399 $conf->cache[
'accountingaccountincurrententity_vat'][$k] = $accountingaccount;
401 $accountingaccount = $conf->cache[
'accountingaccountincurrententity_vat'][$k];
404 $account_label = $accountingaccount->label;
408 $bookkeeping->doc_date = $val[
"date"];
409 $bookkeeping->doc_ref = $val[
"ref"];
410 $bookkeeping->date_creation = $now;
411 $bookkeeping->doc_type =
'expense_report';
412 $bookkeeping->fk_doc = $key;
413 $bookkeeping->fk_docdet = $val[
"fk_expensereportdet"];
415 $bookkeeping->subledger_account =
'';
416 $bookkeeping->subledger_label =
'';
418 $bookkeeping->numero_compte = $k;
419 $bookkeeping->label_compte = $account_label;
421 $bookkeeping->label_operation = $langs->trans(
"VAT").
' '.implode(
', ', $def_tva[$key][$k]).
' %';
422 $bookkeeping->montant = $mt;
423 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
424 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
425 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
426 $bookkeeping->code_journal = $journal;
427 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
428 $bookkeeping->fk_user_author = $user->id;
429 $bookkeeping->entity = $conf->entity;
431 $totaldebit += $bookkeeping->debit;
432 $totalcredit += $bookkeeping->credit;
434 $result = $bookkeeping->create($user);
436 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
439 $errorforinvoice[$key] =
'alreadyjournalized';
444 $errorforinvoice[$key] =
'other';
454 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
457 $errorforinvoice[$key] =
'amountsnotbalanced';
458 setEventMessages(
'We tried to insert a non balanced transaction in book for '.$val[
"ref"].
'. Canceled. Surely a bug.',
null,
'errors');
461 if (!$errorforline) {
467 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
475 if (empty($error) && count($tabpay) > 0) {
477 } elseif (count($tabpay) == $error) {
480 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
486 if (count($tabpay) != $error) {
487 $param =
'id_journal='.$id_journal;
488 $param .=
'&date_startday='.$date_startday;
489 $param .=
'&date_startmonth='.$date_startmonth;
490 $param .=
'&date_startyear='.$date_startyear;
491 $param .=
'&date_endday='.$date_endday;
492 $param .=
'&date_endmonth='.$date_endmonth;
493 $param .=
'&date_endyear='.$date_endyear;
494 $param .=
'&in_bookkeeping='.$in_bookkeeping;
496 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
506$form =
new Form($db);
508$userstatic =
new User($db);
511if ($action ==
'exportcsv' && !$error) {
514 $filename =
'journal';
515 $type_export =
'journal';
516 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
519 print
'"'.$langs->transnoentitiesnoconv(
"Date").
'"'.$sep;
520 print
'"'.$langs->transnoentitiesnoconv(
"Piece").
'"'.$sep;
521 print
'"'.$langs->transnoentitiesnoconv(
"AccountAccounting").
'"'.$sep;
522 print
'"'.$langs->transnoentitiesnoconv(
"LabelOperation").
'"'.$sep;
523 print
'"'.$langs->transnoentitiesnoconv(
"AccountingDebit").
'"'.$sep;
524 print
'"'.$langs->transnoentitiesnoconv(
"AccountingCredit").
'"'.$sep;
527 foreach ($taber as $key => $val) {
530 $userstatic->id = $tabuser[$key][
'id'];
531 $userstatic->name = $tabuser[$key][
'name'];
534 foreach ($tabht[$key] as $k => $mt) {
536 $accountingaccount->fetch(
null, $k,
true);
538 print
'"'.$date.
'"'.$sep;
539 print
'"'.$val[
"ref"].
'"'.$sep;
540 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
541 print
'"'.dol_trunc($accountingaccount->label, 32).
'"'.$sep;
542 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
543 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"';
549 foreach ($tabtva[$key] as $k => $mt) {
551 print
'"'.$date.
'"'.$sep;
552 print
'"'.$val[
"ref"].
'"'.$sep;
553 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
554 print
'"'.dol_trunc($langs->trans(
"VAT")).
'"'.$sep;
555 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
556 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"';
562 foreach ($tabttc[$key] as $k => $mt) {
563 print
'"'.$date.
'"'.$sep;
564 print
'"'.$val[
"ref"].
'"'.$sep;
565 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
566 print
'"'.dol_trunc($userstatic->name).
'"'.$sep;
567 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
568 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"';
574if (empty($action) || $action ==
'view') {
575 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
576 $help_url =
'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilité_en_Partie_Double#Génération_des_écritures_en_comptabilité';
577 llxHeader(
'',
dol_string_nohtmltag($title), $help_url,
'', 0, 0,
'',
'',
'',
'mod-accountancy accountancy-generation page-expensereportsjournal');
584 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
586 $listofchoices = array(
'notyet'=>$langs->trans(
"NotYetInGeneralLedger"),
'already'=>$langs->trans(
"AlreadyInGeneralLedger"));
587 $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);
588 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
590 $varlink =
'id_journal='.$id_journal;
592 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
597 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int) $conf->entity);
598 $resql = $db->query($sql);
600 $obj = $db->fetch_object($resql);
602 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
603 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
604 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
615 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
616 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
617 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
621 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
623 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
624 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
627 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
629 if ($in_bookkeeping ==
'notyet') {
630 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
632 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
639 <script type="text/javascript">
640 function launch_export() {
641 $("div.fiche form input[name=\"action\"]").val("exportcsv");
642 $("div.fiche form input[type=\"submit\"]").click();
643 $("div.fiche form input[name=\"action\"]").val("");
645 function writebookkeeping() {
646 console.log("click on writebookkeeping");
647 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
648 $("div.fiche form input[type=\"submit\"]").click();
649 $("div.fiche form input[name=\"action\"]").val("");
659 print
'<div class="div-table-responsive">';
660 print
"<table class=\"noborder\" width=\"100%\">";
661 print
"<tr class=\"liste_titre\">";
662 print
"<td>".$langs->trans(
"Date").
"</td>";
663 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"ExpenseReportRef").
")</td>";
664 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
665 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
666 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
667 print
'<td class="right">'.$langs->trans(
"AccountingDebit").
"</td>";
668 print
'<td class="right">'.$langs->trans(
"AccountingCredit").
"</td>";
676 foreach ($taber as $key => $val) {
677 $expensereportstatic->id = $key;
678 $expensereportstatic->ref = $val[
"ref"];
679 $expensereportlinestatic->comments = html_entity_decode(
dol_trunc($val[
"comments"], 32));
683 if ($errorforinvoice[$key] ==
'somelinesarenotbound') {
684 print
'<tr class="oddeven">';
685 print
"<!-- Some lines are not bound -->";
686 print
"<td>".$date.
"</td>";
687 print
"<td>".$expensereportstatic->getNomUrl(1).
"</td>";
690 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $val[
'ref']).
'</span>';
697 print
'<td class="right"></td>';
698 print
'<td class="right"></td>';
705 foreach ($tabht[$key] as $k => $mt) {
706 if (empty($conf->cache[
'accountingaccountincurrententity'][$k])) {
708 $accountingaccount->fetch(0, $k,
true);
709 $conf->cache[
'accountingaccountincurrententity'][$k] = $accountingaccount;
711 $accountingaccount = $conf->cache[
'accountingaccountincurrententity'][$k];
715 print
'<tr class="oddeven">';
716 print
"<!-- Fees -->";
717 print
"<td>".$date.
"</td>";
718 print
"<td>".$expensereportstatic->getNomUrl(1).
"</td>";
719 $userstatic->id = $tabuser[$key][
'id'];
720 $userstatic->name = $tabuser[$key][
'name'];
724 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
725 print
'<span class="error">'.$langs->trans(
"FeeAccountNotDefined").
'</span>';
733 $userstatic->id = $tabuser[$key][
'id'];
734 $userstatic->name = $tabuser[$key][
'name'];
735 print
"<td>".$userstatic->getNomUrl(0,
'user', 16).
' - '.$accountingaccount->label.
"</td>";
736 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
737 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
745 foreach ($tabttc[$key] as $k => $mt) {
746 $userstatic->id = $tabuser[$key][
'id'];
747 $userstatic->name = $tabuser[$key][
'name'];
749 print
'<tr class="oddeven">';
750 print
"<!-- Thirdparty -->";
751 print
"<td>".$date.
"</td>";
752 print
"<td>".$expensereportstatic->getNomUrl(1).
"</td>";
756 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
757 print
'<span class="error">'.$langs->trans(
"MainAccountForUsersNotDefined").
'</span>';
765 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
766 print
'<span class="error">'.$langs->trans(
"UserAccountNotDefined").
'</span>';
771 print
"<td>".$userstatic->getNomUrl(0,
'user', 16).
' - '.$langs->trans(
"SubledgerAccount").
"</td>";
772 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
773 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
780 $listoftax = array(0, 1, 2);
781 foreach ($listoftax as $numtax) {
782 $arrayofvat = $tabtva;
784 $arrayofvat = $tablocaltax1;
787 $arrayofvat = $tablocaltax2;
790 foreach ($arrayofvat[$key] as $k => $mt) {
792 print
'<tr class="oddeven">';
793 print
"<!-- VAT -->";
794 print
"<td>".$date.
"</td>";
795 print
"<td>".$expensereportstatic->getNomUrl(1).
"</td>";
799 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
800 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
'</span>';
808 print
"<td>".$userstatic->getNomUrl(0,
'user', 16).
' - '.$langs->trans(
"VAT").
' '.implode(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'');
810 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
811 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
822 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.