Location: PHPKode > projects > CoreAsset > coreasset/show_export.php
<?php
	require_once("lib/inc.php");
	require_once("lib/security.php");
	
	$smarty = new Smarty;
	$smarty->compile_check = true;
	$smarty->debugging = false;
	$title	  ="::: View Asset list :::";
	$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
	$date     = date("Y-m-d");
	$flag = "";
	$equip_name = "";
	$serialno = "";
	$maf = "";
	$expr_dt = "";
	$issuduserid = "";
	$cat_id_book = "";
	$user_issued  = "";
	$eq_serial = "";
	$eq_manufac = "";
	$book_receive = "";
	$issued_userid = "";
	$create_date = "";
//	$issued_userid = "";
	$book_isbn_no = "";
	$book_name = "";
	$user_issued = "";
	$user_name = "";
	$cnt  = "";



	$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)
{

	if(isset($_GET['act']))
	{
	 $cat_id = $_POST['category_id'];
	 $smarty->assign('cat_id',$cat_id);
	 $q			=	"select * from asset_assets where category_id='$cat_id';";
	 $res		=	$database->Execute($q);
	 $numrow    =	$database->no_of_rows($q);
	   
	 if($numrow > 0)
	 {
		while($row1   = mysql_fetch_array($res))
		{
		   $asset_tag[]               = $row1['asset_tag'];
		   $ast_tg					  = $row1['asset_tag'];
		  // $asset_manufacturer[]      = $row1['asset_manufacturer'];
		  // $asset_model[]             = $row1['asset_model'];
		  // $asset_serial[]            = $row1['asset_serial'];
		   $po_no[]                   = $row1['po_no'];
		   $pono	                  = $row1['po_no'];
		   $vendor_id[]               = $row1['vendor_id'];
		   $asset_price[]             = $row1['asset_price'];
		   $equipment_id[]            = $row1['equipment_id'];
		   $asset_description[]       = $row1['asset_description'];
		   $receive_date[]            = $row1['receive_date'];
		   //$cat_id[]                  = $row1['category_id'];     
		   $asset_nickname[]          = $row1['asset_nickname']; 

		   // *******************  GETTING VENDOR INFORMATION ***********************************************************
		   $vend_id               = $row1['vendor_id'];
		   $row3                  = $database->get_from_database("select * from asset_vendor where vendor_id='$vend_id'");
		   $vendor_name[]         = $row3['vendor_name'];

		   // *******************  GETTING EQUIPMENT INFORMATION *********************************************************
		   $res123          = $database->Execute("select * from asset_purchase_order where po_no='$pono'");

		   while($rrw123 = mysql_fetch_array($res123))	
		   {
			   $eq_id                 = $rrw123['equipment_id'];
			   $n_pcs                 = $rrw123['no_pcs'];
			   $no_pcs                = explode(",",$n_pcs);
			   $eq                    = explode(",",$eq_id);

			   foreach($eq as $n=>$v)
			   {
			   //echo $v;
				 if($v!="")
				 {
				   $row4                  = $database->get_from_database("select * from asset_equipment where equipment_id='$v'");
				   $eq_mod	   =	$row4['equipment_model'];
				   $equip_name.=    $row4['equipment_name']." [".$eq_mod."]"." ".$no_pcs[$n]." Pcs"."<br>";
				 }
				}
			   
			   $equipment_name[]        = $equip_name;
			   //echo "<br>";
			   $equip_name = "";
		   }

		   $rrr = $database->Execute("select * from asset_serial_number  where asset_id='$ast_tg'");
		   while($rrww = mysql_fetch_array($rrr))
		   {
				$serialno.= $rrww['serial_no']."<br>";
				$maf.= $rrww['manufacturer']."<br>";
				$expr_dt.= $rrww['expiry_date']."<br>";
				$issuduserid1= $rrww['issud_userid'];
				if($issuduserid1 > 0)
			    {
					$ass_uid = $database->get_from_database("select * from asset_users  where user_id='$issuduserid1'");
					$issuduserid.=$ass_uid['full_name']."<br>";
				}
				else
				{
					$issuduserid.="Not Assigned <br>";
				}

		   }
		   $ser_no[] = $serialno;
		   $man_f[]	 = $maf;
		   $iss_uid[] = $issuduserid;
		   $exp_dt[] = $expr_dt;

		$serialno = "";
		$maf = "";
		$issuduserid = "";
		$expr_dt = "";
}
		 
		///////////////////////////////////////////////////////////////////////////////////////////////////////////
		  
		  $book_rows		=$database->Execute("SELECT * from asset_assets where category_id = '$cat_id_book'");
		  //echo count($book_rows);
		  while($row_books=mysql_fetch_array($book_rows))
		  {
		  $eq_id			= $row_books['equipment_id'];
		  $list_eq			= explode(",",$eq_id);
		  //print_r($list_eq);
		  $ccc_book=1;
		foreach($list_eq as $n=>$v)
			{  
				if($v!="")
				{    
					$qry_book					= "select * from asset_books where book_id='$v'";
					$rrw_book					= $database->get_from_database($qry_book);
					$user_id_book				= $rrw_book['issued_user'];
					$un_temp					= $database->get_from_database("SELECT full_name from asset_users where user_id='$user_id_book'");
					$book_name1.=$ccc_book.".";
					$book_name1.=$rrw_book['book_name']."\n";
					$book_rec.=$ccc_book.".";
					$book_rec.=$rrw_book['receive_date']."\n";
					$book_isbn.=$ccc_book.".";
					$book_isbn.=$rrw_book['isbn_no']."\n";
					
					$book_user.=$ccc_book.".";
					if($un_temp['full_name']=="")
					{
						$book_user.="None\n";
					}
					else
					{
						$book_user.=$un_temp['full_name']."\n";
					}
					$ccc_book++;
				}
	         //echo $eq_name;
			}
			$book_name[]				    = nl2br($book_name1);
			$book_name1				   		= "";
			$book_receive[]				    = nl2br($book_rec);
			$book_rec				        = "";
			$user_issued[]					= nl2br($book_user);
			$book_user						="";
			$book_isbn_no[]                 = nl2br($book_isbn);
			$book_isbn                      =""; 
			
			$asset_description[]       = $row1['asset_description'];
			$receive_date[]            = $row1['receive_date'];
			$issued_userid[]           = $row1['issued_userid'];
			$create_date[]             = $row1['create_date'];
		}	
		//print_r($book_name);
		/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		$qn			=	"select equipment_id from asset_assets where category_id='$cat_id';";
		$resn		=	$database->Execute($qn);
		for($q=0;$q<$numrow;$q++)
		{    
			 $equip=mysql_fetch_array($resn);
			 $eq = explode(",", $equip[0]);
			 $count=0;
			 foreach ($eq as $value)
			 {
			 if($value != "")
			 {
			 
			 $count++;
			 }
			 }
			 for($m=0;$m<$count;$m++)
			   {
				 $qur="select equipment_name from asset_equipment where equipment_id=$eq[$m];";
				 $resq          = $database->Execute($qur);
					 while($row   = mysql_fetch_array($resq))
					   {
						 $equipment_name[]            = $row['equipment_name'];
					   }
				  
			  }
		}
		
		//************************************************************************************************************//
		
			  $smarty->assign('user_name',$user_issued);
	
			  $smarty->assign('serial_no',$eq_serial);
			  $smarty->assign('manufacturer',$eq_manufac); 
			  $smarty->assign('exp_dt',$exp_dt);
			  $smarty->assign('asset_tag',$asset_tag);
			  $smarty->assign('asset_nickname',$asset_nickname);
			  $smarty->assign('po_no',$po_no);
			  $smarty->assign('vendor_id',$vendor_id);
			  $smarty->assign('vendor_name',$vendor_name);
			  $smarty->assign('asset_price',$asset_price);
			  $smarty->assign('equipment_id',$equipment_id);
			  $smarty->assign('asset_description',$asset_description);
			  $smarty->assign('receive_date',$book_receive);
			  $smarty->assign('asset_rec_date',$receive_date);
			  $smarty->assign('issued_userid',$issued_userid);
			  $smarty->assign('create_date',$create_date);
			  $smarty->assign('numrow',$numrow);
			  $smarty->assign('user_name',$user_name);
			  $smarty->assign('equipment_name',$equipment_name);
			  $smarty->assign('book_isbn_no',$book_isbn_no);
			  $smarty->assign('book_name',$book_name);
			  $smarty->assign('issued_to',$user_issued);
			  $smarty->assign('cnt',$cnt);

  			  $smarty->assign('ser_no',$ser_no);
			  $smarty->assign('man_f',$man_f);
			  $smarty->assign('iss_uid',$iss_uid);
		  }
	}
	
	if(isset($_REQUEST['act']))
	{
		$flag=1;
	}
	$smarty->assign('flag',$flag);

	$serialno = "";
	$maf = "";
	$issuduserid = "";

	$status   = $_SESSION['status'];
	$user_id  = $_SESSION['user_id'];
	$row      = $database->get_from_database("select * from asset_users where user_id='$user_id'");
	$name     = $row['full_name'];
	$smarty->assign('name',$name);
	$rr=$database->Execute("select category_id from asset_category where category_name like 'book%';");
	$a= mysql_fetch_array($rr);
	$cat_id_book= $a[0];
	$smarty->assign('cat_id_book',$cat_id_book);
	// 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
	$result			=	$database->Execute("select * from asset_category");
	$category_name	=	array();
	$category_id	=	array();
	while($row=mysql_fetch_array($result))
	{
		$category_name[] = $row[1];
		$category_id[]	 = $row[0];
	}
  $smarty->assign('category_name',$category_name);
  $smarty->assign('category_id',$category_id);
}
	
else
{
 $mes = "Sorry ! You have no such Privillage ...";
 $smarty->assign('mes',$mes);
}

$smarty->assign('name',$name);
$smarty->assign('status',$status);
$smarty->display('show_export.tpl');
	?>
Return current item: CoreAsset