<?php


function read_mtr($mtr_no, &$mtr_cart)
{
    read_mtr_header($mtr_no, $mtr_cart);
    read_mtr_details($mtr_cart);
    
}
    
function read_mtr_header($mtr_no, &$mtr_cart)
{
    $myrow = get_material_transfer_requisition($mtr_no);

    $mtr_cart->order_id = $myrow["mtr_no"];
    $mtr_cart->reference = $myrow["reference"];
    $mtr_cart->issuing_location  = $myrow["issuing_location"];
    $mtr_cart->requesting_location  = $myrow["requesting_location"];
    $mtr_cart->required_date  = ($myrow["mtr_required_date"]);
    $mtr_cart->memo_  = $myrow["comments"];
    $mtr_cart->requestor_name  = $myrow["requestor_name"];
    $mtr_cart->created_by  = $myrow["created_by"];
    $mtr_cart->created_on  = $myrow["created_on"];
    $mtr_cart->receiving_location  = $myrow["requesting_location"];
    $mtr_cart->mtr_complete  = $myrow["mtr_complete"];
    $mtr_cart->project_id  = $myrow["project_id"];
    $mtr_cart->job_reference  = $myrow["project_description"];
    $mtr_cart->project_description  = $myrow["project_description"];
    $mtr_cart->next_approval_group_id  = $myrow["next_approval_group_id"];
    $mtr_cart->approval_status  = $myrow["approval_status"];
    $mtr_cart->movement_type = $myrow["movement_type"];
    $mtr_cart->sample_items = $myrow["sample_items"];
    $mtr_cart->row_state = $myrow["row_state"];
    $mtr_cart->linked_field_id = $myrow["linked_field_id"];
  

        
}
        
function read_mtr_details(&$mtr_cart)
{

    $mtr_details = get_mtr_details($mtr_cart->order_id);

    $element_no = 0;
    while ($mtrd_row = db_fetch($mtr_details)) 
    {
        $mtr_line = new line_item($mtrd_row["stock_id"], 0, $standard_cost=null, 
                $mtrd_row["description"],sql2date($mtrd_row["required_date"]), $mtrd_row["line_comment"],
                null, $mtrd_row["id"], $mtrd_row["issued_qty"], $mtrd_row["requested_qty"], 0, 0, null, 0, 
                null, null, null, null, null, $mtrd_row["requested_unit"], $mtrd_row["requested_unit_qty"], 
                $mtrd_row["req_unit_conv_factor"]);

        $mtr_line->row_id = $mtrd_row["id"];
        $mtr_line->line_complete = $mtrd_row["line_complete"];
        $mtr_line->created_by = $mtrd_row["created_by"];
        $mtr_line->created_on = $mtrd_row["created_on"];
        $mtr_line->high_value_item = $mtrd_row["high_value_item"];
        $mtr_line->sample_item = $mtrd_row["sample_item"];
        $mtr_line->reference_cost = $mtrd_row["reference_cost"];
        $mtr_line->project_site_id = $mtrd_row["project_site_id"];
        $mtr_line->project_site_description = $mtrd_row["project_site_description"];
        $mtr_line->task_id = $mtrd_row["task_id"];
        $mtr_line->task_description = $mtrd_row["task_description"];

        $mtr_cart->line_items[$element_no] = $mtr_line;
        $element_no++;
    }

}


