<?php
/**********************************************************************
***********************************************************************/
$page_security = 'SA_TOOL_RETURN_INQ';
$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/data_checks.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/assets/includes/db/tool_returns_inquiry_db.inc");
include_once($path_to_root . "/includes/common_functions.inc");     
include_once($path_to_root . "/includes/db/group_companies_db.inc");   

$js = "";
if ($SysPrefs->use_popup_windows)
	$js .= get_js_open_window(800, 500);
page(_($help_context = "View Asset Return"), true, false, "", $js);

//-------------------------------------------------------------------------------------------------

if ($_GET['trans_no'] != "")
{
    $asset_return_id = $_GET['trans_no'];
}

display_heading("Tool Return No: " . $asset_return_id);

start_table(TABLESTYLE2, "width=60%");

$myrow = view_tool_return($asset_return_id);

start_row();
label_cells("Reference", $myrow['reference'], "class='tableheader2'");
end_row();

label_cells(_("Project"), $myrow['project_name'], "class='tableheader2'");
end_row();

label_cells("Company", $myrow['company_code'], "class='tableheader2'");
end_row();

label_cells(_("Employee"), $myrow['employee_code']." - ".$myrow['initials']."  ".$myrow['employee_last_name'], "class='tableheader2'");
end_row();

label_cells(_("Location"), $myrow['location_name'], "class='tableheader2'");
end_row();

label_cells(_("Date"), sql2date($myrow['tran_date']), "class='tableheader2'");
end_row();

label_cells(_("Comment"), $myrow['comment'], "class='tableheader2'");
end_row();

label_cells(_("Tool Issue"), get_asset_trans_view_str(ST_TOOL_ISSUE, $myrow['asset_issue_id']), "class='tableheader2'");
end_row();

end_table(1);

//--------------------------------------------------------------------------------------------------

start_table(TABLESTYLE2, "width=90%");

display_heading("Details");

$result = view_tool_return_details($asset_return_id);

$th = array(_("ID"),_("Tool"),  _("Quantity"), _('Site'),
            _("Returned Date"), "Lost", _("Comment"),);  
                                     

table_header($th);
$k = 0; //row colour counter
  
while($row_b = db_fetch($result)){
    
    alt_table_row_color($k);
     
    label_cell($row_b['id']);    
    label_cell($row_b['asset_code']."-".$row_b['asset_description']."-"."(".$row_b['asset_id'].")");   
    label_cell($row_b['quantity'], "align=right");
    label_cell($row_b['site_name']);
    label_cell(sql2date($row_b['returned_date']), "align=center");
    label_cell(get_yes_no_name($row_b['lost']), "align=center");
    label_cell($row_b['line_comment']);
    
     
    $k++;
}

end_table(1);


//start_table(TABLESTYLE2, "width=60%");
//
//    display_heading("Asset Issue");
//
//    $th = array(_("ID"),_("Reference"),_("Date"),_("Location"),_("Employee"));
//
//    table_header($th);
//
//    $asset_issue_details = view_asset_issue_for_asset_return($myrow['asset_issue_id']);
//    
//    while($ai_row = db_fetch($asset_issue_details)){
//        alt_table_row_color($k);
//        
//        $id = get_asset_trans_view_str(ST_ASSET_ISSUE, $ai_row['id']);
//        label_cell($id);
//        label_cell($ai_row['reference']);
//        label_cell(sql2date($ai_row['tran_date']), "align=center");
//        label_cell($ai_row['location_name']);
//        $name = get_group_company_employee_formatted_long_name($ai_row['company_code'], $ai_row['employee_code']);
//        label_cell($name) ;  
//    }
//
//end_table();

end_page(true, false, false, ST_TOOL_RETURN, $asset_return_id);


?>
