dolibarr  16.0.5
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  if (!empty($conf->global->FACTURE_SUPPLIER_DEPOSITS_ARE_JUST_PAYMENTS)) {
208  $description .= $langs->trans("SupplierDepositsAreNotIncluded");
209  }
210  $builddate = dol_now();
211  //$exportlink=$langs->trans("NotYetAvailable");
212 } elseif ($modecompta == "RECETTES-DEPENSES") {
213  $name = $langs->trans("AnnualByAccountInputOutputMode");
214  $calcmode = $langs->trans("CalcModeEngagement");
215  $calcmode .= '<br>('.$langs->trans("SeeReportInDueDebtMode", '<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.(GETPOST("month") > 0 ? '&month='.GETPOST("month") : '').'&modecompta=CREANCES-DETTES">', '</a>').')';
216  if (isModEnabled('accounting')) {
217  $calcmode .= '<br>('.$langs->trans("SeeReportInBookkeepingMode", '<a href="'.$_SERVER["PHP_SELF"].'?year='.$year.'&modecompta=BOOKKEEPING">', '</a>').')';
218  }
219  $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
220  //$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>';
221  $description = $langs->trans("RulesResultInOut");
222  $builddate = dol_now();
223  //$exportlink=$langs->trans("NotYetAvailable");
224 } elseif ($modecompta == "BOOKKEEPING") {
225  $name = $langs->trans("ReportInOut").', '.$langs->trans("ByPersonalizedAccountGroups");
226  $calcmode = $langs->trans("CalcModeBookkeeping");
227  //$calcmode.='<br>('.$langs->trans("SeeReportInDueDebtMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=CREANCES-DETTES">','</a>').')';
228  //$calcmode.='<br>('.$langs->trans("SeeReportInInputOutputMode",'<a href="'.$_SERVER["PHP_SELF"].'?year_start='.$year_start.'&modecompta=RECETTES-DEPENSES">','</a>').')';
229  $period = $form->selectDate($date_start, 'date_start', 0, 0, 0, '', 1, 0).' - '.$form->selectDate($date_end, 'date_end', 0, 0, 0, '', 1, 0);
230  $arraylist = array('no'=>$langs->trans("No"), 'yes'=>$langs->trans("AccountWithNonZeroValues"), 'all'=>$langs->trans("All"));
231  $period .= ' &nbsp; &nbsp; '.$langs->trans("DetailByAccount").' '.$form->selectarray('showaccountdetail', $arraylist, $showaccountdetail, 0);
232  $periodlink = $textprevyear.$textnextyear;
233  $exportlink = '';
234  $description = $langs->trans("RulesResultBookkeepingPersonalized");
235  $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")).')';
236  $builddate = dol_now();
237 }
238 
239 report_header($name, '', $period, $periodlink, $description, $builddate, $exportlink, array('modecompta'=>$modecompta, 'action' => ''), $calcmode);
240 
241 
242 if (isModEnabled('accounting') && $modecompta != 'BOOKKEEPING') {
243  print info_admin($langs->trans("WarningReportNotReliable"), 0, 0, 1);
244 }
245 
246 
247 $moreforfilter = '';
248 
249 print '<div class="div-table-responsive">';
250 print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
251 
252 print '<tr class="liste_titre">';
253 print '<th class="liste_titre">'.$langs->trans("AccountingCategory").'</th>';
254 print '<th class="liste_titre"></th>';
255 print '<th class="liste_titre right">'.$langs->trans("PreviousPeriod").'</th>';
256 print '<th class="liste_titre right">'.$langs->trans("SelectedPeriod").'</th>';
257 foreach ($months as $k => $v) {
258  if (($k + 1) >= $date_startmonth) {
259  print '<th class="liste_titre right width50">'.$langs->trans('MonthShort'.sprintf("%02s", ($k + 1))).'</th>';
260  }
261 }
262 foreach ($months as $k => $v) {
263  if (($k + 1) < $date_startmonth) {
264  print '<th class="liste_titre right width50">'.$langs->trans('MonthShort'.sprintf("%02s", ($k + 1))).'</th>';
265  }
266 }
267 print '</tr>';
268 
269 if ($modecompta == 'CREANCES-DETTES') {
270  //if (! empty($date_start) && ! empty($date_end))
271  // $sql.= " AND f.datef >= '".$db->idate($date_start)."' AND f.datef <= '".$db->idate($date_end)."'";
272 } elseif ($modecompta == "RECETTES-DEPENSES") {
273  //if (! empty($date_start) && ! empty($date_end))
274  // $sql.= " AND p.datep >= '".$db->idate($date_start)."' AND p.datep <= '".$db->idate($date_end)."'";
275 } elseif ($modecompta == "BOOKKEEPING") {
276  // Get array of all report groups that are active
277  $cats = $AccCat->getCats(); // WARNING: Computed groups must be after group they include
278  $unactive_cats = $AccCat->getCats(-1, 0);
279 
280  /*
281  $sql = 'SELECT DISTINCT t.numero_compte as nb FROM '.MAIN_DB_PREFIX.'accounting_bookkeeping as t, '.MAIN_DB_PREFIX.'accounting_account as aa';
282  $sql.= " WHERE t.numero_compte = aa.account_number AND aa.fk_accounting_category = 0";
283  if (! empty($date_start) && ! empty($date_end))
284  $sql.= " AND t.doc_date >= '".$db->idate($date_start)."' AND t.doc_date <= '".$db->idate($date_end)."'";
285  if (! empty($month)) {
286  $sql .= " AND MONTH(t.doc_date) = " . ((int) $month);
287  }
288  $resql = $db->query($sql);
289  if ($resql)
290  {
291  $num_rows = $db->num_rows($resql);
292  if ($num_rows) {
293 
294  print '<div class="warning">Warning: There is '.$num_rows.' accounts in your ledger table that are not set into a reporting group</div>';
295  $i = 0;
296  //while ($i < $num) {
297  // $obj = $db->fetch_object($resql);
298  // $i++;
299  //}
300  }
301  }
302  else dol_print_error($db);
303  */
304 
305  $j = 1;
306  $sommes = array();
307  $totPerAccount = array();
308  if (!is_array($cats) && $cats < 0) {
309  setEventMessages(null, $AccCat->errors, 'errors');
310  } elseif (is_array($cats) && count($cats) > 0) {
311  foreach ($cats as $cat) {
312  // Loop on each group
313  if (!empty($cat['category_type'])) {
314  // category calculed
315  // When we enter here, $sommes was filled by group of accounts
316 
317  $formula = $cat['formula'];
318 
319  print '<tr class="liste_total">';
320 
321  // Year NP
322  print '<td class="liste_total width200">';
323  print dol_escape_htmltag($cat['code']);
324  print '</td><td>';
325  print dol_escape_htmltag($cat['label']);
326  print '</td>';
327 
328  $vars = array();
329 
330  // Unactive categories have a total of 0 to be used in the formula.
331  foreach ($unactive_cats as $un_cat) {
332  $vars[$un_cat['code']] = 0;
333  }
334 
335  // Previous Fiscal year (N-1)
336  foreach ($sommes as $code => $det) {
337  if (is_null($det['NP'])) {
338  $det['NP'] = 0;
339  }
340  $vars[$code] = $det['NP'];
341  }
342 
343  $result = strtr($formula, $vars);
344 
345  //var_dump($result);
346  //$r = $AccCat->calculate($result);
347 
348  $r = dol_eval($result, 1, 1, '1');
349  if (is_nan($r)) {
350  $r = 0;
351  }
352 
353  print '<td class="liste_total right"><span class="amount">'.price($r).'</span></td>';
354 
355  // Year N
356  $code = $cat['code']; // code of categorie ('VTE', 'MAR', ...)
357  $sommes[$code]['NP'] += $r;
358 
359  // Current fiscal year (N)
360  if (is_array($sommes) && !empty($sommes)) {
361  foreach ($sommes as $code => $det) {
362  $vars[$code] = $det['N'];
363  }
364  }
365 
366  $result = strtr($formula, $vars);
367 
368  //$r = $AccCat->calculate($result);
369  $r = dol_eval($result, 1, 1, 1);
370  if (is_nan($r)) {
371  $r = 0;
372  }
373 
374  print '<td class="liste_total right"><span class="amount">'.price($r).'</span></td>';
375  $sommes[$code]['N'] += $r;
376 
377  // Detail by month
378  foreach ($months as $k => $v) {
379  if (($k + 1) >= $date_startmonth) {
380  foreach ($sommes as $code => $det) {
381  $vars[$code] = $det['M'][$k];
382  }
383  $result = strtr($formula, $vars);
384 
385  //$r = $AccCat->calculate($result);
386  $r = dol_eval($result, 1, 1, 1);
387  if (is_nan($r)) {
388  $r = 0;
389  }
390 
391  print '<td class="liste_total right"><span class="amount">'.price($r).'</span></td>';
392  $sommes[$code]['M'][$k] += $r;
393  }
394  }
395  foreach ($months as $k => $v) {
396  if (($k + 1) < $date_startmonth) {
397  foreach ($sommes as $code => $det) {
398  $vars[$code] = $det['M'][$k];
399  }
400  $result = strtr($formula, $vars);
401 
402  //$r = $AccCat->calculate($result);
403  $r = dol_eval($result, 1, 1, 1);
404  if (is_nan($r)) {
405  $r = 0;
406  }
407 
408  print '<td class="liste_total right"><span class="amount">'.price($r).'</span></td>';
409  $sommes[$code]['M'][$k] += $r;
410  }
411  }
412 
413  print "</tr>\n";
414 
415  //var_dump($sommes);
416  } else // normal category
417  {
418  $code = $cat['code']; // Category code we process
419 
420  $totCat = array();
421  $totCat['NP'] = 0;
422  $totCat['N'] = 0;
423  $totCat['M'] = array();
424  foreach ($months as $k => $v) {
425  $totCat['M'][$k] = 0;
426  }
427 
428  // Set $cpts with array of accounts in the category/group
429  $cpts = $AccCat->getCptsCat($cat['rowid']);
430  // 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.
431  if (empty($cpts)) $cpts[] = array();
432 
433 
434  $arrayofaccountforfilter = array();
435  foreach ($cpts as $i => $cpt) {// Loop on each account.
436  if (!empty($cpt['account_number'])) {
437  $arrayofaccountforfilter[] = $cpt['account_number'];
438  }
439  }
440 
441  // N-1
442  if (!empty($arrayofaccountforfilter)) {
443  $return = $AccCat->getSumDebitCredit($arrayofaccountforfilter, $date_start_previous, $date_end_previous, $cat['dc'] ? $cat['dc'] : 0);
444 
445  if ($return < 0) {
446  setEventMessages(null, $AccCat->errors, 'errors');
447  $resultNP = 0;
448  } else {
449  foreach ($cpts as $i => $cpt) { // Loop on each account.
450  $resultNP = empty($AccCat->sdcperaccount[$cpt['account_number']]) ? 0 : $AccCat->sdcperaccount[$cpt['account_number']];
451 
452  $totCat['NP'] += $resultNP;
453  $sommes[$code]['NP'] += $resultNP;
454  $totPerAccount[$cpt['account_number']]['NP'] = $resultNP;
455  }
456  }
457  }
458 
459  // Set value into column N and month M ($totCat)
460  // This make 12 calls for each accountancy account (12 monthes M)
461  foreach ($cpts as $i => $cpt) { // Loop on each account.
462  // We make 1 loop for each account because we may want detail per account.
463  // @todo Optimize to ask a 'group by' account and a filter with account in (..., ...) in request
464 
465  // Each month
466  $resultN = 0;
467  foreach ($months as $k => $v) {
468  $monthtoprocess = $k + 1; // ($k+1) is month 1, 2, ..., 12
469  $yeartoprocess = $start_year;
470  if (($k + 1) < $start_month) {
471  $yeartoprocess++;
472  }
473 
474  //var_dump($monthtoprocess.'_'.$yeartoprocess);
475  $return = $AccCat->getSumDebitCredit($cpt['account_number'], $date_start, $date_end, $cat['dc'] ? $cat['dc'] : 0, 'nofilter', $monthtoprocess, $yeartoprocess);
476  if ($return < 0) {
477  setEventMessages(null, $AccCat->errors, 'errors');
478  $resultM = 0;
479  } else {
480  $resultM = $AccCat->sdc;
481  }
482  $totCat['M'][$k] += $resultM;
483  $sommes[$code]['M'][$k] += $resultM;
484  $totPerAccount[$cpt['account_number']]['M'][$k] = $resultM;
485 
486  $resultN += $resultM;
487  }
488 
489  $totCat['N'] += $resultN;
490  $sommes[$code]['N'] += $resultN;
491  $totPerAccount[$cpt['account_number']]['N'] = $resultN;
492  }
493 
494 
495  // Now output columns for row $code ('VTE', 'MAR', ...)
496 
497  print "<tr>";
498 
499  // Column group
500  print '<td class="width200">';
501  print dol_escape_htmltag($cat['code']);
502  print '</td>';
503 
504  // Label of group
505  print '<td>';
506  print dol_escape_htmltag($cat['label']);
507  if (count($cpts) > 0 && !empty($cpts[0])) { // Show example of 5 first accounting accounts
508  $i = 0;
509  foreach ($cpts as $cpt) {
510  if ($i > 5) {
511  print '...)';
512  break;
513  }
514  if ($i > 0) {
515  print ', ';
516  } else {
517  print ' (';
518  }
519  print dol_escape_htmltag($cpt['account_number']);
520  $i++;
521  }
522  if ($i <= 5) {
523  print ')';
524  }
525  } else {
526  print ' - <span class="warning">'.$langs->trans("GroupIsEmptyCheckSetup").'</span>';
527  }
528  print '</td>';
529 
530  print '<td class="right"><span class="amount">'.price($totCat['NP']).'</span></td>';
531  print '<td class="right"><span class="amount">'.price($totCat['N']).'</span></td>';
532 
533  // Each month
534  foreach ($totCat['M'] as $k => $v) {
535  if (($k + 1) >= $date_startmonth) {
536  print '<td class="right nowraponall"><span class="amount">'.price($v).'</span></td>';
537  }
538  }
539  foreach ($totCat['M'] as $k => $v) {
540  if (($k + 1) < $date_startmonth) {
541  print '<td class="right nowraponall"><span class="amount">'.price($v).'</span></td>';
542  }
543  }
544 
545  print "</tr>\n";
546 
547  // Loop on detail of all accounts to output the detail
548  if ($showaccountdetail != 'no') {
549  foreach ($cpts as $i => $cpt) {
550  $resultNP = $totPerAccount[$cpt['account_number']]['NP'];
551  $resultN = $totPerAccount[$cpt['account_number']]['N'];
552 
553  if ($showaccountdetail == 'all' || $resultN != 0) {
554  print '<tr>';
555  print '<td></td>';
556  print '<td class="tdoverflowmax200">';
557  print ' &nbsp; &nbsp; '.length_accountg($cpt['account_number']);
558  print ' - ';
559  print $cpt['account_label'];
560  print '</td>';
561  print '<td class="right"><span class="amount">'.price($resultNP).'</span></td>';
562  print '<td class="right"><span class="amount">'.price($resultN).'</span></td>';
563 
564  // Make one call for each month
565  foreach ($months as $k => $v) {
566  if (($k + 1) >= $date_startmonth) {
567  $resultM = $totPerAccount[$cpt['account_number']]['M'][$k];
568  print '<td class="right"><span class="amount">'.price($resultM).'</span></td>';
569  }
570  }
571  foreach ($months as $k => $v) {
572  if (($k + 1) < $date_startmonth) {
573  $resultM = $totPerAccount[$cpt['account_number']]['M'][$k];
574  print '<td class="right"><span class="amount">'.price($resultM).'</span></td>';
575  }
576  }
577  print "</tr>\n";
578  }
579  }
580  }
581  }
582  }
583  }
584 }
585 
586 print "</table>";
587 print '</div>';
588 
589 // End of page
590 llxFooter();
591 $db->close();
dol_getdate
dol_getdate($timestamp, $fast=false, $forcetimezone='')
Return an array with locale date info.
Definition: functions.lib.php:2713
dol_escape_htmltag
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.
Definition: functions.lib.php:1468
restrictedArea
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.
Definition: security.lib.php:234
llxFooter
llxFooter()
Empty footer.
Definition: wrapper.php:73
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
AccountancyCategory
Class to manage categories of an accounting account.
Definition: accountancycategory.class.php:32
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
FormAccounting
Class to manage generation of HTML components for accounting management.
Definition: html.formaccounting.class.php:33
img_next
img_next($titlealt='default', $moreatt='')
Show next logo.
Definition: functions.lib.php:4557
dol_get_first_day
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_get_last_day
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
info_admin
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
Definition: functions.lib.php:4800
isModEnabled
isModEnabled($module)
Is Dolibarr module enabled.
Definition: functions.lib.php:105
dol_time_plus_duree
dol_time_plus_duree($time, $duration_value, $duration_unit, $ruleforendofmonth=0)
Add a delay to a date.
Definition: date.lib.php:121
dol_eval
dol_eval($s, $returnvalue=0, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
Definition: functions.lib.php:8611
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
dol_now
dol_now($mode='auto')
Return date for now.
Definition: functions.lib.php:2845
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137
dol_mktime
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...
Definition: functions.lib.php:2757
img_previous
img_previous($titlealt='default', $moreatt='')
Show previous logo.
Definition: functions.lib.php:4576
report_header
report_header($reportname, $notused, $period, $periodlink, $description, $builddate, $exportlink='', $moreparam=array(), $calcmode='', $varlink='')
Show header of a report.
Definition: report.lib.php:41