<?php
class buda_enterprenuer_class{
	 public  $dbcon;
     public  $host="localhost";
     public  $dbname="aiderste_enterprenuers";
     public  $user="aiderste_aiderstech";
     public  $pwd="Aid@2022_2023";


                                      //FUNCTION FOR DATABASE CONNECTION GOES HERE
 
function __construct(){
	
		   $this->dbcon = new PDO("mysql:dbname=$this->dbname;host=$this->host",$this->user,$this->pwd);
          
}
//////////////////////////////////////////////CHECK THE CONFIRMATION CODE////////////////
///////////////////////

function updateThisOrderStatus($date,$status,$orderid,$customerid,$itemid,$shopid){
	try{
			$data=array($date,$status,$orderid,$customerid,$itemid,$shopid);
		    $ownerH=$this->dbcon->prepare("update order_info set deliverdate=?, processingstatus=?  where orderid=? and customerid=? and itemid=? and $shopid=?"); 
	   
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}
 


 function getMyBatchOrderList($ownID){
	try{
		$status="In progress";
		//$date="";
		$ownerH=$this->dbcon->prepare("select * from  batch_info where customerid =:Id and status=:std");
		$ownerH->bindParam(":Id",$ownID); 
		$ownerH->bindParam(":std",$status);
		//$ownerH->bindParam(":don",$date);
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}

function getMyProgressiveOrderByDateRange($ownID,$sdate,$edate){
	$status="In progress";
	$data= array($status,$ownID,$sdate,$edate);
	try{
		$ownerH=$this->dbcon->prepare("select * from  Order_info where processingstatus=? and customerid =? and dateordered between ? and ? order by dateordered DESC");  
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}


function getMyOrderInprogress($ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from  Order_info where customerid =:Id and processingstatus=:pid");
		$status="In progress";
		$ownerH->bindParam(":Id",$ownID); 
		$ownerH->bindParam(":pid",$status); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}


function getMyProgressiveOrderByDate($ownID,$sdate){
	$status="In progress";
	$data= array($status,$ownID,'%'.$sdate.'%');
	try{
		$ownerH=$this->dbcon->prepare("select * from  Order_info where processingstatus=? and customerid =? and dateordered like ? order by dateordered DESC");
	    //$ownerH->bindParam(":id",$ownID);
       // $ownerH->bindParam(":date",$sdate); 
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}



function getMyOrderInprogressById($ownID,$id){
	$status="In progress";
	$data= array($ownID,$status,$id,$id,$id);
	try{
	
		$ownerH=$this->dbcon->prepare("select * from  Order_info where customerid =? and processingstatus=? and itemid= ? or orderid=? or batchID =?");
	   
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}

function updateThisOrderReceptionStatus($orderid,$customerid,$itemid,$shopid){
	try{
		   $status="Delivery OK";
		   $date="OK by: ".Date("Y-m-d");
			$data=array($date,$status,$orderid,$customerid,$itemid,$shopid);
		    $ownerH=$this->dbcon->prepare("update order_info set reception=?, processingstatus=?  where orderid=? and customerid=? and itemid=? and $shopid=?"); 
	   
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}



 	function getMyBatchOrderByBatchId($ownID,$id){
	$status="In progress";
	 
	$data= array($status,$ownID,$id);
	try{
		$ownerH=$this->dbcon->prepare("select * from  batch_info where  status=? and customerid =? and batchID=?");
	   
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}



function getMyBatchOrderByRange($ownID,$sdate,$edate){
	$status="In progress";
	//$date="";
	$data= array($status, $ownID,$sdate,$edate);
	try{
		$ownerH=$this->dbcon->prepare("select * from  batch_info where status=?   and  customerid =? and createdon between ? and ?");  
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}



function getMyAllBatch($ownID){
	try{
	///createdon	customerid	shopid	quantity	value	status	deliveredon

		$ownerH=$this->dbcon->prepare("select * from  batch_info where customerid =:Id order by createdon DESC");
 
		$ownerH->bindParam(":Id",$ownID);
		//$ownerH->bindParam(":sId",$shopid);  
		//$ownerH->bindParam(":bId",$batchID); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}

function getThisMyShop($ownID,$shopid){
	try{
		$ownerH=$this->dbcon->prepare("select * from shop_info where ownerid =:Id and shopid=:sd");
		$ownerH->bindParam(":Id",$ownID);
		$ownerH->bindParam(":sd",$shopid);  
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
 



 function getMyShopBatchOrderByItemId($shopid,$id,$batchID){
	$data= array($shopid,$id,$id,$batchID);
	try{
		$ownerH=$this->dbcon->prepare("select * from  Order_info where shopid =? and itemid= ? or orderid=? and batchID=?");
	   
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}

function getThisOrderBatchItemsFromMyShop($shopid,$batchID){
	try{
		$ownerH=$this->dbcon->prepare("select * from  Order_info where shopid =:Id and batchID=:bid");
		$ownerH->bindParam(":Id",$shopid);
		$ownerH->bindParam(":bid",$batchID);  
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}

function getMyShopBatchOrderByDate($shopid,$sdate){
	$status="In progress";
	 
	$data= array($status,$shopid,'%'.$sdate.'%');
	try{
		$ownerH=$this->dbcon->prepare("select * from  batch_info where status =?  and shopid =? and createdon like ?");
	    //$ownerH->bindParam(":id",$ownID);
       // $ownerH->bindParam(":date",$sdate); 
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}

function getMyShopBatchOrderByBatchId($shopid,$id){
	$status="In progress";
	 
	$data= array($status,$shopid,$id);
	try{
		$ownerH=$this->dbcon->prepare("select * from  batch_info where  status=? and shopid =? and batchID=?");
	   
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}


function getMyShopBatchOrderByRange($shopid,$sdate,$edate){
	$status="In progress";
	//$date="";
	$data= array($status, $shopid,$sdate,$edate);
	try{
		$ownerH=$this->dbcon->prepare("select * from  batch_info where status=?   and  shopid =? and createdon between ? and ?");  
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}


function getBatchOrderFromMyShop($shopid){
	try{
		$status="In progress";
		//$date="";
		$ownerH=$this->dbcon->prepare("select * from  batch_info where shopid =:Id and status=:std");
		$ownerH->bindParam(":Id",$shopid); 
		$ownerH->bindParam(":std",$status); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
function getMyBatchOrderByDate($ownID,$sdate){
	$status="In progress";
	 
	$data= array($status,$ownID,'%'.$sdate.'%');
	try{
		$ownerH=$this->dbcon->prepare("select * from  batch_info where status =?  and customerid =? and createdon like ?");
	    //$ownerH->bindParam(":id",$ownID);
       // $ownerH->bindParam(":date",$sdate); 
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}




 /////////////////FUNCTION RETRIEVING SHOP OWNED BY THE ACCOUNT USER/////////
function getMyCurrentOrder($ownID,$shopid){
	try{
		$status="In progress";
		//$ddate="NULL";
		//$reception='';
		$ownerH=$this->dbcon->prepare("select distinct batchID from  Order_info where customerid =:Id and shopid=:sId and processingstatus=:tId");
  // and processingstatus=:tId and deliverdate=:dId 
		$ownerH->bindParam(":Id",$ownID);
		$ownerH->bindParam(":sId",$shopid);  
		$ownerH->bindParam(":tId",$status);
		//$ownerH->bindParam(":dId",$ddate);
		///$ownerH->bindParam(":rId",$reception);
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
	////////////

/////////////////FUNCTION RETRIEVING SHOP OWNED BY THE ACCOUNT USER/////////
function getMyCurrentBatch($ownID,$shopid,$batchID){
	try{
	///createdon	customerid	shopid	quantity	value	status	deliveredon

		$ownerH=$this->dbcon->prepare("select * from  batch_info where customerid =:Id and shopid=:sId  and batchID=:bId");
 
		$ownerH->bindParam(":Id",$ownID);
		$ownerH->bindParam(":sId",$shopid);  
		$ownerH->bindParam(":bId",$batchID); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
	/////////

/////////////////FUNCTION RETRIEVING SHOP OWNED BY THE ACCOUNT USER/////////
function getMyCurrentOrderClosed($ownID,$shopid,$batchID){
	try{
		$status="In progress";
		//$ddate="NULL";
		//$reception='';
		$ownerH=$this->dbcon->prepare("select distinct batchID from  Order_info where customerid =:Id and shopid=:sId and processingstatus!=:tId and batchID=:bId");
  // and processingstatus=:tId and deliverdate=:dId 
		$ownerH->bindParam(":Id",$ownID);
		$ownerH->bindParam(":sId",$shopid);  
		$ownerH->bindParam(":tId",$status);
		$ownerH->bindParam(":bId",$batchID);
		///$ownerH->bindParam(":rId",$reception);
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
	////////
///////////////////////////////////////////////////////////
/////////////////FUNCTION RETRIEVING SHOPS OUT VIEW BY THE ACCOUNT USER/////////
 
function addShop($hnm,$ownerid,$hname,$category,$phoneno, $email,$pobox,$district,$country, $street ,$ward, $region,$popularDistination,$fn,$tmp_name){
	
  
try{
  	
 
    $site="../enterprenuersimages/".$fn;

	$Qr=$this->dbcon->prepare("insert into shop_info (shopid, ownerid,shopname,category, country,region,district,ward,street,phoneno ,postAddress,email,popularmark,directory) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)") ;
	$data=array($hnm,$ownerid,$hname,$category,$country,$region,$district,$ward,$street,$phoneno,$pobox,$email,$popularDistination,$site);
	$Qr->execute($data);

	 if($Qr->rowCount()>0)
	 {
	 	   move_uploaded_file($tmp_name,$site);
          return $Qr="Successfully saved!..";

          
	 }
	 else
	 {
	 	  return  $Qr->ErrorInfo();//="Changes not saved resubmit the form!..";
	 }

}
catch(PDOException $ex){
	$ex->getMessage();
}
}
                                               //////////////////////////
    
 /////////////////FUNCTION RETRIEVING SHOPS OUT VIEW BY THE ACCOUNT USER/////////
function getThisShopItemByShopid($shopid){
	try{
		$ownerH=$this->dbcon->prepare("select * from  item_info where  shopid=:sd");
		$ownerH->bindParam(":sd",$shopid); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}

/////////////////FUNCTION RETRIEVING SHOPS OUT VIEW BY THE ACCOUNT USER/////////              
 /////////////////FUNCTION RETRIEVING SHOPS OUT VIEW BY THE ACCOUNT USER/////////
function getThisShopItemBySearch($searchValue,$shopid){
	try{
		$ownerH=$this->dbcon->prepare("select * from  item_info where  itemname  like ?  or itemtype  like ? or itemcategory  like ?   or description  like ? and shopid like ?");
		//$ownerH->bindParam(":Id",$ownID); 
	    $ownerH->execute(array('%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$shopid.'%')); 
		  
		return $ownerH;

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

}

/////////////////FUNCTION RETRIEVING SHOPS OUT VIEW BY THE ACCOUNT USER/////////
function getItemBySearch($searchValue){
	try{
		$ownerH=$this->dbcon->prepare("select * from  item_info where  itemname  like ?  or itemtype  like ? or itemcategory  like ?   or description  like ?");
		//$ownerH->bindParam(":Id",$ownID); 
	    $ownerH->execute(array('%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%')); 
		  
		return $ownerH;

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

}

/////////////////FUNCTION RETRIEVING SHOPS OUT VIEW BY THE ACCOUNT USER/////////
function getShopBySearch($searchValue){
	try{
		$ownerH=$this->dbcon->prepare("select * from shop_info where  shopname  like ?  or country  like ? or region  like ?  or district  like ? or street  like ? or phoneno  like ? or email  like ?  or category  like ?  or popularmark  like ?");
		//$ownerH->bindParam(":Id",$ownID); 
	    $ownerH->execute(array('%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%')); 
		  
		return $ownerH;

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

}

/////////////
////////////////FUNCTION RETRIEVING SHOPS OUT VIEW BY THE ACCOUNT USER/////////
function getShopByKeypressSearch($searchValue){
	try{
		$ownerH=$this->dbcon->prepare("select * from shop_info where  shopname  like ? or category  like ?");
		//$ownerH->bindParam(":Id",$ownID); 
	    $ownerH->execute(array('%'.$searchValue.'%','%'.$searchValue.'%' )); 
		  
		return $ownerH;

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

}



function addOrder($shopid,$itemid,$customerid,$quantity,$cost,$batch){
	
      
     //$checkin=Date("hh:mm:ss");
	 $code="HBUDAJ19";
     $orderid=substr(Date("Ymdhis"),2);
     $status="In progress";
	 $data=array($orderid,$itemid,$shopid,$customerid,$code,$quantity,$status,$cost,$batch);
try{
	
	$Qr=$this->dbcon->prepare("insert into  order_info(orderid,itemid,shopid,customerid,paymentcode,quantity,processingstatus,tcost,batchID) values(?,?,?,?,?,?,?,?,?)");
	$Qr->execute($data);
if ($Qr->rowCount()>0) {
	$Qc=$this->dbcon->prepare("select * from batch_info where batchID=:bID and	customerid=:cID and	shopid =:sID");
	$Qc->bindParam(":bID",$batch);
	$Qc->bindParam(":cID",$customerid);
	$Qc->bindParam(":sID",$shopid);
	$Qc->execute();
	 if($Qc->rowCount()>0)
	 {
	 $cQ=$Qc->fetch();
	 $quantity=$quantity+$cQ['quantity'];
	 $value=$cost+$cQ['value'];
     $data=array($quantity,$value,$batch,$shopid,$customerid);

	$Qc=$this->dbcon->prepare("update batch_info set quantity=?, value=? where batchID=? and shopid=? and customerid=?");
	$Qc->execute($data);
	 return $Qc;
	 }
	 else
	 {
	  $data=array($batch,$customerid,$shopid,$quantity,$cost,$status);
//batchID	createdon	customerid	shopid	quantity	value	status	deliveredon
	$Qc=$this->dbcon->prepare("insert into batch_info (batchID,	customerid,	shopid,	quantity,value,status) values(?,?,?,?,?,?)");
	$Qc->execute($data);

	  return $Qc;//->ErrorInfo();// "Data not saved resubmit the form!..";
	 }
	 

    return $Qr;//="Information submitted successfully!..";
	  
    }
 
 
	 else
	 {
	 	  return  $Qr;//$Re="Data not saved resubmit the form!..";
	 }

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


/*
function addOrder($shopid,$itemid,$customerid,$quantity,$tcost){
	
      
     //$checkin=Date("hh:mm:ss");
	$status="In progress";
     $orderid=substr(Date("Ymdhis"),2);
     $code="HBUDAJ19";
	 $data=array($orderid,$itemid,$shopid,$customerid,$code,$quantity,$tcost,$status);
try{
	
 	//dateordered	itemid			deliverdate	reception

	$Qr=$this->dbcon->prepare("insert into  order_info(orderid,itemid,shopid,customerid,paymentcode,quantity,tcost,processingstatus) values(?,?,?,?,?,?,?,?)");
	$Qr->execute($data);

/*if ($Qr->rowCount()>0) {
	$status="Confirmed";
	$data=array($status,$code,$shopid,$itemid);

	$Qc=$this->dbcon->prepare("update payment_info set codestatus=? where paymentcode=? and shopid=? and itemid=?");
	$Qc->execute($data);
*
	 if($Qr->rowCount()>0)
	 {
          return $Re="Information submitted successfully!..";
	 }
	 else
	 {
	 	  return $Qr;
	 }
 
   // }
 
 
	 
	 	 // return  $Qr->ErrorInfo();//$Re="Data not saved resubmit the form!..";
	  

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





function addOrder($shopid,$itemid,$code,$customerid,$quantity){
	
      
     //$checkin=Date("hh:mm:ss");
     $orderid=substr(Date("Ymdhis"),2);
	 $data=array($orderid,$itemid,$shopid,$customerid,$code,$quantity);
try{
	
	$Qr=$this->dbcon->prepare("insert into  order_info(orderid,itemid,shopid,customerid,paymentcode,quantity) values(?,?,?,?,?,?)");
	$Qr->execute($data);
if ($Qr->rowCount()>0) {
	$status="Confirmed";
	$data=array($status,$code,$shopid,$itemid);

	$Qc=$this->dbcon->prepare("update payment_info set codestatus=? where paymentcode=? and shopid=? and itemid=?");
	$Qc->execute($data);

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


    }
 
 
	 else
	 {
	 	  return  $Qr->ErrorInfo();//$Re="Data not saved resubmit the form!..";
	 }

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


function OrederInquire($shopid,$itemid,$orderid,$customerid,$message){
	
      
     //$checkin=Date("hh:mm:ss");
     //$orderid=substr(Date("Ymdhis"),2);
	$replystatus="In processs";
	 $data=array($orderid,$itemid,$shopid,$customerid,$replystatus,$message);
try{
	
	$Qr=$this->dbcon->prepare("insert into  orderinquire(orderid,itemid,shopid,customerid,replystatus,message) values(?,?,?,?,?,?)");
	$Qr->execute($data);
if ($Qr->rowCount()>0) {
	 
	  
          return $Re="Information submitted successfully!..";
	  

    }
 
 
	 else
	 {
	 	  return  $Qr->ErrorInfo();//$Re="Data not saved resubmit the form!..";
	 }

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

/////////////////////////////////CHECK IF THE VALIDATION CODE GOES////////////////
/////////////////////////

/////////////////////////////////CHECK IF THE VALIDATION CODE GOES////////////////
///////////////////////////////////////////////////////////////////////////


                                           //FUNCTION FOR GETTING PAYMENT CODE GOES HERE HERE

///////////////////////
function getConfirmCode($code){
	try{
		$status="Confirmed";
		$ownerH=$this->dbcon->prepare("select * from  payment_info where paymentcode=:code and codestatus!=:status");
		$ownerH->bindParam(":code",$code);

		$ownerH->bindParam(":status",$status);
	    $ownerH->execute(); 
		  
		return $ownerH;

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



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

///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;
		          }
	           }                           


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

/////////////////////////////VALIDATION OF ITEMQUANTITY////////////////



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


function eQuantity($quantity) {
	 if($quantity=="")
	               {

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

                    ///////////////////////////
///////////////////////
/////////////////FUNCTION RETRIEVING SHOP OWNED BY THE ACCOUNT USER/////////
function getMyShop($ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from shop_info where ownerid =:Id");
		$ownerH->bindParam(":Id",$ownID); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////

/////////////////FUNCTION RETRIEVING SHOP NAME/////////
function getShopName($shopid){
	try{
		$ownerH=$this->dbcon->prepare("select * from shop_info where shopid =:Id");
		$ownerH->bindParam(":Id",$shopid); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
///////////////////////
/////////////////FUNCTION RETRIEVING ORDER INQUIRED  BY THE ACCOUNT USER/////////
function getMyOrderMessageReply($orderid,$ownID,$inquireid){
	try{
		$ownerH=$this->dbcon->prepare("select * from orderqueryreply where orderid=:id and customerid=:Id and inquireid=:iD"); 
		$ownerH->bindParam(":id",$orderid);
		$ownerH->bindParam(":Id",$ownID);  

		$ownerH->bindParam(":iD",$inquireid); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////

/////////////////FUNCTION RETRIEVING ORDER INQUIRED  BY THE ACCOUNT USER/////////
function getMyOrderMessage($orderid,$ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from orderinquire where orderid=:id and customerid=:Id"); 
		$ownerH->bindParam(":id",$orderid);
		$ownerH->bindParam(":Id",$ownID);  
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////
/////////////////FUNCTION RETRIEVING ORDER INQUIRED  BY THE ACCOUNT USER/////////
function getMyShopOrderMessage($orderid,$shopid){
	try{
		$ownerH=$this->dbcon->prepare("select * from orderinquire where orderid=:id and shopid=:Id"); 
		$ownerH->bindParam(":id",$orderid);
		$ownerH->bindParam(":Id",$shopid);  
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////

function getProgressiveOrderFromMyShop($shopid){
	try{
		$status="In progress";
		$ownerH=$this->dbcon->prepare("select * from  Order_info where shopid =:Id and processingstatus=:pid  order by dateordered DESC");
		$ownerH->bindParam(":Id",$shopid);
		$ownerH->bindParam(":pid",$status);  
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}

/////////////////FUNCTION RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////
function getItemName($itemid,$shopid){
	try{
		$ownerH=$this->dbcon->prepare("select * from item_info where itemid=:id and shopid=:Id"); 
		$ownerH->bindParam(":id",$itemid);
		$ownerH->bindParam(":Id",$shopid);  
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////


/////////////////FUNCTION RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////
function getAmountPaid($code){
	try{
		$ownerH=$this->dbcon->prepare("select * from payment_info where paymentcode=:id"); 
		$ownerH->bindParam(":id",$code);  
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////
/////////////////FUNCTION RETRIEVING SHOP OWNED BY THE ACCOUNT USER/////////
function getMyOrder($ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from  Order_info where customerid =:Id");
		$ownerH->bindParam(":Id",$ownID); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////


	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////
/////////////////FUNCTION RETRIEVING ORDER FROM SHOP OWNED BY THE ACCOUNT USER/////////
function getOrderFromMyShop($shopid){
	try{
		$ownerH=$this->dbcon->prepare("select * from  Order_info where shopid =:Id");
		$ownerH->bindParam(":Id",$shopid); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////


/////////////////FUNCTION RETRIEVING MY ITEM ORDER DETAIL THE ACCOUNT USER/////////
function getMyItemOrderDetail($ownID,$orderid){
	try{
		$ownerH=$this->dbcon->prepare("select * from  Order_info where customerid =:Id and orderid=:id");
		$ownerH->bindParam(":Id",$ownID); 
		$ownerH->bindParam(":id",$orderid);
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////


/////////////////FUNCTION RETRIEVING MY ITEM ORDER DETAIL THE ACCOUNT USER/////////
function getMyShopItemOrderDetail($shopid,$orderid){
	try{
		$ownerH=$this->dbcon->prepare("select * from  Order_info where shopid =:Id and orderid=:id");
		$ownerH->bindParam(":Id",$shopid); 
		$ownerH->bindParam(":id",$orderid);
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////
/////////////////FUNCTION GET ORDER BY DATE RANGE/////////
function getMyOrderByDate($ownID,$sdate){
	$data= array($ownID,'%'.$sdate.'%');
	try{
		$ownerH=$this->dbcon->prepare("select * from  Order_info where customerid =? and dateordered like ?");
	    //$ownerH->bindParam(":id",$ownID);
       // $ownerH->bindParam(":date",$sdate); 
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}

	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////


/////////////////FUNCTION GET ORDER BY DATE RANGE/////////
function getMyOrderByItemId($ownID,$id){
	$data= array($ownID,$id,$id);
	try{
		$ownerH=$this->dbcon->prepare("select * from  Order_info where customerid =? and itemid= ? or orderid=?");
	   
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}

	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////
/////////////////FUNCTION GET ORDER BY DATE RANGE/////////
function getMyOrderByRange($ownID,$sdate,$edate){
	$data= array($ownID,$sdate,$edate);
	try{
		$ownerH=$this->dbcon->prepare("select * from  Order_info where customerid =? and dateordered between ? and ?");  
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}
	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////
/////////
/////////////////FUNCTION GET ORDER BY DATE RANGE/////////


/////////////////FUNCTION GET ORDER BY DATE RANGE/////////
function getMyShopOrderByItemId($shopid,$id){
	$data= array($shopid,$id,$id);
	try{
		$ownerH=$this->dbcon->prepare("select * from  Order_info where shopid =? and itemid= ? or orderid=?");
	   
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}

	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////

function getMyShopOrderByDate($shopid,$sdate){
	$data= array($shopid,'%'.$sdate.'%');
	try{
		$ownerH=$this->dbcon->prepare("select * from  Order_info where shopid =? and dateordered like ?");
	    //$ownerH->bindParam(":id",$ownID);
       // $ownerH->bindParam(":date",$sdate); 
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}

	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////
function getMyShopOrderByRange($shopid,$sdate,$edate){
	$data= array($shopid,$sdate,$edate);
	try{
		$ownerH=$this->dbcon->prepare("select * from  Order_info where shopid =? and dateordered between ? and ?");  
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}
	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////

/////////////////FUNCTION RETRIEVING SHOP OWNED BY THE ACCOUNT USER/////////
function getThisShop($shopid){
	try{
		$ownerH=$this->dbcon->prepare("select * from shop_info where shopid =:Id");
		$ownerH->bindParam(":Id",$shopid); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////


/////////////////FUNCTION RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////
function getMyShopItem($shopid){
	try{
		$ownerH=$this->dbcon->prepare("select * from shop_info where   shopid=:id"); 
		$ownerH->bindParam(":id",$shopid);  
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////

	////////////////////HERE GOES FUNCTIO NFOR RETRIEING SHOP ITEMS/PRODUCTS////////////

	/////////////////FUNCTION RETRIEVING SHOP OWNED BY THE ACCOUNT USER/////////
function getShopItem($shopid){
	try{
		$ownerH=$this->dbcon->prepare("select * from item_info where shopid=:id");
	    $ownerH->bindParam(":id",$shopid); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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


	/////////////////FUNCTION RETRIEVING SHOP SPECIFIC ITEM/////////
function getThisItem($shopid,$itemid){
	try{
		$ownerH=$this->dbcon->prepare("select * from item_info where itemid=:id and shopid=:Id");
	    $ownerH->bindParam(":id",$itemid);
	     $ownerH->bindParam(":Id",$shopid); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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


function getAllBatchOrderFromMyShop($shopid){
	try{
		//$status="In progress";
		//$date="";
		$ownerH=$this->dbcon->prepare("select * from  batch_info where shopid =:Id order by createdon DESC");
		$ownerH->bindParam(":Id",$shopid); 
		//$ownerH->bindParam(":std",$status);
		//$ownerH->bindParam(":don",$date);
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}


function getMyShopAllBatchOrderByRange($shopid,$sdate,$edate){
	//$status="In progress";
	//$date="";
	$data= array($shopid,$sdate,$edate);
	try{
		$ownerH=$this->dbcon->prepare("select * from  batch_info where  shopid =? and createdon between ? and ? order by createdon DESC");  
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}
function getMyShopAllBatchOrderByBatchId($shopid,$id){
	///$status="In progress";
	 
	$data= array($shopid,$id);
	try{
		$ownerH=$this->dbcon->prepare("select * from  batch_info where  shopid =? and batchID=? order by createdon DESC");
	   
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}


function getMyShopAllBatchOrderByDate($shopid,$sdate){
	//$status="In progress";
	 
	$data= array($shopid,'%'.$sdate.'%');
	try{
		$ownerH=$this->dbcon->prepare("select * from  batch_info where   shopid =? and createdon like ? order by createdon DESC");
	    //$ownerH->bindParam(":id",$ownID);
       // $ownerH->bindParam(":date",$sdate); 
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}




function updateThisItemPrice($itemcost,$currency,$itemid,$shopid){
	try{
			$data=array($itemcost,$currency,$itemid,$shopid);
		    $ownerH=$this->dbcon->prepare("update item_info set itemcost=?, currency=? where itemid=? and shopid=?"); 
	   
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}

//////////////////////////                           /////////////////
////////////////////////GET ITEM FROM THIS SHOP///////////////////////
function getThisItemImage($shopid,$itemid,$profile){
	try{
		$ownerH=$this->dbcon->prepare("select * from itemimages where itemid=:it and shopid=:id and directory !=:prof");
	    $ownerH->bindParam(":id",$shopid);
	    $ownerH->bindParam(":it",$itemid); 
	    $ownerH->bindParam(":prof",$profile); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

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

////////////////////
//////////////////////////                           /////////////////
////////////////////////GET ITEM FROM THIS SHOP///////////////////////
function getThisItemProfile($shopid,$itemid){
	try{
		$ownerH=$this->dbcon->prepare("select * from itemimages where itemid=:it and shopid=:id");
	    $ownerH->bindParam(":id",$shopid);
	    $ownerH->bindParam(":it",$itemid);  
	    $ownerH->execute(); 
		  
		return $ownerH;

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

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

////////////////////                            //////////////////
//////////////////////GET SHOP PROFILE IMAGE/////////////////////
function getItemImages($shopid,$itemid){
	try{
		$ownerH=$this->dbcon->prepare("select * from itemimages where itemid =:iD and shopid =:Id");
		$ownerH->bindParam(":Id",$shopid);
		$ownerH->bindParam(":iD",$itemid);  
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
/////////////////FUNCTION RETRIEVING SHOPS OUT VIEW BY THE ACCOUNT USER/////////
function getShop(){
	try{
		$ownerH=$this->dbcon->prepare("select * from shop_info");
		//$ownerH->bindParam(":Id",$ownID); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}

/////////////////FUNCTION RETRIEVING SHOP OTHER VIEW BY THE ACCOUNT USER/////////
function getOtherShop($ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from shop_info where ownerid!=:Id");
		$ownerH->bindParam(":Id",$ownID); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////

///////////////////////////////////////GET SELECTED SHOP////////////////
//////////////////////////////////////////////////////////////////

/////////////////FUNCTION RETRIEVING SHOP OTHER VIEW BY THE ACCOUNT USER/////////
function getSelectedShopOther($shopid){
	try{
		$ownerH=$this->dbcon->prepare("select * from shop_info where shopid=:Id");
		$ownerH->bindParam(":Id",$shopid); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////

   
   /////////////////////                                             //////////////////////
///////////////////////  FUNCTION FOR VALIDATION OF ITEM DETAIL  GOES HERE///////////////

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

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


function eitemname($itemname) {
	 if($itemname=="")
	               {

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



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


function eitemtype($itemtype) {
	 if($itemtype=="")
	               {

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

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


function eitemcategory($itemcategory) {
	 if($itemcategory=="")
	               {

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



                               ////////////////////////////////
	                                    //  ROUTE DIRECTION VIA POINT
function vitemcost($itemcost,$currency) {
	 
	
		if(preg_match("/^[0-9]+$/",$itemcost)  && $itemcost!="" && $currency!=""){
			return 	$itemcost;
		} 
		 else{
		 	return false;
		 }
}  


function eitemcost($itemcost,$currency) {
	 if($itemcost=="" || $currency=="")
	               {

	 	return $itemcost="Both Price and currency are required!..";
	               }
	
	 else if(!preg_match("/^[0-9]+$/",$itemcost))
	              {
		 
        return $via= "Cost typed with error! ";
		          }
	 else         {
		          	return;
		          }
	           }                           
                               ////////////////////////////////
	                                    //  ROUTE DETAIL
function vitemdescription($itemdescription) {
	 
	
		if($itemdescription!=""){
			return 	$itemdescription;
		} 
		 else{
		 	return false;
		 }
}  


function eitemdescription($itemdescription) {
	 if($itemdescription=="")
	               {

	 	return $itemdescription="Description required!..";
	               }
	 
	 else         {
		          	return;
		          }
	           }                           


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

	           /////////////////MESSAGE VALIDATION/////////////////


	           function vmessage($message) {
	 
	
		if($message!=""){
			return 	$message;
		} 
		 else{
		 	return false;
		 }
}  


function emessage($message) {
	 if($message=="")
	               {

	 	return $message="message required!..";
	               }
	 
	 else         {
		          	return;
		          }
	           }                           
//////////////////////////
	                                    //  ROUTE DESTINATION
function vexpiredate($expiredate) {
	 
	
		if($expiredate!=""){
			return 	$expiredate;
		} 
		 else{
		 	return false;
		 }
}  


function eexpiredate($expiredate) {
	 if($expiredate=="")
	               {

	 	return $ldistance="Expire date required!..";
	               }
	 	          
	 else         {
		          	return;
		          }
	           }        

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


function addItem($itemid,$itemdescription,$itemcost,$itemcategory,$itemname,$itemtype,$expiredate,$shopid,$fn,$currency){
	
      
     $site="../enterprenuersimages/".$fn;

	 $data=array($shopid,$itemid,$itemname,$itemtype,$itemcategory,$itemcost,$itemdescription,$expiredate,$site,$currency);
       try{
	
	      $Qr=$this->dbcon->prepare("insert into item_info(shopid,itemid,itemname,itemtype,itemcategory,itemcost, description,expiredate,profileimages,currency) values(?,?,?,?,?,?,?,?,?,?)");
	     
	     $Qr->execute($data);
	      
	     return $Qr; 

        }

 
      catch(PDOException $ex){
	  $ex->getMessage();
}
} 
//////////////////////// ITEM DETAIL VALIDATIO NEND//////////////
///////////////////////////////////////////////////////////////// 
///////////////////////

///////////////////////////UPDATE PROFILE IMAGES//////////////////////
///////////////////////////////////////////////////////////////////

function updateProfileImage($itemid,$shopid,$profile){
	 
	 $data=array($profile,$shopid,$itemid);
       try{
	
	      $Qr=$this->dbcon->prepare("update item_info set profileimages=? where shopid=? and itemid=?");
	     
	     $Qr->execute($data);
	      
	     return $Qr; 

        }

 
      catch(PDOException $ex){
	  $ex->getMessage();
}
} 
////////////////////////////IMAGE TITLE//////////////////
///////////////////////UPDATE ITEM PROFILE/////////////////////
////////////////////////////////////////////////////////

function updateItem($itemid,$itemdescription,$itemcost,$itemcategory,$itemname,$itemtype,$expiredate,$shopid,$currency){
	 
	 $data=array($itemname,$itemtype,$itemcategory,$itemcost,$itemdescription,$expiredate,$currency,$shopid,$itemid);
       try{
	
	      $Qr=$this->dbcon->prepare("update item_info set itemname=?,itemtype=?,itemcategory=?,itemcost=?, description=?,expiredate=?, currency=? where shopid=? and itemid=?");
	     
	     $Qr->execute($data);
	      
	     return $Qr; 

        }

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

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


function eimagename($itemname) {
	 if($itemname=="")
	               {

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



////////////////////////////////////////////
//////////////////////////////////////////////   FUNCTION  FOR IMAGE VALIDATIO  GOES HERE //////////////////////
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<2000000)
	{
      
      return $size;
		  
    }
	else
	 {
	  return false; 
	 }

     }  



function eImageSize($size) 
 {
	 
	if($size>=0 && $size<2000000)
	{
      
      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("../enterprenuersimages/".$fn))
	{
      
      return false;
		  
    }
	else
	 {
	  return true; 
	 }

     }  



function eImageExist($fn) 
 {
	 
	
if(file_exists("../enterprenuersimages/".$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 ;
    }


} 

/////////////////////////////////UPLOAD ITEM IMAGES/////////////////////

function uploadImage($fn,$itemname, $itemid,$tmp_name,$shopid){

$site="../enterprenuersimages/".$fn;
    
 ///////////
 /////// IMAGE COMPRESSION/////////
 // Getting file name
 
  $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($shopid,$itemid,$site,$itemname);
 try{
	
	$Qr=$this->dbcon->prepare("insert into itemimages(shopid,itemid,directory,imagename) values(?,?,?,?)");
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {

     //move_uploaded_file($tmp_name,$site);
     imagejpeg($image, $site, 1);
           
          return $Qr;//="The image is successfully uploaded!..";
	 }
	 else
	 {
	 	  return $Qr= $Qr->ErrorInfo(); //$Re="Oops your network is low to upload data!..";
	 } 

}
catch(PDOException $ex){
	$ex->getMessage();
}
}
//////////////////////////////////////////////                               //////////////////////
///////////////////////////////////////////////////// IMAGE VALIDATION ENDS  ///////////////////
}
?>
