Location: PHPKode > projects > CoreAsset > coreasset/book_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);
//echo "bunti";
$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'];
$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'");

// 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'");
$bk_id_list			 = explode(',',$data['equipment_id']); 
$count_book			 = count($bk_id_list);
$i=0;
if($count_book > 0)
{
 foreach($bk_id_list as $n=>$v)
	{
		$book_id						= $v;

		$b_nm							= $database->get_from_database("SELECT * FROM asset_books WHERE book_id='$book_id'");

		$book_name[]					= $b_nm['book_name'];
		$author[]						= $b_nm['author'];
		$publisher[]					= $b_nm['publisher'];
		$isbn_no[]						= $b_nm['isbn_no'];
		$price[]						= $b_nm['price'];

		$result         = $database->Execute("select * from asset_book_history where asset_tag='$asset_tag' and book_id='$book_id'");
		$count			= mysql_num_rows($result);

		while($rwrw = mysql_fetch_array($result))
		{
			$book_hist_id[$i][]		= $rwrw['book_hist_id'];
			$assigned_userid		= $rwrw['assigned_userid'];

			if($assigned_userid > 0)
			{
				$u_nm							= $database->get_from_database("SELECT * FROM asset_users WHERE user_id='$assigned_userid'");
				$user_nm[$i][]					= $u_nm['full_name'];
			}
			else
			{
				$user_nm[$i][]					= "Not Assigned !";
			}

			$issued_on[$i][]		= $rwrw['issued_on'];
			$return_date[$i][]		= $rwrw['return_date'];
			$change_date[$i][]		= $rwrw['change_date'];
		}

	  $i++;
	}
}




$smarty->assign('asset_tag',$asset_tag);
$smarty->assign('count_inner',$count_inner);
$smarty->assign('book_name',$book_name);
$smarty->assign('author',$author);
$smarty->assign('publisher',$publisher);
$smarty->assign('isbn_no',$isbn_no);
$smarty->assign('price',$price);
$smarty->assign('change_date',$change_date);
$smarty->assign('user_nm',$user_nm);
$smarty->assign('return_date',$return_date);
$smarty->assign('issued_on',$issued_on);
$smarty->assign('book_hist_id',$book_hist_id);

}
$smarty->assign('status',$status);
$smarty->assign('rows',$rows);
$j = 1;
$smarty->assign('j',$j);
$smarty->display('book_history.tpl');
?>
Return current item: CoreAsset