function display_trial_balance($type, $typename) { global $path_to_root, $clear_trial_balance_opening; global $k, $pdeb, $pcre, $cdeb, $ccre, $tdeb, $tcre, $pbal, $cbal, $tbal; $printtitle = 0; //Flag for printing type name $k = 0; //$accounts = get_gl_accounts(); //Get Accounts directly under this group/type $accounts = get_gl_accounts(null, null, $type); $begin = get_fiscalyear_begin_for_date($_POST['TransFromDate']); //$begin = begin_fiscalyear(); if (date1_greater_date2($begin, $_POST['TransFromDate'])) { $begin = $_POST['TransFromDate']; } $begin = add_days($begin, -1); while ($account = db_fetch($accounts)) { //Print Type Title if it has atleast one non-zero account if (!$printtitle) { start_row("class='inquirybg' style='font-weight:bold'"); label_cell(_("Group") . " - " . $type . " - " . $typename, "colspan=8"); end_row(); $printtitle = 1; } // FA doesn't really clear the closed year, therefore the brought forward balance includes all the transactions from the past, even though the balance is null. // If we want to remove the balanced part for the past years, this option removes the common part from from the prev and tot figures. if (@$clear_trial_balance_opening) { $open = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $begin, $begin, false, true); $offset = min($open['debit'], $open['credit']); } else { $offset = 0; } $prev = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $begin, $_POST['TransFromDate'], false, false); $curr = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $_POST['TransFromDate'], $_POST['TransToDate'], true, true); $tot = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $begin, $_POST['TransToDate'], false, true); if (check_value("NoZero") && !$prev['balance'] && !$curr['balance'] && !$tot['balance']) { continue; } alt_table_row_color($k); $url = "<a href='{$path_to_root}/gl/inquiry/gl_account_inquiry.php?TransFromDate=" . $_POST["TransFromDate"] . "&TransToDate=" . $_POST["TransToDate"] . "&account=" . $account["account_code"] . "&Dimension=" . $_POST["Dimension"] . "&Dimension2=" . $_POST["Dimension2"] . "'>" . $account["account_code"] . "</a>"; label_cell($url); label_cell($account["account_name"]); if (check_value('Balance')) { display_debit_or_credit_cells($prev['balance']); display_debit_or_credit_cells($curr['balance']); display_debit_or_credit_cells($tot['balance']); } else { amount_cell($prev['debit'] - $offset); amount_cell($prev['credit'] - $offset); amount_cell($curr['debit']); amount_cell($curr['credit']); amount_cell($tot['debit'] - $offset); amount_cell($tot['credit'] - $offset); $pdeb += $prev['debit']; $pcre += $prev['credit']; $cdeb += $curr['debit']; $ccre += $curr['credit']; $tdeb += $tot['debit']; $tcre += $tot['credit']; } $pbal += $prev['balance']; $cbal += $curr['balance']; $tbal += $tot['balance']; end_row(); } //Get Account groups/types under this group/type $result = get_account_types(false, false, $type); while ($accounttype = db_fetch($result)) { //Print Type Title if has sub types and not previously printed if (!$printtitle) { start_row("class='inquirybg' style='font-weight:bold'"); label_cell(_("Group") . " - " . $type . " - " . $typename, "colspan=8"); end_row(); $printtitle = 1; } display_trial_balance($accounttype["id"], $accounttype["name"] . ' (' . $typename . ')'); } }
function display_trial_balance($type, $typename) { global $path_to_root; global $k, $pdeb, $pcre, $cdeb, $ccre, $tdeb, $tcre, $pbal, $cbal, $tbal; $printtitle = 0; //Flag for printing type name $k = 0; //$accounts = get_gl_accounts(); //Get Accounts directly under this group/type $accounts = get_gl_accounts(null, null, $type); $begin = get_fiscalyear_begin_for_date($_POST['TransFromDate']); //$begin = begin_fiscalyear(); if (date1_greater_date2($begin, $_POST['TransFromDate'])) { $begin = $_POST['TransFromDate']; } $begin = add_days($begin, -1); while ($account = db_fetch($accounts)) { //Print Type Title if it has atleast one non-zero account if ($type == 3502) { continue; } if (!$printtitle) { start_row("class='inquirybg' style='font-weight:bold'"); label_cell(_("Group") . " - " . $type . " - " . $typename, "colspan=8"); end_row(); $printtitle = 1; } $prev = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $begin, $_POST['TransFromDate'], false, false); $curr = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $_POST['TransFromDate'], $_POST['TransToDate'], true, true); $tot = get_balance($account["account_code"], $_POST['Dimension'], $_POST['Dimension2'], $begin, $_POST['TransToDate'], false, true); if (check_value("NoZero") && !$prev['balance'] && !$curr['balance'] && !$tot['balance']) { continue; } alt_table_row_color($k); $url = "<a href='{$path_to_root}/gl/inquiry/gl_account_inquiry.php?TransFromDate=" . $_POST["TransFromDate"] . "&TransToDate=" . $_POST["TransToDate"] . "&account=" . $account["account_code"] . "&Dimension=" . $_POST["Dimension"] . "&Dimension2=" . $_POST["Dimension2"] . "'>" . $account["account_code"] . "</a>"; label_cell($url); label_cell($account["account_name"]); if (check_value('Balance')) { display_debit_or_credit_cells($prev['balance']); display_debit_or_credit_cells($curr['balance']); display_debit_or_credit_cells($tot['balance']); } else { amount_cell($prev['debit']); amount_cell($prev['credit']); amount_cell($curr['debit']); amount_cell($curr['credit']); amount_cell($tot['debit']); amount_cell($tot['credit']); $pdeb += $prev['debit']; $pcre += $prev['credit']; $cdeb += $curr['debit']; $ccre += $curr['credit']; $tdeb += $tot['debit']; $tcre += $tot['credit']; } $pbal += $prev['balance']; $cbal += $curr['balance']; $tbal += $tot['balance']; end_row(); } //Get Account groups/types under this group/type $result = get_account_types(false, false, $type); while ($accounttype = db_fetch($result)) { //Print Type Title if has sub types and not previously printed if (!$printtitle) { start_row("class='inquirybg' style='font-weight:bold'"); label_cell(_("Group") . " - " . $type . " - " . $typename, "colspan=8"); end_row(); $printtitle = 1; } display_trial_balance($accounttype["id"], $accounttype["name"] . ' (' . $typename . ')'); } }
} else { $begin = begin_fiscalyear(); if ($_POST['TransFromDate'] < $begin) { $begin = $_POST['TransFromDate']; } $begin = add_days($begin, -1); } $prev_balance = get_balance($account["account_code"], $begin, $_POST['TransFromDate'], false, false); $curr_balance = get_balance($account["account_code"], $_POST['TransFromDate'], $_POST['TransToDate']); if (check_value("NoZero") && !$prev_balance && !$curr_balance) { continue; } alt_table_row_color($k); $url = "<a href='{$path_to_root}/gl/inquiry/gl_account_inquiry.php?" . SID . "TransFromDate=" . $_POST["TransFromDate"] . "&TransToDate=" . $_POST["TransToDate"] . "&account=" . $account["account_code"] . "'>" . $account["account_code"] . "</a>"; label_cell($url); label_cell($account["account_name"]); display_debit_or_credit_cells($prev_balance); display_debit_or_credit_cells($curr_balance); display_debit_or_credit_cells($prev_balance + $curr_balance); end_row(); } end_table(1); } //---------------------------------------------------------------------------------------------------- gl_inquiry_controls(); display_trial_balance(); //---------------------------------------------------------------------------------------------------- end_page(); ?>