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

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

$to_date	=date("Y-m-d");
$smarty->assign('cur_date',$to_date);

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

$smarty->assign('status',$status);
if($status < 5)
{
  $query	="select * from asset_books";
if(isset($_REQUEST['srch_type']))
 { 
  $smarty->assign('srch_val',$_REQUEST['srch_type']);
  //echo $_REQUEST['srch_type'];
 if($_REQUEST['srch_type'] == 1)
 {
   //echo "normal";
   $book_norm         		=$_POST['book_name_norm']; 
   $author_norm             =$_POST['author_norm'];
   $smarty->assign('book_name_norm',$book_norm);
   $smarty->assign('author_norm',$author_norm);
   //echo $book_norm;
    if($status == 1)
   {
     $query="select * from asset_books where book_name LIKE'$book_norm%' and author LIKE'$author_norm%' "; 
	}
   else
   {
   $query="select * from asset_books where book_name LIKE '$book_norm%' and author LIKE '$author_norm%' and issued_user=0"; 
   }
 }
  
  
 if($_REQUEST['srch_type'] == 2)
  {
  $book_adv		         =$_POST['book_name']; 
  $author_adv            =$_POST['author'];
  $publisher_adv         =$_POST['publisher'];
  $rec_date_adv          =$_POST['rec_date'];           
   $smarty->assign('book_name_adv',$book_adv);
   $smarty->assign('author_adv',$author_adv);
   $smarty->assign('publisher_adv',$publisher_adv);
   $smarty->assign('rec_date_adv',$rec_date_adv);
   if($status == 1)
    {
     $query="select * from asset_books where book_name='$book_adv' and author='$author_adv' and publisher='$publisher_adv' and receive_date='$rec_date_adv'"; 
	}
   else
   {
   $query="select * from asset_books where book_name='$book_adv' and author='$author_adv' and publisher='$publisher_adv' and receive_date='$rec_date_adv' and issued_user=0"; 
   }
      
  } 
  }
	if(isset($_REQUEST['act']) && $_REQUEST['act']=="assign")
	{
	// Book is assigned
	
		
		 $book_id_list		= explode(',',$_REQUEST['book_id_list']);array_pop($book_id_list);
		 $user_id_list		= explode(',',$_REQUEST['user_id_list']);array_pop($user_id_list);
		 $changed_list		= explode(',',$_REQUEST['changed_list']);array_pop($changed_list);
		 $date_today=date("Y-m-d");
		// print_r($changed_list);
		 //echo count($changed_list);
		 for($i=0; $i<count($changed_list); $i++)
		  {      $option=$_REQUEST['user'];
				//print_r($option);
				//echo $option[5];
				//$op="option".$i;
				$ret_dt="ret_date".$changed_list[$i];
				$return_date =$_REQUEST['$ret_dt'];
				if($option[$changed_list[$i]] != "")
				{
				    $database->update("UPDATE asset_books SET issued_user='$user_id_list[$i]',issued_date = '$date_today',return_date='$return_date'  WHERE book_id='$book_id_list[$i]'");
				}
				else
				{
				    $database->update("UPDATE asset_books SET issued_user='',issued_date = '',return_date=''  WHERE book_id='$book_id_list[$i]'");
				}
		  }
		 
	
	
	
	}
	$num = $database->no_of_rows($query);

   


    if($num > 0)
    {
      $res          = $database->Execute($query);
      while($row1   = mysql_fetch_array($res))
      {
       $book_id[]                          = $row1['book_id'];
       $book_name[]                        = $row1['book_name'];
       $author[]                           = $row1['author'];
       $publisher[]                        = $row1['publisher'];
       $isbn_no[]                          = $row1['isbn_no'];
       $price[]                            = $row1['price'];
       $receive_date[]                     = $row1['receive_date'];
       $issued_user[]                      = $row1['issued_user'];
	   //$isbn_no[]                          = $row1['isbn_no'];
	  // $issued_date[] 					   = $row1['issued_date'];	
			  if($row1['return_date'] == "0000-00-00")
			   {   
			     $return_date[]                      = "Not Issued";
			   }
			  else
			   {
				  $return_date[]                      = $row1['return_date']; 
		
			   } 
			   if($row1['issued_date'] == "0000-00-00")
			   {   
			     $issued_date[]                      = "Not Issued";
			   }
			  else
			   {
				  $issued_date[]                      = $row1['issued_date']; 
		
			   } 
	  }
	  
    $smarty->assign('book_id',$book_id);
    $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('receive_date',$receive_date);
    $smarty->assign('issued_user',$issued_user);
	$smarty->assign('isbn_no',$isbn_no);
	$smarty->assign('return_dt',$return_date);
	$smarty->assign('issued_date',$issued_date);

    }
// User list pull down
 
 	  $res_user          = $database->Execute("select * from asset_users");
      while($row2   = mysql_fetch_array($res_user))
      {
       $userid[]    = $row2['user_id'];
       $user_name[] = $row2['full_name'];
       
      }
    $smarty->assign('user_id',$userid);
    $smarty->assign('user_name',$user_name);

    

// 	
	
$smarty->assign('num',$num);
$smarty->assign('mes',$mes);
}


else
{
 $num = "invalid";
 $smarty->assign('num',$num);
}

$smarty->assign('name',$name);
$smarty->assign('status',$status);

$smarty->assign('cal_cnt',0);
$smarty->display('manage_book.tpl');
?>
Return current item: CoreAsset