<?php
ERROR_REPORTING(0);
require_once("lib/inc.php");
require_once("lib/security.php");
$smarty = new Smarty;
$smarty->compile_check = true;
$smarty->debugging = false;
$title ="::: Edit Book :::";
$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'];
$smarty->assign('name',$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(isset($_GET['hd83___2y8dh328f____8hhdiw___jd9']))
{
$book_id = $_GET['hd83___2y8dh328f____8hhdiw___jd9'];
$row1 = $database->get_from_database("select * from asset_books where book_id='$book_id'");
$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'];
//echo $receive_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);
}
if(isset($_REQUEST['act']))
{
if ($_REQUEST['act'] =="edit")
{
$book_id =trim($_POST['book_id']);
$book_name =trim($_POST['book_name']);
$author =trim($_POST['author']);
$isbn_no =trim($_POST['isbn_no']);
$publisher =trim($_POST['publisher']);
$rec_date =trim($_POST['rec_date']);
$price =trim($_POST['price']);
//$pieces =$_POST['pieces'];
$old_isbn_res = $database->get_from_database("SELECT isbn_no from asset_books WHERE book_id='$book_id'");
$old_isbn = $old_isbn_res['isbn_no'];
if($old_isbn != $isbn_no)
{
$existing = $database->no_of_rows("SELECT * from asset_books WHERE book_name='$book_name' AND author='$author' AND publisher='$publisher' AND isbn_no='$isbn_no';");
if($existing != 0)
{
redirect("display_book.php","Exist" );
}
}
else
{
if($database->update("update asset_books set book_name='$book_name',author='$author',publisher='$publisher',isbn_no='$isbn_no',receive_date='$rec_date',price='$price' where book_id='$book_id'"))
{
redirect ("display_book.php","Edit");
}
}
}
}
$smarty->display('edit_book.tpl');
?>