FIX proposed new feature: autocomplete for accounting account groups

This commit is contained in:
Florian Mortgat
2021-05-28 08:42:38 +02:00
parent c29d5fa747
commit e6deab5c85

View File

@@ -258,13 +258,13 @@ if ($action == 'create') {
print '</td>';
print '<td>';
print '<input type="text" name="pcg_type" list="pcg_type_datalist" value="'.dol_escape_htmltag(GETPOSTISSET('pcg_type') ? GETPOST('pcg_type', 'alpha') : $object->pcg_type).'">';
// autosuggest from existing account types if found
print '<datalist id="pcg_type_datalist">';
$sql = 'SELECT a.rowid as rowid, a.code as code, a.label FROM '.MAIN_DB_PREFIX.'c_accounting_category as a WHERE a.active=1';
$resql = $db->query($sql);
if ($resql) {
while ($obj = $db->fetch_object($resql)) {
print '<option value="' . dol_escape_htmltag($obj->code) . '">';
}
$sql = 'SELECT DISTINCT pcg_type FROM ' . MAIN_DB_PREFIX . 'accounting_account';
$sql .= ' WHERE fk_pcg_version = "' . $db->escape($accountsystem->ref) . '"';
$sql .= ' LIMIT 50000'; // just as a sanity check
foreach ($db->getRows($sql) as $obj) {
print '<option value="' . dol_escape_htmltag($obj->pcg_type) . '">';
}
print '</datalist>';
print '</td></tr>';