<?php
//mysql_connect("localhost","root","") or die("Error1:".mysql_error());
//mysql_select_db("buda_hotel_dbms") or die("Error2:".mysql_error());
class connect_class{

     public  $dbcon;
     public  $host="localhost";
     public  $dbname="aiderste_hotel_dbms";
      public  $user="aiderste_aiderstech";
      public  $pwd="Aid@2022_2023";
     //public  $user="root";
    // public  $pwd="";
    // public  $port="3308";


                                      //FUNCTION FOR DATABASE CONNECTION GOES HERE
 
function __construct(){
	
			 //  $this->dbcon = new PDO("mysql:dbname=$this->dbname;host=$this->host;$this->port",$this->user,$this->pwd);
            $this->dbcon = new PDO("mysql:dbname=$this->dbname;host=$this->host;",$this->user,$this->pwd);
          
}
                        /////////////////////////////////////////////////////////////
///////////////SELECT * FROM `` WHERE 1/////////////////////POST ADVERTISEMENT HERE///////////////////////////////////////////////////////////
          ///////////////SAVING ROOM DATA TO THE DATABASE GOES HERE
////////////////////////////////////////////////////////////////////
	           ///////////////SAVING ROOM DATA EDITING TO THE DATABASE GOES HERE

function addHotel($hnm,$ownerid,$hname,$category,$phoneno, $email,$pobox,$district,$country, $street ,$ward, $region,$popularDistination){
	
  
try{
	
	$Qr=$this->dbcon->prepare("insert into hotel (hotel_id, owner_id,hname,category, country,city,ltown_city,lstreet_vil,phoneno ,paddress,email,popularDistination) values(?,?,?,?,?,?,?,?,?,?,?,?)") ;
	$data=array($hnm,$ownerid,$hname,$category,$country,$region,$district,$street,$phoneno,$pobox,$email,$popularDistination);
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {
          return $Qr="Changes successfully saved!..";
	 }
	 else
	 {
	 	  return  $Qr->ErrorInfo();//="Changes not saved resubmit the form!..";
	 }

}
catch(PDOException $ex){
	$ex->getMessage();
}
}
            


                                      // COST  VALIDATION END
  function getUsers($userid){
	try{
		$ownerH=$this->dbcon->prepare("select * from superuser where userid=:id");
		 $ownerH->bindParam(":id",$userid);
		//$ownerH->bindParam(":Id",$accountId);   
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
                              ////////////////////////////////
	                                    //  HOTEL SERVICES
function vTname($tname) {
	 
	
		if(preg_match("/^[\sA-Za-z]+$/",$tname)  && $tname!=""){
			return 	$tname;
		} 
		 else{
		 	return false;
		 }
}  


function eTname($tname) {
	 if($sname=="")
	               {

	 	return $tname="Description required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z]+$/",$tname))
	              {
		 
        return $tname= "Error in typing description!";
		          }
	 else         {
		          	return;
		          }
	           }                           


                                                                //FUNCTION FOR VISITORS OF HOTEL HERE
function getHotelAdvImages($hnm){
	try{
		$ownerH=$this->dbcon->prepare("select * from advertisement where  hotel_id =:hID order by timePosted desc");
		$ownerH->bindParam(":hID",$hnm);  
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}



//////////////////////////////////////////////////////////////
//////////////////////////  ROOM IMAGES GOES HERE /////////////////
function addAdPostAndImg($sname,$hnm,$fn,$tmp_name,$tname){ 

 $site="hotelAdvertisement/".$fn; 
 $ext = strtolower($site);

  $info = getimagesize($tmp_name);

  if ($info['mime'] == 'image/jpeg')
  {
      
    $image = imagecreatefromjpeg($tmp_name);
  }
  elseif ($info['mime'] == 'image/gif') 
  {
    $image = imagecreatefromgif($tmp_name);
  }
  elseif ($info['mime'] == 'image/png')
  { 
    $image = imagecreatefrompng($tmp_name);
  }
 //imagejpeg($image, $site, 1);
 $data=array($hnm,$sname,$site,$tname);
   try{
	  $Qr=$this->dbcon->prepare("insert into advertisement(hotel_id,content,directory,title) values(?,?,?,?)");
	  $Qr->execute($data);
	  if($Qr->rowCount()>0)
	  {

          //move_uploaded_file($tmp_name,$site);
        imagejpeg($image, $site, 1);
          return $Re="Posted successfully!..";


	  }
	  else
	  {
	 	  return  $Re="Error in post!..";
	  }

    }
    catch(PDOException $ex){
	$ex->getMessage();
    }
   }

   function vImageAdvExist($fn) {
	 
	if(file_exists("hotelAdvertisement/".$fn))
	{
      
      return false;
		  
    }
	else
	 {
	  return true; 
	 }

     } 


function eImageAdvExist($fn) 
 {
	 
	
if(file_exists("hotelAdvertisement/".$fn))
	{
      
      return  $exs= "The ".$fn." already exist, please rename the image!..";
  
    }
	 else
    {
	 return ;
    }


}  
////////////////////POST ONLY ADV WITHOUT IMAGES/////////////////
   ///////////////////////////////////////////////////

   //////////////////////////////////////////////////////////
function addAdPostOnly($sname,$hnm,$tname){ 
  
 $data=array($hnm,$sname,$tname);
   try{
	  $Qr=$this->dbcon->prepare("insert into advertisement(hotel_id,content,title) values(?,?,?)");
	  $Qr->execute($data);
	  if($Qr->rowCount()>0)
	  {
          return $Re="Posted successfully!..";
	  }
	  else
	  {
	 	  return  $Re="Error in post!..";
	  }

    }
    catch(PDOException $ex){
	$ex->getMessage();
    }
   } 
   ///////////////////////////////




function eAname($sname) {
	 if($sname=="")
	               {

	 	return $sname="Advertisement  required!..";
	               }
	 
	 else         {
		          	return;
		          }
	           } 

	           	                                    //  HOTEL SERVICES
function vAname($sname) {
	 
	
		if($sname!=""){
			return 	$sname;
		} 
		 else{
		 	return false;
		 }
}   


/////////////////////////EDIT HOTEL PROFILE HERE////////////////////////                         

///////////////////////////////////////////////////////////////////////
	           ///////////////SAVING ROOM DATA EDITING TO THE DATABASE GOES HERE

function updateHotelInfo($ownID,$hnm,$hname,$phoneno, $email,$pobox,$district,$country, $street ,$ward, $region,$popularDistination){
	
  
try{
	
	$Qr=$this->dbcon->prepare("update hotel set hname=?, country=?,city=?,ltown_city=?,lstreet_vil=?,phoneno=? ,paddress=?,email=?,popularDistination=? where hotel_id=? and owner_id=?");
	$data=array($hname,$country,$region,$district,$street,$phoneno,$pobox,$email,$popularDistination,$hnm,$ownID);
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {
          return $Re="Changes successfully saved!..";
	 }
	 else
	 {
	 	  return  $Re="Changes not saved resubmit the form!..";
	 }

}
catch(PDOException $ex){
	$ex->getMessage();
}
}

   //POPULAR DESTINATION VALIDATION

function vPopularDistination($popularDistination) {
	 
	
		if(preg_match("/^[\sA-Za-z]+$/",$popularDistination)  && $popularDistination!=""){
			return 	$popularDistination;
		} 
		 else{
		 	return false;
		 }
}  


function ePopularDistination($popularDistination) {
	 if($popularDistination=="")
	               {

	 	return $popularDistination="Popular destination required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z]+$/",$popularDistination))
	              {
		 
        return $popularDistination= "Popular destination typed with error!";
		          }
	 else         {
		          	return;
		          }
	 

}
  ///////////////////////////////////HOTEL NAME VALIDATION////////////////////////////////
                       /////////////////////////////////////
/////////////////////////////////////////////////////////////////
function vHname($hname) {
	 
	
		if(preg_match("/^[\sA-Za-z]+$/",$hname)  && $hname!=""){
			return 	$hname;
		} 
		 else{
		 	return false;
		 }
}  


function eHname($hname) {
	 if($hname=="")
	               {

	 	return $hname="Hotel name required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z]+$/",$hname))
	              {
		 
        return $hname= "Hotel name typed with error!";
		          }
	 else         {
		          	return;
		          }
	 

}





//////////////////
 ////////////////////////HOTEL INCOME SOURCE/////////////////////
                                           //FUNCTION FOR OWNED HOTEL HERE


/////GET GENERAL REPORT HOTEL INCOME////////////////

///////////////RANGE DATE //////////////////
function OtherIncomesByDateRange($hnm,$arrived_on,$edate){
	try{
		$ownerH=$this->dbcon->prepare("select * from hotelincome where  dateearned between ? and ? and hotelid=?");
		$data= array($arrived_on,$edate,$hnm); 
	    $ownerH->execute($data); 
		  
		return $ownerH; 

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}

///////////////////////

function OtherIncomesByDate($hnm,$arrived_on){
	try{
		$ownerH=$this->dbcon->prepare("select * from hotelincome where  dateearned =:id and  hotelid=:hID");
		//$data= array($arrived_on,$edate,$hnm);  
		$ownerH->bindParam(":id",$arrived_on);
        $ownerH->bindParam(":hID",$hnm);    
	    $ownerH->execute(); 
		  
		return $ownerH; 

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}

///////////////////////
function getHotelIncomes($hnm){
	try{
		$ownerH=$this->dbcon->prepare("select * from recept where hotel_id=:hID");
		$ownerH->bindParam(":hID",$hnm);
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}


                                           //FUNCTION FOR OWNED HOTEL HERE

///////////////////////
function getConfirmCode($code){
	try{
		$ownerH=$this->dbcon->prepare("select * from  paymentcode where code=:hID");
		$ownerH->bindParam(":hID",$code);
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}


                                           //FUNCTION FOR OWNED HOTEL HERE


function getHotelOtherIncomes($hnm){
	try{
		$ownerH=$this->dbcon->prepare("select * from hotelincome where hotelid=:hID");
		$ownerH->bindParam(":hID",$hnm);
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}



                                            //FUNCTION FOR OTHER HOTEL HERE
 



///////////////////////////////////////// GET HOTEL EXPENSES //////////////////////
///////////////////////////////////////////////////////////////////////////////////
///////////////////////
function getHotelExpenses($hnm){
	try{
		$ownerH=$this->dbcon->prepare("select * from expenses where hotel_id=:hID");
		$ownerH->bindParam(":hID",$hnm);
	    $ownerH->execute(); 
		  
		return $ownerH;

	  }
	  catch(PDOException $xc){
	  $xc->getMessage();
	  }
}


                                           //FUNCTION FOR OWNED HOTEL HERE

///////////////RANGE DATE //////////////////
function getHotelExpenseByDateRange($hnm,$arrived_on,$edate){
	try{
		$ownerH=$this->dbcon->prepare("select * from expenses where exp_date between ? and ? and hotel_id=?");
		$data= array($arrived_on,$edate,$hnm);   
	    $ownerH->execute($data); 
		  
		return $ownerH; 

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}

////////////////////////FILTER BY DATE////////////////////
//////////////////////////////////////////////////////
function getHotelExpenseByDate($hnm,$arrived_on){
	try{
		$ownerH=$this->dbcon->prepare("select * from expenses where  exp_date=? and hotel_id=?");
		$data= array($arrived_on,$hnm);  
		//$ownerH->bindParam(":hID",$hnm);  
	    $ownerH->execute($data); 
		  
		return $ownerH; 

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}


     //////////////////////////// VISITORS PROFILE ////////////////
                          //////////////////////////

//////////////                                  FUNCTION FOR VALIDATING  VISITORS IN INFO //////////////
                      /////////////////////////
///////////////////////////////////GET IMAGES FOR HOTEL SERVICES GOES GOES HERE ///////////////////
                     //////////////////////////////////////////////

                                                                //FUNCTION FOR VISITORS OF HOTEL HERE
function getHotelImages($hnm){
	try{
		$ownerH=$this->dbcon->prepare("select * from images where  hotelid=:hID");
		$ownerH->bindParam(":hID",$hnm);  
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}

///////////////PRESENT CURRENT HOTEL PROFILE IMAGE/////////////////
/////////////////////////////////////////////////
                                                                //FUNCTION FOR VISITORS OF HOTEL HERE
function setHotelProfileImages($hnm,$profile){
	try{
		$current="current";
		$ownerH=$this->dbcon->prepare("select * from images where  hotelid=:hID and profileImage=:img");
		$ownerH->bindParam(":hID",$hnm);
		$ownerH->bindParam(":img",$current);  
	    $ownerH->execute();

	     if ($ownerH->rowCount()>0)
	         {
	             $remove="NULL";
	              $data=array($remove,$hnm,$current);

	              $ownerR=$this->dbcon->prepare("update images set profileImage=? where  hotelid=? and profileImage=?");
		    
	              $ownerR->execute($data); 
	           if ($ownerR->rowCount()>0)
	            {

	      
	                     $data=array($current,$hnm,$profile);

	                     $ownerU=$this->dbcon->prepare("update images set profileImage=? where  hotelid=? and directory=?");
		    
	                     $ownerU->execute($data);

	                        if ($ownerU->rowCount()>0)
	                             {
	                                return $ownerU="Successfully set!..";
	                             }
	                        else
	                            {
	      	                    return $ownerU="Error occured!..";
	                            }

	     	
	           }
	           else
	           {
	     	   return $ownerR="Failed to reset current profile";
	           }
	         }

	     else
	     {

	          $current="current";
	          $data=array($current,$hnm,$profile);

	          $ownerU=$this->dbcon->prepare("update images set profileImage=? where  hotelid=? and directory=?");
		    
	          $ownerU->execute($data);
	       if ($ownerU->rowCount()>0)
	          {
	            return $ownerU="Successfully set!..";
	          }
	       else
	          {
	      	  return $ownerU="Error occured!..";
	          }
	     }
	     }
		  
		

	//}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}


////////////////////////////////////////////////////////////////////
///////////////////////GET HOTEL PROFILE IMAGES//////////////////////
function getHotelProfileImages($hnm){
	try{
		
		$current="current";
		$ownerH=$this->dbcon->prepare("select * from images where  hotelid=:hID and profileImage=:img");
		$ownerH->bindParam(":hID",$hnm);
		$ownerH->bindParam(":img",$current);  
	    $ownerH->execute();

	    return $ownerH;
	   }
		  
	 
	catch(PDOException $xc){
		$xc->getMessage();
	}
}



//////////////////////////////////////////////////////////////
//////////////////////////  ROOM IMAGES GOES HERE /////////////////
///////////////////////////////

     //////////////////////////// IMAGES ////////////////

                                                                //FUNCTION FOR VISITORS OF HOTEL HERE
function getRoomImages($hnm){
	try{
		$ownerH=$this->dbcon->prepare("select * from roomimages where  hotelid=:hID");
		$ownerH->bindParam(":hID",$hnm);  
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
            //////////////////////////// IMAGES ////////////////

                                                                //FUNCTION FOR VISITORS OF HOTEL HERE
function getGivenRoomImagesView($hnm,$roomid){
	try{
		$ownerH=$this->dbcon->prepare("select * from roomimages where  hotelid=:hID and room_no=:rid");
		$ownerH->bindParam(":hID",$hnm);
		$ownerH->bindParam(":rid",$roomid);  
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
         
  







                        ///HOTEL PLACE VISITOR ARRIVED FROM GOES HERE
function vDepartto($departto) {
	 
	
		if(preg_match("/^[\sA-Za-z0-9]+$/",$departto)  && $departto!=""){
			return 	$departto;
		} 
		 else{
		 	return false;
		 }
}  


function eDepartto($departto) {
	 if($departto=="")
	               {

	 	return $departto="Where you depart to required!..";
	               }
	
	 else if(!preg_match("/^[A-Za-z0-9]+$/",$departto))
	              {
		 
        return $departto= "Error in typing where you depart to!";
		          }
	 else         {
		          	return;
		          }
	           } 

	           //////////////////////////////////////


	              /////////////////

///HOTEL VISITORS  INFO GOES HERE


function vCarregno($carregno) {
	 
	if ($carregno!="") {
		if(preg_match("/^[A-Za-z0-9]+$/",$carregno)){
			return 	$carregno;
		}  
		
		else
		{
		 	return false;
		}
}  
}




function eCarregno($carregno) {
	 if ($carregno=="") {
	 	 return;
	 }

	 else{
	if ($carregno!="") {
		if(preg_match("/^[A-Za-z0-9]+$/",$carregno)){
			return;
		}  
		
		else
		{
		 	
        return $carregno= "Error in typing n!";
		  }
		}
}  
}



 
                    ///////////////////////////


              ///////////////////////////// PAYMENT VALIDATION//////////////////////////////
                               ////////////////////////////////////



function vNoguest($noguest) {
	 
	
		if(preg_match("/^[0-9]+$/",$noguest)  && $noguest!=""){
			return 	$noguest;
		} 
		 else{
		 	return false;
		 }
}  


function eNoguest($noguest) {
	 if($noguest=="")
	               {

	 	return $noguest="Number of guest required!..";
	               }
	
	 else if(!preg_match("/^[0-9]+$/",$noguest))
	              {
		 
        return $noguest= "Error in typing number of guest!";
		          }
	 else         {
		          	return;
		          }
	           } 

                    ///////////////////////////

////////////////////////////   DATE OF DEPART///////////////////



function vDeparton($departon) {
	 
	
		if($departon!=""){
			return 	$departon;
		} 
		 else{
		 	return false;
		 }
}  


function eDeparton($departon) {
	 if($departon=="")
	               {

	 	return $departon="Date of depart required!..";
	               }
	 
	 else         {
		          	return;
		          }
	           } 


                        ///HOTEL VISITORS  INFO GOES HERE

              ///////////////////////////// PAYMENT VALIDATION//////////////////////////////
                               ////////////////////////////////////



function vPayment($payment) {
	 
	
		if(preg_match("/^[0-9]+$/",$payment)  && $payment!=""){
			return 	$payment;
		} 
		 else{
		 	return false;
		 }
}  


function ePayment($payment) {
	 if($payment=="")
	               {

	 	return $payment="Payment required!..";
	               }
	
	 else if(!preg_match("/^[0-9]+$/",$payment))
	              {
		 
        return $payment= "Error in typing payment!";
		          }
	 else         {
		          	return;
		          }
	           } 

                    ///////////////////////////

	           /////////////////


                        ///HOTEL PLACE VISITOR ARRIVED FROM GOES HERE
function vArrivedfrom($arrivedfrom) {
	 
	
		if(preg_match("/^[\sA-Za-z0-9]+$/",$arrivedfrom)  && $arrivedfrom!=""){
			return 	$arrivedfrom;
		} 
		 else{
		 	return false;
		 }
}  


function eArrivedfrom($arrivedfrom) {
	 if($arrivedfrom=="")
	               {

	 	return $arrivedfrom="Where youa rrived from required!..";
	               }
	
	 else if(!preg_match("/^[A-Za-z0-9]+$/",$arrivedfrom))
	              {
		 
        return $arrivedfrom= "Error in typing where you came from!";
		          }
	 else         {
		          	return;
		          }
	           } 

	           //////////////////////////////////////


	              /////////////////


                        ///HOTEL PLACE VISITOR ARRIVED FROM GOES HERE
function vArrivedon($arrivedon) {
	 
	
		if($arrivedon!=""){
			return 	$arrivedon;
		} 
		 else{
		 	return false;
		 }
}  


function eArrivedon($arrivedon) 
           {
	 if($arrivedon=="")
	        {

	 	return $arrivedon="Date of arrival required!..";
	      }
	             
	 else {
		   	return;
		   }
	     } 






/////////////////////////////////////// FUNCTION THAT SAVING ///////////////////////
	           ///////////////////////////////////////////
/*

 receipNo 	 
	cust_id 	 
	hotel_id 	 Primary 	Unique 	Index 	Fulltext
	roomID		 	 	 	 	 	 	 	 	 		 	 		 	


*/

function addVisitors($hnm,$roomid,$accountId,$arrivedon,$arrivedfrom,$departon,$departto,$noguest,$payment,$carregno){
	
      
     //$checkin=Date("hh:mm:ss");
     $rec=Date("Ymdhis");
	 $data=array($rec,$hnm,$roomid,$accountId,$arrivedon,$arrivedfrom,$departon,$departto,$noguest,$payment,$carregno);
try{
	
	$Qr=$this->dbcon->prepare("insert into  recept(recept_no,hotel_id,room_id,cust_id,arrived_on,arivedf,departure_on,departure_to,nofguest,cash_amount,car_reg) values(?,?,?,?,?,?,?,?,?,?,?)");
	$Qr->execute($data);
     if($Qr->rowCount()>0)
	 {
    $data=array($rec,$hnm,$roomid,$accountId);

	$Qc=$this->dbcon->prepare("insert into  customer(receipNo,hotel_id,roomID,cust_id) values(?,?,?,?)");
	$Qc->execute($data);


	 if($Qc->rowCount()>0)
	 {
          return $Re="Information submitted successfully!..";
	 }
	 else
	 {
	 	  return  $Re=$Qc->ErrorInfo();//"Data not saved resubmit the form!..";
	 }
	}
	 else
	 {
	 	  return  $Re=$Qr->ErrorInfo();//"Data not saved resubmit the form!..";
	 }

}
catch(PDOException $ex){
	$ex->getMessage();
}
} 
     

//////////////////////////////////////ADD HOTEL EMPLOYEE HERE//////////////////
 /////////////////////////////////HHHHHHHHHHHHHHHHH///////////////////

                        ///HOTEL VISITORS  INFO GOES HERE



                        ///HOTEL VISITORS  INFO GOES HERE




//////////////                                  FUNCTION FOR VALIDATING  EMPLOYEE INFO //////////////



	           /////////


                        ///HOTEL EMPLOYEES TITLE GOES HERE



function vSalary($salary) {
	 
	
		if(preg_match("/^[0-9]+$/",$salary)  && $salary!=""){
			return 	$salary;
		} 
		 else{
		 	return false;
		 }
}  


function eSalary($salary) {
	 if($salary=="")
	               {

	 	return $salary="Salary required!..";
	               }
	
	 else if(!preg_match("/^[0-9]+$/",$salary))
	              {
		 
        return $salary= "Error in typing salary!";
		          }
	 else         {
		          	return;
		          }
	           } 


                        ///HOTEL EMPLOYEES SALARY GOES HERE
function vJobtitle($jobtitle) {
	 
	
		if(preg_match("/^[\sA-Za-z0-9]+$/",$jobtitle)  && $jobtitle!=""){
			return 	$jobtitle;
		} 
		 else{
		 	return false;
		 }
}  


function eJobtitle($jobtitle) {
	 if($jobtitle=="")
	               {

	 	return $jobtitle="Jobtitle required!..";
	               }
	
	 else if(!preg_match("/^[A-Za-z0-9]+$/",$jobtitle))
	              {
		 
        return $jobtitle= "Error in typing jobtitle!";
		          }
	 else         {
		          	return;
		          }
	           } 


 /////////////////////////////////////// FUNCTION THAT SAVING ///////////////////////
	           ///////////////////////////////////////////


function addRegisterEmployee($jobtitle,$accountId,$salary,$hnm){
	
 
	 $data=array($jobtitle,$salary,$accountId,$hnm);
try{
	
	$Qr=$this->dbcon->prepare("insert into  hotelworkers(jobtitle,salary,accountId,hotelid) values(?,?,?,?)");
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {
          return $Re="Information submitted successfully!..";
	 }
	 else
	 {
	 	  return  $Re="Data not saved resubmit the form!..";
	 }

}
catch(PDOException $ex){
	$ex->getMessage();
}
} 


                              ///////////////////////////

                           ///////////////////   EDIT EMPLOYEE DETAIL ///////////////////

                              ///////////////////////////////

            //////////////////////
	           ///////////////SAVING ROOM DATA EDITING TO THE DATABASE GOES HERE

function updateEmployeeIfo($jobtitle,$accountId,$salary, $hnm){
	
  
try{
	
	$Qr=$this->dbcon->prepare("update  hotelworkers set salary=? ,jobtitle =? where hotelid=? and accountId=?");
	$Qr->execute(array($salary,$jobtitle,$hnm,$accountId));
	 if($Qr)
	 {
          return $Re="Changes successfully saved!..";
	 }
	 else
	 {
	 	  return  $Re="Changes not saved resubmit the form!..";
	 }

}
catch(PDOException $ex){
	$ex->getMessage();
}
}











///////////////////////////////////GET CUSTOMER RECEIPT GOES HERE ///////////////////
                     //////////////////////////////////////////////

                                                                //FUNCTION FOR VISITORS OF HOTEL HERE
function getHotelVisitorsReceipt($hnm){
	try{
		$ownerH=$this->dbcon->prepare("select * from recept where  hotel_id=:hID");
		$ownerH->bindParam(":hID",$hnm);  
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
///////////////////////////////GET RECEIPT FILTER BY DATE OF ARIVAL//////////

                                                                //FUNCTION FOR VISITORS OF HOTEL HERE
function getHotelVisitorsReceiptByDate($hnm,$arrived_on){
	try{
		$ownerH=$this->dbcon->prepare("select * from recept where arrived_on=:Id and hotel_id=:hID");
		$ownerH->bindParam(":Id",$arrived_on);  
		$ownerH->bindParam(":hID",$hnm);  
	    $ownerH->execute(); 
		  
		return $ownerH;
		

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
///////////////RANGE DATE //////////////////
function getHotelVisitorsReceiptByDateRange($hnm,$arrived_on,$edate){
	try{
		$ownerH=$this->dbcon->prepare("select * from recept where  arrived_on between ? and ? and hotel_id=?");
		$data= array($arrived_on,$edate,$hnm);  
		//$ownerH->bindParam(":hID",$hnm);  
	    $ownerH->execute($data); 
		  
		return $ownerH; 

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}

     //////////////////////////// VISITORS PROFILE ////////////////
                          //////////////////////////

function getHotelVisitorsProfile($hnm,$accountId){
	try{
		$ownerH=$this->dbcon->prepare("select * from account_owner where owner_id=:Id");
		//$ownerH->bindParam(":hID",$hnm);
		$ownerH->bindParam(":Id",$accountId);   
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}





                                              ///////////////////////////////////


                                               //////////////////////////
                                           //FUNCTION FOR WORKERS OF HOTEL HERE
function getHotelWorkersDetail($accountId){
	try{
		$ownerH=$this->dbcon->prepare("select * from  account_owner where owner_id=:Id");
		$ownerH->bindParam(":Id",$accountId); 
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
                                  ////////////////////////
                                  ///////////////////////

                                           //FUNCTION FOR WORKERS OF HOTEL HERE
function getHotelWorkersForEdit($accountId,$hnm){
	try{
		$ownerH=$this->dbcon->prepare("select * from hotelworkers where  hotelid=:hID and accountId=:Id");
		$ownerH->bindParam(":hID",$hnm);
		$ownerH->bindParam(":Id",$accountId);  
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}

                                           //FUNCTION FOR WORKERS OF HOTEL HERE
function getHotelWorkers($hnm){
	try{
		$ownerH=$this->dbcon->prepare("select * from hotelworkers where  hotelid=:hID");
		$ownerH->bindParam(":hID",$hnm);  
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}




//////////////////////////////////////ADD HOTEL EMPLOYEE HERE//////////////////
 /////////////////////////////////HHHHHHHHHHHHHHHHH///////////////////


                        ///HOTEL EMPLOYEES GOES HERE
function vAccountId($accountId) {
	 
	
		if(preg_match("/^[\sA-Za-z0-9]+$/",$accountId)  && $accountId!=""){
			return 	$accountId;
		} 
		 else{
		 	return false;
		 }
}  


function eAccountId($accountId) {
	 if($accountId=="")
	               {

	 	return $accountId="Account id required!..";
	               }
	
	 else if(!preg_match("/^[A-Za-z0-9]+$/",$accountId))
	              {
		 
        return $accountId= "Error in typing account id!";
		          }
	 else         {
		          	return;
		          }
	           }      



     function checkIdOfUserIfExist($ownerid){
	try{
		$Rs=$this->dbcon->prepare("select * from account_owner where own_regno=:id");
		$Rs->bindParam(":id",$ownerid);
	    $Rs->execute(); 
		  
		return $Rs;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
            //////////////////////


     function checkIdOfemployyeeExist($accountId){
	try{
		$Rs=$this->dbcon->prepare("select * from account_owner where owner_id=:id");
		$Rs->bindParam(":id",$accountId);
	    $Rs->execute(); 
		  
		return $Rs;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
            //////////////////////


 



     function checkIdForSameEmpExist($accountId){
	try{
		$Rs=$this->dbcon->prepare("select * from hotelworkers where accountId=:id");
		$Rs->bindParam(":id",$accountId);
	    $Rs->execute(); 
		  
		return $Rs;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
            //////////////////////



 

 


                         ///ROUTE REGISTRATION FORM
	                                  ////////////////////////////////
	                                    //  ROUTE DETAIL
                                      //ROUTE STARTING LOCATION


                 //////////////////////////////////

function vStart($start) {
	 
	
		if(preg_match("/^[\sA-Za-z]+$/",$start)  && $start!=""){
			return 	$start;
		} 
		 else{
		 	return false;
		 }
}  


function eStart($start) {
	 if($start=="")
	               {

	 	return $start="Where start required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z]+$/",$start))
	              {
		 
        return $start= "Error in typing starting location of route!";
		          }
	 else         {
		          	return;
		          }
	           }                           



                               ////////////////////////////////
	                                    //  ROUTE DETAIL
function vRlength($rlength) {
	 
	
		if(preg_match("/^[\sA-Za-z0-9]+$/",$rlength)  && $rlength!=""){
			return 	$rlength;
		} 
		 else{
		 	return false;
		 }
}  


function eRlength($rlength) {
	 if($rlength=="")
	               {

	 	return $rlength="Route length required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z0-9]+$/",$rlength))
	              {
		 
        return $rlength= "Error in typing route length!";
		          }
	 else         {
		          	return;
		          }
	           }                           

                               ////////////////////////////////
	                                    //  ROUTE DETAIL
function vRouteId($routeId) {
	 
	
		if(preg_match("/^[A-Za-z0-9]+$/",$routeId)  && $routeId!=""){
			return 	$routeId;
		} 
		 else{
		 	return false;
		 }
}  


function eRouteId($routeId) {
	 if($routeId=="")
	               {

	 	return $routeId="Route id required!..";
	               }
	
	 else if(!preg_match("/^[A-Za-z0-9]+$/",$routeId))
	              {
		 
        return $routeId= "Error in typing route length!";
		          }
	 else         {
		          	return;
		          }
	           }      



                               ////////////////////////////////
	                                    //  ROUTE DIRECTION VIA POINT
function vVia($via) {
	 
	
		if(preg_match("/^[\sA-Za-z]+$/",$via)  && $via!=""){
			return 	$via;
		} 
		 else{
		 	return false;
		 }
}  


function eVia($via) {
	 if($via=="")
	               {

	 	return $viat="Route via point required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z]+$/",$via))
	              {
		 
        return $via= "Route via point typed with error! ";
		          }
	 else         {
		          	return;
		          }
	           }                           
                               ////////////////////////////////
	                                    //  ROUTE DETAIL
function vEnd($end) {
	 
	
		if(preg_match("/^[\sA-Za-z]+$/",$end)  && $end!=""){
			return 	$end;
		} 
		 else{
		 	return false;
		 }
}  


function eEnd($end) {
	 if($end=="")
	               {

	 	return $end="Route destionation required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z]+$/",$end))
	              {
		 
        return $end= "Route destination point!";
		          }
	 else         {
		          	return;
		          }
	           }                           


                               ////////////////////////////////
	                                    //  ROUTE DESTINATION
function vDistance($ldistance) {
	 
	
		if(preg_match("/^[\sA-Za-z0-9]+$/",$ldistance)  && $ldistance!=""){
			return 	$ldistance;
		} 
		 else{
		 	return false;
		 }
}  


function eDistance($ldistance) {
	 if($ldistance=="")
	               {

	 	return $ldistance="Distance from destination to location required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z0-9]+$/",$ldistance))
	              {
		 
        return $ldistance= "Error in typing distance location from destination of route!";
		          }
	 else         {
		          	return;
		          }
	           }        

	           /////////////////////
	           //////////////////ADD ROUTE FUNCTION GOES HERE
	           ///////////////////////                   


function addRoute($start,$rlength,$routeId,$end,$ldistance,$via,$hnm){
	
 
	 $data=array($start,$rlength,$end,$ldistance,$via,$routeId,$hnm);
try{
	
	$Qr=$this->dbcon->prepare("insert into routetohotel(startStation,estimatedDistance,lastStation,ldistance,via,routeId,hotelid) values(?,?,?,?,?,?,?)");
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {
          return $Re="Information submitted successfully!..";
	 }
	 else
	 {
	 	  return  $Re="Data not saved resubmit the form!..";
	 }

}
catch(PDOException $ex){
	$ex->getMessage();
}
} 
                     ///////////////////  UPDATE  ROUTE//////////////

function UpdateRoute($start,$rlength,$routeId,$end,$ldistance,$via,$hnm){
	
 
	 $data=array($start,$rlength,$end,$ldistance,$via,$routeId,$hnm);
try{
	
	$Qr=$this->dbcon->prepare("update routetohotel set startStation=?,estimatedDistance=?,lastStation=?,ldistance =?,via=? where routeId=? and hotelid=?");
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {
          return $Re="Changes saved successfully!..";
	 }
	 else
	 {
	 	  return  $Re="Changes not saved!..";
	 }

}
catch(PDOException $ex){
	$ex->getMessage();
}
} 
///////////////////////DELETE ROUTE///////////////////////
/////////////////////////////////////////////////////////////////
function DeleteRoute($routeId,$hnm){
	
 
	 //$data=array($routeId,$hnm);
try{
	
	$Qr=$this->dbcon->prepare("delete  from routetohotel where routeId=:rid and hotelid=:id");
	$Qr->bindParam(":rid",$routeId);
	$Qr->bindParam(":id",$hnm);
	$Qr->execute();
	 if($Qr->rowCount()>0)
	 {
          return $Re="Record deleted successfully!..";
	 }
	 else
	 {
	 	  return  $Re="Record not deleted!..";
	 }

}
catch(PDOException $ex){
	$ex->getMessage();
}
} 
///////////////////DELETE HOTEL ASS SERVICES//////////////////


///////////////////////DELETE ROUTE///////////////////////
/////////////////////////////////////////////////////////////////
function DeleteEmployee($accountId,$hnm){
	
 
	 //$data=array($routeId,$hnm);
try{
	
	$Qr=$this->dbcon->prepare("delete  from  hotelworkers where accountId=:rid and hotelid=:id");
	$Qr->bindParam(":rid",$accountId);
	$Qr->bindParam(":id",$hnm);
	$Qr->execute();
	 if($Qr->rowCount()>0)
	 {
          return $Re="Record deleted successfully!..";
	 }
	 else
	 {
	 	  return  $Re="Record not deleted!..";
	 }

}
catch(PDOException $ex){
	$ex->getMessage();
}
} 
///////////////////DELETE HOTEL ASS SERVICES//////////////////


///////////////////////DELETE ROUTE///////////////////////
/////////////////////////////////////////////////////////////////
function DeleteRoom($room_no,$hnm){
	
 
	 //$data=array($routeId,$hnm);
try{
	
	$Qr=$this->dbcon->prepare("delete  from room where room_no=:rid and hotel_id=:id");
	$Qr->bindParam(":rid",$room_no);
	$Qr->bindParam(":id",$hnm);
	$Qr->execute();
	 if($Qr->rowCount()>0)
	 {
          return $Re="Record deleted successfully!..";
	 }
	 else
	 {
	 	  return  $Re="Record not deleted!..";
	 }

}
catch(PDOException $ex){
	$ex->getMessage();
}
} 
///////////////////DELETE HOTEL ASS SERVICES//////////////////
//////////////////////////
//////////////////////
//////////////////////////
///////////////////////DELETE ROUTE///////////////////////
/////////////////////////////////////////////////////////////////
function DeleteService($serviceId,$hnm){
	
 
	 //$data=array($routeId,$hnm);
try{
	
	$Qr=$this->dbcon->prepare("delete  from  hotelasssevices where serviceId=:rid and hotelid=:id");
	$Qr->bindParam(":rid",$serviceId);
	$Qr->bindParam(":id",$hnm);
	$Qr->execute();
	 if($Qr->rowCount()>0)
	 {
          return $Re="Record deleted successfully!..";
	 }
	 else
	 {
	 	  return  $Re="Record not deleted!..";
	 }

}
catch(PDOException $ex){
	$ex->getMessage();
}
} 
    


                                      // COST  VALIDATION END

                                      // HOTEL SERVICE VALIDATION END


                        /////////////ROOM REGISTRATION

                        ///ROOM NAME REGISTRATION FORM
function vRname($rname) {
	 
	
		if(preg_match("/^[\sA-Za-z0-9]+$/",$rname)  && $rname!=""){
			return 	$rname;
		} 
		 else{
		 	return false;
		 }
}  


function eRname($rname) {
	 if($rname=="")
	               {

	 	return $rname="Room name required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z0-9]+$/",$rname))
	              {
		 
        return $rname= "Error in typing room!";
		          }
	 else         {
		          	return;
		          }
	           }                           


                                      // ROOM NAME VALIDATION END


	                                   ///CODE FOR HOTEL ASSOCIATED SERVICES 
	           ///////////////////

                ///////////////OTHER SOURCE OF INCOME//////////////////
function vDateearned($dateearned) {
	 
	
		if($dateearned!=""){
			return 	$dateearned;
		} 
		 else{
		 	return false;
		 }
}  



 
function eDateearned($dateearned) {
	 if($dateearned=="")
	               {

	 	return $dateearned="Date required!..";
	               }

    
	 else         {
		          	return;
		          }
	 

}


///////////////////////////

function addIncome($sname,$scost,$dateearned, $hnm){
	
 $date=Date("Ymdhis");
	 $data=array($date,$hnm,$sname,$scost,$dateearned);
try{
	
	$Qr=$this->dbcon->prepare("insert into  hotelincome(incomeId,hotelid,incomeSource,incomeAmount, 	dateearned) values(?,?,?,?,?)");
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {
          return $Re="Information submitted successfully!..";
	 }
	 else
	 {
	 	  return  $Re="Data not saved resubmit the form!..";
	 }

}
catch(PDOException $ex){
	$ex->getMessage();
}
} 
  

/////////////////////// SAVE THE INCOME SOURCE TO DATABASE////////////

                 ////////////////////////////
//////////////////////////EXPENSES///////////////
///////////////////////////

function addExpensesRecord($sname,$scost,$dateearned,$hnm){
	
 $date=Date("Ymdhis");

 $data=array($date,$hnm,$sname,$scost,$dateearned);
   try{
	  $Qr=$this->dbcon->prepare("insert into expenses(expenses_id,hotel_id,exp_purpose,amount,exp_date) values(?,?,?,?,?)");
	  $Qr->execute($data);
	  if($Qr->rowCount()>0)
	  {
          return $Re="Information submitted successfully!..";
	  }
	  else
	  {
	 	  return  $Re=$Qr->ErrorInfo();//"Data not saved resubmit the form!..";
	  }

    }
    catch(PDOException $ex){
	$ex->getMessage();
    }
   } 



//////////////////////

	           	                                    //  HOTEL SERVICES
function vSservice($serviceId) {
	 
	
		if(preg_match("/^[A-Za-z0-9]+$/",$serviceId)  && $serviceId!=""){
			return 	$serviceId;
		} 
		 else{
		 	return false;
		 }
}  


function eSservice($serviceId) {
	 if($serviceId=="")
	               {

	 	return $serviceId="Service id required!..";
	               }
	
	 else if(!preg_match("/^[A-Za-z0-9]+$/",$serviceId))
	              {
		 
        return $serviceId= "Error in typing service id!";
		          }
	 else         {
		          	return;
		          }
	           }                           








	                                  ////////////////////////////////
	                                    //  HOTEL SERVICES
function vSname($sname) {
	 
	//preg_match("/^[\sA-Za-z]+$/",$sname)  &&
		if($sname!=""){
			return 	$sname;
		} 
		 else{
		 	return false;
		 }
}  


function eSname($sname) {
	 if($sname=="")
	               {

	 	return $sname="Description required!..";
	               }
	
//	 else if(!preg_match("/^[\sA-Za-z]+$/",$sname))
	      //        {
		 
        //return $sname= "Error in typing description!";
		        //  }
	 else         {
		          	return;
		          }
	           }                           








                        ///HOTEL SERVICES COST GOES HERE
function vScost($scost) {
	 //preg_match("/^[\sA-Za-z0-9]+$/",$scost)  &&
	
		if($scost!=""){
			return 	$scost;
		} 
		 else{
		 	return false;
		 }
}  


function eScost($scost) {
	 if($scost=="")
	               {

	 	return $scost="Amount required!..";
	               }
	
	/// else if(!preg_match("/^[\sA-Za-z0-9]+$/",$scost))
	        //      {
		 
        //return $scost= "Error in typing amount!";
		    //      }
	 else         {
		          	return;
		          }
	           }      


            //////////////////////
	           ///////////////SAVING ROOM DATA TO THE DATABASE GOES HERE

function addAssService($sname,$scost,$serviceId, $hnm){
	
 
	 $data=array($hnm,$serviceId,$sname,$scost);
try{
	
	$Qr=$this->dbcon->prepare("insert into hotelasssevices(hotelid,serviceId,service,charge) values(?,?,?,?)");
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {
          return $Re="Information submitted successfully!..";
	 }
	 else
	 {
	 	  return  $Re="Data not saved resubmit the form!..";
	 }

}
catch(PDOException $ex){
	$ex->getMessage();
}
} 
                     


                                      // COST  VALIDATION END

 //////////////////////////////////UPDATE HOTEL COST//////////////////
function UpdateAssService($scost,$serviceId,$sname, $hnm){
	
 
	 $data=array($sname,$scost,$hnm,$serviceId);
try{
	
	$Qr=$this->dbcon->prepare("update hotelasssevices set service=?,charge=? where hotelid=? and serviceId=?");
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {
          return $Re="Changes saved successfully!..";
	 }
	 else
	 {
	 	  return  $Re="Chages not saved the form!..";
	 }

}
catch(PDOException $ex){
	$ex->getMessage();
}
} 
                     


                                      // HOTEL SERVICE VALIDATION END





                        ///ROOM TYPE REGISTRATION FORM
function vRtype($rtype) {
	 
	
		if(preg_match("/^[\sA-Za-z0-9]+$/",$rtype)  && $rtype!=""){
			return 	$rtype;
		} 
		 else{
		 	return false;
		 }
}  


function eRtype($rtype) {
	 if($rtype=="")
	               {

	 	return $rtype="Room type required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z0-9]+$/",$rtype))
	              {
		 
        return $rtype= "Error in typing room type!";
		          }
	 else         {
		          	return;
		          }
	           }                           


                                      // ROOM TYPE VALIDATION END


                        ///ROOM TYPE REGISTRATION FORM
function vRcost($rcost) {
	 
	
		if(preg_match("/^[0-9]+$/",$rcost)  && $rcost!=""){
			return 	$rcost;
		} 
		 else{
		 	return false;
		 }
}  


function eRcost($rcost) {
	 if($rcost=="")
	               {

	 	return $rcost="Room cost required!..";
	               }
	
	 else if(!preg_match("/^[0-9]+$/",$rcost))
	              {
		 
        return $rcost= "Error in typing room cost!";
		          }
	 else         {
		          	return;
		          }
	           }                           


                                      // ROOM TYPE VALIDATION END





                        ///ROOM TYPE REGISTRATION FORM
function vRroomid($roomid) {
	 
	
		if(preg_match("/^[A-Za-z0-9]+$/",$roomid)  && $roomid!=""){
			return 	$roomid;
		} 
		 else{
		 	return false;
		 }
} 

///PAYMENT CODE CONFIRMATION///////////
function vCode($code) {
	 
	
		if(preg_match("/^[A-Za-z0-9]+$/",$code)  && $code!=""){
			return 	$code;
		} 
		 else{
		 	return false;
		 }
}  

function eCode($code) {
	 if($code=="")
	               {

	 	return $code="Payment code required!..";
	               }
	
	 else if(!preg_match("/^[A-Za-z0-9]+$/",$code))
	              {
		 
        return $code= "Error in typing payment code!";
		          }
	 else         {
		          	return;
		          }
	           }                           


///////////////////////// 


function eRroomid($roomid) {
	 if($roomid=="")
	               {

	 	return $roomid="Room id required!..";
	               }
	
	 else if(!preg_match("/^[A-Za-z0-9]+$/",$roomid))
	              {
		 
        return $roomid= "Error in typing room id!";
		          }
	 else         {
		          	return;
		          }
	           }                           


                                      // ROOM TYPE VALIDATION END


            //////////////////////
	           ///////////////SAVING ROOM DATA TO THE DATABASE GOES HERE

function addRoom($rname,$rtype,$rcost, $roomid, $hnm){
	

	 $rstatus="Free";
	 $data=array($hnm,$roomid,$rname,$rtype,$rcost,$rstatus);
try{
	
	$Qr=$this->dbcon->prepare("insert into room(hotel_id,room_no, rname,rtype,rcost,rstatus) values(?,?,?,?,?,?)");
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {
          return $Re="Information submitted successfully!..";
	 }
	 else
	 {
	 	  return  $Re="Data not saved resubmit the form!..";
	 }

}
catch(PDOException $ex){
	$ex->getMessage();
}
} 


            //////////////////////
	           ///////////////SAVING ROOM DATA EDITING TO THE DATABASE GOES HERE

function editRoom($rname,$rtype,$rcost, $roomid, $hnm){
	
  
try{
	
	$Qr=$this->dbcon->prepare("update room set rname=?  ,rtype =?,rcost=? where hotel_id=? and room_no=?");
	$Qr->execute(array($rname,$rtype,$rcost,$hnm,$roomid));
	 if($Qr)
	 {
          return $Re="Changes successfully saved!..";
	 }
	 else
	 {
	 	  return  $Re="Changes not saved resubmit the form!..";
	 }

}
catch(PDOException $ex){
	$ex->getMessage();
}
}




///----------------REGISTRATION FORM VALIDATION---------------------
                              //VALIDATE FIRST NAME

function vFname($fname) {
	 
	
		if(preg_match("/^[A-Za-z]+$/",$fname)  && $fname!=""){
			return 	$fname;
		} 
		 else{
		 	return false;
		 }
}  


function eFname($fname) {
	 if($fname=="")
	               {

	 	return $mname="First name required!..";
	               }
	
	 else if(!preg_match("/^[A-Za-z]+$/",$fname))
	              {
		 
        return $fname= "Invalid name!";
		          }
	 else         {
		          	return;
		          }
	 

}                           


                                      //MIDDLE NAME VALIDATION

function vMname($mname) {
	 
	
		if(preg_match("/^[A-Za-z]+$/",$mname)  && $mname!=""){
			return 	$mname;
		} 
		 else{
		 	return false;
		 }
}  


function eMname($mname) {
	 if($mname=="")
	               {

	 	return $mname="Middle name required!..";
	               }
	
	 else if(!preg_match("/^[A-Za-z]+$/",$mname))
	              {
		 
        return $mname= "Invalid name!";
		          }
	 else         {
		          	return;
		          }
	 

}     





                                      //LAST NAME VALIDATION

function vLname($lname) {
	 
	
		if(preg_match("/^[A-Za-z]+$/",$lname)  && $lname!=""){
			return 	$lname;
		} 
		 else{
		 	return false;
		 }
}  


function eLname($lname) {
	 if($lname=="")
	               {

	 	return $lname="Middle name required!..";
	               }
	
	 else if(!preg_match("/^[A-Za-z]+$/",$lname))
	              {
		 
        return $lname= "Invalid name!";
		          }
	 else         {
		          	return;
		          }
	 

}




                                      //WARD VALIDATION

function vWard($ward) {
	 
	
		if(preg_match("/^[\sA-Za-z]+$/",$ward)  && $ward!=""){
			return 	$ward;
		} 
		 else{
		 	return false;
		 }
}  


function eWard($ward) {
	 if($ward=="")
	               {

	 	return $ward="Ward required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z]+$/",$ward))
	              {
		 
        return $ward= "Invalid ward name!";
		          }
	 else         {
		          	return;
		          }
	 

}






 



                                      //STREET VALIDATION

function vStreet($street) {
	 
	
		if(preg_match("/^[\sA-Za-z]+$/",$street)  && $street!=""){
			return 	$street;
		} 
		 else{
		 	return false;
		 }
}  


function eStreet($street) {
	 if($street=="")
	               {

	 	return $street="Street required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z]+$/",$street))
	              {
		 
        return $street= "Invalid street  name!";
		          }
	 else         {
		          	return;
		          }
	 

}




                                      //EMAIL VALIDATION

function vEmail($email) {
	 
	
		if(preg_match("/\b[(A-Za-z)][\w.]\w+@\w+\.(net|com|edu)\b/",$email)  && $email!=""){
			return 	$email;
		} 
		 else{
		 	return false;
		 }
}  


function eEmail($email) {
	 if($email=="")
	               {

	 	return $email="Email required!..";
	               }
	
	 else if(!preg_match("/\b[\(A-Za-z)][\w.]\w+@\w+\.(net|com|edu)\b/",$email))
	              {
		 
        return $email= "Invalid email address!";
		          }
	 else         {
		          	return;
		          }
	 

}                                                    


                                      //DISTRICT VALIDATION

function vDistrict($district) {
	 
	
		if(preg_match("/^[\sA-Za-z]+$/",$district)  && $district!=""){
			return 	$district;
		} 
		 else{
		 	return false;
		 }
}  


function eDistrict($district) {
	 if($district=="")
	               {

	 	return $district="District required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z]+$/",$district))
	              {
		 
        return $district= "Invalid district name!";
		          }
	 else         {
		          	return;
		          }
	 

}




                                      //REGION VALIDATION

function vRegion($region) {
	 
	
		if(preg_match("/^[\sA-Za-z]+$/",$region)  && $region!=""){
			return 	$region;
		} 
		 else{
		 	return false;
		 }
}  


function eRegion($region) {
	 if($region=="")
	               {

	 	return $region="Region required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z]+$/",$region))
	              {
		 
        return $district= "Invalid region name!";
		          }
	 else         {
		          	return;
		          }
	 

}

                                      //COUNTRY VALIDATION

function vCountry($country) {
	 
	
		if(preg_match("/^[\sA-Za-z]+$/",$country)  && $country!=""){
			return 	$country;
		} 
		 else{
		 	return false;
		 }
}  


function eCountry($country) {
	 if($country=="")
	               {

	 	return $region="Country required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z]+$/",$country))
	              {
		 
        return $district= "Invalid country name!";
		          }
	 else         {
		          	return;
		          }
	 

}

   //OCCUPATION VALIDATION

function vOccupation($occupation) {
	 
	
		if(preg_match("/^[\sA-Za-z]+$/",$occupation)  && $occupation!=""){
			return 	$occupation;
		} 
		 else{
		 	return false;
		 }
} 




function eOccupation($occupation) {
	 if($occupation=="")
	               {

	 	return $occupation="Occupation required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z]+$/",$occupation))
	              {
		 
        return $district= "Invalid occupation name!";
		          }
	 else         {
		          	return;
		          }
	 

}


function vCategory($category) {
	 
	
		if(preg_match("/^[\sA-Za-z]+$/",$category)  && $category!=""){
			return 	$category;
		} 
		 else{
		 	return false;
		 }
} 


function eCategory($category) {
	 if($category=="")
	               {

	 	return $category="category required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z]+$/",$category))
	              {
		 
        return $category= "Invalid category name!";
		          }
	 else         {
		          	return;
		          }
	 

}
//PASSWORD VALIDATION

function vPassword($password) {
	 
	
		if(preg_match("/\w{8,25}/",$password)  && $password!=""){
			return 	$password;
		} 
		 else{
		 	return false;
		 }
}  


function ePassword($password) {
	 if($password=="")
	               {

	 	return $password="password required!..";
	               }

   
	 else if(!preg_match("/\w{8,25}/",$password))
	              {
		 
        return $password= "Strong password with mixed numeric, upper and lower case required!";
		          }
	 else         {
		          	return;
		          }
	 

}

//PASSWORD VALIDATION

function vNpassword($npassword) {
	 
	
		if(preg_match("/\w{8,25}/",$npassword)  && $npassword!=""){
			return 	$npassword;
		} 
		 else{
		 	return false;
		 }
}  


function eNpassword($npassword) {
	 if($npassword=="")
	               {

	 	return $npassword="password required!..";
	               }

   
	 else if(!preg_match("/\w{8,25}/",$npassword))
	              {
		 
        return $npassword= "Strong password with mixed numeric, upper and lower case required!";
		          }
	 else         {
		          	return;
		          }
	 

}


 

function vNcpassword($npassword,$cpassword) {
	 
	
		if($npassword== $cpassword){
			return 	$npassword;
		} 
		 else{
		 	return false;
		 }
}  



function eNcpassword($npassword,$cpassword) {
	 if($npassword!=$cpassword )
	               {

	 	return $npassword="Password mismatch!..";
	               }

    
	 else         {
		          	return;
		          }
	 

}


                             //PASSWORD CONFIRMATION

function vCPassword($password,$cpassword) {
	 
	
		if($password== $cpassword){
			return 	$password;
		} 
		 else{
		 	return false;
		 }
}  



function eCPassword($password,$cpassword) {
	 if($password!=$cpassword )
	               {

	 	return $password="Password mismatch!..";
	               }

    
	 else         {
		          	return;
		          }
	 

}



//PHONE NUMBER VALIDATION

function vPhoneno($phoneno) {
	 
	
		if(preg_match("/\d{10,12}/",$phoneno)  && $phoneno!=""){
			return 	$phoneno;
		} 
		 else{
		 	return false;
		 }
}  


function ePhoneno($phoneno) {
	 if($phoneno=="")
	               {

	 	return $phoneno="Phone number required!..";
	               }

   
	 else if(!preg_match("/\d{10,12}/",$phoneno))
	              {
		 
        return $phoneno= "Invalid phone number!..";
		          }
	 else         {
		          	return;
		          }
	 

}


                             //GENDER CONFIRMATION

function vGender($gender) {
	 
	
		if($gender!=""){
			return 	$gender;
		} 
		 else{
		 	return false;
		 }
}  



function eGender($gender) {
	 if($gender=="")
	               {

	 	return $gender="Gender required!..";
	               }

    
	 else         {
		          	return;
		          }
	 

}




                             //DATE OF BIRTH VALIDATION

function vDate($dob) {
	 
	
		if($dob!=""){
			return 	$dob;
		} 
		 else{
		 	return false;
		 }
}  



function eDate($dob) {
	 if($dob=="")
	               {

	 	return $dob="Date of birth required!..";
	               }

    
	 else         {
		          	return;
		          }
	 

}






                                       // FUNCTION FOR REGISTERING USER GOES HERE
/*if(isset($_POST['phoneno']) && isset($_POST['dob'])  && isset($_POST['fname']) && isset($_POST['mname']) && isset($_POST['lname']) && isset($_POST['email']) &&isset($_POST['ward']) && isset($_POST['gender']) && isset($_POST['district']) && isset($_POST['street']) && isset($_POST['country']) && isset($_POST['genger']) && isset($_POST['rcity']) && isset($_POST['password']) && isset($_POST['pobox'])){
 
*/

function registerOwner($phoneno,$reg,$fname, $mname, $lname, $gender, $occupation, $email,$pobox, $password,$district,$country, $street ,$ward, $region, $dob, $regdate){
	

	 $md=md5($reg);
	 $datetime=Date("Y-m-d");$time=Date("h:i:sa");
	 $data=array($time,$datetime,$phoneno,$reg,$md,$fname, $mname, $lname, $gender, $occupation,$phoneno, $email,$pobox, $password,$district,$country, $street ,$ward, $region, $dob, $regdate);
try{
	
	$Qr=$this->dbcon->prepare("insert into account_owner
		(lastlogTime,lastLogin,owner_id,own_regno,no_md5,fname, mname,lname,gender,occupation,phoneno,email,postAddress,password,district,country,street,ward,city,dob,regdate) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {
	     
	     
	     $id1="qsgsfhuw8891o1pggywiuiwpwp8091hhwjmbbbnbsnusbbsggs98202iiahjhabbabbabba89299200gsgshsiisi00200hhshhsbbssbbsbbsk2002002002002";
	  $g="srqwesgbsynnebbdyyeuueumnennenneeyyyoy3yy3uu33iii3o3oo3oo3i3iii3ii3uu3uu3uuu3uuu3uuu3uuu3uuuu3uuu3uu3uu3uuu3uu3ttyy3yy3yy3yy3yy3yyy3yy3yy3yy3yy3shshhshhwhhwhhwhhheh";
	  
	 // hotel_default_entry.php   afterLoginHotel.php
	 	$suc="SUCCESSFULLLY REGISTRERED!";
         header("location:hotel_default_entry.php?suc=$suc&eqsgsfhuw8=$id1&rsrqwes=$g&id=$md"); //="Information submitted successfully!..";
	 }
	 else
	 { 
	 return $err=$Qr;//->ErrorInfo();
	 	//header("location:newUserRegform.php?id=$err");
	 	 // return  $Re="Data not saved resubmit the form!..";
	 }
	 //

}
catch(PDOException $ex){
	$ex->getMessage();
}
}

                                                             // REGISTRATION FUNCTION ENDS

////////////////////////////////
              ///////////////////////UPDATE USER ACCOUNT FUNCTION GOES HERE///////////
              /////////////////////////////////
function updateMyAccount($phoneno,$accountId,$fname, $mname, $lname, $gender, $occupation, $email,$pobox,$district,$country, $street ,$ward, $region, $dob){
	

	 
	 $data=array($fname, $mname, $lname, $gender, $occupation,$phoneno, $email,$pobox,$district,$country, $street ,$ward, $region, $dob,$accountId);
try{
	
	$Qr=$this->dbcon->prepare("update account_owner set fname =?, mname=?,lname=?,gender=?,occupation=?,phoneno=?,email=?,postAddress=?,district=?,country=?,street=?,ward=?,city=?,dob=? where own_regno=?"); 
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {
          return $Re="Information submitted successfully!..";
	 }
	 else
	 {
	 	  return  $Re="Data not saved resubmit the form!..";
	 }

}
catch(PDOException $ex){
	$ex->getMessage();
}
}

////////////////////////CHANGE PASSWORD FUNCTION////////////
////////////////////////////////////////////////
function updateMyAccountPassword($ownID,$npassword){
	

	 
	 $data=array($npassword,$ownID);
try{
	
	$Qr=$this->dbcon->prepare("update account_owner set password =? where own_regno=?"); 
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {
          return $Re="Information submitted successfully!..";
	 }
	 else
	 {
	 	  return  $Re="Data not saved resubmit the form!..";
	 }

}
catch(PDOException $ex){
	$ex->getMessage();
}
}

////////////////////////////////////////////////
function updateThisAccountStatus($ownID){
	

	 $status="Active";
	 $data=array($status,$ownID);
try{
	
	$Qr=$this->dbcon->prepare("update account_owner set accStatus =? where own_regno=?"); 
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {
          return $Re="Activation successful!..";
	 }
	 else
	 {
	 	  return  $Re="Activation failed!..";
	 }

}
catch(PDOException $ex){
	$ex->getMessage();
}
}


                                               







                                                         ///ROOM IMAGE UPLOAD FUNCTION
 function uploadRoomImage($fn,$tit,$roomid, $hnm,$tmp_name,$size){
	

 

  $site="hotel_images/".$fn;
    
  $ext = strtolower($site);

  $info = getimagesize($tmp_name);

  if ($info['mime'] == 'image/jpeg')
  {
      
    $image = imagecreatefromjpeg($tmp_name);
  }
  elseif ($info['mime'] == 'image/gif') 
  {
    $image = imagecreatefromgif($tmp_name);
  }
  elseif ($info['mime'] == 'image/png')
  { 
    $image = imagecreatefrompng($tmp_name);
  }
//imagejpeg($image, $site, 9);
	 
	 $data=array($hnm,$tit,$roomid,$site);
try{
	
	$Qr=$this->dbcon->prepare("insert into roomimages(hotelid,imgname,room_no,directory) values(?,?,?,?)");
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {

     //move_uploaded_file($tmp_name,$site);
     if($size>2500000){
         imagejpeg($image, $site, 9);
        }
        else if($size>1500000 && $size<2500000){
           imagejpeg($image, $site, 20);  
        }
        else if($size<1500000){
           imagejpeg($image, $site, 40);  
        }
          return $Re="The image is successfully uploaded!..";
	 }
	 else
	 {
	 	  return  $Re="Oops your network is low to upload data!..";
	 } 

}
catch(PDOException $ex){
	$ex->getMessage();
}
}
                                    //UPLOAD ROOM IMAGE ENDS

                                                             
                                                             //FUNCTION FOR UPLOADING  HOTEL IMAGES
 function uploadImage($fn,$tit, $hnm,$tmp_name,$size){
	

 

$site="hotel_images/".$fn;
    
$ext = strtolower($site);

  $info = getimagesize($tmp_name);

  if ($info['mime'] == 'image/jpeg')
  {
      
    $image = imagecreatefromjpeg($tmp_name);
  }
  elseif ($info['mime'] == 'image/gif') 
  {
    $image = imagecreatefromgif($tmp_name);
  }
  elseif ($info['mime'] == 'image/png')
  { 
    $image = imagecreatefrompng($tmp_name);
  }
 //imagejpeg($image, $site, 1);
	 
 $data=array($hnm,$tit,$site);
  try{
	
	$Qr=$this->dbcon->prepare("insert into images(hotelid,imgname,directory) values(?,?,?)");
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {

        //move_uploaded_file($tmp_name,$site);
        if($size>2500000){
         imagejpeg($image, $site, 9);
        }
        else if($size>1500000 && $size<2500000){
           imagejpeg($image, $site, 20);  
        }
        else if($size<1500000){
           imagejpeg($image, $site, 40);  
        }
          return $Qr="The image is successfully uploaded!..";
	 }
	 else
	 {
	 	  return  print_r($Qr->ErrorInfo());//="Oops your network is low to upload data!..";
	 } 

}
catch(PDOException $ex){
	$ex->getMessage();
}
}
                           //VALIDATE IMAGE TITLE

                           //VALIDATE ROOM IA NO TITLE

function vRoomID($roomid) {
	 
	
		if(preg_match("/^[A-Za-z0-9]+$/",$roomid)  && $roomid!=""){
			return 	$roomid;
		} 
		 else{
		 	return false;
		 }
}  



function eRoomID($roomid) {
	 if($roomid=="")
	               {

	 	return $roomid="Room id required!..";
	               }
	
	 else if(!preg_match("/^[A-Za-z0-9]+$/",$roomid))
	              {
		 
        return $roomid= "Room id typed with error!";
		          }
	 else         {
		          	return;
		          }
	 

}

 
                            //FUNCTION FOR VALIDATING ROOM ID NO ENDS



function vTitle($tit) {
	 
	
		if(preg_match("/^[\sA-Za-z]+$/",$tit)  && $tit!=""){
			return 	$tit;
		} 
		 else{
		 	return false;
		 }
}  



function eTitle($tit) {
	 if($tit=="")
	               {

	 	return $tit="Title required!..";
	               }
	
	 else if(!preg_match("/^[\sA-Za-z]+$/",$tit))
	              {
		 
        return $tit= "Title typed with error!";
		          }
	 else         {
		          	return;
		          }
	 

}

 
                            //IMAGE TITLE ENDS






                             //IMAGE TYPE VALIDATION

function vImageType($ext,$allowedtype) {
	 
	if(in_array($ext,$allowedtype))
	{
      
      return $ext;
		  
    }
	else
	 {
	  return false; 
	 }

     }  



function eImageType($ext,$allowedtype) {
	 
	if(in_array($ext,$allowedtype))
	{
      
      return;
		  
    }
	else
	 {
	  return $ex= "The extension ".$ext." is not type of an image!..";
	 }

     }  
                                      //TYPE OF IMAGE ENDS




                             //IMAGE SIZE VALIDATION

function vImageSize($size) {
	 
	if($size>=0 && $size<500000)
	{
      
      return $size;
		  
    }
	else
	 {
	  return false; 
	 }

     }  



function eImageSize($size) 
 {
	 
	if($size>=0 && $size<5000000)
	{
      
      return;
		  
    }
	 else
    {
	 return $size= "The Height:  ".$height." and   Width: ".$width."   of image is not within range!..";
    }


} 
                                      //VALIDATION  OF IMAGE SIZE ENDS


                             //IMAGE ERROR VALIDATION

function vImageError($error) {
	 
	if($error <= 0)
	{
      
      return true;
		  
    }
	else
	 {
	  return false; 
	 }

     }  



function eImageError($error) 
 {
	 
	if($error > 0)
	{
      
      return $err="An error: ".$error." occurred while uploading file!..."; 

		  
    }
	 else
    {
	 return ;
    }


} 

//IMAGE ERROR VALIDATION

                            //CHECK IF IMAGE EXIST

function vImageExist($fn) {
	 
	if(file_exists("hotel_images/".$fn))
	{
      
      return false;
		  
    }
	else
	 {
	  return true; 
	 }

     }  



function eImageExist($fn) 
 {
	 
	
if(file_exists("hotel_images/".$fn))
	{
      
      return  $exs= "The ".$fn." already uploaded!..";
  
    }
	 else
    {
	 return ;
    }


} 


                            //CHECK IF IMAGE SELECTED

function vImageSelectF($fn) {
	 
	if($fn=="")
	{
      
      return false;
		  
    }
	else
	 {
	  return true; 
	 }

     }  



function eImageSelectF($fn) 
 {
	 
	
if($fn=="")
	{
      
      return  $exs= "Select file to upload!..";
  
    }
	 else
    {
	 return ;
    }


} 

                                                             // IMAGE UPLOAD  FUNCTION ENDS

                                                             // IMAGE UPLOAD  FUNCTION ENDS
 

                                                              //FUNCTION FOR GETING HOTEL ASSOCIATED SERVICES

function getAssServices($hnm){
	try{
		$Rs=$this->dbcon->prepare("select * from hotelasssevices where hotelid=:id");
		$Rs->bindParam(":id",$hnm);
	    $Rs->execute();
		
		return $Rs;

	}
	catch(PDOException $xc){
		$xc->getMessage();                                        
	}
}    

                                                            //HOTEL ASSOCIATED SERVICES FUNCTION ENDS
                   ///////////////////////////RETRIEVE HOTEL ASSOCIATE SERVICES FOR EDITING//////////////
                            ///////////////////////////////////////////////////////
function getAssServicesForEditing($hnm,$serviceId){
	try{
		$Rs=$this->dbcon->prepare("select * from hotelasssevices where hotelid=:id and serviceId=:Sid");
		$Rs->bindParam(":id",$hnm);
		$Rs->bindParam(":Sid",$serviceId);
	    $Rs->execute();
		
		return $Rs;

	}
	catch(PDOException $xc){
		$xc->getMessage();                                        
	}
}                                               
  

    

                                                            //FUNCTION FOR GETING ROUTE TO HOTEL STARTS

     function getRouteToHotel($hnm){
	try{
		$Rs=$this->dbcon->prepare("select * from  routetohotel where hotelid=:id");
		$Rs->bindParam(":id",$hnm);
	    $Rs->execute(); 
		  
		return $Rs;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}





                                            
                                                            //FUNCTION FOR GETING ROUTE TO HOTEL ENDS

///////////////////////ROUTE TO UPDATE HOTEL////////////////////
///////////////////////////////////////////////////////////////

     function getRouteToUpdate($hnm,$routeId){
	try{
		$Rs=$this->dbcon->prepare("select * from  routetohotel where hotelid=:id and routeId=:rId");
		$Rs->bindParam(":id",$hnm);
		$Rs->bindParam(":rId",$routeId);
	    $Rs->execute(); 
		  
		return $Rs;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
/////////////////RPOUTE//////////


    

                                                            // FUNCTION FOR GETING  HOTEL ROOM STARTS
//////////////////////////////GET BOOKED HOTEL FUNCTION GOES HERE///////////////////
 //FUNCTION FOR OWNED HOTEL HERE
function getThisHotel($hnm){
	try{
		$ownerH=$this->dbcon->prepare("select * from hotel where hotel_id=:Id");
		$ownerH->bindParam(":Id",$hnm);
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}

                                            //FUNCTION FOR OTHER HOTEL HERE


/////////////////////////////THE ROOM BOOKED//////////////////
 
////////////////////////


     function getHotelBookedRoom($hnm,$roomid){
	try{
		$room=$this->dbcon->prepare("select * from  room where hotel_id=:id and room_no=:rid");
		$room->bindParam(":id",$hnm);
		$room->bindParam(":rid",$roomid);
	    $room->execute(); 
		  
		return $room;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
/////////////////////////////////ROOM WE ARE BOOKING///////////////////


     function getHotelRoom($hnm){
	try{
		$room=$this->dbcon->prepare("select * from  room where hotel_id=:id");
		$room->bindParam(":id",$hnm);
	    $room->execute(); 
		  
		return $room;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}




                                        
                                                            //FUNCTION FOR GETING  HOTEL ROOM ENDS



                                                            // FUNCTION FOR GETING  HOTEL ROOM STARTS

     function getHotelRoomForEdit($hnm,$roomid){
	try{
		$room=$this->dbcon->prepare("select * from  room where hotel_id=:id and room_no=:Id");
		$room->bindParam(":id",$hnm);
		$room->bindParam(":Id",$roomid);
	    $room->execute(); 
		  
		return $room;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}




                                        
                                                            //FUNCTION FOR GETING  HOTEL ROOM ENDS

    

                                                            // FUNCTION FOR GETING  HOTEL INFO STARTS

     function getHotelInfo($hnm){
	try{
		$hotel=$this->dbcon->prepare("select * from hotel where hotel_id=:Id");
		$hotel->bindParam(":Id",$hnm);
	    $hotel->execute(); 
		  
		return $hotel;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}

                                        
                                                            //FUNCTION FOR GETING  HOTEL INFO ENDS

   

                                                            // FUNCTION FOR GETING  HOTEL STARTS
function getHotelBySearch($searchValue){
	try{
		$hname=$this->dbcon->prepare("select * from hotel where  hname  like ? or description  like ? or country  like ? or city  like ?  or ltown_city  like ? or lstreet_vil  like ? or phoneno  like ? or email  like ?  or popularDistination  like ? ");
		 //$data =;
		//$data=array('%'.$searchValue.'%');
	    $hname->execute(array('%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%')); 
		  
		return $hname;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}

/*
function getHotelBySearch($searchValue){
	try{
//hotel_id,owner_id,hname,description,country,city,	ltown_city,lstreet_vil,phoneno,paddress,email,reg_date,popularDistination


		$hname=$this->dbcon->prepare("select hotel_id,owner_id,hname,description,country,city,	ltown_city,lstreet_vil,phoneno,paddress,email,reg_date,popularDistination from hotel where concat(hotel_id,owner_id,hname,description,country,city,ltown_city,lstreet_vil,phoneno,paddress,email,reg_date,popularDistination) like concat('%',:val,'%')");
		$data=array(":val"=>$searchValue);
	    $hname->execute($data); 
		  
		return $hname;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}

*/

                                            //FUNCTION FOR OWNED HOTEL HERE
    

                                                            // FUNCTION FOR GETING  HOTEL STARTS

function getHotel(){
	try{
		$hname=$this->dbcon->prepare("select * from hotel");
		 
	    $hname->execute(); 
		  
		return $hname;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}

                                            //FUNCTION FOR OWNED HOTEL HERE
function getMyHotel($ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from hotel where owner_id=:Id");
		$ownerH->bindParam(":Id",$ownID);
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}

                                            //FUNCTION FOR OTHER HOTEL HERE
                                           
                                           //FUNCTION FOR OWNED HOTEL HERE
function getMyOperationHotel($ownID,$hnm){
	try{
		$ownerH=$this->dbcon->prepare("select * from hotel where owner_id=:Id and hotel_id=:hID");
		$ownerH->bindParam(":Id",$ownID);
		$ownerH->bindParam(":hID",$hnm);
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
                                            //FUNCTION FOR OTHER HOTEL HERE
                                     //FUNCTION FOR OTHER HOTEL HERE

                        //FUNCTION FOR ADD IMAGE HOTEL HERE
function getCheckIfPostExist($tit,$hnm){
	try{
		$ownerH=$this->dbcon->prepare("select * from images where hotelid=:Id and imgname=:img");
		$ownerH->bindParam(":Id",$hnm);
		$ownerH->bindParam(":img",$tit);
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}

                                            //FUNCTION FOR OTHER HOTEL HERE

                                            //FUNCTION FOR ADD IMAGE HOTEL HERE
function getHotelAddImage($ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from hotel where hotel_id=:Id");
		$ownerH->bindParam(":Id",$ownID);
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}

                                            //FUNCTION FOR OTHER HOTEL HERE
function getOtherHotel($ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from hotel where owner_id!=:Id");
	    $ownerH->bindParam(":Id",$ownID);
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}


                                            //FUNCTION FOR OWNED HOTEL HERE
function getMyProfileForContract($ownIDC){
	try{
		$ownerH=$this->dbcon->prepare("select * from account_owner where own_regno=:Id");
		$ownerH->bindParam(":Id",$ownIDC);
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}

 ///////////////////GET ACCOUNT OWNER PROFILE HERE/////////////
   
                                            //FUNCTION FOR OWNED HOTEL HERE
function getSystemUser(){
	try{
		$ownerH=$this->dbcon->prepare("select * from account_owner");
		//$ownerH->bindParam(":Id",$ownID);
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}

 ///////////////////GET ACCOUNT OWNER PROFILE HERE/////////////


                                            //FUNCTION FOR OWNED HOTEL HERE
function getMyProfile($ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from account_owner where own_regno=:Id");
		$ownerH->bindParam(":Id",$ownID);
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}

 ///////////////////GET ACCOUNT OWNER PROFILE HERE/////////////

     function myProfileInfo($accountId){
	try{
		$Rs=$this->dbcon->prepare("select * from account_owner where  own_regno=:id");
		$Rs->bindParam(":id",$accountId);
	    $Rs->execute(); 
		  
		return $Rs;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
            //////////////////////

////////////////CHANGES PASSWORD////////////
/////////////////////////////////////////
                                           //FUNCTION FOR OWNED HOTEL HERE
function getMyPassword($ownID,$password){
	try{
		$ownerH=$this->dbcon->prepare("select * from account_owner where own_regno=:Id and password=:hID");
		$ownerH->bindParam(":Id",$ownID);
		$ownerH->bindParam(":hID",$password);
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
   //////////////////////GET OWNER ID HERE///////////////////
////////////////////////////////////////////////////////////
function getOwnerAddImage($ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from account_owner where own_regno=:Id");
		$ownerH->bindParam(":Id",$ownID);
	    $ownerH->execute(); 
		  
		return $ownerH;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}

////////////////////////////UPLOAD PROFILE IMAGES/////////////////////
///////////////////////////////////////////////////////////////////////

function eImageProfileExist($fn) {
	 
	if(file_exists("accountProfileImages/".$fn))
	{
      
      return  $exs= "The ".$fn." already uploaded!..";
  
    }
	 else
    {
	 return ;
    }


} 


function vImageProfileExist($fn) {
	 
	if(file_exists("accountProfileImages/".$fn))
	{
      
      return false;
		  
    }
	else
	 {
	  return true; 
	 }

     } 

     ///////////////////////////////////////////////////////////////
     //////////////////////////FUNCTION FOR UPLOADING PROFILE IMAGE/////////////// 
     ////////////////////////////////////////////////////////////////////////

function uploadProfileImage($fn, $ownID,$tmp_name){


$date=Date("Y-m-d h:i:s");
	
try{


$Qr=$this->dbcon->prepare("select * from  profilepicture where ownerid=:Id");
$Qr->bindParam(":Id",$ownID);
	$Qr->execute();
	 if($Qr->rowCount()<=0)
	 {

 //////////////
 

    $site="accountProfileImages/".$fn;
	 
	$data=array($ownID,$site,$date);
    
	
	$Qr=$this->dbcon->prepare("insert into  profilepicture(ownerid,directory,lastUpdate) values(?,?,?)");
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {

     move_uploaded_file($tmp_name,$site);

     return $Re="The image is successfully uploaded!..";
	 }
	 else
	 {
	 return  $Re="Oops your network is low to upload data!..";
	 }
	 ///////////////
	}
	else{
   ///////////////////////////
    $site="accountProfileImages/".$fn;
	 
	$data=array($site,$date,$ownID);
    
	
	$Qr=$this->dbcon->prepare("update profilepicture set directory=?,lastUpdate=? where ownerid=?");
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {
    
    if(!file_exists("accountProfileImages/".$fn))
	 {
      
     move_uploaded_file($tmp_name,$site);
  
      }

           
          return $Re="Profile successfully set!..";
	 }
	 else
	 {
	 	  return  $Re="Oops your network is low to upload data!..";
	 }


		/////////////////////////

	} 

}
catch(PDOException $ex){
	$ex->getMessage();
}
}
                                    //UPLOAD ROOM IMAGE ENDS

////////////////////////////////////////////////

////////////////////////PROFILE NAME AND IMAGE///////////////

//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
function getThisUserProfile($userID){
	

	  
try{
	
	$Qr=$this->dbcon->prepare("select * from account_owner where own_regno=:Id");
	$Qr->bindParam(":Id",$userID); 
	$Qr->execute();
	 return $Qr;

}
catch(PDOException $ex){
	$ex->getMessage();
}
}

//////////////////////////GET IMAGE PROFILE////////////////////////////////

////////////////////////PROFILE NAME AND IMAGE///////////////

//////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////
function getMyRegNo($ownID){
	

	  
try{
	
	$Qr=$this->dbcon->prepare("select * from account_owner where no_md5=:Id");
	$Qr->bindParam(":Id",$ownID); 
	$Qr->execute();
	 return $Qr;

}
catch(PDOException $ex){
	$ex->getMessage();
}
}
//////////////////////////GET IMAGE PROFILE////////////////////////////////
//////////////////////////////////////////////////////////
function getMyOfficeHotel($ownID){
	

	  
try{
	
	$Qr=$this->dbcon->prepare("select * from hotelworkers where accountId=:Id");
	$Qr->bindParam(":Id",$ownID); 
	$Qr->execute();
	 return $Qr;
	 //
//hotelid


}
catch(PDOException $ex){
	$ex->getMessage();
}
}
//////////////////////////GET IMAGE PROFILE////////////////////////////////
//////////////////////////////////////////////////////////
function getMyProfileName($ownID){
	

	  
try{
	
	$Qr=$this->dbcon->prepare("select * from account_owner where own_regno=:Id");
	$Qr->bindParam(":Id",$ownID); 
	$Qr->execute();
	 return $Qr;

}
catch(PDOException $ex){
	$ex->getMessage();
}
}

//////////////////////////GET IMAGE PROFILE////////////////////////////////
//////////////////////////////////////////////////////////
function getMyShopWorkersprofileName($ownerid){
	

	 	
  
try{
	
	$Qr=$this->dbcon->prepare("select * from account_owner where owner_id=:Id");
	$Qr->bindParam(":Id",$ownerid); 
	$Qr->execute();
	 return $Qr;

}
catch(PDOException $ex){
	$ex->getMessage();
}
}

//////////////////////////GET IMAGE PROFILE////////////////////////////////

//////////////////////////GET IMAGE PROFILE////////////////////////////////
//////////////////////////////////////////////////////////
function getMyHprofileName($ownID){
	

	 	
  
try{
	
	$Qr=$this->dbcon->prepare("select * from account_owner where owner_id=:Id");
	$Qr->bindParam(":Id",$ownID); 
	$Qr->execute();
	 return $Qr;

}
catch(PDOException $ex){
	$ex->getMessage();
}
}
//////////////////////////GET IMAGE PROFILE////////////////////////////////
function getMyWorkersProfilePicture($ownerid){
	

	  
try{
	
	$Qr=$this->dbcon->prepare("select * from profilepicture where ownerid=:Id");
	$Qr->bindParam(":Id",$ownerid); 
	$Qr->execute();
	 return $Qr;
}
catch(PDOException $ex){
	$ex->getMessage();
}
}

//////////////////////////GET IMAGE PROFILE////////////////////////////////
function getMyProfilePicture($ownID){
	

	  
try{
	
	$Qr=$this->dbcon->prepare("select * from profilepicture where ownerid=:Id");
	$Qr->bindParam(":Id",$ownID); 
	$Qr->execute();
	 return $Qr;
}
catch(PDOException $ex){
	$ex->getMessage();
}
}


     function superlogin($username,$password){
	try{
		$Rs=$this->dbcon->prepare("select * from superuser where lname=:em and password=:pwd");
		$Rs->bindParam(":em",$username);
		$Rs->bindParam(":pwd",$password);
	    $Rs->execute(); 
		  
        return $Rs;
	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}

     function login($username,$password){
	try{
		$Rs=$this->dbcon->prepare("select * from account_owner where email=:em and password=:pwd");
		$Rs->bindParam(":em",$username);
		$Rs->bindParam(":pwd",$password);
	    $Rs->execute(); 
		if ($Rs->rowCount()>0)
		 {
			/////////////
	       //$rg=Date("h:i:sa");
    
           $regdate=Date("Y-m-d"); $time=Date("h:i:sa");
	       $data=array($time,$regdate,$password,$username);
 
	       $Qr=$this->dbcon->prepare("update account_owner set lastlogTime=?, lastLogin =? where password=? and email=?"); 
	       $Qr->execute($data);
	    
			/////////////////
		 }
        return $Rs;

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}


                                         // CLASS TERMINAL
}




 
/*
if($pdo){
	$hname="NEW AMAZING HOTEL";
	class user{
public function get($var){
	if(property_exists($this, $var)){
		return $this->$var;
	}
	return false;
} 
}
$stmt=$pdo->prepare("select hotel_id,hname,country,city,ltown_city,lstreet_vil,paddress,email from hotel");
//$stmt->bindParam(":Name",$hname);
if($stmt->execute()){
	
	//$rows=$stmt->fetchObject("user");
	//echo $rows->get("hotel_id");
	//print_r($rows);

	while($row=$stmt->fetch()){
		echo "<pre>";
		echo  $row["hname"];
	}
}
}*/
?> 