Location: PHPKode > projects > CoreAsset > coreasset/show_asset.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 :::";
$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
$u_id = "";
$asset_manufacturer = "";
$vendor_id = "";
$submit_status = "";

$date     = date("Y-m-d");
$smarty->assign('cur_date',$date);
$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);

if($status < 4)
{

//*********************************** Getting User Lists *************************************************
  $res3          = $database->Execute("select * from asset_users");
  while($row3    = mysql_fetch_array($res3))
  {
   $userid[]                          = $row3['user_id'];
   $full_name[]                       = $row3['full_name'];
  }
  $smarty->assign("userid",$userid);
  $smarty->assign("full_name",$full_name);
// *********************************************************************

  if(isset($_GET['hd83___2y8dh328f____8hhdiw___jd9']))
  {
   $asset_tag           = $_GET['hd83___2y8dh328f____8hhdiw___jd9'];
   $row                 = $database->get_from_database("select * from asset_assets where asset_tag='$asset_tag'");

//   $asset_manufacturer  = $row['asset_manufacturer'];
   $asset_nickname      = $row['asset_nickname'];
   $po_no               = $row['po_no'];
   $asset_price         = $row['asset_price'];
   $asset_description   = $row['asset_description'];
   $receive_date        = $row['receive_date'];
   $vendorid            = $row['vendor_id'];
   $equipmentid         = $row['equipment_id'];
   $row_name            = $database->get_from_database("select * from asset_users where user_id='$u_id'");
   // *******************  GETTING VENDOR INFORMATION ***********************************************************
   $vend_id               = $row['vendor_id'];
   $row3                  = $database->get_from_database("select * from asset_vendor where vendor_id='$vend_id'");
   $vendor_name           = $row3['vendor_name'];

   // *******************  GETTING EQUIPMENT INFORMATION *********************************************************
   $eq_id                 = $row['equipment_id'];
   $eq                    = explode(",",$eq_id);

  // $manufacturer		=array();
  // $expiry_date			=array();
  // $depreciation    	=array();
  // $eq_price            =array();
  // $eq_status           =array();

   $manufacturer		=array();
   $expiry_date			=array();
   $depreciation    	=array();
   $eq_price            =array();
   $serial_id           =array();
   $reason              =array(); 
   $stat                =array();

   foreach($eq as $n=>$v)
   {
    if($v!="")
    {
     $row4				= $database->get_from_database("select * from asset_equipment where equipment_id='$v'");
     $equipment_name[]	= $row4['equipment_name'];
	 $equipment_model[] = $row4['equipment_model'];
	}
   }

 $res5			   = $database->Execute("select * from asset_serial_number where asset_id='$asset_tag'");
 while($row5	   = mysql_fetch_array($res5))
 {
	 $serial_no[]		= $row5['serial_no'];
	 $manufacturer[]	= $row5['manufacturer']; 
	 $serial_id[]		= $row5['serial_id'];
	 $expiry_date[]		= $row5['expiry_date'];
//	 $depreciation[]	= $row5['depreciation'];
	 $eq_price[]		= $row5['equip_price'];
	 $eq_status[]		= $row5['status'];
	 $issud_userid[]	= $row5['issud_userid'];

	 $issuserid			= $row5['issud_userid'];
	 $rww				= $database->get_from_database("select * from asset_users where user_id='$issuserid'");
	 $issud_usernm[]	= $rww['full_name'];
	 $reason[]			= $row5['reason'];
	// $status[]			= $row5['status'];
 }
  
   $smarty->assign('asset_tag',$asset_tag);
   $smarty->assign('asset_manufacturer',$asset_manufacturer);
   $smarty->assign('asset_nickname',$asset_nickname);
   $smarty->assign('serial_no',$serial_no);
   $smarty->assign('serial_id',$serial_id);
   $smarty->assign('man',$manufacturer);
   $smarty->assign('expiry_date',$expiry_date);
//   $smarty->assign('depreciation',$depreciation);
   $smarty->assign('eq_price',$eq_price);
   $smarty->assign('eq_status',$eq_status);
   $smarty->assign('reason',$reason);
   $smarty->assign('stat',$eq_status);

   //$smarty_assign('manufacturer',$manufacturer);
   $smarty->assign('po_no',$po_no);
   $smarty->assign('asset_price',$asset_price);
   $smarty->assign('asset_description',$asset_description);
   $smarty->assign('receive_date',$receive_date);
   $smarty->assign('vendor_id',$vendor_id);
   $smarty->assign('equi_id',$eq_id);
   $smarty->assign('vendor_name',$vendor_name);
   $smarty->assign('equipment_name',$equipment_name);
   $smarty->assign('issud_userid',$issud_userid);
   $smarty->assign('issud_usernm',$issud_usernm);
   $smarty->assign('equipment_model',$equipment_model);
   $smarty->assign('u_id',$u_id);
  }

  if(isset($_REQUEST['act']) && $_REQUEST['act'] == "Submit")
  {
     
	 $total_rows		    = $_REQUEST['total_rows'];
	 $equi_id   		    = $_REQUEST['equi_id'];
	 $equip_array           = explode(",",$equi_id);
	 $serial                = $_REQUEST['serial'];
	 $asset_tag             = $_REQUEST['asset_tag'];
	 $status1               = $_REQUEST['status'];
	 $reason                = $_REQUEST['reason']; 
	 $serial_id             = $_REQUEST['serial_id'];
	 $chkbox=array();
	 for($k=0;$k<=$total_rows;$k++)
	 {
	   $chkbox[$k]                = $_REQUEST['status_eq'.$k];
	 }
	  //print_r($chkbox);
	  /*if(in_array("ok",$chkbox))
	     {
		   $submit_status = 1;
		 } 
		else
		  {
		    $submit_status = 0;
		  }*/
	 for($i=0;$i<$total_rows;$i++)
	{  
	   $u=$i+1;
	   //echo $chkbox;
       if($chkbox[$u] != "")
		{
		  $old=$database->get_from_database("select * from asset_serial_number where  asset_id='$asset_tag' and serial_id='$serial_id[$i]'  and  equipment_id ='$equip_array[$i]'" );
		 // echo "select status from asset_serial_number where  asset_id='$asset_tag' and serial_id='$serial_id[$i]'  and  equipment_id ='$equip_array[$i]'";
		$old_status=$old['status'];
		$old_userid=$old['issud_userid'];

		$database->update("update asset_serial_number set status='$status1[$i]',reason='$reason[$i]'  where    asset_id='$asset_tag' and serial_id='$serial_id[$i]'  and  equipment_id ='$equip_array[$i]'");
		
		 $database->insert("insert into asset_history(history_id,asset_tag,serial_id,equipment_id,old_status,new_status,reason,change_date, user_id) 		 values('','$asset_tag','$serial_id[$i]','$equip_array[$i]','$old_status','$status1[$i]','$reason[$i]','$date','$old_userid')");
		 
		 
		 redirect ("manage_asset.php","Edit");
		}	
	
	} 
	
  }
}

else
{
 $mes = "Sorry ! You have no such Privillage ...";
 $smarty->assign('mes',$mes);
}
$smarty->assign('name',$name);
$smarty->assign('status',$status);
$smarty->assign('serial',0);
$smarty->assign('submit_status',$submit_status);
$smarty->display('show_asset.tpl');
?>
Return current item: CoreAsset