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

$smarty = new Smarty;
$smarty->compile_check = true;
$smarty->debugging = false;
$title	  ="::: Search Asset :::";
$smarty->assign('title',$title);
// 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
$today_q = date("Y-m-d");

$num="";
$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);

$numm = $database->no_of_rows("select * from asset_users");

if($numm > 0)
{
	$roww = $database->Execute("select * from asset_users");
	while($rrrw = mysql_fetch_array($roww))
	{
		$userr_id[]		= $rrrw['user_id'];
		$login[]		= $rrrw['full_name'];
	}
	$smarty->assign('userr_id', $userr_id);
	$smarty->assign('login', $login);
}

if(isset($_REQUEST['act']))
	{
		
		 $usr_id = $_REQUEST['user_user'];
		if ($usr_id == "select")
		{
			$set == 0;
		}
		else
		{
		 $qq = "select * from asset_serial_number where issud_userid='$usr_id'";
		$query_user_result = mysql_query($qq) or die(mysql_error());
		$num = mysql_num_rows($query_user_result);
		

		  while($row1   =	mysql_fetch_array($query_user_result))
		  {
		   $serial_id[]               = $row1['serial_id'];
		   $asset_id				  = $row1['asset_id'];
		   $manufacturer[]			  = $row1['manufacturer'];
   		   $equip_price[]			  = $row1['equip_price'];
		   $equipment_id 			  = $row1['equipment_id'];
		   $serial_no[]				  = $row1['serial_no'];	
		   $expr 					  = $row1['expiry_date'];
		   $exp_explode = explode("-",$expr);
		   $exp_in_days[]  = $exp_explode[0]*365+$exp_explode[1]*30+$exp_explode[2];	
		   $expiry_date[]			  = $row1['expiry_date'];	
		   for($r=0;$r<count($expiry_date);$r++)
		   {
		   	if($expiry_date[$r] < $today_q)
				{
					$mmssgg[$r] = 0;
				}
			else
				{
					$mmssgg[$r] = $expiry_date[$r];
				}	
		   }
		  // 
		   $query_asset = $database->Execute("select * from asset_assets where  asset_tag = '$asset_id';");
 		   while($row_asset   =	mysql_fetch_array($query_asset))
		   {
		   		$asset_nickname[]		= $row_asset['asset_nickname'];
		   }
		   
		    $query_equip = $database->Execute("select * from asset_equipment where  equipment_id = '$equipment_id';");
 		   while($row_equip   =	mysql_fetch_array($query_equip))
		   {
		   		$equipment_name[]		= $row_equip['equipment_name'];
				$equipment_model[]		= $row_equip['equipment_model'];	 
		   }

		   }
		   $set = 1;

	}
	
	} 
      $smarty->assign('num',$num);
	  $smarty->assign('mmssgg',$mmssgg);
      $smarty->assign('expiry_date',$expiry_date);
      $smarty->assign('serial_no',$serial_no);
      $smarty->assign('equipment_model',$equipment_model);
      $smarty->assign('set',$set);
      $smarty->assign('usr_id',$usr_id);
      $smarty->assign('serial_id',$serial_id);
      $smarty->assign('manufacturer',$manufacturer);
      $smarty->assign('equip_price',$equip_price);
      $smarty->assign('asset_nickname',$asset_nickname);
      $smarty->assign('receive_date',$receive_date);
      $smarty->assign('equipment_name',$equipment_name);
	  $smarty->assign('name',$name);

$smarty->display('search_asset_by_user.tpl');
?>
Return current item: CoreAsset