Example #1
0
function print_Chart_of_Accounts()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $showbalance = $_REQUEST['PARAM_0'];
    $comments = $_REQUEST['PARAM_1'];
    $dec = 0;
    $cols = array(0, 50, 300, 425, 500);
    $headers = array(tr('Account'), tr('Account Name'), tr('Account Code'), tr('Balance'));
    $aligns = array('left', 'left', 'left', 'right');
    $params = array(0 => $comments);
    $rep = new FrontReport(tr('Chart of Accounts'), "ChartOfAccounts.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $classname = '';
    $group = '';
    $accounts = get_gl_accounts_all();
    while ($account = db_fetch($accounts)) {
        if ($showbalance == 1) {
            $begin = begin_fiscalyear();
            if (is_account_balancesheet($account["account_code"])) {
                $begin = "";
            }
            $balance = get_gl_trans_from_to($begin, ToDay(), $account["account_code"], 0);
        }
        if ($account['AccountTypeName'] != $group) {
            if ($classname != '') {
                $rep->row -= 4;
            }
            if ($account['AccountClassName'] != $classname) {
                $rep->Font('bold');
                $rep->TextCol(0, 4, $account['AccountClassName']);
                $rep->Font();
                $rep->row -= $rep->lineHeight + 4;
            }
            $group = $account['AccountTypeName'];
            $rep->TextCol(0, 4, $account['AccountTypeName']);
            //$rep->Line($rep->row - 4);
            $rep->row -= $rep->lineHeight + 4;
        }
        $classname = $account['AccountClassName'];
        $rep->TextCol(0, 1, $account['account_code']);
        $rep->TextCol(1, 2, $account['account_name']);
        $rep->TextCol(2, 3, $account['account_code2']);
        if ($showbalance == 1) {
            $rep->TextCol(3, 4, number_format2($balance, $dec));
        }
        $rep->NewLine();
        if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight) {
            $rep->Line($rep->row - 2);
            $rep->Header();
        }
    }
    $rep->Line($rep->row);
    $rep->End();
}
Example #2
0
function print_profit_and_loss_statement()
{
    global $comp_path, $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $dim = get_company_pref('use_dimension');
    $dimension = $dimension2 = 0;
    $from = $_REQUEST['PARAM_0'];
    $to = $_REQUEST['PARAM_1'];
    $compare = $_REQUEST['PARAM_2'];
    if ($dim == 2) {
        $dimension = $_REQUEST['PARAM_3'];
        $dimension2 = $_REQUEST['PARAM_4'];
        $graphics = $_REQUEST['PARAM_5'];
        $comments = $_REQUEST['PARAM_6'];
    } else {
        if ($dim == 1) {
            $dimension = $_REQUEST['PARAM_3'];
            $graphics = $_REQUEST['PARAM_4'];
            $comments = $_REQUEST['PARAM_5'];
        } else {
            $graphics = $_REQUEST['PARAM_3'];
            $comments = $_REQUEST['PARAM_4'];
        }
    }
    if ($graphics) {
        include_once $path_to_root . "reporting/includes/class.graphic.inc";
        $pg = new graph();
    }
    $dec = 0;
    $pdec = user_percent_dec();
    $cols = array(0, 50, 200, 350, 425, 500);
    //------------0--1---2----3----4----5--
    $headers = array(tr('Account'), tr('Account Name'), tr('Period'), tr('Accumulated'), tr('Achieved %'));
    $aligns = array('left', 'left', 'right', 'right', 'right');
    if ($dim == 2) {
        $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => tr('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => ''));
    } else {
        if ($dim == 1) {
            $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension'), 'from' => get_dimension_string($dimension), 'to' => ''));
        } else {
            $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to));
        }
    }
    if ($compare == 0 || $compare == 2) {
        $end = $to;
        if ($compare == 2) {
            $begin = $from;
            $headers[3] = tr('Budget');
        } else {
            $begin = begin_fiscalyear();
        }
    } elseif ($compare == 1) {
        $begin = add_months($from, -12);
        $end = add_months($to, -12);
        $headers[3] = tr('Period Y-1');
    }
    $rep = new FrontReport(tr('Profit and Loss Statement'), "ProfitAndLoss.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $classname = '';
    $group = '';
    $totalper = 0.0;
    $totalacc = 0.0;
    $classper = 0.0;
    $classacc = 0.0;
    $salesper = 0.0;
    $salesacc = 0.0;
    $accounts = get_gl_accounts_all(0);
    while ($account = db_fetch($accounts)) {
        $per_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2);
        if ($compare == 2) {
            $acc_balance = get_budget_trans_from_to($begin, $end, $account["account_code"], $dimension, $dimension2);
        } else {
            $acc_balance = get_gl_trans_from_to($begin, $end, $account["account_code"], $dimension, $dimension2);
        }
        if (!$per_balance && !$acc_balance) {
            continue;
        }
        if ($account['AccountClassName'] != $classname) {
            if ($classname != '') {
                $closeclass = true;
            }
        }
        if ($account['AccountTypeName'] != $group) {
            if ($group != '') {
                $rep->Line($rep->row + 6);
                $rep->row -= 6;
                $rep->TextCol(0, 2, tr('Total') . " " . $group);
                $rep->TextCol(2, 3, number_format2($totalper, $dec));
                $rep->TextCol(3, 4, number_format2($totalacc, $dec));
                $rep->TextCol(4, 5, number_format2(Achieve($totalper, $totalacc), $pdec));
                if ($graphics) {
                    $pg->x[] = $group;
                    $pg->y[] = abs($totalper);
                    $pg->z[] = abs($totalacc);
                }
                $totalper = $totalacc = 0.0;
                $rep->row -= $rep->lineHeight + 4;
                if ($closeclass) {
                    $rep->Line($rep->row + 6);
                    $rep->row -= 6;
                    $rep->Font('bold');
                    $rep->TextCol(0, 2, tr('Total') . " " . $classname);
                    $rep->TextCol(2, 3, number_format2($classper, $dec));
                    $rep->TextCol(3, 4, number_format2($classacc, $dec));
                    $rep->TextCol(4, 5, number_format2(Achieve($classper, $classacc), $pdec));
                    $rep->Font();
                    $salesper += $classper;
                    $salesacc += $classacc;
                    $classper = $classacc = 0.0;
                    $rep->NewLine(3);
                    $closeclass = false;
                }
            }
            if ($account['AccountClassName'] != $classname) {
                $rep->Font('bold');
                $rep->TextCol(0, 5, $account['AccountClassName']);
                $rep->Font();
                $rep->row -= $rep->lineHeight + 4;
            }
            $group = $account['AccountTypeName'];
            $rep->TextCol(0, 5, $account['AccountTypeName']);
            $rep->Line($rep->row - 4);
            $rep->row -= $rep->lineHeight + 4;
        }
        $classname = $account['AccountClassName'];
        $per_balance *= -1;
        $acc_balance *= -1;
        $totalper += $per_balance;
        $totalacc += $acc_balance;
        $classper += $per_balance;
        $classacc += $acc_balance;
        $rep->TextCol(0, 1, $account['account_code']);
        $rep->TextCol(1, 2, $account['account_name']);
        $rep->TextCol(2, 3, number_format2($per_balance, $dec));
        $rep->TextCol(3, 4, number_format2($acc_balance, $dec));
        $rep->TextCol(4, 5, number_format2(Achieve($per_balance, $acc_balance), $pdec));
        $rep->NewLine();
        if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight) {
            $rep->Line($rep->row - 2);
            $rep->Header();
        }
    }
    if ($account['AccountClassName'] != $classname) {
        if ($classname != '') {
            $closeclass = true;
        }
    }
    if ($account['AccountTypeName'] != $group) {
        if ($group != '') {
            $rep->Line($rep->row + 6);
            $rep->row -= 6;
            $rep->TextCol(0, 2, tr('Total') . " " . $group);
            $rep->TextCol(2, 3, number_format2($totalper, $dec));
            $rep->TextCol(3, 4, number_format2($totalacc, $dec));
            $rep->TextCol(4, 5, number_format2(Achieve($totalper, $totalacc), $pdec));
            if ($graphics) {
                $pg->x[] = $group;
                $pg->y[] = abs($totalper);
                $pg->z[] = abs($totalacc);
            }
            $rep->row -= $rep->lineHeight + 4;
            if ($closeclass) {
                $rep->Line($rep->row + 6);
                $calculateper = $salesper + $classper;
                $calculateacc = $salesacc + $classacc;
                $rep->row -= 6;
                $rep->Font('bold');
                $rep->TextCol(0, 2, tr('Total') . " " . $classname);
                $rep->TextCol(2, 3, number_format2($classper, $dec));
                $rep->TextCol(3, 4, number_format2($classacc, $dec));
                $rep->TextCol(4, 5, number_format2(Achieve($classper, $classacc), $pdec));
                $rep->row -= $rep->lineHeight + 8;
                $rep->TextCol(0, 2, tr('Calculated Return'));
                $rep->TextCol(2, 3, number_format2($calculateper, $dec));
                $rep->TextCol(3, 4, number_format2($calculateacc, $dec));
                $rep->TextCol(4, 5, number_format2(Achieve($calculateper, $calculateacc), $pdec));
                if ($graphics) {
                    $pg->x[] = tr('Calculated Return');
                    $pg->y[] = abs($calculateper);
                    $pg->z[] = abs($calculateacc);
                }
                $rep->Font();
                $rep->NewLine();
            }
        }
    }
    $rep->Line($rep->row);
    if ($graphics) {
        global $decseps, $graph_skin;
        $pg->title = $rep->title;
        $pg->axis_x = tr("Group");
        $pg->axis_y = tr("Amount");
        $pg->graphic_1 = $headers[2];
        $pg->graphic_2 = $headers[3];
        $pg->type = $graphics;
        $pg->skin = $graph_skin;
        $pg->built_in = false;
        $pg->fontfile = $path_to_root . "reporting/fonts/Vera.ttf";
        $pg->latin_notation = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != ".";
        $filename = $comp_path . '/' . user_company() . "/pdf_files/test.png";
        $pg->display($filename, true);
        $w = $pg->width / 1.5;
        $h = $pg->height / 1.5;
        $x = ($rep->pageWidth - $w) / 2;
        $rep->NewLine(2);
        if ($rep->row - $h < $rep->bottomMargin) {
            $rep->Header();
        }
        $rep->AddImage($filename, $x, $rep->row - $h, $w, $h);
    }
    $rep->End();
}
Example #3
0
function print_annual_expense_breakdown()
{
    global $path_to_root, $date_system;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $dim = get_company_pref('use_dimension');
    $dimension = $dimension2 = 0;
    if ($dim == 2) {
        $year = $_REQUEST['PARAM_0'];
        $dimension = $_REQUEST['PARAM_1'];
        $dimension2 = $_REQUEST['PARAM_2'];
        $comments = $_REQUEST['PARAM_3'];
    } else {
        if ($dim == 1) {
            $year = $_REQUEST['PARAM_0'];
            $dimension = $_REQUEST['PARAM_1'];
            $comments = $_REQUEST['PARAM_2'];
        } else {
            $year = $_REQUEST['PARAM_0'];
            $comments = $_REQUEST['PARAM_1'];
        }
    }
    $dec = 1;
    //$pdec = user_percent_dec();
    $cols = array(0, 40, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450, 480, 510);
    //------------0--1---2----3----4----5----6----7----8----10---11---12---13---14---15-
    //$yr = date('Y');
    //$mo = date('m'):
    // from now
    $yr = $year;
    $mo = 12;
    $da = 1;
    if ($date_system == 1) {
        list($yr, $mo, $da) = jalali_to_gregorian($yr, $mo, $da);
    } elseif ($date_system == 2) {
        list($yr, $mo, $da) = islamic_to_gregorian($yr, $mo, $da);
    }
    $per12 = strftime('%b', mktime(0, 0, 0, $mo, $da, $yr));
    $per11 = strftime('%b', mktime(0, 0, 0, $mo - 1, $da, $yr));
    $per10 = strftime('%b', mktime(0, 0, 0, $mo - 2, $da, $yr));
    $per09 = strftime('%b', mktime(0, 0, 0, $mo - 3, $da, $yr));
    $per08 = strftime('%b', mktime(0, 0, 0, $mo - 4, $da, $yr));
    $per07 = strftime('%b', mktime(0, 0, 0, $mo - 5, $da, $yr));
    $per06 = strftime('%b', mktime(0, 0, 0, $mo - 6, $da, $yr));
    $per05 = strftime('%b', mktime(0, 0, 0, $mo - 7, $da, $yr));
    $per04 = strftime('%b', mktime(0, 0, 0, $mo - 8, $da, $yr));
    $per03 = strftime('%b', mktime(0, 0, 0, $mo - 9, $da, $yr));
    $per02 = strftime('%b', mktime(0, 0, 0, $mo - 10, $da, $yr));
    $per01 = strftime('%b', mktime(0, 0, 0, $mo - 11, $da, $yr));
    $headers = array(tr('Account'), tr('Account Name'), $per01, $per02, $per03, $per04, $per05, $per06, $per07, $per08, $per09, $per10, $per11, $per12);
    $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right');
    if ($dim == 2) {
        $params = array(0 => $comments, 1 => array('text' => tr("Year"), 'from' => $year, 'to' => ''), 2 => array('text' => tr("Dimension") . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => tr("Dimension") . " 2", 'from' => get_dimension_string($dimension2), 'to' => ''), 4 => array('text' => tr('Info'), 'from' => tr('Amounts in thousands'), 'to' => ''));
    } else {
        if ($dim == 1) {
            $params = array(0 => $comments, 1 => array('text' => tr("Year"), 'from' => $year, 'to' => ''), 2 => array('text' => tr('Dimension'), 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => tr('Info'), 'from' => tr('Amounts in thousands'), 'to' => ''));
        } else {
            $params = array(0 => $comments, 1 => array('text' => tr("Year"), 'from' => $year, 'to' => ''), 2 => array('text' => tr('Info'), 'from' => tr('Amounts in thousands'), 'to' => ''));
        }
    }
    $rep = new FrontReport(tr('Annual Expense Breakdown'), "AnnualBreakDown.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $classname = '';
    $group = '';
    $total = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    $total2 = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    $sales = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    $calc = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    $accounts = get_gl_accounts_all(0);
    while ($account = db_fetch($accounts)) {
        $bal = getPeriods($year, $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;
        }
        $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']);
        if ($account['AccountClassName'] != $classname) {
            if ($classname != '') {
                $closeclass = true;
            }
        }
        if ($account['AccountTypeName'] != $group) {
            if ($group != '') {
                $rep->Line($rep->row + 6);
                $rep->row -= 6;
                $rep->TextCol(0, 2, tr('Total') . " " . $group);
                for ($i = 1; $i <= 12; $i++) {
                    $rep->TextCol($i + 1, $i + 2, number_format2($total[$i], $dec));
                }
                $total = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
                $rep->row -= $rep->lineHeight + 4;
                if ($closeclass) {
                    $rep->Line($rep->row + 6);
                    $rep->row -= 6;
                    $rep->Font('bold');
                    $rep->TextCol(0, 2, tr('Total') . " " . $classname);
                    for ($i = 1; $i <= 12; $i++) {
                        $rep->TextCol($i + 1, $i + 2, number_format2($total2[$i], $dec));
                        $sales[$i] += $total2[$i];
                    }
                    $rep->Font();
                    $total2 = array(1 => 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
                    $rep->NewLine(3);
                    $closeclass = false;
                }
            }
            if ($account['AccountClassName'] != $classname) {
                $rep->Font('bold');
                $rep->TextCol(0, 5, $account['AccountClassName']);
                $rep->Font();
                $rep->row -= $rep->lineHeight + 4;
            }
            $group = $account['AccountTypeName'];
            $rep->TextCol(0, 5, $account['AccountTypeName']);
            $rep->Line($rep->row - 4);
            $rep->row -= $rep->lineHeight + 4;
        }
        $classname = $account['AccountClassName'];
        $rep->TextCol(0, 1, $account['account_code']);
        $rep->TextCol(1, 2, $account['account_name']);
        for ($i = 1; $i <= 12; $i++) {
            $rep->TextCol($i + 1, $i + 2, number_format2($balance[$i], $dec));
            $total[$i] += $balance[$i];
            $total2[$i] += $balance[$i];
        }
        $rep->NewLine();
        if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight) {
            $rep->Line($rep->row - 2);
            $rep->Header();
        }
    }
    if ($account['AccountClassName'] != $classname) {
        if ($classname != '') {
            $closeclass = true;
        }
    }
    if ($account['AccountTypeName'] != $group) {
        if ($group != '') {
            $rep->Line($rep->row + 6);
            $rep->row -= 6;
            $rep->TextCol(0, 2, tr('Total') . " " . $group);
            for ($i = 1; $i <= 12; $i++) {
                $rep->TextCol($i + 1, $i + 2, number_format2($total[$i], $dec));
            }
            $rep->row -= $rep->lineHeight + 4;
            if ($closeclass) {
                $rep->Line($rep->row + 6);
                $rep->row -= 6;
                $rep->Font('bold');
                $rep->TextCol(0, 2, tr('Total') . " " . $classname);
                for ($i = 1; $i <= 12; $i++) {
                    $rep->TextCol($i + 1, $i + 2, number_format2($total2[$i], $dec));
                    $calc[$i] = $sales[$i] + $total2[$i];
                }
                $rep->row -= $rep->lineHeight + 8;
                $rep->TextCol(0, 2, tr('Calculated Return'));
                for ($i = 1; $i <= 12; $i++) {
                    $rep->TextCol($i + 1, $i + 2, number_format2($calc[$i], $dec));
                }
                $rep->Font();
                $rep->NewLine();
            }
        }
    }
    $rep->Line($rep->row);
    $rep->End();
}
Example #4
0
function print_balance_sheet()
{
    global $comp_path, $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $dim = get_company_pref('use_dimension');
    $dimension = $dimension2 = 0;
    $from = $_REQUEST['PARAM_0'];
    $to = $_REQUEST['PARAM_1'];
    if ($dim == 2) {
        $dimension = $_REQUEST['PARAM_2'];
        $dimension2 = $_REQUEST['PARAM_3'];
        $graphics = $_REQUEST['PARAM_4'];
        $comments = $_REQUEST['PARAM_5'];
    } else {
        if ($dim == 1) {
            $dimension = $_REQUEST['PARAM_2'];
            $graphics = $_REQUEST['PARAM_3'];
            $comments = $_REQUEST['PARAM_4'];
        } else {
            $graphics = $_REQUEST['PARAM_2'];
            $comments = $_REQUEST['PARAM_3'];
        }
    }
    if ($graphics) {
        include_once $path_to_root . "reporting/includes/class.graphic.inc";
        $pg = new graph();
    }
    $dec = 0;
    $cols = array(0, 50, 200, 350, 425, 500);
    //------------0--1---2----3----4----5--
    $headers = array(tr('Account'), tr('Account Name'), tr('Open Balance'), tr('Period'), tr('Close Balance'));
    $aligns = array('left', 'left', 'right', 'right', 'right');
    if ($dim == 2) {
        $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 3 => array('text' => tr('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => ''));
    } else {
        if ($dim == 1) {
            $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Dimension'), 'from' => get_dimension_string($dimension), 'to' => ''));
        } else {
            $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to));
        }
    }
    $rep = new FrontReport(tr('Balance Sheet'), "BalanceSheet.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $classname = '';
    $group = '';
    $totalopen = 0.0;
    $totalperiod = 0.0;
    $totalclose = 0.0;
    $classopen = 0.0;
    $classperiod = 0.0;
    $classclose = 0.0;
    $assetsopen = 0.0;
    $assetsperiod = 0.0;
    $assetsclose = 0.0;
    $closeclass = false;
    $accounts = get_gl_accounts_all(1);
    while ($account = db_fetch($accounts)) {
        $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;
        }
        if ($account['AccountClassName'] != $classname) {
            if ($classname != '') {
                $closeclass = true;
            }
        }
        if ($account['AccountTypeName'] != $group) {
            if ($group != '') {
                $rep->Line($rep->row + 6);
                $rep->row -= 6;
                $rep->TextCol(0, 2, tr('Total') . " " . $group);
                $rep->TextCol(2, 3, number_format2($totalopen, $dec));
                $rep->TextCol(3, 4, number_format2($totalperiod, $dec));
                $rep->TextCol(4, 5, number_format2($totalclose, $dec));
                if ($graphics) {
                    $pg->x[] = $group;
                    $pg->y[] = abs($totalclose);
                }
                $totalopen = $totalperiod = $totalclose = 0.0;
                $rep->row -= $rep->lineHeight + 4;
                if ($closeclass) {
                    $rep->Line($rep->row + 6);
                    $rep->row -= 6;
                    $rep->Font('bold');
                    $rep->TextCol(0, 2, tr('Total') . " " . $classname);
                    $rep->TextCol(2, 3, number_format2($classopen, $dec));
                    $rep->TextCol(3, 4, number_format2($classperiod, $dec));
                    $rep->TextCol(4, 5, number_format2($classclose, $dec));
                    $rep->Font();
                    $assetsopen += $classopen;
                    $assetsperiod += $classperiod;
                    $assetsclose += $classclose;
                    $classopen = $classperiod = $classclose = 0.0;
                    $rep->NewLine(3);
                    $closeclass = false;
                }
            }
            if ($account['AccountClassName'] != $classname) {
                $rep->Font('bold');
                $rep->TextCol(0, 5, $account['AccountClassName']);
                $rep->Font();
                $rep->row -= $rep->lineHeight + 4;
            }
            $group = $account['AccountTypeName'];
            $rep->TextCol(0, 5, $account['AccountTypeName']);
            $rep->Line($rep->row - 4);
            $rep->row -= $rep->lineHeight + 4;
        }
        $classname = $account['AccountClassName'];
        $totalopen += $prev_balance;
        $totalperiod += $curr_balance;
        $totalclose = $totalopen + $totalperiod;
        $classopen += $prev_balance;
        $classperiod += $curr_balance;
        $classclose = $classopen + $classperiod;
        $rep->TextCol(0, 1, $account['account_code']);
        $rep->TextCol(1, 2, $account['account_name']);
        $rep->TextCol(2, 3, number_format2($prev_balance, $dec));
        $rep->TextCol(3, 4, number_format2($curr_balance, $dec));
        $rep->TextCol(4, 5, number_format2($curr_balance + $prev_balance, $dec));
        $rep->NewLine();
        if ($rep->row < $rep->bottomMargin + 3 * $rep->lineHeight) {
            $rep->Line($rep->row - 2);
            $rep->Header();
        }
    }
    if ($account['AccountClassName'] != $classname) {
        if ($classname != '') {
            $closeclass = true;
        }
    }
    if ($account['AccountTypeName'] != $group) {
        if ($group != '') {
            $rep->Line($rep->row + 6);
            $rep->row -= 6;
            $rep->TextCol(0, 2, tr('Total') . " " . $group);
            $rep->TextCol(2, 3, number_format2($totalopen, $dec));
            $rep->TextCol(3, 4, number_format2($totalperiod, $dec));
            $rep->TextCol(4, 5, number_format2($totalclose, $dec));
            if ($graphics) {
                $pg->x[] = $group;
                $pg->y[] = abs($totalclose);
            }
            $rep->row -= $rep->lineHeight + 4;
            if ($closeclass) {
                $rep->Line($rep->row + 6);
                $calculateopen = -$assetsopen - $classopen;
                $calculateperiod = -$assetsperiod - $classperiod;
                $calculateclose = -$assetsclose - $classclose;
                $rep->row -= 6;
                $rep->TextCol(0, 2, tr('Calculated Return'));
                $rep->TextCol(2, 3, number_format2($calculateopen, $dec));
                $rep->TextCol(3, 4, number_format2($calculateperiod, $dec));
                $rep->TextCol(4, 5, number_format2($calculateclose, $dec));
                if ($graphics) {
                    $pg->x[] = tr('Calculated Return');
                    $pg->y[] = abs($calculateclose);
                }
                $rep->row -= $rep->lineHeight + 4;
                $rep->Font('bold');
                $rep->TextCol(0, 2, tr('Total') . " " . $classname);
                $rep->TextCol(2, 3, number_format2(-$assetsopen, $dec));
                $rep->TextCol(3, 4, number_format2(-$assetsperiod, $dec));
                $rep->TextCol(4, 5, number_format2(-$assetsclose, $dec));
                $rep->Font();
                $rep->NewLine();
            }
        }
    }
    $rep->Line($rep->row);
    if ($graphics) {
        global $decseps, $graph_skin;
        $pg->title = $rep->title;
        $pg->axis_x = tr("Group");
        $pg->axis_y = tr("Amount");
        $pg->graphic_1 = $to;
        $pg->type = $graphics;
        $pg->skin = $graph_skin;
        $pg->built_in = false;
        $pg->fontfile = $path_to_root . "reporting/fonts/Vera.ttf";
        $pg->latin_notation = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != ".";
        $filename = $comp_path . '/' . user_company() . "/pdf_files/test.png";
        $pg->display($filename, true);
        $w = $pg->width / 1.5;
        $h = $pg->height / 1.5;
        $x = ($rep->pageWidth - $w) / 2;
        $rep->NewLine(2);
        if ($rep->row - $h < $rep->bottomMargin) {
            $rep->Header();
        }
        $rep->AddImage($filename, $x, $rep->row - $h, $w, $h);
    }
    $rep->End();
}