Exemple #1
0
function display_type($type, $typename, $from, $to, $convert, &$dec, &$rep, $dimension, $dimension2, $tags, &$pg, $graphics)
{
    $code_open_balance = 0;
    $code_period_balance = 0;
    $open_balance_total = 0;
    $period_balance_total = 0;
    $totals_arr = array();
    $printtitle = 0;
    //Flag for printing type name
    //Get Accounts directly under this group/type
    $result = get_gl_accounts(null, null, $type);
    while ($account = db_fetch($result)) {
        if ($tags != -1 && is_array($tags) && $tags[0] != false) {
            if (!is_record_in_tags($tags, TAG_ACCOUNT, $account['account_code'])) {
                continue;
            }
        }
        $prev_balance = get_gl_balance_from_to("", $from, $account["account_code"], $dimension, $dimension2);
        $curr_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2);
        if (!$prev_balance && !$curr_balance) {
            continue;
        }
        //Print Type Title if it has atleast one non-zero account
        if (!$printtitle) {
            $printtitle = 1;
            $rep->row -= 4;
            $rep->TextCol(0, 5, $typename);
            $rep->row -= 4;
            $rep->Line($rep->row);
            $rep->NewLine();
        }
        $rep->TextCol(0, 1, $account['account_code']);
        $rep->TextCol(1, 2, $account['account_name']);
        $rep->AmountCol(2, 3, $prev_balance * $convert, $dec);
        $rep->AmountCol(3, 4, $curr_balance * $convert, $dec);
        $rep->AmountCol(4, 5, ($prev_balance + $curr_balance) * $convert, $dec);
        $rep->NewLine();
        $code_open_balance += $prev_balance;
        $code_period_balance += $curr_balance;
    }
    //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) {
            $printtitle = 1;
            $rep->row -= 4;
            $rep->TextCol(0, 5, $typename);
            $rep->row -= 4;
            $rep->Line($rep->row);
            $rep->NewLine();
        }
        $totals_arr = display_type($accounttype["id"], $accounttype["name"], $from, $to, $convert, $dec, $rep, $dimension, $dimension2, $tags, $pg, $graphics);
        $open_balance_total += $totals_arr[0];
        $period_balance_total += $totals_arr[1];
    }
    //Display Type Summary if total is != 0 OR head is printed (Needed in case of unused hierarchical COA)
    if ($code_open_balance + $open_balance_total + $code_period_balance + $period_balance_total != 0 || $printtitle) {
        $rep->row += 6;
        $rep->Line($rep->row);
        $rep->NewLine();
        $rep->TextCol(0, 2, _('Total') . " " . $typename);
        $rep->AmountCol(2, 3, ($code_open_balance + $open_balance_total) * $convert, $dec);
        $rep->AmountCol(3, 4, ($code_period_balance + $period_balance_total) * $convert, $dec);
        $rep->AmountCol(4, 5, ($code_open_balance + $open_balance_total + $code_period_balance + $period_balance_total) * $convert, $dec);
        if ($graphics) {
            $pg->x[] = $typename;
            $pg->y[] = abs($code_open_balance + $open_balance_total);
            $pg->z[] = abs($code_period_balance + $period_balance_total);
        }
        $rep->NewLine();
    }
    $totals_arr[0] = $code_open_balance + $open_balance_total;
    $totals_arr[1] = $code_period_balance + $period_balance_total;
    return $totals_arr;
}
Exemple #2
0
function display_type($type, $typename, $yr, $mo, $convert, &$dec, &$rep, $dimension, $dimension2, $tags)
{
    $ctotal = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    $total = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    $totals_arr = array();
    $printtitle = 0;
    //Flag for printing type name
    //Get Accounts directly under this group/type
    $result = get_gl_accounts(null, null, $type);
    while ($account = db_fetch($result)) {
        if ($tags != -1 && is_array($tags) && $tags[0] != false) {
            if (!is_record_in_tags($tags, TAG_ACCOUNT, $account['account_code'])) {
                continue;
            }
        }
        $bal = getPeriods($yr, $mo, $account["account_code"], $dimension, $dimension2);
        if (!$bal['per01'] && !$bal['per02'] && !$bal['per03'] && !$bal['per04'] && !$bal['per05'] && !$bal['per06'] && !$bal['per07'] && !$bal['per08'] && !$bal['per09'] && !$bal['per10'] && !$bal['per11'] && !$bal['per12']) {
            continue;
        }
        //Print Type Title if it has atleast one non-zero account
        if (!$printtitle) {
            $printtitle = 1;
            $rep->row -= 4;
            $rep->TextCol(0, 5, $typename);
            $rep->row -= 4;
            $rep->Line($rep->row);
            $rep->NewLine();
        }
        $balance = array(1 => $bal['per01'], $bal['per02'], $bal['per03'], $bal['per04'], $bal['per05'], $bal['per06'], $bal['per07'], $bal['per08'], $bal['per09'], $bal['per10'], $bal['per11'], $bal['per12']);
        $rep->TextCol(0, 1, $account['account_code']);
        $rep->TextCol(1, 2, $account['account_name']);
        for ($i = 1; $i <= 12; $i++) {
            $rep->AmountCol($i + 1, $i + 2, $balance[$i] * $convert, $dec);
            $ctotal[$i] += $balance[$i];
        }
        $rep->NewLine();
    }
    //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) {
            $printtitle = 1;
            $rep->row -= 4;
            $rep->TextCol(0, 5, $typename);
            $rep->row -= 4;
            $rep->Line($rep->row);
            $rep->NewLine();
        }
        $totals_arr = display_type($accounttype["id"], $accounttype["name"], $yr, $mo, $convert, $dec, $rep, $dimension, $dimension2, $tags);
        for ($i = 1; $i <= 12; $i++) {
            $total[$i] += $totals_arr[$i];
        }
    }
    //Display Type Summary if total is != 0 OR head is printed (Needed in case of unused hierarchical COA)
    if ($printtitle) {
        $rep->row += 6;
        $rep->Line($rep->row);
        $rep->NewLine();
        $rep->TextCol(0, 2, _('Total') . " " . $typename);
        for ($i = 1; $i <= 12; $i++) {
            $rep->AmountCol($i + 1, $i + 2, ($total[$i] + $ctotal[$i]) * $convert, $dec);
        }
        $rep->NewLine();
    }
    for ($i = 1; $i <= 12; $i++) {
        $totals_arr[$i] = $total[$i] + $ctotal[$i];
    }
    return $totals_arr;
}