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"));
44 $id_journal =
GETPOST(
'id_journal',
'int');
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';
64 if ($user->socid > 0) {
67 if (empty($user->rights->accounting->mouvements->lire)) {
81 $accountingjournalstatic->fetch($id_journal);
82 $journal = $accountingjournalstatic->code;
83 $journal_label = $accountingjournalstatic->label;
85 $date_start =
dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
86 $date_end =
dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
88 if (empty($date_startmonth) || empty($date_endmonth)) {
91 $date_start = $dates[
'date_start'];
92 $date_end = $dates[
'date_end'];
93 $pastmonthyear = $dates[
'pastmonthyear'];
94 $pastmonth = $dates[
'pastmonth'];
97 if (!
GETPOSTISSET(
'date_startmonth') && (empty($date_start) || empty($date_end))) {
102 $sql =
"SELECT er.rowid, er.ref, er.date_debut as de,";
103 $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, ";
104 $sql .=
" u.rowid as uid, u.firstname, u.lastname, u.accountancy_code as user_accountancy_account,";
105 $sql .=
" f.accountancy_code, aa.rowid as fk_compte, aa.account_number as compte, aa.label as label_compte";
106 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport_det as erd";
107 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_type_fees as f ON f.id = erd.fk_c_type_fees";
108 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
109 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"expensereport as er ON er.rowid = erd.fk_expensereport";
110 $sql .=
" JOIN ".MAIN_DB_PREFIX.
"user as u ON u.rowid = er.fk_user_author";
111 $sql .=
" WHERE er.fk_statut > 0";
112 $sql .=
" AND erd.fk_code_ventilation > 0";
113 $sql .=
" AND er.entity IN (".getEntity(
'expensereport', 0).
")";
114 if ($date_start && $date_end) {
115 $sql .=
" AND er.date_debut >= '".$db->idate($date_start).
"' AND er.date_debut <= '".$db->idate($date_end).
"'";
118 if (!empty($conf->global->ACCOUNTING_DATE_START_BINDING)) {
119 $sql .=
" AND er.date_debut >= '".$db->idate($conf->global->ACCOUNTING_DATE_START_BINDING).
"'";
122 if ($in_bookkeeping ==
'already') {
123 $sql .=
" AND er.rowid IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
125 if ($in_bookkeeping ==
'notyet') {
126 $sql .=
" AND er.rowid NOT IN (SELECT fk_doc FROM ".MAIN_DB_PREFIX.
"accounting_bookkeeping as ab WHERE ab.doc_type='expense_report')";
128 $sql .=
" ORDER BY er.date_debut";
130 dol_syslog(
'accountancy/journal/expensereportsjournal.php', LOG_DEBUG);
131 $result = $db->query($sql);
138 $tablocaltax1 = array();
139 $tablocaltax2 = array();
142 $num = $db->num_rows($result);
145 $account_salary = (!empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT)) ? $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT :
'NotDefined';
146 $account_vat = (!empty($conf->global->ACCOUNTING_VAT_BUY_ACCOUNT)) ? $conf->global->ACCOUNTING_VAT_BUY_ACCOUNT :
'NotDefined';
150 $obj = $db->fetch_object($result);
153 $compta_user = (!empty($obj->user_accountancy_account)) ? $obj->user_accountancy_account : $account_salary;
154 $compta_fees = $obj->compte;
156 $vatdata =
getTaxesFromId($obj->tva_tx.($obj->vat_src_code ?
' ('.$obj->vat_src_code.
')' :
''), $mysoc, $mysoc, 0);
157 $compta_tva = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $account_vat);
158 $compta_localtax1 = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $cpttva);
159 $compta_localtax2 = (!empty($vatdata[
'accountancy_code_buy']) ? $vatdata[
'accountancy_code_buy'] : $cpttva);
162 if (
price2num($obj->tva_tx) || !empty($obj->vat_src_code)) {
163 $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.
')' :
''));
166 $taber[$obj->rowid][
"date"] = $db->jdate($obj->de);
167 $taber[$obj->rowid][
"ref"] = $obj->ref;
168 $taber[$obj->rowid][
"comments"] = $obj->comments;
169 $taber[$obj->rowid][
"fk_expensereportdet"] = $obj->erdid;
172 if (!isset($tabttc[$obj->rowid][$compta_user])) {
173 $tabttc[$obj->rowid][$compta_user] = 0;
175 if (!isset($tabht[$obj->rowid][$compta_fees])) {
176 $tabht[$obj->rowid][$compta_fees] = 0;
178 if (!isset($tabtva[$obj->rowid][$compta_tva])) {
179 $tabtva[$obj->rowid][$compta_tva] = 0;
181 if (!isset($tablocaltax1[$obj->rowid][$compta_localtax1])) {
182 $tablocaltax1[$obj->rowid][$compta_localtax1] = 0;
184 if (!isset($tablocaltax2[$obj->rowid][$compta_localtax2])) {
185 $tablocaltax2[$obj->rowid][$compta_localtax2] = 0;
188 $tabttc[$obj->rowid][$compta_user] += $obj->total_ttc;
189 $tabht[$obj->rowid][$compta_fees] += $obj->total_ht;
190 $tabtva[$obj->rowid][$compta_tva] += $obj->total_tva;
191 $tablocaltax1[$obj->rowid][$compta_localtax1] += $obj->total_localtax1;
192 $tablocaltax2[$obj->rowid][$compta_localtax2] += $obj->total_localtax2;
193 $tabuser[$obj->rowid] = array(
196 'user_accountancy_code' => $obj->user_accountancy_account
206 $sql =
"SELECT fk_expensereport, COUNT(erd.rowid) as nb";
207 $sql .=
" FROM ".MAIN_DB_PREFIX.
"expensereport_det as erd";
208 $sql .=
" WHERE erd.fk_code_ventilation <= 0";
209 $sql .=
" AND erd.total_ttc <> 0";
210 $sql .=
" AND fk_expensereport IN (".$db->sanitize(join(
",", array_keys($taber))).
")";
211 $sql .=
" GROUP BY fk_expensereport";
212 $resql = $db->query($sql);
214 $num = $db->num_rows(
$resql);
217 $obj = $db->fetch_object(
$resql);
219 $errorforinvoice[$obj->fk_expensereport] =
'somelinesarenotbound';
225 if ($action ==
'writebookkeeping' && !$error) {
230 $accountingaccountexpense->fetch(
null, $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT,
true);
232 foreach ($taber as $key => $val) {
241 if ($errorforinvoice[$key] ==
'somelinesarenotbound') {
244 setEventMessages($langs->trans(
'ErrorInvoiceContainsLinesNotYetBounded', $val[
'ref']),
null,
'errors');
248 if (!$errorforline) {
249 foreach ($tabttc[$key] as $k => $mt) {
252 $bookkeeping->doc_date = $val[
"date"];
253 $bookkeeping->doc_ref = $val[
"ref"];
254 $bookkeeping->date_creation = $now;
255 $bookkeeping->doc_type =
'expense_report';
256 $bookkeeping->fk_doc = $key;
257 $bookkeeping->fk_docdet = $val[
"fk_expensereportdet"];
259 $bookkeeping->subledger_account = $tabuser[$key][
'user_accountancy_code'];
260 $bookkeeping->subledger_label = $tabuser[$key][
'name'];
262 $bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
263 $bookkeeping->label_compte = $accountingaccountexpense->label;
265 $bookkeeping->label_operation = $tabuser[$key][
'name'];
266 $bookkeeping->montant = $mt;
267 $bookkeeping->sens = ($mt >= 0) ?
'C' :
'D';
268 $bookkeeping->debit = ($mt <= 0) ? -$mt : 0;
269 $bookkeeping->credit = ($mt > 0) ? $mt : 0;
270 $bookkeeping->code_journal = $journal;
271 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
272 $bookkeeping->fk_user_author = $user->id;
273 $bookkeeping->entity = $conf->entity;
275 $totaldebit += $bookkeeping->debit;
276 $totalcredit += $bookkeeping->credit;
278 $result = $bookkeeping->create($user);
280 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
283 $errorforinvoice[$key] =
'alreadyjournalized';
288 $errorforinvoice[$key] =
'other';
297 if (!$errorforline) {
298 foreach ($tabht[$key] as $k => $mt) {
301 if ($accountingaccount->fetch(
null, $k,
true)) {
303 $bookkeeping->doc_date = $val[
"date"];
304 $bookkeeping->doc_ref = $val[
"ref"];
305 $bookkeeping->date_creation = $now;
306 $bookkeeping->doc_type =
'expense_report';
307 $bookkeeping->fk_doc = $key;
308 $bookkeeping->fk_docdet = $val[
"fk_expensereportdet"];
310 $bookkeeping->subledger_account =
'';
311 $bookkeeping->subledger_label =
'';
313 $bookkeeping->numero_compte = $k;
314 $bookkeeping->label_compte = $accountingaccount->label;
316 $bookkeeping->label_operation = $accountingaccount->label;
317 $bookkeeping->montant = $mt;
318 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
319 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
320 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
321 $bookkeeping->code_journal = $journal;
322 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
323 $bookkeeping->fk_user_author = $user->id;
324 $bookkeeping->entity = $conf->entity;
326 $totaldebit += $bookkeeping->debit;
327 $totalcredit += $bookkeeping->credit;
329 $result = $bookkeeping->create($user);
331 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
334 $errorforinvoice[$key] =
'alreadyjournalized';
339 $errorforinvoice[$key] =
'other';
349 if (!$errorforline) {
350 $listoftax = array(0, 1, 2);
351 foreach ($listoftax as $numtax) {
352 $arrayofvat = $tabtva;
354 $arrayofvat = $tablocaltax1;
357 $arrayofvat = $tablocaltax2;
360 foreach ($arrayofvat[$key] as $k => $mt) {
362 $accountingaccount->fetch(
null, $k,
true);
363 $account_label = $accountingaccount->label;
367 $bookkeeping->doc_date = $val[
"date"];
368 $bookkeeping->doc_ref = $val[
"ref"];
369 $bookkeeping->date_creation = $now;
370 $bookkeeping->doc_type =
'expense_report';
371 $bookkeeping->fk_doc = $key;
372 $bookkeeping->fk_docdet = $val[
"fk_expensereportdet"];
374 $bookkeeping->subledger_account =
'';
375 $bookkeeping->subledger_label =
'';
377 $bookkeeping->numero_compte = $k;
378 $bookkeeping->label_compte = $account_label;
380 $bookkeeping->label_operation = $langs->trans(
"VAT").
' '.join(
', ', $def_tva[$key][$k]).
' %';
381 $bookkeeping->montant = $mt;
382 $bookkeeping->sens = ($mt < 0) ?
'C' :
'D';
383 $bookkeeping->debit = ($mt > 0) ? $mt : 0;
384 $bookkeeping->credit = ($mt <= 0) ? -$mt : 0;
385 $bookkeeping->code_journal = $journal;
386 $bookkeeping->journal_label = $langs->transnoentities($journal_label);
387 $bookkeeping->fk_user_author = $user->id;
388 $bookkeeping->entity = $conf->entity;
390 $totaldebit += $bookkeeping->debit;
391 $totalcredit += $bookkeeping->credit;
393 $result = $bookkeeping->create($user);
395 if ($bookkeeping->error ==
'BookkeepingRecordAlreadyExists') {
398 $errorforinvoice[$key] =
'alreadyjournalized';
403 $errorforinvoice[$key] =
'other';
413 if (!$errorforline && (
price2num($totaldebit,
'MT') !=
price2num($totalcredit,
'MT'))) {
416 $errorforinvoice[$key] =
'amountsnotbalanced';
417 setEventMessages(
'Try to insert a non balanced transaction in book for '.$val[
"ref"].
'. Canceled. Surely a bug.',
null,
'errors');
420 if (!$errorforline) {
426 setEventMessages($langs->trans(
"ErrorTooManyErrorsProcessStopped"),
null,
'errors');
434 if (empty($error) && count($tabpay) > 0) {
436 } elseif (count($tabpay) == $error) {
439 setEventMessages($langs->trans(
"GeneralLedgerSomeRecordWasNotRecorded"),
null,
'warnings');
445 if (count($tabpay) != $error) {
446 $param =
'id_journal='.$id_journal;
447 $param .=
'&date_startday='.$date_startday;
448 $param .=
'&date_startmonth='.$date_startmonth;
449 $param .=
'&date_startyear='.$date_startyear;
450 $param .=
'&date_endday='.$date_endday;
451 $param .=
'&date_endmonth='.$date_endmonth;
452 $param .=
'&date_endyear='.$date_endyear;
453 $param .=
'&in_bookkeeping='.$in_bookkeeping;
455 header(
"Location: ".$_SERVER[
'PHP_SELF'].($param ?
'?'.$param :
''));
467 $userstatic =
new User($db);
470 if ($action ==
'exportcsv' && !$error) {
471 $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
473 $filename =
'journal';
474 $type_export =
'journal';
475 include DOL_DOCUMENT_ROOT.
'/accountancy/tpl/export_journal.tpl.php';
478 print
'"'.$langs->transnoentitiesnoconv(
"Date").
'"'.$sep;
479 print
'"'.$langs->transnoentitiesnoconv(
"Piece").
'"'.$sep;
480 print
'"'.$langs->transnoentitiesnoconv(
"AccountAccounting").
'"'.$sep;
481 print
'"'.$langs->transnoentitiesnoconv(
"LabelOperation").
'"'.$sep;
482 print
'"'.$langs->transnoentitiesnoconv(
"Debit").
'"'.$sep;
483 print
'"'.$langs->transnoentitiesnoconv(
"Credit").
'"'.$sep;
486 foreach ($taber as $key => $val) {
489 $userstatic->id = $tabuser[$key][
'id'];
490 $userstatic->name = $tabuser[$key][
'name'];
493 foreach ($tabht[$key] as $k => $mt) {
495 $accountingaccount->fetch(
null, $k,
true);
497 print
'"'.$date.
'"'.$sep;
498 print
'"'.$val[
"ref"].
'"'.$sep;
499 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
500 print
'"'.dol_trunc($accountingaccount->label, 32).
'"'.$sep;
501 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
502 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"';
507 foreach ($tabtva[$key] as $k => $mt) {
509 print
'"'.$date.
'"'.$sep;
510 print
'"'.$val[
"ref"].
'"'.$sep;
511 print
'"'.length_accountg(html_entity_decode($k)).
'"'.$sep;
512 print
'"'.dol_trunc($langs->trans(
"VAT")).
'"'.$sep;
513 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"'.$sep;
514 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"';
520 foreach ($tabttc[$key] as $k => $mt) {
521 print
'"'.$date.
'"'.$sep;
522 print
'"'.$val[
"ref"].
'"'.$sep;
523 print
'"'.length_accounta(html_entity_decode($k)).
'"'.$sep;
524 print
'"'.dol_trunc($userstatic->name).
'"'.$sep;
525 print
'"'.($mt < 0 ?
price(-$mt) :
'').
'"'.$sep;
526 print
'"'.($mt >= 0 ?
price($mt) :
'').
'"';
532 if (empty($action) || $action ==
'view') {
533 llxHeader(
'', $langs->trans(
"ExpenseReportsJournal"));
535 $nom = $langs->trans(
"ExpenseReportsJournal").
' | '.$accountingjournalstatic->getNomUrl(0, 1, 1,
'', 1);
540 $description = $langs->trans(
"DescJournalOnlyBindedVisible").
'<br>';
542 $listofchoices = array(
'notyet'=>$langs->trans(
"NotYetInGeneralLedger"),
'already'=>$langs->trans(
"AlreadyInGeneralLedger"));
543 $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);
544 $period .=
' - '.$langs->trans(
"JournalizationInLedgerStatus").
' '.
$form->selectarray(
'in_bookkeeping', $listofchoices, $in_bookkeeping, 1);
546 $varlink =
'id_journal='.$id_journal;
548 journalHead($nom, $nomlink, $period, $periodlink, $description, $builddate, $exportlink, array(
'action' =>
''),
'', $varlink);
551 if (empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT ==
'-1') {
552 print
'<br><div class="warning">'.img_warning().
' '.$langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone");
553 $desc =
' : '.$langs->trans(
"AccountancyAreaDescMisc", 4,
'{link}');
554 $desc = str_replace(
'{link}',
'<strong>'.$langs->transnoentitiesnoconv(
"MenuAccountancy").
'-'.$langs->transnoentitiesnoconv(
"Setup").
"-".$langs->transnoentitiesnoconv(
"MenuDefaultAccounts").
'</strong>', $desc);
558 print
'<div class="tabsAction tabsActionNoBottom centerimp">';
560 if (!empty($conf->global->ACCOUNTING_ENABLE_EXPORT_DRAFT_JOURNAL) && $in_bookkeeping ==
'notyet') {
561 print
'<input type="button" class="butAction" name="exportcsv" value="'.$langs->trans(
"ExportDraftJournal").
'" onclick="launch_export();" />';
563 if (empty($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT) || $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT ==
'-1') {
564 print
'<input type="button" class="butActionRefused classfortooltip" title="'.dol_escape_htmltag($langs->trans(
"SomeMandatoryStepsOfSetupWereNotDone")).
'" value="'.$langs->trans(
"WriteBookKeeping").
'" />';
566 if ($in_bookkeeping ==
'notyet') {
567 print
'<input type="button" class="butAction" name="writebookkeeping" value="'.$langs->trans(
"WriteBookKeeping").
'" onclick="writebookkeeping();" />';
569 print
'<a href="#" class="butActionRefused classfortooltip" name="writebookkeeping">'.$langs->trans(
"WriteBookKeeping").
'</a>';
576 <script type="text/javascript">
577 function launch_export() {
578 $("div.fiche form input[name=\"action\"]").val("exportcsv");
579 $("div.fiche form input[type=\"submit\"]").click();
580 $("div.fiche form input[name=\"action\"]").val("");
582 function writebookkeeping() {
583 console.log("click on writebookkeeping");
584 $("div.fiche form input[name=\"action\"]").val("writebookkeeping");
585 $("div.fiche form input[type=\"submit\"]").click();
586 $("div.fiche form input[name=\"action\"]").val("");
596 print
'<div class="div-table-responsive">';
597 print
"<table class=\"noborder\" width=\"100%\">";
598 print
"<tr class=\"liste_titre\">";
599 print
"<td>".$langs->trans(
"Date").
"</td>";
600 print
"<td>".$langs->trans(
"Piece").
' ('.$langs->trans(
"ExpenseReportRef").
")</td>";
601 print
"<td>".$langs->trans(
"AccountAccounting").
"</td>";
602 print
"<td>".$langs->trans(
"SubledgerAccount").
"</td>";
603 print
"<td>".$langs->trans(
"LabelOperation").
"</td>";
604 print
'<td class="center">'.$langs->trans(
"Debit").
"</td>";
605 print
'<td class="center">'.$langs->trans(
"Credit").
"</td>";
613 foreach ($taber as $key => $val) {
614 $expensereportstatic->id = $key;
615 $expensereportstatic->ref = $val[
"ref"];
616 $expensereportlinestatic->comments = html_entity_decode(
dol_trunc($val[
"comments"], 32));
620 if ($errorforinvoice[$key] ==
'somelinesarenotbound') {
621 print
'<tr class="oddeven">';
622 print
"<!-- Some lines are not bound -->";
623 print
"<td>".$date.
"</td>";
624 print
"<td>".$expensereportstatic->getNomUrl(1).
"</td>";
627 print
'<span class="error">'.$langs->trans(
'ErrorInvoiceContainsLinesNotYetBoundedShort', $val[
'ref']).
'</span>';
634 print
'<td class="right"></td>';
635 print
'<td class="right"></td>';
642 foreach ($tabht[$key] as $k => $mt) {
644 $accountingaccount->fetch(
null, $k,
true);
647 print
'<tr class="oddeven">';
648 print
"<!-- Fees -->";
649 print
"<td>".$date.
"</td>";
650 print
"<td>".$expensereportstatic->getNomUrl(1).
"</td>";
651 $userstatic->id = $tabuser[$key][
'id'];
652 $userstatic->name = $tabuser[$key][
'name'];
656 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
657 print
'<span class="error">'.$langs->trans(
"FeeAccountNotDefined").
'</span>';
665 $userstatic->id = $tabuser[$key][
'id'];
666 $userstatic->name = $tabuser[$key][
'name'];
667 print
"<td>".$userstatic->getNomUrl(0,
'user', 16).
' - '.$accountingaccount->label.
"</td>";
668 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
669 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
677 foreach ($tabttc[$key] as $k => $mt) {
678 $userstatic->id = $tabuser[$key][
'id'];
679 $userstatic->name = $tabuser[$key][
'name'];
681 print
'<tr class="oddeven">';
682 print
"<!-- Thirdparty -->";
683 print
"<td>".$date.
"</td>";
684 print
"<td>".$expensereportstatic->getNomUrl(1).
"</td>";
687 $accountoshow =
length_accountg($conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT);
688 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
689 print
'<span class="error">'.$langs->trans(
"MainAccountForUsersNotDefined").
'</span>';
697 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
698 print
'<span class="error">'.$langs->trans(
"UserAccountNotDefined").
'</span>';
703 print
"<td>".$userstatic->getNomUrl(0,
'user', 16).
' - '.$langs->trans(
"SubledgerAccount").
"</td>";
704 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
705 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
712 $listoftax = array(0, 1, 2);
713 foreach ($listoftax as $numtax) {
714 $arrayofvat = $tabtva;
716 $arrayofvat = $tablocaltax1;
719 $arrayofvat = $tablocaltax2;
722 foreach ($arrayofvat[$key] as $k => $mt) {
724 print
'<tr class="oddeven">';
725 print
"<!-- VAT -->";
726 print
"<td>".$date.
"</td>";
727 print
"<td>".$expensereportstatic->getNomUrl(1).
"</td>";
731 if (($accountoshow ==
"") || $accountoshow ==
'NotDefined') {
732 print
'<span class="error">'.$langs->trans(
"VATAccountNotDefined").
'</span>';
740 print
"<td>".$userstatic->getNomUrl(0,
'user', 16).
' - '.$langs->trans(
"VAT").
' '.join(
', ', $def_tva[$key][$k]).
' %'.($numtax ?
' - Localtax '.$numtax :
'');
742 print
'<td class="right nowraponall amount">'.($mt >= 0 ?
price($mt) :
'').
"</td>";
743 print
'<td class="right nowraponall amount">'.($mt < 0 ?
price(-$mt) :
'').
"</td>";
753 print
'<tr class="oddeven"><td colspan="7"><span class="opacitymedium">'.$langs->trans(
"NoRecordFound").
'</span></td></tr>';