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