Location: PHPKode > projects > CoreAsset > coreasset/asset_history.php
<?php
require_once("lib/inc.php");
require_once("lib/security.php");

$smarty = new Smarty;
$smarty->compile_check = true;
$smarty->debugging = false;
$title	  ="::: Show Asset History :::";
$smarty->assign('title',$title);

$asset_nickname = "";

$date     = date("Y-m-d");
$status   = $_SESSION['status'];
$user_id  = $_SESSION['user_id'];
$smarty->assign('user_id',$user_id);
$row      = $database->get_from_database("select * from asset_users where user_id='$user_id'");
$name     = $row['full_name'];
$rw		  = $database->get_from_database("select * from asset_users where user_id='$_SESSION[user_id]'");
$last_login  = $rw['last_login'];
$last_logout = $rw['last_logout'];
$smarty->assign('last_login',$last_login);
$smarty->assign('last_logout',$last_logout);

$smarty->assign('name',$name );
// Date & Time to be dispalyed on the header 
$date_time	= date("h:i:s A")." ".date("d-m-Y");
$smarty->assign('date_time',$date_time);
// Done
$layer_status	="none";
$res_cat=$database->get_from_database("select category_id from asset_category where category_name like 'book%';");
$cat_id_book		= $res_cat['category_id'];
$query_cond	= "SELECT asset_tag FROM asset_assets where category_id !='$cat_id_book'";
if(isset($_REQUEST['sdjgf05___Xjsarey3__nujdhj_h']))
{
$asset_cond			= $_REQUEST['sdjgf05___Xjsarey3__nujdhj_h'];
if(isset($_REQUEST['dsfhsjv_DMJ___DKIW']))
{
	$asset_nickname		= $_REQUEST['dsfhsjv_DMJ___DKIW'];
}
switch($asset_cond)
{
	case 0: $query_cond.= ""; break;
	case 1: $query_cond.= " AND issued_userid = -1"; break; 
	case 2: $query_cond.= " AND issued_userid != -1"; break; 
	case 3: $query_cond.= " AND asset_nickname ='$asset_nickname'";break;
}
if($asset_nickname == "")
	$layer_status	="none";
else
	{
	 $layer_status	="inline";
	 $smarty->assign('asset_nick',$asset_nickname);
	}
$smarty->assign('old_cond',$asset_cond);
}
$smarty->assign('layer_status',$layer_status);
// Asset tag Choosing
//echo $query_cond;

$asset_list         = $database->Execute($query_cond);
$rows				= mysql_num_rows($asset_list);
//echo $rows;
if($rows > 0)
{
while($row_asset=mysql_fetch_array($asset_list))
	{
		$asset_tag_array[]		 = $row_asset['asset_tag'];
	}
$len 						= count($asset_tag_array);
	
if(isset($_REQUEST['sdfh__gi468_k___coe856']))
{
	
	$action						= $_REQUEST['act'];
	$asset_tag_prev				= $_REQUEST['sdfh__gi468_k___coe856'] ;
	$key						= array_search($asset_tag_prev,$asset_tag_array);
	
	if($action === "next")
	{
		
		if( $key == $len-1 )
		{
		 	$asset_tag				= $asset_tag_array[$key];
			
		}
		else
		{
			$asset_tag				= $asset_tag_array[$key+1];
			
		}	
	}
	else if($action === "prev")
	{
		if( $key == 0)
		{
		 	$asset_tag				= $asset_tag_array[$key];
			
		}
		else
		{
			$asset_tag				= $asset_tag_array[$key-1];
			
		}
	}
	else if($action === "first")
	{
	        $asset_tag				= $asset_tag_array[0];
	}
	else if($action === "last")
	{
	        $asset_tag				= $asset_tag_array[$len-1];
	}
}
else
{
	$asset_tag			 = $asset_tag_array[0];
}
$nickname		= $database->get_from_database("SELECT * FROM asset_assets WHERE asset_tag='$asset_tag'");
$asset_nickname		= $nickname['asset_nickname'];
$smarty->assign('asset_nickname',$asset_nickname);


// Done
// Flag Set for Prev And Next
$main_key	= array_search($asset_tag,$asset_tag_array);
//echo $len;
$l=$len-1;
if($main_key == $l && $l != 0)
{   
	$flag	= 1;
}
else if($main_key == 0 || $l == 0)
{   
	$flag	= 0;
}
else
{
	$flag	= 3;
}
$smarty->assign('flag',$flag);
// Done

$data				 = $database->get_from_database("SELECT * from asset_assets WHERE asset_tag='$asset_tag'");
$eq_id_list			 = explode(',',$data['equipment_id']); 
$count_equip		 = count($eq_id_list);

$i = 0;
$serial_list1	= $database->Execute("SELECT * from asset_serial_number WHERE asset_id='$asset_tag'");
while($serial_list = mysql_fetch_array($serial_list1))
    {	
	
	$serialid			= $serial_list['serial_id'];
	$eeq_id				= $serial_list['equipment_id'];
	$row4				= $database->get_from_database("select * from asset_equipment where equipment_id='$eeq_id'");
	$eq_name[]			= $row4['equipment_name']." [".$row4['equipment_model']."]";
	$equipment_model[] = $row4['equipment_model'];
	
	$eq_serial[]	= $serial_list['serial_no'];
	$eq_manufac[]	= $serial_list['manufacturer'];
	$eq_warranty[]	= $serial_list['expiry_date'];
	//$eq				= $database->get_from_database("SELECT * FROM asset_equipment WHERE equipment_id = '$eq_id_list[$i]'");
	//$eq_name[]		= $eq['equipment_name'];
//	$result         = $database->Execute("select * from asset_history where asset_tag='$asset_tag' AND equipment_id = '$eq_id_list[$i]'");
	$result         = $database->Execute("select * from asset_history where serial_id='$serialid'");
	$count			= mysql_num_rows($result);
	if($count > 0)
	{
	  $count_inner[]		= $count;
	  while($row = mysql_fetch_array($result))
		{
			$eq_id[]							= $row['equipment_id'];
			$old_stat							= $row['old_status'];
			$new_stat							= $row['new_status'];
			$comment[$i][]						= $row['reason'];
			$change_date[$i][]                  = $row['change_date'];
			$user_id							= $row['user_id'];
			if($user_id > 0)
			{
				$u_nm							= $database->get_from_database("SELECT * FROM asset_users WHERE user_id='$user_id'");
				$user_nm[$i][]					= $u_nm['full_name'];
			}
			else
			{
				$user_nm[$i][]					= "Not Assigned !";
			}

			switch($old_stat)
			{
				case 1: $old_status[$i][]			= "<font color='GREEN'>OK</font>"; break;
				case 2: $old_status[$i][]			= "<font color='DARKORANGE'>Repairing</font>"; break;
				case 3: $old_status[$i][]			= "<font color='RED'>Obsolete</font>"; break;
				default : $old_status[$i][]			= "NA"; break;
			}
			switch($new_stat)
			{
				case 1: $new_status[$i][]			= "<font color='GREEN'>OK</font>"; break;
				case 2: $new_status[$i][]			= "<font color='DARKORANGE'>Repairing</font>"; break;
				case 3: $new_status[$i][]			= "<font color='RED'>Obsolete</font>"; break;
				default : $new_status[$i][]			= "NA"; break;
			}
		
		}
	}
	else
	{
		$count_inner[]		= 0;
	}
	$i++;
}


$smarty->assign('asset_tag',$asset_tag);
$smarty->assign('count_inner',$count_inner);
$smarty->assign('eq_name',$eq_name);
$smarty->assign('eq_id',$eq_id);
$smarty->assign('old_status',$old_status);
$smarty->assign('new_status',$new_status);
$smarty->assign('comment',$comment);
$smarty->assign('change_date',$change_date);
$smarty->assign('eq_serial',$eq_serial);
$smarty->assign('eq_manufac',$eq_manufac);
$smarty->assign('eq_warranty',$eq_warranty);
$smarty->assign('user_nm',$user_nm);
}
$smarty->assign('status',$status);
$smarty->assign('rows',$rows);
$j = 1;
$smarty->assign('j',$j);
$smarty->display('asset_history.tpl');
?>
Return current item: CoreAsset