<?php
#####Class For Adding Content Management ######
class About extends MysqlFns
{
 /* class constructor */
	function About()
	{
 		$this->LDDisplayPath= $config['SiteGlobalPath']."class.About.php";
  		global $config;
  		global $objSmarty;
  		$this->MysqlFns();
  		$this->Limit = 15;
		$SelQuerys	= 'SELECT max(order_id) as last FROM `customer_orders_master` Limit 0,1';
   		$CusDetail	= $this->ExecuteQuery($SelQuerys, 'select');
   		mysql_query("SET SESSION sql_mode=''");
   
if($CusDetail[0]['last']!="")
   		{
			$CusDetail[0]['order_id'] = stripslashes($CusDetail[0]['last']);
			$c_id1 = preg_replace("/[^0-9\.]/", '', $CusDetail[0]['order_id']);
			$c_id1= $c_id1 + 1;
			$str = str_split($CusDetail[0]['last'], 2);
			$c_id = $str[0]. "" .$c_id1;
   		} else
   		{
   		   $c_id = "EL1001";
   		}
		$objSmarty->assign('c_id', $c_id);

  }
  
  

//*************************************************************************************************************************************************
	function category()
	{
  		global $objSmarty;
  		$SelQuery3		= 'SELECT * FROM `book` WHERE `category` = "astrology"';
		$listing_split2 = new MsplitPageResults($SelQuery3, $this->Limit);
  if ( ($listing_split2->number_of_rows > 0) )  {
   $objSmarty->assign('LinkPage_amc_view_tab',$listing_split2->display_count (TEXT_DISPLAY_NUMBER_OF_RESULT));
   $objSmarty->assign('PerPageNavigation_amc_view_tab',TEXT_RESULT_PAGE1 . ' ' . $listing_split2->display_links($this->Limit, get_all_get_params(array('page', 'info', 'x', 'y')))); 
   $PageList2 = $this->ExecuteQuery($listing_split2->sql_query, 'selectassoc');
  }
   if(!empty($PageList2) && is_array($PageList2))
  {
  $objSmarty->assign('i', $listing_split2->i);
  $objSmarty->assign('PageList2', $PageList2);//print_r($PageList2);
  return $PageList2;
  }
  elseif(empty($PageList2) && is_array($PageList2))
    $objSmarty->assign('ErrorMessage', 'No Records Found');
 }
/**********************************************************************************************/
function Getbooksheader()
{
global $objSmarty;
//echo $_POST['branch'];
 	//$SelQuery2		= 'SELECT * FROM `book` WHERE book_name like  "'.$_POST['search_value'].'%" or author like  "'.$_POST['search_value'].'%" or isbn like  "'.$_POST['search_value'].'%"';
	
	$SelQuery2 =	"select * from  `book` where (book_name like  '%".$_GET['bname']."%' or author like  '%".$_GET['bname']."%' or isbn like  '".$_GET['bname']."%') GROUP BY id";
	
	/*if($_POST['branch'] == 0)
	{
	 $SelQuery2 =	"select *,br.book_id,b.book_name from `book_receipt` br left join `book` b on br.book_id =b.id where (b.book_name like  '%".$_GET['bname']."%' or b.author like  '%".$_GET['bname']."%' or b.isbn like  '".$_GET['bname']."%') GROUP BY br.book_id";

 //$SelQuery2 =	"select *,br.book_id,b.book_name from `book_receipt` br left join `book` b on br.book_id =b.id left join `images` m on m.isbn =b.isbn  where (b.book_name like  '".$_GET['bname']."%' or b.author like  '".$_GET['bname']."%' or b.isbn like  '".$_GET['bname']."%')";
}
else
{
  $SelQuery2 =	"select *,br.book_id,b.book_name from `book_receipt` br left join `book` b on br.book_id =b.id where (b.book_name like  '%".$_GET['bname']."%' or b.author like  '%".$_GET['bname']."%' or b.isbn like  '".$_GET['bname']."%') and (br.branch_name='".$_POST['branch']."') GROUP BY br.book_id";
  
// $SelQuery2 =	"select *,br.book_id,b.book_name from `book_receipt` br left join `book` b on br.book_id =b.id left join `images` m on m.isbn =b.isbn  where (b.book_name like  '".$_GET['bname']."%' or b.author like  '".$_GET['bname']."%' or b.isbn like  '".$_GET['bname']."%') and (br.branch_name='".$_POST['branch']."')";
}*/

// $SelQuery2 =	"select * from  `book` b left join `images` m on m.isbn =b.isbn  where (b.book_name like  '".$_GET['bname']."%' or b.author like  '".$_GET['bname']."%' or b.isbn like  '".$_GET['bname']."%')";

	/*	$listing_split = new MsplitPageResults($SelQuery2, $this->Limit);
  if ( ($listing_split->number_of_rows > 0) )  {
   $objSmarty->assign('LinkPage_amc_view_tab',$listing_split->display_count (TEXT_DISPLAY_NUMBER_OF_RESULT));
   $objSmarty->assign('PerPageNavigation_amc_view_tab',TEXT_RESULT_PAGE1 . ' ' . $listing_split->display_links($this->Limit, get_all_get_params(array('page', 'info', 'x', 'y')))); 
   $PageList8 = $this->ExecuteQuery($listing_split->sql_query, 'selectassoc');
  }*/
  $PageList8 = $this->ExecuteQuery($SelQuery2, 'select');
   if(!empty($PageList8) && is_array($PageList8))
  { 
 // $objSmarty->assign('i', $listing_split->i);
  $objSmarty->assign('PageList8', $PageList8);//print_r($PageList8);
  //return $PageList8;
  }
  else
    {
    $source="insert into search_books(book_author_isbn,member_id,member_name,branch)values('".$_POST['search_value']."','".$_SESSION['user_id']."','".$_SESSION['login_user']."','".$_SESSION['branchname']."')";
$this->ExecuteQuery($source, 'insert');

    //$objSmarty->assign('ErrorMessage', 'No Records Found');
	}
}

/******************************************************************************************/
function weekauthor()
{
global $objSmarty;
// $d = new DateTime('first day of this month'); $d2 = $d->format('jS,01-m-Y');echo $d2;
    $d= date('Y-m-01');
	 $d2= date('Y-m-d');//echo $d2;
 $SelQuery3		='SELECT * FROM `check_out_in_history` WHERE (check_out_date BETWEEN "'.$d.'" AND "'.$d2.'") OR (actual_check_in_date BETWEEN "'.$d.'" AND "'.$d2.'") GROUP BY book_id ORDER BY R_TIMESTAMP DESC';
$AutDetail		= $this->ExecuteQuery($SelQuery3, 'select');
	$objSmarty->assign('AutDetail', $AutDetail);

//print_r($AutDetail);
foreach($AutDetail as $key => $value){
	"Name: $key, book_id: $value <br />";
	$AutDetail[$key]['book_id'] = stripslashes($AutDetail[$key]['book_id']);
	
$SelQuery31	='SELECT * FROM `book` WHERE id IN("'.$AutDetail[$key]['book_id'].'")';
$AutDetail2		= $this->ExecuteQuery($SelQuery31, 'select');
$objSmarty->assign('AutDetail2', $AutDetail2);
}
}

/************************************************************************************/
/*function monthbooks()
{
	global $objSmarty;
	$d= date('Y-m-01');
	$d2= date('Y-m-d');
	 
 $SelQuery4		='SELECT * FROM `check_out_in_history` WHERE (check_out_date BETWEEN "'.$d.'" AND "'.$d2.'") OR (actual_check_in_date BETWEEN "'.$d.'" AND "'.$d2.'") GROUP BY book_id ORDER BY R_TIMESTAMP DESC Limit 0,5';
$BookDetail2		= $this->ExecuteQuery($SelQuery4, 'select');//print_r($BookDetail2);
/*while($rows=mysql_fetch_array(mysql_query($SelQuery4)))
							  {
							  $book_id=$book_id."','".$rows['book_id']; print_r($book_id);
							  }
$a1=array_fill(0,1,$BookDetail2);//print_r($a1);

echo $SelQuery32	='SELECT * FROM `book` WHERE id IN('.implode(',', $a1).')';
$BookDetail3		= $this->ExecuteQuery($SelQuery32, 'select');print_r($BookDetail3);
$objSmarty->assign('BookDetail3', $BookDetail3);
 }*/
 /*****************************************************************************************/
 function updatepass()
 {
 global $objSmarty;
 $mno = $_POST['c_num'];
 if($mno == '')
 {
 $UpQuery4 = 'UPDATE `members` SET `password` = "'.$_POST['pass'].'" WHERE `member_code` ="'.$_POST['m_code'].'" AND branch="'.$_POST['b_name'].'"';
 $this->ExecuteQuery($UpQuery4, 'update');
 
  $UpQuery41 = 'SELECT * FROM `members` WHERE `password` = "'.$_POST['pass'].'" AND branch="'.$_POST['b_name'].'" AND `member_code` ="'.$_POST['m_code'].'" ';
  $BookDetail3 =	$this->ExecuteQuery($UpQuery41, 'select');
 }
 else
 {
 $UpQuery4 = 'UPDATE `members` SET `password` = "'.$_POST['pass'].'", contact_number="'.$_POST['c_num'].'", emailid="'.$_POST['mail'].'" WHERE `member_code` ="'.$_POST['m_code'].'" AND branch="'.$_POST['b_name'].'"';
 $this->ExecuteQuery($UpQuery4, 'update');
 
  $UpQuery41 = 'SELECT * FROM `members` WHERE `password` = "'.$_POST['pass'].'" AND branch="'.$_POST['b_name'].'" AND `member_code` ="'.$_POST['m_code'].'" AND (RIGHT(contact_number,10) ="'.$_POST['c_num'].'" OR `land_line` ="'.$_POST['c_num'].'")';
  $BookDetail3 =	$this->ExecuteQuery($UpQuery41, 'select');
 }
 
 
 //print_r($BookDetail3);echo $BookDetail3[0]['count'];exit;
if(!empty($BookDetail3) && is_array($BookDetail3)){
echo '<script>';
echo 'alert("Member Registered Successfully!!!")';
echo '</script>';
 }
 else 
{
echo '<script language="javascript">';
echo 'alert("Member Not Registered!!!")';
echo '</script>';
header('Location:' .$_SERVER['PHP_SELF'].'');
//$objSmarty->assign('SuccessMessage1', 'Username or Password is invalid');
}
}
function do_post_request($objArray) {
  $SelQuery2		= 'SELECT * FROM `members` WHERE `member_code` = "'.$_POST['m_code'].'"';
 $CusDetail		= $this->ExecuteQuery($SelQuery2, 'select');//echo $CusDetail[0]['sms_status'];
 $sta_s=$CusDetail[0]['sms_status'];//echo $sta_s;
 if($sta_s == 1)
 {
$url = 'http://www.meru.co.in/wip/sendsms?';//echo $url;
$mobile=substr($CusDetail[0]['contact_number'],-10);//echo $mobile;
$message2='M id:'.$CusDetail[0]['member_code'].' Dear Member, Greeting from ELL. You have been successfully registered for Online services. Ct:044-42636919';
$data = 'username=eswlibtxn&password=eswlibtxn&message='.urlencode($message2).'&to='.urlencode($mobile);//echo $message2;echo $data;
                $params = array('http'      => array(

                                'method'       => 'POST',

                                'content'      => $data,

                                ));

                if ($optional_headers !== null) {

                                $params['http']['header'] = $optional_headers;

                }
                $ctx = stream_context_create($params); 

                $response = @file_get_contents($url, false, $ctx);

                if ($response === false) {

                                print "Problem reading data from $url, No status returned ";

                }
              // print $response;exit;
                return $response;
				}
}
  /*****************************************************************************************/
 function loginpass()
 {
 global $objSmarty;
 mysql_query("SET SESSION sql_mode=''");
   $UpQuery4 = 'SELECT DISTINCT(count(id)) AS count,member_name,member_code,id,branch,contact_number,land_line,member_type FROM `members` WHERE `password` = "'.$_POST['pass2'].'" AND (`member_code` ="'.$_POST['m_id'].'" OR (`emailid` ="'.$_POST['mail2'].'" OR `land_line` = "'.$_POST['mail2'].'" OR RIGHT(contact_number,10)="'.$_POST['mail2'].'"))';
 //$UpQuery4 = 'SELECT DISTINCT(count(id)) AS count,member_name,member_code,id,branch FROM `members` WHERE `password` = "'.$_POST['pass2'].'" AND (`id` ="'.$_POST['m_id'].'" OR (`emailid` ="'.$_POST['mail2'].'" OR `land_line` = "'.$_POST['mail2'].'"))';
 $BookDetail3 =	$this->ExecuteQuery($UpQuery4, 'select');//print_r($BookDetail3);//echo $BookDetail3[0]['count'];
if ($BookDetail3[0]['count'] == 1) {
$_SESSION['login_user']= $BookDetail3[0]['member_name']; // Initializing Session
$_SESSION['user_code']= $BookDetail3[0]['member_code'];
$_SESSION['user_id']= $BookDetail3[0]['id'];
$_SESSION['branchname']= $BookDetail3[0]['branch'];
$_SESSION['mobile']= $BookDetail3[0]['contact_number'];
$_SESSION['phone']= $BookDetail3[0]['land_line'];
$_SESSION['m_type']= $BookDetail3[0]['member_type'];
//echo $_SESSION['login_user'];echo $_SESSION['user_code'];echo $_SESSION['user_id'];echo $_SESSION['branchname'];echo $_SESSION['mobile'];echo $_SESSION['phone'];
echo '<script>window.location="index.php";';
echo 'alert("Login Successfully!!!")';
echo '</script>';
} 
else 
{
echo '<script language="javascript">';
echo 'alert("Login Details are invalid!!!")';
echo '</script>';
//header('Location:' .$_SERVER['PHP_SELF'].'');
//$objSmarty->assign('SuccessMessage1', 'Username or Password is invalid');
}
//header('Location:' .$_SERVER['PHP_SELF'].'');
 }
 /***************************Duplicate Checking***************************************************************/ 
function ChkDupliCust($c_id){
  global $objSmarty;
   
  if(!empty($c_id))
 // $WhereClause	= ' AND `id` != '.$Ident;
  $SelQuery2		= 'SELECT * FROM `customer_orders_master` WHERE `order_id` = "'.$c_id.'" Limit 0,1';
  $CusDetail		= $this->ExecuteQuery($SelQuery2, 'select');
  if(!empty($CusDetail) && is_array($CusDetail))
   return false;
  else
   return true;
 }
 /************************************************************************************************/
 function insertcart()
 {
 global $objSmarty;
$status = $_POST['s_id'];//echo $status;exit;
//echo $_POST['b_id'];exit;
 $UpQuery3 = 'SELECT * FROM `book` WHERE `id` = "'.$_POST['b_id'].'"';
 $BookDetail3 =	$this->ExecuteQuery($UpQuery3, 'select');//print_r($BookDetail3);
 
if($status == 1){
  $UpQuery2 = 'SELECT * FROM `customer_orders_master` WHERE `member_id` = "'.$_SESSION['user_id'].'" AND submit_status="0"';
 $BookDetail2 =	$this->ExecuteQuery($UpQuery2, 'select');//print_r($BookDetail3);
 
  if(!empty($BookDetail2) && is_array($BookDetail2))
  { 
   $count=$BookDetail2[0]['count']+1; 
   $UpQuery4 = 'UPDATE `customer_orders_master` SET count="'.$count.'" WHERE  `member_id` = "'.$_SESSION['user_id'].'" AND submit_status="0"';
 $BookDetail4 =	$this->ExecuteQuery($UpQuery4, 'update');
 
/* $UpQuery5 = 'SELECT * FROM `images` WHERE `isbn` = "'.$BookDetail3[0]['isbn'].'"';
 $BookDetail5 =	$this->ExecuteQuery($UpQuery5, 'select');//print_r($BookDetail3);*/
 
  $source="insert into customer_orders_details(order_id,isbn,book_name,author,book_id,image_path,reading_charges,price,order_status,status,book_status)values('".$BookDetail2[0]['order_id']."','".$BookDetail3[0]['isbn']."','".$BookDetail3[0]['book_name']."','".$BookDetail3[0]['author']."','".$BookDetail3[0]['id']."','".$BookDetail3[0]['image']."','".$BookDetail3[0]['reading_charges']."','".$BookDetail3[0]['cost']."','Pending','1','0')";
$this->ExecuteQuery($source, 'insert');
  }
  else
  {
  if($this->ChkDupliCust(trim(addslashes($_POST['order_id']))))
   {
		 $source="insert into customer_orders_master(order_id,member_id,member_code,member_name,member_type,mobile_number,phone_number,date_of_order,count,total_reading_charges,delivery_charges,total_charges,other_charges,order_status,record_status,comments,delivery_time,return_time,submit_status,delivery_date,return_date)values('".$_POST['order']."','".$_SESSION['user_id']."','".$_SESSION['user_code']."','".$_SESSION['login_user']."','".$_SESSION['m_type']."','".$_SESSION['mobile']."','".$_SESSION['phone']."',date(Now()),'1','0','0','0','0','Pending','1','','','','0','0000-00-00','0000-00-00')";
		$this->ExecuteQuery($source, 'insert');
		}
		else
		{
		echo '<script language="javascript">';
		echo 'alert("Order ID Already Exist!!!")';
		echo '</script>';
		}
		
	/* $UpQuery5 = 'SELECT * FROM `images` WHERE `isbn` = "'.$BookDetail3[0]['isbn'].'"';
     $BookDetail5 =	$this->ExecuteQuery($UpQuery5, 'select');//print_r($BookDetail3);*/
		
 $source="insert into customer_orders_details(order_id,isbn,book_name,author,book_id,image_path,reading_charges,price,order_status,status,book_status)values('".$_POST['order']."','".$BookDetail3[0]['isbn']."','".$BookDetail3[0]['book_name']."','".$BookDetail3[0]['author']."','".$BookDetail3[0]['id']."','".$BookDetail3[0]['image']."','".$BookDetail3[0]['reading_charges']."','".$BookDetail3[0]['cost']."','Pending','1','')";
$this->ExecuteQuery($source, 'insert');
}
}
elseif($status == 2)
{
 /*$UpQuery5 = 'SELECT * FROM `images` WHERE `isbn` = "'.$BookDetail3[0]['isbn'].'"';
 $BookDetail5 =	$this->ExecuteQuery($UpQuery5, 'select');//print_r($BookDetail3);*/
 
 $source="insert into customer_wish_details(member_id,member_code,member_name,isbn,book_name,author,book_id,mobile_number,date,image_path,reading_charges,price,status)values('".$_SESSION['user_id']."','".$_SESSION['user_code']."','".$_SESSION['login_user']."','".$BookDetail3[0]['isbn']."','".$BookDetail3[0]['book_name']."','".$BookDetail3[0]['author']."','".$BookDetail3[0]['id']."','".$_SESSION['mobile']."','".date('Y-m-d')."','".$BookDetail3[0]['image']."','".$BookDetail3[0]['reading_charges']."','".$BookDetail3[0]['cost']."','1')";
$this->ExecuteQuery($source, 'insert');
}
else
{
/*$source="insert into customer_wish_details(member_id,member_code,member_name,isbn,book_name,author,book_id,mobile_number,date,image_path,reading_charges,price,status)values('".$_SESSION['user_id']."','".$_SESSION['user_code']."','".$_SESSION['login_user']."','".$BookDetail3[0]['isbn']."','".$BookDetail3[0]['book_name']."','".$BookDetail3[0]['author']."','".$BookDetail3[0]['id']."','".$_SESSION['mobile']."','".date('Y-m-d')."','".$BookDetail3[0]['image']."','".$BookDetail3[0]['reading_charges']."','".$BookDetail3[0]['cost']."','3')";
$this->ExecuteQuery($source, 'insert');*/

$source="insert into book_reserved(book_id,book_receipt_id,member_id,branch,reserved_date,comments)values(
'".$BookDetail3[0]['id']."',
'".$_POST['r_id']."',
'".$_SESSION['user_id']."',
'".$_SESSION['branchname']."',
'".date('Y-m-d')."',
'')";
$this->ExecuteQuery($source, 'insert');
}
/*else
{
echo $UpQuery5 = 'SELECT * FROM `customer_orders_master` WHERE `member_id` = "'.$_SESSION['user_id'].'"';
 $BookDetail5 =	$this->ExecuteQuery($UpQuery5, 'select');//print_r($BookDetail3);
 
 $count=$BookDetail5[0]['count']+1; 
 
echo $UpQuery4 = 'UPDATE `customer_orders_master` SET count="'.$count.'" WHERE  `member_id` = "'.$_SESSION['user_id'].'"';
 //$BookDetail4 =	$this->ExecuteQuery($UpQuery4, 'update');
}
echo $UpQuery6 = 'SELECT * FROM `images` WHERE `isbn` = "'.$BookDetail3[0]['isbn'].'"';
 $BookDetail6 =	$this->ExecuteQuery($UpQuery6, 'select');//print_r($BookDetail3);

echo $UpQuery7 = 'SELECT * FROM `customer_orders_master` WHERE `member_id` = "'.$_SESSION['user_id'].'"';
 $BookDetail7 =	$this->ExecuteQuery($UpQuery7, 'select');//print_r($BookDetail3);

 echo $source="insert into customer_orders_details(order_id,isbn,book_name,author,book_id,image_path,reading_charges,price,status)values('".$BookDetail5[0]['order_id']."','".$BookDetail3[0]['isbn']."','".$BookDetail3[0]['book_name']."','".$BookDetail3[0]['author']."','".$BookDetail3[0]['id']."','".$BookDetail4[0]['image']."','".$BookDetail3[0]['reading_charges']."','".$BookDetail3[0]['cost']."','1')";exit;
$this->ExecuteQuery($source, 'insert');

echo $UpQuery8 = 'SELECT * FROM `customer_orders_details` WHERE `order_id` = "'.$BookDetail3[0]['isbn'].'"';
 $BookDetail8 =	$this->ExecuteQuery($UpQuery8, 'select');//print_r($BookDetail3);*/

 }
  /************************************************************************************************/
 function removecart()
 {
 global $objSmarty;
 $UpQuery4 = 'UPDATE `customer_orders_details` SET status="0" WHERE `book_id` = "'.$_POST['b_id'].'"';
 $BookDetail3 =	$this->ExecuteQuery($UpQuery4, 'update');//print_r($BookDetail3);
  }
 /**********************************************************************************************/
 function CartCount(){
 global $objSmarty;
/* $UpQuery4 = 'SELECT DISTINCT(count(id)) AS count FROM `temp_cart` WHERE `session_id` = "'.session_id().'"';
 $BookDetail3 =	$this->ExecuteQuery($UpQuery4, 'select');//print_r($BookDetail3[0]['count']);
 $objSmarty->assign('BookDetail3', $BookDetail3);*/
	}
	/*****************************************************************************************/
 function media_list()
 {
 global $objSmarty;
 
 $UpQuery5 = 'SELECT * FROM `media` WHERE `status` = "1" ';
 $BookDetail3 =	$this->ExecuteQuery($UpQuery5, 'select');//print_r($BookDetail3);
 $objSmarty->assign('BookDetail3', $BookDetail3);
 }
 
  /***************************Search Books List***************************************************************/ 
function searchBooks()
{
  global $objSmarty;
   $SelQuery2		= 'SELECT * FROM `search_books`';
  $SerDetail		= $this->ExecuteQuery($SelQuery2, 'select');
  $objSmarty->assign('SerDetail', $SerDetail);
  }
  function GetCategoryList()
  {
   global $objSmarty;
   $SelQuery2		= 'SELECT * FROM `category` WHERE status="1" ORDER BY name asc';
  $CatDetail		= $this->ExecuteQuery($SelQuery2, 'select');
  $objSmarty->assign('CatDetail', $CatDetail);
  }
/******************************My Profile List********************************************************************************/
 function profile()
 {global $objSmarty;
 
// $SelQuery2 = "select *,cm.order_id,cm.member_id,cm.member_name,cm.total_reading_charges,cm.delivery_charges,cm.total_charges from `customer_orders_master` cm left join `customer_orders_details` cd on cm.order_id =cd.order_id where cm.order_id=cd.order_id and cm.order_status='Pending'";
$tdate=date("Y-m-d");
 if((isset($_POST['f_date3'])) && (isset($_POST['t_date3'])))
 {
  $SelQuery2 =  'select *,ch.book_id,b.book_name,b.author from `check_out_in_history` ch  left join `book` b on b.id =ch.book_id  where ch.member_id ="'.$_SESSION['user_id'].'"  and ch.check_out_date between "'.$_POST['f_date3'].'" and "'.$_POST['t_date3'].'"  and ch.status="0"';
 
//  $SelQuery2 = 'SELECT * FROM check_out_in_history WHERE status="0" AND member_id="'.$_SESSION['user_id'].'" AND check_out_date BETWEEN "'.$_POST['f_date3'].'" AND "'.$_POST['t_date3'].'"';
 }
 else
 {
  /*$SelQuery2 =  'select *,ch.book_id,b.book_name,b.author from `check_out_in_history` ch left join `book` b on b.id =ch.book_id  where ch.member_id ="'.$_SESSION['user_id'].'" and ch.check_out_date between "'.$tdate.'" and "'.$tdate.'" and ch.status="0"';*/
   $SelQuery2 =  'select *,ch.book_id,b.book_name,b.author from `check_out_in_history` ch left join `book` b on b.id =ch.book_id  where ch.member_id ="'.$_SESSION['user_id'].'" and ch.status="0"';
 
  // $SelQuery2 = 'SELECT * FROM check_out_in_history WHERE status="0" AND member_id="'.$_SESSION['user_id'].'"';
   
 }
  $SerDetail		= $this->ExecuteQuery($SelQuery2, 'select');//print_r($SerDetail);
  $objSmarty->assign('SerDetail', $SerDetail);
 }
 /***************************************************************************************************************************/
 function profile_book()
 {global $objSmarty;
 
$SelQuery2 = "select *,cm.order_id,cm.member_id,cm.member_name,cm.total_reading_charges,cm.delivery_charges,cm.total_charges,cm.order_status from `customer_orders_master` cm left join `customer_orders_details` cd on cm.order_id =cd.order_id where cm.order_id='".$_GET['order_id']."' and cm.member_id='".$_SESSION['user_id']."' ";
 
  // $SelQuery2 = 'SELECT * FROM customer_orders_master WHERE record_status="1" AND submit_status="1" AND member_id="'.$_SESSION['user_id'].'" AND order_status="Pending"';
    $SerDetail		= $this->ExecuteQuery($SelQuery2, 'select');
  $objSmarty->assign('SerDetail', $SerDetail);
 }
 /******************************My Profile List********************************************************************************/
 function profile_myorders()
 {global $objSmarty;
 
//  $SelQuery2 = "select *,cm.order_id,cm.member_id,cm.member_name,cm.total_reading_charges,cm.delivery_charges,cm.total_charges from `customer_orders_master` cm left join `customer_orders_details` cd on cm.order_id =cd.order_id where cm.order_id=cd.order_id";
 if((isset($_POST['f_date'])) && (isset($_POST['t_date'])))
 {
  $SelQuery2 = 'SELECT * FROM customer_orders_master WHERE record_status="1" AND member_id="'.$_SESSION['user_id'].'" AND date_of_order BETWEEN "'.$_POST['f_date'].'" AND "'.$_POST['t_date'].'" ORDER BY order_id DESC';
 }
 else
 {
   $SelQuery2 = 'SELECT * FROM customer_orders_master WHERE record_status="1" AND member_id="'.$_SESSION['user_id'].'" ORDER BY order_id DESC';
    
 }
 $SerDetail3		= $this->ExecuteQuery($SelQuery2, 'select');
  $objSmarty->assign('SerDetail3', $SerDetail3);//print_r($SerDetail3);
 }
/******************************My Profile List********************************************************************************/
 function profile_checkin()
 {global $objSmarty;
 
//$SelQuery2 = "select *,cm.order_id,cm.member_id,cm.member_name,cm.total_reading_charges,cm.delivery_charges,cm.total_charges from `customer_orders_master` cm left join `customer_orders_details` cd on cm.order_id =cd.order_id where cm.order_id=cd.order_id and cm.order_status='Delivered'";
 $tdate=date("Y-m-d");
if((isset($_POST['f_date2'])) && (isset($_POST['t_date2'])))
 {
  //$SelQuery2 = 'SELECT * FROM check_out_in_history WHERE status="1" AND member_id="'.$_SESSION['user_id'].'" AND check_in_date BETWEEN "'.$_POST['f_date3'].'" AND "'.$_POST['t_date3'].'"';
  $SelQuery2 =  'select *,ch.book_id,b.book_name,b.author from `check_out_in_history` ch left join `book` b on b.id =ch.book_id  where ch.member_id ="'.$_SESSION['user_id'].'" and ch.actual_check_in_date between "'.$_POST['f_date2'].'" and "'.$_POST['t_date2'].'" and ch.status="1" order by actual_check_in_date desc';
 }
 else
 {
 $SelQuery2 =  'select *,ch.book_id,b.book_name,b.author from `check_out_in_history` ch left join `book` b on b.id =ch.book_id  where ch.member_id ="'.$_SESSION['user_id'].'" and  ch.actual_check_in_date between "'.$tdate.'" and "'.$tdate.'" and  ch.status="1" order by actual_check_in_date desc';
  // $SelQuery2 = 'SELECT * FROM check_out_in_history WHERE status="1" AND member_id="'.$_SESSION['user_id'].'"';
   
 }
 //echo $SelQuery2;
 $SerDetail4		= $this->ExecuteQuery($SelQuery2, 'select');
  $objSmarty->assign('SerDetail4', $SerDetail4);
 }
  /******************************My Profile List********************************************************************************/
 function profile_reserved()
 {global $objSmarty;
 
//$SelQuery2 = "select *,cm.order_id,cm.member_id,cm.member_name,cm.total_reading_charges,cm.delivery_charges,cm.total_charges from `customer_orders_master` cm left join `customer_orders_details` cd on cm.order_id =cd.order_id where cm.order_id=cd.order_id and cm.order_status='Delivered'";
if((isset($_POST['f_date4'])) && (isset($_POST['t_date4'])))
 {/*'select *,ch.book_id,br.book_id,b.book_name from `check_out_in_history` ch left join `book_receipt` br on ch.book_id =br.book_id left join `book` b on b.id =ch.book_id  where br.taken_by="'.$_SESSION['user_id'].'" and ch.member_id ="'.$_SESSION['user_id'].'" and ch.status="0"'*/
  $SelQuery2 = 'SELECT *,br.book_id,be.book_status,be.branch_name,b.book_name,b.author FROM book_reserved br LEFT JOIN `book_receipt` be ON be.book_id =br.book_id LEFT JOIN `book` b ON b.id =br.book_id WHERE br.status="0" AND br.member_id="'.$_SESSION['user_id'].'" AND br.reserved_date BETWEEN "'.$_POST['f_date4'].'" AND "'.$_POST['t_date4'].'" AND be.branch_name="'.$_SESSION['branchname'].'" GROUP BY br.book_id';
 }
 else
 {
   //$SelQuery2 = 'SELECT * FROM book_reserved WHERE status="0" AND member_id="'.$_SESSION['user_id'].'"';
  $SelQuery2 = 'SELECT *,br.book_id,be.book_status,be.branch_name,b.book_name,b.author FROM book_reserved br LEFT JOIN `book_receipt` be ON be.book_id =br.book_id LEFT JOIN `book` b ON b.id =br.book_id WHERE br.status="0" AND br.member_id="'.$_SESSION['user_id'].'" AND be.branch_name="'.$_SESSION['branchname'].'" GROUP BY br.book_id';
   
 }
 $SerDetailR		= $this->ExecuteQuery($SelQuery2, 'select');
  $objSmarty->assign('SerDetailR', $SerDetailR);
 }
 /****************************************************************************************************/
 function orderBook_details()
 { global $objSmarty;
 $SelQuery4 = "select *,cm.order_id,cm.member_id,cm.member_name,cm.total_reading_charges,cm.delivery_charges,cm.total_charges from `customer_orders_master` cm left join `customer_orders_details` cd on cm.order_id =cd.order_id where cm.order_id=cd.order_id and cm.order_status='Delivered'";
 
		//	 $SelQuery4		= "SELECT * FROM `customer_orders_details` WHERE status='0' AND order_id ='".$_GET['order_id']."' ";
			 $SerDetail		= $this->ExecuteQuery($SelQuery4, 'select');
             $objSmarty->assign('SerDetail', $SerDetail);
 
 }
  /****************************************************************************************************/
 function profile_account()
 { global $objSmarty;
			 $SelQuery4		= "SELECT * FROM `members` WHERE status='0' AND id ='".$_SESSION['user_id']."' ";
			 $SerDetail5		= $this->ExecuteQuery($SelQuery4, 'select');//print_r($SerDetail5);
             $objSmarty->assign('SerDetail5', $SerDetail5);
 
 }
 /****************************************************************************************************/
 function about_image()
 { global $objSmarty;
			 $SelQuery4		= "SELECT * FROM `about_us` WHERE status='1'";
			 $SerDetail6		= $this->ExecuteQuery($SelQuery4, 'select');//print_r($SerDetail6);
             $objSmarty->assign('SerDetail6', $SerDetail6);
 
 }
  /****************************************************************************************************/
 function team_member()
 { global $objSmarty;
			 $SelQuery14		= "SELECT * FROM `team_member` WHERE NewStatus='1'";
			 $SerDetail7		= $this->ExecuteQuery($SelQuery14, 'select');//print_r($SerDetail6);
             $objSmarty->assign('SerDetail7', $SerDetail7);
 
 }
 }
 
?>


