dolibarr  17.0.4
balance.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2016 Olivier Geffroy <jeff@jeffinfo.com>
3  * Copyright (C) 2016 Florian Henry <florian.henry@open-concept.pro>
4  * Copyright (C) 2016-2022 Alexandre Spangaro <aspangaro@open-dsi.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 
30 // Class
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
33 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/bookkeeping.class.php';
34 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
35 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
36 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountancyexport.class.php';
37 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
38 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
39 
40 // Load translation files required by the page
41 $langs->loadLangs(array("accountancy", "compta"));
42 
43 $action = GETPOST('action', 'aZ09');
44 $optioncss = GETPOST('optioncss', 'alpha');
45 $contextpage = GETPOST('contextpage', 'aZ09');
46 
47 // Load variable for pagination
48 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
49 $sortfield = GETPOST('sortfield', 'aZ09comma');
50 $sortorder = GETPOST('sortorder', 'aZ09comma');
51 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
52 if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
53  $page = 0;
54 } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
55 $offset = $limit * $page;
56 $pageprev = $page - 1;
57 $pagenext = $page + 1;
58 //if (! $sortfield) $sortfield="p.date_fin";
59 //if (! $sortorder) $sortorder="DESC";
60 
61 $show_subgroup = GETPOST('show_subgroup', 'alpha');
62 $search_date_start = dol_mktime(0, 0, 0, GETPOST('date_startmonth', 'int'), GETPOST('date_startday', 'int'), GETPOST('date_startyear', 'int'));
63 $search_date_end = dol_mktime(23, 59, 59, GETPOST('date_endmonth', 'int'), GETPOST('date_endday', 'int'), GETPOST('date_endyear', 'int'));
64 $search_ledger_code = GETPOST('search_ledger_code', 'array');
65 $search_accountancy_code_start = GETPOST('search_accountancy_code_start', 'alpha');
66 if ($search_accountancy_code_start == - 1) {
67  $search_accountancy_code_start = '';
68 }
69 $search_accountancy_code_end = GETPOST('search_accountancy_code_end', 'alpha');
70 if ($search_accountancy_code_end == - 1) {
71  $search_accountancy_code_end = '';
72 }
73 
74 // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
75 $object = new BookKeeping($db);
76 $hookmanager->initHooks(array('balancelist')); // Note that conf->hooks_modules contains array
77 
78 $formaccounting = new FormAccounting($db);
79 $formother = new FormOther($db);
80 $form = new Form($db);
81 
82 if (empty($search_date_start) && !GETPOSTISSET('formfilteraction')) {
83  $sql = "SELECT date_start, date_end from ".MAIN_DB_PREFIX."accounting_fiscalyear ";
84  $sql .= " WHERE date_start < '".$db->idate(dol_now())."' AND date_end > '".$db->idate(dol_now())."'";
85  $sql .= $db->plimit(1);
86  $res = $db->query($sql);
87  if ($res->num_rows > 0) {
88  $fiscalYear = $db->fetch_object($res);
89  $search_date_start = strtotime($fiscalYear->date_start);
90  $search_date_end = strtotime($fiscalYear->date_end);
91  } else {
92  $month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
93  $year_start = dol_print_date(dol_now(), '%Y');
94  if (dol_print_date(dol_now(), '%m') < $month_start) {
95  $year_start--; // If current month is lower that starting fiscal month, we start last year
96  }
97  $year_end = $year_start + 1;
98  $month_end = $month_start - 1;
99  if ($month_end < 1) {
100  $month_end = 12;
101  $year_end--;
102  }
103  $search_date_start = dol_mktime(0, 0, 0, $month_start, 1, $year_start);
104  $search_date_end = dol_get_last_day($year_end, $month_end);
105  }
106 }
107 if ($sortorder == "") {
108  $sortorder = "ASC";
109 }
110 if ($sortfield == "") {
111  $sortfield = "t.numero_compte";
112 }
113 
114 
115 $param = '';
116 if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
117  $param .= '&contextpage='.urlencode($contextpage);
118 }
119 if ($limit > 0 && $limit != $conf->liste_limit) {
120  $param .= '&limit='.urlencode($limit);
121 }
122 
123 $filter = array();
124 if (!empty($search_date_start)) {
125  $filter['t.doc_date>='] = $search_date_start;
126  $param .= '&date_startmonth='.GETPOST('date_startmonth', 'int').'&date_startday='.GETPOST('date_startday', 'int').'&date_startyear='.GETPOST('date_startyear', 'int');
127 }
128 if (!empty($search_date_end)) {
129  $filter['t.doc_date<='] = $search_date_end;
130  $param .= '&date_endmonth='.GETPOST('date_endmonth', 'int').'&date_endday='.GETPOST('date_endday', 'int').'&date_endyear='.GETPOST('date_endyear', 'int');
131 }
132 if (!empty($search_accountancy_code_start)) {
133  $filter['t.numero_compte>='] = $search_accountancy_code_start;
134  $param .= '&search_accountancy_code_start='.urlencode($search_accountancy_code_start);
135 }
136 if (!empty($search_accountancy_code_end)) {
137  $filter['t.numero_compte<='] = $search_accountancy_code_end;
138  $param .= '&search_accountancy_code_end='.urlencode($search_accountancy_code_end);
139 }
140 if (!empty($search_ledger_code)) {
141  $filter['t.code_journal'] = $search_ledger_code;
142  foreach ($search_ledger_code as $code) {
143  $param .= '&search_ledger_code[]='.urlencode($code);
144  }
145 }
146 
147 if (!isModEnabled('accounting')) {
148  accessforbidden();
149 }
150 if ($user->socid > 0) {
151  accessforbidden();
152 }
153 if (!$user->hasRight('accounting', 'mouvements', 'lire')) {
154  accessforbidden();
155 }
156 
157 
158 
159 /*
160  * Action
161  */
162 
163 $parameters = array();
164 $arrayfields = array();
165 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
166 if ($reshook < 0) {
167  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
168 }
169 
170 if (empty($reshook)) {
171  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All tests are required to be compatible with all browsers
172  $show_subgroup = '';
173  $search_date_start = '';
174  $search_date_end = '';
175  $search_accountancy_code_start = '';
176  $search_accountancy_code_end = '';
177  $search_ledger_code = array();
178  $filter = array();
179  }
180 }
181 
182 /*
183  * View
184  */
185 
186 if ($action == 'export_csv') {
187  $sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
188 
189  $filename = 'balance';
190  $type_export = 'balance';
191  include DOL_DOCUMENT_ROOT.'/accountancy/tpl/export_journal.tpl.php';
192 
193  $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, 0, $filter);
194  if ($result < 0) {
195  setEventMessages($object->error, $object->errors, 'errors');
196  }
197 
198  foreach ($object->lines as $line) {
199  print '"'.length_accountg($line->numero_compte).'"'.$sep;
200  print '"'.$object->get_compte_desc($line->numero_compte).'"'.$sep;
201  print '"'.price($line->debit).'"'.$sep;
202  print '"'.price($line->credit).'"'.$sep;
203  print '"'.price($line->debit - $line->credit).'"'.$sep;
204  print "\n";
205  }
206 
207  exit;
208 }
209 
210 
211 $title_page = $langs->trans("AccountBalance");
212 
213 llxHeader('', $title_page);
214 
215 
216 if ($action != 'export_csv') {
217  // List
218  $nbtotalofrecords = '';
219  if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
220  $nbtotalofrecords = $object->fetchAllBalance($sortorder, $sortfield, 0, 0, $filter);
221  if ($nbtotalofrecords < 0) {
222  setEventMessages($object->error, $object->errors, 'errors');
223  }
224  }
225 
226  $result = $object->fetchAllBalance($sortorder, $sortfield, $limit, $offset, $filter);
227  if ($result < 0) {
228  setEventMessages($object->error, $object->errors, 'errors');
229  }
230 
231  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
232  if ($optioncss != '') {
233  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
234  }
235  print '<input type="hidden" name="token" value="'.newToken().'">';
236  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
237  print '<input type="hidden" name="action" id="action" value="list">';
238  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
239  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
240  print '<input type="hidden" name="page" value="'.$page.'">';
241 
242 
243  $parameters = array();
244  $reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
245  if ($reshook < 0) {
246  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
247  }
248 
249  $button = empty($hookmanager->resPrint) ? '' : $hookmanager->resPrint;
250 
251  if (empty($reshook)) {
252  $button .= '<input type="button" id="exportcsvbutton" name="exportcsvbutton" class="butAction" value="'.$langs->trans("Export").' ('.$conf->global->ACCOUNTING_EXPORT_FORMAT.')" />';
253 
254  print '<script type="text/javascript">
255  jQuery(document).ready(function() {
256  jQuery("#exportcsvbutton").click(function() {
257  event.preventDefault();
258  console.log("Set action to export_csv");
259  jQuery("#action").val("export_csv");
260  jQuery("#searchFormList").submit();
261  jQuery("#action").val("list");
262  });
263  });
264  </script>';
265  }
266 
267  print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
268 
269  $selectedfields = '';
270 
271  $moreforfilter = '';
272 
273  $moreforfilter .= '<div class="divsearchfield">';
274  $moreforfilter .= $langs->trans('DateStart').': ';
275  $moreforfilter .= $form->selectDate($search_date_start ? $search_date_start : -1, 'date_start', 0, 0, 1, '', 1, 0);
276  $moreforfilter .= $langs->trans('DateEnd').': ';
277  $moreforfilter .= $form->selectDate($search_date_end ? $search_date_end : -1, 'date_end', 0, 0, 1, '', 1, 0);
278 
279  $moreforfilter .= ' - ';
280  $moreforfilter .= '<label for="show_subgroup">'.$langs->trans('ShowSubtotalByGroup').'</label>: ';
281  $moreforfilter .= '<input type="checkbox" name="show_subgroup" id="show_subgroup" value="show_subgroup"'.($show_subgroup == 'show_subgroup' ? ' checked' : '').'>';
282 
283  $moreforfilter .= '</div>';
284 
285  $moreforfilter .= '<div class="divsearchfield">';
286 
287  $moreforfilter .= $langs->trans("Journal");
288  $moreforfilter .= $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1);
289 
290  $moreforfilter .= '</div>';
291 
292  if (!empty($moreforfilter)) {
293  print '<div class="liste_titre liste_titre_bydiv centpercent">';
294  print $moreforfilter;
295  $parameters = array();
296  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
297  print $hookmanager->resPrint;
298  print '</div>';
299  }
300 
301 
302  $colspan = (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE) ? 5 : 4);
303 
304  print '<table class="liste '.($moreforfilter ? "listwithfilterbefore" : "").'">';
305 
306  print '<tr class="liste_titre_filter">';
307  print '<td class="liste_titre" colspan="'.$colspan.'">';
308  print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, '', 'accounts');
309  print ' ';
310  print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, '', 'accounts');
311  print '</td>';
312 
313  // Fields from hook
314  $parameters = array('arrayfields'=>$arrayfields);
315  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
316  print $hookmanager->resPrint;
317 
318  // Action column
319  print '<td class="liste_titre maxwidthsearch">';
320  $searchpicto = $form->showFilterButtons();
321  print $searchpicto;
322  print '</td>';
323  print '</tr>'."\n";
324 
325  print '<tr class="liste_titre">';
326  print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
327  if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
328  print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder);
329  }
330  print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder);
331  print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder);
332  print_liste_field_titre("Balance", $_SERVER["PHP_SELF"], "", $param, "", 'class="right"', $sortfield, $sortorder);
333 
334  // Hook fields
335  $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
336  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
337  print $hookmanager->resPrint;
338  // Action column
339  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
340  print '</tr>'."\n";
341 
342  $total_debit = 0;
343  $total_credit = 0;
344  $sous_total_debit = 0;
345  $sous_total_credit = 0;
346  $total_opening_balance = 0;
347  $sous_total_opening_balance = 0;
348  $displayed_account = "";
349 
350  $accountingaccountstatic = new AccountingAccount($db);
351 
352  // TODO Debug - This feature is dangerous, it takes all the entries and adds all the accounts
353  // without time and class limits (Class 6 and 7 accounts ???) and does not take into account the "a-nouveau" journal.
354  if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
355  $sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance";
356  $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t";
357  $sql .= " WHERE t.entity = " . $conf->entity; // Never do sharing into accounting features
358  $sql .= " AND t.doc_date < '" . $db->idate($search_date_start) . "'";
359  $sql .= " GROUP BY t.numero_compte";
360 
361  $resql = $db->query($sql);
362  $nrows = $db->num_rows($resql);
363  $opening_balances = array();
364  for ($i = 0; $i < $nrows; $i++) {
365  $arr = $resql->fetch_array();
366  $opening_balances["'" . $arr['numero_compte'] . "'"] = $arr['opening_balance'];
367  }
368  }
369 
370  foreach ($object->lines as $line) {
371  // reset before the fetch (in case of the fetch fails)
372  $accountingaccountstatic->id = 0;
373  $accountingaccountstatic->account_number = '';
374 
375  $accountingaccountstatic->fetch(null, $line->numero_compte, true);
376  if (!empty($accountingaccountstatic->account_number)) {
377  $accounting_account = $accountingaccountstatic->getNomUrl(0, 1, 0, '', 0, -1, 0, 'accountcard');
378  } else {
379  $accounting_account = length_accountg($line->numero_compte);
380  }
381 
382  $link = '';
383  $total_debit += $line->debit;
384  $total_credit += $line->credit;
385  $opening_balance = isset($opening_balances["'".$line->numero_compte."'"]) ? $opening_balances["'".$line->numero_compte."'"] : 0;
386  $total_opening_balance += $opening_balance;
387 
388  $tmparrayforrootaccount = $object->getRootAccount($line->numero_compte);
389  $root_account_description = $tmparrayforrootaccount['label'];
390  $root_account_number = $tmparrayforrootaccount['account_number'];
391 
392  //var_dump($tmparrayforrootaccount);
393  //var_dump($accounting_account);
394  //var_dump($accountingaccountstatic);
395  if (empty($accountingaccountstatic->label) && $accountingaccountstatic->id > 0) {
396  $link = '<a class="editfielda reposition" href="' . DOL_URL_ROOT . '/accountancy/admin/card.php?action=update&token=' . newToken() . '&id=' . $accountingaccountstatic->id . '">' . img_edit() . '</a>';
397  } elseif ($accounting_account == 'NotDefined') {
398  $link = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/card.php?action=create&token=' . newToken() . '&accountingaccount=' . length_accountg($line->numero_compte) . '">' . img_edit_add() . '</a>';
399  } elseif (empty($tmparrayforrootaccount['label'])) {
400  // $tmparrayforrootaccount['label'] not defined = the account has not parent with a parent.
401  // This is useless, we should not create a new account when an account has no parent, we must edit it to fix its parent.
402  // BUG 1: Accounts on level root or level 1 must not have a parent 2 level higher, so should not show a link to create another account.
403  // BUG 2: Adding a link to create a new accounting account here is useless because it is not add as parent of the orphelin.
404  //$link = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/card.php?action=create&token=' . newToken() . '&accountingaccount=' . length_accountg($line->numero_compte) . '">' . img_edit_add() . '</a>';
405  }
406 
407  if (!empty($show_subgroup)) {
408  // Show accounting account
409  if (empty($displayed_account) || $root_account_number != $displayed_account) {
410  // Show subtotal per accounting account
411  if ($displayed_account != "") {
412  print '<tr class="liste_total">';
413  print '<td class="right">'.$langs->trans("SubTotal").':</td>';
414  if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
415  print '<td class="right nowraponall amount">'.price($sous_total_opening_balance).'</td>';
416  }
417  print '<td class="right nowraponall amount">'.price($sous_total_debit).'</td>';
418  print '<td class="right nowraponall amount">'.price($sous_total_credit).'</td>';
419  if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
420  print '<td class="right nowraponall amount">'.price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit)).'</td>';
421  } else {
422  print '<td class="right nowraponall amount">'.price(price2num($sous_total_debit - $sous_total_credit)).'</td>';
423  }
424  print "<td></td>\n";
425  print '</tr>';
426  }
427 
428  // Show first line of a break
429  print '<tr class="trforbreak">';
430  print '<td colspan="'.($colspan+1).'" class="tdforbreak">'.$root_account_number.($root_account_description ? ' - '.$root_account_description : '').'</td>';
431  print '</tr>';
432 
433  $displayed_account = $root_account_number;
434  $sous_total_debit = 0;
435  $sous_total_credit = 0;
436  $sous_total_opening_balance = 0;
437  }
438  }
439 
440  print '<tr class="oddeven">';
441  print '<td>'.$accounting_account.'</td>';
442  if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
443  print '<td class="right nowraponall amount">'.price(price2num($opening_balance, 'MT')).'</td>';
444  }
445 
446  $urlzoom = '';
447  if ($line->numero_compte) {
448  $urlzoom = DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start='.urlencode($line->numero_compte).'&search_accountancy_code_end='.urlencode($line->numero_compte);
449  if (GETPOSTISSET('date_startmonth')) {
450  $urlzoom .= '&search_date_startmonth='.GETPOST('date_startmonth', 'int').'&search_date_startday='.GETPOST('date_startday', 'int').'&search_date_startyear='.GETPOST('date_startyear', 'int');
451  }
452  if (GETPOSTISSET('date_endmonth')) {
453  $urlzoom .= '&search_date_endmonth='.GETPOST('date_endmonth', 'int').'&search_date_endday='.GETPOST('date_endday', 'int').'&search_date_endyear='.GETPOST('date_endyear', 'int');
454  }
455  }
456  // Debit
457  print '<td class="right nowraponall amount"><a href="'.$urlzoom.'">'.price(price2num($line->debit, 'MT')).'</a></td>';
458  // Credit
459  print '<td class="right nowraponall amount"><a href="'.$urlzoom.'">'.price(price2num($line->credit, 'MT')).'</a></td>';
460 
461  if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
462  print '<td class="right nowraponall amount">'.price(price2num($opening_balance + $line->debit - $line->credit, 'MT')).'</td>';
463  } else {
464  print '<td class="right nowraponall amount">'.price(price2num($line->debit - $line->credit, 'MT')).'</td>';
465  }
466  print '<td class="center">';
467  print $link;
468  print '</td>';
469  print "</tr>\n";
470 
471  // Records the sub-total
472  $sous_total_debit += $line->debit;
473  $sous_total_credit += $line->credit;
474  $sous_total_opening_balance += $opening_balance;
475  }
476 
477  if (!empty($show_subgroup)) {
478  print '<tr class="liste_total"><td class="right">'.$langs->trans("SubTotal").':</td>';
479  if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
480  print '<td class="right nowraponall amount">'.price(price2num($sous_total_opening_balance, 'MT')).'</td>';
481  }
482  print '<td class="right nowraponall amount">'.price(price2num($sous_total_debit, 'MT')).'</td>';
483  print '<td class="right nowraponall amount">'.price(price2num($sous_total_credit, 'MT')).'</td>';
484  if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
485  print '<td class="right nowraponall amount">' . price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit, 'MT')) . '</td>';
486  } else {
487  print '<td class="right nowraponall amount">' . price(price2num($sous_total_debit - $sous_total_credit, 'MT')) . '</td>';
488  }
489  print "<td></td>\n";
490  print '</tr>';
491  }
492 
493  print '<tr class="liste_total"><td class="right">'.$langs->trans("AccountBalance").':</td>';
494  if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
495  print '<td class="nowrap right">'.price(price2num($total_opening_balance, 'MT')).'</td>';
496  }
497  print '<td class="right nowraponall amount">'.price(price2num($total_debit, 'MT')).'</td>';
498  print '<td class="right nowraponall amount">'.price(price2num($total_credit, 'MT')).'</td>';
499  if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
500  print '<td class="right nowraponall amount">' . price(price2num($total_opening_balance + $total_debit - $total_credit, 'MT')) . '</td>';
501  } else {
502  print '<td class="right nowraponall amount">' . price(price2num($total_debit - $total_credit, 'MT')) . '</td>';
503  }
504  print "<td></td>\n";
505  print '</tr>';
506 
507  $parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
508  $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
509  print $hookmanager->resPrint;
510 
511  print "</table>";
512  print '</form>';
513 }
514 
515 // End of page
516 llxFooter();
517 $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()
Empty header.
Definition: wrapper.php:56
llxFooter()
Empty footer.
Definition: wrapper.php:70
Class to manage accounting accounts.
Class to manage Ledger (General Ledger and Subledger)
Class to manage generation of HTML components for accounting management.
Class to manage generation of HTML components Only common components must be here.
Classe permettant la generation de composants html autre Only common components are here.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:745
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:143
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...
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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_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.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip='', $forcenowrapcolumntitle=0)
Get title line of an array.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $morehtmlcenter='', $num=-1, $totalnboflines='', $picto='generic', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0, $pagenavastextinput=0, $morehtmlrightbeforearrow='')
Print a title with navigation controls for pagination.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
img_edit_add($titlealt='default', $other='')
Show logo +.
isModEnabled($module)
Is Dolibarr module enabled.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
$nbtotalofrecords
Count total nb of records.
Definition: list.php:329
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.