dolibarr 21.0.0-alpha
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
34// Load translation files required by the page
35$langs->loadLangs(array("compta", "bills", "other", "accountancy"));
36
37$validatemonth = GETPOSTINT('validatemonth');
38$validateyear = GETPOSTINT('validateyear');
39
40$month_start = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
41if (GETPOSTINT("year")) {
42 $year_start = GETPOSTINT("year");
43} else {
44 $year_start = dol_print_date(dol_now(), '%Y');
45 if (dol_print_date(dol_now(), '%m') < $month_start) {
46 $year_start--; // If current month is lower that starting fiscal month, we start last year
47 }
48}
49$year_end = $year_start + 1;
50$month_end = $month_start - 1;
51if ($month_end < 1) {
52 $month_end = 12;
53 $year_end--;
54}
55$search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
56$search_date_end = dol_get_last_day($year_end, $month_end);
57$year_current = $year_start;
58
59// Validate History
60$action = GETPOST('action', 'aZ09');
61
62$chartaccountcode = dol_getIdFromCode($db, getDolGlobalString('CHARTOFACCOUNTS'), 'accounting_system', 'rowid', 'pcg_version');
63
64// Security check
65if (!isModEnabled('accounting')) {
67}
68if ($user->socid > 0) {
70}
71if (!$user->hasRight('accounting', 'bind', 'write')) {
73}
74
75
76/*
77 * Actions
78 */
79
80if (($action == 'clean' || $action == 'validatehistory') && $user->hasRight('accounting', 'bind', 'write')) {
81 // Clean database by removing binding done on non existing or no more existing accounts
82 $db->begin();
83 $sql1 = "UPDATE ".$db->prefix()."expensereport_det as erd";
84 $sql1 .= " SET fk_code_ventilation = 0";
85 $sql1 .= ' WHERE erd.fk_code_ventilation NOT IN';
86 $sql1 .= ' (SELECT accnt.rowid ';
87 $sql1 .= ' FROM '.$db->prefix().'accounting_account as accnt';
88 $sql1 .= ' INNER JOIN '.$db->prefix().'accounting_system as syst';
89 $sql1 .= ' ON accnt.fk_pcg_version = syst.pcg_version AND syst.rowid='.((int) getDolGlobalInt('CHARTOFACCOUNTS')).' AND accnt.entity = '.((int) $conf->entity).')';
90 $sql1 .= ' AND erd.fk_expensereport IN (SELECT rowid FROM '.$db->prefix().'expensereport WHERE entity = '.((int) $conf->entity).')';
91 $sql1 .= " AND fk_code_ventilation <> 0";
92 dol_syslog("htdocs/accountancy/customer/index.php fixaccountancycode", LOG_DEBUG);
93 $resql1 = $db->query($sql1);
94 if (!$resql1) {
95 $error++;
96 $db->rollback();
97 setEventMessages($db->lasterror(), null, 'errors');
98 } else {
99 $db->commit();
100 }
101 // End clean database
102}
103
104if ($action == 'validatehistory' && $user->hasRight('accounting', 'bind', 'write')) {
105 $error = 0;
106 $nbbinddone = 0;
107 $nbbindfailed = 0;
108 $notpossible = 0;
109
110 $db->begin();
111
112 // Now make the binding
113 $sql1 = "SELECT erd.rowid, accnt.rowid as suggestedid";
114 $sql1 .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
115 $sql1 .= " LEFT JOIN ".MAIN_DB_PREFIX."c_type_fees as t ON erd.fk_c_type_fees = t.id";
116 $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).",";
117 $sql1 .= " ".MAIN_DB_PREFIX."expensereport as er";
118 $sql1 .= " WHERE erd.fk_expensereport = er.rowid AND er.entity = ".((int) $conf->entity);
119 $sql1 .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.") AND erd.fk_code_ventilation <= 0";
120 if ($validatemonth && $validateyear) {
121 $sql1 .= dolSqlDateFilter('erd.date', 0, $validatemonth, $validateyear);
122 }
123
124 dol_syslog('htdocs/accountancy/expensereport/index.php');
125
126 $result = $db->query($sql1);
127 if (!$result) {
128 $error++;
129 setEventMessages($db->lasterror(), null, 'errors');
130 } else {
131 $num_lines = $db->num_rows($result);
132
133 $i = 0;
134 while ($i < min($num_lines, 10000)) { // No more than 10000 at once
135 $objp = $db->fetch_object($result);
136
137 $lineid = $objp->rowid;
138 $suggestedid = $objp->suggestedid;
139
140 if ($suggestedid > 0) {
141 $sqlupdate = "UPDATE ".MAIN_DB_PREFIX."expensereport_det";
142 $sqlupdate .= " SET fk_code_ventilation = ".((int) $suggestedid);
143 $sqlupdate .= " WHERE fk_code_ventilation <= 0 AND rowid = ".((int) $lineid);
144
145 $resqlupdate = $db->query($sqlupdate);
146 if (!$resqlupdate) {
147 $error++;
148 setEventMessages($db->lasterror(), null, 'errors');
149 $nbbindfailed++;
150 break;
151 } else {
152 $nbbinddone++;
153 }
154 } else {
155 $notpossible++;
156 $nbbindfailed++;
157 }
158
159 $i++;
160 }
161 if ($num_lines > 10000) {
162 $notpossible += ($num_lines - 10000);
163 }
164 }
165
166 if ($error) {
167 $db->rollback();
168 } else {
169 $db->commit();
170 setEventMessages($langs->trans('AutomaticBindingDone', $nbbinddone, $notpossible), null, ($notpossible ? 'warnings' : 'mesgs'));
171 if ($nbbindfailed) {
172 setEventMessages($langs->trans('DoManualBindingForFailedRecord', $nbbindfailed), null, 'warnings');
173 }
174 }
175}
176
177
178/*
179 * View
180 */
181$help_url = 'EN:Module_Double_Entry_Accounting|FR:Module_Comptabilit&eacute;_en_Partie_Double#Liaisons_comptables';
182
183llxHeader('', $langs->trans("ExpenseReportsVentilation"), $help_url, '', 0, 0, '', '', '', 'mod-accountancy accountancy-expensereport page-list');
184
185$textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current - 1).'">'.img_previous().'</a>';
186$textnextyear = '&nbsp;<a href="'.$_SERVER["PHP_SELF"].'?year='.($year_current + 1).'">'.img_next().'</a>';
187
188
189print load_fiche_titre($langs->trans("ExpenseReportsVentilation")."&nbsp;".$textprevyear."&nbsp;".$langs->trans("Year")."&nbsp;".$year_start."&nbsp;".$textnextyear, '', 'title_accountancy');
190
191print '<span class="opacitymedium">'.$langs->trans("DescVentilExpenseReport").'</span><br>';
192print '<span class="opacitymedium hideonsmartphone">'.$langs->trans("DescVentilExpenseReportMore", $langs->transnoentitiesnoconv("ValidateHistory"), $langs->transnoentitiesnoconv("ToBind")).'<br>';
193print '</span><br>';
194
195
196$y = $year_current;
197
198$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>';
199
200
201print_barre_liste(img_picto('', 'unlink', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesNotBound"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1, 0, $buttonbind);
202//print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesNotBound"), $buttonbind, '');
203
204print '<div class="div-table-responsive-no-min">';
205print '<table class="noborder centpercent">';
206print '<tr class="liste_titre"><td class="minwidth100">'.$langs->trans("Account").'</td>';
207for ($i = 1; $i <= 12; $i++) {
208 $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1;
209 if ($j > 12) {
210 $j -= 12;
211 }
212 $cursormonth = $j;
213 if ($cursormonth > 12) {
214 $cursormonth -= 12;
215 }
216 $cursoryear = ($cursormonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y;
217 $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt');
218
219 print '<td width="60" class="right">';
220 if (!empty($tmp['mday'])) {
221 $param = 'search_date_startday=1&search_date_startmonth='.$cursormonth.'&search_date_startyear='.$cursoryear;
222 $param .= '&search_date_endday='.$tmp['mday'].'&search_date_endmonth='.$tmp['mon'].'&search_date_endyear='.$tmp['year'];
223 $param .= '&search_month='.$tmp['mon'].'&search_year='.$tmp['year'];
224 print '<a href="'.DOL_URL_ROOT.'/accountancy/expensereport/list.php?'.$param.'">';
225 }
226 print $langs->trans('MonthShort'.str_pad((string) $j, 2, '0', STR_PAD_LEFT));
227 if (!empty($tmp['mday'])) {
228 print '</a>';
229 }
230 print '</td>';
231}
232print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
233
234$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,";
235$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
236for ($i = 1; $i <= 12; $i++) {
237 $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1;
238 if ($j > 12) {
239 $j -= 12;
240 }
241 $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).",";
242 $sql .= " SUM(".$db->ifsql("MONTH(er.date_debut) = ".((string) $j), "1", "0").") AS nbmonth".str_pad((string) $j, 2, "0", STR_PAD_LEFT).",";
243}
244$sql .= " SUM(erd.total_ht) as total, COUNT(erd.rowid) as nb";
245$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
246$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
247$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
248$sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'";
249$sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'";
250// Define begin binding date
251if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) {
252 $sql .= " AND er.date_debut >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'";
253}
254$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
255$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
256$sql .= " AND aa.account_number IS NULL";
257$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
258$sql .= ' ORDER BY aa.account_number';
259
260dol_syslog('/accountancy/expensereport/index.php', LOG_DEBUG);
261$resql = $db->query($sql);
262if ($resql) {
263 $num = $db->num_rows($resql);
264
265 while ($row = $db->fetch_row($resql)) {
266 print '<tr class="oddeven">';
267 print '<td>';
268 if ($row[0] == 'tobind') {
269 //print '<span class="opacitymedium">'.$langs->trans("Unknown").'</span>';
270 } else {
271 print length_accountg($row[0]).' - ';
272 }
273 //print '</td>';
274 //print '<td>';
275 if ($row[0] == 'tobind') {
276 $startmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1);
277 if ($startmonth > 12) {
278 $startmonth -= 12;
279 }
280 $startyear = ($startmonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y;
281 $endmonth = getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) + 11;
282 if ($endmonth > 12) {
283 $endmonth -= 12;
284 }
285 $endyear = ($endmonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y;
286 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"));
287 } else {
288 print $row[1];
289 }
290 print '</td>';
291 for ($i = 2; $i <= 13; $i++) {
292 $cursormonth = (getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) + $i - 2);
293 if ($cursormonth > 12) {
294 $cursormonth -= 12;
295 }
296 $cursoryear = ($cursormonth < getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1)) ? $y + 1 : $y;
297 $tmp = dol_getdate(dol_get_last_day($cursoryear, $cursormonth, 'gmt'), false, 'gmt');
298
299 print '<td class="right nowraponall amount" title="'.price($row[2*$i - 2]).' - '.$row[2*$i - 1].' lines">';
300 print price($row[2*$i - 2]);
301 // Add link to make binding
302 if (!empty(price2num($row[2*$i - 2])) || !empty($row[2*$i - 1])) {
303 print '<a href="'.$_SERVER['PHP_SELF'].'?action=validatehistory&year='.$y.'&validatemonth='.((int) $cursormonth).'&validateyear='.((int) $cursoryear).'&token='.newToken().'">';
304 print img_picto($langs->trans("ValidateHistory").' ('.$langs->trans('Month'.str_pad((string) $cursormonth, 2, '0', STR_PAD_LEFT)).' '.$cursoryear.')', 'link', 'class="marginleft2"');
305 print '</a>';
306 }
307 print '</td>';
308 }
309 print '<td class="right nowraponall amount"><b>'.price($row[26]).'</b></td>';
310 print '</tr>';
311 }
312 $db->free($resql);
313
314 if ($num == 0) {
315 print '<tr class="oddeven"><td colspan="15">';
316 print '<span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span>';
317 print '</td></tr>';
318 }
319} else {
320 print $db->lasterror(); // Show last sql error
321}
322print "</table>\n";
323print '</div>';
324
325
326print '<br>';
327
328
329print_barre_liste(img_picto('', 'link', 'class="paddingright fa-color-unset"').$langs->trans("OverviewOfAmountOfLinesBound"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
330//print load_fiche_titre($langs->trans("OverviewOfAmountOfLinesBound"), '', '');
331
332
333print '<div class="div-table-responsive-no-min">';
334print '<table class="noborder centpercent">';
335print '<tr class="liste_titre"><td class="minwidth100">'.$langs->trans("Account").'</td>';
336for ($i = 1; $i <= 12; $i++) {
337 $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1;
338 if ($j > 12) {
339 $j -= 12;
340 }
341 print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad((string) $j, 2, '0', STR_PAD_LEFT)).'</td>';
342}
343print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
344
345$sql = "SELECT ".$db->ifsql('aa.account_number IS NULL', "'tobind'", 'aa.account_number')." AS codecomptable,";
346$sql .= " ".$db->ifsql('aa.label IS NULL', "'tobind'", 'aa.label')." AS intitule,";
347for ($i = 1; $i <= 12; $i++) {
348 $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1;
349 if ($j > 12) {
350 $j -= 12;
351 }
352 $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).",";
353}
354$sql .= " ROUND(SUM(erd.total_ht),2) as total";
355$sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
356$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
357$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as aa ON aa.rowid = erd.fk_code_ventilation";
358$sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'";
359$sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'";
360// Define begin binding date
361if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) {
362 $sql .= " AND er.date_debut >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'";
363}
364$sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
365$sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
366$sql .= " AND aa.account_number IS NOT NULL";
367$sql .= " GROUP BY erd.fk_code_ventilation,aa.account_number,aa.label";
368
369dol_syslog('htdocs/accountancy/expensereport/index.php');
370$resql = $db->query($sql);
371if ($resql) {
372 $num = $db->num_rows($resql);
373
374 while ($row = $db->fetch_row($resql)) {
375 print '<tr class="oddeven">';
376 print '<td class="tdoverflowmax300"'.(empty($row[1]) ? '' : ' title="'.dol_escape_htmltag($row[1]).'"').'>';
377 if ($row[0] == 'tobind') {
378 //print '<span class="opacitymedium">'.$langs->trans("Unknown").'</span>';
379 } else {
380 print length_accountg($row[0]).' - ';
381 }
382 if ($row[0] == 'tobind') {
383 print $langs->trans("UseMenuToSetBindindManualy", DOL_URL_ROOT.'/accountancy/expensereport/list.php?search_year='.((int) $y), $langs->transnoentitiesnoconv("ToBind"));
384 } else {
385 print $row[1];
386 }
387 print '</td>';
388 for ($i = 2; $i <= 13; $i++) {
389 print '<td class="right nowraponall amount">';
390 print price($row[$i]);
391 print '</td>';
392 }
393 print '<td class="right nowraponall amount"><b>'.price($row[14]).'</b></td>';
394 print '</tr>';
395 }
396 $db->free($resql);
397
398 if ($num == 0) {
399 print '<tr class="oddeven"><td colspan="15">';
400 print '<span class="opacitymedium">'.$langs->trans("NoRecordFound").'</span>';
401 print '</td></tr>';
402 }
403} else {
404 print $db->lasterror(); // Show last sql error
405}
406print "</table>\n";
407print '</div>';
408
409
410
411if (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 ?
412 print '<br>';
413 print '<br>';
414
415 print_barre_liste($langs->trans("OtherInfo"), '', '', '', '', '', '', -1, '', '', 0, '', '', 0, 1, 1);
416 //print load_fiche_titre($langs->trans("OtherInfo"), '', '');
417
418 print '<div class="div-table-responsive-no-min">';
419 print '<table class="noborder centpercent">';
420 print '<tr class="liste_titre"><td class="left">'.$langs->trans("Total").'</td>';
421 for ($i = 1; $i <= 12; $i++) {
422 $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1;
423 if ($j > 12) {
424 $j -= 12;
425 }
426 print '<td width="60" class="right">'.$langs->trans('MonthShort'.str_pad((string) $j, 2, '0', STR_PAD_LEFT)).'</td>';
427 }
428 print '<td width="60" class="right"><b>'.$langs->trans("Total").'</b></td></tr>';
429
430 $sql = "SELECT '".$db->escape($langs->trans("TotalExpenseReport"))."' AS label,";
431 for ($i = 1; $i <= 12; $i++) {
432 $j = $i + getDolGlobalInt('SOCIETE_FISCAL_MONTH_START', 1) - 1;
433 if ($j > 12) {
434 $j -= 12;
435 }
436 $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).",";
437 }
438 $sql .= " SUM(erd.total_ht) as total";
439 $sql .= " FROM ".MAIN_DB_PREFIX."expensereport_det as erd";
440 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."expensereport as er ON er.rowid = erd.fk_expensereport";
441 $sql .= " WHERE er.date_debut >= '".$db->idate($search_date_start)."'";
442 $sql .= " AND er.date_debut <= '".$db->idate($search_date_end)."'";
443 // Define begin binding date
444 if (getDolGlobalString('ACCOUNTING_DATE_START_BINDING')) {
445 $sql .= " AND er.date_debut >= '".$db->idate(getDolGlobalString('ACCOUNTING_DATE_START_BINDING'))."'";
446 }
447 $sql .= " AND er.fk_statut IN (".ExpenseReport::STATUS_APPROVED.", ".ExpenseReport::STATUS_CLOSED.")";
448 $sql .= " AND er.entity IN (".getEntity('expensereport', 0).")"; // We don't share object for accountancy
449
450 dol_syslog('htdocs/accountancy/expensereport/index.php');
451 $resql = $db->query($sql);
452 if ($resql) {
453 $num = $db->num_rows($resql);
454
455 while ($row = $db->fetch_row($resql)) {
456 print '<tr><td>'.$row[0].'</td>';
457 for ($i = 1; $i <= 12; $i++) {
458 print '<td class="right nowraponall amount">'.price($row[$i]).'</td>';
459 }
460 print '<td class="right nowraponall amount"><b>'.price($row[13]).'</b></td>';
461 print '</tr>';
462 }
463
464 $db->free($resql);
465 } else {
466 print $db->lasterror(); // Show last sql error
467 }
468 print "</table>\n";
469 print '</div>';
470}
471
472// End of page
473llxFooter();
474$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:70
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:378
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition date.lib.php:615
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.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.