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

$smarty = new Smarty;
$smarty->compile_check = true;
$smarty->debugging = false;
$title	  ="::: Manage Equipment :::";
$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
$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);

if($status < 5)
{
    $num = $database->no_of_rows("select * from asset_equipment");

    if(isset($_GET['hd83___2y8dh328f____8hhdiw___jd9']))
    {
     if($status < 4)
     {
        $equipment_id = $_GET['hd83___2y8dh328f____8hhdiw___jd9'];
        if($database->delet("delete from asset_equipment where equipment_id='$equipment_id'"))
        {
         redirect ("manage_equipment.php","Delete");
        }
        else
        {
         echo mysql_error();
        }
      }
      else
      {
        $num = "invalid";
        $smarty->assign('num',$num);
      }
    }


    if(isset($_GET['act']))
    {
     if($_GET['act']=="Add")
     {
      $mes = "Equipment is Successfully Created !";
     }
     if($_GET['act']=="Edit")
     {
      $mes = "Equipment is Successfully Updated !";
     }
     if($_GET['act']=="Delete")
     {
      $mes = "Equipment is Successfully Deleted !";
     }
     if($_GET['act']=="Exist")
     {
      $mes = "Equipment is already Added ...";
     }
    }


    if($num > 0)
    {
      $res          = $database->Execute("select * from asset_equipment");
      while($row1   = mysql_fetch_array($res))
      {
       $equipment_id[]                        = $row1['equipment_id'];
       $equipment_name[]                      = $row1['equipment_name'];
       $equipment_model[]                     = $row1['equipment_model'];
	   $status_del[]						  = $row1['status'];
      }
    $smarty->assign('equipment_id',$equipment_id);
    $smarty->assign('equipment_name',$equipment_name);
    $smarty->assign('equipment_model',$equipment_model);
	$smarty->assign('status_equip',$status_del);
    }
	
$smarty->assign('num',$num);
$smarty->assign('mes',$mes);
}
else
{
 $num = "invalid";
 $smarty->assign('num',$num);
}

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


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