dolibarr  13.0.2
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 $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'accountingaccountlist'; // To manage different context of search
42 
43 $search_account = GETPOST('search_account', 'alpha');
44 $search_label = GETPOST('search_label', 'alpha');
45 $search_labelshort = GETPOST('search_labelshort', 'alpha');
46 $search_accountparent = GETPOST('search_accountparent', 'alpha');
47 $search_pcgtype = GETPOST('search_pcgtype', 'alpha');
48 
49 $chartofaccounts = GETPOST('chartofaccounts', 'int');
50 
51 // Security check
52 if ($user->socid > 0) accessforbidden();
53 if (!$user->rights->accounting->chartofaccount) accessforbidden();
54 
55 // Load variable for pagination
56 $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
57 $sortfield = GETPOST('sortfield', 'aZ09comma');
58 $sortorder = GETPOST('sortorder', 'aZ09comma');
59 $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
60 if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
61 $offset = $limit * $page;
62 $pageprev = $page - 1;
63 $pagenext = $page + 1;
64 if (!$sortfield) $sortfield = "aa.account_number";
65 if (!$sortorder) $sortorder = "ASC";
66 
67 $arrayfields = array(
68  'aa.account_number'=>array('label'=>$langs->trans("AccountNumber"), 'checked'=>1),
69  'aa.label'=>array('label'=>$langs->trans("Label"), 'checked'=>1),
70  'aa.labelshort'=>array('label'=>$langs->trans("LabelToShow"), 'checked'=>1),
71  'aa.account_parent'=>array('label'=>$langs->trans("Accountparent"), 'checked'=>1),
72  'aa.pcg_type'=>array('label'=>$langs->trans("Pcgtype"), 'checked'=>1, 'help'=>'PcgtypeDesc'),
73  'aa.reconcilable'=>array('label'=>$langs->trans("Reconcilable"), 'checked'=>1),
74  'aa.active'=>array('label'=>$langs->trans("Activated"), 'checked'=>1)
75 );
76 
77 if ($conf->global->MAIN_FEATURES_LEVEL < 2) unset($arrayfields['aa.reconcilable']);
78 
79 $accounting = new AccountingAccount($db);
80 
81 
82 
83 /*
84  * Actions
85  */
86 
87 if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
88 if (!GETPOST('confirmmassaction', 'alpha')) { $massaction = ''; }
89 
90 $parameters = array();
91 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
92 if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
93 
94 if (empty($reshook))
95 {
96  if (!empty($cancel)) $action = '';
97 
98  include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
99 
100  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
101  {
102  $search_account = "";
103  $search_label = "";
104  $search_labelshort = "";
105  $search_accountparent = "";
106  $search_pcgtype = "";
107  $search_array_options = array();
108  }
109  if ((GETPOST('valid_change_chart', 'alpha') && GETPOST('chartofaccounts', 'int') > 0) // explicit click on button 'Change and load' with js on
110  || (GETPOST('chartofaccounts', 'int') > 0 && GETPOST('chartofaccounts', 'int') != $conf->global->CHARTOFACCOUNTS)) // a submit of form is done and chartofaccounts combo has been modified
111  {
112  if ($chartofaccounts > 0)
113  {
114  // Get language code for this $chartofaccounts
115  $sql = 'SELECT code FROM '.MAIN_DB_PREFIX.'c_country as c, '.MAIN_DB_PREFIX.'accounting_system as a';
116  $sql .= ' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts;
117  $resql = $db->query($sql);
118  if ($resql)
119  {
120  $obj = $db->fetch_object($resql);
121  $country_code = $obj->code;
122  } else dol_print_error($db);
123 
124  // Try to load sql file
125  if ($country_code)
126  {
127  $sqlfile = DOL_DOCUMENT_ROOT.'/install/mysql/data/llx_accounting_account_'.strtolower($country_code).'.sql';
128 
129  $offsetforchartofaccount = 0;
130  // Get the comment line '-- ADD CCCNNNNN to rowid...' to find CCCNNNNN (CCC is country num, NNNNN is id of accounting account)
131  // 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.
132  // This is to be sure there is no conflict for each chart of account, whatever is country, whatever is company when multicompany is used.
133  $tmp = file_get_contents($sqlfile);
134  $reg = array();
135  if (preg_match('/-- ADD (\d+) to rowid/ims', $tmp, $reg))
136  {
137  $offsetforchartofaccount += $reg[1];
138  }
139  $offsetforchartofaccount += ($conf->entity * 100000000);
140 
141  $result = run_sql($sqlfile, 1, $conf->entity, 1, '', 'default', 32768, 0, $offsetforchartofaccount);
142 
143  if ($result > 0)
144  {
145  setEventMessages($langs->trans("ChartLoaded"), null, 'mesgs');
146  } else {
147  setEventMessages($langs->trans("ErrorDuringChartLoad"), null, 'warnings');
148  }
149  }
150 
151  if (!dolibarr_set_const($db, 'CHARTOFACCOUNTS', $chartofaccounts, 'chaine', 0, '', $conf->entity)) {
152  $error++;
153  }
154  } else {
155  $error++;
156  }
157  }
158 
159  if ($action == 'disable') {
160  if ($accounting->fetch($id)) {
161  $mode = GETPOST('mode', 'int');
162  $result = $accounting->accountDeactivate($id, $mode);
163  }
164 
165  $action = 'update';
166  if ($result < 0) {
167  setEventMessages($accounting->error, $accounting->errors, 'errors');
168  }
169  } elseif ($action == 'enable') {
170  if ($accounting->fetch($id)) {
171  $mode = GETPOST('mode', 'int');
172  $result = $accounting->account_activate($id, $mode);
173  }
174  $action = 'update';
175  if ($result < 0) {
176  setEventMessages($accounting->error, $accounting->errors, 'errors');
177  }
178  }
179 }
180 
181 
182 /*
183  * View
184  */
185 
186 $form = new Form($db);
187 $formaccounting = new FormAccounting($db);
188 
189 llxHeader('', $langs->trans("ListAccounts"));
190 
191 if ($action == 'delete') {
192  $formconfirm = $html->formconfirm($_SERVER["PHP_SELF"].'?id='.$id, $langs->trans('DeleteAccount'), $langs->trans('ConfirmDeleteAccount'), 'confirm_delete', '', 0, 1);
193  print $formconfirm;
194 }
195 
196 $pcgver = $conf->global->CHARTOFACCOUNTS;
197 
198 $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, ";
199 $sql .= " a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2";
200 $sql .= " FROM ".MAIN_DB_PREFIX."accounting_account as aa";
201 $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".$conf->entity;
202 if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity;
203 else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity;
204 $sql .= " WHERE asy.rowid = ".$pcgver;
205 //print $sql;
206 if (strlen(trim($search_account))) {
207  $lengthpaddingaccount = 0;
208  if ($conf->global->ACCOUNTING_LENGTH_GACCOUNT || $conf->global->ACCOUNTING_LENGTH_AACCOUNT) {
209  $lengthpaddingaccount = max($conf->global->ACCOUNTING_LENGTH_GACCOUNT, $conf->global->ACCOUNTING_LENGTH_AACCOUNT);
210  }
211  $search_account_tmp = $search_account;
212  $weremovedsomezero = 0;
213  if (strlen($search_account_tmp) <= $lengthpaddingaccount) {
214  for ($i = 0; $i < $lengthpaddingaccount; $i++) {
215  if (preg_match('/0$/', $search_account_tmp)) {
216  $weremovedsomezero++;
217  $search_account_tmp = preg_replace('/0$/', '', $search_account_tmp);
218  }
219  }
220  }
221 
222  //var_dump($search_account); exit;
223  if ($search_account_tmp) {
224  if ($weremovedsomezero) {
225  $search_account_tmp_clean = $search_account_tmp;
226  $search_account_clean = $search_account;
227  $startchar = '%';
228  if (strpos($search_account_tmp, '^') === 0)
229  {
230  $startchar = '';
231  $search_account_tmp_clean = preg_replace('/^\^/', '', $search_account_tmp);
232  $search_account_clean = preg_replace('/^\^/', '', $search_account);
233  }
234  $sql .= " AND (aa.account_number LIKE '".$db->escape($startchar.$search_account_tmp_clean)."'";
235  $sql .= " OR aa.account_number LIKE '".$db->escape($startchar.$search_account_clean)."%')";
236  } else $sql .= natural_search("aa.account_number", $search_account_tmp);
237  }
238 }
239 if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label);
240 if (strlen(trim($search_labelshort))) $sql .= natural_search("aa.labelshort", $search_labelshort);
241 if (strlen(trim($search_accountparent)) && $search_accountparent != '-1') $sql .= natural_search("aa.account_parent", $search_accountparent, 2);
242 if (strlen(trim($search_pcgtype))) $sql .= natural_search("aa.pcg_type", $search_pcgtype);
243 $sql .= $db->order($sortfield, $sortorder);
244 
245 // Count total nb of records
246 $nbtotalofrecords = '';
247 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
248 {
249  $resql = $db->query($sql);
250  $nbtotalofrecords = $db->num_rows($resql);
251  if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
252  {
253  $page = 0;
254  $offset = 0;
255  }
256 }
257 
258 $sql .= $db->plimit($limit + 1, $offset);
259 
260 dol_syslog('accountancy/admin/account.php:: $sql='.$sql);
261 $resql = $db->query($sql);
262 
263 if ($resql)
264 {
265  $num = $db->num_rows($resql);
266 
267  $param = '';
268  if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
269  if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
270  if ($search_account) $param .= '&search_account='.urlencode($search_account);
271  if ($search_label) $param .= '&search_label='.urlencode($search_label);
272  if ($search_labelshort) $param .= '&search_labelshort='.urlencode($search_labelshort);
273  if ($search_accountparent > 0 || $search_accountparent == '0') $param .= '&search_accountparent='.urlencode($search_accountparent);
274  if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype);
275  if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
276 
277  if (!empty($conf->use_javascript_ajax))
278  {
279  print '<!-- Add javascript to reload page when we click "Change plan" -->
280  <script type="text/javascript">
281  $(document).ready(function () {
282  $("#change_chart").on("click", function (e) {
283  console.log("chartofaccounts seleted = "+$("#chartofaccounts").val());
284  // reload page
285  window.location.href = "'.$_SERVER["PHP_SELF"].'?valid_change_chart=1&chartofaccounts="+$("#chartofaccounts").val();
286  });
287  });
288  </script>';
289  }
290 
291  print '<form method="POST" id="searchFormList" action="'.$_SERVER["PHP_SELF"].'">';
292  if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
293  print '<input type="hidden" name="token" value="'.newToken().'">';
294  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
295  print '<input type="hidden" name="action" value="list">';
296  print '<input type="hidden" name="sortfield" value="'.$sortfield.'">';
297  print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
298  print '<input type="hidden" name="contextpage" value="'.$contextpage.'">';
299 
300  $newcardbutton .= dolGetButtonTitle($langs->trans("New"), $langs->trans("Addanaccount"), 'fa fa-plus-circle', './card.php?action=create');
301 
302  print_barre_liste($langs->trans('ListAccounts'), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1);
303 
304  // Box to select active chart of account
305  print $langs->trans("Selectchartofaccounts")." : ";
306  print '<select class="flat minwidth200" name="chartofaccounts" id="chartofaccounts">';
307  $sql = "SELECT a.rowid, a.pcg_version, a.label, a.active, c.code as country_code";
308  $sql .= " FROM ".MAIN_DB_PREFIX."accounting_system as a";
309  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_country as c ON a.fk_country = c.rowid AND c.active = 1";
310  $sql .= " WHERE a.active = 1";
311  dol_syslog('accountancy/admin/account.php $sql='.$sql);
312  print $sql;
313  $resqlchart = $db->query($sql);
314  if ($resqlchart) {
315  $numbis = $db->num_rows($resqlchart);
316  $i = 0;
317  print '<option value="-1">&nbsp;</option>';
318  while ($i < $numbis) {
319  $obj = $db->fetch_object($resqlchart);
320 
321  print '<option value="'.$obj->rowid.'"';
322  print ($pcgver == $obj->rowid) ? ' selected' : '';
323  print '>'.$obj->pcg_version.' - '.$obj->label.' - ('.$obj->country_code.')</option>';
324 
325  $i++;
326  }
327  } else dol_print_error($db);
328  print "</select>";
329  print ajax_combobox("chartofaccounts");
330  print '<input type="'.(empty($conf->use_javascript_ajax) ? 'submit' : 'button').'" class="button" name="change_chart" id="change_chart" value="'.dol_escape_htmltag($langs->trans("ChangeAndLoad")).'">';
331 
332  print '<br>';
333  print '<br>';
334 
335  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
336  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
337 
338  $moreforfilter = '';
339  $massactionbutton = '';
340 
341  print '<div class="div-table-responsive">';
342  print '<table class="tagtable liste'.($moreforfilter ? " listwithfilterbefore" : "").'">'."\n";
343 
344  // Line for search fields
345  print '<tr class="liste_titre_filter">';
346  if (!empty($arrayfields['aa.account_number']['checked'])) print '<td class="liste_titre"><input type="text" class="flat width100" name="search_account" value="'.$search_account.'"></td>';
347  if (!empty($arrayfields['aa.label']['checked'])) print '<td class="liste_titre"><input type="text" class="flat width150" name="search_label" value="'.$search_label.'"></td>';
348  if (!empty($arrayfields['aa.labelshort']['checked'])) print '<td class="liste_titre"><input type="text" class="flat width100" name="search_labelshort" value="'.$search_labelshort.'"></td>';
349  if (!empty($arrayfields['aa.account_parent']['checked'])) {
350  print '<td class="liste_titre">';
351  print $formaccounting->select_account($search_accountparent, 'search_accountparent', 2);
352  print '</td>';
353  }
354  if (!empty($arrayfields['aa.pcg_type']['checked'])) print '<td class="liste_titre"><input type="text" class="flat width100" name="search_pcgtype" value="'.$search_pcgtype.'"></td>';
355  if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) print '<td class="liste_titre">&nbsp;</td>'; }
356  if (!empty($arrayfields['aa.active']['checked'])) print '<td class="liste_titre">&nbsp;</td>';
357  print '<td class="liste_titre maxwidthsearch">';
358  $searchpicto = $form->showFilterAndCheckAddButtons($massactionbutton ? 1 : 0, 'checkforselect', 1);
359  print $searchpicto;
360  print '</td>';
361  print '</tr>';
362 
363  print '<tr class="liste_titre">';
364  if (!empty($arrayfields['aa.account_number']['checked'])) print_liste_field_titre($arrayfields['aa.account_number']['label'], $_SERVER["PHP_SELF"], "aa.account_number", "", $param, '', $sortfield, $sortorder);
365  if (!empty($arrayfields['aa.label']['checked'])) print_liste_field_titre($arrayfields['aa.label']['label'], $_SERVER["PHP_SELF"], "aa.label", "", $param, '', $sortfield, $sortorder);
366  if (!empty($arrayfields['aa.labelshort']['checked'])) print_liste_field_titre($arrayfields['aa.labelshort']['label'], $_SERVER["PHP_SELF"], "aa.labelshort", "", $param, '', $sortfield, $sortorder);
367  if (!empty($arrayfields['aa.account_parent']['checked'])) print_liste_field_titre($arrayfields['aa.account_parent']['label'], $_SERVER["PHP_SELF"], "aa.account_parent", "", $param, '', $sortfield, $sortorder, 'left ');
368  if (!empty($arrayfields['aa.pcg_type']['checked'])) print_liste_field_titre($arrayfields['aa.pcg_type']['label'], $_SERVER["PHP_SELF"], 'aa.pcg_type', '', $param, '', $sortfield, $sortorder, '', $arrayfields['aa.pcg_type']['help']);
369  if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { if (!empty($arrayfields['aa.reconcilable']['checked'])) print_liste_field_titre($arrayfields['aa.reconcilable']['label'], $_SERVER["PHP_SELF"], 'aa.reconcilable', '', $param, '', $sortfield, $sortorder); }
370  if (!empty($arrayfields['aa.active']['checked'])) print_liste_field_titre($arrayfields['aa.active']['label'], $_SERVER["PHP_SELF"], 'aa.active', '', $param, '', $sortfield, $sortorder);
371  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'center maxwidthsearch ');
372  print "</tr>\n";
373 
374  $accountstatic = new AccountingAccount($db);
375  $accountparent = new AccountingAccount($db);
376 
377  $totalarray = array();
378  $i = 0;
379  while ($i < min($num, $limit))
380  {
381  $obj = $db->fetch_object($resql);
382 
383  $accountstatic->id = $obj->rowid;
384  $accountstatic->label = $obj->label;
385  $accountstatic->account_number = $obj->account_number;
386 
387  print '<tr class="oddeven">';
388 
389  // Account number
390  if (!empty($arrayfields['aa.account_number']['checked']))
391  {
392  print "<td>";
393  print $accountstatic->getNomUrl(1, 0, 0, '', 0, 1, 0, 'accountcard');
394  print "</td>\n";
395  if (!$i) $totalarray['nbfield']++;
396  }
397 
398  // Account label
399  if (!empty($arrayfields['aa.label']['checked']))
400  {
401  print "<td>";
402  print $obj->label;
403  print "</td>\n";
404  if (!$i) $totalarray['nbfield']++;
405  }
406 
407  // Account label to show (label short)
408  if (!empty($arrayfields['aa.labelshort']['checked']))
409  {
410  print "<td>";
411  print $obj->labelshort;
412  print "</td>\n";
413  if (!$i) $totalarray['nbfield']++;
414  }
415 
416  // Account parent
417  if (!empty($arrayfields['aa.account_parent']['checked']))
418  {
419  // 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.
420  // So for orphans, obj->account_parent is set but not obj->rowid2
421  if (!empty($obj->account_parent) && !empty($obj->rowid2))
422  {
423  print "<td>";
424  print '<!-- obj->account_parent = '.$obj->account_parent.' obj->rowid2 = '.$obj->rowid2.' -->';
425  $accountparent->id = $obj->rowid2;
426  $accountparent->label = $obj->label2;
427  $accountparent->account_number = $obj->account_number2; // Sotre an account number for output
428  print $accountparent->getNomUrl(1);
429  print "</td>\n";
430  if (!$i) $totalarray['nbfield']++;
431  } else {
432  print '<td>';
433  if (!empty($obj->account_parent)) {
434  print '<!-- Bad value for obj->account_parent = '.$obj->account_parent.': is a rowid that does not exists -->';
435  }
436  print '</td>';
437  if (!$i) $totalarray['nbfield']++;
438  }
439  }
440 
441  // Chart of accounts type
442  if (!empty($arrayfields['aa.pcg_type']['checked']))
443  {
444  print "<td>";
445  print $obj->pcg_type;
446  print "</td>\n";
447  if (!$i) $totalarray['nbfield']++;
448  }
449 
450  if ($conf->global->MAIN_FEATURES_LEVEL >= 2) {
451  // Activated or not reconciliation on accounting account
452  if (!empty($arrayfields['aa.reconcilable']['checked'])) {
453  print '<td class="center">';
454  if (empty($obj->reconcilable)) {
455  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable&mode=1">';
456  print img_picto($langs->trans("Disabled"), 'switch_off');
457  print '</a>';
458  } else {
459  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=disable&mode=1">';
460  print img_picto($langs->trans("Activated"), 'switch_on');
461  print '</a>';
462  }
463  print '</td>';
464  if (!$i) {
465  $totalarray['nbfield']++;
466  }
467  }
468  }
469 
470  // Activated or not
471  if (!empty($arrayfields['aa.active']['checked']))
472  {
473  print '<td class="center">';
474  if (empty($obj->active)) {
475  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=enable&mode=0">';
476  print img_picto($langs->trans("Disabled"), 'switch_off');
477  print '</a>';
478  } else {
479  print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=disable&mode=0">';
480  print img_picto($langs->trans("Activated"), 'switch_on');
481  print '</a>';
482  }
483  print '</td>';
484  if (!$i) $totalarray['nbfield']++;
485  }
486 
487  // Action
488  print '<td class="center">';
489  if ($user->rights->accounting->chartofaccount) {
490  print '<a class="editfielda" href="./card.php?action=update&token='.newToken().'&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?'.$param).'">';
491  print img_edit();
492  print '</a>';
493  print '&nbsp;';
494  print '<a class="marginleftonly" href="./card.php?action=delete&token='.newToken().'&id='.$obj->rowid.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?'.$param).'">';
495  print img_delete();
496  print '</a>';
497  }
498  print '</td>'."\n";
499  if (!$i) $totalarray['nbfield']++;
500 
501  print "</tr>\n";
502  $i++;
503  }
504 
505  print "</table>";
506  print "</div>";
507  print '</form>';
508 } else {
509  dol_print_error($db);
510 }
511 
512 // End of page
513 llxFooter();
514 $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.
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.
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:575
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete= 'resolve')
Convert a html select field into an ajax combobox.
Definition: ajax.lib.php:391
llxHeader()
Empty header.
Definition: wrapper.php:45
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.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it&#39;s its name (generic function)
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
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 ...
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...
run_sql($sqlfile, $silent=1, $entity= '', $usesavepoint=1, $handler= '', $okerror= 'default', $linelengthlimit=32768, $nocommentremoval=0, $offsetforchartofaccount=0)
Launch a sql file.
Definition: admin.lib.php:161
print $_SERVER["PHP_SELF"]
Edit parameters.
print
Draft customers invoices.
Definition: index.php:89
Class to manage generation of HTML components for accounting management.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
Definition: index.php:1232
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Class to manage accounting accounts.
llxFooter()
Empty footer.
Definition: wrapper.php:59
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...