dolibarr  16.0.1
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  $parameters = array();
242  $reshook = $hookmanager->executeHooks('addMoreActionsButtonsList', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
243  if (empty($reshook)) {
244  $button = '<input type="button" id="exportcsvbutton" name="exportcsvbutton" class="butAction" value="'.$langs->trans("Export").' ('.$conf->global->ACCOUNTING_EXPORT_FORMAT.')" />';
245 
246  print '<script type="text/javascript">
247  jQuery(document).ready(function() {
248  jQuery("#exportcsvbutton").click(function() {
249  event.preventDefault();
250  console.log("Set action to export_csv");
251  jQuery("#action").val("export_csv");
252  jQuery("#searchFormList").submit();
253  jQuery("#action").val("list");
254  });
255  });
256  </script>';
257  }
258 
259  print_barre_liste($title_page, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $button, $result, $nbtotalofrecords, 'title_accountancy', 0, '', '', $limit);
260 
261  $selectedfields = '';
262 
263  $moreforfilter = '';
264 
265  $moreforfilter .= '<div class="divsearchfield">';
266  $moreforfilter .= $langs->trans('DateStart').': ';
267  $moreforfilter .= $form->selectDate($search_date_start ? $search_date_start : -1, 'date_start', 0, 0, 1, '', 1, 0);
268  $moreforfilter .= $langs->trans('DateEnd').': ';
269  $moreforfilter .= $form->selectDate($search_date_end ? $search_date_end : -1, 'date_end', 0, 0, 1, '', 1, 0);
270 
271  $moreforfilter .= ' - ';
272  $moreforfilter .= '<label for="show_subgroup">'.$langs->trans('ShowSubtotalByGroup').'</label>: ';
273  $moreforfilter .= '<input type="checkbox" name="show_subgroup" id="show_subgroup" value="show_subgroup"'.($show_subgroup == 'show_subgroup' ? ' checked' : '').'>';
274 
275  $moreforfilter .= '</div>';
276 
277  $moreforfilter .= '<div class="divsearchfield">';
278 
279  $moreforfilter .= $langs->trans("Journal");
280  $moreforfilter .= $formaccounting->multi_select_journal($search_ledger_code, 'search_ledger_code', 0, 1, 1, 1);
281 
282  $moreforfilter .= '</div>';
283 
284  if (!empty($moreforfilter)) {
285  print '<div class="liste_titre liste_titre_bydiv centpercent">';
286  print $moreforfilter;
287  $parameters = array();
288  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
289  print $hookmanager->resPrint;
290  print '</div>';
291  }
292 
293 
294  $colspan = (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE) ? 5 : 4);
295 
296  print '<table class="liste '.($moreforfilter ? "listwithfilterbefore" : "").'">';
297 
298  print '<tr class="liste_titre_filter">';
299  print '<td class="liste_titre" colspan="'.$colspan.'">';
300  print $formaccounting->select_account($search_accountancy_code_start, 'search_accountancy_code_start', $langs->trans('From'), array(), 1, 1, '', 'accounts');
301  print ' ';
302  print $formaccounting->select_account($search_accountancy_code_end, 'search_accountancy_code_end', $langs->trans('to'), array(), 1, 1, '', 'accounts');
303  print '</td>';
304 
305  // Fields from hook
306  $parameters = array('arrayfields'=>$arrayfields);
307  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters, $object); // Note that $action and $object may have been modified by hook
308  print $hookmanager->resPrint;
309 
310  // Action column
311  print '<td class="liste_titre maxwidthsearch">';
312  $searchpicto = $form->showFilterButtons();
313  print $searchpicto;
314  print '</td>';
315  print '</tr>'."\n";
316 
317  print '<tr class="liste_titre">';
318  print_liste_field_titre("AccountAccounting", $_SERVER['PHP_SELF'], "t.numero_compte", "", $param, "", $sortfield, $sortorder);
319  if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
320  print_liste_field_titre("OpeningBalance", $_SERVER['PHP_SELF'], "", $param, "", 'class="right"', $sortfield, $sortorder);
321  }
322  print_liste_field_titre("Debit", $_SERVER['PHP_SELF'], "t.debit", "", $param, 'class="right"', $sortfield, $sortorder);
323  print_liste_field_titre("Credit", $_SERVER['PHP_SELF'], "t.credit", "", $param, 'class="right"', $sortfield, $sortorder);
324  print_liste_field_titre("Balance", $_SERVER["PHP_SELF"], "", $param, "", 'class="right"', $sortfield, $sortorder);
325 
326  // Hook fields
327  $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder);
328  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters, $object); // Note that $action and $object may have been modified by hook
329  print $hookmanager->resPrint;
330  // Action column
331  print getTitleFieldOfList($selectedfields, 0, $_SERVER["PHP_SELF"], '', '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ')."\n";
332  print '</tr>'."\n";
333 
334  $total_debit = 0;
335  $total_credit = 0;
336  $sous_total_debit = 0;
337  $sous_total_credit = 0;
338  $total_opening_balance = 0;
339  $sous_total_opening_balance = 0;
340  $displayed_account = "";
341 
342  $accountingaccountstatic = new AccountingAccount($db);
343 
344  // TODO Debug - This feature is dangerous, it takes all the entries and adds all the accounts
345  // without time and class limits (Class 6 and 7 accounts ???) and does not take into account the "a-nouveau" journal.
346  if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
347  $sql = "SELECT t.numero_compte, (SUM(t.debit) - SUM(t.credit)) as opening_balance";
348  $sql .= " FROM " . MAIN_DB_PREFIX . "accounting_bookkeeping as t";
349  $sql .= " WHERE t.entity = " . $conf->entity; // Never do sharing into accounting features
350  $sql .= " AND t.doc_date < '" . $db->idate($search_date_start) . "'";
351  $sql .= " GROUP BY t.numero_compte";
352 
353  $resql = $db->query($sql);
354  $nrows = $db->num_rows($resql);
355  $opening_balances = array();
356  for ($i = 0; $i < $nrows; $i++) {
357  $arr = $resql->fetch_array();
358  $opening_balances["'" . $arr['numero_compte'] . "'"] = $arr['opening_balance'];
359  }
360  }
361 
362  foreach ($object->lines as $line) {
363  // reset before the fetch (in case of the fetch fails)
364  $accountingaccountstatic->id = 0;
365  $accountingaccountstatic->account_number = '';
366 
367  $accountingaccountstatic->fetch(null, $line->numero_compte, true);
368  if (!empty($accountingaccountstatic->account_number)) {
369  $accounting_account = $accountingaccountstatic->getNomUrl(0, 1, 0, '', 0, -1, 0, 'accountcard');
370  } else {
371  $accounting_account = length_accountg($line->numero_compte);
372  }
373 
374  $link = '';
375  $total_debit += $line->debit;
376  $total_credit += $line->credit;
377  $opening_balance = isset($opening_balances["'".$line->numero_compte."'"]) ? $opening_balances["'".$line->numero_compte."'"] : 0;
378  $total_opening_balance += $opening_balance;
379 
380  $tmparrayforrootaccount = $object->getRootAccount($line->numero_compte);
381  $root_account_description = $tmparrayforrootaccount['label'];
382  $root_account_number = $tmparrayforrootaccount['account_number'];
383 
384  //var_dump($tmparrayforrootaccount);
385  //var_dump($accounting_account);
386  //var_dump($accountingaccountstatic);
387  if (empty($accountingaccountstatic->label) && $accountingaccountstatic->id > 0) {
388  $link = '<a class="editfielda reposition" href="' . DOL_URL_ROOT . '/accountancy/admin/card.php?action=update&token=' . newToken() . '&id=' . $accountingaccountstatic->id . '">' . img_edit() . '</a>';
389  } elseif ($accounting_account == 'NotDefined') {
390  $link = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/card.php?action=create&token=' . newToken() . '&accountingaccount=' . length_accountg($line->numero_compte) . '">' . img_edit_add() . '</a>';
391  } elseif (empty($tmparrayforrootaccount['label'])) {
392  // $tmparrayforrootaccount['label'] not defined = the account has not parent with a parent.
393  // This is useless, we should not create a new account when an account has no parent, we must edit it to fix its parent.
394  // 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.
395  // BUG 2: Adding a link to create a new accounting account here is useless because it is not add as parent of the orphelin.
396  //$link = '<a href="' . DOL_URL_ROOT . '/accountancy/admin/card.php?action=create&token=' . newToken() . '&accountingaccount=' . length_accountg($line->numero_compte) . '">' . img_edit_add() . '</a>';
397  }
398 
399  if (!empty($show_subgroup)) {
400  // Show accounting account
401  if (empty($displayed_account) || $root_account_number != $displayed_account) {
402  // Show subtotal per accounting account
403  if ($displayed_account != "") {
404  print '<tr class="liste_total">';
405  print '<td class="right">'.$langs->trans("SubTotal").':</td>';
406  if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
407  print '<td class="right nowraponall amount">'.price($sous_total_opening_balance).'</td>';
408  }
409  print '<td class="right nowraponall amount">'.price($sous_total_debit).'</td>';
410  print '<td class="right nowraponall amount">'.price($sous_total_credit).'</td>';
411  if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
412  print '<td class="right nowraponall amount">'.price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit)).'</td>';
413  } else {
414  print '<td class="right nowraponall amount">'.price(price2num($sous_total_debit - $sous_total_credit)).'</td>';
415  }
416  print "<td></td>\n";
417  print '</tr>';
418  }
419 
420  // Show first line of a break
421  print '<tr class="trforbreak">';
422  print '<td colspan="'.($colspan+1).'" class="tdforbreak">'.$line->numero_compte.($root_account_description ? ' - '.$root_account_description : '').'</td>';
423  print '</tr>';
424 
425  $displayed_account = $root_account_number;
426  $sous_total_debit = 0;
427  $sous_total_credit = 0;
428  $sous_total_opening_balance = 0;
429  }
430  }
431 
432  print '<tr class="oddeven">';
433  print '<td>'.$accounting_account.'</td>';
434  if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
435  print '<td class="right nowraponall amount">'.price(price2num($opening_balance, 'MT')).'</td>';
436  }
437 
438  $urlzoom = '';
439  if ($line->numero_compte) {
440  $urlzoom = DOL_URL_ROOT.'/accountancy/bookkeeping/listbyaccount.php?search_accountancy_code_start='.urlencode($line->numero_compte).'&search_accountancy_code_end='.urlencode($line->numero_compte);
441  if (GETPOSTISSET('date_startmonth')) {
442  $urlzoom .= '&search_date_startmonth='.GETPOST('date_startmonth', 'int').'&search_date_startday='.GETPOST('date_startday', 'int').'&search_date_startyear='.GETPOST('date_startyear', 'int');
443  }
444  if (GETPOSTISSET('date_endmonth')) {
445  $urlzoom .= '&search_date_endmonth='.GETPOST('date_endmonth', 'int').'&search_date_endday='.GETPOST('date_endday', 'int').'&search_date_endyear='.GETPOST('date_endyear', 'int');
446  }
447  }
448  // Debit
449  print '<td class="right nowraponall amount"><a href="'.$urlzoom.'">'.price(price2num($line->debit, 'MT')).'</a></td>';
450  // Credit
451  print '<td class="right nowraponall amount"><a href="'.$urlzoom.'">'.price(price2num($line->credit, 'MT')).'</a></td>';
452 
453  if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
454  print '<td class="right nowraponall amount">'.price(price2num($opening_balance + $line->debit - $line->credit, 'MT')).'</td>';
455  } else {
456  print '<td class="right nowraponall amount">'.price(price2num($line->debit - $line->credit, 'MT')).'</td>';
457  }
458  print '<td class="center">';
459  print $link;
460  print '</td>';
461  print "</tr>\n";
462 
463  // Records the sub-total
464  $sous_total_debit += $line->debit;
465  $sous_total_credit += $line->credit;
466  $sous_total_opening_balance += $opening_balance;
467  }
468 
469  if (!empty($show_subgroup)) {
470  print '<tr class="liste_total"><td class="right">'.$langs->trans("SubTotal").':</td>';
471  if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
472  print '<td class="right nowraponall amount">'.price(price2num($sous_total_opening_balance, 'MT')).'</td>';
473  }
474  print '<td class="right nowraponall amount">'.price(price2num($sous_total_debit, 'MT')).'</td>';
475  print '<td class="right nowraponall amount">'.price(price2num($sous_total_credit, 'MT')).'</td>';
476  if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
477  print '<td class="right nowraponall amount">' . price(price2num($sous_total_opening_balance + $sous_total_debit - $sous_total_credit, 'MT')) . '</td>';
478  } else {
479  print '<td class="right nowraponall amount">' . price(price2num($sous_total_debit - $sous_total_credit, 'MT')) . '</td>';
480  }
481  print "<td></td>\n";
482  print '</tr>';
483  }
484 
485  print '<tr class="liste_total"><td class="right">'.$langs->trans("AccountBalance").':</td>';
486  if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
487  print '<td class="nowrap right">'.price(price2num($total_opening_balance, 'MT')).'</td>';
488  }
489  print '<td class="right nowraponall amount">'.price(price2num($total_debit, 'MT')).'</td>';
490  print '<td class="right nowraponall amount">'.price(price2num($total_credit, 'MT')).'</td>';
491  if (!empty($conf->global->ACCOUNTANCY_SHOW_OPENING_BALANCE)) {
492  print '<td class="right nowraponall amount">' . price(price2num($total_opening_balance + $total_debit - $total_credit, 'MT')) . '</td>';
493  } else {
494  print '<td class="right nowraponall amount">' . price(price2num($total_debit - $total_credit, 'MT')) . '</td>';
495  }
496  print "<td></td>\n";
497  print '</tr>';
498 
499  print "</table>";
500  print '</form>';
501 }
502 
503 // End of page
504 llxFooter();
505 $db->close();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
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.
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
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...
Class to manage Ledger (General Ledger and Subledger)
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
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.
Class to manage generation of HTML components Only common components must be here.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form...
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is &#39;...
Classe permettant la generation de composants html autre Only common components are here...
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 ...
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
img_edit_add($titlealt= 'default', $other= '')
Show 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
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Class to manage generation of HTML components for accounting management.
newToken()
Return the value of token currently saved into session with name &#39;newtoken&#39;.
isModEnabled($module)
Is Dolibarr module enabled.
Class to manage accounting accounts.
getTitleFieldOfList($name, $thead=0, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $disablesortlink=0, $tooltip= '', $forcenowrapcolumntitle=0)
Get title line of an array.
length_accountg($account)
Return General accounting account with defined length (used for product and miscellaneous) ...
llxFooter()
Empty footer.
Definition: wrapper.php:73