<?php
//ob_start("ob_gzhandler");
/*
		Filename:		dubba.class.php
		Owner:			Sreenath P.
		Date:			17-11-2008
		Description:	File for news management
*/
include_once "Database.class.php";
require_once 'General.class.php';
require_once 'registration.class.php';
require_once 'dubbauser.class.php';
require_once 'generalnew.class.php';

class dubba
{
	 private $general;
	function __construct()
	{
	
			date_default_timezone_set("Asia/Kolkata");
			$this->now		= date("Y-m-d");
			$this->date		= date("Y-m-d H:i:s");
			$this->general	= new General();	
			$this->db		= new database();
			$this->reg		= new register();
			$this->dubbauserobj		= new dubbauser();
			$this->generalnewobj		= new generalnew();
			
			if(!$this->db->dbConnect())
			die("Error Connection".$this->db->ErrorInfo);
	}
		
	function __destruct()
	{
			@$this->db->dbClose();
	}
/////Menu & Category /////////
	function addMenu($POST)
	{
		$cat_id=addslashes($POST['cat_id']);
		$category=addslashes($POST['category']);
		$item_name=addslashes($POST['item_name']);
		$item_desc=addslashes($POST['item_desc']);
		$image=$_FILES['image']['name'];
		$price=addslashes($POST['price']);
		$itemtype=$POST['itemtype'];
		if($_SESSION['type']=='Hotel')
		{
			$user_id	=$_SESSION['userID'];
		}
		else
		{
			$user_id	=addslashes($POST['user_id']);
		}
		$Folder		    =	"../images/item/";
			
			if(trim($_FILES['image']['name'])!="")
			{
				$ForWeb=explode(".",$_FILES['image']['name']);
				$image	=	uniqid(rand(1,99999),false).".".$ForWeb[1];
				$imagePath1	=	$Folder.$image;
				$copy=copy($_FILES['image']['tmp_name'],$imagePath1);
				
				$size=getimagesize($_FILES['image']['tmp_name']);
				
				$this->general->resizeImageWdthHegt($imagePath1,150,80);
			}
			
		if(($category!="")&&($cat_id==""))
		{
			$sql1="insert into menu_cat(user_id,category) values('$user_id','$category')";
			$res1	= $this->db ->setQuery($sql1);
			
			$sql2="select max(cat_id) as id from menu_cat";
			$row	= $this ->db ->readValue($sql2);
			$cat_id=$row['id'];
		}
			
		$sql="insert into menu(user_id,cat_id,item_name,item_desc,image,price,item_type) values('$user_id','$cat_id','$item_name','$item_desc','$image','$price','$itemtype')";
		
		$res	= $this->db ->setQuery($sql);
		
		return "Item added successfully";
	}
	function selectMenuById($item_id)
	{
			$qry	=	"Select * from `menu` where `item_id`=$item_id";	
			//echo $qry;exit;
			$res	=	$this->db->readValue($qry);
			return $res;
  	}	

	function updateMenu($POST,$item_id,$user_id)
	{
		$cat_id=addslashes($POST['cat_id']);
		$category=addslashes($POST['category']);
		$item_name=addslashes($POST['item_name']);
		$item_desc=addslashes($POST['item_desc']);
		$image1=$_FILES['image']['name'];
		$price=addslashes($POST['price']);
		$itemtype=$POST['itemtype'];
		
		if(($category!="")&&($cat_id==""))
		{
			$sql2="insert into menu_cat(user_id,category) values('$user_id','$category')";
			$res2	= $this->db ->setQuery($sql2);
			
			$sql3="select max(cat_id) as id from menu_cat";
			$row	= $this ->db ->readValue($sql3);
			$cat_id=$row['id'];
		}

		
		$sql="update menu set cat_id='$cat_id',item_name='$item_name',item_desc='$item_desc',price='$price' ,item_type='$itemtype' where  item_id='$item_id'";
		$res	= $this->db ->setQuery($sql);
		
		if($_FILES['image']['name']!="")
			{
				$Folder		    =	"../images/item/";
				$pic    	=   $this->selectMenuById($item_id);
 				$file		=	$pic['image'];
  				if(is_file($Folder.$file))
				{
 				unlink($Folder.$file);
				}
				 $ForWeb=explode(".",$_FILES['image']['name']);
				 $image		=   uniqid(rand(1,99999),false).".".$ForWeb[1];
				 $imagePath =   $Folder.$image;
 			   	 $copy		=   copy($_FILES['image']['tmp_name'],$imagePath);
			  	 $size		=	getimagesize($_FILES['image']['tmp_name']);
			  	 $width		=	$size[0];
			  	 $height	=	$size[1];
				 $this->general->resizeImageWdthHegt($imagePath,300,350);
				$qry1		=	"update menu SET image='".$image."' where item_id='$item_id'";
			    $res	=$this->db->setQuery($qry1);
			}
			
		return "Item updated successfully";
	}
	function getItemdetails($item_id)
	{
		$sql="select * from menu left join menu_cat on menu.cat_id=menu_cat.cat_id where item_id='$item_id'";
		$res	= $this->db ->readValue($sql);
		
		return $res;
	}
	function getRestCategory($userid)
	{
		$sql="select * from rest_includes left join rest_categories on rest_includes.rest_category_id=rest_categories.rest_category_id where user_id='$userid'";
		$res	= $this->db ->readValues($sql);
		return $res;
	}
	function getFoodTypes($userid)
	{
		$sql="select * from rest_foodtypes left join foodtypes on rest_foodtypes.food_id=foodtypes.food_id where 			user_id='$userid'";
		//echo $sql;exit;
		$res	= $this->db ->readValues($sql);
		return $res;
	}

	function getworktime($user_id,$day_id)
	{
		$sql="select * from rest_worktime where user_id='$user_id' and day_id='$day_id'";
		//echo $sql;exit;
		$res	= $this->db ->readValue($sql);
		return $res;
	}
	function addWorktime($POST,$userid)
	{
		$day_id=$POST['day_id'];
		$open_hour=$POST['open_hour'];
		$open_minute=$POST['open_minute'];
		
		$close_hour=$POST['close_hour'];
		$close_minute=$POST['close_minute'];
		
		$bopen_hour		=	$POST['bopen_hour'];
		$bopen_minute	=	$POST['bopen_minute'];
		
		$bclose_hour	=	$POST['bclose_hour'];
		$bclose_minute	=	$POST['bclose_minute'];
		
		$drv_open_hour=$POST['drv_open_hour'];
		$drv_open_minute=$POST['drv_open_minute'];
		
		$drv_close_hour=$POST['drv_close_hour'];
		$drv_close_minute=$POST['drv_close_minute'];
		
		$drv_bopen_hour		=	$POST['drv_bopen_hour'];
		$drv_bopen_minute	=	$POST['drv_bopen_minute'];
		
		$drv_bclose_hour	=	$POST['drv_bclose_hour'];
		$drv_bclose_minute	=	$POST['drv_bclose_minute'];

		
		$i=0;
		foreach($day_id as $id)
		{
			
			$open=$open_hour[$i].":".$open_minute[$i];
			$close=$close_hour[$i].":".$close_minute[$i];
			
			$bopen=$bopen_hour[$i].":".$bopen_minute[$i];
			$bclose=$bclose_hour[$i].":".$bclose_minute[$i];
			
			$drv_open=$drv_open_hour[$i].":".$drv_open_minute[$i];
			$drv_close=$drv_close_hour[$i].":".$drv_close_minute[$i];
			
			$drv_bopen=$drv_bopen_hour[$i].":".$drv_bopen_minute[$i];
			$drv_bclose=$drv_bclose_hour[$i].":".$drv_bclose_minute[$i];
			
			$sql="insert into rest_worktime(day_id,user_id,opentime,closetime,breakopentime,breakclosetime,drv_opentime,drv_closetime,drv_breakopentime,drv_breakclosetime) values('$id','$userid','$open','$close','$bopen','$bclose','$drv_open','$drv_close','$drv_bopen','$drv_bclose')";
			//echo $sql;exit;
			$res1	= $this->db ->setQuery($sql);
			$i++;
		}
		return "work time updated successfully";
	}
	function updateWorktime($POST,$userid)
	{
		$day_id=$POST['day_id'];
		$open_hour=$POST['open_hour'];
		$open_minute=$POST['open_minute'];
		
		$close_hour=$POST['close_hour'];
		$close_minute=$POST['close_minute'];
		
		$bopen_hour=$POST['bopen_hour'];
		$bopen_minute=$POST['bopen_minute'];
		
		$bclose_hour=$POST['bclose_hour'];
		$bclose_minute=$POST['bclose_minute'];
		
		$drv_open_hour=$POST['drv_open_hour'];
		$drv_open_minute=$POST['drv_open_minute'];
		
		$drv_close_hour=$POST['drv_close_hour'];
		$drv_close_minute=$POST['drv_close_minute'];
		
		$drv_bopen_hour=$POST['drv_bopen_hour'];
		$drv_bopen_minute=$POST['drv_bopen_minute'];
		
		$drv_bclose_hour=$POST['drv_bclose_hour'];
		$drv_bclose_minute=$POST['drv_bclose_minute'];
		
		$i=0;
		foreach($day_id as $id)
		{
			$open=$open_hour[$i].":".$open_minute[$i];
			$close=$close_hour[$i].":".$close_minute[$i];
			
			$bopen=$bopen_hour[$i].":".$bopen_minute[$i];
			$bclose=$bclose_hour[$i].":".$bclose_minute[$i];
			
			$drv_open=$drv_open_hour[$i].":".$drv_open_minute[$i];
			$drv_close=$drv_close_hour[$i].":".$drv_close_minute[$i];
			
			$drv_bopen=$drv_bopen_hour[$i].":".$drv_bopen_minute[$i];
			$drv_bclose=$drv_bclose_hour[$i].":".$drv_bclose_minute[$i];
			
			$sql="update rest_worktime set opentime='$open',closetime='$close',breakopentime='$bopen',breakclosetime='$bclose' ,drv_opentime='$drv_open',drv_closetime='$drv_close',drv_breakopentime='$drv_bopen',drv_breakclosetime='$drv_bclose' where day_id='$id' and user_id='$userid'";
			$res1	= $this->db ->setQuery($sql);
			$i++;
		}
		return "Work time updated successfully";
	}
	
	function getOrderedItemdetails($order_id)
	{
		$sql="select * from order_details left join menu on order_details.item_id=menu.item_id where order_id='$order_id'";
		$res	= $this->db ->readValues($sql);
		return $res;
	}
	function getAllrestaurant($Offset='',$RowsPerPage='',$txt_search='',$rest_type='')
	{
		$sql="select *,CASE WHEN rest_type='Premium' THEN 1 WHEN rest_type='Deluxe' THEN 2 WHEN rest_type='Economy' THEN 3 END AS restaurantOrder from user where 1=1 and type='Hotel' and status!='Deleted' ";
		if($rest_type!="")
		{
			$sql.=" and rest_type='$rest_type' ";
		}
		if($txt_search!="")
		{
			$sql.=" and (name like '%$txt_search%' or email like '%$txt_search%' or mobile like '%$txt_search%' or pin like '%$txt_search%' or city like '%$txt_search%')";
		}
		
		$sql.=" order by restaurantOrder asc,user_id desc ";
		
		if(trim($Offset)!="" && trim($RowsPerPage)!="")
			{	$sql .=	" LIMIT $Offset,$RowsPerPage";	}
			
		$res	= $this->db ->readValues($sql);
		return $res;
	}
	
	
	function getAllrestaurant1($Offset='',$RowsPerPage='',$txt_search='',$rest_type='')
	{
		$sql="select *,CASE WHEN rest_type='Premium' THEN 1 WHEN rest_type='Deluxe' THEN 2  END AS restaurantOrder from user where 1=1 and type='Hotel' and (rest_type='Premium' or rest_type='Deluxe')";
		if($rest_type!="")
		{
			$sql.=" and rest_type='$rest_type' ";
		}
		if($txt_search!="")
		{
			$sql.=" and (name like '%$txt_search%' or email like '%$txt_search%' or mobile like '%$txt_search%' or pin like '%$txt_search%' or city like '%$txt_search%')";
		}
		
		$sql.=" order by restaurantOrder asc,user_id desc ";
		if(trim($Offset)!="" && trim($RowsPerPage)!="")
			{	$sql .=	" LIMIT $Offset,$RowsPerPage";	}
			
		$res	= $this->db ->readValues($sql);
		
		
		return $res;
	}

	function getAllrestaurantcnt($txt_search='',$rest_type='')
	{
		$sql="select * from user where 1=1 and type='Hotel' and status!='Deleted' ";
		
		if($rest_type!="")
		{
			$sql.=" and rest_type='$rest_type' ";
		}
		if($txt_search!="")
		{
			$sql.=" and (name like '%$txt_search%' or email like '%$txt_search%' or mobile like '%$txt_search%' or pin like '%$txt_search%' or city like '%$txt_search%')";
		}
		
		$sql.=" order by user_id desc";
		$res	= $this->db ->readValues($sql);
		$cnt=count($res);
		return $cnt;
	}
	
	function getAllordercnt($rest_id='',$date='',$order_status='',$user_id='',$datefrom='',$dateto='',$order_type='',$order_payment='',$order_id_search='')
	{
		if($order_id_search!='')
		{
			$order_status="";
		}
		$sql="select * from orders where 1=1";
		if($rest_id!='')
		{
			$sql.=" and rest_id='$rest_id'";
		}
		if($date!='')
		{
			$sql.=" and order_date='$date'";
		}
		if($order_status!='')
		{
			$sql.=" and status_order='$order_status'";
		}
		if($user_id!='')
		{
			$sql.=" and user_id='$user_id'";
		}
		if($datefrom!="" && $dateto!="")
		{
			$sql.=" and order_date between '$datefrom' and '$dateto'";
		}
		if($order_type!='')
		{
			$sql.=" and order_type='$order_type'";
		}
		if($order_payment!='')
		{
			$sql.=" and order_payment='$order_payment'";
		}
		if($order_id_search!='')
		{
			$sql.=" and order_id='$order_id_search'";
		}
		
	//echo $sql;exit;
		$res	= $this->db ->readValues($sql);
		
		$cnt=count($res);
		
		return $cnt;
	}
	
	
	function getAllordercnt_new($rest_id='',$date='',$order_status='',$user_id='',$order_state='',$datefrom='',$dateto='',$order_type='',$order_payment='',$order_id_search='')
	{
		if($order_id_search!='')
		{
			$order_status="";
		}
		$sql="select * from orders where 1=1";
		if($rest_id!='')
		{
			$sql.=" and rest_id='$rest_id'";
		}
		if($date!='')
		{
			$sql.=" and order_date='$date'";
		}
		if($order_status!='')
		{
			$sql.=" and status_order='$order_status'";
		}
		
		if($user_id!='')
		{
			$sql.=" and user_id='$user_id'";
		}
		if($order_state!='')
		{
			$sql.=" and order_state='$order_state'";
		}
		if($datefrom!="" && $dateto!="")
		{
			$sql.=" and order_date between '$datefrom' and '$dateto'";
		}
		if($order_type!='')
		{
			$sql.=" and order_type='$order_type'";
		}
		if($order_payment!='')
		{
			$sql.=" and order_payment='$order_payment'";
		}
		if($order_id_search!='')
		{
			$sql.=" and order_id='$order_id_search'";
		}
		
	//echo $sql;exit;
		$res	= $this->db ->readValues($sql);
		
		$cnt=count($res);
		
		return $cnt;
	}
	
	
	
	function getAllorder($Offset='',$RowsPerPage='',$rest_id='',$date,$order_status='',$user_id='',$datefrom='',$dateto='',$order_type='',$order_payment='',$order_id_search='')
	{
		if($order_id_search!='')
		{
			$order_status="";
		}
		$sql="select * from orders left join user on user.user_id=orders.user_id   where 1=1";
		
		if($date!="")
		{
			$sql.=" and orders.order_date='$date'";
		}
		if($order_status!='')
		{
			$sql.=" and orders.status_order='$order_status'";
		}
		if($user_id!='')
		{
			$sql.=" and orders.user_id='$user_id'";
		}
		if($rest_id!='')
		{
			$sql.=" and orders.rest_id='$rest_id'";
		}
		if($datefrom!="" && $dateto!="")
		{
			$sql.=" and orders.order_date between '$datefrom' and '$dateto'";
		}
		if($order_type!='')
		{
			$sql.=" and orders.order_type='$order_type'";
		}
		if($order_payment!='')
		{
			$sql.=" and orders.order_payment='$order_payment'";
		}
		if($order_id_search!='')
		{
			$sql.=" and orders.order_id='$order_id_search'";
		}
		//echo $sql;exit;
		$sql.=" order by orders.order_id desc";
		
		if(trim($Offset)!="" && trim($RowsPerPage)!="")
		{	
			$sql.=	" LIMIT $Offset,$RowsPerPage";	
		}
		//echo $sql;exit;
		$res	= $this->db ->readValues($sql);
		return $res;
	}
	function getAllorder1($Offset='',$RowsPerPage='',$rest_id='',$date,$order_status='',$user_id='',$datefrom='',$dateto='',$order_type='',$order_payment='',$order_id_search='')
	{
		if($order_id_search!='')
		{
			$order_status="";
		}
		$sql="select user.* from orders left join user on user.user_id=orders.rest_id  where 1=1";
		
		if($date!="")
		{
			$sql.=" and orders.order_date='$date'";
		}
		if($order_status!='')
		{
			$sql.=" and orders.status_order='$order_status'";
		}
		if($user_id!='')
		{
			$sql.=" and orders.user_id='$user_id'";
		}
		if($rest_id!='')
		{
			$sql.=" and orders.rest_id='$rest_id'";
		}
		if($datefrom!="" && $dateto!="")
		{
			$sql.=" and orders.order_date between '$datefrom' and '$dateto'";
		}
		if($order_type!='')
		{
			$sql.=" and orders.order_type='$order_type'";
		}
		if($order_payment!='')
		{
			$sql.=" and orders.order_payment='$order_payment'";
		}
		if($order_id_search!='')
		{
			$sql.=" and orders.order_id='$order_id_search'";
		}
		
		$sql.=" order by orders.order_id desc";
		if(trim($Offset)!="" && trim($RowsPerPage)!="")
		{	
			$sql.=	" LIMIT $Offset,$RowsPerPage";	
		}
		$res1	= $this->db ->readValues($sql);
		
		return $res1;
	}
	
	
	function getAllorder_new($Offset='',$RowsPerPage='',$rest_id='',$date,$order_status='',$user_id='',$order_state='',$datefrom='',$dateto='',$order_type='',$order_payment='',$order_id_search='')
	{
	//echo $order_state;
		if($order_id_search!='')
		{
			$order_status="";
		}
		$sql="select * from orders left join user on user.user_id=orders.user_id   where 1=1";
		
		if($date!="")
		{
			$sql.=" and orders.order_date='$date'";
		}
		if($order_status!='')
		{
			$sql.=" and orders.status_order='$order_status'";
		}
		if($user_id!='')
		{
			$sql.=" and orders.user_id='$user_id'";
		}
		if($order_state!='')
		{
			$sql.=" and order_state='$order_state'";
		}
		if($rest_id!='')
		{
			$sql.=" and orders.rest_id='$rest_id'";
		}
		if($datefrom!="" && $dateto!="")
		{
			$sql.=" and orders.order_date between '$datefrom' and '$dateto'";
		}
		if($order_type!='')
		{
			$sql.=" and orders.order_type='$order_type'";
		}
		if($order_payment!='')
		{
			$sql.=" and orders.order_payment='$order_payment'";
		}
		if($order_id_search!='')
		{
			$sql.=" and orders.order_id='$order_id_search'";
		}
		//echo $sql;exit;
		$sql.=" order by orders.order_id desc";
		
		if(trim($Offset)!="" && trim($RowsPerPage)!="")
		{	
			$sql.=	" LIMIT $Offset,$RowsPerPage";	
		}
		//echo $sql;
		//exit;
		$res	= $this->db ->readValues($sql);
		return $res;
	}
	
	function getAllorder1_new($Offset='',$RowsPerPage='',$rest_id='',$date,$order_status='',$user_id='',$order_state='',$datefrom='',$dateto='',$order_type='',$order_payment='',$order_id_search='')
	{
		if($order_id_search!='')
		{
			$order_status="";
		}
		$sql="select user.* from orders left join user on user.user_id=orders.rest_id  where 1=1";
		
		if($date!="")
		{
			$sql.=" and orders.order_date='$date'";
		}
		if($order_status!='')
		{
			$sql.=" and orders.status_order='$order_status'";
		}
		if($user_id!='')
		{
			$sql.=" and orders.user_id='$user_id'";
		}
		if($order_state!='')
		{
			$sql.=" and order_state='$order_state'";
		}
		if($rest_id!='')
		{
			$sql.=" and orders.rest_id='$rest_id'";
		}
		if($datefrom!="" && $dateto!="")
		{
			$sql.=" and orders.order_date between '$datefrom' and '$dateto'";
		}
		if($order_type!='')
		{
			$sql.=" and orders.order_type='$order_type'";
		}
		if($order_payment!='')
		{
			$sql.=" and orders.order_payment='$order_payment'";
		}
		if($order_id_search!='')
		{
			$sql.=" and orders.order_id='$order_id_search'";
		}
		
		$sql.=" order by orders.order_id desc";
		if(trim($Offset)!="" && trim($RowsPerPage)!="")
		{	
			$sql.=	" LIMIT $Offset,$RowsPerPage";	
		}
		$res1	= $this->db ->readValues($sql);
		
		return $res1;
	}
	
	
	function getAllordercntpayments($rest_id='',$date='',$order_status='',$user_id='',$order_state='',$datefrom='',$dateto='',$order_type='',$order_payment='',$order_id_search='')
	{
		if($order_id_search!='')
		{
			$order_status="";
		}
		$sql="select * from orders where 1=1 ";
		
		$sql.=" and order_payment = 'Card'";
		
		if($rest_id!='')
		{
			$sql.=" and rest_id='$rest_id'";
		}
		if($date!='')
		{
			$sql.=" and order_date='$date'";
		}
		if($order_status!='')
		{
			$sql.=" and status_order='$order_status'";
		}
		
		if($user_id!='')
		{
			$sql.=" and user_id='$user_id'";
		}
		if($order_state!='')
		{
			$sql.=" and order_state='$order_state'";
		}
		if($datefrom!="" && $dateto!="")
		{
			$sql.=" and order_date between '$datefrom' and '$dateto'";
		}
		if($order_type!='')
		{
			$sql.=" and order_type='$order_type'";
		}
		if($order_payment!='')
		{
			$sql.=" and order_payment='$order_payment'";
		}
		if($order_id_search!='')
		{
			$sql.=" and order_id='$order_id_search'";
		}
		
	//echo $sql;exit;
		$res	= $this->db ->readValues($sql);
		
		$cnt=count($res);
		
		return $cnt;
	}
	
	
		function getAllorderpayments($Offset='',$RowsPerPage='',$rest_id='',$date,$order_status='',$user_id='',$order_state='',$datefrom='',$dateto='',$order_type='',$order_payment='',$order_id_search='')
	{
	//echo $order_state;
		if($order_id_search!='')
		{
			$order_status="";
		}
		$sql="select * from orders left join user on user.user_id=orders.user_id  where 1=1";
		
		$sql.=" and payments != 'paid' and orders.status_order='Delivered'";
		
		$sql.=" and order_payment = 'Card'";
		
		if($date!="")
		{
			$sql.=" and orders.order_date='$date'";
		}
		/*if($order_status!='')
		{
			$sql.=" and orders.status_order='Delivered'";
		}*/
		if($user_id!='')
		{
			$sql.=" and orders.user_id='$user_id'";
		}
		if($order_state!='')
		{
			$sql.=" and order_state='$order_state'";
		}
		if($rest_id!='')
		{
			$sql.=" and orders.rest_id='$rest_id'";
		}
		if($datefrom!="" && $dateto!="")
		{
			$sql.=" and orders.order_date between '$datefrom' and '$dateto'";
		}
		if($order_type!='')
		{
			$sql.=" and orders.order_type='$order_type'";
		}
		if($order_payment!='')
		{
			$sql.=" and orders.order_payment='$order_payment'";
		}
		if($order_id_search!='')
		{
			$sql.=" and orders.order_id='$order_id_search'";
		}
		//echo $sql;exit;
		$sql.=" order by orders.order_id desc";
		
		if(trim($Offset)!="" && trim($RowsPerPage)!="")
		{	
			$sql.=	" LIMIT $Offset,$RowsPerPage";	
		}
		//echo $sql;//exit;
		$res	= $this->db ->readValues($sql);
		return $res;
	}
	
	function getAllorder1payments($Offset='',$RowsPerPage='',$rest_id='',$date,$order_status='',$user_id='',$order_state='',$datefrom='',$dateto='',$order_type='',$order_payment='',$order_id_search='')
	{
		if($order_id_search!='')
		{
			$order_status="";
		}
		$sql="select user.* from orders left join user on user.user_id=orders.rest_id  where 1=1";
		
		$sql.=" and order_payment = 'Card'";
		
		if($date!="")
		{
			$sql.=" and orders.order_date='$date'";
		}
		if($order_status!='')
		{
			$sql.=" and orders.status_order='$order_status'";
		}
		if($user_id!='')
		{
			$sql.=" and orders.user_id='$user_id'";
		}
		if($order_state!='')
		{
			$sql.=" and order_state='$order_state'";
		}
		if($rest_id!='')
		{
			$sql.=" and orders.rest_id='$rest_id'";
		}
		if($datefrom!="" && $dateto!="")
		{
			$sql.=" and orders.order_date between '$datefrom' and '$dateto'";
		}
		if($order_type!='')
		{
			$sql.=" and orders.order_type='$order_type'";
		}
		if($order_payment!='')
		{
			$sql.=" and orders.order_payment='$order_payment'";
		}
		if($order_id_search!='')
		{
			$sql.=" and orders.order_id='$order_id_search'";
		}
		
		$sql.=" order by orders.order_id desc";
		if(trim($Offset)!="" && trim($RowsPerPage)!="")
		{	
			$sql.=	" LIMIT $Offset,$RowsPerPage";	
		}
		$res1	= $this->db ->readValues($sql);
		
		return $res1;
	}
	
	
	
	
	function updateDelivery($POST,$user_id)
	{
		if(isset($POST['delivery']))
		$delivery		= addslashes($POST['delivery']);
		else
		$delivery		='No';
				
		$distance		= addslashes($POST['distance']);
		if($distance=='')
		$distance=0;
		
		$fee			= addslashes($POST['fee']);
		if($fee=='')
		$fee=0;
		
		if(isset($POST['cash']))
		$cash		= addslashes($POST['cash']);
		else
		$cash		='No';
		
		$discount			= addslashes($POST['discount']);
		if($discount=='')
		$discount=0;
		
		if($discount>100)
		$discount=100;
		
		$minorder		=addslashes($POST['minorder']);
		if($minorder=='')
		$minorder=0;
		
		$mincollection	=addslashes($POST['min_collectn']);
		$del_weeks		=addslashes($POST['del_weeks']);
		$del_ends		=addslashes($POST['del_ends']);
		
		$sql    		= "update user set delivery_distance='$distance',delivery_fee='$fee',cash_payment='$cash',delivery='$delivery',discount='$discount',min_amount='$minorder',min_time_collection='$mincollection',delivery_t_weekdays='$del_weeks',delivery_t_weekends='$del_ends' where user_id='$user_id'";
		$res			= $this->db ->setQuery($sql);
		
		$sql_search 		= "update rest_searchtable set delivery_distance='$distance',delivery_fee='$fee',delivery='$delivery',min_amount='$minorder' where user_id='$user_id'";
				
		mysql_query($sql_search);
		
		return "Delivery details updated successfully";
	}
	
	function selectmailLists($id)
	{
			$qry	=	"Select * from `mailing_list` where `list_id`=$id";
			$res	=	$this->db->readValue($qry);
			return $res;
	}
	function selectAllUsers()
	{
			$qry	=	"Select email from `user` where `type`='User'";
			$res	=	$this->db->readValue($qry);
			return $res;
	}
	function selectAllRestaurants()
	{
			$qry	=	"Select email from `user` where `type`='Hotel'";
			$res	=	$this->db->readValue($qry);
			return $res;
	}
////  Buffet Menu & Category //////
	function addBuffet($POST)
	{
		$buffet_id		 = addslashes($POST['buffet_id']);
		$buffet_category = addslashes($POST['buffet_category']);
		$buffet_name     = addslashes($POST['buffet_name']);
		$buffet_desc     = addslashes($POST['buffet_desc']);
		$buffet_image    = $_FILES['image']['name'];
		$buffet_price    = addslashes($POST['buffet_price']);
		
		
		if($_SESSION['type']=='Hotel')
		{
			$user_id	=$_SESSION['userID'];
		}
		else
		{
			$user_id	=$POST['user_id'];
		}
		$Folder		    =	"../images/Buffetitem/";
			
			if(trim($_FILES['image']['name'])!="")
			{
				$ForWeb=explode(".",$_FILES['image']['name']);
				$image	=	uniqid(rand(1,99999),false).".".$ForWeb[1];
				$imagePath1	=	$Folder.$image;
				$copy=copy($_FILES['image']['tmp_name'],$imagePath1);
				
				$size=getimagesize($_FILES['image']['tmp_name']);
				
				$this->general->resizeImageWdthHegt($imagePath1,150,80);
			}
			
		if(($buffet_category!="")&&($buffet_id==""))
		{
			$sql1="insert into buffet_cat(buffet_category) values('$buffet_category')";
			$res1	= $this->db ->setQuery($sql1);
			$sql2="select max(buffet_cat_id) as id from buffet_cat";
			$row	= $this ->db ->readValue($sql2);
			$buffet_id=$row['id'];
		}
			
		$sql="insert into buffet(user_id,buffet_cat_id,buffet_name,buffet_desc,buffet_image,buffet_price) values('$user_id','$buffet_id','$buffet_name','$buffet_desc','$image','$buffet_price')";
		$res	= $this->db ->setQuery($sql);
		return "BuffetItem added successfully";
	}
	function selectBuffetById($buffet_id)
	{
			$qry	=	"Select * from `buffet` where `buffet_id`=$buffet_id";	
			$res	=	$this->db->readValue($qry);
			return $res;
  	}	

	function updateBuffet($POST,$buffet_id,$user_id)
	{
		$buffet_id       = addslashes($POST['buffet_id']);
		$buffet_category = addslashes($POST['buffet_category']);
		$buffet_name     = addslashes($POST['buffet_name']);
		$buffet_desc     = addslashes($POST['buffet_desc']);
		$buffet_image    = $_FILES['image']['name'];
		$buffet_price    = addslashes($POST['buffet_price']);
		
		if(($buffet_category!="")&&($buffet_id==""))
		{
			$sql2="insert into buffet_cat(buffet_category) values('$buffet_category')";
			$res2	= $this->db ->setQuery($sql2);
			$sql3="select max(buffet_cat_id) as id from buffet_cat";
			$row	= $this ->db ->readValue($sql3);
			$buffet_id=$row['id'];
		}
    $sql="update buffet set buffet_cat_id='$buffet_id',buffet_name='$buffet_name',buffet_desc='$buffet_desc',buffet_price='$buffet_price' where  buffet_id='$buffet_id'";
		$res	= $this->db ->setQuery($sql);
		
		if($_FILES['image']['name']!="")
			{
				$Folder		    =	"../images/Buffetitem/";
				$pic    	=   $this->selectBuffetById($buffet_id);
 				$file		=	$pic['buffet_image'];
  				if(is_file($Folder.$file))
				{
 				unlink($Folder.$file);
				}
				 $ForWeb=explode(".",$_FILES['image']['name']);
				 $image		=   uniqid(rand(1,99999),false).".".$ForWeb[1];
				 $imagePath =   $Folder.$image;
 			   	 $copy		=   copy($_FILES['image']['tmp_name'],$imagePath);
			  	 $size		=	getimagesize($_FILES['image']['tmp_name']);
			  	 $width		=	$size[0];
			  	 $height	=	$size[1];
				 $this->general->resizeImageWdthHegt($imagePath,$width,$height);
				 $qry1		=	"update buffet SET buffet_image='".$image."' where buffet_id='$buffet_id'";
			     $res	=$this->db->setQuery($qry1);
			}
       }
	
	function getBuffetItemdetails($buffet_id)
	{
	    $sql="select * from buffet left join buffet_cat on buffet.buffet_cat_id=buffet_cat.buffet_cat_id where      buffet_id='$buffet_id'";
		$res	= $this->db ->readValue($sql);
		return $res;
	}	
	function categoryExists($category)
	{
		$category=addslashes($category);
		$sql="select * from menu_cat where category='$category'";
		$res	= $this->db ->readValue($sql);
		return $res;
	}	
	function ItemExists($item_name,$user_id)
	{
		$item_name=addslashes($item_name);
		$sql="select * from menu where item_name='$item_name' and user_id='$user_id' and status!='Deleted'";
		$res	= $this->db ->readValue($sql);
		return $res;
	}
	function ItemExistsUpdate($item_name,$user_id,$item_id)
	{
		$item_name=addslashes($item_name);
		$sql="select * from menu where item_name='$item_name' and user_id='$user_id' and item_id!='$item_id' and status!='Deleted'";
		$res	= $this->db ->readValue($sql);
		return $res;
	}
	function deleteRestaurant($user_id)
	{
		$sql="update user set status='Deleted' where user_id='$user_id'";
		//echo $sql;exit;
		$res	=$this->db->setQuery($sql);
		
		$sqlsearch="update rest_searchtable  set status='Deleted' where user_id='$user_id'";
		//echo $sql;exit;
		$res2	=$this->db->setQuery($sqlsearch);
		return $res;
	}
	function existsGeneral($table,$field=array())
	{
		$sql="select * from $table ";
		if(!empty($field))
		{
			$field1=array_keys($field);
			$field2=$field1[0];
			$field3=$field[$field2];
			$sql.=" where $field2='$field3' and status!='Deleted' ";
		}
		$row	= $this ->db ->readValue($sql);
		return $row;
	}
	function addMenuAll($POST,$user_id)
	{
		$cat_id=addslashes($POST['cat_id']);
		$category=addslashes($POST['category']);
		$item_name=$POST['item_name'];
		$item_desc=$POST['item_desc'];
		$image=$_FILES['image']['name'];
		$temp_image=$_FILES['image']['tmp_name'];
		$price=$POST['price'];
		$itemtype=$POST['itemtype'];
		$count=count($item_name);
		
		
			//echo $_FILES['image']['name'][1];exit;
		
		//print_r($_FILES['image']['tmp_name']);exit;
			
		if(($category!="")&&($cat_id==""))
		{
			$sql1="insert into menu_cat(user_id,category) values('$user_id','$category')";
			$res1	= $this->db ->setQuery($sql1);
			
			$sql2="select max(cat_id) as id from menu_cat";
			$row	= $this ->db ->readValue($sql2);
			$cat_id=$row['id'];
		}
		
		
		$Folder		    =	"../images/item/";
		
		//print_r($image);
		for($i=0;$i<$count;$i++)
		{
			
			if(($_FILES['image']['name'][$i])!="")
			{
				$ForWeb=explode(".",$_FILES['image']['name'][$i]);
				$image1	=	uniqid(rand(1,99999),false).".".$ForWeb[1];
				$imagePath1	=	$Folder.$image1;
				$copy=copy($temp_image[$i],$imagePath1);
				
				$size=getimagesize($temp_image[$i]);
				
				$this->general->resizeImageWdthHegt($imagePath1,300,350);
				
			}
			
			$name=addslashes($item_name[$i]);
			$desc=addslashes($item_desc[$i]);
			$price1=addslashes($price[$i]);
			$itemtype1=$itemtype[$i];
			
			$sql="insert into menu(user_id,cat_id,item_name,item_desc,image,price,item_type) values('$user_id','$cat_id','$name','$desc','$image1','$price1','$itemtype1')";
			
			//echo $sql;exit;
			$res	= $this->db ->setQuery($sql);
			$image1="";
			$name="";
			$desc="";
			$price1="";
		}
		return "Menu added successfully";
		
		
	}
	function Itemdelete($item_id)
	{
		$sql="update menu set status='Deleted' where item_id='$item_id'";
		$res	= $this->db ->setQuery($sql);
		return "Item deleted successfully";
	}
	function getAllitemcnt($txt_search='',$user_id,$category)
	{
		$sql="select * from menu where user_id='$user_id' and status!='Deleted'";
		if($txt_search!="")
		{
			$sql.=" and (item_name like '%$txt_search%' or price like '%$txt_search%')";
		}
		if($category!="")
		{
			$sql.=" and (cat_id='$category')";
		}
		$sql.=" order by item_id desc";
		//echo $sql;exit;
		$res	= $this->db ->readValues($sql);
		$cnt=count($res);
		return $cnt;
	}
	function getAllitem($user_id,$Offset='',$RowsPerPage='',$txt_search,$category='')
	{
		$sql="select * from menu left join menu_cat on menu.cat_id=menu_cat.cat_id where menu.user_id='$user_id' and menu.status!='Deleted'";
		
		if($txt_search!="")
		{
			$sql.=" and (menu.item_name like '%$txt_search%')";
		}
		if($category!="")
		{
			$sql.="  and menu.cat_id='$category'";
		}
		
		if(trim($Offset)!="" && trim($RowsPerPage)!="")
			{	$sql .=	" LIMIT $Offset,$RowsPerPage";	}
			//echo $sql;exit;
		$rows	= $this ->db ->readValues($sql);
		return $rows;
	}
	
	/*function Insert_Profile($POST)
	{
 		$name	=	trim(addslashes($POST['name']));
		$list_type= trim(addslashes($POST['list_type']));
		$sub_type=  trim(addslashes($POST['sub_type']));
 		$emailid=	trim(addslashes($POST['emailid']));
		$password=	trim(addslashes($POST['password']));
 		$mobno  =	trim(addslashes($POST['mobno']));	
 		$phno   =	trim(addslashes($POST['phno']));	
 		$address=	trim(addslashes($POST['address']));
		$address2= 	trim(addslashes($POST['address2']));
		$location= 	trim(addslashes($POST['location']));
 		$pin    =	trim(addslashes($POST['pin']));	
 		$city   =	trim(addslashes($POST['city']));
 		$state  =	trim(addslashes($POST['state']));
		$district=  trim(addslashes($POST['district']));
 		$country=	trim(addslashes($POST['country']));
		$desc	=	trim(addslashes($POST['desc']));	
		$contacts= 	trim(addslashes($POST['contacts']));
		
		$food_type		=	$POST['food_type'];
		$rest_category	=	$POST['rest_category'];
		$delivery_areas=$POST['delivery_areas'];
		$url=trim(addslashes($POST['url']));
		
		$distance		= addslashes($POST['distance']);
		if($distance=='')
		$distance=0;
		
		$fee			= addslashes($POST['fee']);
		if($fee=='')
		$fee=0;
			
		$cash='No';
		if(isset($POST['cash']))
		$cash='Yes';
		
		$card='cNo';
		if(isset($POST['card']))
		$card='cYes';

		
		$delivery='No';
		if(isset($POST['delivery']))
		$delivery		='Yes';
			
		$discount			= addslashes($POST['discount']);
		if($discount=='')
		$discount=0;
		
		$tax				= addslashes($POST['tax']);
		if($tax=='')
		$tax=0;
		
		$min_amount=addslashes($POST['min_amount']);
		$rank	=	addslashes($POST['rank']);

		$min_time_collection=addslashes($POST['min_time_collection']);
		$delivery_t_weekdays=addslashes($POST['delivery_t_weekdays']);
		$delivery_t_weekends=addslashes($POST['delivery_t_weekends']);
		
		if($min_amount<200)
		{
			$min_amount=200;
		}
		
		$promot1			= addslashes($POST['promot1']);
		$promot1_rs			= addslashes($POST['promot1_rs']);
		$promot2			= addslashes($POST['promot2']);
		$promot2_rs			= addslashes($POST['promot2_rs']);
		$promot3			= addslashes($POST['promot3']);
		$promot3_rs			= addslashes($POST['promot3_rs']);
		$custom_promotions			= addslashes($POST['custom_promotions']);
		

		$date	=	$this->date;
		$qry	=	"insert into user(name,email,password,mobile,phone,address,address2,address3,pin,rest_contacts,city,state,district,country,description,
					delivery_area,register_date,delivery_distance,delivery_fee,cash_payment,card_payment,delivery,discount,servicetax,min_amount,min_time_collection,delivery_t_weekdays,delivery_t_weekends,list_type,type,status,rest_type,verification,menu_url,ranking) values('$name','$emailid','$password','$mobno','$phno','$address','$address2','$location','$pin','$contacts','$city','$state','$district','$country','$desc','','$date','$distance','$fee','$cash','$card','$delivery','$discount','$tax','$min_amount','$min_time_collection','$delivery_t_weekdays','$delivery_t_weekends','$list_type','Hotel','Active','$sub_type','','$url','$rank')"; 
		//echo $qry;exit;		
 	    $res	= 	$this->db ->setQuery($qry);
 		$id		=	mysql_insert_id();
		$insertFoodTypes=$this->reg->insertFoodTypes($id,$food_type);
		$insertRestCategory=$this->reg->insertRestCategory($id,$rest_category);
		$insertRestDeliveryAreas=$this->reg->insertRestDeliveryAreas($id,$delivery_areas);
		
		$addToWebConfig=$this->addToWebConfig($id,$url);

		
		$Folder	=	"../images/Restaurantimages/ImageLarg/";
		$Folder1=	"../images/Restaurantimages/ImageThumb/";
			if($_FILES['image']['name']!="")
			{
				$ForWeb=explode(".",$_FILES['image']['name']);
			 	$image		=   uniqid(rand(1,99999),false).".".$ForWeb[1];
			 	$imagePath1	=   $Folder.$image;
 			  	$copy		=   copy($_FILES['image']['tmp_name'],$imagePath1);
			  	$size		=	getimagesize($_FILES['image']['tmp_name']);
			  	$width		=	$size[0];
			  	$height		=	$size[1];
				$this->general->resizeImageWdthHegt($imagePath1,112,104);
				
				$imagePath2	=	$Folder1.$image;
			    $copy1		=	copy($_FILES['image']['tmp_name'],$imagePath2);
			    $size		=	getimagesize($_FILES['image']['tmp_name']);
			  
				$this->general->resizeImageWdthHegt($imagePath2,144,132);
				$qry1		=	"update user SET image='".$image."' where user_id='$id'";
			    $res	    =   $this->db->setQuery($qry1);				
			}
			
			
			$sql="select max(user_id) as ID from user";
			$row	= $this ->db ->readValue($sql);
			$user_id=$row['ID'];
			
			$addWorktime=$this->addWorktime($POST,$user_id);
			$addPromotions=$this->addPromotions($POST,$user_id);
			

		return $id;
	 }*/
	 
	 
	 function Insert_Profile($POST)
	{
 		$name	=	trim(addslashes($POST['name']));
		$list_type= trim(addslashes($POST['list_type']));
		$sub_type=  trim(addslashes($POST['sub_type']));
 		$emailid=	trim(addslashes($POST['emailid']));
		$password=	trim(addslashes($POST['password']));
 		$mobno  =	trim(addslashes($POST['mobno']));	
 		$phno   =	trim(addslashes($POST['phno']));	
 		$address=	trim(addslashes($POST['address']));
		$address2= 	trim(addslashes($POST['address2']));
		$location= 	trim(addslashes($POST['location']));
 		$pin    =	trim(addslashes($POST['pin']));	
 		$city   =	trim(addslashes($POST['city']));
 		$state  =	trim(addslashes($POST['state']));
		$district=  trim(addslashes($POST['district']));
 		$country=	trim(addslashes($POST['country']));
		$desc	=	trim(addslashes($POST['desc']));	
		$contacts= 	trim(addslashes($POST['contacts']));
		$restaurt_type	  =trim(addslashes($POST['restaurant_type'])); 
		//$flavour_type	  = $_POST['flavour'];
		
		$delivery_descption=$_POST['deliverydesc'];
		
		$commisions=$_POST['commission_detail'];
		$commisiontime=$_POST['commission_times'];
		
		$banknames=$_POST['bankname'];
		$branchs=$_POST['branch'];
		$accname=$_POST['accountname'];
		$accnos=$_POST['accountno'];
		$accounttype=$_POST['account_type'];
		$ifsccodes=$_POST['ifsccode'];
		$vouchercode=$_POST['vouchercode'];
		
		$food_type		=	$POST['food_type'];
		$rest_category	=	$POST['rest_category'];
		$delivery_areas=$POST['delivery_areas'];
		$url=trim(addslashes($POST['url']));
		
		$distance		= addslashes($POST['distance']);
		if($distance=='')
		$distance=0;
		
		$fee			= addslashes($POST['fee']);
		if($fee=='')
		$fee=0;
			
		$cash='No';
		if(isset($POST['cash']))
		$cash='Yes';
		
		$card='cNo';
		if(isset($POST['card']))
		$card='cYes';

		
		$delivery='No';
		if(isset($POST['delivery']))
		$delivery		='Yes';
			
		$discount			= addslashes($POST['discount']);
		if($discount=='')
		$discount=0;
		
		$tax				= addslashes($POST['tax']);
		if($tax=='')
		$tax=0;
		
		$min_amount=addslashes($POST['min_amount']);
		$rank	=	addslashes($POST['rank']);

		$min_time_collection=addslashes($POST['min_time_collection']);
		$delivery_t_weekdays=addslashes($POST['delivery_t_weekdays']);
		$delivery_t_weekends=addslashes($POST['delivery_t_weekends']);
		
		if($min_amount<200)
		{
			$min_amount=200;
		}
		
		$promot1			= addslashes($POST['promot1']);
		$promot1_rs			= addslashes($POST['promot1_rs']);
		$promot2			= addslashes($POST['promot2']);
		$promot2_rs			= addslashes($POST['promot2_rs']);
		$promot3			= addslashes($POST['promot3']);
		$promot3_rs			= addslashes($POST['promot3_rs']);
		$custom_promotions			= addslashes($POST['custom_promotions']);
		

		$date	=	$this->date;
		$qry	=	"insert into user(name,email,password,mobile,phone,address,address2,address3,pin,rest_contacts,city,state,district,country,description,
					delivery_area,register_date,delivery_distance,delivery_fee,cash_payment,card_payment,delivery,discount,servicetax,min_amount,min_time_collection,delivery_t_weekdays,delivery_t_weekends,list_type,type,status,rest_type,verification,menu_url,ranking,restaurant_type,delivery_desc,commission,commission_time,bank_name,branch_name,acc_name,accno,acc_type,ifsccode,voucher_code) values('$name','$emailid','$password','$mobno','$phno','$address','$address2','$location','$pin','$contacts','$city','$state','$district','$country','$desc','','$date','$distance','$fee','$cash','$card','$delivery','$discount','$tax','$min_amount','$min_time_collection','$delivery_t_weekdays','$delivery_t_weekends','$list_type','Hotel','Active','$sub_type','','$url','$rank','$restaurt_type','$delivery_descption','$commisions','$commisiontime','$banknames','$branchs','$accname','$accnos','$accounttype','$ifsccodes','$vouchercode')"; 
		//echo $qry;exit;		
 	    $res	= 	$this->db->setQuery($qry);
 		$id		=	mysql_insert_id();
		
		//Insert into searching table 
		
		$sqldistrict = mysql_query("SELECT district FROM districts WHERE district_id =$district");
		$rows = mysql_fetch_array($sqldistrict);
		$districtss = $rows['district'];
		
		$sqlstate = mysql_query("SELECT states FROM states WHERE state_id =$state");
		$rowstate = mysql_fetch_array($sqlstate);
		$statess =  $rowstate['states'];
		
		$sqlcountry = mysql_query("SELECT country_name FROM country_database WHERE country_id =$country");
		$rowcountry = mysql_fetch_array($sqlcountry);
		$countryss =  $rowcountry['country_name'];
		
		$ssql="insert into rest_searchtable(user_id,name,address,address2,address3,delivery_fee,city,state,district,country,menu_url,delivery_distance,list_type,rest_type,ranking,min_amount,status,delivery) values ('$id','$name','$address','$address2','$location','$fee','$city','$statess','$districtss','$countryss','$url','$distance','$list_type','$sub_type','$rank','$min_amount','Active','$delivery')";
		
		
		$smysql=mysql_query($ssql);
		$ssid=mysql_insert_id();

		//echo $sql12;exit;
		//mysql_query($sql12);
		
		$insertFoodTypes=$this->reg->insertFoodTypes($id,$food_type);
		$insertRestCategory=$this->reg->insertRestCategory($id,$rest_category);
		$insertRestDeliveryAreas=$this->reg->insertRestDeliveryAreas($id,$delivery_areas);
		
		$addToWebConfig=$this->addToWebConfig($id,$url);
		
		$sql12=mysql_query("insert into rest_includes(user_id,rest_category_id) values('$id','$restaurt_type')");
        //$sql13=mysql_query("insert into rest_includes(user_id,rest_category_id) values('$id','$flavour_type')");
		
		$Folder	=	"../images/Restaurantimages/ImageLarg/";
		$Folder1=	"../images/Restaurantimages/ImageThumb/";
			if($_FILES['image']['name']!="")
			{
				$ForWeb=explode(".",$_FILES['image']['name']);
			 	$image		=   uniqid(rand(1,99999),false).".".$ForWeb[1];
			 	$imagePath1	=   $Folder.$image;
 			  	$copy		=   copy($_FILES['image']['tmp_name'],$imagePath1);
			  	$size		=	getimagesize($_FILES['image']['tmp_name']);
			  	$width		=	$size[0];
			  	$height		=	$size[1];
				$this->general->resizeImageWdthHegt($imagePath1,112,104);
				
				$imagePath2	=	$Folder1.$image;
			    $copy1		=	copy($_FILES['image']['tmp_name'],$imagePath2);
			    $size		=	getimagesize($_FILES['image']['tmp_name']);
			  
				$this->general->resizeImageWdthHegt($imagePath2,144,132);
				$qry1		=	"update user SET image='".$image."' where user_id='$id'";				
			    $res	    =   $this->db->setQuery($qry1);	
				$qry2		=	"update rest_searchtable SET image='".$image."' where user_id='$id'";		
				$res2	    =   $this->db->setQuery($qry2);		
			}
			
			
			$sql="select max(user_id) as ID from user";
			$row	= $this ->db ->readValue($sql);
			$user_id=$row['ID'];
			
			$addWorktime=$this->addWorktime($POST,$user_id);
			$addPromotions=$this->addPromotions($POST,$user_id);
			

		return $res;
	 }
	 
	 function selectProfileById($id)
	{
			$qry	=	"Select * from `user` where `user_id`=$id";	
			//echo $qry;exit;
			$res	=	$this->db->readValue($qry);
			return $res;
  	}	
/*	 function updateProfile($POST,$id)
	{//exit;
		$name	=	trim(addslashes($POST['name']));
		$list_type= trim(addslashes($POST['list_type']));
		$sub_type=  trim(addslashes($POST['sub_type']));
 		$emailid=	trim(addslashes($POST['emailid']));
 		$mobno  =	trim(addslashes($POST['mobno']));	
 		$phno   =	trim(addslashes($POST['phno']));	
 		$address=	trim(addslashes($POST['address']));
		$address2= 	trim(addslashes($POST['address2']));
		$location= 	trim(addslashes($POST['location']));
 		$pin    =	trim(addslashes($POST['pin']));	
 		$city   =	trim(addslashes($POST['city']));
 		$state  =	trim(addslashes($POST['state']));
		$district=  trim(addslashes($POST['district']));
 		$country=	trim(addslashes($POST['country']));
		$desc	=	trim(addslashes($POST['desc']));		
		$food_type		=	$POST['food_type'];
		$rest_category	=	$POST['rest_category'];
		$delivery_areas=$POST['delivery_areas'];
		$contacts	=	trim(addslashes($POST['contacts']));
		
		$distance		= addslashes($POST['distance']);
		if($distance=='')
		$distance=0;
		
		$fee			= addslashes($POST['fee']);
		if($fee=='')
		$fee=0;
			
		$cash='No';
		if(isset($POST['cash']))
		$cash='Yes';
		
		$card='cNo';
		if(isset($POST['card']))
		$card='cYes';

		
		$delivery='No';
		if(isset($POST['delivery']))
		$delivery		='Yes';
			
		$discount			= addslashes($POST['discount']);
		if($discount=='')
		$discount=0;
		
		$tax			= addslashes($POST['tax']);
		if($tax=='')
		$tax=0;

		
		$min_amount=addslashes($POST['min_amount']);
		$rank=addslashes($POST['rank']);
		$min_time_collection=addslashes($POST['min_time_collection']);
		$delivery_t_weekdays=addslashes($POST['delivery_t_weekdays']);
		$delivery_t_weekends=addslashes($POST['delivery_t_weekends']);
		
		if($min_amount<200)
		{
			$min_amount=200;
		}
		
		$promot1			= addslashes($POST['promot1']);
		$promot1_rs			= addslashes($POST['promot1_rs']);
		$promot2			= addslashes($POST['promot2']);
		$promot2_rs			= addslashes($POST['promot2_rs']);
		$promot3			= addslashes($POST['promot3']);
		$promot3_rs			= addslashes($POST['promot3_rs']);
		$custom_promotions			= addslashes($POST['custom_promotions']);
		
		
		$date		=	$this->date;
		$insertFoodTypes=$this->insertFoodTypes($id,$food_type);
		$insertRestCategory=$this->insertRestCategory($id,$rest_category);
		$insertRestDeliveryAreas=$this->insertRestDeliveryAreas($id,$delivery_areas);
		
			if($_FILES['image']['name']!="")
			{
				$Folder		=	"../images/Restaurantimages/ImageLarg/";
				$Folder1	=	"../images/Restaurantimages/ImageThumb/";
				$pic    	=   $this->selectProfileById($id);
 				$file		=	$pic['image'];
  				if(is_file($Folder.$file))
				{
 				unlink($Folder.$file);
				}
				if(is_file($Folder1.$file))
				{
 				unlink($Folder1.$file);
				}	
				 $ForWeb=explode(".",$_FILES['image']['name']);
				 $image		=   uniqid(rand(1,99999),false).".".$ForWeb[1];
				 $imagePath =   $Folder.$image;
 			   	 $copy		=   copy($_FILES['image']['tmp_name'],$imagePath);
			  	 $size		=	getimagesize($_FILES['image']['tmp_name']);
			  	 $width		=	$size[0];
			  	 $height	=	$size[1];
				 $this->general->resizeImageWdthHegt($imagePath,$width,$height);
				 $imagePath1=	$Folder1.$image;
			     $copy1		=	copy($_FILES['image']['tmp_name'],$imagePath1);
			     $size		=	getimagesize($_FILES['image']['tmp_name']);
				 $this->general->resizeImageWdthHegt($imagePath1,144,132);
				$qry1		=	"update user SET image='".$image."' where user_id='$id'";
			    $res	=$this->db->setQuery($qry1);
			}
			
			
		$qry		=	"update user SET name='$name',email='$emailid',mobile='$mobno',phone='$phno',address='$address',address2='$address2',address3='$location',pin='$pin',rest_contacts='$contacts',city='$city',state='$state',district='$district',country='$country',description='$desc',last_update='$date',delivery_distance='$distance',delivery_fee='$fee',cash_payment='$cash',card_payment='$card',delivery='$delivery',discount='$discount',servicetax='$tax',min_amount='$min_amount',min_time_collection='$min_time_collection',delivery_t_weekdays='$delivery_t_weekdays',delivery_t_weekends='$delivery_t_weekends',list_type='$list_type',rest_type='$sub_type',ranking='$rank' where user_id='$id'";
		//echo $qry;exit;
		$res		= 	$this->db ->setQuery($qry);
		
		$sql6="select * from rest_worktime where user_id='$id'";
		$sql6	= $this ->db ->readValues($sql6);
		
		if($sql6)
		{
			$updateWorktime=$this->updateWorktime($POST,$id);
		}
		else
		{
			$addWorktime=$this->addWorktime($POST,$id);
		}
		
		$sql5="select * from rest_promotions where user_id='$id'";
		$row5	= $this ->db ->readValue($sql5);
		
		if($row5)
		{
			$updatePromotions=$this->updatePromotions($POST,$id);
		}
		else
		{
			$addPromotions=$this->addPromotions($POST,$id);
		}
		
		
				
		//echo "hinew";
		return "Profile updated successfully";
		
	}*/
	
	
	 function updateProfile($POST,$id)
	{//exit;
		$name	=	trim(addslashes($POST['name']));
		$list_type= trim(addslashes($POST['list_type']));
		$sub_type=  trim(addslashes($POST['sub_type']));
 		$emailid=	trim(addslashes($POST['emailid']));
 		$mobno  =	trim(addslashes($POST['mobno']));	
 		$phno   =	trim(addslashes($POST['phno']));	
 		$address=	trim(addslashes($POST['address']));
		$address2= 	trim(addslashes($POST['address2']));
		$location= 	trim(addslashes($POST['location']));
 		$pin    =	trim(addslashes($POST['pin']));	
 		$city   =	trim(addslashes($POST['city']));
 		$state  =	trim(addslashes($POST['state']));
		$district=  trim(addslashes($POST['district']));
 		$country=	trim(addslashes($POST['country']));
		$desc	=	trim(addslashes($POST['desc']));		
		$food_type		=	$POST['food_type'];
		$rest_category	=	$POST['rest_category'];
		$delivery_areas=$POST['delivery_areas'];
		$contacts	=	trim(addslashes($POST['contacts']));
		$delivery_descption=$_POST['deliverydesc'];
		$url=trim(addslashes($POST['url']));
		$restaurt_type=trim(addslashes($POST['restaurant_type'])); 
		
		$commisions=$_POST['commission_detail'];
		$commisiontime=$_POST['commission_times'];
		$banknames=$_POST['bankname'];
		$branchs=$_POST['branch'];
		$accname=$_POST['accountname'];
		$accnos=$_POST['accountno'];
		$accounttype=$_POST['account_type'];
		$ifsccodes=$_POST['ifsccode'];
		$vouchercode=$_POST['vouchercode'];
		
		$distance		= addslashes($POST['distance']);
		if($distance=='')
		$distance=0;
		
		$fee			= addslashes($POST['fee']);
		if($fee=='')
		$fee=0;
			
		$cash='No';
		if(isset($POST['cash']))
		$cash='Yes';
		
		$card='cNo';
		if(isset($POST['card']))
		$card='cYes';

		
		$delivery='No';
		if(isset($POST['delivery']))
		$delivery		='Yes';
			
		$discount			= addslashes($POST['discount']);
		if($discount=='')
		$discount=0;
		
		$tax			= addslashes($POST['tax']);
		if($tax=='')
		$tax=0;

		
		$min_amount=addslashes($POST['min_amount']);
		$rank=addslashes($POST['rank']);
		$min_time_collection=addslashes($POST['min_time_collection']);
		$delivery_t_weekdays=addslashes($POST['delivery_t_weekdays']);
		$delivery_t_weekends=addslashes($POST['delivery_t_weekends']);
		
		if($min_amount<200)
		{
			$min_amount=200;
		}
		
		$promot1			= addslashes($POST['promot1']);
		$promot1_rs			= addslashes($POST['promot1_rs']);
		$promot2			= addslashes($POST['promot2']);
		$promot2_rs			= addslashes($POST['promot2_rs']);
		$promot3			= addslashes($POST['promot3']);
		$promot3_rs			= addslashes($POST['promot3_rs']);
		$custom_promotions			= addslashes($POST['custom_promotions']);
		
		
		
		
		$date		=	$this->date;
		$insertFoodTypes=$this->insertFoodTypes($id,$food_type);
		$insertRestCategory=$this->insertRestCategory($id,$rest_category);
		$insertRestDeliveryAreas=$this->insertRestDeliveryAreas($id,$delivery_areas);
		
			if($_FILES['image']['name']!="")
			{
				$Folder		=	"../images/Restaurantimages/ImageLarg/";
				$Folder1	=	"../images/Restaurantimages/ImageThumb/";
				$pic    	=   $this->selectProfileById($id);
 				$file		=	$pic['image'];
  				if(is_file($Folder.$file))
				{
 				unlink($Folder.$file);
				}
				if(is_file($Folder1.$file))
				{
 				unlink($Folder1.$file);
				}	
				 $ForWeb=explode(".",$_FILES['image']['name']);
				 $image		=   uniqid(rand(1,99999),false).".".$ForWeb[1];
				 $imagePath =   $Folder.$image;
 			   	 $copy		=   copy($_FILES['image']['tmp_name'],$imagePath);
			  	 $size		=	getimagesize($_FILES['image']['tmp_name']);
			  	 $width		=	$size[0];
			  	 $height	=	$size[1];
				 $this->general->resizeImageWdthHegt($imagePath,$width,$height);
				 $imagePath1=	$Folder1.$image;
			     $copy1		=	copy($_FILES['image']['tmp_name'],$imagePath1);
			     $size		=	getimagesize($_FILES['image']['tmp_name']);
				 $this->general->resizeImageWdthHegt($imagePath1,144,132);
				$qry1		=	"update user SET image='".$image."' where user_id='$id'";
			    $res	=$this->db->setQuery($qry1);
				$qry2		=	"update rest_searchtable  SET image='".$image."' where user_id='$id'";
			    $res22 = $this->db->setQuery($qry2);
			}
			
			
		$qry		=	"update user SET name='$name',email='$emailid',mobile='$mobno',phone='$phno',address='$address',address2='$address2',address3='$location',pin='$pin',rest_contacts='$contacts',city='$city',state='$state',district='$district',country='$country',description='$desc',last_update='$date',delivery_distance='$distance',delivery_fee='$fee',cash_payment='$cash',card_payment='$card',delivery='$delivery',discount='$discount',servicetax='$tax',min_amount='$min_amount',min_time_collection='$min_time_collection',delivery_t_weekdays='$delivery_t_weekdays',delivery_t_weekends='$delivery_t_weekends',list_type='$list_type',rest_type='$sub_type',restaurant_type='$restaurt_type',ranking='$rank',delivery_desc='$delivery_descption',commission='$commisions',commission_time='$commisiontime',bank_name='$banknames',branch_name='$branchs',acc_name='$accname',accno='$accnos',acc_type='$accounttype',ifsccode='$ifsccodes',voucher_code='$vouchercode' where user_id='$id'";
		//echo $qry;exit;
		$res		= 	$this->db ->setQuery($qry);
		
		$sql6="select * from rest_worktime where user_id='$id'";
		$sql6	= $this ->db ->readValues($sql6);
		
		if($sql6)
		{
			$updateWorktime=$this->updateWorktime($POST,$id);
		}
		else
		{
			$addWorktime=$this->addWorktime($POST,$id);
		}
		
		$sql5="select * from rest_promotions where user_id='$id'";
		$row5	= $this ->db ->readValue($sql5);
		
		if($row5)
		{
			$updatePromotions=$this->updatePromotions($POST,$id);
		}
		else
		{
			$addPromotions=$this->addPromotions($POST,$id);
		}
		
		
	    $sqldistrict = mysql_query("SELECT district FROM districts WHERE district_id =$district");
		$rows = mysql_fetch_array($sqldistrict);
		$districtss = $rows['district'];
		
		$sqlstate = mysql_query("SELECT states FROM states WHERE state_id =$state");
		$rowstate = mysql_fetch_array($sqlstate);
		$statess =  $rowstate['states'];
		
		$sqlcountry = mysql_query("SELECT country_name FROM country_database WHERE country_id =$country");
		$rowcountry = mysql_fetch_array($sqlcountry);
		$countryss =  $rowcountry['country_name'];
	
		$ssql="update rest_searchtable set name='$name',city='$city',state='$statess',district='$districtss',country='$countryss',delivery_distance='$distance',list_type='$list_type',rest_type='$sub_type',address='$address',delivery_fee='$fee',address2='$address2',address3='$location',ranking='$rank',min_amount='$min_amount',delivery='$delivery' where user_id=".$id;
		
		$res3		= 	$this->db ->setQuery($ssql);
		
		return "Profile updated successfully";
		
	}
	
	
	function updatePromotions($POST,$id)
	{
		$promot1			= addslashes($POST['promot1']);
		$promot1_rs			= addslashes($POST['promot1_rs']);
		if($promot1_rs=="")
		$promot1_rs=0;
		
		$promot2			= addslashes($POST['promot2']);
		if($promot2=="")
		$promot2=0;
		
		$promot2_rs			= addslashes($POST['promot2_rs']);
		if($promot2_rs=="")
		$promot2_rs=0;
		
		$promot3			= addslashes($POST['promot3']);
		if($promot3=="")
		$promot3=0;
		
		$promot3_rs			= addslashes($POST['promot3_rs']);
		if($promot3_rs=="")
		$promot3_rs=0;
		
		$custom_promotions	= addslashes($POST['custom_promotions']);
		
		$sql="update rest_promotions set promot1='$promot1',promot1_rs='$promot1_rs',promot2='$promot2',promot2_rs='$promot2_rs',promot3='$promot3',promot3_rs='$promot3_rs',custom_promotions='$custom_promotions' where user_id='$id' ";
		
		$res	= 	$this->db ->setQuery($sql);
		
		return "";
		
	}
	
	function insertFoodTypes($id,$food_type)
	{
	 	$sql="delete from rest_foodtypes where user_id='$id'";
		
		$res	= 	$this->db ->setQuery($sql);		
		foreach($food_type as $food_id)
		{
			$sql1="insert into rest_foodtypes(user_id,food_id) values('$id','$food_id')";
			$res1	= 	$this->db ->setQuery($sql1);
			
			$rr=mysql_query("SELECT * 
			FROM `foodtypes` where food_id=
			".$food_id);
			$dqrysmf=mysql_fetch_object($rr);
			$restcat2=$dqrysmf->food_type;
			$foodcat.=$restcat2.',';
			//------------------------------------------------//
		}
		mysql_query("update rest_searchtable set  food_type='".substr($foodcat,0,-1)."' where user_id=".$id);

		return "";
	
	}
	function insertRestCategory($id,$rest_category)
	{
		$sql="delete from rest_includes where user_id='$id'";
		$res	= 	$this->db ->setQuery($sql);
		foreach($rest_category as $category)
		{
			$sql1="insert into rest_includes(user_id,rest_category_id) values('$id','$category')";
			$res1	= 	$this->db ->setQuery($sql1);
			
			$r=mysql_query("SELECT * 
			FROM `rest_categories` where rest_category_id=
			".$category);
						
			$dqrysm=mysql_fetch_object($r);
			$restcat2=$dqrysm->rest_category;
			$restcat.=$restcat2.',';
			
		}
		mysql_query("update rest_searchtable set  rest_category='".substr($restcat,0,-1)."' where user_id=".$id);
		
		return "";
	}
		
	function insertRestDeliveryAreas($id,$delivery_areas)
	{
		$sql="delete from delivery_areas where user_id='$id'";
		$res	= 	$this->db ->setQuery($sql);
		foreach($delivery_areas as $delivery_area)
		{
			$sql1="insert into delivery_areas(user_id,delivery_area_id) values('$id','$delivery_area')";
			$res1	= 	$this->db ->setQuery($sql1);
			
			$rrk=mysql_query("SELECT * 
				FROM `rest_delivery_areas` where delivery_area_id=
				".$delivery_area);
			$dqrysmfk=mysql_fetch_object($rrk);
			$delarea2=$dqrysmfk->delivery_area;
						
			$delarea.=$delarea2.',';
			
		}
		mysql_query("update rest_searchtable set  delivery_area='".substr($delarea,0,-1)."' where user_id=".$id);
		
		return "";
	}
	
	
	/*function insertFoodTypes($id,$food_type)
	{
	 	$sql="delete from rest_foodtypes where user_id='$id'";
		
		$res	= 	$this->db ->setQuery($sql);		
		foreach($food_type as $food_id)
		{
			$sql1="insert into rest_foodtypes(user_id,food_id) values('$id','$food_id')";
			$res1	= 	$this->db ->setQuery($sql1);
		}
		return "";
	
	}
	function insertRestCategory($id,$rest_category)
	{
		$sql="delete from rest_includes where user_id='$id'";
		$res	= 	$this->db ->setQuery($sql);
		foreach($rest_category as $category)
		{
			$sql1="insert into rest_includes(user_id,rest_category_id) values('$id','$category')";
			$res1	= 	$this->db ->setQuery($sql1);
		}
		return "";
	}
	function insertRestDeliveryAreas($id,$delivery_areas)
	{
		$sql="delete from delivery_areas where user_id='$id'";
		$res	= 	$this->db ->setQuery($sql);
		foreach($delivery_areas as $delivery_area)
		{
			$sql1="insert into delivery_areas(user_id,delivery_area_id) values('$id','$delivery_area')";
			$res1	= 	$this->db ->setQuery($sql1);
		}
		return "";
	}*/
	
	 function addPromotions($POST,$user_id)
	 {
	 	$promot1			= addslashes($POST['promot1']);
		$promot1_rs			= addslashes($POST['promot1_rs']);
		if($promot1_rs=="")
		$promot1_rs=0;
		
		$promot2			= addslashes($POST['promot2']);
		if($promot2=="")
		$promot2=0;
		
		$promot2_rs			= addslashes($POST['promot2_rs']);
		if($promot2_rs=="")
		$promot2_rs=0;
		
		$promot3			= addslashes($POST['promot3']);
		if($promot3=="")
		$promot3=0;
		
		$promot3_rs			= addslashes($POST['promot3_rs']);
		if($promot3_rs=="")
		$promot3_rs=0;
		$custom_promotions			= addslashes($POST['custom_promotions']);
		
		$sql="insert into rest_promotions(user_id,promot1,promot1_rs,promot2,promot2_rs,promot3,promot3_rs,custom_promotions) values('$user_id','$promot1','$promot1_rs','$promot2','$promot2_rs','$promot3','$promot3_rs','$custom_promotions')";
		
		$res	    =   $this->db->setQuery($sql);
		return "";
	 }
	 function addToWebConfig($id,$url)
	 {
	 		$xml = new DomDocument('1.0');
			$xml->load('../Web.config');
							/* first to create a list of categories */
			$categories = array();
			$XMLCategories = $xml->getElementsByTagName('rules')->item(0);
			
			$addrule=$this->addrule($xml,$url,'');
			
			$xml->save('../Web.config'); 
			// save the whole file
			$categories = $xml->saveXML($XMLCategories); 
			
			
			$xml1 = new DomDocument('1.0');
			$xml1->load('../Web.config');
			
				/* first to create a list of categories */
			$categories = array();
			$XMLCategories1 = $xml1->getElementsByTagName('rule');
				
			$i=0;
			foreach($XMLCategories1 as $key=>$values)
			{
				$i++;					
			}
			
			
			$addmatch=$this->addmatch($xml1,$url,'node',$i);
			$addaction=$this->addaction($xml1,array('Rewrite',"m2enudetailsJavascript.php?user_id=$id",'true'),'node',$i);
				
			$xml1->save('../Web.config'); 
			// save the whole file
			//$categories = $xml1->saveXML($this->$XMLCategories1->documentElement, LIBXML_NOEMPTYTAG); 
			return "";
	 
	 
	 }
	 function addrule(DOMDocument $xml, $catID, $catName)
	 {
			$catName = $xml->createTextNode($catName); // create a node to hold the text
			$category = $xml->createElement('rule'); // create a category element
			$category->appendChild($catName); // add the text to the category element
			$category->setAttribute('name', $catID); // set the category id
				
			$XMLCategories = $xml->getElementsByTagName('rules')->item(0);
			$XMLCategories->appendChild($category); // add the new category
			return "";
					
	 } 
	 function addmatch(DOMDocument $xml, $catID, $catName,$i)
	 {
			$catName = $xml->createTextNode($catName); // create a node to hold the text
			$category = $xml->createElement('match'); // create a category element
			$category->appendChild($catName); // add the text to the category element
			$category->setAttribute('url', $catID); // set the category id
				
			$XMLCategories1 = $xml->getElementsByTagName('rule')->item($i-1);
			$XMLCategories1->appendChild($category); // add the new category
			return "";
					
	 } 
	 function addaction(DOMDocument $xml, $catID=array(), $catName,$i)
	 {
			$catName = $xml->createTextNode($catName); // create a node to hold the text
			$category = $xml->createElement('action'); // create a category element
			$category->appendChild($catName); // add the text to the category element
			$category->setAttribute('type', $catID[0]);
			$category->setAttribute('url', $catID[1]);
			$category->setAttribute('appendQueryString', $catID[2]); // set the category id
				
			$XMLCategories1 = $xml->getElementsByTagName('rule')->item($i-1);
			$XMLCategories1->appendChild($category); // add the new category
			return "";
	 }
	 function getAllUrlRestaurant()
	 {
	 	$sql="select * from user where type='Hotel' and status='Active'";
		$rows	= $this ->db ->readValues($sql);
		return $rows;
	 }
	 function UpdateRstaurantUrl($POST)
	 {
	 	$user_id=addslashes($POST['restaurant']);
		$url	=addslashes($POST['url']);
		
		$sql="update user set menu_url='$url' where user_id='$user_id'";
		$res	    =   $this->db->setQuery($sql);
		
		$myFile = "../.htaccess";
		$fh = fopen($myFile, 'r');
		$theData = fread($fh,filesize($myFile));
		fclose($fh);
		
		$fhw = fopen($myFile, 'w');
		$theData.=" RewriteRule ^".$url."$ menudetails.php?user_id=".$user_id."\n";
		 fwrite($fhw, $theData);

		
		fclose($fhw);
		
		
		return "Restaurant url updated successfully";			
	 }
	 function getAllreviewcnt($user_id='')
	 {
	 	$sql="select * from customer_review left join user on customer_review.user_id=user.user_id where 1=1 ";
		if($user_id!="")
		{
			$sql.=" and customer_review.rest_id='$user_id'";
		}
		//echo $sql;exit;
		$rows	= $this ->db ->readValues($sql);
		$cnt=count($rows);
		return $cnt;
	 }
	 function getAllreview($user_id='',$Offset='',$RowsPerPage='')
	 {
	 	$sql="select * from customer_review left join user on customer_review.user_id=user.user_id where 1=1 ";
		
		if($user_id=="")
		{
			$sql.=" order by customer_review.review_id desc ";
		}
		if($user_id!="")
		{
			$sql.=" and customer_review.rest_id='$user_id' order by customer_review.review_id desc ";
		}
		if(trim($Offset)!="" && trim($RowsPerPage)!="")
		{	
			$sql.=	" LIMIT $Offset,$RowsPerPage";	
		}		

		$rows	= $this ->db ->readValues($sql);
		
		return $rows;
	 }
	 function urlExists($url)
	 {
	 	$sql="select * from user where menu_url like '%$url%' and status!='Deleted'";
		$row	= $this ->db ->readValue($sql);
		return $row;
	 }
	 function urlExistsupdate($url,$user_id)
	 {
	 	$sql="select * from user where menu_url like '%$url%' and user_id!='$user_id'";
		$row	= $this ->db ->readValue($sql);
		return $row;
	 }
	/* function CreateAdminUser($POST)
	 {
	 	$email				=	addslashes($POST['email']);
		$newpassword		=	addslashes($POST['newpassword']);
		$cpassword			=	addslashes($POST['cpassword']);
		
		if(isset($POST['mng_rest']))
		{
			$mng_rest			=	addslashes($POST['mng_rest']);
			$restaurant='Active';
		}
		else
		{
			$restaurant='Inactive';
		}
		if(isset($POST['mng_user']))
		{
			$mng_user			=	addslashes($POST['mng_user']);
			$user='Active';
		}
		else
		{
			$user='Inactive';
		}
		if(isset($POST['mng_order']))
		{
			$mng_order			=	addslashes($POST['mng_order']);
			$order='Active';
		}
		else
		{
			$order	='Inactive';
		}
		
		if(isset($POST['eml_tmplte']))
		{
			$eml_tmplte			=	addslashes($POST['eml_tmplte']);
			$templates='Active';
		}
		else
		{
			$templates	='Inactive';
		}
		
		if(isset($POST['mng_quest']))
		{
			$mng_quest			=	addslashes($POST['mng_quest']);
			$questions='Active';
		}
		else
		{
			$questions	='Inactive';
		}
		
		if(isset($POST['mng_pages']))
		{
			$mng_pages			=	addslashes($POST['mng_pages']);
			$pages='Active';
		}
		else
		{
			$pages	='Inactive';
		}
		$date=$this->date;
		
		
		$sql	=	"insert into user(name,email,password,mobile,phone,address,address2,address3,pin,city,state,district,country,description,
					delivery_area,register_date,type,rest_type,verification,menu_url) values('','$email','$newpassword','','','','','',						                          '','','0','0','0','','','$date','Admin','Premium','','')"; 
		$res	    =   $this->db->setQuery($sql);
		
		$sql1="select max(user_id) as ID from user";
		$row	= $this ->db ->readValue($sql1);
		$ID=$row['ID'];
		
		$sql2="insert into admin_priority(user_id,manage_restaurants,manage_users,manage_orders,email_templates,manage_questions,manage_pages) values('$ID','$restaurant','$user','$order','$templates','$questions','$pages')";
		$res2	    =   $this->db->setQuery($sql2);
		
		return "Admin added successfully";
		
	}*/
	
	 function CreateAdminUser()
	 {
	 	$email				=	addslashes($POST['email']);
		$cpassword			=	addslashes($POST['password']);
		$names = $_POST['name'];
		if(isset($POST['mng_rest']))
		{
			$mng_rest			=	addslashes($POST['mng_rest']);
			$restaurant='Active';
		}
		else
		{
			$restaurant='Inactive';
		}
		if(isset($POST['mng_user']))
		{
			$mng_user			=	addslashes($POST['mng_user']);
			$user='Active';
		}
		else
		{
			$user='Inactive';
		}
		if(isset($POST['mng_order']))
		{
			$mng_order			=	addslashes($POST['mng_order']);
			$order='Active';
		}
		else
		{
			$order	='Inactive';
		}
		
		if(isset($POST['eml_tmplte']))
		{
			$eml_tmplte			=	addslashes($POST['eml_tmplte']);
			$templates='Active';
		}
		else
		{
			$templates	='Inactive';
		}
		
		if(isset($POST['mng_quest']))
		{
			$mng_quest			=	addslashes($POST['mng_quest']);
			$questions='Active';
		}
		else
		{
			$questions	='Inactive';
		}
		
		if(isset($POST['mng_pages']))
		{
			$mng_pages			=	addslashes($POST['mng_pages']);
			$pages='Active';
		}
		else
		{
			$pages	='Inactive';
		}
		
		if(isset($POST['mng_type']))
		{
			$mng_type			=	addslashes($POST['mng_type']);
		}
		else
		{
			$mng_type	='';
		}
		if(isset($POST['mng_status']))
		{
			$mng_statuss			=	addslashes($POST['mng_status']);
			$statuss='1';
		}
		else
		{
			$statuss	='0';
		}
		if(isset($POST['ip_check']))
		{
			$ip_checks			=	addslashes($POST['ip_check']);
			$ip_checks='1';
		}
		else
		{
			$ip_checks	='0';
		}
		$date=$this->date;
		
		
		$sql	=	"insert into tbl_admin(name,email,password,type,register_date,status,manage_restaurants,manage_users,manage_orders,email_templates,manage_questions,manage_pages,ip_check) values('$names','$email','$newpassword','$mng_type','$date','$statuss','$restaurant','$user','$order','$templates','$questions','$pages','$ip_checks')"; 
		$res	    =   $this->db->setQuery($sql);
		
		$sql1="select max(id) as ID from tbl_admin";
		$row	= $this ->db ->readValue($sql1);
		$ID=$row['ID'];
		
		$sql2="insert into admin_priority(user_id,manage_restaurants,manage_users,manage_orders,email_templates,manage_questions,manage_pages) values('$ID','$restaurant','$user','$order','$templates','$questions','$pages')";
		$res2	    =   $this->db->setQuery($sql2);
		
		return "Admin added successfully";
		
	}
	
	
	function adminexists()
	{
		$sql="select * from user where email='$email' and status!='Deleted' and type!='User'";
		$row	= $this ->db ->readValue($sql);
		return $row;
	}
	function getAlladmincnt()
	{
		$sql="select * from tbl_admin where type='SubAdmin'";
		//$sql="select * from tbl_admin where type='SubAdmin'";
		$rows	= $this ->db ->readValues($sql);
		$cnt=count($rows);
		return $cnt;
	}
	
	function getAlladmin($Offset='',$RowsPerPage='')
	{
		$sql="select * from tbl_admin  order by id desc ";
		
		if(trim($Offset)!="" && trim($RowsPerPage)!="")
		{	
			$sql.=	" LIMIT $Offset,$RowsPerPage";	
		}
		$rows	= $this ->db ->readValues($sql);
		return $rows;
	}
	
	/*function getAlladmin($Offset='',$RowsPerPage='')
	{
		$sql="select * from user where type='Admin' and status!='Deleted' order by user_id desc ";
		
		if(trim($Offset)!="" && trim($RowsPerPage)!="")
		{	
			$sql.=	" LIMIT $Offset,$RowsPerPage";	
		}
		$rows	= $this ->db ->readValues($sql);
		return $rows;
	}*/	
	
	function UpdateAdminUser($POST,$user_id)
	{
		$email				=	addslashes($POST['email']);
		
		
		if(isset($POST['mng_type']))
		{
			$mng_type			=	addslashes($POST['mng_type']);
		}
		else
		{
			$mng_type	='';
		}
		if(isset($POST['mng_rest']))
		{
			$mng_rest			=	addslashes($POST['mng_rest']);
			$restaurant='Active';
		}
		else
		{
			$restaurant='Inactive';
		}
		if(isset($POST['mng_user']))
		{
			$mng_user			=	addslashes($POST['mng_user']);
			$user='Active';
		}
		else
		{
			$user='Inactive';
		}
		if(isset($POST['mng_order']))
		{
			$mng_order			=	addslashes($POST['mng_order']);
			$order='Active';
		}
		else
		{
			$order	='Inactive';
		}
		
		if(isset($POST['eml_tmplte']))
		{
			$eml_tmplte			=	addslashes($POST['eml_tmplte']);
			$templates='Active';
		}
		else
		{
			$templates	='Inactive';
		}
		
		if(isset($POST['mng_quest']))
		{
			$mng_quest			=	addslashes($POST['mng_quest']);
			$questions='Active';
		}
		else
		{
			$questions	='Inactive';
		}
		
		if(isset($POST['mng_pages']))
		{
			$mng_pages			=	addslashes($POST['mng_pages']);
			$pages='Active';
		}
		else
		{
			$pages	='Inactive';
		}
		if(isset($POST['mng_status']))
		{
			$mng_statuss			=	addslashes($POST['mng_status']);
			$statuss='1';
		}
		else
		{
			$statuss	='0';
		}
		if(isset($POST['ip_check']))
		{
			$ip_checks			=	addslashes($POST['ip_check']);
			$ip_checks='1';
		}
		else
		{
			$ip_checks	='0';
		}
		$sql="update tbl_admin set email='$email',type='$mng_type',manage_restaurants='$restaurant',manage_users='$user',manage_orders='$order',email_templates='$templates',manage_questions='$questions',manage_pages='$pages',status='$statuss',ip_check='$ip_checks' where id='$user_id'";
		$res	    =   $this->db->setQuery($sql);
		
		$sql1="update admin_priority set manage_restaurants='$restaurant',manage_users='$user',manage_orders='$order',email_templates='$templates',manage_questions='$questions',manage_pages='$pages' where user_id='$user_id'";
		$res1	    =   $this->db->setQuery($sql1);
		return "Admin user details updated succesfully";
	}
	
	/*function UpdateAdminUser($POST,$user_id)
	{
		$email				=	addslashes($POST['email']);
		
		
		if(isset($POST['mng_rest']))
		{
			$mng_rest			=	addslashes($POST['mng_rest']);
			$restaurant='Active';
		}
		else
		{
			$restaurant='Inactive';
		}
		if(isset($POST['mng_user']))
		{
			$mng_user			=	addslashes($POST['mng_user']);
			$user='Active';
		}
		else
		{
			$user='Inactive';
		}
		if(isset($POST['mng_order']))
		{
			$mng_order			=	addslashes($POST['mng_order']);
			$order='Active';
		}
		else
		{
			$order	='Inactive';
		}
		
		if(isset($POST['eml_tmplte']))
		{
			$eml_tmplte			=	addslashes($POST['eml_tmplte']);
			$templates='Active';
		}
		else
		{
			$templates	='Inactive';
		}
		
		if(isset($POST['mng_quest']))
		{
			$mng_quest			=	addslashes($POST['mng_quest']);
			$questions='Active';
		}
		else
		{
			$questions	='Inactive';
		}
		
		if(isset($POST['mng_pages']))
		{
			$mng_pages			=	addslashes($POST['mng_pages']);
			$pages='Active';
		}
		else
		{
			$pages	='Inactive';
		}
		
		$sql="update user set email='$email' where user_id='$user_id'";
		$res	    =   $this->db->setQuery($sql);
		
		$sql1="update admin_priority set manage_restaurants='$restaurant',manage_users='$user',manage_orders='$order',email_templates='$templates',manage_questions='$questions',manage_pages='$pages' where user_id='$user_id'";
		$res1	    =   $this->db->setQuery($sql1);
		return "Admin user details updated succesfully";
	}*/
	function updateadminexists($email,$user_id)
	{
		$sql="select * from user where email='$email' and status!='Deleted' and type!='User' and user_id!='$user_id'";
		$row	= $this ->db ->readValue($sql);
		return $row;
	}
	function emailExists($email,$cat_id)
	{
		$sql="select * from mail_ids where email='$email' and list_id='$cat_id'";
		$row	= $this ->db ->readValue($sql);
		return $row;
	}
	function emailExistsupdate($email,$cat_id,$mail_ids_id)
	{
		$sql="select * from mail_ids where email='$email' and list_id='$cat_id' and mail_ids_id!='$mail_ids_id'";
		$row	= $this ->db ->readValue($sql);
		return $row;
	}
	
	function mailinglistExists($maillist)
	{
		$sql="select * from mailing_list where list_name='$maillist'";
		$row	= $this ->db ->readValue($sql);
		return $row;
	}
	function addMailIdsAll($POST)
	{
		$cat_id			=	addslashes($POST['cat_id']);
		$category		=	addslashes($POST['category']);
		$name			=	$POST['name'];
		$email			=	$POST['email'];
		
		$count=count($email);
		
		if(($category!="")&&($cat_id==""))
		{
			$sql1="insert into mailing_list(list_name) values('$category')";
			$res1	= $this->db ->setQuery($sql1);
			
			$sql2="select max(list_id) as id from mailing_list";
			$row	= $this ->db ->readValue($sql2);
			$cat_id=$row['id'];
		}
		
		for($i=0;$i<$count;$i++)
		{
		
			$name1=addslashes($name[$i]);
			$email1=addslashes($email[$i]);
		
			$sql5="insert into mail_ids(list_id,email,name) values('$cat_id','$email1','$name1')";
			
			//echo $sql;exit;
			$res5	= $this->db ->setQuery($sql5);
			$email1="";
			$name1="";
		}
		return "Emails added successfully";
	}
	function updateMailIdsAll($POST)
	{
		$cat_id			=	addslashes($POST['cat_id']);
		
		$name			=	$POST['name'];
		$email			=	$POST['email'];
		$mail_ids_id			=	$POST['mail_ids_id'];
		
		$count=count($mail_ids_id);
		
		
		
		for($i=0;$i<$count;$i++)
		{
		
			$name1=addslashes($name[$i]);
			$email1=addslashes($email[$i]);
			$mail_ids_id1=addslashes($mail_ids_id[$i]);
		
			
			
			$sql5="update mail_ids set list_id='$cat_id',email='$email1',name='$name1' where mail_ids_id='$mail_ids_id1'";
			
			//echo $sql;exit;
			$res5	= $this->db ->setQuery($sql5);
			$email1="";
			$name1="";
		}
		return "Emails updated successfully";
	}
	
	function getMailids($mail_list)
	{
		$sql="select * from mail_ids where list_id='$mail_list' ";
		$rows	= $this ->db ->readValues($sql);
		return $rows;
	}
	function mailHistory($POST)
	{
		$temp_desc=$POST['temp_desc'];
		$mail_list=$POST['mail_list'];
		
		$date=$this->date;
		
		$sql="insert into mailhistory(mail_content,list_id,date) values('$temp_desc','$mail_list','$date')";
		$res	= $this->db ->setQuery($sql);
		return "";
	}
	function addVoucherCode($POST)
	{
		$voucher_code		=	$POST['voucher_code'];
		$dob				=	$POST['dob'];
		
		$hourfrom			=	$POST['hourfrom'];
		$minutefrom			=	$POST['minutefrom'];
		
		$hourto				=	$POST['hourto'];
		$minuteto			=	$POST['minuteto'];
		
		$discount			=	$POST['discount'];
		$max_amount			=	$POST['max_amount'];
		
		list($day,$month,$year)=explode('/',$dob);
		$datefrom=$year."-".$month."-".$day." ".$hourfrom.":".$minutefrom;
		
		$dateto=$year."-".$month."-".$day." ".$hourto.":".$minuteto;
		
		$sql="insert into voucher_code(voucher_code,discount,max_amount,datefrom,dateto,status) values('$voucher_code','$discount','$max_amount','$datefrom','$dateto','Active') ";
		$res	= $this->db ->setQuery($sql);
		return "Voucher code added successfully";
	}
	function vouchercodeexists($voucher_code)
	{
		$sql="select * from voucher_code where voucher_code='$voucher_code'";
		$rows	= $this ->db ->readValue($sql);
		return $rows;
	}
	function addDeliveryArea($POST)
	{
		$district_id=addslashes($POST['district_id']);
		$delivery_area_rest=addslashes($POST['delivery_area_rest']);
		
		$sql="insert into rest_delivery_areas(district_id,delivery_area) values('$district_id','$delivery_area_rest')";
		$res	= $this->db ->setQuery($sql);
		return "Delivery area added successfully";
	}
	function getDeliveryAreas($user_id)
	{
		$sql="select * from delivery_areas left join rest_delivery_areas on delivery_areas.delivery_area_id=rest_delivery_areas.delivery_area_id where delivery_areas.user_id='$user_id'";
		
		$rows	= $this ->db ->readValues($sql);
		return $rows;
	}
	function getPassword($user_id)
	{
		$sql="select password from user where user_id='$user_id'";
		
		$rows	= $this ->db ->readValue($sql);
		return $rows;
	}
	
	function addDeliveryareaAll($POST)
	{
		$district=addslashes($POST['district']);
		$delivery_area=$POST['delivery_area'];
		$count=count($delivery_area);
		for($i=0;$i<$count;$i++)
		{			
			$name=addslashes($delivery_area[$i]);
			$sql="insert into rest_delivery_areas(district_id,delivery_area) values('$district','$name')";
			$res	= $this->db ->setQuery($sql);
			$name="";
		}
		return "Delivery area added successfully";
	}
	function DeliveryareaExists($delivery_area)
	{
		$delivery_area=addslashes($delivery_area);
		$sql="select * from rest_delivery_areas where delivery_area='$delivery_area'";
		$res	= $this->db ->readValue($sql);
		return $res;
	}
    function deliveryExistsupdate($delivery_area,$delivery_id)
	{
		
		$count=count($delivery_area);
		for($i=0;$i<$count;$i++)
		{			
			$name=addslashes($delivery_area[$i]);
			$id=$delivery_id[$i];
			$sql="update rest_delivery_areas set  delivery_area='$name' where $name not in (select delivery_area from rest_delivery_areas)";
			echo $sql;
			$res1	= $this->db ->readValues($sql);
				/*if(array_key_exists($res1))
				{
				  echo "Delivery area already exists";
				}*/
			
		}exit;
		return $res1;
	}
	function editDeliveryareaAll($POST,$delivery_id)
	{
		$deliveryarea=$POST['delivery_area'];
		$count=count($deliveryarea);
		$errors=array();	
		for($i=0;$i<$count;$i++)
		{		
			
			$name=addslashes($deliveryarea[$i]);
			$id=$delivery_id[$i];
			$sql="update rest_delivery_areas set delivery_area='$name' where delivery_area_id='$id'";
			$res	= $this->db ->setQuery($sql);
			/*if($res)
			{
				  $errors[]="Delivery area already exists";
			}*/
			$name="";
		}
		return "$res";
	}
	function sendMailtoRest($booktable_id)
	{
	
			$getBookatableDetails=$this->generalnewobj->getGeneralById('book_table',array('booktable_id'=>$booktable_id));
			
			$name=$getBookatableDetails['name'];
			$email=$getBookatableDetails['email_id'];
			$mobile=$getBookatableDetails['mobile'];
			$phone=$getBookatableDetails['phone'];
			
			$start_date=$getBookatableDetails['start_date'];
			
			
			$end_date=$getBookatableDetails['end_date'];
			
			
			$seats=$getBookatableDetails['total_seats'];
			$cuisine=$getBookatableDetails['cuisine'];
			
			
			$service=$getBookatableDetails['service'];
			
			
			
			$budget=$getBookatableDetails['budget'];
			$city=$getBookatableDetails['city'];
			$locality=$getBookatableDetails['locality'];
			$getDistrictbyId=$this->generalnewobj->getGeneralById('districts',array('district'=>$locality));
			$district=$getDistrictbyId['district_id'];
			
			$occassion=$getBookatableDetails['occasion'];
			$instruction=$getBookatableDetails['instructions'];
			
			$getAllcorporateRestaurant=$this->dubbauserobj->getAllcorporateRestaurant($district);
		
			
			$mail1=	new PHPMailer();
			$mail1->IsHTML(true); 
			
			$mail1->Host = '208.109.217.153';	
			
			//print_r($getAllcorporateRestaurant);exit;
			foreach($getAllcorporateRestaurant as $key=>$values)
			{
				$mail1->AddAddress($values['email'],$values['name']);
			}
			//$mail1->AddAddress('sreenathp20@gmail.com');
			
			$mail1->AddAddress('corporate@yummybay.com');
			
			$mail1->From = "info@yummybay.com";
			$mail1->FromName = "YummyBay.com";
			$mail1->Subject = "Corporate booking from yummybay.com";
			
			$msg1='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>email_letter2_html</title>
<style type="text/css" media="screen">
body {
         margin: 0;
         padding: 0;
         background-color: #FFFFFF;
		 font-family: Arial;
		 color:#333333;
		 
      }
	   a {
         font-family: Arial;
         font-size: 13px;
         font-weight: normal;
         color: #f03e60;
      }

      p {
         font-family: Arial;
         font-size: 11px;
         font-weight: normal;
         color: #df143d;
		 margin:0px;
		 padding:5px 0 0 0;
      }
	  h3{
	  color:#999999;
	  }
</style>
</head>

<body>
<table  width="636"border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="background-image:url(image/bg.jpg); background-repeat:repeat-y;">
  <tr>
    <td><table width="580" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td height="111" colspan="3"><div align="center"><img src="http://yummybay.com/images/f1-img/l2ogo.jpg" width="582" height="111" /></div></td>
      </tr>
      <tr>
        <td style="background-image:url(http://yummybay.com/images/f1-img/r1ainb1ow.jpg); padding:0 0 0 10px;; margin:0px; height:155px; color:#FF0000;" colspan="3">Dear <span style="color:#333333;">restaurateur,</span>
          <h3 align="center">Welcome to Yummybay</h3>          <div align="center"></div></td>
      </tr>
      
      <tr>
        <td height="20" colspan="3"><div align="center" style="font-size:13px; color:#999999;">
          <p>Corporate booking  from yummybay.com</p>
        </div></td>
      </tr>
      
      <tr>
        <td height="20" colspan="3">&nbsp;</td>
      </tr>
      <tr>
        <td width="256" height="20"><div align="right" style="font-size:13px;" ><strong>Name</strong></div> </td>
        <td width="19" height="20" align="right"><strong>:</strong> </td>
        <td width="307" height="20"><div align="left" style="font-size:13px;color:#999999;" ><strong>'.$name.'</strong></div></td>
      </tr>
      <tr>
        <td width="256" height="20"><div align="right" style="font-size:13px;" ><strong>Email</strong></div> </td>
        <td width="19" height="20" align="right"><strong>:</strong> </td>
        <td width="307" height="20"><div align="left" style="font-size:13px;color:#999999;" ><strong>'.$email.'</strong></div></td>
      </tr>
       <tr>
        <td width="256" height="20"><div align="right" style="font-size:13px;" ><strong>Start date and time</strong></div> </td>
        <td width="19" height="20" align="right"><strong>:</strong> </td>
        <td width="307" height="20"><div align="left" style="font-size:13px;color:#999999;" ><strong>'.$start_date.'</strong></div></td>
      </tr>
       <tr>
        <td width="256" height="20"><div align="right" style="font-size:13px;" ><strong>End date and time</strong></div> </td>
        <td width="19" height="20" align="right"><strong>:</strong> </td>
        <td width="307" height="20"><div align="left" style="font-size:13px;color:#999999;" ><strong>'.$end_date.'</strong></div></td>
      </tr>
       <tr>
        <td width="256" height="20"><div align="right" style="font-size:13px;" ><strong>No. of guests</strong></div> </td>
        <td width="19" height="20" align="right"><strong>:</strong> </td>
        <td width="307" height="20"><div align="left" style="font-size:13px;color:#999999;" ><strong>'.$seats.'</strong></div></td>
      </tr>
       <tr>
        <td width="256" height="20"><div align="right" style="font-size:13px;" ><strong>Food type</strong></div> </td>
        <td width="19" height="20" align="right"><strong>:</strong> </td>
        <td width="307" height="20"><div align="left" style="font-size:13px;color:#999999;" ><strong>'.$cuisine.'</strong></div></td>
      </tr>
      <tr>
        <td width="256" height="20"><div align="right" style="font-size:13px;" ><strong>Required service</strong></div> </td>
        <td width="19" height="20" align="right"><strong>:</strong> </td>
        <td width="307" height="20"><div align="left" style="font-size:13px;color:#999999;" ><strong>'.$service.'</strong></div></td>
      </tr>
       <tr>
        <td width="256" height="20"><div align="right" style="font-size:13px;" ><strong>Budget</strong></div> </td>
        <td width="19" height="20" align="right"><strong>:</strong> </td>
        <td width="307" height="20"><div align="left" style="font-size:13px;color:#999999;" ><strong>'.$budget.'</strong></div></td>
      </tr>
       <tr>
        <td width="256" height="20"><div align="right" style="font-size:13px;" ><strong>City</strong></div> </td>
        <td width="19" height="20" align="right"><strong>:</strong> </td>
        <td width="307" height="20"><div align="left" style="font-size:13px;color:#999999;" ><strong>'.$city.'</strong></div></td>
      </tr>
       <tr>
        <td width="256" height="20"><div align="right" style="font-size:13px;" ><strong>District</strong></div> </td>
        <td width="19" height="20" align="right"><strong>:</strong> </td>
        <td width="307" height="20"><div align="left" style="font-size:13px;color:#999999;" ><strong>'.$locality.'</strong></div></td>
      </tr>
      <tr>
        <td width="256" height="20"><div align="right" style="font-size:13px;" ><strong>Occassion</strong></div> </td>
        <td width="19" height="20" align="right"><strong>:</strong> </td>
        <td width="307" height="20"><div align="left" style="font-size:13px;color:#999999;" ><strong>'.$occassion.'</strong></div></td>
      </tr>
      <tr>
        <td width="256" height="20"><div align="right" style="font-size:13px;" ><strong>Instructions</strong></div> </td>
        <td width="19" height="20" align="right"><strong>:</strong> </td>
        <td width="307" height="20"><div align="left" style="font-size:13px;color:#999999;" ><strong>'.$instruction.'</strong></div></td>
      </tr>
      
      
       
      
       
      
      
     
      <tr>
        <td colspan="3">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="3"><div align="center" style="font-size:13px;">
          <p><br />
            If you need any assistance feel free to  contact at yummybay.com.</p>
        </div></td>
      </tr>
      <tr>
        <td colspan="3">&nbsp;</td>
      </tr>
      
      <tr>
    <td align="left" bgcolor="#f4f3f3" colspan="3" ><h3 style="font-size:15px; color:#f03e60; padding:5px 0 5px 10px; margin:0px;">Follow Us</h3></td>
  </tr>
      <tr>
        <td colspan="3">&nbsp;</td>
      </tr>
      <tr >
        <td colspan="3"><table width="580" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="38">&nbsp;</td>
            <td width="107"><a href="http://www.facebook.com/Yummybay" target="_blank"><img src="http://yummybay.com/images/f1-img/f1ace_b1ook.jpg" width="107" height="28" border="0" /></a></td>
            <td width="26">&nbsp;</td>
            <td width="107"><a href="http://twitter.com/yummybay" target="_blank"><img src="http://yummybay.com/images/f1-img/t1witter.jpg" width="107" height="28" border="0" /></a></td>
            <td width="11">&nbsp;</td>
            <td width="117"><a href="http://blog.yummybay.com/" target="_blank"><img src="http://yummybay.com/images/f1-img/b1log.jpg" width="107" height="28" border="0" /></a></td>
            <td width="20">&nbsp;</td>
            <td width="111"><a href="http://www.youtube.com/watch?v=o5IQatKqH2Q" target="_blank"><img src="http://yummybay.com/images/f1-img/y1ou_t1ube.jpg" width="107" height="28" border="0" /></a></td>
            <td width="43">&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td style="border-bottom:dotted; color:#efefef;" colspan="3">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="3">&nbsp;</td>
      </tr>
      <tr>
        <td colspan="3"><table width="580" border="0" cellspacing="0" cellpadding="0" style="background-color:#f4f3f3;">
          <tr>
            <td width="33%" bgcolor="#f4f3f3" style="color:#8b8989; padding:10px 0 0 10px; font-size:13px;">Contact Our CEO</td>
            <td width="33%" bgcolor="#f4f3f3" style="color:#8b8989; padding:10px 0 0 0; font-size:13px;">Marketing Division</td>
            <td width="33%" bgcolor="#f4f3f3" style="color:#8b8989; padding:10px 0 0 0; font-size:13px;">Business Devolopment</td>
          </tr>
          <tr>
            <td bgcolor="#f4f3f3" ><a href="mailto:ceo@yummybay.com" style="font-size:12px; padding:10px 10px 10px 10px;">ceo@yummybay.com</a></td>
            <td bgcolor="#f4f3f3" ><div align="left"><a href="mailto:marketing@yummybay.com" style="font-size:12px; padding:10px 10px 10px 0;">marketing@yummybay.com</a></div></td>
            <td bgcolor="#f4f3f3" ><div align="left"><a href="mailto:business@yummybay.com" style="font-size:12px; padding:10px 10px 10px 0;">business@yummybay.com</a></div></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table></td>
      </tr>
      <tr>
        <td style="font-size:12px; padding:5px 0 10px 0;" bgcolor="#ffffff" colspan="3" ><div align="center" >
          <p>Yummybay.com is a division of AMICITIA FOOD  MART PVT LTD - Registered COCHIN.  Registered Office: AMICITIA FOOD MART PVT LTD,PALATHINKAL BLDG,KOCHAPILLY ROAD,NH  47,PALARIVATTOM BYPASS,ERNAKULAM-682025. This communication contains  information which is confidential and may also be privileged. It is for the  exclusive use of the intended recipient(s). If you are not the intended  recipient(s) please note that any distribution, copying or use of this  communication or the information in it is strictly prohibited. Any views or  opinions expressed in the communication are solely those of the author. If you  have received this communication in error please notify us by e-mail or by  telephone and then delete the communication and any copies of it.<br />
              <br />
            Telephone calls may be monitored or recorded.</p>
        </div></td>
      </tr>
      <tr>
        <td colspan="3">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
</table>

</body>
</html>

';


	
			$mail1->Body=$msg1;
	
						
		   	$send =  $mail1->Send();
			if($send)
			{
				$msg="Your request sent successfully";
			}
			else
			{
				$errors[]="Mail not sent";
			}
	}



}
?>