Beispiel #1
0
function print_po()
{
    global $path_to_root, $show_po_item_codes;
    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();
    $cols = array(4, 60, 225, 300, 340, 385, 450, 515);
    // $headers in doctext.inc
    $aligns = array('left', 'left', 'left', 'right', 'left', 'right', 'right');
    $params = array('comments' => $comments);
    $cur = get_company_Pref('curr_default');
    if ($email == 0) {
        $rep = new FrontReport(_('PURCHASE ORDER'), "PurchaseOrderBulk", user_pagesize(), 9, $orientation);
    }
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    for ($i = $from; $i <= $to; $i++) {
        $myrow = get_po($i);
        $baccount = get_default_bank_account($myrow['curr_code']);
        $params['bankaccount'] = $baccount['id'];
        if ($email == 1) {
            $rep = new FrontReport("", "", user_pagesize(), 9, $orientation);
            $rep->title = _('PURCHASE ORDER');
            $rep->filename = "PurchaseOrder" . $i . ".pdf";
        }
        $rep->SetHeaderType('Header2');
        $rep->currency = $cur;
        $rep->Font();
        $rep->Info($params, $cols, null, $aligns);
        $contacts = get_supplier_contacts($myrow['supplier_id'], 'order');
        $rep->SetCommonData($myrow, null, $myrow, $baccount, ST_PURCHORDER, $contacts);
        $rep->NewPage();
        $result = get_po_details($i);
        $SubTotal = 0;
        $items = $prices = array();
        while ($myrow2 = db_fetch($result)) {
            $data = get_purchase_data($myrow['supplier_id'], $myrow2['item_code']);
            if ($data !== false) {
                if ($data['supplier_description'] != "") {
                    $myrow2['description'] = $data['supplier_description'];
                }
                if ($data['suppliers_uom'] != "") {
                    $myrow2['units'] = $data['suppliers_uom'];
                }
                if ($data['conversion_factor'] != 1) {
                    $myrow2['unit_price'] = round2($myrow2['unit_price'] * $data['conversion_factor'], user_price_dec());
                    $myrow2['quantity_ordered'] = round2($myrow2['quantity_ordered'] / $data['conversion_factor'], user_qty_dec());
                }
            }
            $Net = round2($myrow2["unit_price"] * $myrow2["quantity_ordered"], user_price_dec());
            $prices[] = $Net;
            $items[] = $myrow2['item_code'];
            $SubTotal += $Net;
            $dec2 = 0;
            $DisplayPrice = price_decimal_format($myrow2["unit_price"], $dec2);
            $DisplayQty = number_format2($myrow2["quantity_ordered"], get_qty_dec($myrow2['item_code']));
            $DisplayNet = number_format2($Net, $dec);
            if ($show_po_item_codes) {
                $rep->TextCol(0, 1, $myrow2['item_code'], -2);
                $rep->TextCol(1, 2, $myrow2['description'], -2);
            } else {
                $rep->TextCol(0, 2, $myrow2['description'], -2);
            }
            $rep->TextCol(2, 3, sql2date($myrow2['delivery_date']), -2);
            $rep->TextCol(3, 4, $DisplayQty, -2);
            $rep->TextCol(4, 5, $myrow2['units'], -2);
            $rep->TextCol(5, 6, $DisplayPrice, -2);
            $rep->TextCol(6, 7, $DisplayNet, -2);
            $rep->NewLine(1);
            if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) {
                $rep->NewPage();
            }
        }
        if ($myrow['comments'] != "") {
            $rep->NewLine();
            $rep->TextColLines(1, 5, $myrow['comments'], -2);
        }
        $DisplaySubTot = number_format2($SubTotal, $dec);
        $rep->row = $rep->bottomMargin + 15 * $rep->lineHeight;
        $doctype = ST_PURCHORDER;
        $rep->TextCol(3, 6, _("Sub-total"), -2);
        $rep->TextCol(6, 7, $DisplaySubTot, -2);
        $rep->NewLine();
        $tax_items = get_tax_for_items($items, $prices, 0, $myrow['tax_group_id'], $myrow['tax_included'], null);
        $first = true;
        foreach ($tax_items as $tax_item) {
            if ($tax_item['Value'] == 0) {
                continue;
            }
            $DisplayTax = number_format2($tax_item['Value'], $dec);
            $tax_type_name = $tax_item['tax_type_name'];
            if ($myrow['tax_included']) {
                if (isset($alternative_tax_include_on_docs) && $alternative_tax_include_on_docs == 1) {
                    if ($first) {
                        $rep->TextCol(3, 6, _("Total Tax Excluded"), -2);
                        $rep->TextCol(6, 7, number_format2($sign * $tax_item['net_amount'], $dec), -2);
                        $rep->NewLine();
                    }
                    $rep->TextCol(3, 6, $tax_type_name, -2);
                    $rep->TextCol(6, 7, $DisplayTax, -2);
                    $first = false;
                } else {
                    $rep->TextCol(3, 7, _("Included") . " " . $tax_type_name . _("Amount") . ": " . $DisplayTax, -2);
                }
            } else {
                $SubTotal += $tax_item['Value'];
                $rep->TextCol(3, 6, $tax_type_name, -2);
                $rep->TextCol(6, 7, $DisplayTax, -2);
            }
            $rep->NewLine();
        }
        $rep->NewLine();
        $DisplayTotal = number_format2($SubTotal, $dec);
        $rep->Font('bold');
        $rep->TextCol(3, 6, _("TOTAL PO"), -2);
        $rep->TextCol(6, 7, $DisplayTotal, -2);
        $words = price_in_words($SubTotal, ST_PURCHORDER);
        if ($words != "") {
            $rep->NewLine(1);
            $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, -2);
        }
        $rep->Font();
        if ($email == 1) {
            $myrow['DebtorName'] = $myrow['supp_name'];
            if ($myrow['reference'] == "") {
                $myrow['reference'] = $myrow['order_no'];
            }
            $rep->End($email);
        }
    }
    if ($email == 0) {
        $rep->End();
    }
}
                $j = 1;
                table_header($th);
            }
            //end of page full new headings
        }
        //end of while loop
        end_table();
    }
    div_end();
}
//-----------------------------------------------------------------------------------------------
$dec2 = 6;
if ($Mode == 'Edit') {
    $myrow = get_item_purchasing_data($selected_id, $_POST['stock_id']);
    $supp_name = $myrow["supp_name"];
    $_POST['price'] = price_decimal_format($myrow["price"], $dec2);
    $_POST['suppliers_uom'] = $myrow["suppliers_uom"];
    $_POST['supplier_description'] = $myrow["supplier_description"];
    $_POST['conversion_factor'] = maxprec_format($myrow["conversion_factor"]);
}
br();
hidden('selected_id', $selected_id);
if (@$_GET['popup']) {
    hidden('_tabs_sel', get_post('_tabs_sel'));
    hidden('popup', @$_GET['popup']);
}
start_table(TABLESTYLE2);
if ($Mode == 'Edit') {
    hidden('supplier_id');
    label_row(_("Supplier:"), $supp_name);
} else {
Beispiel #3
0
function print_inventory_valuation_report()
{
    global $path_to_root;
    $date = $_POST['PARAM_0'];
    $category = $_POST['PARAM_1'];
    $location = $_POST['PARAM_2'];
    $detail = $_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";
    }
    $detail = !$detail;
    $dec = user_price_dec();
    $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, 75, 225, 250, 350, 450, 515);
    $headers = array(_('Category'), '', _('UOM'), _('Quantity'), _('Unit Cost'), _('Value'));
    $aligns = array('left', 'left', 'left', 'right', 'right', 'right');
    $params = array(0 => $comments, 1 => array('text' => _('End Date'), 'from' => $date, 'to' => ''), 2 => array('text' => _('Category'), 'from' => $cat, 'to' => ''), 3 => array('text' => _('Location'), 'from' => $loc, 'to' => ''));
    $rep = new FrontReport(_('Inventory Valuation Report'), "InventoryValReport", user_pagesize(), 9, $orientation);
    if ($orientation == 'L') {
        recalculate_cols($cols);
    }
    $rep->Font();
    $rep->Info($params, $cols, $headers, $aligns);
    $rep->NewPage();
    $res = getTransactions($category, $location, $date);
    $total = $grandtotal = 0.0;
    $catt = '';
    while ($trans = db_fetch($res)) {
        if ($catt != $trans['cat_description']) {
            if ($catt != '') {
                if ($detail) {
                    $rep->NewLine(2, 3);
                    $rep->TextCol(0, 4, _('Total'));
                }
                $rep->AmountCol(5, 6, $total, $dec);
                if ($detail) {
                    $rep->Line($rep->row - 2);
                    $rep->NewLine();
                }
                $rep->NewLine();
                $total = 0.0;
            }
            $rep->TextCol(0, 1, $trans['category_id']);
            $rep->TextCol(1, 2, $trans['cat_description']);
            $catt = $trans['cat_description'];
            if ($detail) {
                $rep->NewLine();
            }
        }
        if ($detail) {
            $rep->NewLine();
            $rep->fontSize -= 2;
            $rep->TextCol(0, 1, $trans['stock_id']);
            $rep->TextCol(1, 2, $trans['description'] . ($trans['inactive'] == 1 ? " (" . _("Inactive") . ")" : ""), -1);
            $rep->TextCol(2, 3, $trans['units']);
            $rep->AmountCol(3, 4, $trans['QtyOnHand'], get_qty_dec($trans['stock_id']));
            $dec2 = 0;
            price_decimal_format($trans['UnitCost'], $dec2);
            $rep->AmountCol(4, 5, $trans['UnitCost'], $dec2);
            $rep->AmountCol(5, 6, $trans['ItemTotal'], $dec);
            $rep->fontSize += 2;
        }
        $total += $trans['ItemTotal'];
        $grandtotal += $trans['ItemTotal'];
    }
    if ($detail) {
        $rep->NewLine(2, 3);
        $rep->TextCol(0, 4, _('Total'));
    }
    $rep->Amountcol(5, 6, $total, $dec);
    if ($detail) {
        $rep->Line($rep->row - 2);
        $rep->NewLine();
    }
    $rep->NewLine(2, 1);
    $rep->TextCol(0, 4, _('Grand Total'));
    $rep->AmountCol(5, 6, $grandtotal, $dec);
    $rep->Line($rep->row - 4);
    $rep->NewLine();
    $rep->End();
}
Beispiel #4
0
if (!@$_GET['popup']) {
    echo "<center>" . _("Item:") . "&nbsp;";
    //echo stock_costable_items_list('stock_id', $_POST['stock_id'], false, true);
    echo stock_items_list('stock_id', $_POST['stock_id'], false, true);
    echo "</center><hr>";
} else {
    br(2);
}
set_global_stock_item($_POST['stock_id']);
$myrow = get_item($_POST['stock_id']);
div_start('cost_table');
start_table(TABLESTYLE2);
$dec1 = $dec2 = $dec3 = 0;
$_POST['material_cost'] = price_decimal_format($myrow["material_cost"], $dec1);
$_POST['labour_cost'] = price_decimal_format($myrow["labour_cost"], $dec2);
$_POST['overhead_cost'] = price_decimal_format($myrow["overhead_cost"], $dec3);
amount_row(_("Standard Material Cost Per Unit"), "material_cost", null, "class='tableheader2'", null, $dec1);
if (@$_GET['popup']) {
    hidden('_tabs_sel', get_post('_tabs_sel'));
    hidden('popup', @$_GET['popup']);
}
if ($myrow["mb_flag"] == 'M') {
    amount_row(_("Standard Labour Cost Per Unit"), "labour_cost", null, "class='tableheader2'", null, $dec2);
    amount_row(_("Standard Overhead Cost Per Unit"), "overhead_cost", null, "class='tableheader2'", null, $dec3);
} else {
    hidden("labour_cost", 0);
    hidden("overhead_cost", 0);
}
end_table(1);
div_end();
submit_center('UpdateData', _("Update"), true, false, 'default');
 function amount_decimal_cell($label, $params = "", $id = null)
 {
     $dec = 0;
     label_cell(price_decimal_format($label, $dec), "nowrap align=right " . $params, $id);
 }