function display_wo_issue_details($issue_no) { $result = get_work_order_issue_details($issue_no); if (db_num_rows($result) == 0) { display_note(_("There are no items for this issue.")); } else { start_table(TABLESTYLE); $th = array(_("Component"), _("Quantity"), _("Units")); table_header($th); $j = 1; $k = 0; //row colour counter $total_cost = 0; while ($myrow = db_fetch($result)) { alt_table_row_color($k); label_cell($myrow["stock_id"] . " - " . $myrow["description"]); qty_cell($myrow["qty_issued"], false, get_qty_dec($myrow["stock_id"])); label_cell($myrow["units"]); end_row(); $j++; if ($j == 12) { $j = 1; table_header($th); } //end of page full new headings if } //end of while end_table(); } }
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(); }
function display_po_receive_items() { div_start('grn_items'); start_table(TABLESTYLE, "colspan=7 width='90%'"); $th = array(_("Item Code"), _("Description"), _("Ordered"), _("Units"), _("Received"), _("Outstanding"), _("This Delivery"), _("Price"), _("Total")); table_header($th); /*show the line items on the order with the quantity being received for modification */ $total = 0; $k = 0; //row colour counter if (count($_SESSION['PO']->line_items) > 0) { foreach ($_SESSION['PO']->line_items as $ln_itm) { alt_table_row_color($k); $qty_outstanding = $ln_itm->quantity - $ln_itm->qty_received; if (!isset($_POST['Update']) && !isset($_POST['ProcessGoodsReceived']) && $ln_itm->receive_qty == 0) { //If no quantites yet input default the balance to be received $ln_itm->receive_qty = $qty_outstanding; } $line_total = $ln_itm->receive_qty * $ln_itm->price; $total += $line_total; label_cell($ln_itm->stock_id); if ($qty_outstanding > 0) { text_cells(null, $ln_itm->stock_id . "Desc", $ln_itm->item_description, 30, 50); } else { label_cell($ln_itm->item_description); } $dec = get_qty_dec($ln_itm->stock_id); qty_cell($ln_itm->quantity, false, $dec); label_cell($ln_itm->units); qty_cell($ln_itm->qty_received, false, $dec); qty_cell($qty_outstanding, false, $dec); if ($qty_outstanding > 0) { qty_cells(null, $ln_itm->line_no, number_format2($ln_itm->receive_qty, $dec), "align=right", null, $dec); } else { label_cell(number_format2($ln_itm->receive_qty, $dec), "align=right"); } amount_decimal_cell($ln_itm->price); amount_cell($line_total); end_row(); } } $colspan = count($th) - 1; $display_sub_total = price_format($total); label_row(_("Sub-total"), $display_sub_total, "colspan={$colspan} align=right", "align=right"); $taxes = $_SESSION['PO']->get_taxes(input_num('freight_cost'), true); $tax_total = display_edit_tax_items($taxes, $colspan, $_SESSION['PO']->tax_included); $display_total = price_format($total + input_num('freight_cost') + $tax_total); start_row(); label_cells(_("Amount Total"), $display_total, "colspan={$colspan} align='right'", "align='right'"); end_row(); end_table(); div_end(); }
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(); }
function display_wo_production($prod_id) { $myrow = get_work_order_produce($prod_id); br(1); start_table(TABLESTYLE); $th = array(_("Production #"), _("Reference"), _("For Work Order #"), _("Item"), _("Quantity Manufactured"), _("Date")); table_header($th); start_row(); label_cell($myrow["id"]); label_cell($myrow["reference"]); label_cell(get_trans_view_str(ST_WORKORDER, $myrow["workorder_id"])); label_cell($myrow["stock_id"] . " - " . $myrow["StockDescription"]); qty_cell($myrow["quantity"], false, get_qty_dec($myrow["stock_id"])); label_cell(sql2date($myrow["date_"])); end_row(); comments_display_row(ST_MANURECEIVE, $prod_id); end_table(1); is_voided_display(ST_MANURECEIVE, $prod_id, _("This production has been voided.")); }
function display_kit_items($selected_kit) { $result = get_item_kit($selected_kit); div_start('bom'); start_table(TABLESTYLE, "width='60%'"); $th = array(_("Stock Item"), _("Description"), _("Quantity"), _("Units"), '', ''); table_header($th); $k = 0; while ($myrow = db_fetch($result)) { alt_table_row_color($k); label_cell($myrow["stock_id"]); label_cell($myrow["comp_name"]); qty_cell($myrow["quantity"], false, $myrow["units"] == '' ? 0 : get_qty_dec($myrow["comp_name"])); label_cell($myrow["units"] == '' ? _('kit') : $myrow["units"]); edit_button_cell("Edit" . $myrow['id'], _("Edit")); delete_button_cell("Delete" . $myrow['id'], _("Delete")); end_row(); } //END WHILE LIST LOOP end_table(); div_end(); }
function display_bom_items($selected_parent) { $result = get_bom($selected_parent); div_start('bom'); start_table(TABLESTYLE, "width=60%"); $th = array(_("Code"), _("Description"), _("Location"), _("Work Centre"), _("Quantity"), _("Units"), '', ''); table_header($th); $k = 0; while ($myrow = db_fetch($result)) { alt_table_row_color($k); label_cell($myrow["component"]); label_cell($myrow["description"]); label_cell($myrow["location_name"]); label_cell($myrow["WorkCentreDescription"]); qty_cell($myrow["quantity"], false, get_qty_dec($myrow["component"])); label_cell($myrow["units"]); edit_button_cell("Edit" . $myrow['id'], _("Edit")); delete_button_cell("Delete" . $myrow['id'], _("Delete")); end_row(); } //END WHILE LIST LOOP end_table(); div_end(); }
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(); } }
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(); }
start_row(); label_cells(_("Item"), $from_trans['stock_id'] . " - " . $from_trans['description'], "class='tableheader2'"); label_cells(_("From Location"), $from_trans['location_name'], "class='tableheader2'"); label_cells(_("To Location"), $to_trans['location_name'], "class='tableheader2'"); end_row(); start_row(); label_cells(_("Reference"), $from_trans['reference'], "class='tableheader2'"); $adjustment_type = get_movement_type($from_trans['person_id']); label_cells(_("Adjustment Type"), $adjustment_type['name'], "class='tableheader2'"); label_cells(_("Date"), sql2date($from_trans['tran_date']), "class='tableheader2'"); end_row(); comments_display_row(ST_LOCTRANSFER, $trans_no); end_table(2); start_table(TABLESTYLE, "width=90%"); $th = array(_("Item"), _("Description"), _("Quantity"), _("Units")); table_header($th); $transfer_items = get_stock_moves(ST_LOCTRANSFER, $trans_no); $k = 0; while ($item = db_fetch($transfer_items)) { if ($item['loc_code'] == $to_trans['loc_code']) { alt_table_row_color($k); label_cell($item['stock_id']); label_cell($item['description']); qty_cell($item['qty'], false, get_qty_dec($item['stock_id'])); label_cell($item['units']); end_row(); } } end_table(1); is_voided_display(ST_LOCTRANSFER, $trans_no, _("This transfer has been voided.")); end_page(true, false, false, ST_LOCTRANSFER, $trans_no);
$close_wo = 1; } // if unassembling, negate quantity if ($_POST['ProductionType'] == 0) { $_POST['quantity'] = -$_POST['quantity']; } $id = work_order_produce($_POST['selected_id'], $_POST['ref'], input_num('quantity'), $_POST['date_'], $_POST['memo_'], $close_wo); meta_forward($_SERVER['PHP_SELF'], "AddedID=" . $_POST['selected_id'] . "&date=" . $_POST['date_']); } //------------------------------------------------------------------------------------- display_wo_details($_POST['selected_id']); //------------------------------------------------------------------------------------- start_form(); hidden('selected_id', $_POST['selected_id']); //hidden('WOReqQuantity', $_POST['WOReqQuantity']); $dec = get_qty_dec($wo_details["stock_id"]); if (!isset($_POST['quantity']) || $_POST['quantity'] == '') { $_POST['quantity'] = qty_format(max($wo_details["units_reqd"] - $wo_details["units_issued"], 0), $wo_details["stock_id"], $dec); } start_table(TABLESTYLE2); br(); ref_row(_("Reference:"), 'ref', '', $Refs->get_next(29)); if (!isset($_POST['ProductionType'])) { $_POST['ProductionType'] = 1; } yesno_list_row(_("Type:"), 'ProductionType', $_POST['ProductionType'], _("Produce Finished Items"), _("Return Items to Work Order")); small_qty_row(_("Quantity:"), 'quantity', null, null, null, $dec); date_row(_("Date:"), 'date_'); textarea_row(_("Memo:"), 'memo_', null, 40, 3); end_table(1); submit_center_first('Process', _("Process"), '', 'default');
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(); }
$sub_total = 0; while ($myrow2 = db_fetch($result)) { if ($myrow2["quantity"] == 0) { continue; } alt_table_row_color($k); $value = round2((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"], user_price_dec()); $sub_total += $value; if ($myrow2["discount_percent"] == 0) { $display_discount = ""; } else { $display_discount = percent_format($myrow2["discount_percent"] * 100) . "%"; } label_cell($myrow2["stock_id"]); label_cell($myrow2["StockDescription"]); qty_cell($myrow2["quantity"], false, get_qty_dec($myrow2["stock_id"])); label_cell($myrow2["units"], "align=right"); amount_cell($myrow2["unit_price"]); label_cell($display_discount, "nowrap align=right"); amount_cell($value); end_row(); } //end while there are line items to print out $display_sub_tot = price_format($sub_total); label_row(_("Sub-total"), $display_sub_tot, "colspan=6 align=right", "nowrap align=right width=15%"); } else { display_note(_("There are no line items on this invoice."), 1, 2); } $display_freight = price_format($myrow["ov_freight"]); /*Print out the invoice text entered */ label_row(_("Shipping"), $display_freight, "colspan=6 align=right", "nowrap align=right");
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(); }
if ($q_class === 'skip') { continue; } if (is_array($q_class)) { list($ln_itm->qty_dispatched, $row_classes) = $q_class; $has_marked = true; } } alt_table_row_color($k, $row_classes); view_stock_status_cell($ln_itm->stock_id); if ($ln_itm->descr_editable) { text_cells(null, 'Line' . $line . 'Desc', $ln_itm->item_description, 30, 50); } else { label_cell($ln_itm->item_description); } $dec = get_qty_dec($ln_itm->stock_id); qty_cell($ln_itm->quantity, false, $dec); label_cell($ln_itm->units); qty_cell($ln_itm->qty_done, false, $dec); if (isset($_POST['clear_quantity'])) { $ln_itm->qty_dispatched = 0; } $_POST['Line' . $line] = $ln_itm->qty_dispatched; /// clear post so value displayed in the fiel is the 'new' quantity small_qty_cells(null, 'Line' . $line, qty_format($ln_itm->qty_dispatched, $ln_itm->stock_id, $dec), null, null, $dec); $display_discount_percent = percent_format($ln_itm->discount_percent * 100) . "%"; $line_total = $ln_itm->qty_dispatched * $ln_itm->price * (1 - $ln_itm->discount_percent); amount_cell($ln_itm->price); label_cell($ln_itm->tax_type_name); label_cell($display_discount_percent, "nowrap align=right"); amount_cell($line_total);
$k = 0; $header_shown = false; while ($adjustment = db_fetch($adjustment_items)) { if (!$header_shown) { $adjustment_type = get_movement_type($adjustment['person_id']); start_table(TABLESTYLE2, "width='90%'"); start_row(); label_cells(_("At Location"), $adjustment['location_name'], "class='tableheader2'"); label_cells(_("Reference"), $adjustment['reference'], "class='tableheader2'", "colspan=6"); label_cells(_("Date"), sql2date($adjustment['tran_date']), "class='tableheader2'"); label_cells(_("Adjustment Type"), $adjustment_type['name'], "class='tableheader2'"); end_row(); comments_display_row(ST_INVADJUST, $trans_no); end_table(); $header_shown = true; echo "<br>"; start_table(TABLESTYLE, "width='90%'"); $th = array(_("Item"), _("Description"), _("Quantity"), _("Units"), _("Unit Cost")); table_header($th); } alt_table_row_color($k); label_cell($adjustment['stock_id']); label_cell($adjustment['description']); qty_cell($adjustment['qty'], false, get_qty_dec($adjustment['stock_id'])); label_cell($adjustment['units']); amount_decimal_cell($adjustment['standard_cost']); end_row(); } end_table(1); is_voided_display(ST_INVADJUST, $trans_no, _("This adjustment has been voided.")); end_page(true, false, false, ST_INVADJUST, $trans_no);
function display_credit_items() { start_form(); hidden('cart_id'); start_table(TABLESTYLE2, "width=80%", 5); echo "<tr><td>"; // outer table start_table(TABLESTYLE, "width=100%"); start_row(); label_cells(_("Customer"), $_SESSION['Items']->customer_name, "class='tableheader2'"); label_cells(_("Branch"), get_branch_name($_SESSION['Items']->Branch), "class='tableheader2'"); label_cells(_("Currency"), $_SESSION['Items']->customer_currency, "class='tableheader2'"); end_row(); start_row(); // if (!isset($_POST['ref'])) // $_POST['ref'] = $Refs->get_next(11); if ($_SESSION['Items']->trans_no == 0) { ref_cells(_("Reference"), 'ref', '', null, "class='tableheader2'"); } else { label_cells(_("Reference"), $_SESSION['Items']->reference, "class='tableheader2'"); } label_cells(_("Crediting Invoice"), get_customer_trans_view_str(ST_SALESINVOICE, array_keys($_SESSION['Items']->src_docs)), "class='tableheader2'"); if (!isset($_POST['ShipperID'])) { $_POST['ShipperID'] = $_SESSION['Items']->ship_via; } label_cell(_("Shipping Company"), "class='tableheader2'"); shippers_list_cells(null, 'ShipperID', $_POST['ShipperID']); // if (!isset($_POST['sales_type_id'])) // $_POST['sales_type_id'] = $_SESSION['Items']->sales_type; // label_cell(_("Sales Type"), "class='tableheader2'"); // sales_types_list_cells(null, 'sales_type_id', $_POST['sales_type_id']); end_row(); end_table(); echo "</td><td>"; // outer table start_table(TABLESTYLE, "width=100%"); if ($_SESSION['Items']->custom_num != '') { text_row(_("Credit Memo No."), 'custom_num', $_SESSION['Items']->custom_num, null, "class='tableheader2'"); } else { text_row(_("Credit Memo No."), 'custom_num', '', null, "class='tableheader2'"); } //moodlearning label_row(_("Invoice Date"), $_SESSION['Items']->src_date, "class='tableheader2'"); date_row(_("Credit Note Date"), 'CreditDate', '', $_SESSION['Items']->trans_no == 0, 0, 0, 0, "class='tableheader2'"); end_table(); echo "</td></tr>"; end_table(1); // outer table div_start('credit_items'); start_table(TABLESTYLE, "width=80%"); $th = array(_("Item Code"), _("Item Description"), _("Invoiced Quantity"), _("Units"), _("Credited"), _("Credit Quantity"), _("Price"), _("Discount %"), _("Total")); //Karen edited Credited table_header($th); $k = 0; //row colour counter foreach ($_SESSION['Items']->line_items as $line_no => $ln_itm) { if ($ln_itm->quantity == $ln_itm->qty_done) { continue; // this line was fully credited/removed } alt_table_row_color($k); // view_stock_status_cell($ln_itm->stock_id); alternative view label_cell($ln_itm->stock_id); text_cells(null, 'Line' . $line_no . 'Desc', $ln_itm->item_description, 30, 50); $dec = get_qty_dec($ln_itm->stock_id); qty_cell($ln_itm->quantity, false, $dec); label_cell($ln_itm->units); label_cell($ln_itm->qty_done); //Karen edited amount_cells(null, 'Line' . $line_no, number_format2($ln_itm->qty_dispatched, $dec), null, null, $dec); $line_total = $ln_itm->qty_dispatched * $ln_itm->price * (1 - $ln_itm->discount_percent); amount_cell($ln_itm->price); percent_cell($ln_itm->discount_percent * 100); amount_cell($line_total); end_row(); } if (!check_num('ChargeFreightCost')) { $_POST['ChargeFreightCost'] = price_format($_SESSION['Items']->freight_cost); } $colspan = 8; //Karen edited 7 start_row(); label_cell(_("Credit Shipping Cost"), "colspan={$colspan} align=right"); small_amount_cells(null, "ChargeFreightCost", price_format(get_post('ChargeFreightCost', 0))); end_row(); /*moodlearning*/ start_row(); label_cell(_("Bulk Discount"), "colspan={$colspan} align=right"); small_amount_cells(null, "bulk_dis", $_SESSION['Items']->bulk_discount); end_row(); /* */ $inv_items_total = $_SESSION['Items']->get_items_total_dispatch(); $discount = input_num('bulk_dis') / 100; $display_sub_total = price_format($inv_items_total + input_num($_POST['ChargeFreightCost'])); label_row(_("Sub-total"), $display_sub_total, "colspan={$colspan} align=right", "align=right"); $taxes = $_SESSION['Items']->get_taxes(input_num($_POST['ChargeFreightCost'])); $tax_total = display_edit_tax_items($taxes, $colspan, $_SESSION['Items']->tax_included); /*moodlearning*/ $total = $inv_items_total + input_num('ChargeFreightCost') + $tax_total; $tot = price_format($total - $total * $discount); /* */ $display_total = price_format($inv_items_total + input_num('ChargeFreightCost') + $tax_total); label_row(_("Credit Note Total"), $tot, "colspan={$colspan} align=right", "align=right"); //moodlearning edit $tot end_table(); div_end(); }
function check_item_data() { global $SysPrefs, $allow_negative_prices; $is_inventory_item = is_inventory_item(get_post('stock_id')); if (!get_post('stock_id_text', true)) { display_error(_("Item description cannot be empty.")); set_focus('stock_id_edit'); return false; } elseif (!check_num('qty', 0) || !check_num('Disc', 0, 100)) { display_error(_("The item could not be updated because you are attempting to set the quantity ordered to less than 0, or the discount percent to more than 100.")); set_focus('qty'); return false; } elseif (!check_num('price', 0) && (!$allow_negative_prices || $is_inventory_item)) { display_error(_("Price for inventory item must be entered and can not be less than 0")); set_focus('price'); return false; } elseif (isset($_POST['LineNo']) && isset($_SESSION['Items']->line_items[$_POST['LineNo']]) && !check_num('qty', $_SESSION['Items']->line_items[$_POST['LineNo']]->qty_done)) { set_focus('qty'); display_error(_("You attempting to make the quantity ordered a quantity less than has already been delivered. The quantity delivered cannot be modified retrospectively.")); return false; } elseif ($is_inventory_item && $_SESSION['Items']->trans_type != ST_SALESORDER && $_SESSION['Items']->trans_type != ST_SALESQUOTE && !$SysPrefs->allow_negative_stock()) { $qoh = get_qoh_on_date($_POST['stock_id'], $_POST['Location'], $_POST['OrderDate']); if (input_num('qty') > $qoh) { $stock = get_item($_POST['stock_id']); display_error(_("The delivery cannot be processed because there is an insufficient quantity for item:") . " " . $stock['stock_id'] . " - " . $stock['description'] . " - " . _("Quantity On Hand") . " = " . number_format2($qoh, get_qty_dec($_POST['stock_id']))); return false; } return true; } $cost_home = get_standard_cost(get_post('stock_id')); // Added 2011-03-27 Joe Hunt $cost = $cost_home / get_exchange_rate_from_home_currency($_SESSION['Items']->customer_currency, $_SESSION['Items']->document_date); if (input_num('price') < $cost) { $dec = user_price_dec(); $curr = $_SESSION['Items']->customer_currency; $price = number_format2(input_num('price'), $dec); if ($cost_home == $cost) { $std_cost = number_format2($cost_home, $dec); } else { $price = $curr . " " . $price; $std_cost = $curr . " " . number_format2($cost, $dec); } display_warning(sprintf(_("Price %s is below Standard Cost %s"), $price, $std_cost)); } return true; }
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(); }
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(); }
echo "<center>"; if ($_SESSION['View']->so_type == 1) { display_note(_("This Sales Order is used as a Template."), 0, 0, "class='currentfg'"); } display_heading2(_("Line Details")); start_table(TABLESTYLE, "colspan=9 width=95%"); $th = array(_("Item Code"), _("Item Description"), _("Quantity"), _("Unit"), _("Price"), _("Discount"), _("Total"), _("Quantity Delivered")); table_header($th); $k = 0; //row colour counter foreach ($_SESSION['View']->line_items as $stock_item) { $line_total = round2($stock_item->quantity * $stock_item->price * (1 - $stock_item->discount_percent), user_price_dec()); alt_table_row_color($k); label_cell($stock_item->stock_id); label_cell($stock_item->item_description); $dec = get_qty_dec($stock_item->stock_id); qty_cell($stock_item->quantity, false, $dec); label_cell($stock_item->units); amount_cell($stock_item->price); amount_cell($stock_item->discount_percent * 100); amount_cell($line_total); qty_cell($stock_item->qty_done, false, $dec); end_row(); } label_row(_("Shipping"), price_format($_SESSION['View']->freight_cost), "align=right colspan=6", "nowrap align=right", 1); $sub_tot = $_SESSION['View']->get_items_total() + $_SESSION['View']->freight_cost; $display_sub_tot = price_format($sub_tot); label_row(_("Sub Total"), $display_sub_tot, "align=right colspan=6", "nowrap align=right", 1); $taxes = $_SESSION['View']->get_taxes(); $tax_total = display_edit_tax_items($taxes, 6, $_SESSION['View']->tax_included, 2); $display_total = price_format($sub_tot + $tax_total);
function check_data() { global $total_grn_value, $total_gl_value, $Refs, $SysPrefs; if (!$_SESSION['supp_trans']->is_valid_trans_to_post()) { display_error(_("The credit note cannot be processed because the there are no items or values on the invoice. Credit notes are expected to have a charge.")); set_focus(''); return false; } if (!$Refs->is_valid($_SESSION['supp_trans']->reference)) { display_error(_("You must enter an credit note reference.")); set_focus('reference'); return false; } if (!is_new_reference($_SESSION['supp_trans']->reference, ST_SUPPCREDIT)) { display_error(_("The entered reference is already in use.")); set_focus('reference'); return false; } if (!$Refs->is_valid($_SESSION['supp_trans']->supp_reference)) { display_error(_("You must enter a supplier's credit note reference.")); set_focus('supp_reference'); return false; } if (!is_date($_SESSION['supp_trans']->tran_date)) { display_error(_("The credit note as entered cannot be processed because the date entered is not valid.")); set_focus('tran_date'); return false; } elseif (!is_date_in_fiscalyear($_SESSION['supp_trans']->tran_date)) { display_error(_("The entered date is not in fiscal year.")); set_focus('tran_date'); return false; } if (!is_date($_SESSION['supp_trans']->due_date)) { display_error(_("The invoice as entered cannot be processed because the due date is in an incorrect format.")); set_focus('due_date'); return false; } if ($_SESSION['supp_trans']->ov_amount < $total_gl_value + $total_grn_value) { display_error(_("The credit note total as entered is less than the sum of the the general ledger entires (if any) and the charges for goods received. There must be a mistake somewhere, the credit note as entered will not be processed.")); return false; } if (!$SysPrefs->allow_negative_stock()) { foreach ($_SESSION['supp_trans']->grn_items as $n => $item) { if (is_inventory_item($item->item_code)) { if (check_negative_stock($item->item_code, -$item->this_quantity_inv, null, $_SESSION['supp_trans']->tran_date)) { $stock = get_item($item->item_code); display_error(_("The return cannot be processed because there is an insufficient quantity for item:") . " " . $stock['stock_id'] . " - " . $stock['description'] . " - " . _("Quantity On Hand") . " = " . number_format2($qoh, get_qty_dec($stock['stock_id']))); return false; } } } } return true; }
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(); }
} else { stock_manufactured_items_list_row(_("Item:"), 'stock_id', null, false, true); if (list_updated('stock_id')) { $Ajax->activate('quantity'); } locations_list_row(_("Destination Location:"), 'StockLocation', null); } if (!isset($_POST['quantity'])) { $_POST['quantity'] = qty_format(1, $_POST['stock_id'], $dec); } else { $_POST['quantity'] = qty_format($_POST['quantity'], $_POST['stock_id'], $dec); } if (get_post('type') == WO_ADVANCED) { qty_row(_("Quantity Required:"), 'quantity', null, null, null, $dec); if ($_POST['released']) { label_row(_("Quantity Manufactured:"), number_format($_POST['units_issued'], get_qty_dec($_POST['stock_id']))); } date_row(_("Date") . ":", 'date_', '', true); date_row(_("Date Required By") . ":", 'RequDate', '', null, $SysPrefs->default_wo_required_by()); } else { qty_row(_("Quantity:"), 'quantity', null, null, null, $dec); date_row(_("Date") . ":", 'date_', '', true); hidden('RequDate', ''); $sql = "SELECT DISTINCT account_code FROM " . TB_PREF . "bank_accounts"; $rs = db_query($sql, "could not get bank accounts"); $r = db_fetch_row($rs); if (!isset($_POST['Labour'])) { $_POST['Labour'] = price_format(0); $_POST['cr_lab_acc'] = $r[0]; } amount_row($wo_cost_types[WO_LABOUR], 'Labour');
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']; $orientation = $_POST['PARAM_6']; $TotalDiscount = 0; 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, 60, 225, 300, 325, 385, 450, 515); // $headers in doctext.inc $aligns = array('left', 'left', 'right', 'left', '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); $transId = get_payment_id($i); $urrow = get_customer_trans($transId['trans_no_from'], ST_CUSTPAYMENT); $baccount = get_default_bank_account($myrow['curr_code']); $params['bankaccount'] = $baccount['id']; $branch = get_branch($myrow["branch_code"]); $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('Header2'); $rep->currency = $cur; $rep->Font(); $rep->Info($params, $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); // print_r($result); $SubTotal = 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"], $dec); $DisplayQty = number_format2($sign * $myrow2["quantity"], get_qty_dec($myrow2['stock_id'])); $DisplayNet = number_format2($Net, $dec); if ($myrow2["discount_percent"] == 0) { $DisplayDiscount = 0; } else { $DisplayDiscount = number_format2($myrow2["discount_percent"] * 100, user_percent_dec()) . "%"; } $rep->fontSize += 5; $rep->TextCol(0, 1, $myrow2['stock_id'], -2); $oldrow = $rep->row; $rep->TextColLines(1, 5, $myrow2['StockDescription'], -2); $newrow = $rep->row; $rep->row = $oldrow; 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(5, 6, $DisplayPrice, -2); //$rep->TextCol(5, 6, $DisplayDiscount, -2); $rep->TextCol(6, 7, $DisplayNet, -2); $TotalDiscount += $DisplayPrice * ($DisplayDiscount / 100); } $rep->row = $newrow; //$rep->NewLine(1); if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) { $rep->NewPage(); } $rep->fontSize -= 5; } $memo = get_comments_string(ST_SALESINVOICE, $i); if ($memo != "") { $rep->NewLine(); $rep->TextColLines(1, 5, $memo, -2); } $DisplaySubTot = number_format2($SubTotal, $dec); $DisplayFreight = number_format2($sign * $myrow["ov_freight"], $dec); //$customer_record = get_customer_details($myrow['reference']); $rep->row = $rep->bottomMargin + 15 * $rep->lineHeight; $doctype = ST_SALESINVOICE; $rep->fontSize += 4; $rep->TextCol(3, 6, _("Total: "), -2); $rep->TextCol(6, 7, $DisplaySubTot + $TotalDiscount, -2); //$rep->TextCol(6, 7, $DisplaySubTot, -2); $rep->NewLine(); if ($TotalDiscount > 0 || $urrow['ov_discount'] > 0) { $rep->TextCol(3, 6, _("Discount(s)") . ": ", -2); $rep->TextCol(6, 7, '(' . ($TotalDiscount + $urrow['ov_discount']) . ')', -2); $rep->NewLine(); } // if($urrow['ov_discount']>0) // { // $rep->TextCol(3, 6, _("Cash Discount") . ": ", -2); // $rep->TextCol(6, 7, '('.$urrow['ov_discount'].')', -2); // $rep->NewLine(); // } $rep->TextCol(3, 6, _("Sub-total"), -2); $rep->TextCol(6, 7, $DisplaySubTot - $urrow['ov_discount'], -2); $rep->NewLine(); $rep->TextCol(3, 6, _("Paid"), -2); $rep->TextCol(6, 7, $transId['amt'], -2); $rep->NewLine(); $rep->TextCol(3, 6, _("Due"), -2); $rep->TextCol(6, 7, $DisplaySubTot - $urrow['ov_discount'] - $transId['amt'], -2); $rep->NewLine(); $tax_items = get_trans_tax_details(ST_SALESINVOICE, $i); $first = true; while ($tax_item = db_fetch($tax_items)) { if ($tax_item['amount'] == 0) { continue; } $DisplayTax = number_format2($sign * $tax_item['amount'], $dec); if (isset($suppress_tax_rates) && $suppress_tax_rates == 1) { $tax_type_name = $tax_item['tax_type_name']; } else { $tax_type_name = $tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%) "; } // if($TotalDiscount>0){ // $rep->TextCol(3, 7, _("Total Discount") . ": " . $TotalDiscount.'+'.$urrow['ov_discount'], -2); // $rep->NewLine(); // } if ($tax_item['included_in_price']) { 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 { $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); } $rep->NewLine(); } $rep->NewLine(); $DisplayTotal = number_format2($sign * ($myrow["ov_freight"] + $myrow["ov_gst"] + $myrow["ov_amount"] + $myrow["ov_freight_tax"]), $dec); $rep->Font('bold'); $rep->TextCol(3, 6, _("TOTAL INVOICE"), -2); $rep->TextCol(6, 7, $DisplayTotal - $urrow['ov_discount'], -2); //$words = price_in_words($myrow['Total'], ST_SALESINVOICE); $words = price_in_words($transId['amt'], 0); // $words =$myrow['Total']; if ($words != "") { $rep->NewLine(1); $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, -2); } $rep->fontSize -= 4; $rep->Font(); if ($email == 1) { $rep->End($email); } } if ($email == 0) { $rep->End(); } }
function check_data() { if (!get_post('stock_id_text', true)) { display_error(_("Item description cannot be empty.")); set_focus('stock_id_edit'); return false; } $dec = get_qty_dec($_POST['stock_id']); $min = 1 / pow(10, $dec); if (!check_num('qty', $min)) { $min = number_format2($min, $dec); display_error(_("The quantity of the order item must be numeric and not less than ") . $min); set_focus('qty'); return false; } if (!check_num('price', 0)) { display_error(_("The price entered must be numeric and not less than zero.")); set_focus('price'); return false; } if ($_SESSION['PO']->trans_type == ST_PURCHORDER && !is_date($_POST['req_del_date'])) { display_error(_("The date entered is in an invalid format.")); set_focus('req_del_date'); return false; } return true; }
function print_sales_orders() { global $path_to_root, $print_as_quote, $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']; $print_as_quote = $_POST['PARAM_4']; $comments = $_POST['PARAM_5']; $orientation = $_POST['PARAM_6']; if (!$from || !$to) { return; } $orientation = $orientation ? 'L' : 'P'; $dec = user_price_dec(); $cols = array(4, 60, 225, 300, 325, 385, 450, 515); // $headers in doctext.inc $aligns = array('left', 'left', 'right', 'left', 'right', 'right', 'right'); $params = array('comments' => $comments); $cur = get_company_Pref('curr_default'); if ($email == 0) { if ($print_as_quote == 0) { $rep = new FrontReport(_("SALES ORDER"), "SalesOrderBulk", user_pagesize(), 9, $orientation); } else { $rep = new FrontReport(_("QUOTE"), "QuoteBulk", user_pagesize(), 9, $orientation); } } if ($orientation == 'L') { recalculate_cols($cols); } for ($i = $from; $i <= $to; $i++) { $myrow = get_sales_order_header($i, ST_SALESORDER); $baccount = get_default_bank_account($myrow['curr_code']); $params['bankaccount'] = $baccount['id']; $branch = get_branch($myrow["branch_code"]); if ($email == 1) { $rep = new FrontReport("", "", user_pagesize(), 9, $orientation); if ($print_as_quote == 1) { $rep->title = _('QUOTE'); $rep->filename = "Quote" . $i . ".pdf"; } else { $rep->title = _("SALES ORDER"); $rep->filename = "SalesOrder" . $i . ".pdf"; } } else { $rep->title = $print_as_quote == 1 ? _("QUOTE") : _("SALES ORDER"); } $rep->SetHeaderType('Header2'); $rep->currency = $cur; $rep->Font(); $rep->Info($params, $cols, null, $aligns); $contacts = get_branch_contacts($branch['branch_code'], 'order', $branch['debtor_no'], true); $rep->SetCommonData($myrow, $branch, $myrow, $baccount, ST_SALESORDER, $contacts); $rep->NewPage(); $result = get_sales_order_details($i, ST_SALESORDER); $SubTotal = 0; $items = $prices = array(); while ($myrow2 = db_fetch($result)) { $Net = round2((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"], user_price_dec()); $prices[] = $Net; $items[] = $myrow2['stk_code']; $SubTotal += $Net; $DisplayPrice = number_format2($myrow2["unit_price"], $dec); $DisplayQty = number_format2($myrow2["quantity"], get_qty_dec($myrow2['stk_code'])); $DisplayNet = number_format2($Net, $dec); if ($myrow2["discount_percent"] == 0) { $DisplayDiscount = ""; } else { $DisplayDiscount = number_format2($myrow2["discount_percent"] * 100, user_percent_dec()) . "%"; } $rep->TextCol(0, 1, $myrow2['stk_code'], -2); $oldrow = $rep->row; $rep->TextColLines(1, 2, $myrow2['description'], -2); $newrow = $rep->row; $rep->row = $oldrow; 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(4, 5, $DisplayPrice, -2); $rep->TextCol(5, 6, $DisplayDiscount, -2); $rep->TextCol(6, 7, $DisplayNet, -2); } $rep->row = $newrow; //$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); $DisplayFreight = number_format2($myrow["freight_cost"], $dec); $rep->row = $rep->bottomMargin + 15 * $rep->lineHeight; $doctype = ST_SALESORDER; $rep->TextCol(3, 6, _("Sub-total"), -2); $rep->TextCol(6, 7, $DisplaySubTot, -2); $rep->NewLine(); $rep->TextCol(3, 6, _("Shipping"), -2); $rep->TextCol(6, 7, $DisplayFreight, -2); $rep->NewLine(); $DisplayTotal = number_format2($myrow["freight_cost"] + $SubTotal, $dec); if ($myrow['tax_included'] == 0) { $rep->TextCol(3, 6, _("TOTAL ORDER EX VAT"), -2); $rep->TextCol(6, 7, $DisplayTotal, -2); $rep->NewLine(); } $tax_items = get_tax_for_items($items, $prices, $myrow["freight_cost"], $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($myrow["freight_cost"] + $SubTotal, $dec); $rep->Font('bold'); $rep->TextCol(3, 6, _("TOTAL ORDER VAT INCL."), -2); $rep->TextCol(6, 7, $DisplayTotal, -2); $words = price_in_words($myrow["freight_cost"] + $SubTotal, ST_SALESORDER); if ($words != "") { $rep->NewLine(1); $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, -2); } $rep->Font(); if ($email == 1) { $rep->End($email); } } if ($email == 0) { $rep->End(); } }
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(); }
function print_deliveries() { global $path_to_root, $packing_slip, $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']; $email = $_POST['PARAM_2']; $packing_slip = $_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, 60, 225, 300, 325, 385, 450, 515); // $headers in doctext.inc $aligns = array('left', 'left', 'right', 'left', 'right', 'right', 'right'); $params = array('comments' => $comments); $cur = get_company_Pref('curr_default'); if ($email == 0) { if ($packing_slip == 0) { $rep = new FrontReport(_('DELIVERY'), "DeliveryNoteBulk", user_pagesize(), 9, $orientation); } else { $rep = new FrontReport(_('PACKING SLIP'), "PackingSlipBulk", user_pagesize(), 9, $orientation); } } if ($orientation == 'L') { recalculate_cols($cols); } for ($i = $from; $i <= $to; $i++) { if (!exists_customer_trans(ST_CUSTDELIVERY, $i)) { continue; } $myrow = get_customer_trans($i, ST_CUSTDELIVERY); $branch = get_branch($myrow["branch_code"]); $sales_order = get_sales_order_header($myrow["order_"], ST_SALESORDER); // ? if ($email == 1) { $rep = new FrontReport("", "", user_pagesize(), 9, $orientation); if ($packing_slip == 0) { $rep->title = _('DELIVERY NOTE'); $rep->filename = "Delivery" . $myrow['reference'] . ".pdf"; } else { $rep->title = _('PACKING SLIP'); $rep->filename = "Packing_slip" . $myrow['reference'] . ".pdf"; } } $rep->SetHeaderType('Header2'); $rep->currency = $cur; $rep->Font(); $rep->Info($params, $cols, null, $aligns); $contacts = get_branch_contacts($branch['branch_code'], 'delivery', $branch['debtor_no'], true); $rep->SetCommonData($myrow, $branch, $sales_order, '', ST_CUSTDELIVERY, $contacts); $rep->NewPage(); $result = get_customer_trans_details(ST_CUSTDELIVERY, $i); $SubTotal = 0; while ($myrow2 = db_fetch($result)) { if ($myrow2["quantity"] == 0) { continue; } $Net = round2((1 - $myrow2["discount_percent"]) * $myrow2["unit_price"] * $myrow2["quantity"], user_price_dec()); $SubTotal += $Net; $DisplayPrice = number_format2($myrow2["unit_price"], $dec); $DisplayQty = number_format2($myrow2["quantity"], get_qty_dec($myrow2['stock_id'])); $DisplayNet = number_format2($Net, $dec); if ($myrow2["discount_percent"] == 0) { $DisplayDiscount = ""; } else { $DisplayDiscount = number_format2($myrow2["discount_percent"] * 100, user_percent_dec()) . "%"; } $rep->TextCol(0, 1, $myrow2['stock_id'], -2); $oldrow = $rep->row; $rep->TextColLines(1, 2, $myrow2['StockDescription'], -2); $newrow = $rep->row; $rep->row = $oldrow; 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); if ($packing_slip == 0) { $rep->TextCol(4, 5, $DisplayPrice, -2); $rep->TextCol(5, 6, $DisplayDiscount, -2); $rep->TextCol(6, 7, $DisplayNet, -2); } } $rep->row = $newrow; //$rep->NewLine(1); if ($rep->row < $rep->bottomMargin + 15 * $rep->lineHeight) { $rep->NewPage(); } } $memo = get_comments_string(ST_CUSTDELIVERY, $i); if ($memo != "") { $rep->NewLine(); $rep->TextColLines(1, 5, $memo, -2); } $DisplaySubTot = number_format2($SubTotal, $dec); $DisplayFreight = number_format2($myrow["ov_freight"], $dec); $rep->row = $rep->bottomMargin + 15 * $rep->lineHeight; $doctype = ST_CUSTDELIVERY; if ($packing_slip == 0) { $rep->TextCol(3, 6, _("Sub-total"), -2); $rep->TextCol(6, 7, $DisplaySubTot, -2); $rep->NewLine(); $rep->TextCol(3, 6, _("Shipping"), -2); $rep->TextCol(6, 7, $DisplayFreight, -2); $rep->NewLine(); $tax_items = get_trans_tax_details(ST_CUSTDELIVERY, $i); $first = true; while ($tax_item = db_fetch($tax_items)) { if ($tax_item['amount'] == 0) { continue; } $DisplayTax = number_format2($tax_item['amount'], $dec); if (isset($suppress_tax_rates) && $suppress_tax_rates == 1) { $tax_type_name = $tax_item['tax_type_name']; } else { $tax_type_name = $tax_item['tax_type_name'] . " (" . $tax_item['rate'] . "%) "; } if ($tax_item['included_in_price']) { 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($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 { $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); } $rep->NewLine(); } $rep->NewLine(); $DisplayTotal = number_format2($myrow["ov_freight"] + $myrow["ov_freight_tax"] + $myrow["ov_gst"] + $myrow["ov_amount"], $dec); $rep->Font('bold'); $rep->TextCol(3, 6, _("TOTAL DELIVERY INCL. VAT"), -2); $rep->TextCol(6, 7, $DisplayTotal, -2); $words = price_in_words($myrow['Total'], ST_CUSTDELIVERY); if ($words != "") { $rep->NewLine(1); $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, -2); } $rep->Font(); } if ($email == 1) { $rep->End($email); } } if ($email == 0) { $rep->End(); } }
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(4, 40, 60, 100, 200, 250, 300, 320, 400, 450, 500); // $headers in doctext.inc $aligns = array('left', 'left', 'left', 'left', 'right', 'right', 'right', 'right', 'right', 'right', 'right'); //$params = array('comments' => $comments); $cur = get_company_Pref('curr_default'); $company_data = get_company_prefs(); 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"]); $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; $salesman = get_imc_code($branch['branch_code']); $pay_term = get_payment_terms($myrow['payment_terms']); $branch_data = get_branch_accounts($myrow['branch_code']); $dt = get_discount($branch_data['sales_discount_account'], $myrow['type'], $myrow['trans_no']); $invoice_no = get_custom_no($myrow['trans_no'], $myrow['type']); $contact = getContactPerson($myrow['salesman'], $myrow['debtor_no'], $branch['branch_code']); $rep->NewPage(); $result = get_customer_trans_details(ST_SALESINVOICE, $i); $SubTotal = 0; $rep->NewLine(8); $rep->TextCol(2, 7, _("CHARGE INVOICE # " . $invoice_no)); $rep->TextCol(8, 9, $myrow['TranDate']); $rep->NewLine(); $rep->TextCol(2, 7, $branch['br_name']); if ($dt != 0) { //$display_bulk_discount = (($sub_total - $myrow['Total']) / $sub_total) * 100; $tot = $myrow['Total'] + $dt; $dscnt = ($tot - $myrow['Total']) / $tot * 100; //$dscnt = ($dt / $myrow['Total']) * 100; $significant = strlen(substr(strrchr($dscnt, "."), 1)); if ($significant > 2) { $rep->TextCol(7, 9, floor($dscnt) . "%"); } else { $rep->TextCol(7, 9, $dscnt . "%"); } } $rep->NewLine(); $rep->TextCol(2, 7, $branch['branch_ref']); $rep->TextCol(8, 9, $salesman); $rep->NewLine(); $rep->TextCol(2, 6, $contact); if ($pay_term['terms'] == 'Cash Only') { $rep->TextCol(8, 9, $pay_term['terms']); } else { $rep->TextCol(7, 10, $pay_term['terms']); } $rep->NewLine(); $oldrow = $rep->row; $newrow = $rep->row; $rep->TextColLines(2, 6, $branch['br_address'], -2); $rep->row = $oldrow; $rep->NewLine(5); $rep->Font('bold'); //$rep->Line($rep->row + 10); //$rep->TextCol(2,5, _("Item Description")); //$rep->TextCol(5,6, _("Quantity")); //$rep->TextCol(7,8, _("Unit Price")); //$rep->TextCol(9,10, _("Total Amount")); //$rep->Line($rep->row - 4); $rep->NewLine(2); $rep->Font(); 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()); $Net2 = round2($sign * ($myrow2["unit_price"] * $myrow2["quantity"]), user_price_dec()); $SubTotal += $Net; $DisplayPrice = number_format2($myrow2["unit_price"], $dec); $DisplayQty = number_format2($sign * $myrow2["quantity"], get_qty_dec($myrow2['stock_id'])); $DisplayNet = number_format2($Net, $dec); $dNet = number_format2($Net2, $dec); /*if ($myrow2["discount_percent"]==0) $DisplayDiscount =""; else $DisplayDiscount = number_format2($myrow2["discount_percent"]*100,user_percent_dec()) . "%";*/ //if ($myrow["ov_discount"]==0) // $DisplayDiscount =""; //else //$DisplayDiscount = number_format2($myrow["ov_discount"]/$myrow["ov_amount"] * 100,user_percent_dec()) . "%"; //$rep->TextCol(0, 3, $myrow2['stock_id'], -2); $oldrow = $rep->row; $rep->TextColLines(0, 5, $myrow2['StockDescription'], -2); $newrow = $rep->row; $rep->row = $oldrow; if ($Net != 0.0 || !is_service($myrow2['mb_flag']) || !isset($no_zero_lines_amount) || $no_zero_lines_amount == 0) { $rep->TextCol(5, 6, $DisplayQty . " " . $myrow2['units']); //$rep->TextCol(5, 6, $myrow2['units'], -2); $rep->TextCol(7, 8, $DisplayPrice, -2); //$rep->TextCol(5, 6, $DisplayDiscount, -2); $rep->TextCol(8, 10, $dNet, -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); } $DisplayNet = number_format2($SubTotal, $dec); $DisplaySubTot = number_format2($SubTotal, $dec); $DisplayFreight = number_format2($sign * $myrow["ov_freight"], $dec); $DisplayTots = number_format2($myrow['Total'], $dec); $DisplayDiscount = number_format2($SubTotal - $myrow['Total'], $dec); $rep->row = $rep->bottomMargin + 30 * $rep->lineHeight; $doctype = ST_SALESINVOICE; $rep->NewLine(); $rep->Font('bold'); $rep->TextCol(9, 10, $DisplayNet, -2); $rep->NewLine(); //$rep->TextCol(8, 9, _("Less discount: ")); $rep->TextCol(9, 10, $DisplayDiscount, -2); $rep->NewLine(); //$rep->TextCol(8, 9, _("Net Amount : "), -2); $rep->TextCol(9, 10, $DisplayTots, -2); $rep->NewLine(); /*$tax_items = get_trans_tax_details(ST_SALESINVOICE, $i); $first = true; while ($tax_item = db_fetch($tax_items)) { if ($tax_item['amount'] == 0) continue; $DisplayTax = number_format2($sign*$tax_item['amount'], $dec); if (isset($suppress_tax_rates) && $suppress_tax_rates == 1) $tax_type_name = $tax_item['tax_type_name']; else $tax_type_name = $tax_item['tax_type_name']." (".$tax_item['rate']."%) "; if ($tax_item['included_in_price']) { 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 { $rep->TextCol(3, 6, $tax_type_name, -2); $rep->TextCol(6, 7, $DisplayTax, -2); } $rep->NewLine(); } $rep->NewLine(); $DisplayTotal = number_format2($sign*($myrow["ov_freight"] + $myrow["ov_gst"] + $myrow["ov_amount"]+$myrow["ov_freight_tax"]),$dec);*/ //$rep->Font('bold'); //$rep->TextCol(3, 6, _("TOTAL INVOICE"), - 2); //$rep->TextCol(6, 7, $DisplayTotal, -2); //$words = price_in_words($myrow['Total'], ST_SALESINVOICE); //if ($words != "") //{ // $rep->NewLine(1); // $rep->TextCol(1, 7, $myrow['curr_code'] . ": " . $words, - 2); //} //$rep->Font(); if ($email == 1) { $rep->End($email); } } if ($email == 0) { $rep->End(); } }