31 require
'../../main.inc.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/report.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/date.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
35 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingjournal.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
37 require_once DOL_DOCUMENT_ROOT.
'/expensereport/class/expensereport.class.php';
38 require_once DOL_DOCUMENT_ROOT.
'/user/class/user.class.php';
39 require_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');
54 if ($in_bookkeeping ==
'') {
55 $in_bookkeeping =
'notyet';
60 $hookmanager->initHooks(array(
'expensereportsjournal'));
61 $parameters = array();
67 if ($user->socid > 0) {
70 if (!$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);
93 if (empty($date_startmonth)) {
96 $date_start = $dates[
'date_start'];
97 $pastmonthyear = $dates[
'pastmonthyear'];
98 $pastmonth = $dates[
'pastmonth'];
100 if (empty($date_endmonth)) {
103 $date_end = $dates[
'date_end'];
104 $pastmonthyear = $dates[
'pastmonthyear'];
105 $pastmonth = $dates[
'pastmonth'];
108 if (!
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).
")";
131 if ($date_start && $date_end) {
132 $sql .=
" AND er.date_debut >= '".$db->idate($date_start).
"' AND er.date_debut <= '".$db->idate($date_end).
"'";
139 if ($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')";
142 if ($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";
150 dol_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'] : $cpttva);
179 $compta_localtax2 = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $cpttva);
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';
249 if ($action ==
'writebookkeeping' && !$error) {
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 $accountingaccount->fetch(
null, $k,
true);
387 $account_label = $accountingaccount->label;
391 $bookkeeping->doc_date = $val[
"date"];
392 $bookkeeping->doc_ref = $val[
"ref"];
393 $bookkeeping->date_creation = $now;
394 $bookkeeping->doc_type =
'expense_report';
395 $bookkeeping->fk_doc = $key;
396 $bookkeeping->fk_docdet = $val[
"fk_expensereportdet"];
398 $bookkeeping->subledger_account =
'';
399 $bookkeeping->subledger_label =
'';
401 $bookkeeping->numero_compte = $k;
402 $bookkeeping->label_compte = $account_label;
404 $bookkeeping->label_operation = $langs->trans(
"VAT").
' '.implode(
', ', $def_tva[$key][$k]).
' %';
405 $bookkeeping->montant = $mt;
406 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
407 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
408 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
409 $bookkeeping->code_journal = $journal;
410 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
411 $bookkeeping->fk_user_author = $user->id;
412 $bookkeeping->entity = $conf->entity;
414 $totaldebit += $bookkeeping->debit;
415 $totalcredit += $bookkeeping->credit;
417 $result = $bookkeeping->create($user);
419 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
422 $errorforinvoice[$key] =
'alreadyjournalized';
427 $errorforinvoice[$key] =
'other';
437 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
440 $errorforinvoice[$key] =
'amountsnotbalanced';
441 setEventMessages(
'We tried to insert a non balanced transaction in book for '.$val[
"ref"].
'. Canceled. Surely a bug.',
null,
'errors');
444 if (!$errorforline) {
450 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
458 if (empty($error) && count($tabpay) > 0) {
460 } elseif (count($tabpay) == $error) {
463 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
469 if (count($tabpay) != $error) {
470 $param =
'id_journal='.$id_journal;
471 $param .=
'&date_startday='.$date_startday;
472 $param .=
'&date_startmonth='.$date_startmonth;
473 $param .=
'&date_startyear='.$date_startyear;
474 $param .=
'&date_endday='.$date_endday;
475 $param .=
'&date_endmonth='.$date_endmonth;
476 $param .=
'&date_endyear='.$date_endyear;
477 $param .=
'&in_bookkeeping='.$in_bookkeeping;
479 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
489 $form =
new Form($db);
491 $userstatic =
new User($db);
494 if ($action ==
'exportcsv' && !$error) {
497 $filename =
'journal';
498 $type_export =
'journal';
499 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
502 print
'"'.$langs->transnoentitiesnoconv(
"Date").
'"'.$sep;
503 print
'"'.$langs->transnoentitiesnoconv(
"Piece").
'"'.$sep;
504 print
'"'.$langs->transnoentitiesnoconv(
"AccountAccounting").
'"'.$sep;
505 print
'"'.$langs->transnoentitiesnoconv(
"LabelOperation").
'"'.$sep;
506 print
'"'.$langs->transnoentitiesnoconv(
"AccountingDebit").
'"'.$sep;
507 print
'"'.$langs->transnoentitiesnoconv(
"AccountingCredit").
'"'.$sep;
510 foreach ($taber as $key => $val) {
513 $userstatic->id = $tabuser[$key][
'id'];
514 $userstatic->name = $tabuser[$key][
'name'];
517 foreach ($tabht[$key] as $k => $mt) {
519 $accountingaccount->fetch(
null, $k,
true);
521 print
'"'.$date.
'"'.$sep;
522 print
'"'.$val[
"ref"].
'"'.$sep;
523 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
524 print
'"'.dol_trunc($accountingaccount->label, 32).
'"'.$sep;
525 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
526 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"';
532 foreach ($tabtva[$key] as $k => $mt) {
534 print
'"'.$date.
'"'.$sep;
535 print
'"'.$val[
"ref"].
'"'.$sep;
536 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
537 print
'"'.dol_trunc($langs->trans(
"VAT")).
'"'.$sep;
538 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
539 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"';
545 foreach ($tabttc[$key] as $k => $mt) {
546 print
'"'.$date.
'"'.$sep;
547 print
'"'.$val[
"ref"].
'"'.$sep;
548 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
549 print
'"'.dol_trunc($userstatic->name).
'"'.$sep;
550 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
551 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"';
557 if (empty($action) || $action ==
'view') {
558 $title = $langs->trans(
"GenerationOfAccountingEntries").
' - '.$accountingjournalstatic->getNomUrl(0, 2, 1,
'', 1);
567 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
569 $listofchoices = array(
'notyet'=>$langs->trans(
"NotYetInGeneralLedger"),
'already'=>$langs->trans(
"AlreadyInGeneralLedger"));
570 $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);
571 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
573 $varlink =
'id_journal='.$id_journal;
575 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
580 $sql =
"SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX.
"accounting_fiscalyear WHERE entity = ".((int) $conf->entity);
581 $resql = $db->query(
$sql);
583 $obj = $db->fetch_object($resql);
585 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"TheFiscalPeriodIsNotDefined");
586 $desc =
' : '.$langs->trans(
"AccountancyAreaDescFiscalPeriod", 4,
'{link}');
587 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"FiscalPeriod").
'</strong>', $desc);
598 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
599 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
600 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
604 print
'<br><div class="tabsAction tabsActionNoBottom centerimp">';
606 if (
getDolGlobalString(
'ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL') && $in_bookkeeping ==
'notyet') {
607 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
610 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
612 if ($in_bookkeeping ==
'notyet') {
613 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
615 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
622 <script type="text/javascript">
623 function launch_export() {
624 $("div.fiche form input[name=\"action\"]").val("exportcsv");
625 $("div.fiche form input[type=\"submit\"]").click();
626 $("div.fiche form input[name=\"action\"]").val("");
628 function writebookkeeping() {
629 console.log("click on writebookkeeping");
630 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
631 $("div.fiche form input[type=\"submit\"]").click();
632 $("div.fiche form input[name=\"action\"]").val("");
642 print
'<div class="div-table-responsive">';
643 print
"<table class=\"noborder\" width=\"100%\">";
644 print
"<tr class=\"liste_titre\">";
645 print
"<td>".$langs->trans(
"Date").
"</td>";
646 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"ExpenseReportRef").
")</td>";
647 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
648 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
649 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
650 print
'<td class="right">'.$langs->trans(
"AccountingDebit").
"</td>";
651 print
'<td class="right">'.$langs->trans(
"AccountingCredit").
"</td>";
659 foreach ($taber as $key => $val) {
660 $expensereportstatic->id = $key;
661 $expensereportstatic->ref = $val[
"ref"];
662 $expensereportlinestatic->comments = html_entity_decode(
dol_trunc($val[
"comments"], 32));
666 if ($errorforinvoice[$key] ==
'somelinesarenotbound') {
667 print
'<tr class="oddeven">';
668 print
"<!-- Some lines are not bound -->";
669 print
"<td>".$date.
"</td>";
670 print
"<td>".$expensereportstatic->getNomUrl(1).
"</td>";
673 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $val[
'ref']).
'</span>';
680 print
'<td class="right"></td>';
681 print
'<td class="right"></td>';
688 foreach ($tabht[$key] as $k => $mt) {
690 $accountingaccount->fetch(
null, $k,
true);
693 print
'<tr class="oddeven">';
694 print
"<!-- Fees -->";
695 print
"<td>".$date.
"</td>";
696 print
"<td>".$expensereportstatic->getNomUrl(1).
"</td>";
697 $userstatic->id = $tabuser[$key][
'id'];
698 $userstatic->name = $tabuser[$key][
'name'];
702 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
703 print
'<span class="error">'.$langs->trans(
"FeeAccountNotDefined").
'</span>';
711 $userstatic->id = $tabuser[$key][
'id'];
712 $userstatic->name = $tabuser[$key][
'name'];
713 print
"<td>".$userstatic->getNomUrl(0,
'user', 16).
' - '.$accountingaccount->label.
"</td>";
714 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
715 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
723 foreach ($tabttc[$key] as $k => $mt) {
724 $userstatic->id = $tabuser[$key][
'id'];
725 $userstatic->name = $tabuser[$key][
'name'];
727 print
'<tr class="oddeven">';
728 print
"<!-- Thirdparty -->";
729 print
"<td>".$date.
"</td>";
730 print
"<td>".$expensereportstatic->getNomUrl(1).
"</td>";
734 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
735 print
'<span class="error">'.$langs->trans(
"MainAccountForUsersNotDefined").
'</span>';
743 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
744 print
'<span class="error">'.$langs->trans(
"UserAccountNotDefined").
'</span>';
749 print
"<td>".$userstatic->getNomUrl(0,
'user', 16).
' - '.$langs->trans(
"SubledgerAccount").
"</td>";
750 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
751 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
758 $listoftax = array(0, 1, 2);
759 foreach ($listoftax as $numtax) {
760 $arrayofvat = $tabtva;
762 $arrayofvat = $tablocaltax1;
765 $arrayofvat = $tablocaltax2;
768 foreach ($arrayofvat[$key] as $k => $mt) {
770 print
'<tr class="oddeven">';
771 print
"<!-- VAT -->";
772 print
"<td>".$date.
"</td>";
773 print
"<td>".$expensereportstatic->getNomUrl(1).
"</td>";
777 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
778 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
'</span>';
786 print
"<td>".$userstatic->getNomUrl(0,
'user', 16).
' - '.$langs->trans(
"VAT").
' '.implode(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'');
788 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
789 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
800 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.
if(isModEnabled('invoice') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&!getDolGlobalString('MAIN_USE_NEW_SUPPLIERMOD') && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') && $user->hasRight('tax', 'charges', 'lire')) if(isModEnabled('invoice') &&isModEnabled('order') && $user->hasRight("commande", "lire") &&!getDolGlobalString('WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER')) $sql
Social contributions to pay.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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.