Exemplo n.º 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();
}
Exemplo n.º 2
0
function print_list_of_journal_entries()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $from = $_REQUEST['PARAM_0'];
    $to = $_REQUEST['PARAM_1'];
    $systype = $_REQUEST['PARAM_2'];
    $comments = $_REQUEST['PARAM_3'];
    $dec = user_price_dec();
    $cols = array(0, 100, 240, 300, 400, 460, 520, 580);
    $headers = array(tr('Type/Account'), tr('Account Name'), tr('Date/Dim.'), tr('Person/Item/Memo'), tr('Debit'), tr('Credit'));
    $aligns = array('left', 'left', 'left', 'left', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Type'), 'from' => systypes::name($systype), 'to' => ''));
    $rep = new FrontReport(tr('List of Journal Entries'), "JournalEntries.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    if ($systype == -1) {
        $systype = null;
    }
    $trans = get_gl_transactions($from, $to, -1, null, 0, $systype);
    $typeno = 0;
    while ($myrow = db_fetch($trans)) {
        if ($typeno != $myrow['type_no']) {
            if ($typeno != 0) {
                $rep->Line($rep->row + 4);
                $rep->NewLine();
            }
            $typeno = $myrow['type_no'];
            $TransName = systypes::name($myrow['type']);
            $rep->TextCol(0, 2, $TransName . " # " . $myrow['type_no']);
            $rep->TextCol(2, 3, sql2date($myrow['tran_date']));
            $coms = payment_person_types::person_name($myrow["person_type_id"], $myrow["person_id"]);
            $memo = get_comments_string($myrow['type'], $myrow['type_no']);
            if ($memo != '') {
                $coms .= $coms != "" ? "/" : "" . $memo;
            }
            $rep->TextCol(3, 6, $coms);
            $rep->NewLine(2);
        }
        $rep->TextCol(0, 1, $myrow['account']);
        $rep->TextCol(1, 2, $myrow['account_name']);
        $dim_str = get_dimension_string($myrow['dimension_id']);
        $dim_str2 = get_dimension_string($myrow['dimension2_id']);
        if ($dim_str2 != "") {
            $dim_str .= "/" . $dim_str2;
        }
        $rep->TextCol(2, 3, $dim_str);
        $rep->TextCol(3, 4, $myrow['memo_']);
        if ($myrow['amount'] > 0.0) {
            $rep->TextCol(4, 5, number_format2(abs($myrow['amount']), $dec));
        } else {
            $rep->TextCol(5, 6, number_format2(abs($myrow['amount']), $dec));
        }
        $rep->NewLine(1, 2);
    }
    $rep->Line($rep->row + 4);
    $rep->End();
}
Exemplo n.º 3
0
function print_bill_of_material()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $frompart = $_REQUEST['PARAM_0'];
    $topart = $_REQUEST['PARAM_1'];
    $comments = $_REQUEST['PARAM_2'];
    $dec = user_qty_dec();
    $cols = array(0, 50, 305, 375, 445, 515);
    $headers = array(tr('Component'), tr('Description'), tr('Loc'), tr('Wrk Ctr'), tr('Quantity'));
    $aligns = array('left', 'left', 'left', 'left', 'right');
    $params = array(0 => $comments, 1 => array('text' => tr('Component'), 'from' => $frompart, 'to' => $topart));
    $rep = new FrontReport(tr('Bill of Material Listing'), "BillOfMaterial.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $res = getTransactions($frompart, $topart);
    $parent = '';
    while ($trans = db_fetch($res)) {
        if ($parent != $trans['parent']) {
            if ($parent != '') {
                $rep->Line($rep->row - 2);
                $rep->NewLine(2, 3);
            }
            $rep->TextCol(0, 1, $trans['parent']);
            $desc = get_item($trans['parent']);
            $rep->TextCol(1, 2, $desc['description']);
            $parent = $trans['parent'];
            $rep->NewLine();
        }
        $rep->NewLine();
        $rep->TextCol(0, 1, $trans['component']);
        $rep->TextCol(1, 2, $trans['CompDescription']);
        $rep->TextCol(2, 3, $trans['loc_code']);
        $rep->TextCol(3, 4, $trans['workcentre_added']);
        $rep->TextCol(4, 5, number_format2($trans['quantity'], $dec));
    }
    $rep->Line($rep->row - 4);
    $rep->End();
}
Exemplo n.º 4
0
function print_dimension_summary()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $fromdim = $_REQUEST['PARAM_0'];
    $todim = $_REQUEST['PARAM_1'];
    $showbal = $_REQUEST['PARAM_2'];
    $comments = $_REQUEST['PARAM_3'];
    $cols = array(0, 50, 210, 250, 320, 395, 465, 515);
    $headers = array(tr('Reference'), tr('Name'), tr('Type'), tr('Date'), tr('Due Date'), tr('Closed'), tr('YTD'));
    $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'right');
    $params = array(0 => $comments, 1 => array('text' => tr('Dimension'), 'from' => $fromdim, 'to' => $todim));
    $rep = new FrontReport(tr('Dimension Summary'), "DimensionSummary.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $res = getTransactions($fromdim, $todim);
    while ($trans = db_fetch($res)) {
        $rep->TextCol(0, 1, $trans['reference']);
        $rep->TextCol(1, 2, $trans['name']);
        $rep->TextCol(2, 3, $trans['type_']);
        $rep->TextCol(3, 4, $trans['date_']);
        $rep->TextCol(4, 5, $trans['due_date']);
        if ($trans['closed']) {
            $str = tr('Yes');
        } else {
            $str = tr('No');
        }
        $rep->TextCol(5, 6, $str);
        if ($showbal) {
            $balance = getYTD($trans['id']);
            $rep->TextCol(6, 7, number_format2($balance, 0));
        }
        $rep->NewLine(1, 2);
    }
    $rep->Line($rep->row);
    $rep->End();
}
Exemplo n.º 5
0
function print_order_status_list()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $from = $_REQUEST['PARAM_0'];
    $to = $_REQUEST['PARAM_1'];
    $category = $_REQUEST['PARAM_2'];
    $location = $_REQUEST['PARAM_3'];
    $backorder = $_REQUEST['PARAM_4'];
    $comments = $_REQUEST['PARAM_5'];
    $dec = user_qty_dec();
    if ($category == reserved_words::get_all_numeric()) {
        $category = 0;
    }
    if ($location == reserved_words::get_all()) {
        $location = null;
    }
    if ($category == 0) {
        $cat = tr('All');
    } else {
        $cat = get_category_name($category);
    }
    if ($location == null) {
        $loc = tr('All');
    } else {
        $loc = $location;
    }
    if ($backorder == 0) {
        $back = tr('All Orders');
    } else {
        $back = tr('Back Orders Only');
    }
    $cols = array(0, 60, 150, 260, 325, 385, 450, 515);
    $headers2 = array(tr('Order'), tr('Customer'), tr('Branch'), tr('Customer Ref'), tr('Ord Date'), tr('Del Date'), tr('Loc'));
    $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right');
    $headers = array(tr('Code'), tr('Description'), tr('Ordered'), tr('Invoiced'), tr('Outstanding'), '');
    $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Category'), 'from' => $cat, 'to' => ''), 3 => array('text' => tr('Location'), 'from' => $loc, 'to' => ''), 4 => array('text' => tr('Selection'), 'from' => $back, 'to' => ''));
    $cols2 = $cols;
    $aligns2 = $aligns;
    $rep = new FrontReport(tr('Order Status Listing'), "OrderStatusListing.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2);
    $rep->Header();
    $orderno = 0;
    $result = GetSalesOrders($from, $to, $category, $location, $backorder);
    while ($myrow = db_fetch($result)) {
        if ($rep->row < $rep->bottomMargin + 2 * $rep->lineHeight) {
            $orderno = 0;
            $rep->Header();
        }
        $rep->NewLine(0, 2, false, $orderno);
        if ($orderno != $myrow['order_no']) {
            if ($orderno != 0) {
                $rep->Line($rep->row);
                $rep->NewLine();
            }
            $rep->TextCol(0, 1, $myrow['order_no']);
            $rep->TextCol(1, 2, get_customer_name($myrow['debtor_no']));
            $rep->TextCol(2, 3, get_branch_name($myrow['branch_code']));
            $rep->TextCol(3, 4, $myrow['customer_ref']);
            $rep->TextCol(4, 5, sql2date($myrow['ord_date']));
            $rep->TextCol(5, 6, sql2date($myrow['delivery_date']));
            $rep->TextCol(6, 7, $myrow['from_stk_loc']);
            $rep->NewLine(2);
            $orderno = $myrow['order_no'];
        }
        $rep->TextCol(0, 1, $myrow['stk_code']);
        $rep->TextCol(1, 2, $myrow['description']);
        $rep->TextCol(2, 3, number_format2($myrow['quantity'], $dec));
        $rep->TextCol(3, 4, number_format2($myrow['qty_sent'], $dec));
        $rep->TextCol(4, 5, number_format2($myrow['quantity'] - $myrow['qty_sent'], $dec));
        if ($myrow['quantity'] - $myrow['qty_sent'] > 0) {
            $rep->Font('italic');
            $rep->TextCol(5, 6, tr('Outstanding'));
            $rep->Font();
        }
        $rep->NewLine();
        if ($rep->row < $rep->bottomMargin + 2 * $rep->lineHeight) {
            $orderno = 0;
            $rep->Header();
        }
    }
    $rep->Line($rep->row);
    $rep->End();
}
Exemplo n.º 6
0
function print_inventory_valuation_report()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $category = $_REQUEST['PARAM_0'];
    $location = $_REQUEST['PARAM_1'];
    $detail = $_REQUEST['PARAM_2'];
    $comments = $_REQUEST['PARAM_3'];
    $dec = user_price_dec();
    if ($category == reserved_words::get_all_numeric()) {
        $category = 0;
    }
    if ($category == 0) {
        $cat = tr('All');
    } else {
        $cat = get_category_name($category);
    }
    if ($location == reserved_words::get_all()) {
        $location = 'all';
    }
    if ($location == 'all') {
        $loc = tr('All');
    } else {
        $loc = $location;
    }
    $cols = array(0, 100, 250, 350, 450, 515);
    $headers = array(tr('Category'), '', tr('Quantity'), tr('Unit Cost'), tr('Value'));
    $aligns = array('left', 'left', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => tr('Category'), 'from' => $cat, 'to' => ''), 2 => array('text' => tr('Location'), 'from' => $loc, 'to' => ''));
    $rep = new FrontReport(tr('Inventory Valuation Report'), "InventoryValReport.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $res = getTransactions($category, $location);
    $total = $grandtotal = 0.0;
    $catt = '';
    while ($trans = db_fetch($res)) {
        if ($catt != $trans['cat_description']) {
            if ($catt != '') {
                if ($detail) {
                    $rep->NewLine(2, 3);
                    $rep->TextCol(0, 4, tr('Total'));
                }
                $rep->Textcol(4, 5, number_format2($total, $dec));
                if ($detail) {
                    $rep->Line($rep->row - 2);
                    $rep->NewLine();
                }
                $rep->NewLine();
                $total = 0.0;
            }
            $rep->TextCol(0, 1, $trans['category_id']);
            $rep->TextCol(1, 2, $trans['cat_description']);
            $catt = $trans['cat_description'];
            if ($detail) {
                $rep->NewLine();
            }
        }
        if ($detail) {
            $rep->NewLine();
            $rep->fontsize -= 2;
            $rep->TextCol(0, 1, $trans['stock_id']);
            $rep->TextCol(1, 2, $trans['description']);
            $rep->TextCol(2, 3, number_format2($trans['QtyOnHand'], user_qty_dec()));
            $rep->TextCol(3, 4, number_format2($trans['UnitCost'], $dec));
            $rep->TextCol(4, 5, number_format2($trans['ItemTotal'], $dec));
            $rep->fontsize += 2;
        }
        $total += $trans['ItemTotal'];
        $grandtotal += $trans['ItemTotal'];
    }
    if ($detail) {
        $rep->NewLine(2, 3);
        $rep->TextCol(0, 4, tr('Total'));
    }
    $rep->Textcol(4, 5, number_format2($total, $dec));
    if ($detail) {
        $rep->Line($rep->row - 2);
        $rep->NewLine();
    }
    $rep->NewLine(2, 1);
    $rep->TextCol(0, 4, tr('Grand Total'));
    $rep->TextCol(4, 5, number_format2($grandtotal, $dec));
    $rep->Line($rep->row - 4);
    $rep->End();
}
Exemplo n.º 7
0
function print_aged_supplier_analysis()
{
    global $comp_path, $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $to = $_REQUEST['PARAM_0'];
    $fromsupp = $_REQUEST['PARAM_1'];
    $currency = $_REQUEST['PARAM_2'];
    $summaryOnly = $_REQUEST['PARAM_3'];
    $graphics = $_REQUEST['PARAM_4'];
    $comments = $_REQUEST['PARAM_5'];
    if ($graphics) {
        include_once $path_to_root . "reporting/includes/class.graphic.inc";
        $pg = new graph();
    }
    if ($fromsupp == reserved_words::get_all_numeric()) {
        $from = tr('All');
    } else {
        $from = get_supplier_name($fromsupp);
    }
    $dec = user_price_dec();
    if ($summaryOnly == 1) {
        $summary = tr('Summary Only');
    } else {
        $summary = tr('Detailed Report');
    }
    if ($currency == reserved_words::get_all()) {
        $convert = true;
        $currency = tr('Balances in Home Currency');
    } else {
        $convert = false;
    }
    $PastDueDays1 = get_company_pref('past_due_days');
    $PastDueDays2 = 2 * $PastDueDays1;
    $nowdue = "1-" . $PastDueDays1 . " " . tr('Days');
    $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . tr('Days');
    $pastdue2 = tr('Over') . " " . $PastDueDays2 . " " . tr('Days');
    $cols = array(0, 100, 130, 190, 250, 320, 385, 450, 515);
    $headers = array(tr('Supplier'), '', '', tr('Current'), $nowdue, $pastdue1, $pastdue2, tr('Total Balance'));
    $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => tr('End Date'), 'from' => $to, 'to' => ''), 2 => array('text' => tr('Supplier'), 'from' => $from, 'to' => ''), 3 => array('text' => tr('Currency'), 'from' => $currency, 'to' => ''), 4 => array('text' => tr('Type'), 'from' => $summary, 'to' => ''));
    if ($convert) {
        $headers[2] = tr('currency');
    }
    $rep = new FrontReport(tr('Aged Supplier Analysis'), "AgedSupplierAnalysis.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $total = array();
    $total[0] = $total[1] = $total[2] = $total[3] = $total[4] = 0.0;
    $PastDueDays1 = get_company_pref('past_due_days');
    $PastDueDays2 = 2 * $PastDueDays1;
    $nowdue = "1-" . $PastDueDays1 . " " . tr('Days');
    $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . tr('Days');
    $pastdue2 = tr('Over') . " " . $PastDueDays2 . " " . tr('Days');
    $sql = "SELECT supplier_id, supp_name AS name, curr_code FROM suppliers ";
    if ($fromsupp != reserved_words::get_all_numeric()) {
        $sql .= "WHERE supplier_id={$fromsupp} ";
    }
    $sql .= "ORDER BY supp_name";
    $result = db_query($sql, "The suppliers could not be retrieved");
    while ($myrow = db_fetch($result)) {
        if (!$convert && $currency != $myrow['curr_code']) {
            continue;
        }
        $rep->fontSize += 2;
        $rep->TextCol(0, 3, $myrow['name']);
        if ($convert) {
            $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $to);
            $rep->TextCol(2, 4, $myrow['curr_code']);
        } else {
            $rate = 1.0;
        }
        $rep->fontSize -= 2;
        $supprec = get_supplier_details($myrow['supplier_id'], $to);
        foreach ($supprec as $i => $value) {
            $supprec[$i] *= $rate;
        }
        $total[0] += $supprec["Balance"] - $supprec["Due"];
        $total[1] += $supprec["Due"] - $supprec["Overdue1"];
        $total[2] += $supprec["Overdue1"] - $supprec["Overdue2"];
        $total[3] += $supprec["Overdue2"];
        $total[4] += $supprec["Balance"];
        $str = array(number_format2($supprec["Balance"] - $supprec["Due"], $dec), number_format2($supprec["Due"] - $supprec["Overdue1"], $dec), number_format2($supprec["Overdue1"] - $supprec["Overdue2"], $dec), number_format2($supprec["Overdue2"], $dec), number_format2($supprec["Balance"], $dec));
        for ($i = 0; $i < count($str); $i++) {
            $rep->TextCol($i + 3, $i + 4, $str[$i]);
        }
        $rep->NewLine(1, 2);
        if (!$summaryOnly) {
            $res = get_invoices($myrow['supplier_id'], $to);
            if (db_num_rows($res) == 0) {
                continue;
            }
            $rep->Line($rep->row + 4);
            while ($trans = db_fetch($res)) {
                $rep->NewLine(1, 2);
                $rep->TextCol(0, 1, $trans['type_name'], -2);
                $rep->TextCol(1, 2, $trans['reference'], -2);
                $rep->TextCol(2, 3, sql2date($trans['tran_date']), -2);
                foreach ($trans as $i => $value) {
                    $trans[$i] *= $rate;
                }
                $str = array(number_format2($trans["Balance"] - $trans["Due"], $dec), number_format2($trans["Due"] - $trans["Overdue1"], $dec), number_format2($trans["Overdue1"] - $trans["Overdue2"], $dec), number_format2($trans["Overdue2"], $dec), number_format2($trans["Balance"], $dec));
                for ($i = 0; $i < count($str); $i++) {
                    $rep->TextCol($i + 3, $i + 4, $str[$i]);
                }
            }
            $rep->Line($rep->row - 8);
            $rep->NewLine(2);
        }
    }
    if ($summaryOnly) {
        $rep->Line($rep->row + 4);
        $rep->NewLine();
    }
    $rep->fontSize += 2;
    $rep->TextCol(0, 3, tr('Grand Total'));
    $rep->fontSize -= 2;
    for ($i = 0; $i < count($total); $i++) {
        $rep->TextCol($i + 3, $i + 4, number_format2($total[$i], $dec));
        if ($graphics && $i < count($total) - 1) {
            $pg->y[$i] = abs($total[$i]);
        }
    }
    $rep->Line($rep->row - 8);
    if ($graphics) {
        global $decseps, $graph_skin;
        $pg->x = array(tr('Current'), $nowdue, $pastdue1, $pastdue2);
        $pg->title = $rep->title;
        $pg->axis_x = tr("Days");
        $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();
}
Exemplo n.º 8
0
function print_GL_transactions()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $rep = new FrontReport(tr('GL Account Transactions'), "GLAccountTransactions.pdf", user_pagesize());
    $dim = get_company_pref('use_dimension');
    $dimension = $dimension2 = 0;
    $from = $_REQUEST['PARAM_0'];
    $to = $_REQUEST['PARAM_1'];
    $fromacc = $_REQUEST['PARAM_2'];
    $toacc = $_REQUEST['PARAM_3'];
    if ($dim == 2) {
        $dimension = $_REQUEST['PARAM_4'];
        $dimension2 = $_REQUEST['PARAM_5'];
        $comments = $_REQUEST['PARAM_6'];
    } else {
        if ($dim == 1) {
            $dimension = $_REQUEST['PARAM_4'];
            $comments = $_REQUEST['PARAM_5'];
        } else {
            $comments = $_REQUEST['PARAM_4'];
        }
    }
    $dec = user_price_dec();
    $cols = array(0, 70, 90, 140, 210, 280, 340, 400, 450, 510, 570);
    //------------0--1---2---3----4----5----6----7----8----9----10-------
    //-----------------------dim1-dim2-----------------------------------
    //-----------------------dim1----------------------------------------
    //-------------------------------------------------------------------
    $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'right', 'right', 'right');
    if ($dim == 2) {
        $headers = array(tr('Type'), tr('#'), tr('Date'), tr('Dimension') . " 1", tr('Dimension') . " 2", tr('Person/Item'), tr('Debit'), tr('Credit'), tr('Balance'));
    } else {
        if ($dim == 1) {
            $headers = array(tr('Type'), tr('#'), tr('Date'), tr('Dimension'), "", tr('Person/Item'), tr('Debit'), tr('Credit'), tr('Balance'));
        } else {
            $headers = array(tr('Type'), tr('#'), tr('Date'), "", "", tr('Person/Item'), tr('Debit'), tr('Credit'), tr('Balance'));
        }
    }
    if ($dim == 2) {
        $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Accounts'), 'from' => $fromacc, 'to' => $toacc), 3 => array('text' => tr('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 4 => 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('Accounts'), 'from' => $fromacc, 'to' => $toacc), 3 => array('text' => tr('Dimension'), 'from' => get_dimension_string($dimension), 'to' => ''));
        } else {
            $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Accounts'), 'from' => $fromacc, 'to' => $toacc));
        }
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $accounts = get_gl_accounts($fromacc, $toacc);
    while ($account = db_fetch($accounts)) {
        if (is_account_balancesheet($account["account_code"])) {
            $begin = "";
        } else {
            if ($from < $begin) {
                $begin = add_days($from, -1);
            } else {
                $begin = add_days(begin_fiscalyear(), -1);
            }
        }
        $prev_balance = get_gl_balance_from_to($begin, $from, $account["account_code"], $dimension, $dimension2);
        $trans = get_gl_transactions($from, $to, -1, $account['account_code'], $dimension, $dimension2);
        $rows = db_num_rows($trans);
        if ($prev_balance == 0.0 && $rows == 0) {
            continue;
        }
        $rep->Font('bold');
        $rep->TextCol(0, 3, $account['account_code'] . " " . $account['account_name']);
        $rep->TextCol(3, 5, tr('Opening Balance'));
        if ($prev_balance > 0.0) {
            $rep->TextCol(6, 7, number_format2(abs($prev_balance), $dec));
        } else {
            $rep->TextCol(7, 8, number_format2(abs($prev_balance), $dec));
        }
        $rep->Font();
        $total = $prev_balance;
        $rep->NewLine(2);
        if ($rows > 0) {
            while ($myrow = db_fetch($trans)) {
                $total += $myrow['amount'];
                $rep->TextCol(0, 1, systypes::name($myrow["type"]));
                $rep->TextCol(1, 2, $myrow['type_no']);
                $rep->TextCol(2, 3, sql2date($myrow["tran_date"]));
                if ($dim >= 1) {
                    $rep->TextCol(3, 4, get_dimension_string($myrow['dimension_id']));
                }
                if ($dim > 1) {
                    $rep->TextCol(4, 5, get_dimension_string($myrow['dimension2_id']));
                }
                $rep->TextCol(5, 6, payment_person_types::person_name($myrow["person_type_id"], $myrow["person_id"], false));
                if ($myrow['amount'] > 0.0) {
                    $rep->TextCol(6, 7, number_format2(abs($myrow['amount']), $dec));
                } else {
                    $rep->TextCol(7, 8, number_format2(abs($myrow['amount']), $dec));
                }
                $rep->TextCol(8, 9, number_format2($total, $dec));
                $rep->NewLine();
                if ($rep->row < $rep->bottomMargin + $rep->lineHeight) {
                    $rep->Line($rep->row - 2);
                    $rep->Header();
                }
            }
            $rep->NewLine();
        }
        $rep->Font('bold');
        $rep->TextCol(3, 5, tr("Ending Balance"));
        if ($total > 0.0) {
            $rep->TextCol(6, 7, number_format2(abs($total), $dec));
        } else {
            $rep->TextCol(7, 8, number_format2(abs($total), $dec));
        }
        $rep->Font();
        $rep->Line($rep->row - $rep->lineHeight + 4);
        $rep->NewLine(2, 1);
    }
    $rep->End();
}
Exemplo n.º 9
0
function print_price_listing()
{
    global $comp_path, $path_to_root, $pic_height, $pic_width;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $category = $_REQUEST['PARAM_0'];
    $salestype = $_REQUEST['PARAM_1'];
    $pictures = $_REQUEST['PARAM_2'];
    $showGP = $_REQUEST['PARAM_3'];
    $comments = $_REQUEST['PARAM_4'];
    $dec = user_price_dec();
    if ($category == reserved_words::get_all_numeric()) {
        $category = 0;
    }
    if ($salestype == reserved_words::get_all_numeric()) {
        $salestype = 0;
    }
    if ($category == 0) {
        $cat = tr('All');
    } else {
        $cat = get_category_name($category);
    }
    if ($salestype == 0) {
        $stype = tr('All');
    } else {
        $stype = get_sales_type_name($salestype);
    }
    if ($showGP == 0) {
        $GP = tr('No');
    } else {
        $GP = tr('Yes');
    }
    $cols = array(0, 100, 385, 450, 515);
    $headers = array(tr('Category/Items'), tr('Description'), tr('Price'), tr('GP %'));
    $aligns = array('left', 'left', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => tr('Category'), 'from' => $cat, 'to' => ''), 2 => array('text' => tr('Sales Type'), 'from' => $stype, 'to' => ''), 3 => array('text' => tr('Show GP %'), 'from' => $GP, 'to' => ''));
    if ($pictures) {
        $user_comp = user_company();
    } else {
        $user_comp = "";
    }
    $rep = new FrontReport(tr('Price Listing'), "PriceListing.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $result = fetch_prices($category, $salestype);
    $currcode = '';
    $catgor = '';
    while ($myrow = db_fetch($result)) {
        if ($currcode != $myrow['curr_abrev']) {
            $rep->NewLine(2);
            $rep->fontSize += 2;
            $rep->TextCol(0, 3, $myrow['curr_abrev'] . " " . tr('Prices'));
            $currcode = $myrow['curr_abrev'];
            $rep->fontSize -= 2;
            $rep->NewLine();
        }
        if ($catgor != $myrow['description']) {
            $rep->Line($rep->row - $rep->lineHeight);
            $rep->NewLine(2);
            $rep->fontSize += 2;
            $rep->TextCol(0, 3, $myrow['category_id'] . " - " . $myrow['description']);
            $catgor = $myrow['description'];
            $rep->fontSize -= 2;
            $rep->NewLine();
        }
        $rep->NewLine();
        $rep->TextCol(0, 1, $myrow['stock_id']);
        $rep->TextCol(1, 2, $myrow['name']);
        $rep->TextCol(2, 3, number_format2($myrow['price'], $dec));
        if ($showGP) {
            if ($myrow['price'] != 0.0) {
                $disp = ($myrow['price'] - $myrow['Standardcost']) * 100 / $myrow['price'];
            } else {
                $disp = 0.0;
            }
            $rep->TextCol(3, 4, number_format2($disp, user_percent_dec()) . " %");
        }
        if ($pictures) {
            $image = $comp_path . '/' . $user_comp . "/images/" . $myrow['stock_id'] . ".jpg";
            if (file_exists($image)) {
                $rep->NewLine();
                if ($rep->row - $pic_height < $rep->bottomMargin) {
                    $rep->Header();
                }
                $rep->AddImage($image, $rep->cols[1], $rep->row - $pic_height, $pic_width, $pic_height);
                $rep->row -= $pic_height;
                $rep->NewLine();
            }
        } else {
            $rep->NewLine(0, 1);
        }
    }
    $rep->Line($rep->row - 4);
    $rep->End();
}
Exemplo n.º 10
0
function print_outstanding_GRN()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $fromsupp = $_REQUEST['PARAM_0'];
    $comments = $_REQUEST['PARAM_1'];
    if ($fromsupp == reserved_words::get_all_numeric()) {
        $from = tr('All');
    } else {
        $from = get_supplier_name($fromsupp);
    }
    $dec = user_price_dec();
    $cols = array(0, 40, 80, 190, 250, 320, 385, 450, 515);
    $headers = array(tr('GRN'), tr('Order'), tr('Item') . '/' . tr('Description'), tr('Qty Recd'), tr('qty Inv'), tr('Balance'), tr('Std Cost'), tr('Value'));
    $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => tr('Supplier'), 'from' => $from, 'to' => ''));
    $rep = new FrontReport(tr('Outstanding GRNs Report'), "OutstandingGRN.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $Tot_Val = 0;
    $Supplier = '';
    $SuppTot_Val = 0;
    $res = getTransactions($fromsupp);
    while ($GRNs = db_fetch($res)) {
        if ($Supplier != $GRNs['supplier_id']) {
            if ($Supplier != '') {
                $rep->NewLine(2);
                $rep->TextCol(0, 7, tr('Total'));
                $rep->TextCol(7, 8, number_format2($SuppTot_Val, $dec));
                $rep->Line($rep->row - 2);
                $rep->NewLine(3);
                $SuppTot_Val = 0;
            }
            $rep->TextCol(0, 6, $GRNs['supp_name']);
            $Supplier = $GRNs['supplier_id'];
        }
        $rep->NewLine();
        $rep->TextCol(0, 1, $GRNs['id']);
        $rep->TextCol(1, 2, $GRNs['order_no']);
        $rep->TextCol(2, 3, $GRNs['item_code'] . '-' . $GRNs['description']);
        $rep->TextCol(3, 4, number_format2($GRNs['qty_recd'], $dec));
        $rep->TextCol(4, 5, number_format2($GRNs['quantity_inv'], $dec));
        $QtyOstg = $GRNs['qty_recd'] - $GRNs['quantity_inv'];
        $Value = ($GRNs['qty_recd'] - $GRNs['quantity_inv']) * $GRNs['std_cost_unit'];
        $rep->TextCol(5, 6, number_format2($QtyOstg, $dec));
        $rep->TextCol(6, 7, number_format2($GRNs['std_cost_unit'], $dec));
        $rep->TextCol(7, 8, number_format2($Value, $dec));
        $Tot_Val += $Value;
        $SuppTot_Val += $Value;
        $rep->NewLine(0, 1);
    }
    if ($Supplier != '') {
        $rep->NewLine();
        $rep->TextCol(0, 7, tr('Total'));
        $rep->TextCol(7, 8, number_format2($SuppTot_Val, $dec));
        $rep->Line($rep->row - 2);
        $rep->NewLine(3);
        $SuppTot_Val = 0;
    }
    $rep->NewLine(2);
    $rep->TextCol(0, 7, tr('Grand Total'));
    $rep->TextCol(7, 8, number_format2($Tot_Val, $dec));
    $rep->Line($rep->row - 2);
    $rep->End();
}
Exemplo n.º 11
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();
}
Exemplo n.º 12
0
function print_trial_balance()
{
    global $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'];
    $zero = $_REQUEST['PARAM_2'];
    if ($dim == 2) {
        $dimension = $_REQUEST['PARAM_3'];
        $dimension2 = $_REQUEST['PARAM_4'];
        $comments = $_REQUEST['PARAM_5'];
    } else {
        if ($dim == 1) {
            $dimension = $_REQUEST['PARAM_3'];
            $comments = $_REQUEST['PARAM_4'];
        } else {
            $comments = $_REQUEST['PARAM_3'];
        }
    }
    $dec = user_price_dec();
    $cols2 = array(0, 50, 230, 330, 430, 530);
    //-------------0--1---2----3----4----5--
    $headers2 = array('', '', tr('Brought Forward'), tr('This Period'), tr('Balance'));
    $aligns2 = array('left', 'left', 'left', 'left', 'left');
    $cols = array(0, 50, 200, 250, 300, 350, 400, 450, 500, 550);
    //------------0--1---2----3----4----5----6----7----8----9--
    $headers = array(tr('Account'), tr('Account Name'), tr('Debit'), tr('Credit'), tr('Debit'), tr('Credit'), tr('Debit'), tr('Credit'));
    $aligns = array('left', 'left', 'right', 'right', 'right', '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('Trial Balance'), "TrialBalance.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2);
    $rep->Header();
    $accounts = get_gl_accounts();
    while ($account = db_fetch($accounts)) {
        if (is_account_balancesheet($account["account_code"])) {
            $begin = "";
        } else {
            if ($from < $begin) {
                $begin = add_days($from, -1);
            } else {
                $begin = add_days(begin_fiscalyear(), -1);
            }
        }
        $prev_balance = get_gl_balance_from_to($begin, $from, $account["account_code"], $dimension, $dimension2);
        $curr_balance = get_gl_trans_from_to($from, $to, $account["account_code"], $dimension, $dimension2);
        if ($zero == 0 && !$prev_balance && !$curr_balance) {
            continue;
        }
        $rep->TextCol(0, 1, $account['account_code']);
        $rep->TextCol(1, 2, $account['account_name']);
        if ($prev_balance > 0.0) {
            $rep->TextCol(2, 3, number_format2(abs($prev_balance), $dec));
        } else {
            $rep->TextCol(3, 4, number_format2(abs($prev_balance), $dec));
        }
        if ($curr_balance > 0.0) {
            $rep->TextCol(4, 5, number_format2(abs($curr_balance), $dec));
        } else {
            $rep->TextCol(5, 6, number_format2(abs($curr_balance), $dec));
        }
        if ($curr_balance + $prev_balance > 0.0) {
            $rep->TextCol(6, 7, number_format2(abs($curr_balance + $prev_balance), $dec));
        } else {
            $rep->TextCol(7, 8, number_format2(abs($curr_balance + $prev_balance), $dec));
        }
        $rep->NewLine();
        if ($rep->row < $rep->bottomMargin + $rep->lineHeight) {
            $rep->Line($rep->row - 2);
            $rep->Header();
        }
    }
    $rep->Line($rep->row);
    $rep->End();
}
Exemplo n.º 13
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();
}
Exemplo n.º 14
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();
}
Exemplo n.º 15
0
function print_customer_details_listing()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $from = $_REQUEST['PARAM_0'];
    $area = $_REQUEST['PARAM_1'];
    $folk = $_REQUEST['PARAM_2'];
    $more = $_REQUEST['PARAM_3'];
    $less = $_REQUEST['PARAM_4'];
    $comments = $_REQUEST['PARAM_5'];
    $dec = 0;
    if ($area == reserved_words::get_all_numeric()) {
        $area = 0;
    }
    if ($folk == reserved_words::get_all_numeric()) {
        $folk = 0;
    }
    if ($area == 0) {
        $sarea = tr('All Areas');
    } else {
        $sarea = get_area_name($area);
    }
    if ($folk == 0) {
        $salesfolk = tr('All Sales Folk');
    } else {
        $salesfolk = get_salesman_name($folk);
    }
    if ($more != '') {
        $morestr = tr('Greater than ') . number_format2($more, $dec);
    } else {
        $morestr = '';
    }
    if ($less != '') {
        $lessstr = tr('Less than ') . number_format2($less, $dec);
    } else {
        $lessstr = '';
    }
    $more = (double) $more;
    $less = (double) $less;
    $cols = array(0, 150, 300, 400, 550);
    $headers = array(tr('Customer Postal Address'), tr('Price/Turnover'), tr('Branch Contact Information'), tr('Branch Delivery Address'));
    $aligns = array('left', 'left', 'left', 'left');
    $params = array(0 => $comments, 1 => array('text' => tr('Activity Since'), 'from' => $from, 'to' => ''), 2 => array('text' => tr('Sales Areas'), 'from' => $sarea, 'to' => ''), 3 => array('text' => tr('Sales Folk'), 'from' => $salesfolk, 'to' => ''), 4 => array('text' => tr('Activity'), 'from' => $morestr, 'to' => $lessstr));
    $rep = new FrontReport(tr('Customer Details Listing'), "CustomerDetailsListing.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $result = get_customer_details_for_report($area, $folk);
    $carea = '';
    $sman = '';
    while ($myrow = db_fetch($result)) {
        $printcustomer = true;
        if ($more != '' || $less != '') {
            $turnover = getTransactions($myrow['debtor_no'], $myrow['branch_code'], $from);
            if ($more != 0.0 && $turnover <= (double) $more) {
                $printcustomer = false;
            }
            if ($less != 0.0 && $turnover >= (double) $less) {
                $printcustomer = false;
            }
        }
        if ($printcustomer) {
            if ($carea != $myrow['description']) {
                $rep->fontSize += 2;
                $rep->NewLine(2, 7);
                $rep->Font('bold');
                $rep->TextCol(0, 3, tr('Customers in') . " " . $myrow['description']);
                $carea = $myrow['description'];
                $rep->fontSize -= 2;
                $rep->Font();
                $rep->NewLine();
            }
            if ($sman != $myrow['salesman_name']) {
                $rep->fontSize += 2;
                $rep->NewLine(1, 7);
                $rep->Font('bold');
                $rep->TextCol(0, 3, $myrow['salesman_name']);
                $sman = $myrow['salesman_name'];
                $rep->fontSize -= 2;
                $rep->Font();
                $rep->NewLine();
            }
            $rep->NewLine();
            $rep->TextCol(0, 1, $myrow['name']);
            $adr = Explode("\n", $myrow['address']);
            $count1 = count($adr);
            for ($i = 0; $i < $count1; $i++) {
                $rep->TextCol(0, 1, $adr[$i], 0, ($i + 1) * $rep->lineHeight);
            }
            $count1++;
            $rep->TextCol(1, 2, tr('Price List') . ": " . $myrow['sales_type']);
            if ($more != 0.0 || $less != 0.0) {
                $rep->TextCol(1, 2, tr('Turnover') . ": " . number_format2($turnover, $dec), 0, $rep->lineHeight);
            }
            $rep->TextCol(2, 3, $myrow['br_name']);
            $rep->TextCol(2, 3, $myrow['contact_name'], 0, $rep->lineHeight);
            $rep->TextCol(2, 3, tr('Ph') . ": " . $myrow['phone'], 0, 2 * $rep->lineHeight);
            $rep->TextCol(2, 3, tr('Fax') . ": " . $myrow['fax'], 0, 3 * $rep->lineHeight);
            $adr = Explode("\n", $myrow['br_address']);
            $count2 = count($adr);
            for ($i = 0; $i < $count2; $i++) {
                $rep->TextCol(3, 4, $adr[$i], 0, ($i + 1) * $rep->lineHeight);
            }
            $rep->TextCol(3, 4, $myrow['email'], 0, ($count2 + 1) * $rep->lineHeight);
            $count2++;
            $count1 = Max($count1, $count2);
            $count1 = Max($count1, 4);
            $rep->NewLine($count1);
            $rep->Line($rep->row + 8);
            $rep->NewLine(0, 3);
        }
    }
    $rep->End();
}
Exemplo n.º 16
0
function print_payment_report()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $to = $_REQUEST['PARAM_0'];
    $fromsupp = $_REQUEST['PARAM_1'];
    $currency = $_REQUEST['PARAM_2'];
    $comments = $_REQUEST['PARAM_3'];
    if ($fromsupp == reserved_words::get_all_numeric()) {
        $from = tr('All');
    } else {
        $from = get_supplier_name($fromsupp);
    }
    $dec = user_price_dec();
    if ($currency == reserved_words::get_all()) {
        $convert = true;
        $currency = tr('Balances in Home Currency');
    } else {
        $convert = false;
    }
    $cols = array(0, 100, 130, 190, 250, 320, 385, 450, 515);
    $headers = array(tr('Trans Type'), tr('#'), tr('Due Date'), '', '', '', tr('Total'), tr('Balance'));
    $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => tr('End Date'), 'from' => $to, 'to' => ''), 2 => array('text' => tr('Supplier'), 'from' => $from, 'to' => ''), 3 => array('text' => tr('Currency'), 'from' => $currency, 'to' => ''));
    $rep = new FrontReport(tr('Payment Report'), "PaymentReport.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $total = array();
    $grandtotal = array(0, 0);
    $sql = "SELECT supplier_id, supp_name AS name, curr_code, payment_terms.terms FROM suppliers, payment_terms\n\t\tWHERE ";
    if ($fromsupp != reserved_words::get_all_numeric()) {
        $sql .= "supplier_id={$fromsupp} AND ";
    }
    $sql .= "suppliers.payment_terms = payment_terms.terms_indicator\n\t\tORDER BY supp_name";
    $result = db_query($sql, "The customers could not be retrieved");
    while ($myrow = db_fetch($result)) {
        if (!$convert && $currency != $myrow['curr_code']) {
            continue;
        }
        $rep->fontSize += 2;
        $rep->TextCol(0, 6, $myrow['name'] . " - " . $myrow['terms']);
        if ($convert) {
            $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $to);
            $rep->TextCol(6, 7, $myrow['curr_code']);
        } else {
            $rate = 1.0;
        }
        $rep->fontSize -= 2;
        $rep->NewLine(1, 2);
        $res = getTransactions($myrow['supplier_id'], $to);
        if (db_num_rows($res) == 0) {
            continue;
        }
        $rep->Line($rep->row + 4);
        $total[0] = $total[1] = 0.0;
        while ($trans = db_fetch($res)) {
            $rep->NewLine(1, 2);
            $rep->TextCol(0, 1, $trans['type_name']);
            $rep->TextCol(1, 2, $trans['supp_reference']);
            $rep->TextCol(2, 3, sql2date($trans['due_date']));
            $item[0] = Abs($trans['TranTotal']) * $rate;
            $rep->TextCol(6, 7, number_format2($item[0], $dec));
            $item[1] = $trans['Balance'] * $rate;
            $rep->TextCol(7, 8, number_format2($item[1], $dec));
            for ($i = 0; $i < 2; $i++) {
                $total[$i] += $item[$i];
                $grandtotal[$i] += $item[$i];
            }
        }
        $rep->Line($rep->row - 8);
        $rep->NewLine(2);
        $rep->TextCol(0, 3, tr('Total'));
        for ($i = 0; $i < 2; $i++) {
            $rep->TextCol($i + 6, $i + 7, number_format2($total[$i], $dec));
            $total[$i] = 0.0;
        }
        $rep->Line($rep->row - 4);
        $rep->NewLine(2);
    }
    $rep->fontSize += 2;
    $rep->TextCol(0, 3, tr('Grand Total'));
    $rep->fontSize -= 2;
    for ($i = 0; $i < 2; $i++) {
        $rep->TextCol($i + 6, $i + 7, number_format2($grandtotal[$i], $dec));
    }
    $rep->Line($rep->row - 4);
    $rep->End();
}
Exemplo n.º 17
0
function print_stock_check()
{
    global $comp_path, $path_to_root, $pic_height, $pic_width;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $category = $_REQUEST['PARAM_0'];
    $location = $_REQUEST['PARAM_1'];
    $pictures = $_REQUEST['PARAM_2'];
    $comments = $_REQUEST['PARAM_3'];
    $dec = user_qty_dec();
    if ($category == reserved_words::get_all_numeric()) {
        $category = 0;
    }
    if ($category == 0) {
        $cat = tr('All');
    } else {
        $cat = get_category_name($category);
    }
    if ($location == reserved_words::get_all()) {
        $location = 'all';
    }
    if ($location == 'all') {
        $loc = tr('All');
    } else {
        $loc = $location;
    }
    $cols = array(0, 100, 305, 375, 445, 515);
    $headers = array(tr('Category'), tr('Description'), tr('Quantity'), tr('Demand'), tr('Difference'));
    $aligns = array('left', 'left', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => tr('Category'), 'from' => $cat, 'to' => ''), 2 => array('text' => tr('Location'), 'from' => $loc, 'to' => ''));
    if ($pictures) {
        $user_comp = user_company();
    } else {
        $user_comp = "";
    }
    $rep = new FrontReport(tr('Stock Check Sheets'), "StockCheckSheet.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $res = getTransactions($category, $location);
    $catt = '';
    while ($trans = db_fetch($res)) {
        if ($catt != $trans['cat_description']) {
            if ($catt != '') {
                $rep->Line($rep->row - 2);
                $rep->NewLine(2, 3);
            }
            $rep->TextCol(0, 1, $trans['category_id']);
            $rep->TextCol(1, 2, $trans['cat_description']);
            $catt = $trans['cat_description'];
            $rep->NewLine();
        }
        $demandqty = getDemandQty($trans['stock_id'], $trans['loc_code']);
        $demandqty += getDemandAsmQty($trans['stock_id'], $trans['loc_code']);
        $rep->NewLine();
        $rep->TextCol(0, 1, $trans['stock_id']);
        $rep->TextCol(1, 2, $trans['description']);
        $rep->TextCol(2, 3, number_format2($trans['QtyOnHand'], $dec));
        $rep->TextCol(3, 4, number_format2($demandqty, $dec));
        $rep->TextCol(4, 5, number_format2($trans['QtyOnHand'] - $demandqty, $dec));
        if ($pictures) {
            $image = $comp_path . '/' . $user_comp . '/images/' . $trans['stock_id'] . '.jpg';
            if (file_exists($image)) {
                $rep->NewLine();
                if ($rep->row - $height < $rep->bottomMargin) {
                    $rep->Header();
                }
                $rep->AddImage($image, $rep->cols[1], $rep->row - $pic_height, $pic_width, $pic_height);
                $rep->row -= $pic_height;
                $rep->NewLine();
            }
        }
    }
    $rep->Line($rep->row - 4);
    $rep->End();
}
Exemplo n.º 18
0
function print_salesman_list()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $from = $_REQUEST['PARAM_0'];
    $to = $_REQUEST['PARAM_1'];
    $summary = $_REQUEST['PARAM_2'];
    $comments = $_REQUEST['PARAM_3'];
    if ($summary == 0) {
        $sum = tr("No");
    } else {
        $sum = tr("Yes");
    }
    $dec = user_qty_dec();
    $cols = array(0, 60, 150, 220, 325, 385, 450, 515);
    $headers = array(tr('Invoice'), tr('Customer'), tr('Branch'), tr('Customer Ref'), tr('Inv Date'), tr('Total'), tr('Provision'));
    $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right');
    $headers2 = array(tr('Salesman'), " ", tr('Phone'), tr('Email'), tr('Provision'), tr('Break Pt.'), tr('Provision') . " 2");
    $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Summary Only'), 'from' => $sum, 'to' => ''));
    $cols2 = $cols;
    $aligns2 = $aligns;
    $rep = new FrontReport(tr('Salesman Listing'), "SalesmanListing.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2);
    $rep->Header();
    $salesman = 0;
    $subtotal = $total = $subprov = $provtotal = 0;
    $result = GetSalesmanTrans($from, $to);
    while ($myrow = db_fetch($result)) {
        if ($rep->row < $rep->bottomMargin + 2 * $rep->lineHeight) {
            $salesman = 0;
            $rep->Header();
        }
        $rep->NewLine(0, 2, false, $salesman);
        if ($salesman != $myrow['salesman_code']) {
            if ($salesman != 0) {
                $rep->Line($rep->row - 8);
                $rep->NewLine(2);
                $rep->TextCol(0, 3, tr('Total'));
                $rep->TextCol(5, 6, number_format2($subtotal, $dec));
                $rep->TextCol(6, 7, number_format2($subprov, $dec));
                $rep->Line($rep->row - 4);
                $rep->NewLine(2);
                //$rep->Line($rep->row);
            }
            $rep->TextCol(0, 2, $myrow['salesman_code'] . " " . $myrow['salesman_name']);
            $rep->TextCol(2, 3, $myrow['salesman_phone']);
            $rep->TextCol(3, 4, $myrow['salesman_email']);
            $rep->TextCol(4, 5, number_format2($myrow['provision'], user_percent_dec()) . " %");
            $rep->TextCol(5, 6, number_format2($myrow['break_pt'], $dec));
            $rep->TextCol(6, 7, number_format2($myrow['provision2'], user_percent_dec()) . " %");
            $rep->NewLine(2);
            $salesman = $myrow['salesman_code'];
            $total += $subtotal;
            $provtotal += $subprov;
            $subtotal = 0;
            $subprov = 0;
        }
        $date = sql2date($myrow['tran_date']);
        $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $date);
        $amt = $myrow['InvoiceTotal'] * $rate;
        if ($subprov > $myrow['break_pt'] && $myrow['provision2'] != 0) {
            $prov = $myrow['provision2'] * $amt / 100;
        } else {
            $prov = $myrow['provision'] * $amt / 100;
        }
        if (!$summary) {
            $rep->TextCol(0, 1, $myrow['trans_no']);
            $rep->TextCol(1, 2, $myrow['DebtorName']);
            $rep->TextCol(2, 3, $myrow['br_name']);
            $rep->TextCol(3, 4, $myrow['contact_name']);
            $rep->TextCol(4, 5, $date);
            $rep->TextCol(5, 6, number_format2($amt, $dec));
            $rep->TextCol(6, 7, number_format2($prov, $dec));
            $rep->NewLine();
            if ($rep->row < $rep->bottomMargin + 2 * $rep->lineHeight) {
                $salesman = 0;
                $rep->Header();
            }
        }
        $subtotal += $amt;
        $subprov += $prov;
    }
    if ($salesman != 0) {
        $rep->Line($rep->row - 4);
        $rep->NewLine(2);
        $rep->TextCol(0, 3, tr('Total'));
        $rep->TextCol(5, 6, number_format2($subtotal, $dec));
        $rep->TextCol(6, 7, number_format2($subprov, $dec));
        $rep->Line($rep->row - 4);
        $rep->NewLine(2);
        //$rep->Line($rep->row);
        $total += $subtotal;
        $provtotal += $subprov;
    }
    $rep->fontSize += 2;
    $rep->TextCol(0, 3, tr('Grand Total'));
    $rep->fontSize -= 2;
    $rep->TextCol(5, 6, number_format2($total, $dec));
    $rep->TextCol(6, 7, number_format2($provtotal, $dec));
    $rep->Line($rep->row - 4);
    $rep->End();
}
Exemplo n.º 19
0
function print_customer_balances()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $to = $_REQUEST['PARAM_0'];
    $fromcust = $_REQUEST['PARAM_1'];
    $currency = $_REQUEST['PARAM_2'];
    $comments = $_REQUEST['PARAM_3'];
    if ($fromcust == reserved_words::get_all_numeric()) {
        $from = tr('All');
    } else {
        $from = get_customer_name($fromcust);
    }
    $dec = user_price_dec();
    if ($currency == reserved_words::get_all()) {
        $convert = true;
        $currency = tr('Balances in Home Currency');
    } else {
        $convert = false;
    }
    $cols = array(0, 100, 130, 190, 250, 320, 385, 450, 515);
    $headers = array(tr('Trans Type'), tr('#'), tr('Date'), tr('Due Date'), tr('Charges'), tr('Credits'), tr('Allocated'), tr('Outstanding'));
    $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => tr('End Date'), 'from' => $to, 'to' => ''), 2 => array('text' => tr('Customer'), 'from' => $from, 'to' => ''), 3 => array('text' => tr('Currency'), 'from' => $currency, 'to' => ''));
    $rep = new FrontReport(tr('Customer Balances'), "CustomerBalances.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $grandtotal = array(0, 0, 0, 0);
    $sql = "SELECT debtor_no, name, curr_code FROM debtors_master ";
    if ($fromcust != reserved_words::get_all_numeric()) {
        $sql .= "WHERE debtor_no={$fromcust} ";
    }
    $sql .= "ORDER BY name";
    $result = db_query($sql, "The customers could not be retrieved");
    while ($myrow = db_fetch($result)) {
        if (!$convert && $currency != $myrow['curr_code']) {
            continue;
        }
        $rep->fontSize += 2;
        $rep->TextCol(0, 3, $myrow['name']);
        if ($convert) {
            $rep->TextCol(3, 4, $myrow['curr_code']);
        }
        $rep->fontSize -= 2;
        $rep->NewLine(1, 2);
        $res = get_transactions($myrow['debtor_no'], $to);
        if (db_num_rows($res) == 0) {
            continue;
        }
        $rep->Line($rep->row + 4);
        $total = array(0, 0, 0, 0);
        while ($trans = db_fetch($res)) {
            $rep->NewLine(1, 2);
            $rep->TextCol(0, 1, $trans['type_name']);
            $rep->TextCol(1, 2, $trans['reference']);
            $date = sql2date($trans['tran_date']);
            $rep->TextCol(2, 3, $date);
            if ($trans['type'] == 10) {
                $rep->TextCol(3, 4, sql2date($trans['due_date']));
            }
            $item[0] = $item[1] = 0.0;
            if ($convert) {
                $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $date);
            } else {
                $rate = 1.0;
            }
            if ($trans['type'] == 11 || $trans['type'] == 12 || $trans['type'] == 2) {
                $trans['TotalAmount'] *= -1;
            }
            if ($trans['TotalAmount'] > 0.0) {
                $item[0] = abs($trans['TotalAmount']) * $rate;
                $rep->TextCol(4, 5, number_format2($item[0], $dec));
            } else {
                $item[1] = Abs($trans['TotalAmount']) * $rate;
                $rep->TextCol(5, 6, number_format2($item[1], $dec));
            }
            $item[2] = $trans['Allocated'] * $rate;
            $rep->TextCol(6, 7, number_format2($item[2], $dec));
            if ($trans['type'] == 10) {
                $item[3] = ($trans['TotalAmount'] - $trans['Allocated']) * $rate;
            } else {
                $item[3] = ($trans['TotalAmount'] + $trans['Allocated']) * $rate;
            }
            $rep->TextCol(7, 8, number_format2($item[3], $dec));
            for ($i = 0; $i < 4; $i++) {
                $total[$i] += $item[$i];
                $grandtotal[$i] += $item[$i];
            }
        }
        $rep->Line($rep->row - 8);
        $rep->NewLine(2);
        $rep->TextCol(0, 3, tr('Total'));
        for ($i = 0; $i < 4; $i++) {
            $rep->TextCol($i + 4, $i + 5, number_format2($total[$i], $dec));
        }
        $rep->Line($rep->row - 4);
        $rep->NewLine(2);
    }
    $rep->fontSize += 2;
    $rep->TextCol(0, 3, tr('Grand Total'));
    $rep->fontSize -= 2;
    for ($i = 0; $i < 4; $i++) {
        $rep->TextCol($i + 4, $i + 5, number_format2($grandtotal[$i], $dec));
    }
    $rep->Line($rep->row - 4);
    $rep->End();
}
Exemplo n.º 20
0
function print_inventory_planning()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $category = $_REQUEST['PARAM_0'];
    $location = $_REQUEST['PARAM_1'];
    $comments = $_REQUEST['PARAM_2'];
    $dec = user_qty_dec();
    if ($category == reserved_words::get_all_numeric()) {
        $category = 0;
    }
    if ($category == 0) {
        $cat = tr('All');
    } else {
        $cat = get_category_name($category);
    }
    if ($location == reserved_words::get_all()) {
        $location = 'all';
    }
    if ($location == 'all') {
        $loc = tr('All');
    } else {
        $loc = $location;
    }
    $cols = array(0, 50, 150, 180, 210, 240, 270, 300, 330, 390, 435, 480, 525);
    $per0 = strftime('%b', mktime(0, 0, 0, date('m'), date('d'), date('Y')));
    $per1 = strftime('%b', mktime(0, 0, 0, date('m') - 1, date('d'), date('Y')));
    $per2 = strftime('%b', mktime(0, 0, 0, date('m') - 2, date('d'), date('Y')));
    $per3 = strftime('%b', mktime(0, 0, 0, date('m') - 3, date('d'), date('Y')));
    $per4 = strftime('%b', mktime(0, 0, 0, date('m') - 4, date('d'), date('Y')));
    $headers = array(tr('Category'), '', $per4, $per3, $per2, $per1, $per0, '3*M', tr('QOH'), tr('Cust Ord'), tr('Supp Ord'), tr('Sugg Ord'));
    $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => tr('Category'), 'from' => $cat, 'to' => ''), 2 => array('text' => tr('Location'), 'from' => $loc, 'to' => ''));
    $rep = new FrontReport(tr('Inventory Planning Report'), "InventoryPlanning.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $res = getTransactions($category, $location);
    $catt = '';
    while ($trans = db_fetch($res)) {
        if ($catt != $trans['cat_description']) {
            if ($catt != '') {
                $rep->Line($rep->row - 2);
                $rep->NewLine(2, 3);
            }
            $rep->TextCol(0, 1, $trans['category_id']);
            $rep->TextCol(1, 2, $trans['cat_description']);
            $catt = $trans['cat_description'];
            $rep->NewLine();
        }
        $custqty = getCustQty($trans['stock_id'], $trans['loc_code']);
        $custqty += getCustAsmQty($trans['stock_id'], $trans['loc_code']);
        $suppqty = getSuppQty($trans['stock_id'], $trans['loc_code']);
        $period = getPeriods($trans['stock_id'], $trans['loc_code']);
        $rep->NewLine();
        $rep->TextCol(0, 1, $trans['stock_id']);
        $rep->TextCol(1, 2, $trans['description']);
        $rep->TextCol(2, 3, number_format2($period['prd0'], $dec));
        $rep->TextCol(3, 4, number_format2($period['prd1'], $dec));
        $rep->TextCol(4, 5, number_format2($period['prd2'], $dec));
        $rep->TextCol(5, 6, number_format2($period['prd3'], $dec));
        $rep->TextCol(6, 7, number_format2($period['prd4'], $dec));
        $MaxMthSales = Max($period['prd0'], $period['prd1'], $period['prd2'], $period['prd3']);
        $IdealStockHolding = $MaxMthSales * 3;
        $rep->TextCol(7, 8, number_format2($IdealStockHolding, $dec));
        $rep->TextCol(8, 9, number_format2($trans['qty_on_hand'], $dec));
        $rep->TextCol(9, 10, number_format2($custqty, $dec));
        $rep->TextCol(10, 11, number_format2($suppqty, $dec));
        $SuggestedTopUpOrder = $IdealStockHolding - $trans['qty_on_hand'] + $custqty - $suppqty;
        if ($SuggestedTopUpOrder < 0.0) {
            $SuggestedTopUpOrder = 0.0;
        }
        $rep->TextCol(11, 12, number_format2($SuggestedTopUpOrder, $dec));
    }
    $rep->Line($rep->row - 4);
    $rep->End();
}
Exemplo n.º 21
0
function print_tax_report()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $rep = new FrontReport(tr('Tax Report'), "TaxReport.pdf", user_pagesize());
    $from = $_REQUEST['PARAM_0'];
    $to = $_REQUEST['PARAM_1'];
    $summaryOnly = $_REQUEST['PARAM_2'];
    $comments = $_REQUEST['PARAM_3'];
    $dec = user_price_dec();
    if ($summaryOnly == 1) {
        $summary = tr('Summary Only');
    } else {
        $summary = tr('Detailed Report');
    }
    $res = getTaxTypes();
    $taxes = array();
    $i = 0;
    while ($tax = db_fetch($res)) {
        $taxes[$i++] = $tax['id'];
    }
    $idcounter = count($taxes);
    $totalinvout = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    $totaltaxout = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    $totalinvin = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    $totaltaxin = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    if (!$summaryOnly) {
        $cols = array(0, 80, 130, 190, 290, 370, 435, 500, 565);
        $headers = array(tr('Trans Type'), tr('#'), tr('Date'), tr('Name'), tr('Branch Name'), tr('Net'), tr('Tax'));
        $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right');
        $params = array(0 => $comments, 1 => array('text' => tr('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => tr('Type'), 'from' => $summary, 'to' => ''));
        $rep->Font();
        $rep->Info($params, $cols, $headers, $aligns);
        $rep->Header();
    }
    $totalnet = 0.0;
    $totaltax = 0.0;
    $transactions = getCustTransactions($from, $to);
    while ($trans = db_fetch($transactions)) {
        if (!$summaryOnly) {
            $rep->TextCol(0, 1, $trans['type_name']);
            $rep->TextCol(1, 2, $trans['reference']);
            $rep->TextCol(2, 3, sql2date($trans['tran_date']));
            $rep->TextCol(3, 4, $trans['name']);
            if ($trans["branch_code"] > 0) {
                $rep->TextCol(4, 5, get_branch_name($trans["branch_code"]));
            }
            $rep->TextCol(5, 6, number_format2($trans['NetAmount'], $dec));
            $rep->TextCol(6, 7, number_format2($trans['Tax'], $dec));
            $rep->NewLine();
            if ($rep->row < $rep->bottomMargin + $rep->lineHeight) {
                $rep->Line($rep->row - 2);
                $rep->Header();
            }
        }
        $totalnet += $trans['NetAmount'];
        $totaltax += $trans['Tax'];
    }
    if (!$summaryOnly) {
        $rep->NewLine();
        if ($rep->row < $rep->bottomMargin + $rep->lineHeight) {
            $rep->Line($rep->row - 2);
            $rep->Header();
        }
        $rep->Line($rep->row + $rep->lineHeight);
        $rep->TextCol(3, 5, tr('Total Outputs'));
        $rep->TextCol(5, 6, number_format2($totalnet, $dec));
        $rep->TextCol(6, 7, number_format2($totaltax, $dec));
        $rep->Line($rep->row - 5);
        $rep->Header();
    }
    $totalinnet = 0.0;
    $totalintax = 0.0;
    $transactions = getSuppTransactions($from, $to);
    while ($trans = db_fetch($transactions)) {
        if (!$summaryOnly) {
            $rep->TextCol(0, 1, $trans['type_name']);
            $rep->TextCol(1, 2, $trans['supp_reference']);
            $rep->TextCol(2, 3, sql2date($trans['tran_date']));
            $rep->TextCol(3, 5, $trans['supp_name']);
            $rep->TextCol(5, 6, number_format2($trans['NetAmount'], $dec));
            $rep->TextCol(6, 7, number_format2($trans['Tax'], $dec));
            $rep->NewLine();
            if ($rep->row < $rep->bottomMargin + $rep->lineHeight) {
                $rep->Line($rep->row - 2);
                $rep->Header();
            }
        }
        $totalinnet += $trans['NetAmount'];
        $totalintax += $trans['Tax'];
    }
    if (!$summaryOnly) {
        $rep->NewLine();
        if ($rep->row < $rep->bottomMargin + $rep->lineHeight) {
            $rep->Line($rep->row - 2);
            $rep->Header();
        }
        $rep->Line($rep->row + $rep->lineHeight);
        $rep->TextCol(3, 5, tr('Total Inputs'));
        $rep->TextCol(5, 6, number_format2($totalinnet, $dec));
        $rep->TextCol(6, 7, number_format2($totalintax, $dec));
        $rep->Line($rep->row - 5);
    }
    $cols2 = array(0, 100, 200, 300, 400, 500, 600);
    $headers2 = array(tr('Tax Rate'), tr('Outputs'), tr('Output Tax'), tr('Inputs'), tr('Input Tax'));
    $aligns2 = array('left', 'right', 'right', 'right', 'right');
    $invamount = 0.0;
    for ($i = 0; $i < $idcounter; $i++) {
        $amt = getCustInvTax($taxes[$i], $from, $to);
        $totalinvout[$i] += $amt[0];
        $totaltaxout[$i] += $amt[1];
        $invamount += $amt[0];
    }
    if ($totalnet != $invamount) {
        $totalinvout[$idcounter] = $invamount - $totalnet;
    }
    for ($i = 0; $i < $idcounter; $i++) {
        $amt = getSuppInvTax($taxes[$i], $from, $to);
        $totalinvin[$i] += $amt[0];
        $totaltaxin[$i] += $amt[1];
        $invamount += $amt[0];
    }
    if ($totalinnet != $invamount) {
        $totalinvin[$idcounter] = $totalinnet - $invamount;
    }
    for ($i = 0; $i < count($cols2) - 2; $i++) {
        $rep->cols[$i] = $rep->leftMargin + $cols2[$i];
        $rep->headers[$i] = $headers2[$i];
        $rep->aligns[$i] = $aligns2[$i];
    }
    $rep->Header();
    $counter = count($totalinvout);
    $counter = max($counter, $idcounter);
    $trow = $rep->row;
    $i = 0;
    for ($j = 0; $j < $counter; $j++) {
        if (isset($taxes[$j]) && $taxes[$j] > 0) {
            $tx = getTaxInfo($taxes[$j]);
            $str = $tx['name'] . " " . number_format2($tx['rate'], $dec) . "%";
        } else {
            $str = tr('No tax specified');
        }
        $rep->TextCol($i, $i + 1, $str);
        $rep->NewLine();
    }
    $i++;
    $rep->row = $trow;
    for ($j = 0; $j < $counter; $j++) {
        $rep->TextCol($i, $i + 1, number_format2($totalinvout[$j], $dec));
        $rep->NewLine();
    }
    $i++;
    $rep->row = $trow;
    for ($j = 0; $j < $counter; $j++) {
        $rep->TextCol($i, $i + 1, number_format2($totaltaxout[$j], $dec));
        $rep->NewLine();
    }
    $i++;
    $rep->row = $trow;
    for ($j = 0; $j < $counter; $j++) {
        $rep->TextCol($i, $i + 1, number_format2($totalinvin[$j], $dec));
        $rep->NewLine();
    }
    $i++;
    $rep->row = $trow;
    for ($j = 0; $j < $counter; $j++) {
        $rep->TextCol($i, $i + 1, number_format2($totaltaxin[$j], $dec));
        $rep->NewLine();
    }
    $rep->Line($rep->row - 4);
    $locale = $path_to_root . "lang/" . $_SESSION['language']->code . "/locale.inc";
    if (file_exists($locale)) {
        $taxinclude = true;
        include $locale;
        /*
        if (function_exists("TaxFunction"))
        	TaxFunction();
        */
    }
    $rep->End();
}