diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index 4caad5cfa94..dfe1d734c2c 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -27,6 +27,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/accounting.lib.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingaccount.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; // Load translation files required by the page $langs->loadLangs(array("compta", "bills", "admin", "accountancy", "salaries")); @@ -183,6 +184,7 @@ if (empty($reshook)) */ $form = new Form($db); +$formaccounting = new FormAccounting($db); llxHeader('', $langs->trans("ListAccounts")); @@ -201,10 +203,30 @@ if ($db->type == 'pgsql') $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_accou else $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."accounting_account as a2 ON a2.rowid = aa.account_parent AND a2.entity = ".$conf->entity; $sql .= " WHERE asy.rowid = ".$pcgver; //print $sql; -if (strlen(trim($search_account))) $sql .= natural_search("aa.account_number", $search_account); +if (strlen(trim($search_account))) { + $lengthpaddingaccount = 0; + if ($conf->global->ACCOUNTING_LENGTH_GACCOUNT || $conf->global->ACCOUNTING_LENGTH_AACCOUNT) { + $lengthpaddingaccount = max($conf->global->ACCOUNTING_LENGTH_GACCOUNT, $conf->global->ACCOUNTING_LENGTH_AACCOUNT); + } + $search_account_tmp = $search_account; + $weremovedsomezero = 0; + if (strlen($search_account_tmp) <= $lengthpaddingaccount) { + for($i = 0; $i < $lengthpaddingaccount; $i++) { + if (preg_match('/0$/', $search_account_tmp)) { + $weremovedsomezero++; + $search_account_tmp = preg_replace('/0$/', '', $search_account_tmp); + } + } + } + //var_dump($search_account); exit; + if ($search_account_tmp) { + if ($weremovedsomezero) $sql .= " AND aa.account_number LIKE '%".$search_account_tmp."'"; + else $sql .= natural_search("aa.account_number", $search_account_tmp); + } +} if (strlen(trim($search_label))) $sql .= natural_search("aa.label", $search_label); if (strlen(trim($search_labelshort))) $sql .= natural_search("aa.labelshort", $search_labelshort); -if (strlen(trim($search_accountparent))) $sql .= natural_search("aa.account_parent", $search_accountparent); +if (strlen(trim($search_accountparent)) && $search_accountparent != '-1') $sql .= natural_search("aa.account_parent", $search_accountparent, 2); if (strlen(trim($search_pcgtype))) $sql .= natural_search("aa.pcg_type", $search_pcgtype); if (strlen(trim($search_pcgsubtype))) $sql .= natural_search("aa.pcg_subtype", $search_pcgsubtype); $sql .= $db->order($sortfield, $sortorder); @@ -237,7 +259,7 @@ if ($resql) if ($search_account) $param .= '&search_account='.urlencode($search_account); if ($search_label) $param .= '&search_label='.urlencode($search_label); if ($search_labelshort) $param.= '&search_labelshort='.urlencode($search_labelshort); - if ($search_accountparent) $param .= '&search_accountparent='.urlencode($search_accountparent); + if ($search_accountparent > 0 || $search_accountparent == '0') $param .= '&search_accountparent='.urlencode($search_accountparent); if ($search_pcgtype) $param .= '&search_pcgtype='.urlencode($search_pcgtype); if ($search_pcgsubtype) $param .= '&search_pcgsubtype='.urlencode($search_pcgsubtype); if ($optioncss != '') $param .= '&optioncss='.$optioncss; @@ -322,8 +344,12 @@ if ($resql) if (!empty($arrayfields['aa.account_number']['checked'])) print ''; if (!empty($arrayfields['aa.label']['checked'])) print ''; if (!empty($arrayfields['aa.labelshort']['checked'])) print ''; - if (!empty($arrayfields['aa.account_parent']['checked'])) print ''; - if (!empty($arrayfields['aa.pcg_type']['checked'])) print ''; + if (!empty($arrayfields['aa.account_parent']['checked'])) { + print ''; + print $formaccounting->select_account($search_accountparent, 'search_accountparent', 2); + print ''; + } + if (!empty($arrayfields['aa.pcg_type']['checked'])) print ''; if (!empty($arrayfields['aa.pcg_subtype']['checked'])) print ''; if (!empty($arrayfields['aa.active']['checked'])) print ' '; print ''; @@ -346,6 +372,7 @@ if ($resql) $accountstatic = new AccountingAccount($db); $accountparent = new AccountingAccount($db); + $totalarray = array(); $i = 0; while ($i < min($num, $limit)) { diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 729492fd709..2fb8eea45f6 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -6235,7 +6235,12 @@ class Form $out .= '