<?php
/**********************************************************************
***********************************************************************/
$page_security = 'SA_MANUFTRANSVIEW';
$path_to_root = "../..";

include_once($path_to_root . "/includes/session.inc");

include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/inventory.inc");
include_once($path_to_root . "/includes/data_checks.inc");
include_once($path_to_root . "/manufacturing/includes/manufacturing_db.inc");
include_once($path_to_root . "/manufacturing/includes/db/manufacturing_requirements_db.inc");
include_once($path_to_root . "/manufacturing/includes/manufacturing_ui.inc");
$js = "";
if ($SysPrefs->use_popup_windows)
	$js .= get_js_open_window(800, 500);
page(_($help_context = "View Manufacturing Requirement"), true, false, "", $js);

//-------------------------------------------------------------------------------------------------
$woid = 0;
if ($_GET['trans_no'] != "")
{
	$wom_id = $_GET['trans_no'];
}



function display_row($name, $value)
{
    start_row();        
    label_cells($name, $value, "width=70px class='tableheader2'", "width=60px");
    end_row();
    
}


global $systypes_array;


br(2);

start_table(TABLESTYLE, "width=50%");

display_heading('Workorder Item');


//table_header($th);

    $myrow = view_wo_material_line($wom_id);
    display_row("Workorder No:",$myrow["workorder_id"]);
    //display_row("Order No:",get_trans_view_str(ST_MANUF_REQUEST,$myrow["id"]));
    display_row("Process :",$myrow["process_description"]);
    display_row("Item code",$myrow["stock_id"]);
    display_row("Item Description",$myrow["item_description"]);
    display_row("WO Qty",number_format($myrow["req_unit_qty"],2));
    display_row("Unit",$myrow["req_unit"]);
    display_row("Issued Qty",number_format($myrow["units_issued"],2));
    display_row("Ordered Qty",number_format($myrow["qty_ordered"],2));
    display_row("Required Date",sql2date($myrow["item_required_date"]));
       
   
 

end_row();

end_table(1);

start_table(TABLESTYLE, "width=70%");

display_heading('Purchase Requests');

$th = array(_("Oredred Unit"),_("Ordered Unit Qty"), "Ordered Req Date", _("PR No"), _("PR Unit"), _("PR Qty"), _("PR Req Date"));
table_header($th);
$k = 0;

$order_type_name="";
$data = view_wo_material_pr_lines($wom_id);
while($mr_req=db_fetch($data))
{
    label_cell($mr_req["order_unit"]);
    amount_decimal_cell($mr_req["order_unit_qty"]);
    label_cell(sql2date($mr_req["required_date"]), "align=center");

    //label_cell($mr_req["pr_no"]);
    label_cell(get_trans_view_str(ST_PURCH_REQ,$mr_req["pr_no"]), "align=center");
    label_cell($mr_req["pr_unit"]);
    amount_decimal_cell($mr_req["pr_unit_qty"]);
    label_cell(sql2date($mr_req["pr_req_date"]), "align=center");

    end_row();

    $k++;
}

end_row();

end_table(1);
//
//is_voided_display(ST_LOCTRANSFER, $trans_no, _("This transfer has been voided."));

end_page(true, false, false, ST_WORKORDER, $woid);

?>
