<?php
/**********************************************************************
***********************************************************************/
$page_security = 'SA_SUPPTRANSVIEW';
$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 . "/purchasing/includes/db/purchase_indents_db.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'] != "")
{
	$pr_line_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('Purchase Requisition Item');


//table_header($th);

    $myrow = view_open_requisition_details_for_indents($pr_line_id);
    display_row("PR No:",get_supplier_trans_view_str(ST_PURCH_REQ, $myrow["pr_no"], $myrow["pr_no"]));
    //display_row("Order No:",get_trans_view_str(ST_MANUF_REQUEST,$myrow["id"]));
    display_row("Project :",$myrow["project_description"]);
    display_row("Item code",$myrow["item_code"]);
    display_row("Item Description",$myrow["description"]);
    display_row("Qty",number_format($myrow["requested_unit_qty"],2));
    display_row("Unit",$myrow["requested_unit"]);
    display_row("Required Date",sql2date($myrow["required_date"]));
       
   
 

end_row();

end_table(1);

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

display_heading('Purchase Indents');

$th = array(_("Indent No."),_("Supplier"),_("Address"),_("Location"),_("Item Code"),_("Item Description"), _("Unit"), _("Quantity"));
table_header($th);
$k = 0;
$supplier = '';
$address = '';
$location = '';
$order_type_name="";
$data = view_purchase_indent_details($pr_line_id);
while($pi_lines=db_fetch($data))
{
    label_cell(get_supplier_trans_view_str(ST_PURCH_INDENTS,$pi_lines["indent_id"]),$pi_lines["indent_id"],"align=left");
    if($pi_lines["supplier_id"] !='')
    {
       $supplier = $pi_lines["supp_name"]; 
       $address = $pi_lines["supp_address"]; 
    }
    else
    {
       $supplier = $pi_lines["new_supplier_name"];  
       $address = $pi_lines["new_supp_address"]; 
        
    }
    if($pi_lines["location"] !='')
    {
        $location = $pi_lines["location_name"];
    }
    else
    {
        $location = $pi_lines["new_location_address"];
    }
    label_cell($supplier,"align=left");
    label_cell($address,"align=left");
    label_cell($location,"align=left");
    label_cell($pi_lines["item_code"],"align=left");
    label_cell($pi_lines["description"],"align=left");
    label_cell($pi_lines["tran_unit"],"align=left");
    amount_cell($pi_lines["qty"],"align=right");
//    label_cell(get_trans_view_str(ST_PURCH_REQ,$mr_req["pr_no"]), "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);

?>
