dolibarr 21.0.0-beta
index.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
3 * Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
4 * Copyright (C) 2013-2024 Alexandre Spangaro <alexandre@inovea-conseil.com>
5 * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
6 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
28// Load Dolibarr environment
29require '../../main.inc.php';
30require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport.class.php';
33
42// Load translation files required by the page
43$langs->loadLangs(array("compta", "bills", "other", "accountancy"));
44
45$validatemonth = GETPOSTINT('validatemonth');
46$validateyear = GETPOSTINT('validateyear');
47
48$month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
49if (GETPOSTINT("year")) {
50 $year_start = GETPOSTINT("year");
51} else {
52 $year_start = dol_print_date(dol_now(), '%Y');
53 if (dol_print_date(dol_now(), '%m') < $month_start) {
54 $year_start--; // If current month is lower that starting fiscal month, we start last year
55 }
56}
57$year_end = $year_start + 1;
58$month_end = $month_start - 1;
59if ($month_end < 1) {
60 $month_end = 12;
61 $year_end--;
62}
63$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
64$search_date_end = dol_get_last_day($year_end, $month_end);
65$year_current = $year_start;
66
67// Validate History
68$action = GETPOST('action', 'aZ09');
69
70$chartaccountcode = dol_getIdFromCode($db, getDolGlobalString('CHARTOFACCOUNTS'), 'accounting_system', 'rowid', 'pcg_version');
71
72// Security check
73if (!isModEnabled('accounting')) {
75}
76if ($user->socid > 0) {
78}
79if (!$user->hasRight('accounting', 'bind', 'write')) {
81}
82
83
84/*
85 * Actions
86 */
87$error = 0;
88
89if (($action == 'clean' || $action == 'validatehistory') && $user->hasRight('accounting', 'bind', 'write')) {
90 // Clean database by removing binding done on non existing or no more existing accounts
91 $db->begin();
92 $sql1 = "UPDATE ".$db->prefix()."expensereport_det as erd";
93 $sql1 .= " SET fk_code_ventilation = 0";
94 $sql1 .= ' WHERE erd.fk_code_ventilation NOT IN';
95 $sql1 .= ' (SELECT accnt.rowid ';
96 $sql1 .= ' FROM '.$db->prefix().'accounting_account as accnt';
97 $sql1 .= ' INNER JOIN '.$db->prefix().'accounting_system as syst';
98 $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.((int) getDolGlobalInt('CHARTOFACCOUNTS')).' AND accnt.entity = '.((int) $conf->entity).')';
99 $sql1 .= ' AND erd.fk_expensereport IN (SELECT rowid FROM '.$db->prefix().'expensereport WHERE entity = '.((int) $conf->entity).')';
100 $sql1 .= " AND fk_code_ventilation <> 0";
101 dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
102 $resql1 = $db->query($sql1);
103 if (!$resql1) {
104 $error++;
105 $db->rollback();
106 setEventMessages($db->lasterror(), null, 'errors');
107 } else {
108 $db->commit();
109 }
110 // End clean database
111}
112
113if ($action == 'validatehistory' && $user->hasRight('accounting', 'bind', 'write')) {
114 $nbbinddone = 0;
115 $nbbindfailed = 0;
116 $notpossible = 0;
117
118 $db->begin();
119
120 // Now make the binding
121 $sql1 = "SELECT erd.rowid, accnt.rowid as suggestedid";
122 $sql1 .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
123 $sql1 .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as t ON erd.fk_c_type_fees = t.id";
124 $sql1 .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as accnt ON t.accountancy_code = accnt.account_number AND accnt.active = 1 AND accnt.fk_pcg_version = '".$db->escape($chartaccountcode)."' AND accnt.entity =".((int) $conf->entity).",";
125 $sql1 .= " ".MAIN_DB_PREFIX."expensereport as er";
126 $sql1 .= " WHERE erd.fk_expensereport = er.rowid AND er.entity = ".((int) $conf->entity);
127 $sql1 .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0";
128 if ($validatemonth && $validateyear) {
129 $sql1 .= dolSqlDateFilter('erd.date', 0, $validatemonth, $validateyear);
130 }
131
132 dol_syslog('htdocs/accountancy/expensereport/index.php');
133
134 $result = $db->query($sql1);
135 if (!$result) {
136 $error++;
137 setEventMessages($db->lasterror(), null, 'errors');
138 } else {
139 $num_lines = $db->num_rows($result);
140
141 $i = 0;
142 while ($i < min($num_lines, 10000)) { // No more than 10000 at once
143 $objp = $db->fetch_object($result);
144
145 $lineid = $objp->rowid;
146 $suggestedid = $objp->suggestedid;
147
148 if ($suggestedid > 0) {
149 $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."expensereport_det";
150 $sqlupdate .= " SET fk_code_ventilation = ".((int) $suggestedid);
151 $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND rowid = ".((int) $lineid);
152
153 $resqlupdate = $db->query($sqlupdate);
154 if (!$resqlupdate) {
155 $error++;
156 setEventMessages($db->lasterror(), null, 'errors');
157 $nbbindfailed++;
158 break;
159 } else {
160 $nbbinddone++;
161 }
162 } else {
163 $notpossible++;
164 $nbbindfailed++;
165 }
166
167 $i++;
168 }
169 if ($num_lines > 10000) {
170 $notpossible += ($num_lines - 10000);
171 }
172 }
173
174 if ($error) {
175 $db->rollback();
176 } else {
177 $db->commit();
178 setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, ($notpossible ? 'warnings' : 'mesgs'));
179 if ($nbbindfailed) {
180 setEventMessages($langs->trans('DoManualBindingForFailedRecord', $nbbindfailed), null, 'warnings');
181 }
182 }
183}
184
185
186/*
187 * View
188 */
189$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#Liaisons_comptables';
190
191llxHeader('', $langs->trans("ExpenseReportsVentilation"), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-expensereport page-list');
192
193$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
194$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
195
196
197print load_fiche_titre($langs->trans("ExpenseReportsVentilation")."&nbsp;".$textprevyear."&nbsp;".$langs->trans("Year")."&nbsp;".$year_start."&nbsp;".$textnextyear, '', 'title_accountancy');
198
199print '<span class="opacitymedium">'.$langs->trans("DescVentilExpenseReport").'</span><br>';
200print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")).'<br>';
201print '</span><br>';
202
203
204$y = $year_current;
205
206$buttonbind = '<a class="button small" href="'.$_SERVER['PHP_SELF'].'?action=validatehistory&token='.newToken().'&year='.$year_current.'">'.img_picto($langs->trans("ValidateHistory"), 'link', 'class="pictofixedwidth fa-color-unset"').$langs->trans("ValidateHistory").'</a>';
207
208
209print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), 0, '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1, 0, $buttonbind);
210//print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
211
212print '<div class="div-table-responsive-no-min">';
213print '<table class="noborder centpercent">';
214print '<tr class="liste_titre"><td class="minwidth100">'.$langs->trans("Account").'</td>';
215for ($i = 1; $i <= 12; $i++) {
216 $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1;
217 if ($j > 12) {
218 $j -= 12;
219 }
220 $cursormonth = $j;
221 if ($cursormonth > 12) {
222 $cursormonth -= 12;
223 }
224 $cursoryear = ($cursormonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y;
225 $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt');
226
227 print '<td width="60" class="right">';
228 if (!empty($tmp['mday'])) {
229 $param = 'search_date_startday=1&search_date_startmonth='.$cursormonth.'&search_date_startyear='.$cursoryear;
230 $param .= '&search_date_endday='.$tmp['mday'].'&search_date_endmonth='.$tmp['mon'].'&search_date_endyear='.$tmp['year'];
231 $param .= '&search_month='.$tmp['mon'].'&search_year='.$tmp['year'];
232 print '<a href="'.DOL_URL_ROOT.'/accountancy/expensereport/list.php?'.$param.'">';
233 }
234 print $langs->trans('MonthShort'.str_pad((string) $j, 2, '0', STR_PAD_LEFT));
235 if (!empty($tmp['mday'])) {
236 print '</a>';
237 }
238 print '</td>';
239}
240print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
241
242$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,";
243$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
244for ($i = 1; $i <= 12; $i++) {
245 $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1;
246 if ($j > 12) {
247 $j -= 12;
248 }
249 $sql .= " SUM(".$db->ifsql("MONTH(er.date_debut) = ".((int) $j), "erd.total_ht", "0").") AS month".str_pad((string) $j, 2, "0", STR_PAD_LEFT).",";
250 $sql .= " SUM(".$db->ifsql("MONTH(er.date_debut) = ".((string) $j), "1", "0").") AS nbmonth".str_pad((string) $j, 2, "0", STR_PAD_LEFT).",";
251}
252$sql .= " SUM(erd.total_ht) as total, COUNT(erd.rowid) as nb";
253$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
254$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
255$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
256$sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'";
257$sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'";
258// Define begin binding date
259if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) {
260 $sql .= " AND er.date_debut >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'";
261}
262$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
263$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
264$sql .= " AND aa.account_number IS NULL";
265$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
266$sql .= ' ORDER BY aa.account_number';
267
268dol_syslog('/accountancy/expensereport/index.php', LOG_DEBUG);
269$resql = $db->query($sql);
270if ($resql) {
271 $num = $db->num_rows($resql);
272
273 while ($row = $db->fetch_row($resql)) {
274 print '<tr class="oddeven">';
275 print '<td>';
276 if ($row[0] == 'tobind') {
277 //print '<span class="opacitymedium">'.$langs->trans("Unknown").'</span>';
278 } else {
279 print length_accountg($row[0]).' - ';
280 }
281 //print '</td>';
282 //print '<td>';
283 if ($row[0] == 'tobind') {
284 $startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
285 if ($startmonth > 12) {
286 $startmonth -= 12;
287 }
288 $startyear = ($startmonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y;
289 $endmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) + 11;
290 if ($endmonth > 12) {
291 $endmonth -= 12;
292 }
293 $endyear = ($endmonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y;
294 print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_date_startday=1&search_date_startmonth='.((int) $startmonth).'&search_date_startyear='.((int) $startyear).'&search_date_endday=&search_date_endmonth='.((int) $endmonth).'&search_date_endyear='.((int) $endyear), $langs->transnoentitiesnoconv("ToBind"));
295 } else {
296 print $row[1];
297 }
298 print '</td>';
299 for ($i = 2; $i <= 13; $i++) {
300 $cursormonth = (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) + $i - 2);
301 if ($cursormonth > 12) {
302 $cursormonth -= 12;
303 }
304 $cursoryear = ($cursormonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y;
305 $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt');
306
307 print '<td class="right nowraponall amount" title="'.price($row[2*$i - 2]).' - '.$row[2*$i - 1].' lines">';
308 print price($row[2*$i - 2]);
309 // Add link to make binding
310 if (!empty(price2num($row[2*$i - 2])) || !empty($row[2*$i - 1])) {
311 print '<a href="'.$_SERVER['PHP_SELF'].'?action=validatehistory&year='.$y.'&validatemonth='.((int) $cursormonth).'&validateyear='.((int) $cursoryear).'&token='.newToken().'">';
312 print img_picto($langs->trans("ValidateHistory").' ('.$langs->trans('Month'.str_pad((string) $cursormonth, 2, '0', STR_PAD_LEFT)).' '.$cursoryear.')', 'link', 'class="marginleft2"');
313 print '</a>';
314 }
315 print '</td>';
316 }
317 print '<td class="right nowraponall amount"><b>'.price($row[26]).'</b></td>';
318 print '</tr>';
319 }
320 $db->free($resql);
321
322 if ($num == 0) {
323 print '<tr class="oddeven"><td colspan="15">';
324 print '<span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span>';
325 print '</td></tr>';
326 }
327} else {
328 print $db->lasterror(); // Show last sql error
329}
330print "</table>\n";
331print '</div>';
332
333
334print '<br>';
335
336
337print_barre_liste(img_picto('', 'link', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesBound"), 0, '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
338//print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', '');
339
340
341print '<div class="div-table-responsive-no-min">';
342print '<table class="noborder centpercent">';
343print '<tr class="liste_titre"><td class="minwidth100">'.$langs->trans("Account").'</td>';
344for ($i = 1; $i <= 12; $i++) {
345 $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1;
346 if ($j > 12) {
347 $j -= 12;
348 }
349 print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad((string) $j, 2, '0', STR_PAD_LEFT)).'</td>';
350}
351print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
352
353$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,";
354$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
355for ($i = 1; $i <= 12; $i++) {
356 $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1;
357 if ($j > 12) {
358 $j -= 12;
359 }
360 $sql .= " SUM(".$db->ifsql("MONTH(er.date_debut) = ".((int) $j), "erd.total_ht", "0").") AS month".str_pad((string) $j, 2, "0", STR_PAD_LEFT).",";
361}
362$sql .= " ROUND(SUM(erd.total_ht),2) as total";
363$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
364$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
365$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
366$sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'";
367$sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'";
368// Define begin binding date
369if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) {
370 $sql .= " AND er.date_debut >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'";
371}
372$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
373$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
374$sql .= " AND aa.account_number IS NOT NULL";
375$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
376
377dol_syslog('htdocs/accountancy/expensereport/index.php');
378$resql = $db->query($sql);
379if ($resql) {
380 $num = $db->num_rows($resql);
381
382 while ($row = $db->fetch_row($resql)) {
383 print '<tr class="oddeven">';
384 print '<td class="tdoverflowmax300"'.(empty($row[1]) ? '' : ' title="'.dol_escape_htmltag($row[1]).'"').'>';
385 if ($row[0] == 'tobind') {
386 //print '<span class="opacitymedium">'.$langs->trans("Unknown").'</span>';
387 } else {
388 print length_accountg($row[0]).' - ';
389 }
390 if ($row[0] == 'tobind') {
391 print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.((int) $y), $langs->transnoentitiesnoconv("ToBind"));
392 } else {
393 print $row[1];
394 }
395 print '</td>';
396 for ($i = 2; $i <= 13; $i++) {
397 print '<td class="right nowraponall amount">';
398 print price($row[$i]);
399 print '</td>';
400 }
401 print '<td class="right nowraponall amount"><b>'.price($row[14]).'</b></td>';
402 print '</tr>';
403 }
404 $db->free($resql);
405
406 if ($num == 0) {
407 print '<tr class="oddeven"><td colspan="15">';
408 print '<span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span>';
409 print '</td></tr>';
410 }
411} else {
412 print $db->lasterror(); // Show last sql error
413}
414print "</table>\n";
415print '</div>';
416
417
418
419if (getDolGlobalString('SHOW_TOTAL_OF_PREVIOUS_LISTS_IN_LIN_PAGE')) { // This part of code looks strange. Why showing a report that should rely on result of this step ?
420 print '<br>';
421 print '<br>';
422
423 print_barre_liste($langs->trans("OtherInfo"), 0, '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
424 //print load_fiche_titre($langs->trans("OtherInfo"), '', '');
425
426 print '<div class="div-table-responsive-no-min">';
427 print '<table class="noborder centpercent">';
428 print '<tr class="liste_titre"><td class="left">'.$langs->trans("Total").'</td>';
429 for ($i = 1; $i <= 12; $i++) {
430 $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1;
431 if ($j > 12) {
432 $j -= 12;
433 }
434 print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad((string) $j, 2, '0', STR_PAD_LEFT)).'</td>';
435 }
436 print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
437
438 $sql = "SELECT '".$db->escape($langs->trans("TotalExpenseReport"))."' AS label,";
439 for ($i = 1; $i <= 12; $i++) {
440 $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1;
441 if ($j > 12) {
442 $j -= 12;
443 }
444 $sql .= " SUM(".$db->ifsql("MONTH(er.date_create) = ".((int) $j), "erd.total_ht", "0").") AS month".str_pad((string) $j, 2, "0", STR_PAD_LEFT).",";
445 }
446 $sql .= " SUM(erd.total_ht) as total";
447 $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
448 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
449 $sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'";
450 $sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'";
451 // Define begin binding date
452 if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) {
453 $sql .= " AND er.date_debut >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'";
454 }
455 $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
456 $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
457
458 dol_syslog('htdocs/accountancy/expensereport/index.php');
459 $resql = $db->query($sql);
460 if ($resql) {
461 $num = $db->num_rows($resql);
462
463 while ($row = $db->fetch_row($resql)) {
464 print '<tr><td>'.$row[0].'</td>';
465 for ($i = 1; $i <= 12; $i++) {
466 print '<td class="right nowraponall amount">'.price($row[$i]).'</td>';
467 }
468 print '<td class="right nowraponall amount"><b>'.price($row[13]).'</b></td>';
469 print '</tr>';
470 }
471
472 $db->free($resql);
473 } else {
474 print $db->lasterror(); // Show last sql error
475 }
476 print "</table>\n";
477 print '</div>';
478}
479
480// End of page
481llxFooter();
482$db->close();
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous)
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:71
const STATUS_CLOSED
Classified paid.
dolSqlDateFilter($datefield, $day_date, $month_date, $year_date, $excludefirstand=0, $gm=false)
Generate a SQL string to make a filter into a range (for second of date until last second of date).
Definition date.lib.php:382
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition date.lib.php:619
llxFooter()
Footer empty.
Definition document.php:107
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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
print_barre_liste($title, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $selectlimitsuffix=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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_getIdFromCode($db, $key, $tablename, $fieldkey='code', $fieldid='id', $entityfilter=0, $filters='')
Return an id or code from a code or id.
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).
newToken()
Return the value of token currently saved into session with name 'newtoken'.
img_previous($titlealt='default', $moreatt='')
Show previous logo.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_next($titlealt='default', $moreatt='')
Show next logo.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
Definition member.php:79
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.