OR name='retained_earnings_act'
OR name='freight_act'
OR name='deferred_income_act'
+ OR name='grn_clearing_act'
OR name='default_sales_act'
OR name='default_sales_discount_act'
OR name='default_prompt_payment_act'
$result = db_query($sql,"Couldn't test AR/AP account");
$myrow = db_fetch_row($result);
- return $myrow[0];
+ return $myrow == false ? 0 : $myrow[0];
}
function get_subaccount_data($code_id, $person_id)
return false;
}
-function get_chart_accounts_search($like)
+function get_chart_accounts_search($like, $skip=false)
{
global $SysPrefs;
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.
+ 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.");
}