
<?php
class buda_myStockAgro_class{
	 public  $dbcon;
     public  $host="localhost";
     public  $dbname="aiderste_myagrostock";
     public  $user="aiderste_aiderstech";
     public  $pwd="Aid@2022_2023";
     //public  $user="root";
    // public  $pwd="";
    // public  $port="3308";


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


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

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

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



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

function getMyShopExpenses($shopid){
	try{
		$ownerH=$this->dbcon->prepare("select * from expenses where hotel_id=:hID");
		$ownerH->bindParam(":hID",$shopid);
	    $ownerH->execute(); 
		  
		return $ownerH;

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



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

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

////////////////////////FILTER BY DATE////////////////////

//////////////////////////////////////////////////////
function getMyShopExpenseByDate($shopid,$arrived_on){
	try{
		$ownerH=$this->dbcon->prepare("select * from expenses where  exp_date=? and hotel_id=?");
		$data= array($arrived_on,$shopid);    
	    $ownerH->execute($data); 
		  
		return $ownerH; 

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


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



///////////////////////SET BUYING PRICE AND SELLING PRICE EQUAL/////////////////

/////////
function resetThisItemPrice($itemcost,$itemid,$shopid,$ownID){
	try{
	        $price=$itemcost;//+$itemcost*0.1;
			$data=array($price,$itemcost, $itemid,$shopid,$ownID);
		    $ownerH=$this->dbcon->prepare("update itemstock set price=?, buyprice=?  where itemID=? and shopid=? and ownerid=?"); 
	   
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}

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




function getNameByFLetterItemSoldCheck($post){
	try{
		$ownerH=$this->dbcon->prepare("select * from itemsSold where itemName like ? order by itemName asc ");
	   /////where itemid=:id// $ownerH->bindParam(":id",$itemid);
	    // $ownerH->bindParam(":Id",$shopid); 
	    $ownerH->execute(array($post.'%')); 
		  
		return $ownerH;

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




function getNameByLetterItemEntryCheck($post){
	try{
		$ownerH=$this->dbcon->prepare("select * from itemsEntry where itemName like ? order by dateBought desc ");
	    ; 
	    $ownerH->execute(array($post.'%')); 
		  
		return $ownerH;

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



function getNameByFLetterItemCheck($post){
	try{
		$ownerH=$this->dbcon->prepare("select * from item_info where itemname like ? order by itemname asc ");
	     $ownerH->execute(array($post.'%')); 
		  
		return $ownerH;

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

















//////////////////////////////////////////////CHECK THE CONFIRMATION COD
function getCheckedShopItemPricesOtherView($itemid,$shopid,$ownerD){
	try{
		$ownerH=$this->dbcon->prepare("select * from itemstock where itemID =:id and shopid=:Id and ownerid=:iD"); 
		$ownerH->bindParam(":id",$itemid);
		$ownerH->bindParam(":Id",$shopid);
		$ownerH->bindParam(":iD",$ownerD);   
	    $ownerH->execute(); 
		  
		return $ownerH;

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

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

function getItemPriceUpdate(){
	try{ 
		 
    		$owner=$this->dbcon->prepare("select * from itemstock");
    	   // $owner->bindParam(":id",$itemID); 
    	   // $owner->bindParam(":sd",$shopid);
    	     $owner->execute();
		 //
		 	if($owner->rowCount()>0){
		 	 $F=$owner->fetchAll();
		 	 foreach ($F as $key => $p) {
    	  	 $itemID=$p['itemID'];
    	  	 $bpr=$p['buyprice'];
    	  	 //if($bpr<150000){
    	  	  
    	  	 $price=$bpr+$bpr*0.1;   
    	  	 //}
    	  	// else{
    	  	     
    	  	 //$price=$bpr+ 25000;
    	  	 //}
	  	  	 $data=array($price,$itemID);
		     $owH=$this->dbcon->prepare("update itemstock set price=?  where itemID=?"); 
	   // and $shopid=
	         $owH->execute($data);
    	  	 }
	      
		  
		 
	}

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

	
	/////////////////FUNCTION RETRIEVING SHOP OWNED BY THE ACCOUNT USER/////////
function checkExistItem($itemcost,$itemcategory,$itemname,$itemtype,$currency){
	try{ 
	     $data=array('%'.$itemname.'%','%'.$itemtype.'%','%'.$itemcategory.'%','%'.$itemcost.'%','%'.$currency.'%');
		$ownerH=$this->dbcon->prepare("select * from item_info where itemname like ? and itemtype like ? and itemcategory like ? and itemcost like ? and currency like ?");
	    //$ownerH->bindParam(":id",$shopid); 
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

/////////////////FUNCTION GET ORDER BY DATE RANGE/////////
function getOrderFromMyShopProg($shopid){
	try{
		$status="In progress";
		$ownerH=$this->dbcon->prepare("select * from  order_info where shopid =:Id and processingstatus=:sp");
		$ownerH->bindParam(":Id",$shopid);
		$ownerH->bindParam(":sp",$status);  
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}

function getMyShopOrderByRangeProg($shopid,$sdate,$edate){
	$status="In progress";
	$data= array($shopid,$status,$sdate,$edate);
	try{
		$ownerH=$this->dbcon->prepare("select * from  order_info where shopid =? and processingstatus=? and dateordered between ? and ?");  
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}

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

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

}


function getMyShopOrderByDateProg($shopid,$sdate){
	$status="In progress";
	$data= array($shopid,$sdate,$status);
	try{
		$ownerH=$this->dbcon->prepare("select * from  order_info where shopid =? and dateordered like ? and processingstatus=?");
	    //$ownerH->bindParam(":id",$ownID);
       // $ownerH->bindParam(":date",$sdate); 
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}

	//////
function getMyOrderSuperUser(){
	try{
		$ownerH=$this->dbcon->prepare("select * from  Order_info"); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
function getMyOrderSuperUserProg(){
	try{
		$status="In progress";
		$ownerH=$this->dbcon->prepare("select * from  order_info where processingstatus=:sp"); 
		$ownerH->bindParam(":sp",$status);
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}


function getOrderByRangeSuperUser($sdate,$edate){
	$data= array($sdate,$edate);
	try{
		$ownerH=$this->dbcon->prepare("select * from  order_info where  dateordered between ? and ?");  
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}


function getOrderByRangeSuperUserProg($sdate,$edate){
	$data= array($sdate,$edate);
	try{
		$ownerH=$this->dbcon->prepare("select * from  order_info where  dateordered between ? and ?");  
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}
function getOrderByItemIdSuperUser($id){
	$data= array($id,$id);
	try{
		$ownerH=$this->dbcon->prepare("select * from  order_info where itemid= ? or orderid=?");
	   
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}


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

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

}
	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////
 
function getOrderByDateSuperUser($sdate){
	$data= array('%'.$sdate.'%');
	try{
		$ownerH=$this->dbcon->prepare("select * from  order_info where  dateordered like ?");
	    //$ownerH->bindParam(":id",$ownID);
       // $ownerH->bindParam(":date",$sdate); 
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}


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

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

}

////////////////END SUPER ORDER RETRIEVAL////////////////////




/////////////////FUNCTION RETRIEVING SHOP OWNED BY THE ACCOUNT USER/////////
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 FOR RETRIEVING SHOP ENDS/////////////////
/////////////////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 FOR RETRIEVING SHOP ENDS/////////////////
	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////
/////////////////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 FOR RETRIEVING SHOP ENDS/////////////////

	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////
/////////////////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 FOR RETRIEVING SHOP ENDS/////////////////

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

function addShop($hnm,$ownerid,$hname,$category,$phoneno, $email,$pobox,$district,$country, $street ,$ward, $region,$popularDistination,$fn,$tmp_name){
	
  
try{
  	
 
    $site="../agroImages/".$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 FOR WORKERS OF HOTEL HERE
                               ////////////////////////
       
       


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

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
            ///////                           //////////////////////
        //////////////////////
	           ///////////////SAVING ROOM DATA EDITING TO THE DATABASE GOES HERE

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

}
catch(PDOException $ex){
	$ex->getMessage();
}
}
 
                                         //FUNCTION FOR WORKERS OF HOTEL HERE
function getShopWorkersForEdit($accountId,$shopid){
	try{
		$ownerH=$this->dbcon->prepare("select * from shopworkers where  shopid=:hID and accountId=:Id");
		$ownerH->bindParam(":hID",$shopid);
		$ownerH->bindParam(":Id",$accountId);  
	    $ownerH->execute(); 
		  
		return $ownerH;

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

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


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

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


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

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

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

/////////////////////////////////////////////////////////////////
function getShopWorkersProfile($ownerid,$shopid){
	try{
		$ownerH=$this->dbcon->prepare("select * from shopworkers where  shopid=:hID and accountId=:id");
		$ownerH->bindParam(":hID",$shopid); 
		$ownerH->bindParam(":id",$ownerid); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

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

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

/////////////////////////////////////////////////////////////////
function getEmployee($ownerid){
	
 
	 //$data=array($routeId,$hnm);
try{
	
	$Qr=$this->dbcon->prepare("select * from  shopworkers where accountId=:rid");
	$Qr->bindParam(":rid",$ownerid);
	//$Qr->bindParam(":id",$shopid);
	$Qr->execute();
	// if($Qr->rowCount()>0)
	// {
    return $Qr;//="Record deleted successfully!..";
	// }
	 //else
	 //{
	 	 // return  $Re="Record not deleted!..";
	// }

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


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

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

function createMyStock($stockID,$ownID,$itemid, $itemcost, $shopid, $currency,$scost,$dateBought,$bestsupply,$quantity,$itemname){

 

	 $data=array($stockID,$ownID,$itemid, $itemcost,$scost,$shopid, $currency,$bestsupply, $quantity,$itemname);
       try{
           
	      $Qr=$this->dbcon->prepare("insert into itemstock(stockID,ownerid,itemID,buyprice,price,shopid,currency,bestsupply,quantity,itemName) values(?,?,?,?,?,?,?,?,?,?)");
	     
	     $Qr->execute($data);
	      
	     return $Qr; 

        }

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

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

function addMyStock($stockID,$ownID,$itemid, $itemcost, $shopid, $currency,$scost,$dateBought,$bestsupply,$quantity,$itemname){

 

	   $data=array($stockID,$ownID,$itemid, $itemcost,$scost,$shopid, $currency,$bestsupply, $quantity,$dateBought,$itemname);
       try{
           
	      $Qr=$this->dbcon->prepare("insert into itemsEntry(stockID,ownerid,itemID,buyprice,price,shopid,currency,bestsupply,quantity,dateBought,itemName) values(?,?,?,?,?,?,?,?,?,?,?)");
	     
	     $Qr->execute($data);
	      
	     return $Qr; 

        }

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


//////////////////////// ITEM DETAIL VALIDATIO NEND//////////////

function saleMyStock($stockID,$ownID,$itemid, $itemcost, $shopid, $currency,$scost,$dateBought,$quantity,$itemname){

 

	   $data=array($stockID,$ownID,$itemid, $itemcost,$scost,$shopid, $currency, $quantity,$dateBought,$itemname);
       try{
           
	      $Qr=$this->dbcon->prepare("insert into itemsSold(stockID,ownerid,itemID,buyprice,price,shopid,currency,quantity,dateSold,itemName) values(?,?,?,?,?,?,?,?,?,?)");
	     
	     $Qr->execute($data);
	      
	     return $Qr; 

        }

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


//////////////////////// ITEM DETAIL VALIDATIO NEND//////////////
///////////////////////////////////////////////////////////////// 
///////////////////////
//////////////////////////////////////////////////////////////////////////////////
 	/////////////////FUNCTION RETRIEVING SHOP OTHER VIEW BY THE ACCOUNT USER/////////
function getShopsItems(){
	try{
		$ownerH=$this->dbcon->prepare("select * from item_info");
		//$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 getItemOfThisPrice($itemid,$shopid,$ownerD){
	try{
		$ownerH=$this->dbcon->prepare("select * from itemstock where itemID=:id and shopid=:sd and ownerid=:ow"); 
		$ownerH->bindParam(":id",$itemid); 
		$ownerH->bindParam(":sd",$shopid); 
		$ownerH->bindParam(":ow",$ownerD); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
  	
/////////////////FUNCTION RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////

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

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

}
  	
/////////////////FUNCTION RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////



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

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

}
 
/////////////////FUNCTION RETRIEVING SHOPS OUT VIEW BY THE ACCOUNT USER/////////
  	
  	/////////
function getCheckedShopItemPrices($itemid,$shopid,$ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from itemstock where itemID=:id and shopid=:Id and ownerid=:iD"); 
		$ownerH->bindParam(":id",$itemid);
		$ownerH->bindParam(":Id",$shopid);
		$ownerH->bindParam(":iD",$ownID);   
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
 
/////////////////FUNCTION RETRIEVING SHOPS OUT VIEW BY THE ACCOUNT USER/////////
/////////////////FUNCTION RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////

 	/////////
function getShopEntryItem($shopid,$ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from itemsEntry where shopid=:Id and ownerid=:iD order by dateBought desc"); 
	 	$ownerH->bindParam(":Id",$shopid);
		$ownerH->bindParam(":iD",$ownID);   
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
 
/////////////////FUNCTION RETRIEVING SHOPS OUT VIEW BY THE ACCOUNT USER/////////
/////////////
function getShopItemPrices($shopid,$ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from itemstock where shopid=:Id and ownerid=:iD"); 
		//$ownerH->bindParam(":id",$itemid);
		$ownerH->bindParam(":Id",$shopid);
		$ownerH->bindParam(":iD",$ownID);   
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
 
/////////////////FUNCTION RETRIEVING SHOPS OUT VIEW BY THE ACCOUNT USER/////////

/////////////////FUNCTION RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////
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 RETRIEVING SHOPS OUT VIEW BY THE ACCOUNT USER/////////
/////////////////FUNCTION RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////
function updateThisBatchStatus($date,$orderid,$customerid,$shopid){
	try{
			  
 
		    
		      $own=$this->dbcon->prepare("select * from  order_info where orderid=:ord and customerid=:Id and shopid=:sId");
              $own->bindParam(":ord",$orderid); 
		      $own->bindParam(":Id",$customerid);
		      $own->bindParam(":sId",$shopid);   
		      $own->execute();
		      if ($own->rowCount()>0)
		      {
		      $G=$own->fetch();
		      $batchID=$G['batchID'];/////
		       //////////////

		      $ob=$this->dbcon->prepare("select * from  batch_info where batchID=:bid and customerid=:Id and shopid=:sId");
              $ob->bindParam(":bid",$batchID); 
		      $ob->bindParam(":Id",$customerid);
		      $ob->bindParam(":sId",$shopid);   
		      $ob->execute();
		      if ($ob->rowCount()>0)
		      {
		      	 $GG=$ob->fetch();  
		      	 if ($GG['status']!="Processing done")
		      	  {
		      	  $status="Processing done";
		      	  $data=array($status,$date,$batchID,$shopid,$customerid);
	              $Qc=$this->dbcon->prepare("update batch_info set status=?, deliveredon=? where batchID=? and shopid=? and customerid=?");
	              $Qc->execute($data);
	              return $Qc;
		       
		      	  }
		         return $ob;
		      	
		          }
		          else{
		      	  return $ob;
		          }
           

	           /////////////
		      	
		      }
		      else{
		      	return $own;
		      }
           
		 

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

/////////////////FUNCTION RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////
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); 
		   if ($ownerH->rowCount()>0) {
		        
		     /* $own=$this->dbcon->prepare("select * from  Order_info where orderid=:ord and customerid=:Id and shopid=:sId");
              $own->bindParam(":ord",$orderid); 
		      $own->bindParam(":Id",$ownID);
		      $own->bindParam(":sId",$shopid);
		      //$own->bindParam(":sId",$shopid);  
		      $own->execute();
		      if ($own->rowCount()>0)
		      {
		      	 $GG=$own->fetch(); 
		      	 $batchID=$GG['batchID'];
		         $data=array($status,$date,$batchID,$shopid,$customerid);
	             $Qc=$this->dbcon->prepare("update batch_info set status=?, deliveredon=? where batchID=? and shopid=? and customerid=?");

	             $Qc->execute($data);
	             return $Qc;
		       
		      	
		      }
		      else{
		      	return $own;
		      }
		      */
           return $ownerH;
		  } 
		  else{
		  	return $ownerH;
		  }
		 

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

}
 
/////////////////FUNCTION RETRIEVING SHOPS OUT VIEW BY THE ACCOUNT USER/////////

/////////////////FUNCTION RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////
function updateThisBatchOrderStatus($date,$customerid,$batchID,$shopid){
	try{
		    $status="Confirmed";
			$data=array($date,$status,$batchID,$customerid,$shopid);
		    $ownerH=$this->dbcon->prepare("update order_info set deliverdate=?, processingstatus=?  where batchID=? and customerid=?  and shopid=?"); 
	   
	        $ownerH->execute($data); 
		   if ($ownerH->rowCount()>0) {
		        
		         $status="Processing done";
		         $data=array($status,$date,$batchID,$shopid,$customerid);
	             $Qc=$this->dbcon->prepare("update batch_info set status=?, deliveredon=? where batchID=? and shopid=? and customerid=?");

	             $Qc->execute($data);
	             return $Qc;
		      
           return $ownerH;
		  } 
		  else{
		  	return $ownerH;
		  }
		 

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

}
 
/////////////////FUNCTION RETRIEVING SHOPS OUT VIEW BY THE ACCOUNT USER/////////
/////////////////FUNCTION RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////
function deleteThisItemFromStock($itemid,$shopid,$ownID){
	try{
	         
			$data=array($itemid,$shopid,$ownID);
		    $ownerH=$this->dbcon->prepare("delete from itemstock where itemID=? and shopid=? and ownerid=?"); 
	   
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}
  
 function updateThisItemPrice($bestsupply,$scost,$itemcost,$currency,$itemid,$shopid,$ownID){
	try{ 
			$data=array($bestsupply,$scost,$itemcost,$currency,$itemid,$shopid,$ownID);
		    $ownerH=$this->dbcon->prepare("update itemstock set bestsupply=?,price=?, buyprice=?, currency=? where itemID=? and shopid=? and ownerid=?"); 
	   
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}

 function updateThisItemQuantity($cquantity,$itemid,$shopid,$ownID){
	try{
	         
		$data=array($cquantity,$itemid,$shopid,$ownID);
		$ownerH=$this->dbcon->prepare("update itemstock set quantity=? where itemID=? and shopid=? and ownerid=?"); 
	   
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}
//
/////////////////FUNCTION RETRIEVING SHOPS OUT VIEW BY THE ACCOUNT USER/////////

/////////////////FUNCTION RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////
function updateItemDetail($itemcategory,$itemname,$itemtype,$itemid){
	try{ 
			$data=array($itemcategory,$itemname,$itemtype,$itemid);
		    $ownerH=$this->dbcon->prepare("update item_info set itemcategory=?, itemname=?, itemtype=? where itemid=?"); 
	   
	    $ownerH->execute($data); 
		  
		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 RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////
function getThisShopItemPriceOther($itemid,$shopid,$ownerD){
	try{
		$ownerH=$this->dbcon->prepare("select * from itemstock where itemID=:id and shopid=:Id and ownerid=:iD"); 
		$ownerH->bindParam(":id",$itemid);
		$ownerH->bindParam(":Id",$shopid);
		$ownerH->bindParam(":iD",$ownerD);   
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
 
/////////////////FUNCTION RETRIEVING SHOPS OUT VIEW BY THE ACCOUNT USER/////////
/////////////////FUNCTION RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////
function getThisShopItemPrice($itemid,$shopid,$ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from itemstock where itemID=:id and shopid=:Id and ownerid=:iD"); 
		$ownerH->bindParam(":id",$itemid);
		$ownerH->bindParam(":Id",$shopid);
		$ownerH->bindParam(":iD",$ownID);   
	    $ownerH->execute(); 
		  
		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 SHOP OTHER VIEW BY THE ACCOUNT USER/////////

function addOrder($shopid,$itemid,$code,$customerid,$quantity,$cost,$batchID){
	
      
     //$checkin=Date("hh:mm:ss");
     $orderid=substr(Date("Ymdhis"),2);
     $status="In progress";
	 $data=array($orderid,$itemid,$shopid,$customerid,$code,$quantity,$status,$cost,$batchID);
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",$batchID);
	$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,$batchID,$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($batchID,$customerid,$shopid,$quantity,$cost,$status);

	$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!..";
	 }
	/*$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!..";
	 }*/

    return $Qr;//="Information submitted successfully!..";
	  
    }
 
 
	 else
	 {
	 	  return  $Qr;//$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;
		          }
	           }                           


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

  //  COST OF SALE
function vscost($scost,$currency) {
	 
	
		if(preg_match("/^[0-9]+$/",$scost)  && $scost!="" && $currency!=""){
			return 	$scost;
		} 
		 else{
		 	return false;
		 }
}  


function escost($scost,$currency) {
	 if($scost=="" || $currency=="")
	               {

	 	return $scost="Both Price and currency are required!..";
	               }
	
	 else if(!preg_match("/^[0-9]+$/",$scost))
	              {
		 
        return $scost= "Cost typed with error! ";
		          }
	 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="Quantity required!..";
	               }
	
	 else if(!preg_match("/^[0-9]+$/",$quantity))
	              {
		 
        return $quantity= "Error in typing quantity 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 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 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 RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////
function getItemName($itemid){
	try{
		$ownerH=$this->dbcon->prepare("select * from item_info where itemid=: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 getMyOrderInprogress($ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from  order_info where customerid =:Id and processingstatus=:pid order by dateordered DESC");
		$status="In progress";
		$ownerH->bindParam(":Id",$ownID); 
		$ownerH->bindParam(":pid",$status); 
	    $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 order by dateordered DESC");
		$ownerH->bindParam(":Id",$ownID); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

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

/////////////////FUNCTION RETRIEVING ORDER FROM SHOP OWNED BY THE ACCOUNT USER/////////
function getMyBatchOrderList($ownID){
	try{
		$status="In progress";
		//$date="";
		$ownerH=$this->dbcon->prepare("select * from  batch_info where customerid =:Id and status=:std order by createdon DESC");
		$ownerH->bindParam(":Id",$ownID); 
		$ownerH->bindParam(":std",$status);
		//$ownerH->bindParam(":don",$date);
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////
/////////////////FUNCTION RETRIEVING ORDER FROM SHOP OWNED BY THE ACCOUNT USER/////////
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 FOR RETRIEVING SHOP ENDS/////////////////

	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////
/////////////////FUNCTION RETRIEVING ORDER FROM SHOP OWNED BY THE ACCOUNT USER/////////
function getBatchOrderFromMyShop($shopid){
	try{
		$status="In progress";
		//$date="";
		$ownerH=$this->dbcon->prepare("select * from  batch_info where shopid =:Id and status=:std  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 FOR RETRIEVING SHOP ENDS/////////////////

/////////////////FUNCTION RETRIEVING ORDER FROM SHOP OWNED BY THE ACCOUNT USER/////////
function getThisOrderBatchItemsFromMyShop($shopid,$batchID){
	try{
		$ownerH=$this->dbcon->prepare("select * from  order_info where shopid =:Id and batchID=:bid  order by dateordered DESC");
		$ownerH->bindParam(":Id",$shopid);
		$ownerH->bindParam(":bid",$batchID);  
	    $ownerH->execute(); 
		  
		return $ownerH;

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

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

////////////////FUNCTION RETRIEVING ORDER FROM SHOP OWNED BY THE ACCOUNT USER/////////
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 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  order by dateordered DESC");
		$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  order by dateordered DESC");
		$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 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 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 ?  order by dateordered DESC");
	    //$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 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 =?  order by dateordered DESC");
	   
	    $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,$id);
	try{
		$ownerH=$this->dbcon->prepare("select * from  order_info where customerid =? and itemid= ? or orderid=? or batchID =?  order by dateordered DESC");
	   
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}

	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////
/////////////////FUNCTION GET ORDER BY DATE RANGE/////////
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 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 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 GET ORDER BY DATE RANGE/////////
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 GET ORDER BY DATE RANGE/////////
/////////////////FUNCTION GET ORDER BY DATE RANGE/////////
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 GET ORDER BY DATE RANGE/////////
function getMyShopBatchOrderByThisId($shopid,$id,$batchID){
	$status="";
	$date="";
	$data= array($date,$status,$shopid,$id);
	try{
		$ownerH=$this->dbcon->prepare("select * from  batch_info where deliveredon=? and status=? and shopid =? and batchID=?");
	   
	    $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 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 FOR RETRIEVING SHOP ENDS////////

/////////////////FUNCTION GET ORDER BY DATE RANGE/////////
function getMyShopProgressiveOrderByItemId($shopid,$id){
	$status="In progress";
	$data= array($status,$shopid,$id,$id);
	try{
		$ownerH=$this->dbcon->prepare("select * from  order_info where processingstatus=? and shopid =? 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 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 FOR RETRIEVING SHOP ENDS/////////////////

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 FOR RETRIEVING SHOP ENDS////
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 FOR RETRIEVING SHOP ENDS////
	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS////
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 FOR RETRIEVING SHOP ENDS////
//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////

function getMyShopProgressiveOrderByDate($shopid,$sdate){
	$status="In progress";
	$data= array($status,$shopid,'%'.$sdate.'%');
	try{
		$ownerH=$this->dbcon->prepare("select * from  order_info where processingstatus=? and 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 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 getShopSoldItem($shopid,$ownID){
	try{
		$ownerH=$this->dbcon->prepare("select * from itemsSold where shopid=:Id and ownerid=:iD"); 
		//$ownerH->bindParam(":id",$itemid);
		$ownerH->bindParam(":Id",$shopid);
		$ownerH->bindParam(":iD",$ownID);   
	    $ownerH->execute(); 
		  
		return $ownerH;

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

}
 
/////////////////FUNCTION RETRIEVING SHOPS OUT VIEW BY THE ACCOUNT USER/////////
function getMyShopSaleByDate($shopid,$sdate){
	$data= array($shopid,'%'.$sdate.'%');
	try{
		$ownerH=$this->dbcon->prepare("select * from  itemsSold where shopid =? and dateSold like ?");  
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

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

function getMyShopEntryByDate($shopid,$sdate){
	$data= array($shopid,'%'.$sdate.'%');
	try{
		$ownerH=$this->dbcon->prepare("select * from  itemsEntry where shopid =? and dateBought like ?");  
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}
//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////
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 FOR RETRIEVING SHOP ENDS////
//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////
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 FOR RETRIEVING SHOP ENDS////////////////

	//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////
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 FOR RETRIEVING SHOP ENDS////////////////
//////////////////FUNCTION FOR RETRIEVING SHOP ENDS/////////////////
function getMyShopProgressiveOrderByRange($shopid,$sdate,$edate){
	$status="In progress";
	$data= array($status,$shopid,$sdate,$edate);
	try{
		$ownerH=$this->dbcon->prepare("select * from  order_info where processingstatus=? and shopid =? and dateordered between ? and ?");  
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

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

	//////////////////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 FOR RETRIEVING SHOP ENDS/////////////////
function getMyShopEntryByRange($shopid,$sdate,$edate){
	 
	$data= array($shopid,$sdate,$edate);
	try{
		$ownerH=$this->dbcon->prepare("select * from  itemsEntry where shopid =? and dateBought between ? and ?");  
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}

/////////////////FUNCTION RETRIEVING SHOP OWNED BY THE ACCOUNT USER/////////


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

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

}

/////////////////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 getAllItemSoldCheck(){
	try{
		$ownerH=$this->dbcon->prepare("select * from itemsSold order by dateSold desc ");
	   /////where itemid=:id// $ownerH->bindParam(":id",$itemid);
	    // $ownerH->bindParam(":Id",$shopid); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

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

	}
	catch(PDOException $xc){
		$xc->getMessage();
	}
}
////////////////////////// 
////////////////////////// 
function getOrderNameAllItemEntryCheck(){
	try{
		$ownerH=$this->dbcon->prepare("select * from itemsEntry order by itemName asc ");
	    $ownerH->execute(); 
		  
		return $ownerH;

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

	///////////
function getOrderNameAllItemCheck(){
	try{
		$ownerH=$this->dbcon->prepare("select * from item_info order by itemname asc ");
	   /////where itemid=:id// $ownerH->bindParam(":id",$itemid);
	    // $ownerH->bindParam(":Id",$shopid); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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

	/////////////////FUNCTION RETRIEVING SHOP SPECIFIC ITEM/////////
function getThisItem($itemid){
	try{
		$ownerH=$this->dbcon->prepare("select * from item_info where itemid=:id");
	    $ownerH->bindParam(":id",$itemid);
	    // $ownerH->bindParam(":Id",$shopid); 
	    $ownerH->execute(); 
		  
		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 getShopCategory(){
	try{
		$ownerH=$this->dbcon->prepare("select distinct category 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 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/////////
		 /*//$data =;
		//$data=array('%'.$searchValue.'%');
	    $hname->execute(array('%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%')); 
		  
		return $hname;*/
/////////////////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 SHOP OTHER VIEW BY THE ACCOUNT USER/////////

/////////////////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 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($itemname!=""){
			return 	$itemname;
			//preg_match("/^[\sA-Za-z0-9]+$/",$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;
		          }
	           }                           
                //////////////////////////////////

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


function evendor($vendor) {
	 if($vendor=="")
	               {

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



                               ////////////////////////////////
	                                    //  ROUTE DETAIL
function vitemtype($itemtype) {
	 
	
		if($itemtype!=""){
		    //preg_match("/^[\sA-Za-z0-9]+$/",$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) {
	 //preg_match("/^[\sA-Za-z0-9]+$/",$itemcategory)  &&
	
		if( $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,$itemcost,$itemcategory,$itemname,$itemtype,$currency){
//	$itemdescription,,$vendor
      
    // $site="../itemimages/".$fn;

	 $data=array($itemid,$itemname,$itemtype,$itemcategory,$itemcost,$currency );
       try{
	
	      $Qr=$this->dbcon->prepare("insert into item_info(itemid,itemname,itemtype,itemcategory,itemcost, 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("../pharmacyimages/".$fn))
	{
      
      return false;
		  
    }
	else
	 {
	  return true; 
	 }

     }  



function eImageExist($fn) 
 {
	 
	
if(file_exists("../itemimages/".$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="../itemimages/".$fn;
     $ext = strtolower($site);

  $info = getimagesize($tmp_name);

  if ($info['mime'] == 'image/jpeg')
  {
      
    $image = imagecreatefromjpeg($tmp_name);
  }
  elseif ($info['mime'] == 'image/gif') 
  {
    $image = imagecreatefromgif($tmp_name);
  }
  elseif ($info['mime'] == 'image/png')
  { 
    $image = imagecreatefrompng($tmp_name);
  }
 //imagejpeg($image, $site, 1);
	 
	 $data=array($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  ///////////////////
}
?>
