<?php
/**********************************************************************
***********************************************************************/

$page_security = 'SA_TOOL_REQUEST_INQ';
if (!@$_GET['popup'])
	$path_to_root = "../..";
else	
	$path_to_root = "..";
include_once($path_to_root . "/includes/db_pager.inc");
include_once($path_to_root . "/includes/session.inc");
include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/includes/inventory.inc");
include_once($path_to_root . "/includes/data_checks.inc");
include_once($path_to_root . "/assets/includes/db/tool_requests_inquiry_db.inc");
include_once($path_to_root . "/includes/db/group_companies_db.inc");


$js = '';

if ($SysPrefs->use_popup_windows) {
	$js .= get_js_open_window(900, 500);
}

if (user_use_date_picker()) {
	$js .= get_js_date_picker();
}

page($help_context = "Approve Asset Request Inquiry", false, false, "", $js);
//---------------------------------------------------------------------------------------------

simple_page_mode(true);

if (isset($_GET['order_no']))
{
    $_POST['order_no'] = $_GET['order_no'];
}

function selected_id($row)
{
    return get_asset_trans_view_str(ST_TOOL_REQUEST, $row['id']);  
}

function project_description($row)
{
    return $row['project_description'];
}

function employee_name($row)
{
    $name = get_group_company_employee_formatted_long_name($row['company_code'], $row['employee_code']);
    return $name;    
}


function reference($row)
{
    return $row['reference'];
}

function order_date($row)
{
   return sql2date($row['date']);
}

function location_name($row)
{
    return $row['location_name'];
}

function comment($row)
{
    return $row['comment'];
}


function edit_link($row) 
{
    $modify = "ARNo";   
        
    return pager_link(_("Edit"), "/assets/tool_requests.php?$modify=". $row['id'], ICON_EDIT);   
   
}


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


if ($Mode == 'RESET')
{
	$selected_id = -1;
}

if (isset($_POST['_selected_id_update']) )
{
	$selected_id = $_POST['selected_id'];
	//$Ajax->activate('_page_body');
}

//if (list_updated('employee_code')) 
	$Ajax->activate('_page_body');
//--------------------------------------------------------------------------------------------------

start_form();

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


$current_user_id = $_SESSION['wa_current_user']->user;

$sql = get_sql_for_approve_tool_request_inquiry($current_user_id);    
                                                       
                                                      
$cols = array(_("ID")=> array('fun'=>'selected_id'),
                _("Reference")=>array('fun'=>'reference','align'=>'center'),   
                _("Project")=> array('fun'=>'project_description'), 
                _("Employee")=> array('fun'=>'employee_name','align'=>'center'),
                _("Location")=> array('fun'=>'location_name','align'=>'center'),                       
                _("Date")=>array('fun'=>'order_date','align'=>'left'),                         
                _("Comment")=>array('fun'=>'comment','align'=>'center'),
             
            );

    array_append($cols, array(
		
		array('insert'=>true, 'fun'=>'edit_link')));

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

$table =& new_db_pager('orders_tbl', $sql, $cols, null, null);

$table->width = "90%";

display_db_pager($table);

br();

if (!@$_GET['popup'])
{
    end_form();
    end_page();
}	


?>
