28require 
'../../main.inc.php';
 
   29require_once DOL_DOCUMENT_ROOT.
'/core/lib/admin.lib.php';
 
   30require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
 
   31require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
 
   32require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
 
   35$langs->loadLangs(array(
'accountancy', 
'admin', 
'bills', 
'compta', 
'salaries'));
 
   37$action = 
GETPOST(
'action', 
'aZ09');
 
   38$cancel = 
GETPOST(
'cancel', 
'alpha');
 
   41$massaction = 
GETPOST(
'massaction', 
'aZ09');
 
   42$optioncss = 
GETPOST(
'optioncss', 
'alpha');
 
   43$contextpage = 
GETPOST(
'contextpage', 
'aZ') ? 
GETPOST(
'contextpage', 
'aZ') : 
'accountingaccountlist'; 
 
   46$search_account = 
GETPOST(
'search_account', 
'alpha');
 
   47$search_label = 
GETPOST(
'search_label', 
'alpha');
 
   48$search_labelshort = 
GETPOST(
'search_labelshort', 
'alpha');
 
   49$search_accountparent = 
GETPOST(
'search_accountparent', 
'alpha');
 
   50$search_pcgtype = 
GETPOST(
'search_pcgtype', 
'alpha');
 
   51$search_import_key = 
GETPOST(
'search_import_key', 
'alpha');
 
   52$toselect = 
GETPOST(
'toselect', 
'array');
 
   54$confirm = 
GETPOST(
'confirm', 
'alpha');
 
   56$chartofaccounts = 
GETPOSTINT(
'chartofaccounts');
 
   58$permissiontoadd = $user->hasRight(
'accounting', 
'chartofaccount');
 
   59$permissiontodelete = $user->hasRight(
'accounting', 
'chartofaccount');
 
   62if ($user->socid > 0) {
 
   65if (!$user->hasRight(
'accounting', 
'chartofaccount')) {
 
   71$sortfield = 
GETPOST(
'sortfield', 
'aZ09comma');
 
   72$sortorder = 
GETPOST(
'sortorder', 
'aZ09comma');
 
   74if (empty($page) || $page == -1) {
 
   77$offset = $limit * $page;
 
   81  $sortfield = 
"aa.account_number";
 
   88  'aa.account_number' => array(
'label' => 
"AccountNumber", 
'checked' => 1),
 
   89  'aa.label' => array(
'label' => 
"Label", 
'checked' => 1),
 
   90  'aa.labelshort' => array(
'label' => 
"LabelToShow", 
'checked' => 1),
 
   91  'aa.account_parent' => array(
'label' => 
"Accountparent", 
'checked' => 1),
 
   92  'aa.pcg_type' => array(
'label' => 
"Pcgtype", 
'checked' => 1, 
'help' => 
'PcgtypeDesc'),
 
   93  'categories' => array(
'label' => 
"AccountingCategories", 
'checked' => -1, 
'help' => 
'AccountingCategoriesDesc'),
 
   94  'aa.reconcilable' => array(
'label' => 
"Reconcilable", 
'checked' => 1),
 
   95  'aa.import_key' => array(
'label' => 
"ImportId", 
'checked' => -1, 
'help' => 
''),
 
   96  'aa.active' => array(
'label' => 
"Activated", 
'checked' => 1)
 
  100  unset($arrayfields[
'categories']);
 
  101  unset($arrayfields[
'aa.reconcilable']);
 
  107$hookmanager->initHooks(array(
'accountancyadminaccount'));
 
  114if (
GETPOST(
'cancel', 
'alpha')) {
 
  118if (!
GETPOST(
'confirmmassaction', 
'alpha')) {
 
  122$parameters = array(
'chartofaccounts' => $chartofaccounts, 
'permissiontoadd' => $permissiontoadd, 
'permissiontodelete' => $permissiontodelete);
 
  123$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $accounting, $action); 
 
  128if (empty($reshook)) {
 
  129  if (!empty($cancel)) {
 
  133  $objectclass = 
'AccountingAccount';
 
  134  $uploaddir = $conf->accounting->multidir_output[$conf->entity];
 
  135  include DOL_DOCUMENT_ROOT.
'/core/actions_massactions.inc.php';
 
  137  if ($action == 
"delete") {
 
  140  include DOL_DOCUMENT_ROOT.
'/core/actions_changeselectedfields.inc.php';
 
  142  if (
GETPOST(
'button_removefilter_x', 
'alpha') || 
GETPOST(
'button_removefilter.x', 
'alpha') || 
GETPOST(
'button_removefilter', 
'alpha')) { 
 
  143    $search_account = 
"";
 
  145    $search_labelshort = 
"";
 
  146    $search_accountparent = 
"";
 
  147    $search_pcgtype = 
"";
 
  148    $search_import_key = 
"";
 
  149    $search_array_options = array();
 
  155    if ($chartofaccounts > 0 && $permissiontoadd) {
 
  158      $sql = 
'SELECT code FROM '.MAIN_DB_PREFIX.
'c_country as c, '.MAIN_DB_PREFIX.
'accounting_system as a';
 
  159      $sql .= 
' WHERE c.rowid = a.fk_country AND a.rowid = '.(int) $chartofaccounts;
 
  160      $resql = $db->query($sql);
 
  162        $obj = $db->fetch_object($resql);
 
  164          $country_code = $obj->code;
 
  172        $sqlfile = DOL_DOCUMENT_ROOT.
'/install/mysql/data/llx_accounting_account_'.strtolower($country_code).
'.sql';
 
  174        $offsetforchartofaccount = 0;
 
  178        $tmp = file_get_contents($sqlfile);
 
  180        if (preg_match(
'/-- ADD (\d+) to rowid/ims', $tmp, $reg)) {
 
  181          $offsetforchartofaccount += $reg[1];
 
  183        $offsetforchartofaccount += ($conf->entity * 100000000);
 
  185        $result = 
run_sql($sqlfile, 1, $conf->entity, 1, 
'', 
'default', 32768, 0, $offsetforchartofaccount);
 
  194      if (!
dolibarr_set_const($db, 
'CHARTOFACCOUNTS', $chartofaccounts, 
'chaine', 0, 
'', $conf->entity)) {
 
  202  if ($action == 
'disable' && $permissiontoadd) {
 
  203    if ($accounting->fetch($id)) {
 
  205      $result = $accounting->accountDeactivate($id, $mode);
 
  212  } elseif ($action == 
'enable' && $permissiontoadd) {
 
  213    if ($accounting->fetch($id)) {
 
  215      $result = $accounting->accountActivate($id, $mode);
 
  228$form = 
new Form($db);
 
  231$help_url = 
'EN:Module_Double_Entry_Accounting#Setup|FR:Module_Comptabilité_en_Partie_Double#Configuration';
 
  233llxHeader(
'', $langs->trans(
"ListAccounts"), $help_url);
 
  235if ($action == 
'delete') {
 
  236  $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
'?id='.$id, $langs->trans(
'DeleteAccount'), $langs->trans(
'ConfirmDeleteAccount'), 
'confirm_delete', 
'', 0, 1);
 
  242$sql = 
"SELECT aa.rowid, aa.fk_pcg_version, aa.pcg_type, aa.account_number, aa.account_parent, aa.label, aa.labelshort, aa.fk_accounting_category,";
 
  243$sql .= 
" aa.reconcilable, aa.active, aa.import_key,";
 
  244$sql .= 
" a2.rowid as rowid2, a2.label as label2, a2.account_number as account_number2";
 
  247$parameters = array();
 
  248$reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters, 
$object, $action); 
 
  249$sql .= $hookmanager->resPrint;
 
  250$sql = preg_replace(
'/,\s*$/', 
'', $sql);
 
  252$sql .= 
" FROM ".MAIN_DB_PREFIX.
"accounting_account as aa";
 
  253$sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_system as asy ON aa.fk_pcg_version = asy.pcg_version AND aa.entity = ".((int) $conf->entity);
 
  254$sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".((int) $conf->entity);
 
  257$parameters = array();
 
  258$reshook = $hookmanager->executeHooks(
'printFieldListFrom', $parameters, 
$object); 
 
  259$sql .= $hookmanager->resPrint;
 
  261$sql .= 
" WHERE asy.rowid = ".((int) $pcgver);
 
  263if (strlen(trim($search_account))) {
 
  264  $lengthpaddingaccount = 0;
 
  268  $search_account_tmp = $search_account;
 
  269  $weremovedsomezero = 0;
 
  270  if (strlen($search_account_tmp) <= $lengthpaddingaccount) {
 
  271    for ($i = 0; $i < $lengthpaddingaccount; $i++) {
 
  272      if (preg_match(
'/0$/', $search_account_tmp)) {
 
  273        $weremovedsomezero++;
 
  274        $search_account_tmp = preg_replace(
'/0$/', 
'', $search_account_tmp);
 
  280  if ($search_account_tmp) {
 
  281    if ($weremovedsomezero) {
 
  282      $search_account_tmp_clean = $search_account_tmp;
 
  283      $search_account_clean = $search_account;
 
  285      if (substr($search_account_tmp, 0, 1) === 
'^') {
 
  287        $search_account_tmp_clean = preg_replace(
'/^\^/', 
'', $search_account_tmp);
 
  288        $search_account_clean = preg_replace(
'/^\^/', 
'', $search_account);
 
  290      $sql .= 
" AND (aa.account_number LIKE '".$db->escape($startchar.$search_account_tmp_clean).
"'";
 
  291      $sql .= 
" OR aa.account_number LIKE '".$db->escape($startchar.$search_account_clean).
"%')";
 
  297if (strlen(trim($search_label))) {
 
  300if (strlen(trim($search_labelshort))) {
 
  303if (strlen(trim($search_accountparent)) && $search_accountparent != 
'-1') {
 
  304  $sql .= 
natural_search(
"aa.account_parent", $search_accountparent, 2);
 
  306if (strlen(trim($search_pcgtype))) {
 
  309if (strlen(trim($search_import_key))) {
 
  314$parameters = array();
 
  315$reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters, 
$object, $action); 
 
  316$sql .= $hookmanager->resPrint;
 
  318$sql .= $db->order($sortfield, $sortorder);
 
  322$nbtotalofrecords = 
'';
 
  324  $resql = $db->query($sql);
 
  325  $nbtotalofrecords = $db->num_rows($resql);
 
  326  if (($page * $limit) > $nbtotalofrecords) { 
 
  332$sql .= $db->plimit($limit + 1, $offset);
 
  334dol_syslog(
"accountancy/admin/account.php:: sql=".$sql);
 
  335$resql = $db->query($sql);
 
  338  $num = $db->num_rows($resql);
 
  340  $arrayofselected = is_array($toselect) ? $toselect : array();
 
  343  if (!empty($contextpage) && $contextpage != $_SERVER[
"PHP_SELF"]) {
 
  344    $param .= 
'&contextpage='.urlencode($contextpage);
 
  346  if ($limit > 0 && $limit != $conf->liste_limit) {
 
  347    $param .= 
'&limit='.((int) $limit);
 
  349  if ($search_account) {
 
  350    $param .= 
'&search_account='.urlencode($search_account);
 
  353    $param .= 
'&search_label='.urlencode($search_label);
 
  355  if ($search_labelshort) {
 
  356    $param .= 
'&search_labelshort='.urlencode($search_labelshort);
 
  358  if ($search_accountparent > 0 || $search_accountparent == 
'0') {
 
  359    $param .= 
'&search_accountparent='.urlencode($search_accountparent);
 
  361  if ($search_pcgtype) {
 
  362    $param .= 
'&search_pcgtype='.urlencode($search_pcgtype);
 
  364  if ($search_import_key) {
 
  365    $param .= 
'&search_import_key='.urlencode($search_import_key);
 
  367  if ($optioncss != 
'') {
 
  368    $param .= 
'&optioncss='.urlencode($optioncss);
 
  372  $parameters = array();
 
  373  $reshook = $hookmanager->executeHooks(
'printFieldListSearchParam', $parameters, 
$object, $action); 
 
  374  $param .= $hookmanager->resPrint;
 
  376  if (!empty($conf->use_javascript_ajax)) {
 
  377    print 
'<!-- Add javascript to reload page when we click "Change plan" --> 
  378      <script type="text/javascript"> 
  379      $(document).ready(function () { 
  380          $("#change_chart").on("click", function (e) { 
  381          console.log("chartofaccounts selected = "+$("#chartofaccounts").val()); 
  383          window.location.href = "'.$_SERVER[
"PHP_SELF"].
'?valid_change_chart=1&chartofaccounts="+$("#chartofaccounts").val(); 
  390  $arrayofmassactions = array();
 
  391  if ($user->hasRight(
'accounting', 
'chartofaccount')) {
 
  392    $arrayofmassactions[
'predelete'] = 
'<span class="fa fa-trash paddingrightonly"></span>'.$langs->trans(
"Delete");
 
  394  if (in_array($massaction, array(
'presend', 
'predelete', 
'closed'))) {
 
  395    $arrayofmassactions = array();
 
  398  $massactionbutton = $form->selectMassAction(
'', $arrayofmassactions);
 
  401  $newcardbutton = 
dolGetButtonTitle($langs->trans(
'Addanaccount'), 
'', 
'fa fa-plus-circle', DOL_URL_ROOT.
'/accountancy/admin/card.php?action=create', 
'', $permissiontoadd);
 
  404  print 
'<form method="POST" id="searchFormList" action="'.$_SERVER[
"PHP_SELF"].
'">';
 
  405  if ($optioncss != 
'') {
 
  406    print 
'<input type="hidden" name="optioncss" value="'.$optioncss.
'">';
 
  408  print 
'<input type="hidden" name="token" value="'.newToken().
'">';
 
  409  print 
'<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
 
  410  print 
'<input type="hidden" name="action" value="list">';
 
  411  print 
'<input type="hidden" name="sortfield" value="'.$sortfield.
'">';
 
  412  print 
'<input type="hidden" name="sortorder" value="'.$sortorder.
'">';
 
  413  print 
'<input type="hidden" name="contextpage" value="'.$contextpage.
'">';
 
  416  print_barre_liste($langs->trans(
'ListAccounts'), $page, $_SERVER[
"PHP_SELF"], $param, $sortfield, $sortorder, $massactionbutton, $num, $nbtotalofrecords, 
'accounting_account', 0, $newcardbutton, 
'', $limit, 0, 0, 1);
 
  418  include DOL_DOCUMENT_ROOT.
'/core/tpl/massactions_pre.tpl.php';
 
  421  print $langs->trans(
"Selectchartofaccounts").
" : ";
 
  422  print 
'<select class="flat minwidth200" name="chartofaccounts" id="chartofaccounts">';
 
  423  $sql = 
"SELECT a.rowid, a.pcg_version, a.label, a.active, c.code as country_code";
 
  424  $sql .= 
" FROM ".MAIN_DB_PREFIX.
"accounting_system as a";
 
  425  $sql .= 
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_country as c ON a.fk_country = c.rowid AND c.active = 1";
 
  426  $sql .= 
" WHERE a.active = 1";
 
  428  dol_syslog(
"accountancy/admin/account.php sql=".$sql);
 
  430  $resqlchart = $db->query($sql);
 
  432    $numbis = $db->num_rows($resqlchart);
 
  434    print 
'<option value="-1"> </option>';
 
  435    while ($i < $numbis) {
 
  436      $obj = $db->fetch_object($resqlchart);
 
  438        print 
'<option value="'.$obj->rowid.
'"';
 
  439        print ($pcgver == $obj->rowid) ? 
' selected' : 
'';
 
  440        print 
'>'.$obj->pcg_version.
' - '.$obj->label.
' - ('.$obj->country_code.
')</option>';
 
  449  print 
'<input type="'.(empty($conf->use_javascript_ajax) ? 
'submit' : 
'button').
'" class="button button-edit small" name="change_chart" id="change_chart" value="'.
dol_escape_htmltag($langs->trans(
"ChangeAndLoad")).
'">';
 
  453  $parameters = array(
'chartofaccounts' => $chartofaccounts, 
'permissiontoadd' => $permissiontoadd, 
'permissiontodelete' => $permissiontodelete);
 
  454  $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $accounting, $action); 
 
  455  print $hookmanager->resPrint;
 
  457  $parameters = array();
 
  458  $reshook = $hookmanager->executeHooks(
'printFieldPreListTitle', $parameters, 
$object, $action); 
 
  459  print $hookmanager->resPrint;
 
  463  $varpage = empty($contextpage) ? $_SERVER[
"PHP_SELF"] : $contextpage;
 
  464  $htmlofselectarray = $form->multiSelectArrayWithCheckbox(
'selectedfields', $arrayfields, $varpage, 
getDolGlobalString(
'MAIN_CHECKBOX_LEFT_COLUMN'));  
 
  465  $selectedfields = ($mode != 
'kanban' ? $htmlofselectarray : 
'');
 
  466  $selectedfields .= (count($arrayofmassactions) ? $form->showCheckAddButtons(
'checkforselect', 1) : 
'');
 
  469  if ($moreforfilter) {
 
  470    print 
'<div class="liste_titre liste_titre_bydiv centpercent">';
 
  471    print $moreforfilter;
 
  477  $totalarray = array();
 
  478  $totalarray[
'nbfield'] = 0;
 
  480  print 
'<div class="div-table-responsive">';
 
  481  print 
'<table class="tagtable liste'.($moreforfilter ? 
" listwithfilterbefore" : 
"").
'">'.
"\n";
 
  485  print 
'<tr class="liste_titre_filter">';
 
  489    print 
'<td class="liste_titre center maxwidthsearch">';
 
  490    $searchpicto = $form->showFilterButtons(
'left');
 
  494  if (!empty($arrayfields[
'aa.account_number'][
'checked'])) {
 
  495    print 
'<td class="liste_titre"><input type="text" class="flat width100" name="search_account" value="'.$search_account.
'"></td>';
 
  497  if (!empty($arrayfields[
'aa.label'][
'checked'])) {
 
  498    print 
'<td class="liste_titre"><input type="text" class="flat width150" name="search_label" value="'.$search_label.
'"></td>';
 
  500  if (!empty($arrayfields[
'aa.labelshort'][
'checked'])) {
 
  501    print 
'<td class="liste_titre"><input type="text" class="flat width100" name="search_labelshort" value="'.$search_labelshort.
'"></td>';
 
  503  if (!empty($arrayfields[
'aa.account_parent'][
'checked'])) {
 
  504    print 
'<td class="liste_titre">';
 
  505    print $formaccounting->select_account($search_accountparent, 
'search_accountparent', 2, array(), 0, 0, 
'maxwidth150');
 
  509  if (!empty($arrayfields[
'aa.pcg_type'][
'checked'])) {
 
  510    print 
'<td class="liste_titre"><input type="text" class="flat width75" name="search_pcgtype" value="'.$search_pcgtype.
'"></td>';
 
  513  if (!empty($arrayfields[
'categories'][
'checked'])) {
 
  514    print 
'<td class="liste_titre"></td>';
 
  518  $parameters = array(
'arrayfields' => $arrayfields);
 
  519  $reshook = $hookmanager->executeHooks(
'printFieldListOption', $parameters, 
$object, $action); 
 
  520  print $hookmanager->resPrint;
 
  523  if (!empty($arrayfields[
'aa.import_key'][
'checked'])) {
 
  524    print 
'<td class="liste_titre"><input type="text" class="flat width75" name="search_import_key" value="'.$search_import_key.
'"></td>';
 
  527    if (!empty($arrayfields[
'aa.reconcilable'][
'checked'])) {
 
  528      print 
'<td class="liste_titre"> </td>';
 
  531  if (!empty($arrayfields[
'aa.active'][
'checked'])) {
 
  532    print 
'<td class="liste_titre"> </td>';
 
  536    print 
'<td class="liste_titre center maxwidthsearch">';
 
  537    $searchpicto = $form->showFilterButtons();
 
  543  $totalarray = array();
 
  544  $totalarray[
'nbfield'] = 0;
 
  548  print 
'<tr class="liste_titre">';
 
  551    print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"], 
"", 
'', 
'', 
'', $sortfield, $sortorder, 
'center maxwidthsearch actioncolumn ');
 
  552    $totalarray[
'nbfield']++;
 
  554  if (!empty($arrayfields[
'aa.account_number'][
'checked'])) {
 
  555    print_liste_field_titre($arrayfields[
'aa.account_number'][
'label'], $_SERVER[
"PHP_SELF"], 
"aa.account_number", 
"", $param, 
'', $sortfield, $sortorder);
 
  556    $totalarray[
'nbfield']++;
 
  558  if (!empty($arrayfields[
'aa.label'][
'checked'])) {
 
  559    print_liste_field_titre($arrayfields[
'aa.label'][
'label'], $_SERVER[
"PHP_SELF"], 
"aa.label", 
"", $param, 
'', $sortfield, $sortorder);
 
  560    $totalarray[
'nbfield']++;
 
  562  if (!empty($arrayfields[
'aa.labelshort'][
'checked'])) {
 
  563    print_liste_field_titre($arrayfields[
'aa.labelshort'][
'label'], $_SERVER[
"PHP_SELF"], 
"aa.labelshort", 
"", $param, 
'', $sortfield, $sortorder);
 
  564    $totalarray[
'nbfield']++;
 
  566  if (!empty($arrayfields[
'aa.account_parent'][
'checked'])) {
 
  567    print_liste_field_titre($arrayfields[
'aa.account_parent'][
'label'], $_SERVER[
"PHP_SELF"], 
"aa.account_parent", 
"", $param, 
'', $sortfield, $sortorder, 
'left ');
 
  568    $totalarray[
'nbfield']++;
 
  570  if (!empty($arrayfields[
'aa.pcg_type'][
'checked'])) {
 
  571    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);
 
  572    $totalarray[
'nbfield']++;
 
  574  if (!empty($arrayfields[
'categories'][
'checked'])) {
 
  575    print_liste_field_titre($arrayfields[
'categories'][
'label'], $_SERVER[
"PHP_SELF"], 
'', 
'', $param, 
'', $sortfield, $sortorder, 
'', $arrayfields[
'categories'][
'help'], 1);
 
  576    $totalarray[
'nbfield']++;
 
  580  $parameters = array(
'arrayfields' => $arrayfields, 
'param' => $param, 
'sortfield' => $sortfield, 
'sortorder' => $sortorder);
 
  581  $reshook = $hookmanager->executeHooks(
'printFieldListTitle', $parameters, 
$object, $action); 
 
  582  print $hookmanager->resPrint;
 
  584  if (!empty($arrayfields[
'aa.import_key'][
'checked'])) {
 
  585    print_liste_field_titre($arrayfields[
'aa.import_key'][
'label'], $_SERVER[
"PHP_SELF"], 
'aa.import_key', 
'', $param, 
'', $sortfield, $sortorder, 
'', $arrayfields[
'aa.import_key'][
'help'], 1);
 
  586    $totalarray[
'nbfield']++;
 
  589    if (!empty($arrayfields[
'aa.reconcilable'][
'checked'])) {
 
  590      print_liste_field_titre($arrayfields[
'aa.reconcilable'][
'label'], $_SERVER[
"PHP_SELF"], 
'aa.reconcilable', 
'', $param, 
'', $sortfield, $sortorder);
 
  591      $totalarray[
'nbfield']++;
 
  594  if (!empty($arrayfields[
'aa.active'][
'checked'])) {
 
  595    print_liste_field_titre($arrayfields[
'aa.active'][
'label'], $_SERVER[
"PHP_SELF"], 
'aa.active', 
'', $param, 
'', $sortfield, $sortorder);
 
  596    $totalarray[
'nbfield']++;
 
  600    print_liste_field_titre($selectedfields, $_SERVER[
"PHP_SELF"], 
"", 
'', 
'', 
'', $sortfield, $sortorder, 
'center maxwidthsearch ');
 
  601    $totalarray[
'nbfield']++;
 
  608  while ($i < min($num, $limit)) {
 
  609    $obj = $db->fetch_object($resql);
 
  611    $accountstatic->id = $obj->rowid;
 
  612    $accountstatic->label = $obj->label;
 
  613    $accountstatic->account_number = $obj->account_number;
 
  615    print 
'<tr class="oddeven">';
 
  619      print 
'<td class="center nowraponall">';
 
  620      if ($user->hasRight(
'accounting', 
'chartofaccount')) {
 
  621        print 
'<a class="editfielda" href="./card.php?action=update&token='.newToken().
'&id='.$obj->rowid.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?'.$param).
'">';
 
  625        print 
'<a class="marginleftonly" href="./card.php?action=delete&token='.newToken().
'&id='.$obj->rowid.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?'.$param).
'">';
 
  629        if ($massactionbutton || $massaction) {   
 
  631          if (in_array($obj->rowid, $arrayofselected)) {
 
  634          print 
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ? 
' checked="checked"' : 
'').
'>';
 
  639        $totalarray[
'nbfield']++;
 
  644    if (!empty($arrayfields[
'aa.account_number'][
'checked'])) {
 
  646      print $accountstatic->getNomUrl(1, 0, 0, 
'', 0, 1, 0, 
'accountcard');
 
  649        $totalarray[
'nbfield']++;
 
  654    if (!empty($arrayfields[
'aa.label'][
'checked'])) {
 
  655      print 
'<td class="tdoverflowmax150" title="'.dol_escape_htmltag($obj->label).
'">';
 
  659        $totalarray[
'nbfield']++;
 
  664    if (!empty($arrayfields[
'aa.labelshort'][
'checked'])) {
 
  669        $totalarray[
'nbfield']++;
 
  674    if (!empty($arrayfields[
'aa.account_parent'][
'checked'])) {
 
  677      if (!empty($obj->account_parent) && !empty($obj->rowid2)) {
 
  679        print 
'<!-- obj->account_parent = '.$obj->account_parent.
' obj->rowid2 = '.$obj->rowid2.
' -->';
 
  680        $accountparent->id = $obj->rowid2;
 
  681        $accountparent->label = $obj->label2;
 
  682        $accountparent->account_number = $obj->account_number2; 
 
  683        print $accountparent->getNomUrl(1);
 
  686          $totalarray[
'nbfield']++;
 
  690        if (!empty($obj->account_parent)) {
 
  691          print 
'<!-- Bad value for obj->account_parent = '.$obj->account_parent.
': is a rowid that does not exists -->';
 
  695          $totalarray[
'nbfield']++;
 
  701    if (!empty($arrayfields[
'aa.pcg_type'][
'checked'])) {
 
  706        $totalarray[
'nbfield']++;
 
  710    if (!empty($arrayfields[
'categories'][
'checked'])) {
 
  716        $totalarray[
'nbfield']++;
 
  721    $parameters = array(
'arrayfields' => $arrayfields, 
'obj' => $obj, 
'i' => $i, 
'totalarray' => &$totalarray);
 
  722    $reshook = $hookmanager->executeHooks(
'printFieldListValue', $parameters, 
$object, $action); 
 
  723    print $hookmanager->resPrint;
 
  726    if (!empty($arrayfields[
'aa.import_key'][
'checked'])) {
 
  731        $totalarray[
'nbfield']++;
 
  737      if (!empty($arrayfields[
'aa.reconcilable'][
'checked'])) {
 
  738        print 
'<td class="center">';
 
  739        if (empty($obj->reconcilable)) {
 
  740          print 
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$obj->rowid.
'&action=enable&mode=1&token='.
newToken().
'">';
 
  741          print 
img_picto($langs->trans(
"Disabled"), 
'switch_off');
 
  744          print 
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$obj->rowid.
'&action=disable&mode=1&token='.
newToken().
'">';
 
  745          print 
img_picto($langs->trans(
"Activated"), 
'switch_on');
 
  750          $totalarray[
'nbfield']++;
 
  756    if (!empty($arrayfields[
'aa.active'][
'checked'])) {
 
  757      print 
'<td class="center">';
 
  758      if (empty($obj->active)) {
 
  759        print 
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$obj->rowid.
'&action=enable&mode=0&token='.
newToken().
'">';
 
  760        print 
img_picto($langs->trans(
"Disabled"), 
'switch_off');
 
  763        print 
'<a class="reposition" href="'.$_SERVER[
"PHP_SELF"].
'?id='.$obj->rowid.
'&action=disable&mode=0&token='.
newToken().
'">';
 
  764        print 
img_picto($langs->trans(
"Activated"), 
'switch_on');
 
  769        $totalarray[
'nbfield']++;
 
  775      print 
'<td class="center nowraponall">';
 
  776      if ($user->hasRight(
'accounting', 
'chartofaccount')) {
 
  777        print 
'<a class="editfielda" href="./card.php?action=update&token='.newToken().
'&id='.$obj->rowid.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?'.$param).
'">';
 
  781        print 
'<a class="marginleftonly" href="./card.php?action=delete&token='.newToken().
'&id='.$obj->rowid.
'&backtopage='.urlencode($_SERVER[
"PHP_SELF"].
'?'.$param).
'">';
 
  785        if ($massactionbutton || $massaction) {   
 
  787          if (in_array($obj->rowid, $arrayofselected)) {
 
  790          print 
'<input id="cb'.$obj->rowid.
'" class="flat checkforselect marginleftonly" type="checkbox" name="toselect[]" value="'.$obj->rowid.
'"'.($selected ? 
' checked="checked"' : 
'').
'>';
 
  795        $totalarray[
'nbfield']++;
 
  805    foreach ($arrayfields as $key => $val) {
 
  806      if (!empty($val[
'checked'])) {
 
  810    print 
'<tr><td colspan="'.$colspan.
'"><span class="opacitymedium">'.$langs->trans(
"None").
'</span></td></tr>';
 
  815  $parameters = array(
'arrayfields' => $arrayfields, 
'sql' => $sql);
 
  816  $reshook = $hookmanager->executeHooks(
'printFieldListFooter', $parameters, 
$object, $action); 
 
  817  print $hookmanager->resPrint;
 
  819  print 
'</table>'.
"\n";
 
  822  print 
'</form>'.
"\n";
 
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
run_sql($sqlfile, $silent=1, $entity=0, $usesavepoint=1, $handler='', $okerror='default', $linelengthlimit=32768, $nocommentremoval=0, $offsetforchartofaccount=0, $colspan=0, $onlysqltoimportwebsite=0, $database='')
Launch a sql file.
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).
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage accounting accounts.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
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...
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
print_liste_field_titre($name, $file="", $field="", $begin="", $moreparam="", $moreattrib="", $sortfield="", $sortorder="", $prefix="", $tooltip="", $forcenowrapcolumntitle=0)
Show title line of an array.
print_barre_liste($title, $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.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.