function print_purchases_cost()
{
    global $path_to_root;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $destination = $_POST['PARAM_2'];
    $orientation = $_POST['PARAM_3'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $dec = user_price_dec();
    if ($category == ALL_NUMERIC) {
        $category = 0;
    }
    if ($category == 0) {
        $cat = _('All');
    } else {
        $cat = get_category_name($category);
    }
    $cols = array(0, 20, 55, 85, 125, 200, 230, 260, 290, 325, 350, 375, 425, 475);
    //14 headers + 1 lagi dapat for cols
    //todo: format date paid to 2 digits representation only i.e. 12/12/12
    $headers = array(_('CV#'), _('Date Paid'), _('OR #'), _('Supplier'), _('Title of Book'), _('Quantity'), _('Unit Cost'), _('Amount'), _('With Tax'), _('Net'), _('PO #'), _('Stock Supplied'), _('Stock Amount'), _('Total Amount'));
    //todo: Date Paid, OR(official receipt number) Amount, w/tax, net, Stock supplied, stock amount and total amount
    // Possible tables to read on:  grn_batch and grn_items
    $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left', 'left');
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''));
    $rep = new FrontReport(_('Summary of Purchases at Cost Report'), "SummaryPurchasesCostReport", user_pagesize(), 8, 'L');
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $res = getTransactions($from, $to);
    $total = $grandtotal = 0.0;
    $total1 = $grandtotal1 = 0.0;
    $total2 = $grandtotal2 = 0.0;
    $catt = '';
    while ($trans = db_fetch($res)) {
        $rep->NewLine();
        $rep->fontSize -= 2;
        $rep->TextCol(3, 4, $trans['supp_name']);
        $rep->TextCol(4, 5, $trans['description']);
        $rep->AmountCol(5, 6, $trans['quantity_ordered']);
        $rep->AmountCol(6, 7, $trans['unit_price']);
        $rep->AmountCol(10, 11, $trans['order_no']);
    }
    $rep->NewLine(2, 3);
    $rep->TextCol(0, 4, _('Total'));
    $rep->AmountCol(4, 5, $total, $dec);
    $rep->Line($rep->row - 2);
    $rep->NewLine();
    $rep->NewLine(2, 1);
    $rep->TextCol(0, 4, _('Grand Total'));
    $rep->AmountCol(4, 5, $grandtotal, $dec);
    $rep->Line($rep->row - 4);
    $rep->NewLine();
    $rep->End();
}
Exemplo n.º 2
0
function print_audit_trail()
{
    global $path_to_root, $systypes_array;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $systype = $_POST['PARAM_2'];
    $user = $_POST['PARAM_3'];
    $comments = $_POST['PARAM_4'];
    $orientation = $_POST['PARAM_5'];
    $destination = $_POST['PARAM_6'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $dec = user_price_dec();
    $cols = array(0, 60, 120, 180, 240, 340, 400, 460, 520);
    $headers = array(_('Date'), _('Time'), _('User'), _('Trans Date'), _('Type'), _('#'), _('Action'), _('Amount'));
    $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'left', 'right');
    $usr = get_user($user);
    $user_id = $usr['user_id'];
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Type'), 'from' => $systype != -1 ? $systypes_array[$systype] : _('All'), 'to' => ''), 3 => array('text' => _('User'), 'from' => $user != -1 ? $user_id : _('All'), 'to' => ''));
    $rep = new FrontReport(_('Audit Trail'), "AuditTrail", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $trans = getTransactions($from, $to, $systype, $user);
    while ($myrow = db_fetch($trans)) {
        $rep->TextCol(0, 1, sql2date(date("Y-m-d", $myrow['unix_stamp'])));
        if (user_date_format() == 0) {
            $rep->TextCol(1, 2, date("h:i:s a", $myrow['unix_stamp']));
        } else {
            $rep->TextCol(1, 2, date("H:i:s", $myrow['unix_stamp']));
        }
        $rep->TextCol(2, 3, $myrow['user_id']);
        $rep->TextCol(3, 4, sql2date($myrow['gl_date']));
        $rep->TextCol(4, 5, $systypes_array[$myrow['type']]);
        $rep->TextCol(5, 6, $myrow['trans_no']);
        if ($myrow['gl_seq'] == null) {
            $action = _('Changed');
        } else {
            $action = _('Closed');
        }
        $rep->TextCol(6, 7, $action);
        if ($myrow['amount'] != null) {
            $rep->AmountCol(7, 8, $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;
    $frompart = $_POST['PARAM_0'];
    $topart = $_POST['PARAM_1'];
    $comments = $_POST['PARAM_2'];
    $orientation = $_POST['PARAM_3'];
    $destination = $_POST['PARAM_4'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $cols = array(0, 50, 305, 375, 445, 515);
    $headers = array(_('Component'), _('Description'), _('Loc'), _('Wrk Ctr'), _('Quantity'));
    $aligns = array('left', 'left', 'left', 'left', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('Component'), 'from' => $frompart, 'to' => $topart));
    $rep = new FrontReport(_('Bill of Material Listing'), "BillOfMaterial", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $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();
        $dec = get_qty_dec($trans['component']);
        $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']);
        $wc = get_work_centre($trans['workcentre_added']);
        $rep->TextCol(2, 3, get_location_name($trans['loc_code']));
        $rep->TextCol(3, 4, $wc['name']);
        $rep->AmountCol(4, 5, $trans['quantity'], $dec);
    }
    $rep->Line($rep->row - 4);
    $rep->NewLine();
    $rep->End();
}
Exemplo n.º 4
0
function print_dimension_summary()
{
    global $path_to_root;
    $fromdim = $_POST['PARAM_0'];
    $todim = $_POST['PARAM_1'];
    $showbal = $_POST['PARAM_2'];
    $comments = $_POST['PARAM_3'];
    $orientation = $_POST['PARAM_4'];
    $destination = $_POST['PARAM_5'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $cols = array(0, 50, 210, 250, 320, 395, 465, 515);
    $headers = array(_('Reference'), _('Name'), _('Type'), _('Date'), _('Due Date'), _('Closed'), _('YTD'));
    $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('Dimension'), 'from' => get_dimension_string($fromdim), 'to' => get_dimension_string($todim)));
    $rep = new FrontReport(_('Dimension Summary'), "DimensionSummary", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $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->DateCol(3, 4, $trans['date_'], true);
        $rep->DateCol(4, 5, $trans['due_date'], true);
        if ($trans['closed']) {
            $str = _('Yes');
        } else {
            $str = _('No');
        }
        $rep->TextCol(5, 6, $str);
        if ($showbal) {
            $balance = getYTD($trans['id']);
            $rep->AmountCol(6, 7, $balance, 0);
        }
        $rep->NewLine(1, 2);
    }
    $rep->Line($rep->row);
    $rep->End();
}
Exemplo n.º 5
0
function print_assets_list()
{
    global $path_to_root;
    $frompart = $_POST['PARAM_0'];
    $topart = $_POST['PARAM_1'];
    $comments = $_POST['PARAM_2'];
    $destination = $_POST['PARAM_3'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $cols = array(0, 50, 305, 375, 445, 515);
    $headers = array(_('Asset Type'), _('Asset name'), _('Serial Number'), _('Purchase Date'), _('Purchase Value'));
    $aligns = array('left', 'left', 'left', 'left', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('Component'), 'from' => $frompart, 'to' => $topart));
    $rep = new FrontReport(_('Assets Listing'), "AssetList", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $res = getTransactions($frompart, $topart);
    $parent = '';
    while ($trans = db_fetch($res)) {
        if ($parent != $trans['asset_type_name']) {
            if ($parent != '') {
                $rep->Line($rep->row - 2);
                $rep->NewLine(2, 3);
            }
            $rep->TextCol(0, 2, $trans['asset_type_name']);
            $desc = get_item($trans['asset_type_name']);
            $parent = $trans['asset_type_name'];
            $rep->NewLine();
        }
        $rep->NewLine();
        $dec = get_qty_dec($trans['asset_id']);
        $rep->TextCol(0, 1, $trans['asset_type_name']);
        $rep->TextCol(1, 2, $trans['asset_name']);
        $rep->TextCol(2, 3, $trans['asset_serial']);
        $rep->TextCol(3, 4, $trans['purchase_date']);
        $rep->AmountCol(4, 5, $trans['purchase_value'], $dec);
    }
    $rep->Line($rep->row - 4);
    $rep->NewLine();
    $rep->End();
}
Exemplo n.º 6
0
function print_outstanding_GRN()
{
    global $path_to_root;
    $fromsupp = $_POST['PARAM_0'];
    $comments = $_POST['PARAM_1'];
    $orientation = $_POST['PARAM_2'];
    $destination = $_POST['PARAM_3'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    if ($fromsupp == ALL_TEXT) {
        $from = _('All');
    } else {
        $from = get_supplier_name($fromsupp);
    }
    $dec = user_price_dec();
    $cols = array(0, 40, 80, 190, 250, 320, 385, 450, 515);
    $headers = array(_('GRN'), _('Order'), _('Item') . '/' . _('Description'), _('Qty Recd'), _('qty Inv'), _('Balance'), _('Act Price'), _('Value'));
    $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('Supplier'), 'from' => $from, 'to' => ''));
    $rep = new FrontReport(_('Outstanding GRNs Report'), "OutstandingGRN", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $Tot_Val = 0;
    $Supplier = '';
    $SuppTot_Val = 0;
    $res = getTransactions($fromsupp);
    while ($GRNs = db_fetch($res)) {
        $dec2 = get_qty_dec($GRNs['item_code']);
        if ($Supplier != $GRNs['supplier_id']) {
            if ($Supplier != '') {
                $rep->NewLine(2);
                $rep->TextCol(0, 7, _('Total'));
                $rep->AmountCol(7, 8, $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->AmountCol(3, 4, $GRNs['qty_recd'], $dec2);
        $rep->AmountCol(4, 5, $GRNs['quantity_inv'], $dec2);
        $QtyOstg = $GRNs['qty_recd'] - $GRNs['quantity_inv'];
        $Value = ($GRNs['qty_recd'] - $GRNs['quantity_inv']) * $GRNs['act_price'];
        $rep->AmountCol(5, 6, $QtyOstg, $dec2);
        $rep->AmountCol(6, 7, $GRNs['act_price'], $dec);
        $rep->AmountCol(7, 8, $Value, $dec);
        $Tot_Val += $Value;
        $SuppTot_Val += $Value;
        $rep->NewLine(0, 1);
    }
    if ($Supplier != '') {
        $rep->NewLine();
        $rep->TextCol(0, 7, _('Total'));
        $rep->AmountCol(7, 8, $SuppTot_Val, $dec);
        $rep->Line($rep->row - 2);
        $rep->NewLine(3);
        $SuppTot_Val = 0;
    }
    $rep->NewLine(2);
    $rep->TextCol(0, 7, _('Grand Total'));
    $rep->AmountCol(7, 8, $Tot_Val, $dec);
    $rep->Line($rep->row - 2);
    $rep->NewLine();
    $rep->End();
}
Exemplo n.º 7
0
function print_remittances()
{
    global $path_to_root, $systypes_array;
    include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $currency = $_POST['PARAM_2'];
    $email = $_POST['PARAM_3'];
    $comments = $_POST['PARAM_4'];
    $orientation = $_POST['PARAM_5'];
    if (!$from || !$to) {
        return;
    }
    $orientation = $orientation ? 'L' : 'P';
    $dec = user_price_dec();
    $fno = explode("-", $from);
    $tno = explode("-", $to);
    $from = min($fno[0], $tno[0]);
    $to = max($fno[0], $tno[0]);
    $cols = array(4, 85, 150, 225, 275, 360, 450, 515);
    // $headers in doctext.inc
    $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right');
    $params = array('comments' => $comments);
    $cur = get_company_Pref('curr_default');
    if ($email == 0) {
        $rep = new FrontReport(_('REMITTANCE'), "RemittanceBulk", user_pagesize(), 9, $orientation);
    }
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    for ($i = $from; $i <= $to; $i++) {
        if ($fno[0] == $tno[0]) {
            $types = array($fno[1]);
        } else {
            $types = array(ST_BANKPAYMENT, ST_SUPPAYMENT, ST_SUPPCREDIT);
        }
        foreach ($types as $j) {
            $myrow = get_remittance($j, $i);
            if (!$myrow) {
                continue;
            }
            $res = get_bank_trans($j, $i);
            $baccount = db_fetch($res);
            $params['bankaccount'] = $baccount['bank_act'];
            if ($email == 1) {
                $rep = new FrontReport("", "", user_pagesize(), 9, $orientation);
                $rep->title = _('REMITTANCE');
                $rep->filename = "Remittance" . $i . ".pdf";
            }
            $rep->SetHeaderType('Header2');
            $rep->currency = $cur;
            $rep->Font();
            $rep->Info($params, $cols, null, $aligns);
            $contacts = get_supplier_contacts($myrow['supplier_id'], 'invoice');
            $rep->SetCommonData($myrow, null, $myrow, $baccount, ST_SUPPAYMENT, $contacts);
            $rep->NewPage();
            $result = get_allocations_for_remittance($myrow['supplier_id'], $myrow['type'], $myrow['trans_no']);
            $doctype = ST_SUPPAYMENT;
            $total_allocated = 0;
            $rep->TextCol(0, 4, _("As advance / full / part / payment towards:"), -2);
            $rep->NewLine(2);
            while ($myrow2 = db_fetch($result)) {
                $rep->TextCol(0, 1, $systypes_array[$myrow2['type']], -2);
                $rep->TextCol(1, 2, $myrow2['supp_reference'], -2);
                $rep->TextCol(2, 3, sql2date($myrow2['tran_date']), -2);
                $rep->TextCol(3, 4, sql2date($myrow2['due_date']), -2);
                $rep->AmountCol(4, 5, $myrow2['Total'], $dec, -2);
                $rep->AmountCol(5, 6, $myrow2['Total'] - $myrow2['alloc'], $dec, -2);
                $rep->AmountCol(6, 7, $myrow2['amt'], $dec, -2);
                $total_allocated += $myrow2['amt'];
                $rep->NewLine(1);
                if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) {
                    $rep->NewPage();
                }
            }
            $memo = get_comments_string($j, $i);
            if ($memo != "") {
                $rep->NewLine();
                $rep->TextColLines(1, 5, $memo, -2);
            }
            $rep->row = $rep->bottomMargin + 16 * $rep->lineHeight;
            $rep->TextCol(3, 6, _("Total Allocated"), -2);
            $rep->AmountCol(6, 7, $total_allocated, $dec, -2);
            $rep->NewLine();
            $rep->TextCol(3, 6, _("Left to Allocate"), -2);
            $myrow['Total'] *= -1;
            $myrow['ov_discount'] *= -1;
            $rep->AmountCol(6, 7, $myrow['Total'] + $myrow['ov_discount'] - $total_allocated, $dec, -2);
            if (floatcmp($myrow['ov_discount'], 0)) {
                $rep->NewLine();
                $rep->TextCol(3, 6, _("Discount"), -2);
                $rep->AmountCol(6, 7, -$myrow['ov_discount'], $dec, -2);
            }
            $rep->NewLine();
            $rep->Font('bold');
            $rep->TextCol(3, 6, _("TOTAL REMITTANCE"), -2);
            $rep->AmountCol(6, 7, $myrow['Total'], $dec, -2);
            $words = price_in_words($myrow['Total'], ST_SUPPAYMENT);
            if ($words != "") {
                $rep->NewLine(2);
                $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, -2);
            }
            $rep->Font();
            if ($email == 1) {
                $myrow['DebtorName'] = $myrow['supp_name'];
                $rep->End($email);
            }
        }
    }
    if ($email == 0) {
        $rep->End();
    }
}
function print_purchases_cost()
{
    global $path_to_root;
    $from = $_POST['PARAM_0'];
    $destination = $_POST['PARAM_1'];
    $orientation = $_POST['PARAM_2'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $dec = user_price_dec();
    if ($category == ALL_NUMERIC) {
        $category = 0;
    }
    if ($category == 0) {
        $cat = _('All');
    } else {
        $cat = get_category_name($category);
    }
    $cols = array(0, 50, 100, 150, 200, 250, 300, 350);
    $headers = array(_('Invoice'), _('Client Name'), _('IMC'), _('Charge'), _('Sales'), _('Date of'));
    //$header2 = array(_('Date'), '', '', _('Invoice'), _('Amount'), _('Credit  Memo'), _('Memo No.'), _(' Return'), _('%'), _('%'), _('Sales'), _('Provisional Receipt'), _('Receipt No.'), _('Payment'), _('Remittance'), _('Commission'), _('Percentage'), '', _('W/holding Tax'), _('Commission'));
    $aligns = array('left', 'left', 'left', 'left');
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''));
    $rep = new FrontReport(_('Summary of Purchases at Cost Report'), "SummaryPurchasesCostReport", user_pagesize(), 8, 'L');
    $rep->Font();
    $rep->Info($params, $cols, $header2, $aligns);
    $rep->NewPage();
    $res = getTransactions($category, $from, $to);
    $total = $grandtotal = 0.0;
    $total1 = $grandtotal1 = 0.0;
    $total2 = $grandtotal2 = 0.0;
    $catt = '';
    while ($trans = db_fetch($res)) {
        if ($catt != $trans['cat_description']) {
            if ($catt != '') {
                $rep->NewLine(2, 3);
                $rep->TextCol(0, 4, _('Total'));
                $rep->AmountCol(4, 5, $total, $dec);
                $rep->Line($rep->row - 2);
                $rep->NewLine();
                $rep->NewLine();
                $total = $total1 = $total2 = 0.0;
            }
            $rep->TextCol(0, 1, $trans['category_id']);
            $rep->TextCol(1, 7, $trans['cat_description']);
            $catt = $trans['cat_description'];
            $rep->NewLine();
        }
        $rep->NewLine();
        $rep->fontSize -= 2;
        $rep->TextCol(0, 1, $trans['stock_id']);
        $rep->TextCol(1, 2, $trans['description']);
        $rep->AmountCol(2, 3, $trans['quantity'], get_qty_dec($trans['stock_id']));
        $rep->AmountCol(3, 4, $trans['unit_price'], $dec);
        $rep->AmountCol(4, 5, $trans['quantity'] * $trans['unit_price'], $dec);
        if ($trans['unit_price'] == 0) {
            $rep->TextCol(6, 7, _('Gift'));
        }
        $rep->fontSize += 2;
        $total += $trans['quantity'] * $trans['unit_price'];
        $grandtotal += $trans['quantity'] * $trans['unit_price'];
    }
    $rep->NewLine(2, 3);
    $rep->TextCol(0, 4, _('Total'));
    $rep->AmountCol(4, 5, $total, $dec);
    $rep->Line($rep->row - 2);
    $rep->NewLine();
    $rep->NewLine(2, 1);
    $rep->TextCol(0, 4, _('Grand Total'));
    $rep->AmountCol(4, 5, $grandtotal, $dec);
    $rep->Line($rep->row - 4);
    $rep->NewLine();
    $rep->End();
}
Exemplo n.º 9
0
function print_price_listing()
{
    global $path_to_root, $pic_height, $pic_width;
    $currency = $_POST['PARAM_0'];
    $category = $_POST['PARAM_1'];
    $salestype = $_POST['PARAM_2'];
    $pictures = $_POST['PARAM_3'];
    $showGP = $_POST['PARAM_4'];
    $comments = $_POST['PARAM_5'];
    $orientation = $_POST['PARAM_6'];
    $destination = $_POST['PARAM_7'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $dec = user_price_dec();
    $home_curr = get_company_pref('curr_default');
    if ($currency == ALL_TEXT) {
        $currency = $home_curr;
    }
    $curr = get_currency($currency);
    $curr_sel = $currency . " - " . $curr['currency'];
    if ($category == ALL_NUMERIC) {
        $category = 0;
    }
    if ($salestype == ALL_NUMERIC) {
        $salestype = 0;
    }
    if ($category == 0) {
        $cat = _('All');
    } else {
        $cat = get_category_name($category);
    }
    if ($salestype == 0) {
        $stype = _('All');
    } else {
        $stype = get_sales_type_name($salestype);
    }
    if ($showGP == 0) {
        $GP = _('No');
    } else {
        $GP = _('Yes');
    }
    $cols = array(0, 100, 360, 385, 450, 515);
    $headers = array(_('Category/Items'), _('Description'), _('UOM'), _('Price'), _('GP %'));
    $aligns = array('left', 'left', 'left', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('Currency'), 'from' => $curr_sel, 'to' => ''), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 3 => array('text' => _('Sales Type'), 'from' => $stype, 'to' => ''), 4 => array('text' => _('Show GP %'), 'from' => $GP, 'to' => ''));
    if ($pictures) {
        $user_comp = user_company();
    } else {
        $user_comp = "";
    }
    $rep = new FrontReport(_('Price Listing'), "PriceListing", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $result = fetch_items($category);
    $catgor = '';
    $_POST['sales_type_id'] = $salestype;
    while ($myrow = db_fetch($result)) {
        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, $myrow['units']);
        $price = get_price($myrow['stock_id'], $currency, $salestype);
        $rep->AmountCol(3, 4, $price, $dec);
        if ($showGP) {
            $price2 = get_price($myrow['stock_id'], $home_curr, $salestype);
            if ($price2 != 0.0) {
                $disp = ($price2 - $myrow['Standardcost']) * 100 / $price2;
            } else {
                $disp = 0.0;
            }
            $rep->TextCol(4, 5, number_format2($disp, user_percent_dec()) . " %");
        }
        if ($pictures) {
            $image = company_path() . "/images/" . item_img_name($myrow['stock_id']) . ".jpg";
            if (file_exists($image)) {
                $rep->NewLine();
                if ($rep->row - $pic_height < $rep->bottomMargin) {
                    $rep->NewPage();
                }
                $rep->AddImage($image, $rep->cols[1], $rep->row - $pic_height, 0, $pic_height);
                $rep->row -= $pic_height;
                $rep->NewLine();
            }
        } else {
            $rep->NewLine(0, 1);
        }
    }
    $rep->Line($rep->row - 4);
    $result = get_kits($category);
    $catgor = '';
    while ($myrow = db_fetch($result)) {
        if ($catgor != $myrow['cat_name']) {
            if ($catgor == '') {
                $rep->NewLine(2);
                $rep->fontSize += 2;
                $rep->TextCol(0, 3, _("Sales Kits"));
                $rep->fontSize -= 2;
            }
            $rep->Line($rep->row - $rep->lineHeight);
            $rep->NewLine(2);
            $rep->fontSize += 2;
            $rep->TextCol(0, 3, $myrow['cat_id'] . " - " . $myrow['cat_name']);
            $catgor = $myrow['cat_name'];
            $rep->fontSize -= 2;
            $rep->NewLine();
        }
        $rep->NewLine();
        $rep->TextCol(0, 1, $myrow['kit_code']);
        $rep->TextCol(1, 3, $myrow['kit_name']);
        $price = get_kit_price($myrow['kit_code'], $currency, $salestype);
        $rep->AmountCol(3, 4, $price, $dec);
        $rep->NewLine(0, 1);
    }
    $rep->Line($rep->row - 4);
    $rep->NewLine();
    $rep->End();
}
Exemplo n.º 10
0
function print_stock_check()
{
    global $path_to_root, $pic_height;
    $category = $_POST['PARAM_0'];
    $location = $_POST['PARAM_1'];
    $pictures = $_POST['PARAM_2'];
    $check = $_POST['PARAM_3'];
    $shortage = $_POST['PARAM_4'];
    $no_zeros = $_POST['PARAM_5'];
    $like = $_POST['PARAM_6'];
    $comments = $_POST['PARAM_7'];
    $orientation = $_POST['PARAM_8'];
    $destination = $_POST['PARAM_9'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    if ($category == ALL_NUMERIC) {
        $category = 0;
    }
    if ($category == 0) {
        $cat = _('All');
    } else {
        $cat = get_category_name($category);
    }
    if ($location == ALL_TEXT) {
        $location = 'all';
    }
    if ($location == 'all') {
        $loc = _('All');
    } else {
        $loc = get_location_name($location);
    }
    if ($shortage) {
        $short = _('Yes');
        $available = _('Shortage');
    } else {
        $short = _('No');
        $available = _('Available');
    }
    if ($no_zeros) {
        $nozeros = _('Yes');
    } else {
        $nozeros = _('No');
    }
    if ($check) {
        $cols = array(0, 75, 225, 250, 295, 345, 390, 445, 515);
        $headers = array(_('Stock ID'), _('Description'), _('UOM'), _('Quantity'), _('Check'), _('Demand'), $available, _('On Order'));
        $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right');
    } else {
        $cols = array(0, 75, 225, 250, 315, 380, 445, 515);
        $headers = array(_('Stock ID'), _('Description'), _('UOM'), _('Quantity'), _('Demand'), $available, _('On Order'));
        $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right');
    }
    $params = array(0 => $comments, 1 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 2 => array('text' => _('Location'), 'from' => $loc, 'to' => ''), 3 => array('text' => _('Only Shortage'), 'from' => $short, 'to' => ''), 4 => array('text' => _('Suppress Zeros'), 'from' => $nozeros, 'to' => ''));
    if ($pictures) {
        $user_comp = user_company();
    } else {
        $user_comp = "";
    }
    $rep = new FrontReport(_('Stock Check Sheets'), "StockCheckSheet", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $res = getTransactions($category, $location, $like);
    $catt = '';
    while ($trans = db_fetch($res)) {
        if ($location == 'all') {
            $loc_code = "";
        } else {
            $loc_code = $location;
        }
        $demandqty = get_demand_qty($trans['stock_id'], $loc_code);
        $demandqty += get_demand_asm_qty($trans['stock_id'], $loc_code);
        $onorder = get_on_porder_qty($trans['stock_id'], $loc_code);
        $flag = get_mb_flag($trans['stock_id']);
        if ($flag == 'M') {
            $onorder += get_on_worder_qty($trans['stock_id'], $loc_code);
        }
        if ($no_zeros && $trans['QtyOnHand'] == 0 && $demandqty == 0 && $onorder == 0) {
            continue;
        }
        if ($shortage && $trans['QtyOnHand'] - $demandqty >= 0) {
            continue;
        }
        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();
        }
        $rep->NewLine();
        $dec = get_qty_dec($trans['stock_id']);
        $rep->TextCol(0, 1, $trans['stock_id']);
        $rep->TextCol(1, 2, $trans['description'] . ($trans['inactive'] == 1 ? " (" . _("Inactive") . ")" : ""), -1);
        $rep->TextCol(2, 3, $trans['units']);
        $rep->AmountCol(3, 4, $trans['QtyOnHand'], $dec);
        if ($check) {
            $rep->TextCol(4, 5, "_________");
            $rep->AmountCol(5, 6, $demandqty, $dec);
            $rep->AmountCol(6, 7, $trans['QtyOnHand'] - $demandqty, $dec);
            $rep->AmountCol(7, 8, $onorder, $dec);
        } else {
            $rep->AmountCol(4, 5, $demandqty, $dec);
            $rep->AmountCol(5, 6, $trans['QtyOnHand'] - $demandqty, $dec);
            $rep->AmountCol(6, 7, $onorder, $dec);
        }
        if ($pictures) {
            $image = company_path() . '/images/' . item_img_name($trans['stock_id']) . '.jpg';
            if (file_exists($image)) {
                $rep->NewLine();
                if ($rep->row - $pic_height < $rep->bottomMargin) {
                    $rep->NewPage();
                }
                $rep->AddImage($image, $rep->cols[1], $rep->row - $pic_height, 0, $pic_height);
                $rep->row -= $pic_height;
                $rep->NewLine();
            }
        }
    }
    $rep->Line($rep->row - 4);
    $rep->NewLine();
    $rep->End();
}
Exemplo n.º 11
0
function print_GL_transactions()
{
    global $path_to_root, $systypes_array;
    $dim = get_company_pref('use_dimension');
    $dimension = $dimension2 = 0;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $fromacc = $_POST['PARAM_2'];
    $toacc = $_POST['PARAM_3'];
    if ($dim == 2) {
        $dimension = $_POST['PARAM_4'];
        $dimension2 = $_POST['PARAM_5'];
        $comments = $_POST['PARAM_6'];
        $orientation = $_POST['PARAM_7'];
        $destination = $_POST['PARAM_8'];
    } else {
        if ($dim == 1) {
            $dimension = $_POST['PARAM_4'];
            $comments = $_POST['PARAM_5'];
            $orientation = $_POST['PARAM_6'];
            $destination = $_POST['PARAM_7'];
        } else {
            $comments = $_POST['PARAM_4'];
            $orientation = $_POST['PARAM_5'];
            $destination = $_POST['PARAM_6'];
        }
    }
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $rep = new FrontReport(_('GL Account Transactions'), "GLAccountTransactions", user_pagesize(), 9, $orientation);
    $dec = 2;
    //$cols = array(0, 80, 100, 150, 210, 280, 340, 400, 450, 510, 570);
    $cols = array(0, 65, 105, 125, 175, 230, 290, 345, 405, 465, 525);
    //------------0--1---2---3----4----5----6----7----8----9----10-------
    //-----------------------dim1-dim2-----------------------------------
    //-----------------------dim1----------------------------------------
    //-------------------------------------------------------------------
    $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'left', 'right', 'right', 'right');
    if ($dim == 2) {
        $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), _('Dimension') . " 1", _('Dimension') . " 2", _('Person/Item'), _('Debit'), _('Credit'), _('Balance'));
    } elseif ($dim == 1) {
        $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), _('Dimension'), "", _('Person/Item'), _('Debit'), _('Credit'), _('Balance'));
    } else {
        $headers = array(_('Type'), _('Ref'), _('#'), _('Date'), "", "", _('Person/Item'), _('Debit'), _('Credit'), _('Balance'));
    }
    if ($dim == 2) {
        $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $toacc), 3 => array('text' => _('Dimension') . " 1", 'from' => get_dimension_string($dimension), 'to' => ''), 4 => array('text' => _('Dimension') . " 2", 'from' => get_dimension_string($dimension2), 'to' => ''));
    } else {
        if ($dim == 1) {
            $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $toacc), 3 => array('text' => _('Dimension'), 'from' => get_dimension_string($dimension), 'to' => ''));
        } else {
            $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $toacc));
        }
    }
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $accounts = get_gl_accounts($fromacc, $toacc);
    while ($account = db_fetch($accounts)) {
        if (is_account_balancesheet($account["account_code"])) {
            $begin = "";
        } else {
            $begin = get_fiscalyear_begin_for_date($from);
            if (date1_greater_date2($begin, $from)) {
                $begin = $from;
            }
            $begin = add_days($begin, -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, 4, $account['account_code'] . " " . $account['account_name'], -2);
        $rep->TextCol(4, 6, _('Opening Balance'));
        if ($prev_balance > 0.0) {
            $rep->AmountCol(7, 8, abs($prev_balance), $dec);
        } else {
            $rep->AmountCol(8, 9, abs($prev_balance), $dec);
        }
        $rep->Font();
        $total = $prev_balance;
        $rep->NewLine(2);
        if ($rows > 0) {
            while ($myrow = db_fetch($trans)) {
                $total += $myrow['amount'];
                $type_name = $systypes_array[$myrow["type"]];
                if ($type_name == "Customer Payment") {
                    $rep->TextCol(0, 1, "CRB", -2);
                }
                if ($type_name == "Cash Disbursement/Check Voucher") {
                    $rep->TextCol(0, 1, "CDB", -2);
                }
                if ($type_name == "Journal Entry") {
                    $rep->TextCol(0, 1, "JB", -2);
                }
                if ($type_name == "Customer Credit Note") {
                    $type_name = "Credit Memo";
                }
                if ($type_name == "Sales Invoice") {
                    $type_name = "Invoice";
                } else {
                    if ($type_name != "Customer Payment" && $type_name != "Cash Disbursement/Check Voucher" && $type_name != "Journal Entry") {
                        $rep->TextCol(0, 1, $type_name, -2);
                    }
                }
                $reference = get_reference($myrow["type"], $myrow["type_no"]);
                $rep->TextCol(1, 2, $reference);
                $rep->TextCol(2, 3, $myrow['type_no'], -2);
                $rep->DateCol(3, 4, $myrow["tran_date"], true);
                if ($dim >= 1) {
                    $rep->TextCol(4, 5, get_dimension_string($myrow['dimension_id']));
                }
                if ($dim > 1) {
                    $rep->TextCol(5, 6, get_dimension_string($myrow['dimension2_id']));
                }
                $txt = payment_person_name($myrow["person_type_id"], $myrow["person_id"], false);
                $memo = $myrow['memo_'];
                if ($txt != "") {
                    if ($memo != "") {
                        $txt = $txt . "/" . $memo;
                    }
                } else {
                    $txt = $memo;
                }
                $rep->TextCol(6, 7, $txt, -2);
                if ($myrow['amount'] > 0.0) {
                    $rep->AmountCol(7, 8, abs($myrow['amount']), $dec);
                } else {
                    $rep->AmountCol(8, 9, abs($myrow['amount']), $dec);
                }
                $rep->TextCol(9, 10, number_format2($total, $dec));
                $rep->NewLine();
                if ($rep->row < $rep->bottomMargin + $rep->lineHeight) {
                    $rep->Line($rep->row - 2);
                    $rep->NewPage();
                }
            }
            $rep->NewLine();
        }
        $rep->Font('bold');
        $rep->TextCol(4, 6, _("Ending Balance"));
        if ($total > 0.0) {
            $rep->AmountCol(7, 8, abs($total), $dec);
        } else {
            $rep->AmountCol(8, 9, abs($total), $dec);
        }
        $rep->Font();
        $rep->Line($rep->row - $rep->lineHeight + 4);
        $rep->NewLine(2, 1);
    }
    $rep->End();
}
Exemplo n.º 12
0
function print_aged_supplier_analysis()
{
    global $path_to_root, $systypes_array;
    $to = $_POST['PARAM_0'];
    $fromsupp = $_POST['PARAM_1'];
    $currency = $_POST['PARAM_2'];
    $show_all = $_POST['PARAM_3'];
    $summaryOnly = $_POST['PARAM_4'];
    $no_zeros = $_POST['PARAM_5'];
    $graphics = $_POST['PARAM_6'];
    $comments = $_POST['PARAM_7'];
    $orientation = $_POST['PARAM_8'];
    $destination = $_POST['PARAM_9'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    if ($graphics) {
        include_once $path_to_root . "/reporting/includes/class.graphic.inc";
        $pg = new graph();
    }
    if ($fromsupp == ALL_TEXT) {
        $from = _('All');
    } else {
        $from = get_supplier_name($fromsupp);
    }
    $dec = user_price_dec();
    if ($summaryOnly == 1) {
        $summary = _('Summary Only');
    } else {
        $summary = _('Detailed Report');
    }
    if ($currency == ALL_TEXT) {
        $convert = true;
        $currency = _('Balances in Home Currency');
    } else {
        $convert = false;
    }
    if ($no_zeros) {
        $nozeros = _('Yes');
    } else {
        $nozeros = _('No');
    }
    if ($show_all) {
        $show = _('Yes');
    } else {
        $show = _('No');
    }
    $PastDueDays1 = get_company_pref('past_due_days');
    $PastDueDays2 = 2 * $PastDueDays1;
    $nowdue = "1-" . $PastDueDays1 . " " . _('Days');
    $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . _('Days');
    $pastdue2 = _('Over') . " " . $PastDueDays2 . " " . _('Days');
    $cols = array(0, 100, 130, 190, 250, 320, 385, 450, 515);
    $headers = array(_('Supplier'), '', '', _('Current'), $nowdue, $pastdue1, $pastdue2, _('Total Balance'));
    $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('End Date'), 'from' => $to, 'to' => ''), 2 => array('text' => _('Supplier'), 'from' => $from, 'to' => ''), 3 => array('text' => _('Currency'), 'from' => $currency, 'to' => ''), 4 => array('text' => _('Type'), 'from' => $summary, 'to' => ''), 5 => array('text' => _('Show Also Allocated'), 'from' => $show, 'to' => ''), 6 => array('text' => _('Suppress Zeros'), 'from' => $nozeros, 'to' => ''));
    if ($convert) {
        $headers[2] = _('currency');
    }
    $rep = new FrontReport(_('Aged Supplier Analysis'), "AgedSupplierAnalysis", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $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 . " " . _('Days');
    $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . _('Days');
    $pastdue2 = _('Over') . " " . $PastDueDays2 . " " . _('Days');
    $sql = "SELECT supplier_id, supp_name AS name, curr_code FROM " . TB_PREF . "suppliers";
    if ($fromsupp != ALL_TEXT) {
        $sql .= " WHERE supplier_id=" . db_escape($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;
        }
        if ($convert) {
            $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $to);
        } else {
            $rate = 1.0;
        }
        $supprec = get_supplier_details($myrow['supplier_id'], $to, $show_all);
        if (!$supprec) {
            continue;
        }
        $supprec['Balance'] *= $rate;
        $supprec['Due'] *= $rate;
        $supprec['Overdue1'] *= $rate;
        $supprec['Overdue2'] *= $rate;
        $str = array($supprec["Balance"] - $supprec["Due"], $supprec["Due"] - $supprec["Overdue1"], $supprec["Overdue1"] - $supprec["Overdue2"], $supprec["Overdue2"], $supprec["Balance"]);
        if ($no_zeros && floatcmp(array_sum($str), 0) == 0) {
            continue;
        }
        $rep->fontSize += 2;
        $rep->TextCol(0, 2, $myrow['name']);
        if ($convert) {
            $rep->TextCol(2, 3, $myrow['curr_code']);
        }
        $rep->fontSize -= 2;
        $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"];
        for ($i = 0; $i < count($str); $i++) {
            $rep->AmountCol($i + 3, $i + 4, $str[$i], $dec);
        }
        $rep->NewLine(1, 2);
        if (!$summaryOnly) {
            $res = get_invoices($myrow['supplier_id'], $to, $show_all);
            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, $systypes_array[$trans['type']], -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($trans["Balance"] - $trans["Due"], $trans["Due"] - $trans["Overdue1"], $trans["Overdue1"] - $trans["Overdue2"], $trans["Overdue2"], $trans["Balance"]);
                for ($i = 0; $i < count($str); $i++) {
                    $rep->AmountCol($i + 3, $i + 4, $str[$i], $dec);
                }
            }
            $rep->Line($rep->row - 8);
            $rep->NewLine(2);
        }
    }
    if ($summaryOnly) {
        $rep->Line($rep->row + 4);
        $rep->NewLine();
    }
    $rep->fontSize += 2;
    $rep->TextCol(0, 3, _('Grand Total'));
    $rep->fontSize -= 2;
    for ($i = 0; $i < count($total); $i++) {
        $rep->AmountCol($i + 3, $i + 4, $total[$i], $dec);
        if ($graphics && $i < count($total) - 1) {
            $pg->y[$i] = abs($total[$i]);
        }
    }
    $rep->Line($rep->row - 8);
    $rep->NewLine();
    if ($graphics) {
        global $decseps, $graph_skin;
        $pg->x = array(_('Current'), $nowdue, $pastdue1, $pastdue2);
        $pg->title = $rep->title;
        $pg->axis_x = _("Days");
        $pg->axis_y = _("Amount");
        $pg->graphic_1 = $to;
        $pg->type = $graphics;
        $pg->skin = $graph_skin;
        $pg->built_in = false;
        $pg->latin_notation = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != ".";
        $filename = company_path() . "/pdf_files/" . uniqid("") . ".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->NewPage();
        }
        $rep->AddImage($filename, $x, $rep->row - $h, $w, $h);
    }
    $rep->End();
}
function print_inventory_sales()
{
    global $path_to_root;
    $from = $_POST['PARAM_0'];
    $destination = $_POST['PARAM_1'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $dec = user_price_dec();
    if ($category == ALL_NUMERIC) {
        $category = 0;
    }
    if ($category == 0) {
        $cat = _('All');
    } else {
        $cat = get_category_name($category);
    }
    $cols = array(0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1050, 1100, 1150, 1200);
    $headers = array(_('Date'), _('Client Name'), _('IMC'), _('Charge'), _('Sales'), _('Date'), _('CM#'), _('Returns'), _(''), _('Discount'), _('Balance'), _('Date'), _('PR/OR#'), _('Date'), _('OR #'), _('Partial'), _('Net'), _('Balance'), _('Date'), _(''), _('Commission'), _('w/tax'), _('Net Commission'));
    $header2 = array(_(''), '', '', _('Invoice'), _('Amount'), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), '', _(''), _(''));
    $aligns = array('left', 'center', 'center', 'center', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''));
    $rep = new FrontReport(_('Series Report'), "Series Report", user_pagesize(), 8, 'L');
    $rep->Font();
    $rep->Info($params, $cols, $header2, $aligns, $cols, $headers, $aligns);
    $rep->NewPage();
    $total = $grandtotal = 0.0;
    $total1 = $grandtotal1 = 0.0;
    $total2 = $grandtotal2 = 0.0;
    $catt = '';
    $res = getTransactions($imc, $from);
    while ($myrow = db_fetch($res)) {
        $company_data = get_company_prefs();
        $branch = get_branch($myrow["branch_code"]);
        $branch_data = get_branch_accounts($myrow['branch_code']);
        $dt = get_discount($branch_data['sales_discount_account'], $myrow['type'], $myrow['trans_no']);
        $salesman = get_imc_code($myrow['branch_code']);
        $res2 = get_return_details($myrow['order_']);
        $returns = 0;
        $rtn_dt = 0;
        while ($myrow2 = db_fetch($res2)) {
            $returns += $myrow2['ov_amount'];
            $credit_num = $myrow2['customized_no'];
            $cm_date = $myrow2['tran_date'];
            $res2 = get_return_discount($branch_data['sales_discount_account'], $myrow2['type'], $myrow2['trans_no']);
            while ($myrow3 = db_fetch($res2)) {
                $rtn_dt += abs($myrow3['amount']);
            }
        }
        $total_returns = $returns + $rtn_dt;
        $return_discount = $rtn_dt / $total_returns * 100;
        $discount = $myrow['discount'];
        $invoicetot = $myrow['ov_amount'] + $dt;
        $sales_discount = ($invoicetot - $total_returns) * ($return_discount / 100);
        $net_sales = $invoicetot - $total_returns - $sales_discount;
        $gross_commission = ($invoicetot - $total_returns) * ($myrow['commission'] / 100);
        $rep->TextCol(0, 1, $myrow['tran_date']);
        $rep->TextCol(1, 2, $myrow['br_name']);
        $rep->TextCol(2, 3, $salesman);
        $rep->TextCol(3, 4, $myrow['customized_no']);
        $rep->AmountCol(4, 5, $invoicetot, 2);
        $rep->TextCol(5, 6, $cm_date);
        $rep->TextCol(6, 7, $credit_num);
        $rep->AmountCol(7, 8, $total_returns, 2);
        $rep->TextCol(8, 9, $return_discount . "%");
        $rep->AmountCol(9, 10, $sales_discount, 2);
        $rep->AmountCol(10, 11, $net_sales, 2);
        $rep->TextCol(18, 19, $myrow['date']);
        $rep->TextCol(19, 20, $myrow['commission'] . "%");
        $rep->AmountCol(20, 21, $gross_commission, 2);
        $rep->AmountCol(21, 22, $myrow['with_tax'], 2);
        $rep->AmountCol(22, 23, $myrow['net_commission'], 2);
        $or = get_pr_details($myrow['type'], $myrow['trans_no']);
        while ($pr = db_fetch($or)) {
            $net_remittance = $net_sales - $pr['amt'];
            $rep->TextCol(11, 12, $pr['date_alloc']);
            $rep->TextCol(12, 13, $pr['customized_no']);
            $rep->TextCol(13, 14, _("DATE"));
            $rep->TextCol(14, 15, _("OR#"));
            $rep->TextCol(15, 16, "");
            $rep->AmountCol(17, 18, '', 2);
        }
        $rep->NewLine();
        //
    }
    $rep->NewLine();
    $rep->End();
}
Exemplo n.º 14
0
function print_invoices()
{
    global $path_to_root, $alternative_tax_include_on_docs, $suppress_tax_rates, $no_zero_lines_amount;
    include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $currency = $_POST['PARAM_2'];
    $email = $_POST['PARAM_3'];
    $pay_service = $_POST['PARAM_4'];
    $comments = $_POST['PARAM_5'];
    $customer = $_POST['PARAM_6'];
    $orientation = $_POST['PARAM_7'];
    if (!$from || !$to) {
        return;
    }
    $orientation = $orientation ? 'L' : 'P';
    $dec = user_price_dec();
    $fno = explode("-", $from);
    $tno = explode("-", $to);
    $from = min($fno[0], $tno[0]);
    $to = max($fno[0], $tno[0]);
    $cols = array(-15, 10, 30, 50, 80, 240, 300, 340, 360, 400);
    // $headers in doctext.inc
    $aligns = array('right', 'left', 'left', 'left', 'left', 'left', 'right', 'right', 'right', 'right');
    $params = array('comments' => $comments);
    $cur = get_company_Pref('curr_default');
    if ($email == 0) {
        $rep = new FrontReport(_('INVOICE'), "InvoiceBulk", user_pagesize(), 9, $orientation);
    }
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    for ($i = $from; $i <= $to; $i++) {
        if (!exists_customer_trans(ST_SALESINVOICE, $i)) {
            continue;
        }
        $sign = 1;
        $myrow = get_customer_trans($i, ST_SALESINVOICE);
        if ($customer && $myrow['debtor_no'] != $customer) {
            continue;
        }
        $baccount = get_default_bank_account($myrow['curr_code']);
        $params['bankaccount'] = $baccount['id'];
        $branch = get_branch($myrow["branch_code"]);
        $salesm = get_salesman_name($branch['salesman']);
        $sales_order = get_sales_order_header($myrow["order_"], ST_SALESORDER);
        if ($email == 1) {
            $rep = new FrontReport("", "", user_pagesize(), 9, $orientation);
            $rep->title = _('INVOICE');
            $rep->filename = "Invoice" . $myrow['reference'] . ".pdf";
        }
        $rep->SetHeaderType(0);
        $rep->currency = $cur;
        $rep->Font();
        $rep->Info(null, $cols, null, $aligns);
        $contacts = get_branch_contacts($branch['branch_code'], 'invoice', $branch['debtor_no'], true);
        $baccount['payment_service'] = $pay_service;
        $rep->SetCommonData($myrow, $branch, $sales_order, $baccount, ST_SALESINVOICE, $contacts);
        $rep->NewPage();
        $result = get_customer_trans_details(ST_SALESINVOICE, $i);
        $SubTotal = 0;
        $invoice_no = get_custom_no($myrow['trans_no'], ST_SALESINVOICE);
        $rep->NewLine(5);
        $rep->TextCol(2, 5, $branch['br_name']);
        $rep->TextCol(7, 9, $myrow['TranDate']);
        $rep->NewLine();
        $rep->TextCol(2, 10, $branch['br_address']);
        $rep->TextCol(7, 9, "SI - " . $invoice_no);
        $rep->NewLine();
        $rep->TextCol(0, 2, "Contact: ");
        $rep->TextCol(2, 5, $contacts["name"] . $contacts["name2"]);
        $rep->TextCol(6, 9, "IMC: " . $salesm);
        $rep->NewLine();
        $rep->TextCol(2, 5, "");
        $rep->NewLine();
        $rep->TextCol(2, 5, "");
        $rep->NewLine(3);
        //$rep->NewLine(2);
        $ent = 0;
        while ($myrow2 = db_fetch($result)) {
            if ($myrow2["quantity"] == 0) {
                continue;
            }
            $Net = round2($sign * ((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"]), user_price_dec());
            $SubTotal += $Net;
            $DisplayPrice = number_format2($myrow2["unit_price"], 2);
            $DisplayQty = number_format2($sign * $myrow2["quantity"], get_qty_dec($myrow2['stock_id']));
            $DisplayNet = number_format2($Net, 2);
            if ($myrow2["discount_percent"] == 0) {
                $DisplayDiscount = "";
            } else {
                $DisplayDiscount = number_format2($myrow2["discount_percent"] * 100, 2) . "%";
            }
            //$rep->TextCol(3, 4,	$myrow2['stock_id'], -2);
            $oldrow = $rep->row;
            $rep->TextColLines(4, 6, $myrow2['StockDescription'], -2);
            $newrow = $rep->row;
            $rep->row = $oldrow;
            $ent++;
            if ($Net != 0.0 || !is_service($myrow2['mb_flag']) || !isset($no_zero_lines_amount) || $no_zero_lines_amount == 0) {
                $rep->TextCol(2, 3, $DisplayQty, -2);
                $rep->TextCol(3, 4, $myrow2['units'], -2);
                $rep->TextCol(6, 7, $DisplayPrice, -2);
                $rep->TextCol(7, 9, $DisplayNet, -2);
            }
            $rep->row = $newrow;
            //$rep->NewLine(1);
            if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) {
                $rep->NewPage();
            }
        }
        $memo = get_comments_string(ST_SALESINVOICE, $i);
        if ($memo != "") {
            $rep->NewLine();
            $rep->TextColLines(1, 5, $memo, -2);
        }
        $DisplaySubTot = $SubTotal;
        $rep->NewLine(8 - $ent);
        $doctype = ST_SALESINVOICE;
        $tot = $sign * ($myrow["ov_freight"] + $myrow["ov_gst"] + $myrow["ov_amount"] + $myrow["ov_freight_tax"]);
        if ($tot != $SubTotal) {
            $discount = $SubTotal * ($myrow['bulk_discount'] / 100);
        }
        $rep->AmountCol(7, 9, $DisplaySubTot, 2);
        $rep->NewLine();
        if ($myrow['bulk_discount'] != 0) {
            $rep->TextCol(5, 7, "Less Discount: " . $myrow['bulk_discount'] . "%");
        }
        $rep->AmountCol(7, 9, $discount, 2);
        $rep->NewLine();
        $DisplayTotal = $sign * ($myrow["ov_freight"] + $myrow["ov_gst"] + $myrow["ov_amount"] + $myrow["ov_freight_tax"]);
        $rep->Font('bold');
        $rep->AmountCol(7, 9, $DisplayTotal, 2);
    }
    if ($email == 0) {
        $rep->End();
    }
}
Exemplo n.º 15
0
function print_inventory_purchase()
{
    global $path_to_root;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $category = $_POST['PARAM_2'];
    $location = $_POST['PARAM_3'];
    $fromsupp = $_POST['PARAM_4'];
    $item = $_POST['PARAM_5'];
    $comments = $_POST['PARAM_6'];
    $orientation = $_POST['PARAM_7'];
    $destination = $_POST['PARAM_8'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $dec = user_price_dec();
    if ($category == ALL_NUMERIC) {
        $category = 0;
    }
    if ($category == 0) {
        $cat = _('All');
    } else {
        $cat = get_category_name($category);
    }
    if ($location == '') {
        $loc = _('All');
    } else {
        $loc = get_location_name($location);
    }
    if ($fromsupp == '') {
        $froms = _('All');
    } else {
        $froms = get_supplier_name($fromsupp);
    }
    if ($item == '') {
        $itm = _('All');
    } else {
        $itm = $item;
    }
    $cols = array(0, 60, 180, 225, 275, 400, 420, 465, 520);
    $headers = array(_('Category'), _('Description'), _('Date'), _('#'), _('Supplier'), _('Qty'), _('Unit Price'), _('Total'));
    if ($fromsupp != '') {
        $headers[4] = '';
    }
    $aligns = array('left', 'left', 'left', 'left', 'left', 'left', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 3 => array('text' => _('Location'), 'from' => $loc, 'to' => ''), 4 => array('text' => _('Supplier'), 'from' => $froms, 'to' => ''), 5 => array('text' => _('Item'), 'from' => $itm, 'to' => ''));
    $rep = new FrontReport(_('Inventory Purchasing Report'), "InventoryPurchasingReport", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $res = getTransactions($category, $location, $fromsupp, $item, $from, $to);
    $total = $total_supp = $grandtotal = 0.0;
    $total_qty = 0.0;
    $catt = $stock_description = $stock_id = $supplier_name = '';
    while ($trans = db_fetch($res)) {
        if ($stock_description != $trans['description']) {
            if ($stock_description != '') {
                if ($supplier_name != '') {
                    $rep->NewLine(2, 3);
                    $rep->TextCol(0, 1, _('Total'));
                    $rep->TextCol(1, 4, $stock_description);
                    $rep->TextCol(4, 5, $supplier_name);
                    $rep->AmountCol(5, 7, $total_qty, get_qty_dec($stock_id));
                    $rep->AmountCol(7, 8, $total_supp, $dec);
                    $rep->Line($rep->row - 2);
                    $rep->NewLine();
                    $total_supp = $total_qty = 0.0;
                    $supplier_name = $trans['supplier_name'];
                }
            }
            $stock_id = $trans['stock_id'];
            $stock_description = $trans['description'];
        }
        if ($supplier_name != $trans['supplier_name']) {
            if ($supplier_name != '') {
                $rep->NewLine(2, 3);
                $rep->TextCol(0, 1, _('Total'));
                $rep->TextCol(1, 4, $stock_description);
                $rep->TextCol(4, 5, $supplier_name);
                $rep->AmountCol(5, 7, $total_qty, get_qty_dec($stock_id));
                $rep->AmountCol(7, 8, $total_supp, $dec);
                $rep->Line($rep->row - 2);
                $rep->NewLine();
                $total_supp = $total_qty = 0.0;
            }
            $supplier_name = $trans['supplier_name'];
        }
        if ($catt != $trans['cat_description']) {
            if ($catt != '') {
                $rep->NewLine(2, 3);
                $rep->TextCol(0, 1, _('Total'));
                $rep->TextCol(1, 7, $catt);
                $rep->AmountCol(7, 8, $total, $dec);
                $rep->Line($rep->row - 2);
                $rep->NewLine();
                $rep->NewLine();
                $total = 0.0;
            }
            $rep->TextCol(0, 1, $trans['category_id']);
            $rep->TextCol(1, 6, $trans['cat_description']);
            $catt = $trans['cat_description'];
            $rep->NewLine();
        }
        $curr = get_supplier_currency($trans['supplier_id']);
        $rate = get_exchange_rate_from_home_currency($curr, sql2date($trans['tran_date']));
        $trans['price'] *= $rate;
        $rep->NewLine();
        $trans['supp_reference'] = get_supp_inv_reference($trans['supplier_id'], $trans['stock_id'], $trans['tran_date']);
        $rep->fontSize -= 2;
        $rep->TextCol(0, 1, $trans['stock_id']);
        if ($fromsupp == ALL_TEXT) {
            $rep->TextCol(1, 2, $trans['description'] . ($trans['inactive'] == 1 ? " (" . _("Inactive") . ")" : ""), -1);
            $rep->TextCol(2, 3, sql2date($trans['tran_date']));
            $rep->TextCol(3, 4, $trans['supp_reference']);
            $rep->TextCol(4, 5, $trans['supplier_name']);
        } else {
            $rep->TextCol(1, 2, $trans['description'] . ($trans['inactive'] == 1 ? " (" . _("Inactive") . ")" : ""), -1);
            $rep->TextCol(2, 3, sql2date($trans['tran_date']));
            $rep->TextCol(3, 4, $trans['supp_reference']);
        }
        $rep->AmountCol(5, 6, $trans['qty'], get_qty_dec($trans['stock_id']));
        $rep->AmountCol(6, 7, $trans['price'], $dec);
        $amt = $trans['qty'] * $trans['price'];
        $rep->AmountCol(7, 8, $amt, $dec);
        $rep->fontSize += 2;
        $total += $amt;
        $total_supp += $amt;
        $grandtotal += $amt;
        $total_qty += $trans['qty'];
    }
    if ($stock_description != '') {
        if ($supplier_name != '') {
            $rep->NewLine(2, 3);
            $rep->TextCol(0, 1, _('Total'));
            $rep->TextCol(1, 4, $stock_description);
            $rep->TextCol(4, 5, $supplier_name);
            $rep->AmountCol(5, 7, $total_qty, get_qty_dec($stock_id));
            $rep->AmountCol(7, 8, $total_supp, $dec);
            $rep->Line($rep->row - 2);
            $rep->NewLine();
            $rep->NewLine();
            $total_supp = $total_qty = 0.0;
            $supplier_name = $trans['supplier_name'];
        }
    }
    if ($supplier_name != '') {
        $rep->NewLine(2, 3);
        $rep->TextCol(0, 1, _('Total'));
        $rep->TextCol(1, 4, $stock_description);
        $rep->TextCol(4, 5, $supplier_name);
        $rep->AmountCol(5, 7, $total_qty, get_qty_dec($stock_id));
        $rep->AmountCol(7, 8, $total_supp, $dec);
        $rep->Line($rep->row - 2);
        $rep->NewLine();
        $rep->NewLine();
    }
    $rep->NewLine(2, 3);
    $rep->TextCol(0, 1, _('Total'));
    $rep->TextCol(1, 7, $catt);
    $rep->AmountCol(7, 8, $total, $dec);
    $rep->Line($rep->row - 2);
    $rep->NewLine();
    $rep->NewLine(2, 1);
    $rep->TextCol(0, 7, _('Grand Total'));
    $rep->AmountCol(7, 8, $grandtotal, $dec);
    $rep->Line($rep->row - 4);
    $rep->NewLine();
    $rep->End();
}
Exemplo n.º 16
0
function print_grn_valuation()
{
    global $path_to_root;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $comments = $_POST['PARAM_2'];
    $orientation = $_POST['PARAM_3'];
    $destination = $_POST['PARAM_4'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $dec = user_price_dec();
    $cols = array(0, 75, 225, 260, 295, 330, 370, 410, 455, 515);
    $headers = array(_('Stock ID'), _('Description'), _('PO No'), _('GRN') . "#", _('Inv') . "#", _('Qty'), _('Inv Price'), _('PO Price'), _('Total'));
    $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to));
    $rep = new FrontReport(_('GRN Valuation Report'), "GRNValuationReport", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $res = getTransactions($from, $to);
    $total = $qtotal = $grandtotal = 0.0;
    $stock_id = '';
    while ($trans = db_fetch($res)) {
        if ($stock_id != $trans['item_code']) {
            if ($stock_id != '') {
                $rep->Line($rep->row - 4);
                $rep->NewLine(2);
                $rep->TextCol(0, 3, _('Total'));
                $rep->AmountCol(5, 6, $qtotal, $qdec);
                $rep->AmountCol(8, 9, $total, $dec);
                $rep->NewLine();
                $total = $qtotal = 0;
            }
            $stock_id = $trans['item_code'];
        }
        $curr = get_supplier_currency($trans['supplier_id']);
        $rate = get_exchange_rate_from_home_currency($curr, sql2date($trans['delivery_date']));
        $trans['std_cost_unit'] *= $rate;
        $rep->NewLine();
        $rep->TextCol(0, 1, $trans['item_code']);
        $rep->TextCol(1, 2, $trans['description']);
        $rep->TextCol(2, 3, $trans['order_no']);
        $qdec = get_qty_dec($trans['item_code']);
        $rep->TextCol(3, 4, $trans['batch_no']);
        if ($trans['quantity_inv']) {
            $suppinv = getSuppInvDetails($trans['grn_item_id']);
            while ($inv = db_fetch($suppinv)) {
                $inv['inv_price'] *= $rate;
                $rep->TextCol(4, 5, $inv['inv_no']);
                $rep->AmountCol(5, 6, $inv['inv_qty'], $qdec);
                $rep->AmountCol(6, 7, $inv['inv_price'], $dec);
                $rep->AmountCol(7, 8, $trans['std_cost_unit'], $dec);
                $amt = round2($inv['inv_qty'] * $inv['inv_price'], $dec);
                $rep->AmountCol(8, 9, $amt, $dec);
                $rep->NewLine();
                $total += $amt;
                $qtotal += $inv['inv_qty'];
                $grandtotal += $amt;
            }
        }
        if ($trans['qty_recd'] - $trans['quantity_inv'] != 0) {
            $rep->TextCol(4, 5, "--");
            $rep->AmountCol(5, 6, $trans['qty_recd'] - $trans['quantity_inv'], $qdec);
            $rep->AmountCol(7, 8, $trans['unit_price'], $dec);
            $amt = round2(($trans['qty_recd'] - $trans['quantity_inv']) * $trans['unit_price'], $dec);
            $rep->AmountCol(8, 9, $amt, $dec);
            $total += $amt;
            $qtotal += $trans['qty_recd'] - $trans['quantity_inv'];
            $grandtotal += $amt;
        } else {
            $rep->NewLine(-1);
        }
    }
    if ($stock_id != '') {
        $rep->Line($rep->row - 4);
        $rep->NewLine(2);
        $rep->TextCol(0, 3, _('Total'));
        $rep->AmountCol(5, 6, $qtotal, $qdec);
        $rep->AmountCol(8, 9, $total, $dec);
        $rep->Line($rep->row - 4);
        $rep->NewLine(2);
        $rep->TextCol(0, 7, _('Grand Total'));
        $rep->AmountCol(8, 9, $grandtotal, $dec);
    }
    $rep->Line($rep->row - 4);
    $rep->NewLine();
    $rep->End();
}
function print_check()
{
    global $path_to_root, $systypes_array, $print_invoice_no;
    // Get the payment
    $from = $_POST['PARAM_0'];
    $destination = $_POST['PARAM_1'];
    $trans_no = explode("-", $from);
    $dec = user_price_dec();
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $from_trans = get_remittance($trans_no[1], $trans_no[0]);
    // Get check information
    $total_amt = $from_trans['Total'];
    $date = sql2date($from_trans['tran_date']);
    $memo = get_comments_string($trans_no[1], $trans_no[0]);
    // Begin the report
    $rep = new FrontReport(_('Printable Check'), "PrintableCheck", user_pagesize());
    $rep->SetHeaderType(null);
    $rep->NewPage();
    // Set the font
    $rep->Font('', 'courier');
    $rep->fontSize = 12;
    //////////////////
    // Check portion
    $rep->NewLine(1, 0, 76);
    $rep->cols = array(63, 340, 470, 565);
    $rep->aligns = array('left', 'left', 'right', 'right');
    // Pay to
    $rep->TextCol(0, 1, $from_trans['supp_name']);
    // Date
    $rep->DateCol(1, 2, $rep->DatePrettyPrint($date, 0, 0));
    // Amount (numeric)
    $rep->TextCol(2, 3, '***' . number_format2(-$total_amt, $dec));
    // Amount (words)
    $rep->NewLine(1, 0, 23);
    $rep->TextCol(0, 2, $from_trans['curr_code'] . ": " . price_in_words(-$total_amt, ST_CHEQUE));
    // Memo
    $rep->NewLine(1, 0, 78);
    $rep->TextCol(0, 1, $memo);
    $rep->company = get_company_prefs();
    /////////////////////
    // Item details x 2
    for ($section = 1; $section <= 2; $section++) {
        $rep->fontSize = 12;
        // Move down to the correct section
        $rep->row = $section == 1 ? 505 : 255;
        $rep->cols = array(20, 340, 470, 588);
        $rep->aligns = array('left', 'left', 'right', 'right');
        // Pay to
        $rep->Font('b');
        $rep->TextCol(0, 1, $from_trans['supp_name']);
        $rep->Font();
        // Date
        $rep->DateCol(1, 2, $rep->DatePrettyPrint($date, 0, 0));
        // Amount (numeric)
        $rep->TextCol(2, 3, number_format2(-$total_amt, 2));
        // Add Trans # + Reference
        $rep->NewLine();
        if ($print_invoice_no == 0) {
            $tno = $from_trans['reference'];
        } else {
            $tno = $from_trans['trans_no'];
        }
        $rep->TextCol(0, 3, sprintf(_("Payment # %s - from Customer: %s - %s"), $tno, $from_trans['supp_account_no'], $rep->company['coy_name']));
        // Add memo
        $rep->NewLine();
        $rep->TextCol(0, 3, _("Memo: ") . $memo);
        // TODO: Do we want to set a limit on # of item details?  (Max is probably 6-7)
        // Get item details
        $result = get_allocations_for_remittance($from_trans['supplier_id'], $from_trans['type'], $from_trans['trans_no']);
        // Fill in details
        $rep->NewLine(2);
        $rep->fontSize = 10;
        // Use different columns now for the additional info
        $rep->cols = array(20, 160, 235, 290, 370, 480, 588);
        $rep->aligns = array('left', 'left', 'left', 'right', 'right', 'right');
        // Add headers
        $rep->Font('b');
        $rep->TextCol(0, 1, _("Type/Id"));
        $rep->TextCol(1, 2, _("Trans Date"));
        $rep->TextCol(2, 3, _("Due Date"));
        $rep->TextCol(3, 4, _("Total Amount"));
        $rep->TextCol(4, 5, _("Left to Allocate"));
        $rep->TextCol(5, 6, _("This Allocation"));
        $rep->NewLine();
        $rep->Font();
        $total_allocated = 0;
        while ($item = db_fetch($result)) {
            $rep->TextCol(0, 1, $systypes_array[$item['type']] . " " . $item['supp_reference']);
            $rep->TextCol(1, 2, sql2date($item['tran_date']));
            $rep->TextCol(2, 3, sql2date($item['due_date']));
            $rep->AmountCol(3, 4, $item['Total'], $dec);
            $rep->AmountCol(4, 5, $item['Total'] - $item['alloc'], $dec);
            $rep->AmountCol(5, 6, $item['amt'], $dec);
            $total_allocated += $item['amt'];
            $rep->NewLine(1, 0, $rep->lineHeight + 3);
            // Space it out
        }
        $rep->NewLine();
        $rep->TextCol(4, 5, _("Total Allocated"));
        $rep->AmountCol(5, 6, $total_allocated, $dec);
        $rep->NewLine();
        $rep->TextCol(4, 5, _("Left to Allocate"));
        $rep->AmountCol(5, 6, -$from_trans['Total'] - $total_allocated, $dec);
    }
    // end of section
    $rep->End();
}
Exemplo n.º 18
0
function print_subsidiary_ledger()
{
    global $path_to_root, $systypes_array;
    $dim = get_company_pref('use_dimension');
    $dimension = $dimension2 = 0;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $cat = $_POST['PARAM_2'];
    $account = $_POST['PARAM_3'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report2.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $rep = new FrontReport(_('Subsidiary Ledger Report'), "SubsidiaryLedger", user_pagesize(), 9, $orientation);
    $dec = user_price_dec();
    //$headers = array(_('Type'),   _('Ref'), _('#'),   _('Date'), _('Dimension')." 1", _('Dimension')." 2",
    //      _('Person/Item'), _('Debit'),   _('Credit'), _('Balance'));
    //$cols = array(0, 80, 100, 150, 210, 280, 340, 400, 450, 510, 570);
    $cols = array(0, 65, 105, 125, 175, 230, 290, 345, 405, 465, 525);
    //------------0--1---2---3----4----5----6----7----8----9----10-------
    //-----------------------dim1-dim2-----------------------------------
    //-----------------------dim1----------------------------------------
    //-------------------------------------------------------------------
    $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right');
    $headers = array(_('ID'), '', '', '', '', '', '', _('Debit'), _('Credit'), _('Balance'));
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $fromacc));
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->SetHeaderType('0');
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $rep->NewLine(5);
    $rep->TextCol(4, 8, "ST. MATTHEWS PUBLISHING CORPORATION");
    $rep->NewLine();
    $rep->TextCol(1, 10, "First RVC Building #92 Anonas corner K-6 Streets, East Kamias, Quezon City 1102");
    $rep->NewLine(3);
    $rep->TextCol(4, 8, "SUBSIDIARY LEDGER");
    $rep->NewLine(2);
    //date range here
    if ($cat == 3) {
        $person = get_salesman_name($account);
    }
    $rep->TextCol(0, 2, "Name:" . $person);
    $rep->NewLine();
    $rep->TextCol(0, 1, "ID:");
    $rep->TextCol(1, 2, "Src:");
    $rep->TextCol(2, 3, "Date:");
    $rep->TextCol(3, 4, "Memo:");
    $rep->TextCol(4, 5, "Account:");
    $rep->TextCol(5, 6, "Debit:");
    $rep->TextCol(6, 7, "Credit:");
    $rep->NewLine(2);
    /*  $rep->TextCol(0,1, $from);
        $rep->TextCol(1,2, $to);
        $rep->TextCol(2,3, $cat);
        $rep->TextCol(3,4, $account);*/
    $rep->TextCol(0, 1, $person);
    $rep->NewLine();
    $result = getTransaction($from, $to, $cat, $account);
    while ($myrow = db_fetch($result)) {
        if ($myrow['type'] == ST_DISBURSEMENT && $myrow['customized_no'] != 0) {
            $type = "CV";
        } else {
            $type = "";
        }
        $rep->TextCol(0, 5, $type . "#" . $myrow['customized_no']);
        $rep->TextCol(2, 3, "");
        $rep->TextCol(3, 4, $myrow['tran_date']);
        $rep->TextCol(4, 5, $myrow['account']);
        $rep->AmountCol(5, 6, $myrow['amount'], 2);
        if ($myrow['amount'] < 0) {
            $cr += $myrow['amount'];
        }
        if ($myrow['amount'] > 0) {
            $dr += $myrow['amount'];
        }
        $rep->NewLine();
    }
    $rep->AmountCol(5, 6, $dr, 2);
    $rep->NewLine();
    $rep->AmountCol(1, 2, abs($cr), 2);
    $rep->End();
}
Exemplo n.º 19
0
function print_salesman_list()
{
    global $path_to_root;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $summary = $_POST['PARAM_2'];
    $comments = $_POST['PARAM_3'];
    $orientation = $_POST['PARAM_4'];
    $destination = $_POST['PARAM_5'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    if ($summary == 0) {
        $sum = _("No");
    } else {
        $sum = _("Yes");
    }
    $dec = user_price_dec();
    $cols = array(0, 60, 150, 220, 325, 385, 450, 515);
    $headers = array(_('Invoice'), _('Customer'), _('Branch'), _('Customer Ref'), _('Inv Date'), _('Total'), _('Provision'));
    $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right');
    $headers2 = array(_('Salesman'), " ", _('Phone'), _('Email'), _('Provision'), _('Break Pt.'), _('Provision') . " 2");
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Summary Only'), 'from' => $sum, 'to' => ''));
    $aligns2 = $aligns;
    $rep = new FrontReport(_('Salesman Listing'), "SalesmanListing", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $cols2 = $cols;
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2);
    $rep->NewPage();
    $salesman = 0;
    $subtotal = $total = $subprov = $provtotal = 0;
    $result = GetSalesmanTrans($from, $to);
    while ($myrow = db_fetch($result)) {
        $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, _('Total'));
                $rep->AmountCol(5, 6, $subtotal, $dec);
                $rep->AmountCol(6, 7, $subprov, $dec);
                $rep->Line($rep->row - 4);
                $rep->NewLine(2);
            }
            $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->AmountCol(5, 6, $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;
        }
        $rate = $myrow['rate'];
        $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->DateCol(4, 5, $myrow['tran_date'], true);
            $rep->AmountCol(5, 6, $amt, $dec);
            $rep->AmountCol(6, 7, $prov, $dec);
            $rep->NewLine();
        }
        $subtotal += $amt;
        $subprov += $prov;
    }
    if ($salesman != 0) {
        $rep->Line($rep->row - 4);
        $rep->NewLine(2);
        $rep->TextCol(0, 3, _('Total'));
        $rep->AmountCol(5, 6, $subtotal, $dec);
        $rep->AmountCol(6, 7, $subprov, $dec);
        $rep->Line($rep->row - 4);
        $rep->NewLine(2);
        $total += $subtotal;
        $provtotal += $subprov;
    }
    $rep->fontSize += 2;
    $rep->TextCol(0, 3, _('Grand Total'));
    $rep->fontSize -= 2;
    $rep->AmountCol(5, 6, $total, $dec);
    $rep->AmountCol(6, 7, $provtotal, $dec);
    $rep->Line($rep->row - 4);
    $rep->NewLine();
    $rep->End();
}
Exemplo n.º 20
0
function print_order_status_list()
{
    global $path_to_root;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $category = $_POST['PARAM_2'];
    $location = $_POST['PARAM_3'];
    $backorder = $_POST['PARAM_4'];
    $comments = $_POST['PARAM_5'];
    $orientation = $_POST['PARAM_6'];
    $destination = $_POST['PARAM_7'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    if ($category == ALL_NUMERIC) {
        $category = 0;
    }
    if ($location == ALL_TEXT) {
        $location = null;
    }
    if ($category == 0) {
        $cat = _('All');
    } else {
        $cat = get_category_name($category);
    }
    if ($location == null) {
        $loc = _('All');
    } else {
        $loc = get_location_name($location);
    }
    if ($backorder == 0) {
        $back = _('All Orders');
    } else {
        $back = _('Back Orders Only');
    }
    $cols = array(0, 60, 150, 260, 325, 385, 450, 515);
    $headers2 = array(_('Order'), _('Customer'), _('Branch'), _('Customer Ref'), _('Ord Date'), _('Del Date'), _('Loc'));
    $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right');
    $headers = array(_('Code'), _('Description'), _('Ordered'), _('Delivered'), _('Outstanding'), '');
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 3 => array('text' => _('Location'), 'from' => $loc, 'to' => ''), 4 => array('text' => _('Selection'), 'from' => $back, 'to' => ''));
    $aligns2 = $aligns;
    $rep = new FrontReport(_('Order Status Listing'), "OrderStatusListing", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $cols2 = $cols;
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns, $cols2, $headers2, $aligns2);
    $rep->NewPage();
    $orderno = 0;
    $result = GetSalesOrders($from, $to, $category, $location, $backorder);
    while ($myrow = db_fetch($result)) {
        $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->DateCol(4, 5, $myrow['ord_date'], true);
            $rep->DateCol(5, 6, $myrow['delivery_date'], true);
            $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']);
        $dec = get_qty_dec($myrow['stk_code']);
        $rep->AmountCol(2, 3, $myrow['quantity'], $dec);
        $rep->AmountCol(3, 4, $myrow['qty_sent'], $dec);
        $rep->AmountCol(4, 5, $myrow['quantity'] - $myrow['qty_sent'], $dec);
        if ($myrow['quantity'] - $myrow['qty_sent'] > 0) {
            $rep->Font('italic');
            $rep->TextCol(5, 6, _('Outstanding'));
            $rep->Font();
        }
        $rep->NewLine();
    }
    $rep->Line($rep->row);
    $rep->End();
}
Exemplo n.º 21
0
function print_subsidiary_ledger()
{
    global $path_to_root, $systypes_array;
    $dim = get_company_pref('use_dimension');
    $dimension = $dimension2 = 0;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $cat = $_POST['PARAM_2'];
    $account = $_POST['PARAM_3'];
    $account2 = $_POST['PARAM_4'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report2.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $rep = new FrontReport(_('Subsidiary Ledger Report'), "SubsidiaryLedger", user_pagesize(), 9, L);
    $dec = user_price_dec();
    //$headers = array(_('Type'),   _('Ref'), _('#'),   _('Date'), _('Dimension')." 1", _('Dimension')." 2",
    //      _('Person/Item'), _('Debit'),   _('Credit'), _('Balance'));
    //$cols = array(0, 80, 100, 150, 210, 280, 340, 400, 450, 510, 570);
    $cols = array(0, 50, 140, 200, 210, 400, 450, 550, 600, 650);
    //------------0--1---2-----3----4----5----6----7----8----9----10-------
    //-----------------------dim1-dim2-----------------------------------
    //-----------------------dim1----------------------------------------
    //-------------------------------------------------------------------
    $aligns = array('left', 'left', 'left', 'left', 'left', 'right', 'right', 'right', 'right', 'right');
    //$headers = array(_('ID'), '', '', '', '', '', '', _('Debit'), _('Credit'), _('Balance'));
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Accounts'), 'from' => $fromacc, 'to' => $fromacc));
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->SetHeaderType('header3');
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    if ($cat == 3) {
        $person = get_salesman_name($account);
    }
    if ($cat == 1) {
        $person = get_supplier_name($account);
    }
    /*$rep->TextCol(0,2, $cat);
      $rep->NewLine();*/
    $rep->Font('bold');
    $rep->TextCol(0, 2, "Name:" . $person);
    $rep->NewLine();
    $rep->TextCol(0, 1, "ID:");
    $rep->TextCol(1, 2, "Src:");
    $rep->TextCol(2, 3, "Date:");
    $rep->TextCol(4, 5, "Memo:");
    $rep->TextCol(5, 6, "Account:");
    $rep->TextCol(6, 7, "Debit:");
    $rep->TextCol(8, 9, "Credit:");
    $rep->Font();
    $rep->NewLine(2);
    $result = getTransaction($from, $to, $cat, $account, $account2);
    $type = '';
    while ($myrow = db_fetch($result)) {
        if ($myrow['Voided'] == '' && $myrow['amount'] > 0) {
            $comments = get_comments_string($myrow['type'], $myrow['type_no']);
            $custom = get_custom_no($myrow['type_no'], $myrow['type']);
            if ($myrow['type'] == ST_DISBURSEMENT) {
                $type = "CD";
            }
            if ($myrow['type'] == ST_PURCHASEORDER) {
                $type = "P.O.";
            }
            if ($myrow['type'] == ST_SUPPAYMENT) {
                $type = "CD";
            }
            //else
            //    $type = $systypes_array[$myrow["type"]];
            $rep->TextCol(0, 1, "#" . $custom);
            $rep->TextCol(1, 2, $type);
            $rep->TextCol(2, 3, $myrow['tranDate']);
            $rep->TextCol(4, 5, $comments);
            $rep->TextCol(5, 6, $myrow['account']);
            $dr += $myrow['amount'];
            $rep->AmountCol(6, 7, $myrow['amount'], 2);
            $rep->NewLine();
        } else {
            if ($myrow['Voided'] == '' && $myrow['amount'] < 0) {
                $cr += $myrow['amount'];
                //$rep->AmountCol(8,9, $myrow['amount'], 2);
            }
        }
    }
    $rep->NewLine(2);
    $rep->Font('bold');
    $rep->AmountCol(6, 7, $dr, 2);
    $rep->NewLine(2);
    $rep->TextCol(1, 2, "Net Activity: ");
    $rep->AmountCol(2, 4, $cr, 2);
    $rep->End();
}
Exemplo n.º 22
0
function print_sales_summary_report()
{
    global $path_to_root;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $tax_id = $_POST['PARAM_2'];
    $comments = $_POST['PARAM_3'];
    $orientation = $_POST['PARAM_4'];
    $destination = $_POST['PARAM_5'];
    if ($tax_id == 0) {
        $tid = _('No');
    } else {
        $tid = _('Yes');
    }
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $dec = user_price_dec();
    $rep = new FrontReport(_('Sales Summary Report'), "SalesSummaryReport", user_pagesize(), 9, $orientation);
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Tax Id Only'), 'from' => $tid, 'to' => ''));
    $cols = array(0, 130, 180, 270, 350, 400, 500);
    $headers = array(_('Customer'), _('Total ex. Tax'), _('Tax'), _('Total'), _('Balance'), _('Due'));
    $aligns = array('left', 'left', 'right', 'right', 'right', 'right');
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $totalnet = 0.0;
    $totaltax = 0.0;
    $transactions = getTaxTransactions($from, $to, $tax_id);
    $rep->TextCol(0, 4, _('Balances in Home Currency'));
    $rep->NewLine(2);
    $custno = 0;
    $tax = $total = 0;
    $custname = $tax_id = "";
    while ($trans = db_fetch($transactions)) {
        $customer_record = get_customer_details($custno);
        $customer_crm = getPhone($custno);
        if ($custno != $trans['debtor_no']) {
            if ($custno != 0) {
                $rep->TextCol(0, 1, $custname);
                //$rep->TextCol(1, 2,	$tax_id);
                $rep->TextCol(1, 2, $custno, $dec);
                $rep->TextCol(2, 3, $trans['debtor_no'], $dec);
                $rep->TextCol(3, 4, $customer_crm['phone'], $dec);
                $rep->AmountCol(4, 5, $tax + $total, $dec);
                $rep->AmountCol(5, 6, $customer_record["Balance"], $dec);
                $totalnet += $total;
                $totaltax += $tax;
                $total = $tax = 0;
                $rep->NewLine();
                if ($rep->row < $rep->bottomMargin + $rep->lineHeight) {
                    $rep->Line($rep->row - 2);
                    $rep->NewPage();
                }
            }
            $custno = $trans['debtor_no'];
            $custname = $trans['cust_name'];
            $tax_id = $trans['tax_id'];
        }
        $taxes = getTaxes($trans['type'], $trans['trans_no']);
        if ($taxes != null) {
            if ($taxes['included_in_price']) {
                $trans['total'] -= $taxes['tax'];
            }
            $tax += $taxes['tax'];
        }
        $total += $trans['total'];
    }
    if ($custno != 0) {
        $customer_record = get_customer_details($custno);
        $rep->TextCol(0, 1, $custname);
        //$rep->TextCol(1, 2,	$tax_id);
        $rep->AmountCol(1, 2, $total, $dec);
        $rep->AmountCol(2, 3, $tax, $dec);
        $rep->AmountCol(3, 4, $tax + $total, $dec);
        $rep->AmountCol(4, 5, $customer_record["Balance"], $dec);
        $rep->AmountCol(5, 6, $customer_record["Due"], $dec);
        $totalnet += $total;
        $totaltax += $tax;
        $rep->NewLine();
    }
    $rep->Font('bold');
    $rep->NewLine();
    $rep->Line($rep->row + $rep->lineHeight);
    $rep->TextCol(0, 1, _("Total"));
    $rep->AmountCol(1, 2, $totalnet, $dec);
    $rep->AmountCol(2, 3, $totaltax, $dec);
    $rep->AmountCol(3, 4, $totaltax + $totalnet, $dec);
    $rep->Line($rep->row - 5);
    $rep->Font();
    $rep->End();
}
Exemplo n.º 23
0
function print_inventory_planning()
{
    global $path_to_root;
    $category = $_POST['PARAM_0'];
    $location = $_POST['PARAM_1'];
    $comments = $_POST['PARAM_2'];
    $orientation = $_POST['PARAM_3'];
    $destination = $_POST['PARAM_4'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    if ($category == ALL_NUMERIC) {
        $category = 0;
    }
    if ($category == 0) {
        $cat = _('All');
    } else {
        $cat = get_category_name($category);
    }
    if ($location == ALL_TEXT) {
        $location = 'all';
    }
    if ($location == 'all') {
        $loc = _('All');
    } else {
        $loc = get_location_name($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'), 1, date('Y')));
    $per1 = strftime('%b', mktime(0, 0, 0, date('m') - 1, 1, date('Y')));
    $per2 = strftime('%b', mktime(0, 0, 0, date('m') - 2, 1, date('Y')));
    $per3 = strftime('%b', mktime(0, 0, 0, date('m') - 3, 1, date('Y')));
    $per4 = strftime('%b', mktime(0, 0, 0, date('m') - 4, 1, date('Y')));
    $headers = array(_('Category'), '', $per4, $per3, $per2, $per1, $per0, '3*M', _('QOH'), _('Cust Ord'), _('Supp Ord'), _('Sugg Ord'));
    $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 2 => array('text' => _('Location'), 'from' => $loc, 'to' => ''));
    $rep = new FrontReport(_('Inventory Planning Report'), "InventoryPlanning", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $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();
        }
        if ($location == 'all') {
            $loc_code = "";
        } else {
            $loc_code = $location;
        }
        $custqty = get_demand_qty($trans['stock_id'], $loc_code);
        $custqty += get_demand_asm_qty($trans['stock_id'], $loc_code);
        $suppqty = get_on_porder_qty($trans['stock_id'], $loc_code);
        $suppqty += get_on_worder_qty($trans['stock_id'], $loc_code);
        $period = getPeriods($trans['stock_id'], $trans['loc_code']);
        $rep->NewLine();
        $dec = get_qty_dec($trans['stock_id']);
        $rep->TextCol(0, 1, $trans['stock_id']);
        $rep->TextCol(1, 2, $trans['description'] . ($trans['inactive'] == 1 ? " (" . _("Inactive") . ")" : ""), -1);
        $rep->AmountCol(2, 3, $period['prd0'], $dec);
        $rep->AmountCol(3, 4, $period['prd1'], $dec);
        $rep->AmountCol(4, 5, $period['prd2'], $dec);
        $rep->AmountCol(5, 6, $period['prd3'], $dec);
        $rep->AmountCol(6, 7, $period['prd4'], $dec);
        $MaxMthSales = Max($period['prd0'], $period['prd1'], $period['prd2'], $period['prd3']);
        $IdealStockHolding = $MaxMthSales * 3;
        $rep->AmountCol(7, 8, $IdealStockHolding, $dec);
        $rep->AmountCol(8, 9, $trans['qty_on_hand'], $dec);
        $rep->AmountCol(9, 10, $custqty, $dec);
        $rep->AmountCol(10, 11, $suppqty, $dec);
        $SuggestedTopUpOrder = $IdealStockHolding - $trans['qty_on_hand'] + $custqty - $suppqty;
        if ($SuggestedTopUpOrder < 0.0) {
            $SuggestedTopUpOrder = 0.0;
        }
        $rep->AmountCol(11, 12, $SuggestedTopUpOrder, $dec);
    }
    $rep->Line($rep->row - 4);
    $rep->NewLine();
    $rep->End();
}
Exemplo n.º 24
0
function inventory_movements()
{
    global $path_to_root;
    $from_date = $_POST['PARAM_0'];
    $to_date = $_POST['PARAM_1'];
    $category = $_POST['PARAM_2'];
    $location = $_POST['PARAM_3'];
    $comments = $_POST['PARAM_4'];
    $orientation = $_POST['PARAM_5'];
    $destination = $_POST['PARAM_6'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    if ($category == ALL_NUMERIC) {
        $category = 0;
    }
    if ($category == 0) {
        $cat = _('All');
    } else {
        $cat = get_category_name($category);
    }
    //	if ($location == ALL_TEXT)
    //		$location = '';
    if ($location == '') {
        $loc = _('All');
    } else {
        $loc = get_location_name($location);
    }
    //$cols = array(0, 100, 300, 365, 440, 540, 640, 715);
    $cols = array(0, 60, 220, 240, 310, 380, 450, 520);
    $headers = array(_('Category'), _('Description'), _('UOM'), _('Opening'), _('Quantity In'), _('Quantity Out'), _('Balance'));
    $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from_date, 'to' => $to_date), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 3 => array('text' => _('Location'), 'from' => $loc, 'to' => ''));
    $rep = new FrontReport(_('Inventory Movements'), "InventoryMovements", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $result = fetch_items($category);
    $catgor = '';
    while ($myrow = db_fetch($result)) {
        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, $myrow['units']);
        $qoh_start = $inward = $outward = $qoh_end = 0;
        $qoh_start += get_qoh_on_date($myrow['stock_id'], $location, add_days($from_date, -1));
        $qoh_end += get_qoh_on_date($myrow['stock_id'], $location, $to_date);
        $inward += trans_qty($myrow['stock_id'], $location, $from_date, $to_date);
        $outward += trans_qty($myrow['stock_id'], $location, $from_date, $to_date, false);
        $rep->AmountCol(3, 4, $qoh_start, get_qty_dec($myrow['stock_id']));
        $rep->AmountCol(4, 5, $inward, get_qty_dec($myrow['stock_id']));
        $rep->AmountCol(5, 6, $outward, get_qty_dec($myrow['stock_id']));
        $rep->AmountCol(6, 7, $qoh_end, get_qty_dec($myrow['stock_id']));
        $rep->NewLine(0, 1);
    }
    $rep->Line($rep->row - 4);
    $rep->NewLine();
    $rep->End();
}
Exemplo n.º 25
0
function print_inventory_sales()
{
    global $path_to_root;
    $from = $_POST['PARAM_0'];
    $destination = $_POST['PARAM_1'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $dec = user_price_dec();
    if ($category == ALL_NUMERIC) {
        $category = 0;
    }
    if ($category == 0) {
        $cat = _('All');
    } else {
        $cat = get_category_name($category);
    }
    $cols = array(0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900, 950, 1000, 1050, 1100, 1150, 1200);
    $headers = array(_('Date'), _('Client Name'), _('IMC'), _('Charge'), _('Sales'), _('Date'), _('CM#'), _('Returns'), _(''), _('Discount'), _('Balance'), _('Date'), _('PR/OR#'), _('Date'), _('OR #'), _('Amount'), _('Partial'), _('Balance'), _('Date'), _(''), _('Commission'), _('w/tax'), _('Net Commission'));
    $header2 = array(_(''), '', '', _('Invoice'), _('Amount'), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), _(''), '', _(''), _(''));
    $aligns = array('left', 'center', 'center', 'center', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''));
    $rep = new FrontReport(_('Series Report'), "SeriesReport", user_pagesize(), 8, 'L');
    $rep->Font();
    $rep->Info($params, $cols, $header2, $aligns, $cols, $headers, $aligns);
    $rep->NewPage();
    $total = $grandtotal = 0.0;
    $total1 = $grandtotal1 = 0.0;
    $total2 = $grandtotal2 = 0.0;
    $catt = '';
    $res = getTransactions($imc, $from);
    while ($myrow = db_fetch($res)) {
        $company_data = get_company_prefs();
        $branch = get_branch($myrow["branch_code"]);
        $branch_data = get_branch_accounts($myrow['branch_code']);
        $dt = get_discount($branch_data['sales_discount_account'], $myrow['type'], $myrow['trans_no']);
        $salesman = get_imc_code($myrow['branch_code']);
        $res2 = get_return_details($myrow['order_']);
        $returns = 0;
        $rtn_dt = 0;
        $credit_num = "";
        $cm_date = "";
        $num = db_num_rows($res2);
        $var = array();
        while ($myrow2 = db_fetch($res2)) {
            $returns += $myrow2['ov_amount'];
            if ($num > 1) {
                $credit_num .= $myrow2['customized_no'] . "/";
                $cm_date = $myrow2['tran_date'] . "/";
            } else {
                $credit_num .= $myrow2['customized_no'];
                $cm_date = $myrow2['tran_date'];
            }
            $var = array($myrow2['trans_no']);
            //$res2 = get_return_discount($branch_data['sales_discount_account'], $myrow2['type'], $myrow2['trans_no']);
            //	while ($myrow3 = db_fetch($res2)){
            //		$rtn_dt += abs($myrow3['amount']);
            //	}
        }
        foreach ($var as $vars) {
            $res2 = get_return_discount($branch_data['sales_discount_account'], ST_CUSTCREDIT, $vars);
            while ($myrow3 = db_fetch($res2)) {
                $rtn_dt += abs($myrow3['amount']);
            }
        }
        $total_returns = $returns + $rtn_dt;
        $return_discount = $rtn_dt / $total_returns * 100;
        //$discount = $myrow['discount'];
        $invoicetot = $myrow['ov_amount'] + $dt;
        $invoice_discount = $dt / $invoicetot * 100;
        $sales_discount = ($invoicetot - $total_returns) * ($invoice_discount / 100);
        $net_sales = $invoicetot - $total_returns - $sales_discount;
        $gross_commission = ($invoicetot - $total_returns) * ($myrow['commission'] / 100);
        $tot_invoice = $invoicetot - $invoicetot * ($invoice_discount / 100);
        $sample = $invoicetot - $total_returns;
        $rep->TextCol(0, 1, $myrow['tranDate']);
        $rep->TextCol(1, 2, $myrow['br_name']);
        $rep->TextCol(2, 3, $salesman);
        $rep->TextCol(3, 4, $myrow['customized_no']);
        if ($myrow['IsVoid'] == '') {
            $rep->AmountCol(4, 5, $invoicetot, 2);
            $rep->TextCol(5, 6, $cm_date);
            $rep->TextCol(6, 7, $credit_num);
            if ($total_returns != 0) {
                $rep->AmountCol(7, 8, $total_returns, 2);
            }
            if ($invoice_discount < 0) {
                $rep->TextCol(8, 9, "CLIENT SALES/SALES DISCOUNT NOT DEFINED.");
            } else {
                $rep->TextCol(8, 9, $invoice_discount . "%");
            }
            if ($sales_discount < 0) {
                $rep->TextCol(9, 10, "ERROR.");
            } else {
                if ($sales_discount != 0) {
                    $rep->AmountCol(9, 10, $sales_discount, 2);
                }
            }
            if ($net_sales != 0) {
                $rep->AmountCol(10, 11, $net_sales, 2);
            }
            $partial_payment = 0;
            $or = get_pr_details($myrow['type'], $myrow['trans_no']);
            $ref = '';
            $num2 = db_num_rows($or);
            $date_alloc = '';
            while ($pr = db_fetch($or)) {
                $partial_payment += $pr['amt'];
                $date_alloc = $pr['prDate'] . " ";
                $pr_number = $pr['customized_no'] . " ";
                if ($num2 > 1) {
                    $ref .= $pr['reference'] . "/";
                } else {
                    $ref = $pr['reference'];
                }
            }
            $net_remittance = $net_sales - $partial_payment;
            $rep->TextCol(11, 12, $date_alloc);
            $rep->TextCol(12, 13, $ref);
            $rep->TextCol(13, 14, $date_alloc);
            $rep->TextCol(14, 15, _(""));
            if ($partial_payment == $tot_invoice) {
                $rep->AmountCol(15, 16, $partial_payment, 2);
            }
            if ($partial_payment != 0) {
                if ($partial_payment < $tot_invoice) {
                    $bal = $tot_invoice - $partial_payment;
                    $rep->AmountCol(16, 17, $partial_payment, 2);
                    $rep->AmountCol(17, 18, $bal, 2);
                }
            }
            //$rep->AmountCol(15,16, $partial_payment, 2);
            //$rep->AmountCol(17,18, $net_remittance, 2);
            $myrow4 = db_fetch(get_commission_details($myrow['type'], $myrow['trans_no']));
            $comm = ($invoicetot - $total_returns) * ($myrow4['commission'] / 100);
            $rep->TextCol(18, 19, $myrow4['tranDate']);
            if ($myrow4['commission'] != 0) {
                $rep->TextCol(19, 20, $myrow4['commission'] . "%");
            }
            if ($comm != 0) {
                $rep->AmountCol(20, 21, $comm, 2);
            }
            if ($myrow4['with_tax'] != 0) {
                $rep->AmountCol(21, 22, $myrow4['with_tax'], 2);
            }
            if ($myrow4['net_commission'] != 0) {
                $rep->AmountCol(22, 23, $myrow4['net_commission'], 2);
            }
            $net_invoice += $invoicetot;
            $net_discount += $sales_discount;
            $net_returns += $total_returns;
            $sale_amount += $net_sales;
            $net_partial += $partial_payment;
            $net_rem += $net_remittance;
            $net_bal += $bal;
            $net_balance = $net_rem + $net_bal;
            $net_comm += $comm;
            $net_tax += $myrow4['with_tax'];
            $net_net_comm += $myrow4['net_commission'];
        } else {
            $rep->TextCol(4, 5, "Voided");
        }
        $rep->NewLine();
    }
    $rep->Font('bold');
    $rep->NewLine();
    $rep->TextCol(1, 2, "TOTAL");
    $rep->AmountCol(4, 5, $net_invoice, 2);
    $rep->AmountCol(7, 8, $net_returns, 2);
    $rep->AmountCol(9, 10, $net_discount, 2);
    $rep->AmountCol(10, 11, $sale_amount, 2);
    $rep->AmountCol(16, 17, $net_partial, 2);
    //$rep->AmountCol(17,18, $net_balance, 2);
    $rep->AmountCol(20, 21, $net_comm, 2);
    $rep->AmountCol(21, 22, $net_tax, 2);
    $rep->AmountCol(22, 23, $net_net_comm, 2);
    $rep->NewLine();
    $rep->End();
}
Exemplo n.º 26
0
function print_inventory_sales()
{
    global $path_to_root;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $category = $_POST['PARAM_2'];
    $comments = $_POST['PARAM_3'];
    $orientation = $_POST['PARAM_4'];
    $destination = $_POST['PARAM_5'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $dec = user_price_dec();
    if ($category == ALL_NUMERIC) {
        $category = 0;
    }
    if ($category == 0) {
        $cat = _('All');
    } else {
        $cat = get_category_name($category);
    }
    $cols = array(0, 100, 260, 300, 350, 425, 430, 515);
    $headers = array(_('Item/Category'), _('Description'), _('Qty'), _('Unit Price'), _('Sales'), '', _('Remark'));
    $aligns = array('left', 'left', 'right', 'right', 'right', 'right', 'left');
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''));
    $rep = new FrontReport(_('Item Sales Summary Report'), "ItemSalesSummaryReport", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $res = getTransactions($category, $from, $to);
    $total = $grandtotal = 0.0;
    $total1 = $grandtotal1 = 0.0;
    $total2 = $grandtotal2 = 0.0;
    $catt = '';
    while ($trans = db_fetch($res)) {
        if ($catt != $trans['cat_description']) {
            if ($catt != '') {
                $rep->NewLine(2, 3);
                $rep->TextCol(0, 4, _('Total'));
                $rep->AmountCol(4, 5, $total, $dec);
                $rep->Line($rep->row - 2);
                $rep->NewLine();
                $rep->NewLine();
                $total = $total1 = $total2 = 0.0;
            }
            $rep->TextCol(0, 1, $trans['category_id']);
            $rep->TextCol(1, 7, $trans['cat_description']);
            $catt = $trans['cat_description'];
            $rep->NewLine();
        }
        $rep->NewLine();
        $rep->fontSize -= 2;
        $rep->TextCol(0, 1, $trans['stock_id']);
        $rep->TextCol(1, 2, $trans['description']);
        $rep->AmountCol(2, 3, $trans['quantity'], get_qty_dec($trans['stock_id']));
        $rep->AmountCol(3, 4, $trans['unit_price'], $dec);
        $rep->AmountCol(4, 5, $trans['quantity'] * $trans['unit_price'], $dec);
        if ($trans['unit_price'] == 0) {
            $rep->TextCol(6, 7, _('Gift'));
        }
        $rep->fontSize += 2;
        $total += $trans['quantity'] * $trans['unit_price'];
        $grandtotal += $trans['quantity'] * $trans['unit_price'];
    }
    $rep->NewLine(2, 3);
    $rep->TextCol(0, 4, _('Total'));
    $rep->AmountCol(4, 5, $total, $dec);
    $rep->Line($rep->row - 2);
    $rep->NewLine();
    $rep->NewLine(2, 1);
    $rep->TextCol(0, 4, _('Grand Total'));
    $rep->AmountCol(4, 5, $grandtotal, $dec);
    $rep->Line($rep->row - 4);
    $rep->NewLine();
    $rep->End();
}
Exemplo n.º 27
0
function inventory_movements()
{
    global $path_to_root;
    $from_date = $_POST['PARAM_0'];
    $to_date = $_POST['PARAM_1'];
    $category = $_POST['PARAM_2'];
    $location = $_POST['PARAM_3'];
    $comments = $_POST['PARAM_4'];
    $orientation = $_POST['PARAM_5'];
    $destination = $_POST['PARAM_6'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    if ($category == ALL_NUMERIC) {
        $category = 0;
    }
    if ($category == 0) {
        $cat = _('All');
    } else {
        $cat = get_category_name($category);
    }
    if ($location == '') {
        $loc = _('All');
    } else {
        $loc = get_location_name($location);
    }
    $cols = array(0, 60, 130, 160, 185, 215, 250, 275, 305, 340, 365, 395, 430, 455, 485, 520);
    $headers = array(_('Category'), _('Description'), _('UOM'), '', '', _('OpeningStock'), '', '', _('StockIn'), '', '', _('Delivery'), '', '', _('ClosingStock'));
    $headers2 = array("", "", "", _("QTY"), _("Rate"), _("Value"), _("QTY"), _("Rate"), _("Value"), _("QTY"), _("Rate"), _("Value"), _("QTY"), _("Rate"), _("Value"));
    $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from_date, 'to' => $to_date), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 3 => array('text' => _('Location'), 'from' => $loc, 'to' => ''));
    $rep = new FrontReport(_('Costed Inventory Movements'), "CostedInventoryMovements", user_pagesize(), 8, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers2, $aligns, $cols, $headers, $aligns);
    $rep->NewPage();
    $totval_open = $totval_in = $totval_out = $totval_close = 0;
    $result = fetch_items($category);
    $dec = user_price_dec();
    $catgor = '';
    while ($myrow = db_fetch($result)) {
        if ($catgor != $myrow['description']) {
            $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, $myrow['units']);
        $qoh_start = get_qoh_on_date($myrow['stock_id'], $location, add_days($from_date, -1));
        $qoh_end = get_qoh_on_date($myrow['stock_id'], $location, $to_date);
        $inward = trans_qty($myrow['stock_id'], $location, $from_date, $to_date);
        $outward = trans_qty($myrow['stock_id'], $location, $from_date, $to_date, false);
        $openCost = avg_unit_cost($myrow['stock_id'], $location, $from_date);
        $unitCost = avg_unit_cost($myrow['stock_id'], $location, add_days($to_date, 1));
        $rep->AmountCol(3, 4, $qoh_start, get_qty_dec($myrow['stock_id']));
        $rep->AmountCol(4, 5, $openCost, $dec);
        $openCost *= $qoh_start;
        $totval_open += $openCost;
        $rep->AmountCol(5, 6, $openCost);
        if ($inward > 0) {
            $rep->AmountCol(6, 7, $inward, get_qty_dec($myrow['stock_id']));
            $unitCost_in = trans_qty_unit_cost($myrow['stock_id'], $location, $from_date, $to_date);
            $rep->AmountCol(7, 8, $unitCost_in, $dec);
            $unitCost_in *= $inward;
            $totval_in += $unitCost_in;
            $rep->AmountCol(8, 9, $unitCost_in);
        }
        if ($outward > 0) {
            $rep->AmountCol(9, 10, $outward, get_qty_dec($myrow['stock_id']));
            $unitCost_out = trans_qty_unit_cost($myrow['stock_id'], $location, $from_date, $to_date, false);
            $rep->AmountCol(10, 11, $unitCost_out, $dec);
            $unitCost_out *= $outward;
            $totval_out += $unitCost_out;
            $rep->AmountCol(11, 12, $unitCost_out);
        }
        $rep->AmountCol(12, 13, $qoh_end, get_qty_dec($myrow['stock_id']));
        $rep->AmountCol(13, 14, $unitCost, $dec);
        $unitCost *= $qoh_end;
        $totval_close += $unitCost;
        $rep->AmountCol(14, 15, $unitCost);
        $rep->NewLine(0, 1);
    }
    $rep->Line($rep->row - 4);
    $rep->NewLine(2);
    $rep->TextCol(0, 1, _("Total"));
    $rep->AmountCol(5, 6, $totval_open);
    $rep->AmountCol(8, 9, $totval_in);
    $rep->AmountCol(11, 12, $totval_out);
    $rep->AmountCol(14, 15, $totval_close);
    $rep->Line($rep->row - 4);
    $rep->End();
}
Exemplo n.º 28
0
function print_inventory_sales()
{
    global $path_to_root;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $category = $_POST['PARAM_2'];
    $location = $_POST['PARAM_3'];
    $fromcust = $_POST['PARAM_4'];
    $comments = $_POST['PARAM_5'];
    $orientation = $_POST['PARAM_6'];
    $destination = $_POST['PARAM_7'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    $dec = user_price_dec();
    if ($category == ALL_NUMERIC) {
        $category = 0;
    }
    if ($category == 0) {
        $cat = _('All');
    } else {
        $cat = get_category_name($category);
    }
    if ($location == '') {
        $loc = _('All');
    } else {
        $loc = get_location_name($location);
    }
    if ($fromcust == '') {
        $fromc = _('All');
    } else {
        $fromc = get_customer_name($fromcust);
    }
    $cols = array(0, 75, 175, 250, 300, 375, 450, 515);
    $headers = array(_('Category'), _('Description'), _('Customer'), _('Qty'), _('Sales'), _('Cost'), _('Contribution'));
    if ($fromcust != '') {
        $headers[2] = '';
    }
    $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 3 => array('text' => _('Location'), 'from' => $loc, 'to' => ''), 4 => array('text' => _('Customer'), 'from' => $fromc, 'to' => ''));
    $rep = new FrontReport(_('Inventory Sales Report'), "InventorySalesReport", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $res = getTransactions($category, $location, $fromcust, $from, $to);
    $total = $grandtotal = 0.0;
    $total1 = $grandtotal1 = 0.0;
    $total2 = $grandtotal2 = 0.0;
    $catt = '';
    while ($trans = db_fetch($res)) {
        if ($catt != $trans['cat_description']) {
            if ($catt != '') {
                $rep->NewLine(2, 3);
                $rep->TextCol(0, 4, _('Total'));
                $rep->AmountCol(4, 5, $total, $dec);
                $rep->AmountCol(5, 6, $total1, $dec);
                $rep->AmountCol(6, 7, $total2, $dec);
                $rep->Line($rep->row - 2);
                $rep->NewLine();
                $rep->NewLine();
                $total = $total1 = $total2 = 0.0;
            }
            $rep->TextCol(0, 1, $trans['category_id']);
            $rep->TextCol(1, 6, $trans['cat_description']);
            $catt = $trans['cat_description'];
            $rep->NewLine();
        }
        $curr = get_customer_currency($trans['debtor_no']);
        $rate = get_exchange_rate_from_home_currency($curr, sql2date($trans['tran_date']));
        $trans['amt'] *= $rate;
        $cb = $trans['amt'] - $trans['cost'];
        $rep->NewLine();
        $rep->fontSize -= 2;
        $rep->TextCol(0, 1, $trans['stock_id']);
        if ($fromcust == ALL_TEXT) {
            $rep->TextCol(1, 2, $trans['description'] . ($trans['inactive'] == 1 ? " (" . _("Inactive") . ")" : ""), -1);
            $rep->TextCol(2, 3, $trans['debtor_name']);
        } else {
            $rep->TextCol(1, 3, $trans['description'] . ($trans['inactive'] == 1 ? " (" . _("Inactive") . ")" : ""), -1);
        }
        $rep->AmountCol(3, 4, $trans['qty'], get_qty_dec($trans['stock_id']));
        $rep->AmountCol(4, 5, $trans['amt'], $dec);
        $rep->AmountCol(5, 6, $trans['cost'], $dec);
        $rep->AmountCol(6, 7, $cb, $dec);
        $rep->fontSize += 2;
        $total += $trans['amt'];
        $total1 += $trans['cost'];
        $total2 += $cb;
        $grandtotal += $trans['amt'];
        $grandtotal1 += $trans['cost'];
        $grandtotal2 += $cb;
    }
    $rep->NewLine(2, 3);
    $rep->TextCol(0, 4, _('Total'));
    $rep->AmountCol(4, 5, $total, $dec);
    $rep->AmountCol(5, 6, $total1, $dec);
    $rep->AmountCol(6, 7, $total2, $dec);
    $rep->Line($rep->row - 2);
    $rep->NewLine();
    $rep->NewLine(2, 1);
    $rep->TextCol(0, 4, _('Grand Total'));
    $rep->AmountCol(4, 5, $grandtotal, $dec);
    $rep->AmountCol(5, 6, $grandtotal1, $dec);
    $rep->AmountCol(6, 7, $grandtotal2, $dec);
    $rep->Line($rep->row - 4);
    $rep->NewLine();
    $rep->End();
}
function print_statements()
{
    global $path_to_root, $systypes_array;
    include_once $path_to_root . "/reporting/includes/pdf_report2.inc";
    $from = date2sql($_POST['PARAM_0']);
    $to = date2sql($_POST['PARAM_1']);
    $customer = $_POST['PARAM_2'];
    $currency = $_POST['PARAM_3'];
    $email = $_POST['PARAM_4'];
    $comments = $_POST['PARAM_5'];
    $orientation = $_POST['PARAM_6'];
    $orientation = $orientation ? 'L' : 'P';
    $dec = 2;
    $cols = array(4, 64, 180, 250, 300, 350, 400, 480);
    //$headers in doctext.inc
    $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right');
    $params = array('comments' => $comments);
    $cur = get_company_pref('curr_default');
    $PastDueDays1 = get_company_pref('past_due_days');
    $PastDueDays2 = 2 * $PastDueDays1;
    if ($email == 0) {
        $rep = new FrontReport(_('CUSTOMER ACCOUNT STATEMENT'), "StatementBulk", user_pagesize(), 9, $orientation);
    }
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $sql = "SELECT b.debtor_no, b.name AS DebtorName, b.address, b.tax_id, b.curr_code, cust.salesman, \n\tcurdate() AS tran_date, CONCAT (d.name, d.name2) AS contactPerson, d.phone, d.phone2  \n\tFROM " . TB_PREF . "debtors_master b INNER JOIN\n" . TB_PREF . "crm_contacts c on b.debtor_no=c.entity_id INNER JOIN " . TB_PREF . "crm_persons d on c.person_id=d.id\nINNER JOIN " . TB_PREF . "cust_branch cust on b.debtor_no=cust.debtor_no";
    if ($customer != ALL_TEXT) {
        $sql .= " WHERE c.type='customer' and cust.salesman = " . db_escape($customer);
    } else {
        $sql .= " where c.type='customer' and cust.salesman = " . db_escape($customer) . " ORDER by b.name";
    }
    $result = db_query($sql, "The customers could not be retrieved");
    while ($debtor_row = db_fetch($result)) {
        $date = date('Y-m-d');
        if ($from != $to) {
            // find the latest point where the balance was null
            $start = findLatestNullDate($debtor_row['debtor_no'], $from);
            // but not earlier than the $to date.
            if (date1_greater_date2(sql2date($start), sql2date($to))) {
                $start = $to;
            }
            if (date1_greater_date2(sql2date($from), sql2date($start))) {
                $start = $from;
            }
        } else {
            $start = $from;
        }
        $debtor_row['order_'] = "";
        $TransResult = getTransactions($debtor_row['debtor_no'], $start, $date);
        $baccount = get_default_bank_account($debtor_row['curr_code']);
        $params['bankaccount'] = $baccount['id'];
        if (db_num_rows($TransResult) == 0) {
            continue;
        }
        if ($email == 1) {
            $rep = new FrontReport("CUSTOMER ACCOUNT STATEMENT", "", user_pagesize(), 9, $orientation);
            $rep->title = _('STATEMENT OF ACCOUNT');
            $rep->filename = "Statement" . $debtor_row['debtor_no'] . ".pdf";
            $rep->Info($params, $cols, null, $aligns);
        }
        $rep->filename = "ST-" . strtr($debtor_row['DebtorName'], " '", "__") . "--" . strtr(Today(), "/", "-") . ".pdf";
        $contacts = get_customer_contacts($debtor_row['debtor_no'], 'invoice');
        $rep->SetHeaderType('customheader');
        $rep->currency = $cur;
        $rep->Font();
        $rep->Info(null, $cols, null, $aligns);
        $rep->SetCommonData($debtor_row, null, null, $baccount, ST_STATEMENT, $contacts);
        $rep->NewPage();
        $doctype = ST_STATEMENT;
        //$rep->TextCol(0,4,"yeah");
        $current = false;
        $balance = getInitialBalance($debtor_row['debtor_no'], $start);
        if (true || Abs($balance) > 1.0E-6) {
            if (Abs($balance) < 1.0E-6) {
                $rep->SetTextColor(190, 190, 190);
            } else {
                if ($balance > 0) {
                    $rep->SetTextColor(190, 0, 0);
                }
            }
            $rep->SetTextColor(0, 0, 0);
        }
        $overdue = 0;
        $prev = '';
        $gross_amount = 0;
        $gross_amount2 = 0;
        $payment_tot = 0;
        $tots = 0;
        $discount_amount = 0;
        $percent = 0;
        while ($transaction_row = db_fetch($TransResult)) {
            if ($myrow['IsVoid'] == '') {
                $company_data = get_company_prefs();
                $branch = get_branch($transaction_row["branch_code"]);
                $branch_data = get_branch_accounts($transaction_row['branch_code']);
                $dt = get_discount($branch_data['sales_discount_account'], $transaction_row['type'], $transaction_row['trans_no']);
                $DisplayTotal = number_format2(Abs($transaction_row["TotalAmount"] + $dt), $dec);
                $DisplayAlloc = number_format2($transaction_row["Allocated"], $dec);
                $DisplayNet = number_format2($transaction_row["TotalAmount"] - $transaction_row["Allocated"], $dec);
                /*if ($dt != 0 && $transaction_row['type'] == ST_SALESINVOICE || $transaction_row['type'] == ST_CUSTCREDIT)
                		{
                			$discount_amount += $dt;
                				$ctr = $transaction_row['bulk_discount'];
                		}*/
                $amount = $transaction_row["TotalAmount"] + $dt;
                $balance += $transaction_row["TotalAmount"];
                $invoice_no = get_custom_no($transaction_row['trans_no'], $transaction_row['type']);
                $enter1 = 0;
                if ($systypes_array[$transaction_row['type']] == "Customer Payment") {
                    $open_pay = get_payment_invoice_details($transaction_row["trans_no"], ST_CUSTPAYMENT);
                    if ($open_pay) {
                        $stat2 = false;
                    } else {
                        $stat2 = true;
                        $payment_tot += $amount;
                        $text = "pr#";
                    }
                }
                if ($systypes_array[$transaction_row['type']] == "Sales Invoice") {
                    if ($transaction_row['ov_amount'] > $transaction_row['alloc'] || $transaction_row['alloc'] == 0) {
                        $discount_amount += $dt;
                        $ctr = $transaction_row['bulk_discount'];
                        $gross_amount += $amount;
                        $text = '';
                        $stat3 = true;
                    } else {
                        $stat3 = false;
                    }
                }
                if ($systypes_array[$transaction_row['type']] == "Customer Credit Note") {
                    $open = get_sales_invoice_details($transaction_row['order_'], ST_SALESINVOICE);
                    if ($open) {
                        $stat = false;
                    } else {
                        $discount_amount += $dt;
                        $ctr = $transaction_row['bulk_discount'];
                        $gross_amount2 += $amount;
                        $stat = true;
                    }
                    $text = "cm#";
                }
                $current = $text;
                $tot = $gross_amount + $gross_amount2 - $discount_amount;
                if ($current != '') {
                    if ($prev == $current) {
                    } else {
                        if ($prev == "" && $text == "cm#" && $stat) {
                            $rep->NewLine();
                            $rep->TextCol(1, 2, "Less Returns");
                            $rep->NewLine();
                        }
                        if ($text == 'pr#' && $prev == "cm#" && $stat2) {
                            $rep->AmountCol(6, 7, $tot, 2);
                            $rep->NewLine(2);
                            $rep->TextCol(1, 2, "Less Payments:");
                            $rep->NewLine();
                        }
                        if ($prev == '' && $text == 'pr#' && $stat2) {
                            $rep->TextCol(1, 2, "Less Payments:");
                            $rep->NewLine();
                        }
                    }
                    $prev = $current;
                }
                if ($transaction_row['type'] == ST_SALESINVOICE && $stat3) {
                    $rep->TextCol(1, 2, $text . $invoice_no, -2);
                    $rep->TextCol(0, 3, sql2date($transaction_row['tran_date']), -2);
                    $rep->TextCol(3, 4, $DisplayTotal, -2);
                    $rep->NewLine();
                }
                if ($transaction_row['type'] == ST_CUSTCREDIT && $stat) {
                    $rep->TextCol(1, 2, $text . $invoice_no, -2);
                    $rep->TextCol(0, 3, sql2date($transaction_row['tran_date']), -2);
                    $rep->TextCol(3, 4, $DisplayTotal, -2);
                    $rep->NewLine();
                }
                if ($transaction_row['type'] == ST_CUSTPAYMENT && $stat2) {
                    if ($invoice_no == "") {
                        $rep->TextCol(1, 2, $text . $transaction_row['reference'], -2);
                    } else {
                        $rep->TextCol(1, 2, $text . $invoice_no, -2);
                    }
                    $rep->TextCol(0, 3, sql2date($transaction_row['tran_date']), -2);
                    $rep->TextCol(5, 6, $DisplayTotal, -2);
                    $rep->NewLine();
                }
                $rep->SetTextColor(0, 0, 0);
                //$rep->NewLine();
                if ($rep->row < $rep->bottomMargin + 10 * $rep->lineHeight) {
                    $rep->NewPage();
                }
            }
        }
        if (!$current) {
            $overdue = $balance;
            $balance = 0;
        }
        $rep->NewLine();
        $net = $gross_amount - abs($gross_amount2);
        $percent = $ctr / $net * 100;
        $per = number_format2($percent, 2);
        if ($per != 0) {
            $rep->TextCol(1, 2, "Less  " . $ctr . "% discount");
            $rep->AmountCol(5, 6, $discount_amount, 2);
        }
        $rep->SetTextColor(0, 0, 0);
        $rep->fontSize += 2;
        $rep->NewLine(5);
        $rep->TextCol(1, 2, 'Amount Due');
        //$rep->TextCol(6,7, "     	____________", -2);
        if ($payment_tot != 0) {
            $rep->TextCol(6, 7, number_format2($tot - abs($payment_tot), $dec));
        } else {
            $rep->AmountCol(6, 7, $tot, 2);
        }
        $rep->NewLine(5);
        $rep->TextCol(2, 4, "Verified & Checked by:");
        $rep->TextCol(4, 6, "___________________");
        $rep->NewLine();
        $rep->TextCol(4, 6, "Credit & Collection");
        $rep->fontSize -= 2;
    }
    //$rep->NewPage();
    if ($email == 0) {
        $rep->End();
    }
}
Exemplo n.º 30
0
function print_customer_balances()
{
    global $path_to_root, $systypes_array;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $fromcust = $_POST['PARAM_2'];
    $show_balance = $_POST['PARAM_3'];
    $currency = $_POST['PARAM_4'];
    $no_zeros = $_POST['PARAM_5'];
    $comments = $_POST['PARAM_6'];
    $orientation = $_POST['PARAM_7'];
    $destination = $_POST['PARAM_8'];
    if ($destination) {
        include_once $path_to_root . "/reporting/includes/excel_report.inc";
    } else {
        include_once $path_to_root . "/reporting/includes/pdf_report.inc";
    }
    $orientation = $orientation ? 'L' : 'P';
    if ($fromcust == ALL_TEXT) {
        $cust = _('All');
    } else {
        $cust = get_customer_name($fromcust);
    }
    $dec = user_price_dec();
    if ($currency == ALL_TEXT) {
        $convert = true;
        $currency = _('Balances in Home Currency');
    } else {
        $convert = false;
    }
    if ($no_zeros) {
        $nozeros = _('Yes');
    } else {
        $nozeros = _('No');
    }
    $cols = array(0, 100, 130, 190, 250, 320, 385, 450, 515);
    $headers = array(_('Trans Type'), _('#'), _('Date'), _('Due Date'), _('Charges'), _('Credits'), _('Allocated'), _('Outstanding'));
    if ($show_balance) {
        $headers[7] = _('Balance');
    }
    $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('Period'), 'from' => $from, 'to' => $to), 2 => array('text' => _('Customer'), 'from' => $cust, 'to' => ''), 3 => array('text' => _('Currency'), 'from' => $currency, 'to' => ''), 4 => array('text' => _('Suppress Zeros'), 'from' => $nozeros, 'to' => ''));
    $rep = new FrontReport(_('Customer Balances'), "CustomerBalances", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $grandtotal = array(0, 0, 0, 0);
    $sql = "SELECT debtor_no, name, curr_code FROM " . TB_PREF . "debtors_master ";
    if ($fromcust != ALL_TEXT) {
        $sql .= "WHERE debtor_no=" . db_escape($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;
        }
        $accumulate = 0;
        $rate = $convert ? get_exchange_rate_from_home_currency($myrow['curr_code'], Today()) : 1;
        $bal = get_open_balance($myrow['debtor_no'], $from, $convert);
        $init[0] = $init[1] = 0.0;
        $init[0] = round2(abs($bal['charges'] * $rate), $dec);
        $init[1] = round2(Abs($bal['credits'] * $rate), $dec);
        $init[2] = round2($bal['Allocated'] * $rate, $dec);
        if ($show_balance) {
            $init[3] = $init[0] - $init[1];
            $accumulate += $init[3];
        } else {
            $init[3] = round2($bal['OutStanding'] * $rate, $dec);
        }
        $res = get_transactions($myrow['debtor_no'], $from, $to);
        if ($no_zeros && db_num_rows($res) == 0) {
            continue;
        }
        $rep->fontSize += 2;
        $rep->TextCol(0, 2, $myrow['name']);
        if ($convert) {
            $rep->TextCol(2, 3, $myrow['curr_code']);
        }
        $rep->fontSize -= 2;
        $rep->TextCol(3, 4, _("Open Balance"));
        $rep->AmountCol(4, 5, $init[0], $dec);
        $rep->AmountCol(5, 6, $init[1], $dec);
        $rep->AmountCol(6, 7, $init[2], $dec);
        $rep->AmountCol(7, 8, $init[3], $dec);
        $total = array(0, 0, 0, 0);
        for ($i = 0; $i < 4; $i++) {
            $total[$i] += $init[$i];
            $grandtotal[$i] += $init[$i];
        }
        $rep->NewLine(1, 2);
        $rep->Line($rep->row + 4);
        if (db_num_rows($res) == 0) {
            $rep->NewLine(1, 2);
            continue;
        }
        while ($trans = db_fetch($res)) {
            if ($no_zeros && floatcmp($trans['TotalAmount'], $trans['Allocated']) == 0) {
                continue;
            }
            $rep->NewLine(1, 2);
            $rep->TextCol(0, 1, $systypes_array[$trans['type']]);
            $rep->TextCol(1, 2, $trans['reference']);
            $rep->DateCol(2, 3, $trans['tran_date'], true);
            if ($trans['type'] == ST_SALESINVOICE) {
                $rep->DateCol(3, 4, $trans['due_date'], true);
            }
            $item[0] = $item[1] = 0.0;
            if ($trans['type'] == ST_CUSTCREDIT || $trans['type'] == ST_CUSTPAYMENT || $trans['type'] == ST_BANKDEPOSIT) {
                $trans['TotalAmount'] *= -1;
            }
            if ($trans['TotalAmount'] > 0.0) {
                $item[0] = round2(abs($trans['TotalAmount']) * $rate, $dec);
                $rep->AmountCol(4, 5, $item[0], $dec);
                $accumulate += $item[0];
            } else {
                $item[1] = round2(Abs($trans['TotalAmount']) * $rate, $dec);
                $rep->AmountCol(5, 6, $item[1], $dec);
                $accumulate -= $item[1];
            }
            $item[2] = round2($trans['Allocated'] * $rate, $dec);
            $rep->AmountCol(6, 7, $item[2], $dec);
            if ($trans['type'] == ST_SALESINVOICE || $trans['type'] == ST_BANKPAYMENT) {
                $item[3] = $item[0] + $item[1] - $item[2];
            } else {
                $item[3] = $item[0] - $item[1] + $item[2];
            }
            if ($show_balance) {
                $rep->AmountCol(7, 8, $accumulate, $dec);
            } else {
                $rep->AmountCol(7, 8, $item[3], $dec);
            }
            for ($i = 0; $i < 4; $i++) {
                $total[$i] += $item[$i];
                $grandtotal[$i] += $item[$i];
            }
            if ($show_balance) {
                $total[3] = $total[0] - $total[1];
            }
        }
        $rep->Line($rep->row - 8);
        $rep->NewLine(2);
        $rep->TextCol(0, 3, _('Total'));
        for ($i = 0; $i < 4; $i++) {
            $rep->AmountCol($i + 4, $i + 5, $total[$i], $dec);
        }
        $rep->Line($rep->row - 4);
        $rep->NewLine(2);
    }
    $rep->fontSize += 2;
    $rep->TextCol(0, 3, _('Grand Total'));
    $rep->fontSize -= 2;
    if ($show_balance) {
        $grandtotal[3] = $grandtotal[0] - $grandtotal[1];
    }
    for ($i = 0; $i < 4; $i++) {
        $rep->AmountCol($i + 4, $i + 5, $grandtotal[$i], $dec);
    }
    $rep->Line($rep->row - 4);
    $rep->NewLine();
    $rep->End();
}