dolibarr  x.y.z
result.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2016-2017 Jamal Elbaz <jamelbaz@gmail.com>
3  * Copyright (C) 2016-2022 Alexandre Spangaro <aspangaro@open-dsi.fr>
4  * Copyright (C) 2018-2020 Laurent Destailleur <eldy@destailleur.fr>
5  * Copyright (C) 2018 Frédéric France <frederic.france@netlogic.fr>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
27 // Load Dolibarr environment
28 require '../../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/report.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
33 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancycategory.class.php';
34 
35 // Load translation files required by the page
36 $langs->loadLangs(array('compta', 'bills', 'donation', 'salaries', 'accountancy'));
37 
38 $error = 0;
39 
40 $mesg = '';
41 $action = GETPOST('action', 'aZ09');
42 $cat_id = GETPOST('account_category');
43 $selectcpt = GETPOST('cpt_bk');
44 $id = GETPOST('id', 'int');
45 $rowid = GETPOST('rowid', 'int');
46 $cancel = GETPOST('cancel', 'alpha');
47 $showaccountdetail = GETPOST('showaccountdetail', 'aZ09') ?GETPOST('showaccountdetail', 'aZ09') : 'no';
48 
49 
50 $date_startmonth = GETPOST('date_startmonth', 'int');
51 $date_startday = GETPOST('date_startday', 'int');
52 $date_startyear = GETPOST('date_startyear', 'int');
53 $date_endmonth = GETPOST('date_endmonth', 'int');
54 $date_endday = GETPOST('date_endday', 'int');
55 $date_endyear = GETPOST('date_endyear', 'int');
56 
57 $nbofyear = 1;
58 
59 // Date range
60 $year = GETPOST('year', 'int');
61 if (empty($year)) {
62  $year_current = dol_print_date(dol_now('gmt'), "%Y", 'gmt');
63  $month_current = strftime("%m", dol_now());
64  $year_start = $year_current - ($nbofyear - 1);
65 } else {
66  $year_current = $year;
67  $month_current = strftime("%m", dol_now());
68  $year_start = $year - ($nbofyear - 1);
69 }
70 $date_start = dol_mktime(0, 0, 0, $date_startmonth, $date_startday, $date_startyear);
71 $date_end = dol_mktime(23, 59, 59, $date_endmonth, $date_endday, $date_endyear);
72 
73 // We define date_start and date_end
74 if (empty($date_start) || empty($date_end)) { // We define date_start and date_end
75  $q = GETPOST("q") ?GETPOST("q") : 0;
76  if ($q == 0) {
77  // We define date_start and date_end
78  $year_end = $year_start + ($nbofyear - 1);
79  $month_start = GETPOST("month", 'int') ?GETPOST("month", 'int') : ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
80  $date_startmonth = $month_start;
81  if (!GETPOST('month')) {
82  if (!GETPOST("year") && $month_start > $month_current) {
83  $year_start--;
84  $year_end--;
85  }
86  $month_end = $month_start - 1;
87  if ($month_end < 1) {
88  $month_end = 12;
89  } else {
90  $year_end++;
91  }
92  } else {
93  $month_end = $month_start;
94  }
95  $date_start = dol_get_first_day($year_start, $month_start, false);
96  $date_end = dol_get_last_day($year_end, $month_end, false);
97  }
98  if ($q == 1) {
99  $date_start = dol_get_first_day($year_start, 1, false);
100  $date_end = dol_get_last_day($year_start, 3, false);
101  }
102  if ($q == 2) {
103  $date_start = dol_get_first_day($year_start, 4, false);
104  $date_end = dol_get_last_day($year_start, 6, false);
105  }
106  if ($q == 3) {
107  $date_start = dol_get_first_day($year_start, 7, false);
108  $date_end = dol_get_last_day($year_start, 9, false);
109  }
110  if ($q == 4) {
111  $date_start = dol_get_first_day($year_start, 10, false);
112  $date_end = dol_get_last_day($year_start, 12, false);
113  }
114 }
115 
116 if (($date_start < dol_time_plus_duree($date_end, -1, 'y')) || ($date_start > $date_end)) {
117  $date_end = dol_time_plus_duree($date_start - 1, 1, 'y');
118 }
119 
120 // $date_start and $date_end are defined. We force $start_year and $nbofyear
121 $tmps = dol_getdate($date_start);
122 $start_year = $tmps['year'];
123 $start_month = $tmps['mon'];
124 $tmpe = dol_getdate($date_end);
125 $year_end = $tmpe['year'];
126 $month_end = $tmpe['mon'];
127 $nbofyear = ($year_end - $start_year) + 1;
128 
129 $date_start_previous = dol_time_plus_duree($date_start, -1, 'y');
130 $date_end_previous = dol_time_plus_duree($date_end, -1, 'y');
131 
132 //var_dump($date_start." ".$date_end." ".$date_start_previous." ".$date_end_previous." ".$nbofyear);
133 
134 
135 if ($cat_id == 0) {
136  $cat_id = null;
137 }
138 
139 // Define modecompta ('CREANCES-DETTES' or 'RECETTES-DEPENSES' or 'BOOKKEEPING')
140 $modecompta = $conf->global->ACCOUNTING_MODE;
141 if (isModEnabled('accounting')) {
142  $modecompta = 'BOOKKEEPING';
143 }
144 if (GETPOST("modecompta")) {
145  $modecompta = GETPOST("modecompta", 'alpha');
146 }
147 
148 $AccCat = new AccountancyCategory($db);
149 
150 // Security check
151 $socid = GETPOST('socid', 'int');
152 if ($user->socid > 0) {
153  $socid = $user->socid;
154 }
155 if (isModEnabled('comptabilite')) {
156  $result = restrictedArea($user, 'compta', '', '', 'resultat');
157 }
158 if (isModEnabled('accounting')) {
159  $result = restrictedArea($user, 'accounting', '', '', 'comptarapport');
160 }
161 
162 
163 /*
164  * View
165  */
166 
167 $months = array(
168  $langs->trans("MonthShort01"),
169  $langs->trans("MonthShort02"),
170  $langs->trans("MonthShort03"),
171  $langs->trans("MonthShort04"),
172  $langs->trans("MonthShort05"),
173  $langs->trans("MonthShort06"),
174  $langs->trans("MonthShort07"),
175  $langs->trans("MonthShort08"),
176  $langs->trans("MonthShort09"),
177  $langs->trans("MonthShort10"),
178  $langs->trans("MonthShort11"),
179  $langs->trans("MonthShort12"),
180 );
181 
182 llxheader('', $langs->trans('ReportInOut'));
183 
184 $formaccounting = new FormAccounting($db);
185 $form = new Form($db);
186 
187 $textprevyear = '<a href="'.$_SERVER["PHP_SELF"].'?year='.($start_year - 1).'&showaccountdetail='.urlencode($showaccountdetail).'">'.img_previous().'</a>';
188 $textnextyear = ' &nbsp; <a href="'.$_SERVER["PHP_SELF"].'?year='.($start_year + 1).'&showaccountdetail='.urlencode($showaccountdetail).'">'.img_next().'</a>';
189 
190 
191 
192 // Affiche en-tete de rapport
193 if ($modecompta == "CREANCES-DETTES") {
194  $name = $langs->trans("AnnualByAccountDueDebtMode");
195  $calcmode = $langs->trans("CalcModeDebt");
196  $calcmode .= '<br>('.$langs->trans("SeeReportInInputOutputMode", '<a href="'.$_SERVER["PHP_SELF"].'?year='.$start_year.(GETPOST("month") > 0 ? '&month='.GETPOST("month") : '').'&modecompta=RECETTES-DEPENSES">', '</a>').')';
197  if (isModEnabled('accounting')) {
198  $calcmode .= '<br>('.$langs->trans("SeeReportInBookkeepingMode", '<a href="'.$_SERVER["PHP_SELF"].'?year='.$start_year.'&modecompta=BOOKKEEPING">', '</a>').')';
199  }
200  $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
201  //$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
202  $description = $langs->trans("RulesResultDue");
203  if (!empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) {
204  $description .= $langs->trans("DepositsAreNotIncluded");
205  } else {
206  $description .= $langs->trans("DepositsAreIncluded");
207  }
208  if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
209  $description .= $langs->trans("SupplierDepositsAreNotIncluded");
210  }
211  $builddate = dol_now();
212  //$exportlink=$langs->trans("NotYetAvailable");
213 } elseif ($modecompta == "RECETTES-DEPENSES") {
214  $name = $langs->trans("AnnualByAccountInputOutputMode");
215  $calcmode = $langs->trans("CalcModeEngagement");
216  $calcmode .= '<br>('.$langs->trans("SeeReportInDueDebtMode", '<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.(GETPOST("month") > 0 ? '&month='.GETPOST("month") : '').'&modecompta=CREANCES-DETTES">', '</a>').')';
217  if (isModEnabled('accounting')) {
218  $calcmode .= '<br>('.$langs->trans("SeeReportInBookkeepingMode", '<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&modecompta=BOOKKEEPING">', '</a>').')';
219  }
220  $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
221  //$periodlink='<a href="'.$_SERVER["PHP_SELF"].'?year='.($year-1).'&modecompta='.$modecompta.'">'.img_previous().'</a> <a href="'.$_SERVER["PHP_SELF"].'?year='.($year+1).'&modecompta='.$modecompta.'">'.img_next().'</a>';
222  $description = $langs->trans("RulesResultInOut");
223  $builddate = dol_now();
224  //$exportlink=$langs->trans("NotYetAvailable");
225 } elseif ($modecompta == "BOOKKEEPING") {
226  $name = $langs->trans("ReportInOut").', '.$langs->trans("ByPersonalizedAccountGroups");
227  $calcmode = $langs->trans("CalcModeBookkeeping");
228  //$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
229  //$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
230  $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
231  $arraylist = array('no'=>$langs->trans("No"), 'yes'=>$langs->trans("AccountWithNonZeroValues"), 'all'=>$langs->trans("All"));
232  $period .= ' &nbsp; &nbsp; '.$langs->trans("DetailByAccount").' '.$form->selectarray('showaccountdetail', $arraylist, $showaccountdetail, 0);
233  $periodlink = $textprevyear.$textnextyear;
234  $exportlink = '';
235  $description = $langs->trans("RulesResultBookkeepingPersonalized");
236  $description .= ' ('.$langs->trans("SeePageForSetup", DOL_URL_ROOT.'/accountancy/admin/categories_list.php?search_country_id='.$mysoc->country_id.'&mainmenu=accountancy&leftmenu=accountancy_admin', $langs->transnoentitiesnoconv("Accountancy").' / '.$langs->transnoentitiesnoconv("Setup").' / '.$langs->transnoentitiesnoconv("AccountingCategory")).')';
237  $builddate = dol_now();
238 }
239 
240 report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array('modecompta'=>$modecompta, 'action' => ''), $calcmode);
241 
242 
243 if (isModEnabled('accounting') && $modecompta != 'BOOKKEEPING') {
244  print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1);
245 }
246 
247 
248 $moreforfilter = '';
249 
250 print '<div class="div-table-responsive">';
251 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
252 
253 print '<tr class="liste_titre">';
254 print '<th class="liste_titre">'.$langs->trans("AccountingCategory").'</th>';
255 print '<th class="liste_titre"></th>';
256 print '<th class="liste_titre right">'.$langs->trans("PreviousPeriod").'</th>';
257 print '<th class="liste_titre right">'.$langs->trans("SelectedPeriod").'</th>';
258 foreach ($months as $k => $v) {
259  if (($k + 1) >= $date_startmonth) {
260  print '<th class="liste_titre right width50">'.$langs->trans('MonthShort'.sprintf("%02s", ($k + 1))).'</th>';
261  }
262 }
263 foreach ($months as $k => $v) {
264  if (($k + 1) < $date_startmonth) {
265  print '<th class="liste_titre right width50">'.$langs->trans('MonthShort'.sprintf("%02s", ($k + 1))).'</th>';
266  }
267 }
268 print '</tr>';
269 
270 if ($modecompta == 'CREANCES-DETTES') {
271  //if (!empty($date_start) && !empty($date_end))
272  // $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
273 } elseif ($modecompta == "RECETTES-DEPENSES") {
274  //if (!empty($date_start) && !empty($date_end))
275  // $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
276 } elseif ($modecompta == "BOOKKEEPING") {
277  // Get array of all report groups that are active
278  $cats = $AccCat->getCats(); // WARNING: Computed groups must be after group they include
279  $unactive_cats = $AccCat->getCats(-1, 0);
280 
281  /*
282  $sql = 'SELECT DISTINCT t.numero_compte as nb FROM '.MAIN_DB_PREFIX.'accounting_bookkeeping as t, '.MAIN_DB_PREFIX.'accounting_account as aa';
283  $sql.= " WHERE t.numero_compte = aa.account_number AND aa.fk_accounting_category = 0";
284  if (!empty($date_start) && !empty($date_end))
285  $sql.= " AND t.doc_date >= '".$db->idate($date_start)."' AND t.doc_date <= '".$db->idate($date_end)."'";
286  if (!empty($month)) {
287  $sql .= " AND MONTH(t.doc_date) = " . ((int) $month);
288  }
289  $resql = $db->query($sql);
290  if ($resql)
291  {
292  $num_rows = $db->num_rows($resql);
293  if ($num_rows) {
294 
295  print '<div class="warning">Warning: There is '.$num_rows.' accounts in your ledger table that are not set into a reporting group</div>';
296  $i = 0;
297  //while ($i < $num) {
298  // $obj = $db->fetch_object($resql);
299  // $i++;
300  //}
301  }
302  }
303  else dol_print_error($db);
304  */
305 
306  $j = 1;
307  $sommes = array();
308  $totPerAccount = array();
309  if (!is_array($cats) && $cats < 0) {
310  setEventMessages(null, $AccCat->errors, 'errors');
311  } elseif (is_array($cats) && count($cats) > 0) {
312  // Loop on each custom group of accounts
313  foreach ($cats as $cat) {
314  if (!empty($cat['category_type'])) {
315  // category calculed
316  // When we enter here, $sommes was filled by group of accounts
317 
318  $formula = $cat['formula'];
319 
320  print '<tr class="liste_total">';
321 
322  // Code and Label
323  print '<td class="liste_total tdoverflowmax100" title="'.dol_escape_htmltag($cat['code']).'">';
324  print dol_escape_htmltag($cat['code']);
325  print '</td><td class="tdoverflowmax250 borderright" title="'.dol_escape_htmltag($cat['label']).'">';
326  print dol_escape_htmltag($cat['label']);
327  print '</td>';
328 
329  $vars = array();
330 
331  // Unactive categories have a total of 0 to be used in the formula.
332  foreach ($unactive_cats as $un_cat) {
333  $vars[$un_cat['code']] = 0;
334  }
335 
336  // Previous Fiscal year (N-1)
337  foreach ($sommes as $code => $det) {
338  $vars[$code] = $det['NP'];
339  }
340 
341  $result = strtr($formula, $vars);
342  $result = str_replace('--', '+', $result);
343 
344  if (preg_match('/[a-z]/i', $result)) {
345  $r = 'Error bad formula: '.$result;
346  $rshort = 'Err';
347  print '<td class="liste_total right"><span class="amount" title="'.dol_escape_htmltag($r).'">'.$rshort.'</span></td>';
348  } else {
349  //var_dump($result);
350  //$r = $AccCat->calculate($result);
351  $r = dol_eval($result, 1, 1, '1');
352 
353  print '<td class="liste_total right"><span class="amount">'.price($r).'</span></td>';
354  }
355 
356  // Year N
357  $code = $cat['code']; // code of categorie ('VTE', 'MAR', ...)
358  $sommes[$code]['NP'] += $r;
359 
360  // Current fiscal year (N)
361  if (is_array($sommes) && !empty($sommes)) {
362  foreach ($sommes as $code => $det) {
363  $vars[$code] = $det['N'];
364  }
365  }
366 
367  $result = strtr($formula, $vars);
368  $result = str_replace('--', '+', $result);
369 
370  //$r = $AccCat->calculate($result);
371  $r = dol_eval($result, 1, 1, '1');
372 
373  print '<td class="liste_total right borderright"><span class="amount">'.price($r).'</span></td>';
374  $sommes[$code]['N'] += $r;
375 
376  // Detail by month
377  foreach ($months as $k => $v) {
378  if (($k + 1) >= $date_startmonth) {
379  foreach ($sommes as $code => $det) {
380  $vars[$code] = $det['M'][$k];
381  }
382  $result = strtr($formula, $vars);
383  $result = str_replace('--', '+', $result);
384 
385  //$r = $AccCat->calculate($result);
386  $r = dol_eval($result, 1, 1, '1');
387 
388  print '<td class="liste_total right"><span class="amount">'.price($r).'</span></td>';
389  $sommes[$code]['M'][$k] += $r;
390  }
391  }
392 
393  foreach ($months as $k => $v) {
394  if (($k + 1) < $date_startmonth) {
395  foreach ($sommes as $code => $det) {
396  $vars[$code] = $det['M'][$k];
397  }
398  $result = strtr($formula, $vars);
399  $result = str_replace('--', '+', $result);
400 
401  //$r = $AccCat->calculate($result);
402  $r = dol_eval($result, 1, 1, '1');
403 
404  print '<td class="liste_total right"><span class="amount">'.price($r).'</span></td>';
405  $sommes[$code]['M'][$k] += $r;
406  }
407  }
408 
409  print "</tr>\n";
410 
411  //var_dump($sommes);
412  } else { // normal category
413  $code = $cat['code']; // Category code we process
414 
415  $totCat = array();
416  $totCat['NP'] = 0;
417  $totCat['N'] = 0;
418  $totCat['M'] = array();
419  foreach ($months as $k => $v) {
420  $totCat['M'][$k] = 0;
421  }
422 
423  // Set $cpts with array of accounts in the category/group
424  $cpts = $AccCat->getCptsCat($cat['rowid']);
425  // We should loop over empty $cpts array, else the category _code_ is used in the formula, which leads to wrong result if the code is a number.
426  if (empty($cpts)) {
427  $cpts[] = array();
428  }
429 
430  $arrayofaccountforfilter = array();
431  foreach ($cpts as $i => $cpt) { // Loop on each account.
432  if (!is_null($cpt['account_number'])) {
433  $arrayofaccountforfilter[] = $cpt['account_number'];
434  }
435  }
436 
437  // N-1
438  if (!empty($arrayofaccountforfilter)) {
439  $return = $AccCat->getSumDebitCredit($arrayofaccountforfilter, $date_start_previous, $date_end_previous, $cat['dc'] ? $cat['dc'] : 0);
440  if ($return < 0) {
441  setEventMessages(null, $AccCat->errors, 'errors');
442  $resultNP = 0;
443  } else {
444  foreach ($cpts as $i => $cpt) { // Loop on each account found
445  $resultNP = empty($AccCat->sdcperaccount[$cpt['account_number']]) ? 0 : $AccCat->sdcperaccount[$cpt['account_number']];
446 
447  $totCat['NP'] += $resultNP;
448  $sommes[$code]['NP'] += $resultNP;
449  $totPerAccount[$cpt['account_number']]['NP'] = $resultNP;
450  }
451  }
452  }
453 
454  // Set value into column N and month M ($totCat)
455  // This make 12 calls for each accountancy account (12 monthes M)
456  foreach ($cpts as $i => $cpt) { // Loop on each account.
457  // We make 1 loop for each account because we may want detail per account.
458  // @todo Optimize to ask a 'group by' account and a filter with account in (..., ...) in request
459 
460  // Each month
461  $resultN = 0;
462  foreach ($months as $k => $v) {
463  $monthtoprocess = $k + 1; // ($k+1) is month 1, 2, ..., 12
464  $yeartoprocess = $start_year;
465  if (($k + 1) < $start_month) {
466  $yeartoprocess++;
467  }
468 
469  //var_dump($monthtoprocess.'_'.$yeartoprocess);
470  $return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, $cat['dc'] ? $cat['dc'] : 0, 'nofilter', $monthtoprocess, $yeartoprocess);
471  if ($return < 0) {
472  setEventMessages(null, $AccCat->errors, 'errors');
473  $resultM = 0;
474  } else {
475  $resultM = $AccCat->sdc;
476  }
477  $totCat['M'][$k] += $resultM;
478  $sommes[$code]['M'][$k] += $resultM;
479  $totPerAccount[$cpt['account_number']]['M'][$k] = $resultM;
480 
481  $resultN += $resultM;
482  }
483 
484  $totCat['N'] += $resultN;
485  $sommes[$code]['N'] += $resultN;
486  $totPerAccount[$cpt['account_number']]['N'] = $resultN;
487  }
488 
489 
490  // Now output columns for row $code ('VTE', 'MAR', ...)
491 
492  print '<tr'.($showaccountdetail != 'no' ? ' class="trforbreak"' : '').'>';
493 
494  // Column group
495  print '<td class="tdoverflowmax100" title="'.dol_escape_htmltag($cat['code']).'">';
496  print dol_escape_htmltag($cat['code']);
497  print '</td>';
498 
499  // Label of group
500  $labeltoshow = dol_escape_htmltag($cat['label']);
501  if (count($cpts) > 0 && !empty($cpts[0])) { // Show example of 5 first accounting accounts
502  $i = 0;
503  foreach ($cpts as $cpt) {
504  if ($i > 5) {
505  $labeltoshow .= '...)';
506  break;
507  }
508  if ($i > 0) {
509  $labeltoshow .= ', ';
510  } else {
511  $labeltoshow .= ' (';
512  }
513  $labeltoshow .= dol_escape_htmltag($cpt['account_number']);
514  $i++;
515  }
516  if ($i <= 5) {
517  $labeltoshow .= ')';
518  }
519  } else {
520  $labeltoshow .= ' - <span class="warning">'.$langs->trans("GroupIsEmptyCheckSetup").'</span>';
521  }
522  print '<td class="tdoverflowmax250 borderright" title="'.dol_escape_htmltag(dol_string_nohtmltag($labeltoshow)).'">';
523  print $labeltoshow;
524  print '</td>';
525 
526  print '<td class="right"><span class="amount">'.price($totCat['NP']).'</span></td>';
527  print '<td class="right borderright"><span class="amount">'.price($totCat['N']).'</span></td>';
528 
529  // Each month
530  foreach ($totCat['M'] as $k => $v) {
531  if (($k + 1) >= $date_startmonth) {
532  print '<td class="right nowraponall"><span class="amount">'.price($v).'</span></td>';
533  }
534  }
535  foreach ($totCat['M'] as $k => $v) {
536  if (($k + 1) < $date_startmonth) {
537  print '<td class="right nowraponall"><span class="amount">'.price($v).'</span></td>';
538  }
539  }
540 
541  print "</tr>\n";
542 
543  // Loop on detail of all accounts to output the detail
544  if ($showaccountdetail != 'no') {
545  foreach ($cpts as $i => $cpt) {
546  $resultNP = $totPerAccount[$cpt['account_number']]['NP'];
547  $resultN = $totPerAccount[$cpt['account_number']]['N'];
548 
549  if ($showaccountdetail == 'all' || $resultN != 0) {
550  print '<tr>';
551  print '<td></td>';
552  print '<td class="tdoverflowmax250 borderright">';
553  print ' &nbsp; &nbsp; '.length_accountg($cpt['account_number']);
554  print ' - ';
555  print $cpt['account_label'];
556  print '</td>';
557  print '<td class="right"><span class="amount">'.price($resultNP).'</span></td>';
558  print '<td class="right borderright"><span class="amount">'.price($resultN).'</span></td>';
559 
560  // Make one call for each month
561  foreach ($months as $k => $v) {
562  if (($k + 1) >= $date_startmonth) {
563  $resultM = $totPerAccount[$cpt['account_number']]['M'][$k];
564  print '<td class="right"><span class="amount">'.price($resultM).'</span></td>';
565  }
566  }
567  foreach ($months as $k => $v) {
568  if (($k + 1) < $date_startmonth) {
569  $resultM = $totPerAccount[$cpt['account_number']]['M'][$k];
570  print '<td class="right"><span class="amount">'.price($resultM).'</span></td>';
571  }
572  }
573  print "</tr>\n";
574  }
575  }
576  }
577  }
578  }
579  }
580 }
581 
582 print "</table>";
583 print '</div>';
584 
585 // End of page
586 llxFooter();
587 $db->close();
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage categories of an accounting account.
Class to manage generation of HTML components for accounting management.
Class to manage generation of HTML components Only common components must be here.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:575
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition: date.lib.php:121
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:594
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed informations (by default a local PHP server timestamp) Re...
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto='UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_now($mode='auto')
Return date for now.
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
img_next($titlealt='default', $moreatt='')
Show next logo.
isModEnabled($module)
Is Dolibarr module enabled.
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
Show header of a report.
Definition: report.lib.php:41
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.