Пример #1
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();
}
Пример #2
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();
}
Пример #3
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();
}
Пример #4
0
 }
 $after_qty += $myrow["qty"];
 label_cell($type_name);
 label_cell(get_trans_view_str($myrow["type"], $myrow["trans_no"]));
 label_cell(get_trans_view_str($myrow["type"], $myrow["trans_no"], $myrow["reference"]));
 label_cell($trandate);
 $person = $myrow["person_id"];
 $gl_posting = "";
 if ($myrow["type"] == ST_CUSTDELIVERY || $myrow["type"] == ST_CUSTCREDIT) {
     $cust_row = get_customer_details_from_trans($myrow["type"], $myrow["trans_no"]);
     if (strlen($cust_row['name']) > 0) {
         $person = $cust_row['name'] . " (" . $cust_row['br_name'] . ")";
     }
 } elseif ($myrow["type"] == ST_SUPPRECEIVE || $myrow['type'] == ST_SUPPCREDIT) {
     // get the supplier name
     $supp_name = get_supplier_name($myrow["person_id"]);
     if (strlen($supp_name) > 0) {
         $person = $supp_name;
     }
 } elseif ($myrow["type"] == ST_LOCTRANSFER || $myrow["type"] == ST_INVADJUST) {
     // get the adjustment type
     $movement_type = get_movement_type($myrow["person_id"]);
     $person = $movement_type["name"];
 } elseif ($myrow["type"] == ST_WORKORDER || $myrow["type"] == ST_MANUISSUE || $myrow["type"] == ST_MANURECEIVE) {
     $person = "";
 }
 label_cell($person);
 label_cell($myrow["qty"] >= 0 ? $quantity_formatted : "", "nowrap align=right");
 label_cell($myrow["qty"] < 0 ? $quantity_formatted : "", "nowrap align=right");
 qty_cell($after_qty, false, $dec);
 end_row();
Пример #5
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();
}
Пример #6
0
function print_aged_supplier_analysis()
{
    global $comp_path, $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $to = $_REQUEST['PARAM_0'];
    $fromsupp = $_REQUEST['PARAM_1'];
    $currency = $_REQUEST['PARAM_2'];
    $summaryOnly = $_REQUEST['PARAM_3'];
    $graphics = $_REQUEST['PARAM_4'];
    $comments = $_REQUEST['PARAM_5'];
    if ($graphics) {
        include_once $path_to_root . "reporting/includes/class.graphic.inc";
        $pg = new graph();
    }
    if ($fromsupp == reserved_words::get_all_numeric()) {
        $from = tr('All');
    } else {
        $from = get_supplier_name($fromsupp);
    }
    $dec = user_price_dec();
    if ($summaryOnly == 1) {
        $summary = tr('Summary Only');
    } else {
        $summary = tr('Detailed Report');
    }
    if ($currency == reserved_words::get_all()) {
        $convert = true;
        $currency = tr('Balances in Home Currency');
    } else {
        $convert = false;
    }
    $PastDueDays1 = get_company_pref('past_due_days');
    $PastDueDays2 = 2 * $PastDueDays1;
    $nowdue = "1-" . $PastDueDays1 . " " . tr('Days');
    $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . tr('Days');
    $pastdue2 = tr('Over') . " " . $PastDueDays2 . " " . tr('Days');
    $cols = array(0, 100, 130, 190, 250, 320, 385, 450, 515);
    $headers = array(tr('Supplier'), '', '', tr('Current'), $nowdue, $pastdue1, $pastdue2, tr('Total Balance'));
    $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => tr('End Date'), 'from' => $to, 'to' => ''), 2 => array('text' => tr('Supplier'), 'from' => $from, 'to' => ''), 3 => array('text' => tr('Currency'), 'from' => $currency, 'to' => ''), 4 => array('text' => tr('Type'), 'from' => $summary, 'to' => ''));
    if ($convert) {
        $headers[2] = tr('currency');
    }
    $rep = new FrontReport(tr('Aged Supplier Analysis'), "AgedSupplierAnalysis.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $total = array();
    $total[0] = $total[1] = $total[2] = $total[3] = $total[4] = 0.0;
    $PastDueDays1 = get_company_pref('past_due_days');
    $PastDueDays2 = 2 * $PastDueDays1;
    $nowdue = "1-" . $PastDueDays1 . " " . tr('Days');
    $pastdue1 = $PastDueDays1 + 1 . "-" . $PastDueDays2 . " " . tr('Days');
    $pastdue2 = tr('Over') . " " . $PastDueDays2 . " " . tr('Days');
    $sql = "SELECT supplier_id, supp_name AS name, curr_code FROM suppliers ";
    if ($fromsupp != reserved_words::get_all_numeric()) {
        $sql .= "WHERE supplier_id={$fromsupp} ";
    }
    $sql .= "ORDER BY supp_name";
    $result = db_query($sql, "The suppliers could not be retrieved");
    while ($myrow = db_fetch($result)) {
        if (!$convert && $currency != $myrow['curr_code']) {
            continue;
        }
        $rep->fontSize += 2;
        $rep->TextCol(0, 3, $myrow['name']);
        if ($convert) {
            $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $to);
            $rep->TextCol(2, 4, $myrow['curr_code']);
        } else {
            $rate = 1.0;
        }
        $rep->fontSize -= 2;
        $supprec = get_supplier_details($myrow['supplier_id'], $to);
        foreach ($supprec as $i => $value) {
            $supprec[$i] *= $rate;
        }
        $total[0] += $supprec["Balance"] - $supprec["Due"];
        $total[1] += $supprec["Due"] - $supprec["Overdue1"];
        $total[2] += $supprec["Overdue1"] - $supprec["Overdue2"];
        $total[3] += $supprec["Overdue2"];
        $total[4] += $supprec["Balance"];
        $str = array(number_format2($supprec["Balance"] - $supprec["Due"], $dec), number_format2($supprec["Due"] - $supprec["Overdue1"], $dec), number_format2($supprec["Overdue1"] - $supprec["Overdue2"], $dec), number_format2($supprec["Overdue2"], $dec), number_format2($supprec["Balance"], $dec));
        for ($i = 0; $i < count($str); $i++) {
            $rep->TextCol($i + 3, $i + 4, $str[$i]);
        }
        $rep->NewLine(1, 2);
        if (!$summaryOnly) {
            $res = get_invoices($myrow['supplier_id'], $to);
            if (db_num_rows($res) == 0) {
                continue;
            }
            $rep->Line($rep->row + 4);
            while ($trans = db_fetch($res)) {
                $rep->NewLine(1, 2);
                $rep->TextCol(0, 1, $trans['type_name'], -2);
                $rep->TextCol(1, 2, $trans['reference'], -2);
                $rep->TextCol(2, 3, sql2date($trans['tran_date']), -2);
                foreach ($trans as $i => $value) {
                    $trans[$i] *= $rate;
                }
                $str = array(number_format2($trans["Balance"] - $trans["Due"], $dec), number_format2($trans["Due"] - $trans["Overdue1"], $dec), number_format2($trans["Overdue1"] - $trans["Overdue2"], $dec), number_format2($trans["Overdue2"], $dec), number_format2($trans["Balance"], $dec));
                for ($i = 0; $i < count($str); $i++) {
                    $rep->TextCol($i + 3, $i + 4, $str[$i]);
                }
            }
            $rep->Line($rep->row - 8);
            $rep->NewLine(2);
        }
    }
    if ($summaryOnly) {
        $rep->Line($rep->row + 4);
        $rep->NewLine();
    }
    $rep->fontSize += 2;
    $rep->TextCol(0, 3, tr('Grand Total'));
    $rep->fontSize -= 2;
    for ($i = 0; $i < count($total); $i++) {
        $rep->TextCol($i + 3, $i + 4, number_format2($total[$i], $dec));
        if ($graphics && $i < count($total) - 1) {
            $pg->y[$i] = abs($total[$i]);
        }
    }
    $rep->Line($rep->row - 8);
    if ($graphics) {
        global $decseps, $graph_skin;
        $pg->x = array(tr('Current'), $nowdue, $pastdue1, $pastdue2);
        $pg->title = $rep->title;
        $pg->axis_x = tr("Days");
        $pg->axis_y = tr("Amount");
        $pg->graphic_1 = $to;
        $pg->type = $graphics;
        $pg->skin = $graph_skin;
        $pg->built_in = false;
        $pg->fontfile = $path_to_root . "reporting/fonts/Vera.ttf";
        $pg->latin_notation = $decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != ".";
        $filename = $comp_path . '/' . user_company() . "/pdf_files/test.png";
        $pg->display($filename, true);
        $w = $pg->width / 1.5;
        $h = $pg->height / 1.5;
        $x = ($rep->pageWidth - $w) / 2;
        $rep->NewLine(2);
        if ($rep->row - $h < $rep->bottomMargin) {
            $rep->Header();
        }
        $rep->AddImage($filename, $x, $rep->row - $h, $w, $h);
    }
    $rep->End();
}
Пример #7
0
function print_supplier_balances()
{
    global $path_to_root, $systypes_array;
    $from = $_POST['PARAM_0'];
    $to = $_POST['PARAM_1'];
    $fromsupp = $_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 ($fromsupp == ALL_TEXT) {
        $supp = _('All');
    } else {
        $supp = get_supplier_name($fromsupp);
    }
    $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' => _('Supplier'), 'from' => $supp, 'to' => ''), 3 => array('text' => _('Currency'), 'from' => $currency, 'to' => ''), 4 => array('text' => _('Suppress Zeros'), 'from' => $nozeros, 'to' => ''));
    $rep = new FrontReport(_('Supplier Balances'), "SupplierBalances", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $total = array();
    $grandtotal = array(0, 0, 0, 0);
    $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 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['supplier_id'], $from);
        $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 = getTransactions($myrow['supplier_id'], $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(abs($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_SUPPINVOICE) {
                $rep->DateCol(3, 4, $trans['due_date'], true);
            }
            $item[0] = $item[1] = 0.0;
            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['TotalAmount'] > 0.0) {
                $item[3] = $item[0] - $item[2];
            } else {
                $item[3] = ($item[1] - $item[2]) * -1;
            }
            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);
            $total[$i] = 0.0;
        }
        $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();
}
Пример #8
0
function print_payment_report()
{
    global $path_to_root, $systypes_array;
    $to = $_POST['PARAM_0'];
    $fromsupp = $_POST['PARAM_1'];
    $currency = $_POST['PARAM_2'];
    $no_zeros = $_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 ($fromsupp == ALL_TEXT) {
        $from = _('All');
    } else {
        $from = get_supplier_name($fromsupp);
    }
    $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'), _('#'), _('Due Date'), '', '', '', _('Total'), _('Balance'));
    $aligns = array('left', 'left', 'left', 'left', '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' => _('Suppress Zeros'), 'from' => $nozeros, 'to' => ''));
    $rep = new FrontReport(_('Payment Report'), "PaymentReport", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $total = array();
    $grandtotal = array(0, 0);
    $sql = "SELECT supplier_id, supp_name AS name, curr_code, " . TB_PREF . "payment_terms.terms FROM " . TB_PREF . "suppliers, " . TB_PREF . "payment_terms\n\t\tWHERE ";
    if ($fromsupp != ALL_TEXT) {
        $sql .= "supplier_id=" . db_escape($fromsupp) . " AND ";
    }
    $sql .= "" . TB_PREF . "suppliers.payment_terms = " . TB_PREF . "payment_terms.terms_indicator\n\t\tORDER BY supp_name";
    $result = db_query($sql, "The customers could not be retrieved");
    while ($myrow = db_fetch($result)) {
        if (!$convert && $currency != $myrow['curr_code']) {
            continue;
        }
        $res = getTransactions($myrow['supplier_id'], $to);
        if ($no_zeros && db_num_rows($res) == 0) {
            continue;
        }
        $rep->fontSize += 2;
        $rep->TextCol(0, 6, $myrow['name'] . " - " . $myrow['terms']);
        if ($convert) {
            $rep->TextCol(6, 7, $myrow['curr_code']);
        }
        $rep->fontSize -= 2;
        $rep->NewLine(1, 2);
        if (db_num_rows($res) == 0) {
            continue;
        }
        $rep->Line($rep->row + 4);
        $total[0] = $total[1] = 0.0;
        while ($trans = db_fetch($res)) {
            if ($no_zeros && $trans['TranTotal'] == 0 && $trans['Balance'] == 0) {
                continue;
            }
            if ($convert) {
                $rate = $trans['rate'];
            } else {
                $rate = 1.0;
            }
            $rep->NewLine(1, 2);
            $rep->TextCol(0, 1, $systypes_array[$trans['type']]);
            $rep->TextCol(1, 2, $trans['supp_reference']);
            if ($trans['type'] == ST_SUPPINVOICE) {
                $rep->DateCol(2, 3, $trans['due_date'], true);
            } else {
                $rep->DateCol(2, 3, $trans['tran_date'], true);
            }
            if ($trans['type'] != ST_SUPPINVOICE) {
                $trans['TranTotal'] = -$trans['TranTotal'];
                $trans['Balance'] = -$trans['Balance'];
            }
            $item[0] = $trans['TranTotal'] * $rate;
            $rep->AmountCol(6, 7, $item[0], $dec);
            $item[1] = $trans['Balance'] * $rate;
            $rep->AmountCol(7, 8, $item[1], $dec);
            for ($i = 0; $i < 2; $i++) {
                $total[$i] += $item[$i];
                $grandtotal[$i] += $item[$i];
            }
        }
        $rep->Line($rep->row - 8);
        $rep->NewLine(2);
        $rep->TextCol(0, 3, _('Total'));
        for ($i = 0; $i < 2; $i++) {
            $rep->AmountCol($i + 6, $i + 7, $total[$i], $dec);
            $total[$i] = 0.0;
        }
        $rep->Line($rep->row - 4);
        $rep->NewLine(2);
    }
    $rep->fontSize += 2;
    $rep->TextCol(0, 3, _('Grand Total'));
    $rep->fontSize -= 2;
    for ($i = 0; $i < 2; $i++) {
        $rep->AmountCol($i + 6, $i + 7, $grandtotal[$i], $dec);
    }
    $rep->Line($rep->row - 4);
    $rep->NewLine();
    $rep->End();
}
Пример #9
0
function print_payment_report()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $to = $_REQUEST['PARAM_0'];
    $fromsupp = $_REQUEST['PARAM_1'];
    $currency = $_REQUEST['PARAM_2'];
    $comments = $_REQUEST['PARAM_3'];
    if ($fromsupp == reserved_words::get_all_numeric()) {
        $from = tr('All');
    } else {
        $from = get_supplier_name($fromsupp);
    }
    $dec = user_price_dec();
    if ($currency == reserved_words::get_all()) {
        $convert = true;
        $currency = tr('Balances in Home Currency');
    } else {
        $convert = false;
    }
    $cols = array(0, 100, 130, 190, 250, 320, 385, 450, 515);
    $headers = array(tr('Trans Type'), tr('#'), tr('Due Date'), '', '', '', tr('Total'), tr('Balance'));
    $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => tr('End Date'), 'from' => $to, 'to' => ''), 2 => array('text' => tr('Supplier'), 'from' => $from, 'to' => ''), 3 => array('text' => tr('Currency'), 'from' => $currency, 'to' => ''));
    $rep = new FrontReport(tr('Payment Report'), "PaymentReport.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $total = array();
    $grandtotal = array(0, 0);
    $sql = "SELECT supplier_id, supp_name AS name, curr_code, payment_terms.terms FROM suppliers, payment_terms\n\t\tWHERE ";
    if ($fromsupp != reserved_words::get_all_numeric()) {
        $sql .= "supplier_id={$fromsupp} AND ";
    }
    $sql .= "suppliers.payment_terms = payment_terms.terms_indicator\n\t\tORDER BY supp_name";
    $result = db_query($sql, "The customers could not be retrieved");
    while ($myrow = db_fetch($result)) {
        if (!$convert && $currency != $myrow['curr_code']) {
            continue;
        }
        $rep->fontSize += 2;
        $rep->TextCol(0, 6, $myrow['name'] . " - " . $myrow['terms']);
        if ($convert) {
            $rate = get_exchange_rate_from_home_currency($myrow['curr_code'], $to);
            $rep->TextCol(6, 7, $myrow['curr_code']);
        } else {
            $rate = 1.0;
        }
        $rep->fontSize -= 2;
        $rep->NewLine(1, 2);
        $res = getTransactions($myrow['supplier_id'], $to);
        if (db_num_rows($res) == 0) {
            continue;
        }
        $rep->Line($rep->row + 4);
        $total[0] = $total[1] = 0.0;
        while ($trans = db_fetch($res)) {
            $rep->NewLine(1, 2);
            $rep->TextCol(0, 1, $trans['type_name']);
            $rep->TextCol(1, 2, $trans['supp_reference']);
            $rep->TextCol(2, 3, sql2date($trans['due_date']));
            $item[0] = Abs($trans['TranTotal']) * $rate;
            $rep->TextCol(6, 7, number_format2($item[0], $dec));
            $item[1] = $trans['Balance'] * $rate;
            $rep->TextCol(7, 8, number_format2($item[1], $dec));
            for ($i = 0; $i < 2; $i++) {
                $total[$i] += $item[$i];
                $grandtotal[$i] += $item[$i];
            }
        }
        $rep->Line($rep->row - 8);
        $rep->NewLine(2);
        $rep->TextCol(0, 3, tr('Total'));
        for ($i = 0; $i < 2; $i++) {
            $rep->TextCol($i + 6, $i + 7, number_format2($total[$i], $dec));
            $total[$i] = 0.0;
        }
        $rep->Line($rep->row - 4);
        $rep->NewLine(2);
    }
    $rep->fontSize += 2;
    $rep->TextCol(0, 3, tr('Grand Total'));
    $rep->fontSize -= 2;
    for ($i = 0; $i < 2; $i++) {
        $rep->TextCol($i + 6, $i + 7, number_format2($grandtotal[$i], $dec));
    }
    $rep->Line($rep->row - 4);
    $rep->End();
}
Пример #10
0
function print_outstanding_GRN()
{
    global $path_to_root;
    include_once $path_to_root . "reporting/includes/pdf_report.inc";
    $fromsupp = $_REQUEST['PARAM_0'];
    $comments = $_REQUEST['PARAM_1'];
    if ($fromsupp == reserved_words::get_all_numeric()) {
        $from = tr('All');
    } else {
        $from = get_supplier_name($fromsupp);
    }
    $dec = user_price_dec();
    $cols = array(0, 40, 80, 190, 250, 320, 385, 450, 515);
    $headers = array(tr('GRN'), tr('Order'), tr('Item') . '/' . tr('Description'), tr('Qty Recd'), tr('qty Inv'), tr('Balance'), tr('Std Cost'), tr('Value'));
    $aligns = array('left', 'left', 'left', 'right', 'right', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => tr('Supplier'), 'from' => $from, 'to' => ''));
    $rep = new FrontReport(tr('Outstanding GRNs Report'), "OutstandingGRN.pdf", user_pagesize());
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->Header();
    $Tot_Val = 0;
    $Supplier = '';
    $SuppTot_Val = 0;
    $res = getTransactions($fromsupp);
    while ($GRNs = db_fetch($res)) {
        if ($Supplier != $GRNs['supplier_id']) {
            if ($Supplier != '') {
                $rep->NewLine(2);
                $rep->TextCol(0, 7, tr('Total'));
                $rep->TextCol(7, 8, number_format2($SuppTot_Val, $dec));
                $rep->Line($rep->row - 2);
                $rep->NewLine(3);
                $SuppTot_Val = 0;
            }
            $rep->TextCol(0, 6, $GRNs['supp_name']);
            $Supplier = $GRNs['supplier_id'];
        }
        $rep->NewLine();
        $rep->TextCol(0, 1, $GRNs['id']);
        $rep->TextCol(1, 2, $GRNs['order_no']);
        $rep->TextCol(2, 3, $GRNs['item_code'] . '-' . $GRNs['description']);
        $rep->TextCol(3, 4, number_format2($GRNs['qty_recd'], $dec));
        $rep->TextCol(4, 5, number_format2($GRNs['quantity_inv'], $dec));
        $QtyOstg = $GRNs['qty_recd'] - $GRNs['quantity_inv'];
        $Value = ($GRNs['qty_recd'] - $GRNs['quantity_inv']) * $GRNs['std_cost_unit'];
        $rep->TextCol(5, 6, number_format2($QtyOstg, $dec));
        $rep->TextCol(6, 7, number_format2($GRNs['std_cost_unit'], $dec));
        $rep->TextCol(7, 8, number_format2($Value, $dec));
        $Tot_Val += $Value;
        $SuppTot_Val += $Value;
        $rep->NewLine(0, 1);
    }
    if ($Supplier != '') {
        $rep->NewLine();
        $rep->TextCol(0, 7, tr('Total'));
        $rep->TextCol(7, 8, number_format2($SuppTot_Val, $dec));
        $rep->Line($rep->row - 2);
        $rep->NewLine(3);
        $SuppTot_Val = 0;
    }
    $rep->NewLine(2);
    $rep->TextCol(0, 7, tr('Grand Total'));
    $rep->TextCol(7, 8, number_format2($Tot_Val, $dec));
    $rep->Line($rep->row - 2);
    $rep->End();
}