Cleanup in popup lists related files.
[fa-stable.git] / gl / includes / db / gl_db_accounts.inc
index de487be2d4581a256929bad7e0901532c422dd9f..3244b176cfd701340d2838118dd3f5a626c12c50 100644 (file)
@@ -288,3 +288,24 @@ function is_bank_account($account_code)
        } else
                return false;
 }
+
+function get_chart_accounts_search($like)
+{
+       global $SysPrefs;
+
+       if (isset($SysPrefs->max_rows_in_search))
+               $limit = $SysPrefs->max_rows_in_search;
+       else
+               $limit = 10;
+
+
+       $sql = "SELECT chart.account_code, chart.account_name, type.name
+                       FROM ".TB_PREF."chart_master chart,".TB_PREF."chart_types type
+                       WHERE chart.account_type=type.id
+        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.");
+}