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

$smarty = new Smarty;
$smarty->compile_check = true;
$smarty->debugging = false;
$title	  ="::: Edit Equipment :::";
$smarty->assign('title',$title);
$rrr=$database->Execute("select category_id from asset_category where category_name like 'book%';");
	   $aa= mysql_fetch_array($rrr);
	   $cat_id_book= $aa[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
$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);

// Retriving categories from database
$result     = $database->Execute("select * from asset_category");
$category_name=array();
$category_id=array();
while($row=mysql_fetch_array($result))
{
array_push($category_name,$row[1]);
array_push($category_id,$row[0]);
}
//print_r($category_name);
$smarty->assign('category_name',$category_name);
$smarty->assign('category_id',$category_id);
// category retrived and send to smarty

if($status < 4)
{
  if(isset($_GET['hd83___2y8dh328f____8hhdiw___jd9']))
  {
   $equipment_id         = $_GET['hd83___2y8dh328f____8hhdiw___jd9'];
   $row                  = $database->get_from_database("select * from asset_equipment where equipment_id='$equipment_id'");
   $equipment_name       = $row['equipment_name'];
   $equipment_model      = $row['equipment_model'];
   $cat_id				 = $row['category_id'];
    //echo $cat_id;
	
   $row1            = $database->get_from_database("select * from asset_category where category_id ='$cat_id'");
   $cate_name       = $row1['category_name'];
   $smarty->assign('cate_name',$cate_name);
   
   $smarty->assign('equipment_id',$equipment_id);
   $smarty->assign('equipment_model',$equipment_model);
   $smarty->assign('equipment_name',$equipment_name);
   $smarty->assign('cat_id',$cat_id);
   }

  if(isset($_GET['act']))
  {
   if($_GET['act']=="edit")
   {
    $equipment_id              = $_POST['equipment_id'];
    $equipment_name            = $_POST['equipment_name'];
    $equipment_model           = $_POST['equipment_model'];
	$category			       =($_POST['category']);
    //echo $category;
    //echo "llll";echo $_POST['cat_id'];
	
	$row4           = $database->get_from_database("select * from asset_category where category_name ='$category'");
    $cate_id       = $row4['category_id'];
    
	$numb                 = $database->no_of_rows("select * from asset_equipment where equipment_name='$equipment_name' and equipment_model='$equipment_model'");

	if($numb==0)
    {
		if($database->update("update asset_equipment set equipment_name='$equipment_name', equipment_model='$equipment_model', category_id='$cate_id' where equipment_id='$equipment_id'"))
		{
		 redirect ("manage_equipment.php","Edit");
		}
    }
	else
	{
		redirect ("manage_equipment.php","Exist");
	}
   }
  }
}

else
{
 $mes = "Sorry ! You have no such Privillage ...";
 $smarty->assign('mes',$mes);
}
$smarty->assign('name',$name);
$smarty->assign('status',$status);

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