dolibarr  16.0.5
account.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
3  * Copyright (C) 2013-2020 Alexandre Spangaro <aspangaro@open-dsi.fr>
4  * Copyright (C) 2016-2018 Laurent Destailleur <eldy@users.sourceforge.net>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
26 require '../../main.inc.php';
27 require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
28 require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php';
29 require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php';
31 
32 // Load translation files required by the page
33 $langs->loadLangs(array("compta", "bills", "admin", "accountancy", "salaries"));
34 
35 $mesg = '';
36 $action = GETPOST('action', 'aZ09');
37 $cancel = GETPOST('cancel', 'alpha');
38 $id = GETPOST('id', 'int');
39 $rowid = GETPOST('rowid', 'int');
40 $massaction = GETPOST('massaction', 'aZ09');
41 $optioncss = GETPOST('optioncss', 'alpha');
42 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'accountingaccountlist'; // To manage different context of search
43 
44 $search_account = GETPOST('search_account', 'alpha');
45 $search_label = GETPOST('search_label', 'alpha');
46 $search_labelshort = GETPOST('search_labelshort', 'alpha');
47 $search_accountparent = GETPOST('search_accountparent', 'alpha');
48 $search_pcgtype = GETPOST('search_pcgtype', 'alpha');
49 $toselect = GETPOST('toselect', 'array');
50 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
51 $confirm = GETPOST('confirm', 'alpha');
52 
53 $chartofaccounts = GETPOST('chartofaccounts', 'int');
54 
55 $permissiontoadd = !empty($user->rights->accounting->chartofaccount);
56 $permissiontodelete = !empty($user->rights->accounting->chartofaccount);
57 
58 // Security check
59 if ($user->socid > 0) {
61 }
62 if (empty($user->rights->accounting->chartofaccount)) {
64 }
65 
66 // Load variable for pagination
67 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
68 $sortfield = GETPOST('sortfield', 'aZ09comma');
69 $sortorder = GETPOST('sortorder', 'aZ09comma');
70 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
71 if (empty($page) || $page == -1) {
72  $page = 0;
73 } // If $page is not defined, or '' or -1
74 $offset = $limit * $page;
75 $pageprev = $page - 1;
76 $pagenext = $page + 1;
77 if (!$sortfield) {
78  $sortfield = "aa.account_number";
79 }
80 if (!$sortorder) {
81  $sortorder = "ASC";
82 }
83 
84 $arrayfields = array(
85  'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1),
86  'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
87  'aa.labelshort'=>array('label'=>$langs->trans("LabelToShow"), 'checked'=>1),
88  'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1),
89  'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'),
90  'aa.reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1),
91  'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1)
92 );
93 
94 if ($conf->global->MAIN_FEATURES_LEVEL < 2) {
95  unset($arrayfields['aa.reconcilable']);
96 }
97 
98 $accounting = new AccountingAccount($db);
99 
100 
101 /*
102  * Actions
103  */
104 
105 if (GETPOST('cancel', 'alpha')) {
106  $action = 'list'; $massaction = '';
107 }
108 if (!GETPOST('confirmmassaction', 'alpha')) {
109  $massaction = '';
110 }
111 
112 $parameters = array();
113 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been monowraponalldified by some hooks
114 if ($reshook < 0) {
115  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
116 }
117 
118 if (empty($reshook)) {
119  if (!empty($cancel)) {
120  $action = '';
121  }
122 
123  $objectclass = 'AccountingAccount';
124  $uploaddir = $conf->accounting->multidir_output[$conf->entity];
125  include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
126 
127  if ($action == "delete") {
128  $action = "";
129  }
130  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
131 
132  if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
133  $search_account = "";
134  $search_label = "";
135  $search_labelshort = "";
136  $search_accountparent = "";
137  $search_pcgtype = "";
138  $search_array_options = array();
139  }
140  if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on
141  || (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != $conf->global->CHARTOFACCOUNTS)) { // a submit of form is done and chartofaccounts combo has been modified
142  if ($chartofaccounts > 0 && $permissiontoadd) {
143  // Get language code for this $chartofaccounts
144  $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a';
145  $sql .= ' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts;
146  $resql = $db->query($sql);
147  if ($resql) {
148  $obj = $db->fetch_object($resql);
149  $country_code = $obj->code;
150  } else {
151  dol_print_error($db);
152  }
153 
154  // Try to load sql file
155  if ($country_code) {
156  $sqlfile = DOL_DOCUMENT_ROOT.'/install/mysql/data/llx_accounting_account_'.strtolower($country_code).'.sql';
157 
158  $offsetforchartofaccount = 0;
159  // Get the comment line '-- ADD CCCNNNNN to rowid...' to find CCCNNNNN (CCC is country num, NNNNN is id of accounting account)
160  // and pass CCCNNNNN + (num of company * 100 000 000) as offset to the run_sql as a new parameter to say to update sql on the fly to add offset to rowid and account_parent value.
161  // This is to be sure there is no conflict for each chart of account, whatever is country, whatever is company when multicompany is used.
162  $tmp = file_get_contents($sqlfile);
163  $reg = array();
164  if (preg_match('/-- ADD (\d+) to rowid/ims', $tmp, $reg)) {
165  $offsetforchartofaccount += $reg[1];
166  }
167  $offsetforchartofaccount += ($conf->entity * 100000000);
168 
169  $result = run_sql($sqlfile, 1, $conf->entity, 1, '', 'default', 32768, 0, $offsetforchartofaccount);
170 
171  if ($result > 0) {
172  setEventMessages($langs->trans("ChartLoaded"), null, 'mesgs');
173  } else {
174  setEventMessages($langs->trans("ErrorDuringChartLoad"), null, 'warnings');
175  }
176  }
177 
178  if (!dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
179  $error++;
180  }
181  } else {
182  $error++;
183  }
184  }
185 
186  if ($action == 'disable' && $permissiontoadd) {
187  if ($accounting->fetch($id)) {
188  $mode = GETPOST('mode', 'int');
189  $result = $accounting->accountDeactivate($id, $mode);
190  }
191 
192  $action = 'update';
193  if ($result < 0) {
194  setEventMessages($accounting->error, $accounting->errors, 'errors');
195  }
196  } elseif ($action == 'enable' && $permissiontoadd) {
197  if ($accounting->fetch($id)) {
198  $mode = GETPOST('mode', 'int');
199  $result = $accounting->accountActivate($id, $mode);
200  }
201  $action = 'update';
202  if ($result < 0) {
203  setEventMessages($accounting->error, $accounting->errors, 'errors');
204  }
205  }
206 }
207 
208 
209 /*
210  * View
211  */
212 
213 $form = new Form($db);
214 $formaccounting = new FormAccounting($db);
215 
216 llxHeader('', $langs->trans("ListAccounts"));
217 
218 if ($action == 'delete') {
219  $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1);
220  print $formconfirm;
221 }
222 
223 $pcgver = $conf->global->CHARTOFACCOUNTS;
224 
225 $sql = "SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.account_number, aa.account_parent , aa.label, aa.labelshort, aa.reconcilable, aa.active, ";
226 $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2";
227 $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
228 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".$conf->entity;
229 if ($db->type == 'pgsql') {
230  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity;
231 } else {
232  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity;
233 }
234 $sql .= " WHERE asy.rowid = ".((int) $pcgver);
235 //print $sql;
236 if (strlen(trim($search_account))) {
237  $lengthpaddingaccount = 0;
238  if ($conf->global->ACCOUNTING_LENGTH_GACCOUNT || $conf->global->ACCOUNTING_LENGTH_AACCOUNT) {
239  $lengthpaddingaccount = max($conf->global->ACCOUNTING_LENGTH_GACCOUNT, $conf->global->ACCOUNTING_LENGTH_AACCOUNT);
240  }
241  $search_account_tmp = $search_account;
242  $weremovedsomezero = 0;
243  if (strlen($search_account_tmp) <= $lengthpaddingaccount) {
244  for ($i = 0; $i < $lengthpaddingaccount; $i++) {
245  if (preg_match('/0$/', $search_account_tmp)) {
246  $weremovedsomezero++;
247  $search_account_tmp = preg_replace('/0$/', '', $search_account_tmp);
248  }
249  }
250  }
251 
252  //var_dump($search_account); exit;
253  if ($search_account_tmp) {
254  if ($weremovedsomezero) {
255  $search_account_tmp_clean = $search_account_tmp;
256  $search_account_clean = $search_account;
257  $startchar = '%';
258  if (strpos($search_account_tmp, '^') === 0) {
259  $startchar = '';
260  $search_account_tmp_clean = preg_replace('/^\^/', '', $search_account_tmp);
261  $search_account_clean = preg_replace('/^\^/', '', $search_account);
262  }
263  $sql .= " AND (aa.account_number LIKE '".$db->escape($startchar.$search_account_tmp_clean)."'";
264  $sql .= " OR aa.account_number LIKE '".$db->escape($startchar.$search_account_clean)."%')";
265  } else {
266  $sql .= natural_search("aa.account_number", $search_account_tmp);
267  }
268  }
269 }
270 if (strlen(trim($search_label))) {
271  $sql .= natural_search("aa.label", $search_label);
272 }
273 if (strlen(trim($search_labelshort))) {
274  $sql .= natural_search("aa.labelshort", $search_labelshort);
275 }
276 if (strlen(trim($search_accountparent)) && $search_accountparent != '-1') {
277  $sql .= natural_search("aa.account_parent", $search_accountparent, 2);
278 }
279 if (strlen(trim($search_pcgtype))) {
280  $sql .= natural_search("aa.pcg_type", $search_pcgtype);
281 }
282 $sql .= $db->order($sortfield, $sortorder);
283 //print $sql;
284 
285 // Count total nb of records
286 $nbtotalofrecords = '';
287 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
288  $resql = $db->query($sql);
289  $nbtotalofrecords = $db->num_rows($resql);
290  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
291  $page = 0;
292  $offset = 0;
293  }
294 }
295 
296 // List of mass actions available
297 if ($user->rights->accounting->chartofaccount) {
298  $arrayofmassactions['predelete'] = '<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans("Delete");
299 }
300 if (in_array($massaction, array('presend', 'predelete', 'closed'))) {
301  $arrayofmassactions = array();
302 }
303 
304 $massactionbutton = $form->selectMassAction('', $arrayofmassactions);
305 $arrayofselected = is_array($toselect) ? $toselect : array();
306 $sql .= $db->plimit($limit + 1, $offset);
307 
308 dol_syslog('accountancy/admin/account.php:: $sql='.$sql);
309 $resql = $db->query($sql);
310 
311 if ($resql) {
312  $num = $db->num_rows($resql);
313 
314  $param = '';
315  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
316  $param .= '&contextpage='.urlencode($contextpage);
317  }
318  if ($limit > 0 && $limit != $conf->liste_limit) {
319  $param .= '&limit='.urlencode($limit);
320  }
321  if ($search_account) {
322  $param .= '&search_account='.urlencode($search_account);
323  }
324  if ($search_label) {
325  $param .= '&search_label='.urlencode($search_label);
326  }
327  if ($search_labelshort) {
328  $param .= '&search_labelshort='.urlencode($search_labelshort);
329  }
330  if ($search_accountparent > 0 || $search_accountparent == '0') {
331  $param .= '&search_accountparent='.urlencode($search_accountparent);
332  }
333  if ($search_pcgtype) {
334  $param .= '&search_pcgtype='.urlencode($search_pcgtype);
335  }
336  if ($optioncss != '') {
337  $param .= '&optioncss='.urlencode($optioncss);
338  }
339 
340  if (!empty($conf->use_javascript_ajax)) {
341  print '<!-- Add javascript to reload page when we click "Change plan" -->
342  <script type="text/javascript">
343  $(document).ready(function () {
344  $("#change_chart").on("click", function (e) {
345  console.log("chartofaccounts seleted = "+$("#chartofaccounts").val());
346  // reload page
347  window.location.href = "'.$_SERVER["PHP_SELF"].'?valid_change_chart=1&chartofaccounts="+$("#chartofaccounts").val();
348  });
349  });
350  </script>';
351  }
352 
353  $newcardbutton = '';
354 
355  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
356  if ($optioncss != '') {
357  print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
358  }
359  print '<input type="hidden" name="token" value="'.newToken().'">';
360  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
361  print '<input type="hidden" name="action" value="list">';
362  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
363  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
364  print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
365 
366  $newcardbutton .= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create');
367  include DOL_DOCUMENT_ROOT.'/core/tpl/massactions_pre.tpl.php';
368  print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 'accounting_account', 0, $newcardbutton, '', $limit, 0, 0, 1);
369 
370  // Box to select active chart of account
371  print $langs->trans("Selectchartofaccounts")." : ";
372  print '<select class="flat minwidth200" name="chartofaccounts" id="chartofaccounts">';
373  $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active, c.code as country_code";
374  $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a";
375  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country = c.rowid AND c.active = 1";
376  $sql .= " WHERE a.active = 1";
377  dol_syslog('accountancy/admin/account.php $sql='.$sql);
378 
379  $resqlchart = $db->query($sql);
380  if ($resqlchart) {
381  $numbis = $db->num_rows($resqlchart);
382  $i = 0;
383  print '<option value="-1">&nbsp;</option>';
384  while ($i < $numbis) {
385  $obj = $db->fetch_object($resqlchart);
386 
387  print '<option value="'.$obj->rowid.'"';
388  print ($pcgver == $obj->rowid) ? ' selected' : '';
389  print '>'.$obj->pcg_version.' - '.$obj->label.' - ('.$obj->country_code.')</option>';
390 
391  $i++;
392  }
393  } else {
394  dol_print_error($db);
395  }
396  print "</select>";
397  print ajax_combobox("chartofaccounts");
398  print '<input type="'.(empty($conf->use_javascript_ajax) ? 'submit' : 'button').'" class="button button-edit" name="change_chart" id="change_chart" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">';
399 
400  print '<br>';
401  print '<br>';
402 
403  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
404  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
405  $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons('checkforselect', 1) : '');
406 
407  $moreforfilter = '';
408 
409  $accountstatic = new AccountingAccount($db);
410  $accountparent = new AccountingAccount($db);
411  $totalarray = array();
412  $totalarray['nbfield'] = 0;
413 
414  print '<div class="div-table-responsive">';
415  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
416 
417  // Line for search fields
418  print '<tr class="liste_titre_filter">';
419  if (!empty($arrayfields['aa.account_number']['checked'])) {
420  print '<td class="liste_titre"><input type="text" class="flat width100" name="search_account" value="'.$search_account.'"></td>';
421  }
422  if (!empty($arrayfields['aa.label']['checked'])) {
423  print '<td class="liste_titre"><input type="text" class="flat width150" name="search_label" value="'.$search_label.'"></td>';
424  }
425  if (!empty($arrayfields['aa.labelshort']['checked'])) {
426  print '<td class="liste_titre"><input type="text" class="flat width100" name="search_labelshort" value="'.$search_labelshort.'"></td>';
427  }
428  if (!empty($arrayfields['aa.account_parent']['checked'])) {
429  print '<td class="liste_titre">';
430  print $formaccounting->select_account($search_accountparent, 'search_accountparent', 2);
431  print '</td>';
432  }
433  if (!empty($arrayfields['aa.pcg_type']['checked'])) {
434  print '<td class="liste_titre"><input type="text" class="flat width100" name="search_pcgtype" value="'.$search_pcgtype.'"></td>';
435  }
436  if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
437  if (!empty($arrayfields['aa.reconcilable']['checked'])) {
438  print '<td class="liste_titre">&nbsp;</td>';
439  }
440  }
441  if (!empty($arrayfields['aa.active']['checked'])) {
442  print '<td class="liste_titre">&nbsp;</td>';
443  }
444  print '<td class="liste_titre maxwidthsearch">';
445  $searchpicto = $form->showFilterButtons();
446  print $searchpicto;
447  print '</td>';
448  print '</tr>';
449  print '<tr class="liste_titre">';
450  if (!empty($arrayfields['aa.account_number']['checked'])) {
451  print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
452  }
453  if (!empty($arrayfields['aa.label']['checked'])) {
454  print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder);
455  }
456  if (!empty($arrayfields['aa.labelshort']['checked'])) {
457  print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder);
458  }
459  if (!empty($arrayfields['aa.account_parent']['checked'])) {
460  print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left ');
461  }
462  if (!empty($arrayfields['aa.pcg_type']['checked'])) {
463  print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type,aa.account_number', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help'], 1);
464  }
465  if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
466  if (!empty($arrayfields['aa.reconcilable']['checked'])) {
467  print_liste_field_titre($arrayfields['aa.reconcilable']['label'], $_SERVER["PHP_SELF"], 'aa.reconcilable', '', $param, '', $sortfield, $sortorder);
468  }
469  }
470  if (!empty($arrayfields['aa.active']['checked'])) {
471  print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder);
472  }
473  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
474  print "</tr>\n";
475 
476  $i = 0;
477  while ($i < min($num, $limit)) {
478  $obj = $db->fetch_object($resql);
479 
480  $accountstatic->id = $obj->rowid;
481  $accountstatic->label = $obj->label;
482  $accountstatic->account_number = $obj->account_number;
483 
484  print '<tr class="oddeven">';
485 
486  // Account number
487  if (!empty($arrayfields['aa.account_number']['checked'])) {
488  print "<td>";
489  print $accountstatic->getNomUrl(1, 0, 0, '', 0, 1, 0, 'accountcard');
490  print "</td>\n";
491  if (!$i) {
492  $totalarray['nbfield']++;
493  }
494  }
495 
496  // Account label
497  if (!empty($arrayfields['aa.label']['checked'])) {
498  print "<td>";
499  print $obj->label;
500  print "</td>\n";
501  if (!$i) {
502  $totalarray['nbfield']++;
503  }
504  }
505 
506  // Account label to show (label short)
507  if (!empty($arrayfields['aa.labelshort']['checked'])) {
508  print "<td>";
509  print $obj->labelshort;
510  print "</td>\n";
511  if (!$i) {
512  $totalarray['nbfield']++;
513  }
514  }
515 
516  // Account parent
517  if (!empty($arrayfields['aa.account_parent']['checked'])) {
518  // Note: obj->account_parent is a foreign key to a rowid. It is field in child table and obj->rowid2 is same, but in parent table.
519  // So for orphans, obj->account_parent is set but not obj->rowid2
520  if (!empty($obj->account_parent) && !empty($obj->rowid2)) {
521  print "<td>";
522  print '<!-- obj->account_parent = '.$obj->account_parent.' obj->rowid2 = '.$obj->rowid2.' -->';
523  $accountparent->id = $obj->rowid2;
524  $accountparent->label = $obj->label2;
525  $accountparent->account_number = $obj->account_number2; // Sotre an account number for output
526  print $accountparent->getNomUrl(1);
527  print "</td>\n";
528  if (!$i) {
529  $totalarray['nbfield']++;
530  }
531  } else {
532  print '<td>';
533  if (!empty($obj->account_parent)) {
534  print '<!-- Bad value for obj->account_parent = '.$obj->account_parent.': is a rowid that does not exists -->';
535  }
536  print '</td>';
537  if (!$i) {
538  $totalarray['nbfield']++;
539  }
540  }
541  }
542 
543  // Chart of accounts type
544  if (!empty($arrayfields['aa.pcg_type']['checked'])) {
545  print "<td>";
546  print $obj->pcg_type;
547  print "</td>\n";
548  if (!$i) {
549  $totalarray['nbfield']++;
550  }
551  }
552 
553  if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
554  // Activated or not reconciliation on accounting account
555  if (!empty($arrayfields['aa.reconcilable']['checked'])) {
556  print '<td class="center">';
557  if (empty($obj->reconcilable)) {
558  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable&mode=1&token='.newToken().'">';
559  print img_picto($langs->trans("Disabled"), 'switch_off');
560  print '</a>';
561  } else {
562  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=disable&mode=1&token='.newToken().'">';
563  print img_picto($langs->trans("Activated"), 'switch_on');
564  print '</a>';
565  }
566  print '</td>';
567  if (!$i) {
568  $totalarray['nbfield']++;
569  }
570  }
571  }
572 
573  // Activated or not
574  if (!empty($arrayfields['aa.active']['checked'])) {
575  print '<td class="center">';
576  if (empty($obj->active)) {
577  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable&mode=0&token='.newToken().'">';
578  print img_picto($langs->trans("Disabled"), 'switch_off');
579  print '</a>';
580  } else {
581  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=disable&mode=0&token='.newToken().'">';
582  print img_picto($langs->trans("Activated"), 'switch_on');
583  print '</a>';
584  }
585  print '</td>';
586  if (!$i) {
587  $totalarray['nbfield']++;
588  }
589  }
590 
591  // Action
592  print '<td class="center nowraponall">';
593  if ($user->rights->accounting->chartofaccount) {
594  print '<a class="editfielda" href="./card.php?action=update&token='.newToken().'&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?'.$param).'">';
595  print img_edit();
596  print '</a>';
597  print '&nbsp;';
598  print '<a class="marginleftonly" href="./card.php?action=delete&token='.newToken().'&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?'.$param).'">';
599  print img_delete();
600  print '</a>';
601  print '&nbsp;';
602  if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
603  $selected = 0;
604  if (in_array($obj->rowid, $arrayofselected)) {
605  $selected = 1;
606  }
607  print '<input id="cb'.$obj->rowid.'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$obj->rowid.'"'.($selected ? ' checked="checked"' : '').'>';
608  }
609  }
610  print '</td>'."\n";
611  if (!$i) {
612  $totalarray['nbfield']++;
613  }
614 
615  print "</tr>\n";
616  $i++;
617  }
618 
619  if ($num == 0) {
620  $colspan = 1;
621  foreach ($arrayfields as $key => $val) {
622  if (!empty($val['checked'])) {
623  $colspan++;
624  }
625  }
626  print '<tr><td colspan="'.$colspan.'"><span class="opacitymedium">'.$langs->trans("None").'</span></td></tr>';
627  }
628 
629  print "</table>";
630  print "</div>";
631  print '</form>';
632 } else {
633  dol_print_error($db);
634 }
635 
636 // End of page
637 llxFooter();
638 $db->close();
ajax_combobox
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:438
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
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
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
$form
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
Definition: card.php:142
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
img_picto
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Definition: functions.lib.php:3880
img_delete
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
Definition: functions.lib.php:4429
$formconfirm
$formconfirm
if ($action == 'delbookkeepingyear') {
Definition: listbyaccount.php:576
dolGetButtonTitle
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
Definition: functions.lib.php:10605
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
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
newToken
newToken()
Return the value of token currently saved into session with name 'newtoken'.
Definition: functions.lib.php:10878
dolibarr_set_const
dolibarr_set_const($db, $name, $value, $type='chaine', $visible=0, $note='', $entity=1)
Insert a parameter (key,value) into database (delete old key then insert it again).
Definition: admin.lib.php:627
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
natural_search
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
Definition: functions.lib.php:9420
Form
Class to manage generation of HTML components Only common components must be here.
Definition: html.form.class.php:52
run_sql
run_sql($sqlfile, $silent=1, $entity='', $usesavepoint=1, $handler='', $okerror='default', $linelengthlimit=32768, $nocommentremoval=0, $offsetforchartofaccount=0, $colspan=0, $onlysqltoimportwebsite=0)
Launch a sql file.
Definition: admin.lib.php:167
$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
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
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