X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=gl%2Fincludes%2Fdb%2Fgl_db_accounts.inc;h=bcecad749aba6f546f97e4c7ba22f27bd3e6ab64;hb=1a5b277431e6804654cbca16aaed5ee3a5a729eb;hp=b544094e325551c51f0afd1fb79f308ff349513e;hpb=fa3dd600a4b60b528e4c69519c856125e6c3f9bf;p=fa-stable.git diff --git a/gl/includes/db/gl_db_accounts.inc b/gl/includes/db/gl_db_accounts.inc index b544094e..bcecad74 100644 --- a/gl/includes/db/gl_db_accounts.inc +++ b/gl/includes/db/gl_db_accounts.inc @@ -51,13 +51,17 @@ function get_gl_accounts($from=null, $to=null) function get_gl_accounts_all($balance=-1) { - $sql = "SELECT ".TB_PREF."chart_master.account_code, ".TB_PREF."chart_master.account_name, ".TB_PREF."chart_types.name AS AccountTypeName,".TB_PREF."chart_types.id AS AccountType, - ".TB_PREF."chart_types.parent, ".TB_PREF."chart_class.class_name AS AccountClassName + if ($balance == 1) + $where ="WHERE balance_sheet>0 AND balance_sheet<".CL_INCOME; + elseif ($balance == 0) + $where ="WHERE balance_sheet>".CL_EQUITY." OR balance_sheet=0"; // backwards compatibility + $sql = "SELECT ".TB_PREF."chart_master.account_code, ".TB_PREF."chart_master.account_name, ".TB_PREF."chart_types.name AS AccountTypeName,".TB_PREF."chart_types.id AS AccountType, + ".TB_PREF."chart_types.parent, ".TB_PREF."chart_class.class_name AS AccountClassName, ".TB_PREF."chart_class.cid AS ClassID FROM ".TB_PREF."chart_types INNER JOIN ".TB_PREF."chart_class ON ".TB_PREF."chart_types.class_id=".TB_PREF."chart_class.cid LEFT JOIN ".TB_PREF."chart_master ON ".TB_PREF."chart_master.account_type=".TB_PREF."chart_types.id "; if ($balance != -1) - $sql .= "WHERE ".TB_PREF."chart_class.balance_sheet=$balance "; - $sql .= "ORDER BY ".TB_PREF."chart_class.cid, IF(parent > 0,parent,".TB_PREF."chart_types.id), + $sql .= $where; + $sql .= " ORDER BY ".TB_PREF."chart_class.cid, IF(parent > 0,parent,".TB_PREF."chart_types.id), IF(parent > 0,".TB_PREF."chart_types.id, parent), ".TB_PREF."chart_master.account_code"; return db_query($sql, "could not get gl accounts"); @@ -80,7 +84,7 @@ function is_account_balancesheet($code) $result = db_query($sql,"could not retreive the account class for $code"); $row = db_fetch_row($result); - return $row[0]; + return $row[0] > 0 && $row[0] < CL_INCOME; } function get_gl_account_name($code)