<?php
require_once("lib/inc.php");
require_once("lib/security.php");
$smarty = new Smarty;
$smarty->compile_check = true;
$smarty->debugging = false;
$title ="::: Add User :::";
$smarty->assign('title',$title);
//echo "bunti";
$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);
// 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
$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);
$num_book=$database->no_of_rows("select category_id from asset_assets where category_id='$cat_id_book';");
$smarty->assign('num_of_book',$num_book);
//echo $num_book;
$num = $database->no_of_rows("select * from asset_assets");
//echo $num;
//////////////asset selection section///////////////////////
if( $num-$num_book > 0 )
{
$res = $database->Execute("select * from asset_assets where category_id != '$cat_id_book'");
while($row1 = mysql_fetch_array($res))
{
$asset_tag[] = $row1['asset_tag'];
$asset_manufacturer[] = $row1['asset_manufacturer'];
$asset_model[] = $row1['asset_model'];
$asset_serial[] = $row1['asset_serial'];
$po_no[] = $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'];
// ******************* 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 *********************************************************
$eq_id = $row1['equipment_id'];
$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'");
$equip_name.= $row4['equipment_name'].",";
}
}
$equipment_name[] = $equip_name;
//echo "<br>";
$equip_name = "";
}
$smarty->assign('asset_tag',$asset_tag);
$smarty->assign('asset_manufacturer',$asset_manufacturer);
$smarty->assign('asset_model',$asset_model);
$smarty->assign('asset_serial',$asset_serial);
$smarty->assign('asset_price',$asset_price);
$smarty->assign('asset_description',$asset_description);
$smarty->assign('receive_date',$receive_date);
$smarty->assign('po_no',$po_no);
$smarty->assign('vendor_id',$vendor_id);
$smarty->assign('vendor_name',$vendor_name);
$smarty->assign('equipment_id',$equipment_id);
$smarty->assign('equipment_name',$equipment_name);
$smarty->assign('cat_id',$cat_id);
//$smarty->assign('num',$num);
//$smarty->assign('mes',$mes);
//print_r($asset_tag);
///////////////////asset selection section///////////////////
}
if(isset($_REQUEST['submit']))
{
echo "act";
}
$smarty->display('depri_asset.tpl');
?>