- $sql= "SELECT COUNT(*) FROM ".TB_PREF."bank_accounts WHERE
- account_code=".db_escape($acc);
- $result = db_query($sql,"Couldn't test bank account GL codes");
-
- $myrow = db_fetch_row($result);
- return ($myrow[0] > 0);
+ global $SysPrefs;
+
+ if (isset($SysPrefs->max_rows_in_search))
+ $limit = $SysPrefs->max_rows_in_search;
+ else
+ $limit = 10;
+
+ if ($skip)
+ $sql = "SELECT chart.account_code, chart.account_name, type.name, chart.inactive, type.id
+ FROM (".TB_PREF."chart_master chart,".TB_PREF."chart_types type) "
+ ."LEFT JOIN ".TB_PREF."bank_accounts acc "
+ ."ON chart.account_code=acc.account_code
+ WHERE acc.account_code IS NULL
+ AND chart.account_type=type.id ";
+ else
+ $sql = "SELECT chart.account_code, chart.account_name, type.name, chart.inactive, type.id
+ FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type WHERE chart.account_type=type.id ";
+ $sql .= "AND (
+ chart.account_name LIKE " . db_escape("%" . $like. "%") . " OR
+ chart.account_code LIKE " . db_escape("%" . $like. "%") . "
+ )
+ ORDER BY chart.account_code LIMIT 0,".(int)($limit); // We only display 10 items.
+ return db_query($sql, "Failed in retreiving GL account list.");