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