<?php
class buda_shoping_class{
	 public  $dbcon;
     public  $host="localhost";
     public  $dbname="aiderste_shoping_center";
     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);
          
}



 
/*function updateProfileImage($fn,$itemname, $itemid,$tmp_name){
	

 

    $site="../itemimages/".$fn;
	 
	 $data=array($itemid,$site,$itemname);
try{
	
	$Qr=$this->dbcon->prepare("insert into itemimages(itemid,directory,imagename) values(?,?,?)");
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {

     move_uploaded_file($tmp_name,$site);

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

}
catch(PDOException $ex){
	$ex->getMessage();
}
}
*/
  //////////////////////////
function updatePImage($fn,$itemname, $itemid,$tmp_name)
{
                try{
                        		$ownerH=$this->dbcon->prepare("select * from  item_info where itemid =:Id");
                        		$ownerH->bindParam(":Id",$itemid);  
                        	    $ownerH->execute(); 
                                		if($ownerH->rowCount()>0)
                                         {
                                          $ico=$ownerH->fetch();
                                        
                                           
                                           
                                              if(file_exists($ico['profileimages']))
                                    		       {
                                    		         unlink($ico['profileimages']);
                                    		       } 
                                    		    
                                		  
                                           //////////////
                                             $ow=$this->dbcon->prepare("select * from  itemimages where itemid =:Id");
                                	     	 $ow->bindParam(":Id",$itemid);  
                                	         $ow->execute();
                                	         
                                		     if($ow->rowCount()>0)
                                             {
                                              $N=$ow->fetchAll();
                                        
                                                  foreach ($N as $key => $ic) 
                                                  {
                                		   
                                		              if(file_exists($ic['directory']))
                                    		          {
                                    		            unlink($ic['directory']);
                                    		       
                                    		               if(!file_exists($ic['directory']))
                                    		                {
                                    		       
                                                    		    $d=$this->dbcon->prepare("delete from  itemimages where itemid =:Id");
                                                	  	        $d->bindParam(":Id",$itemid);  
                                                	            $d->execute(); 
                                	                            if($d->rowCount()>0)
                                	                             {
                                	                
                                	               //////////UPDATE ITEM /////////////
                                	                                 $site="../itemimages/".$fn;
                                	 
                                                	                 $data=array($site,$itemid);
                                                	                 $H=$this->dbcon->prepare("update item_info set profileimages=?  where itemid =?");
                                                	  	             $H->bindParam(":Id",$itemid);  
                                                	                 $H->execute($data);
                                                	                 
                                		                                    if($H->rowCount()>0)
                                	                                          {
                                	                     
                                                                        
                                                                                          $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);
                                                                                           }
                                	 /////////////////////
                                	 
                                	 
                                	 
                                                            	 
                                                            	                        $data=array($itemid,$site,$itemname);
                                                             
                                                            	                        $Qr=$this->dbcon->prepare("insert into itemimages(itemid,directory,imagename) values(?,?,?)");
                                                            	                        $Qr->execute($data);
                                	                                                   
                                	                                                    if($Qr->rowCount()>0)
                                	                                                     {
                                                                    	                              if($size>2500000)
                                                                    	                               {
                                                                                                       imagejpeg($image, $site, 9);
                                                                                                        }
                                                                                                      else if($size>1500000 && $size<2500000)
                                                                                                       {
                                                                                                           imagejpeg($image, $site, 20);  
                                                                                                       }
                                                                                                      else if($size<1500000)
                                                                                                      {
                                                                                                           imagejpeg($image, $site, 40);  
                                                                                                      }
                                                                                                           return $Re="The image is successfully uploaded!..";
                                	                                                      }
                                	                                                     else
                                	                                                        {
                                	 	                                                 return  $Re="Oops your network is low to upload data!..";
                                	                                                        } 
                                
                                                                                                                                            /// move_uploaded_file($tmp_name,$site);
                                                                                                                
                                                                                                                           
                                                                                                                                            ///return $Qr="The image is successfully uploaded!..";
                                                                                                                	                        ///}
                                                                                                                	                        ///else
                                                                                                                	                        ///{
                                                                                                                	                    	  ///return $Qr="Oops your network is low to upload data!..";;//= $Qr->ErrorInfo(); //
                                                                                                                	                        ///}
                                                                                                                	                    
                                                                                                                	                        /// return $d="Delete successfully!..";
                                                            	                }
                                                            	                else{
                                                            		       
                                                            		              return $d="Deleting item failed!";
                                                            		             }
                                                            		             
                                		             //////////UPDATE END ITEM /////////////
                                                		        }
                                                		        else{
                                                		       
                                                		        return $d="Deleting failed!";
                                                		        }
                                    		               }
                                		        
                                                     }
                                               //
                                                      else{
                                                               if(!file_exists($ic['profileimages']))
                                                    		   {
                                                    		       
                                                    		    $d=$this->dbcon->prepare("delete from  itemimages where itemid =:Id");
                                                	  	        $d->bindParam(":Id",$itemid);  
                                                	            $d->execute(); 
                                                	            if($d->rowCount()>0)
                                                	               {
                                                	                
                                                	                
                                                	                   
                                                	               //////////UPDATE ITEM /////////////
                                                	                 $site="../itemimages/".$fn;
                                                	 
                                                	                 $data=array($site,$itemid);
                                                	                 $H=$this->dbcon->prepare("update item_info set profileimages=?  where itemid =?");
                                                	  	             $H->bindParam(":Id",$itemid);  
                                                	                 $H->execute($data); 
                                                		                       
                                                		                         if($H->rowCount()>0)
                                                	                                {
                                	                     
                                                    	                        
                                                    	                                      $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);
                                                                                               }
                                                    	 
                                	                                                        
                                	                                                                   $data=array($itemid,$site,$itemname);
                                 
                                                                                	                        $Qr=$this->dbcon->prepare("insert into itemimages(itemid,directory,imagename) values(?,?,?)");
                                                                                	                        $Qr->execute($data);
                                                                                	                        if($Qr->rowCount()>0)
                                                                                	                        {
                                                                                
                                                                                                                 if($size>2500000)
                                                                                	                               {
                                                                                                                   imagejpeg($image, $site, 9);
                                                                                                                    }
                                                                                                                  else if($size>1500000 && $size<2500000)
                                                                                                                   {
                                                                                                                       imagejpeg($image, $site, 20);  
                                                                                                                   }
                                                                                                                  else if($size<1500000)
                                                                                                                  {
                                                                                                                       imagejpeg($image, $site, 40);  
                                                                                                                  }
                                                                                                                       return $Re="The image is successfully uploaded!..";
                                                                                	                              }
                                                                                	                             else
                                                                                	                              {
                                                                                	 	                               return  $Re="Oops your network is low to upload data!..";
                                                                                	                              } 
                                                               
                                
                                           
                                                                                                                ///return $Qr="The image is successfully uploaded!..";
                                                                	            }
                                                                	            else
                                                                	               {
                                                                	                return $Qr="Oops your network is low to upload data!..";;//= $Qr->ErrorInfo(); //
                                                                	              }
                                                                	                    
                                	                
                                	                
                                	               
                                		              
                                            		        }
                                            		             else{
                                            		       
                                            		       
                                            		                                                       	               //////////UPDATE ITEM /////////////
                                                	                 $site="../itemimages/".$fn;
                                                	 
                                                	                 $data=array($site,$itemid);
                                                	                 $H=$this->dbcon->prepare("update item_info set profileimages=?  where itemid =?");
                                                	  	             $H->bindParam(":Id",$itemid);  
                                                	                 $H->execute($data); 
                                                		                       
                                                		                         if($H->rowCount()>0)
                                                	                                {
                                	                     
                                                    	                        
                                                    	                                      $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);
                                                                                               }
                                                    	 
                                	                                                        
                                	                                                                   $data=array($itemid,$site,$itemname);
                                 
                                                                                	                        $Qr=$this->dbcon->prepare("insert into itemimages(itemid,directory,imagename) values(?,?,?)");
                                                                                	                        $Qr->execute($data);
                                                                                	                        if($Qr->rowCount()>0)
                                                                                	                        {
                                                                                
                                                                                                                 if($size>2500000)
                                                                                	                               {
                                                                                                                   imagejpeg($image, $site, 9);
                                                                                                                    }
                                                                                                                  else if($size>1500000 && $size<2500000)
                                                                                                                   {
                                                                                                                       imagejpeg($image, $site, 20);  
                                                                                                                   }
                                                                                                                  else if($size<1500000)
                                                                                                                  {
                                                                                                                       imagejpeg($image, $site, 40);  
                                                                                                                  }
                                                                                                                       return $Re="The image is successfully uploaded!..";
                                                                                	                              }
                                                                                	                             else
                                                                                	                              {
                                                                                	 	                               return  $Re="Oops your network is low to upload data!..";
                                                                                	                              } 
                                                               
                                
                                           
                                                                                                                //return $Qr="The image is successfully uploaded!..";
                                                                	            }
                                                                	            else
                                                                	               {
                                                                	                return $Qr="Oops your network is low to upload data!..";;//= $Qr->ErrorInfo(); //
                                                                	              }
                                                                	                    
                                            		        ///return $d="Deleting detail failed!";
                                            		        }
                                    		                    }
                                    		                    
                                    		                    
                                    		                    else{
                                    		                                                                        	               //////////UPDATE ITEM /////////////
                                                	                 $site="../itemimages/".$fn;
                                                	 
                                                	                 $data=array($site,$itemid);
                                                	                 $H=$this->dbcon->prepare("update item_info set profileimages=?  where itemid =?");
                                                	  	             $H->bindParam(":Id",$itemid);  
                                                	                 $H->execute($data); 
                                                		                       
                                                		                         if($H->rowCount()>0)
                                                	                                {
                                	                     
                                                    	                        
                                                    	                                      $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);
                                                                                               }
                                                    	 
                                	                                                        
                                	                                                                   $data=array($itemid,$site,$itemname);
                                 
                                                                                	                        $Qr=$this->dbcon->prepare("insert into itemimages(itemid,directory,imagename) values(?,?,?)");
                                                                                	                        $Qr->execute($data);
                                                                                	                        if($Qr->rowCount()>0)
                                                                                	                        {
                                                                                
                                                                                                                 if($size>2500000)
                                                                                	                               {
                                                                                                                   imagejpeg($image, $site, 9);
                                                                                                                    }
                                                                                                                  else if($size>1500000 && $size<2500000)
                                                                                                                   {
                                                                                                                       imagejpeg($image, $site, 20);  
                                                                                                                   }
                                                                                                                  else if($size<1500000)
                                                                                                                  {
                                                                                                                       imagejpeg($image, $site, 40);  
                                                                                                                  }
                                                                                                                       return $Re="The image is successfully uploaded!..";
                                                                                	                              }
                                                                                	                             else
                                                                                	                              {
                                                                                	 	                               return  $Re="Oops your network is low to upload data!..";
                                                                                	                              } 
                                                               
                                
                                           
                                                                                                               /// return $Qr="The image is successfully uploaded!..";
                                                                	            }
                                                                	            else
                                                                	               {
                                                                	                return $Qr="Oops your network is low to upload data!..";;//= $Qr->ErrorInfo(); //
                                                                	              }
                                                                	                    
                                    		                        }
                                    		                     
                                               }
                                               ///
                                                 
                                                  }
                                             }
                                            else{
                                                                                                	               //////////UPDATE ITEM /////////////
                                                	                 $site="../itemimages/".$fn;
                                                	 
                                                	                 $data=array($site,$itemid);
                                                	                 $H=$this->dbcon->prepare("update item_info set profileimages=?  where itemid =?");
                                                	  	             $H->bindParam(":Id",$itemid);  
                                                	                 $H->execute($data); 
                                                		                       
                                                		                         if($H->rowCount()>0)
                                                	                                {
                                	                     
                                                    	                        
                                                    	                                      $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);
                                                                                               }
                                                    	 
                                	                                                        
                                	                                                                   $data=array($itemid,$site,$itemname);
                                 
                                                                                	                        $Qr=$this->dbcon->prepare("insert into itemimages(itemid,directory,imagename) values(?,?,?)");
                                                                                	                        $Qr->execute($data);
                                                                                	                        if($Qr->rowCount()>0)
                                                                                	                        {
                                                                                
                                                                                                                 if($size>2500000)
                                                                                	                               {
                                                                                                                   imagejpeg($image, $site, 9);
                                                                                                                    }
                                                                                                                  else if($size>1500000 && $size<2500000)
                                                                                                                   {
                                                                                                                       imagejpeg($image, $site, 20);  
                                                                                                                   }
                                                                                                                  else if($size<1500000)
                                                                                                                  {
                                                                                                                       imagejpeg($image, $site, 40);  
                                                                                                                  }
                                                                                                                       return $Re="The image is successfully uploaded!..";
                                                                                	                              }
                                                                                	                             else
                                                                                	                              {
                                                                                	 	                               return  $Re="Oops your network is low to upload data!..";
                                                                                	                              } 
                                                               
                                
                                           
                                                                                                                ///return $Qr="The image is successfully uploaded!..";
                                                                	            }
                                                                	            else
                                                                	               {
                                                                	                return $Qr="Oops your network is low to upload data!..";;//= $Qr->ErrorInfo(); //
                                                                	              }
                                                                	                    
                                               }
                                            
                                            
                                         }
                                         else{
                                             return $RQ="Item not found!.";
                                         }
            	  }
            	
                catch(PDOException $xc)
                 {
            		$xc->getMessage();
            	 }

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


//////////////////////////////////////////////                               //////////////////////
///////////////////////////////////////////////////// IMAGE VALIDATION ENDS  ///////////////////

function deleteItemFromFolder($itemid){
	try{
		$ownerH=$this->dbcon->prepare("select * from  item_info where itemid =:Id");
		$ownerH->bindParam(":Id",$itemid);  
	    $ownerH->execute(); 
		if($ownerH->rowCount()>0)
         {
         // $hNo==
         $ico=$ownerH->fetch();
        
         // foreach ($hNo as $key => $ico)     {
         
		   if(file_exists($ico['profileimages']))
		   {
		       unlink($ico['profileimages']);
		     if(file_exists($ico['profileimages']))
		   {
	           return $d="Delete failed!..";
		   }
		   else{
		        return $d="Delete successfully!..";
		   }
		   }
		   
              
		    else{
		       
		         return $d="Files do not exists!";
		         } 
              //}
              }
                 
           
	}
     	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 deleteItemFromShop($itemid){
	try{
		$ownerH=$this->dbcon->prepare("select * from  item_info where itemid =:Id");
		$ownerH->bindParam(":Id",$itemid);  
	    $ownerH->execute(); 
		if($ownerH->rowCount()>0)
         {
          $ico=$ownerH->fetch();
        
           
           
           if(file_exists($ico['profileimages']))
    		   {
    		       unlink($ico['profileimages']);
    		   } 
    		    
		   // $H=$this->dbcon->prepare("delete from  item_info where itemid =:Id");
	  	   // $H->bindParam(":Id",$itemid);  
	       // $H->execute(); 
		    //if($H->rowCount()>0)
            //{
      
           //////////////
             $ow=$this->dbcon->prepare("select * from  itemimages where itemid =:Id");
	     	 $ow->bindParam(":Id",$itemid);  
	         $ow->execute(); 
		     if($ow->rowCount()>0)
             {
              $N=$ow->fetchAll();
        
              foreach ($N as $key => $ic) 
              {
		   
		     if(file_exists($ic['directory']))
    		   {
    		       unlink($ic['directory']);
    		       
    		  if(!file_exists($ic['directory']))
    		   {
    		       
    		    $d=$this->dbcon->prepare("delete from  itemimages where itemid =:Id");
	  	        $d->bindParam(":Id",$itemid);  
	            $d->execute(); 
	            if($d->rowCount()>0){
	                
	               //////////DELETE ITEM /////////////
	                 $H=$this->dbcon->prepare("delete from  item_info where itemid =:Id");
	  	             $H->bindParam(":Id",$itemid);  
	                 $H->execute(); 
		            if($H->rowCount()>0)
	                {
	                 return $d="Delete successfully!..";
	                }
	                else{
		       
		              return $d="Deleting item failed!";
		             }
		             
		             //////////DELETE ITEM /////////////
		        }
		        else{
		       
		        return $d="Deleting failed!";
		        }
    		    }
		        
               }
               //
               else{
               if(!file_exists($ico['profileimages']))
    		   {
    		       
    		    $d=$this->dbcon->prepare("delete from  itemimages where itemid =:Id");
	  	        $d->bindParam(":Id",$itemid);  
	            $d->execute(); 
	            if($d->rowCount()>0){
	                
	                 //////////DELETE ITEM /////////////
	                 $H=$this->dbcon->prepare("delete from  item_info where itemid =:Id");
	  	             $H->bindParam(":Id",$itemid);  
	                 $H->execute(); 
		            if($H->rowCount()>0)
	                {
	                 return $d="Delete successfully!..";
	                }
	                else{
		       
		              return $d="Deleting item failed!";
		             }
		             
		             //////////DELETE ITEM /////////////
	            //return $d="Image was already deleted successfully!..";
		        }
		        else{
		       
		        return $d="Deleting detail failed!";
		        }
    		    }
               }
               ///
                 
             }
            }
            
            //
                
           // }
         }
	}
	
     	catch(PDOException $xc){
		$xc->getMessage();
	}

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

function updateItemShopDetail($vendor,$itemdescription,$itemcategory,$itemname,$itemtype,$itemid){
	try{ 
			$data=array($vendor,$itemdescription,$itemcategory,$itemname,$itemtype,$itemid);
		    $ownerH=$this->dbcon->prepare("update item_info set vendor=?, description=?, itemcategory=?, itemname=?, itemtype=? where itemid=?"); 
	   
	    $ownerH->execute($data); 
		  
		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 ");
	    $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/////////
//////////////////////////////////////////////SUPER SHOP ORDER RETRIEVAL////////////////

function getItemBySearchDistCat($searchValue,$cat){
	try{
		$ownerH=$this->dbcon->prepare("select * from  item_info where  itemname  like ?  or itemtype  like ?   or description  like ? and itemcategory=?");
		//$ownerH->bindParam(":Id",$ownID); 
	    $ownerH->execute(array('%'.$searchValue.'%','%'.$searchValue.'%','%'.$searchValue.'%',$cat)); 
		  
		return $ownerH;

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

}


function getItemForCorrection(){
	try{
	    $pr="Printer cartridge";
		$ownerH=$this->dbcon->prepare("select * from item_info where itemcategory=:id ");
	    $ownerH->bindParam(":id",$pr); 
	    $ownerH->execute(); 
		  
		if($ownerH->rowCount()>0){
		 $Ft=$ownerH->fetchAll();
		 $shopid="20190521070234";
		  foreach ($Ft as $key => $p) {
		 $itemID=$p["itemid"];
 

		 ////
		  // $ps="Smart phone";
    		$owner=$this->dbcon->prepare("select * from itemstock where itemID=:id and shopid=:sd ");
    	    $owner->bindParam(":id",$itemID); 
    	    $owner->bindParam(":sd",$shopid);
    	    $owner->execute();
		 //
		 	if($owner->rowCount()>0){
		 	 $F=$owner->fetch();
    	  	 $shopid=$F['shopid'];
    	  	 if($shopid=="20190521070234"){
    	  	 $cid="20190524095229";
	  	  	 $data=array($cid,$itemID);
		     $owH=$this->dbcon->prepare("update itemstock set shopid=?  where itemID=?"); 
	   // and $shopid=
	         $owH->execute($data);
	  	 
	     	}
		 	}
		}
	}

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






/////////////////UPDATE PRICE//////////////////




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.2;   
    	  	 }
    	  	 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 GET ORDER BY DATE RANGE/////////



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 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 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 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 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");
		$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 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 =?");
	   
	    $ownerH->execute($data); 
		  
		return $ownerH;

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

}
/////////////////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");
		$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 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 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 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");
		$ownerH->bindParam(":Id",$shopid); 
		$ownerH->bindParam(":std",$status); 
	    $ownerH->execute(); 
		  
		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 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 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 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 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");
		$ownerH->bindParam(":Id",$shopid);
		$ownerH->bindParam(":bid",$batchID);  
	    $ownerH->execute(); 
		  
		return $ownerH;

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

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


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

/////////////////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 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 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 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 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 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////
///////////////////////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="../itemimages/".$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 getItemByCat($cat){
	try{
		$ownerH=$this->dbcon->prepare("select * from item_info where itemcategory=:id");
	    $ownerH->bindParam(":id",$cat); 
	    $ownerH->execute(); 
		  
		return $ownerH;

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


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

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




function createMyStock($stockID,$ownID,$itemid, $itemcost, $shopid, $currency,$bestsupply){
	
 

             $bpr= $itemcost;
    	  	 if($bpr<150000){
    	  	  
    	  	 $price=$bpr+$bpr*0.2;   
    	  	 }
    	  	 else{
    	  	     
    	  	 $price=$bpr+ 25000;
    	  	 }

	    //$data=array($stockID,$ownID,$itemid, $itemcost, $price,$shopid, $currency);
	    $data=array($stockID,$ownID,$itemid, $itemcost,$price,$shopid, $currency,$bestsupply);
       try{
	
	      ///$Qr=$this->dbcon->prepare("insert into itemstock(stockID,ownerid,itemID,buyprice,price,shopid,currency ) values(?,?,?,?,?,?,?)");
	     
	      $Qr=$this->dbcon->prepare("insert into itemstock(stockID,ownerid,itemID,buyprice,price,shopid,currency,bestsupply) 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 RETRIEVING SHOP AND ITEM OWNED 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 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 RETRIEVING SHOPS OUT VIEW BY THE ACCOUNT USER/////////

/////////////////FUNCTION RETRIEVING SHOP AND ITEM OWNED BY THE ACCOUNT USER/////////
function updateThisItemPrice($bestsupply,$itemcost,$currency,$itemid,$shopid,$ownID){
	try{
			//$data=array($itemcost,$currency,$itemid,$shopid,$ownID);
		   // $ownerH=$this->dbcon->prepare("update itemstock set price=?, //currency=? where itemID=? and shopid=? and ownerid=?"); 
		      $bpr= $itemcost;
    	  	 if($bpr<150000){
    	  	  
    	  	 $price=$bpr+$bpr*0.2;   
    	  	 }
    	  	 else{
    	  	     
    	  	 $price=$bpr+ 25000;
    	  	 }
		    ////
		    //$price=$itemcost+$itemcost*0.1;
			//$data=array($price,$itemcost,$currency,$itemid,$shopid,$ownID);
		   // $ownerH=$this->dbcon->prepare("update itemstock set price=?, buyprice=?, currency=? where itemID=? and shopid=? and ownerid=?"); 
		    
		    ////
	   	$data=array($bestsupply,$price,$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 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 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!..";
	 }
	 

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

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(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,$fn,$currency,$vendor){
	
      //$expiredate,
     $site="../itemimages/".$fn;

	 $data=array($itemid,$itemname,$itemtype,$itemcategory,$itemcost,$itemdescription, $site,$currency,$vendor);
       try{
	
	      $Qr=$this->dbcon->prepare("insert into item_info(itemid,itemname,itemtype,itemcategory,itemcost, description,profileimages,currency,vendor) 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,$currency){
	 
	 $data=array($itemname,$itemtype,$itemcategory,$itemcost,$itemdescription,$expiredate,$currency,$itemid);
       try{
	
	      $Qr=$this->dbcon->prepare("update item_info set itemname=?,itemtype=?,itemcategory=?,itemcost=?, description=?,expiredate=?, currency=? where 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<500000)
	{
      
      return $size;
		  
    }
	else
	 {
	  return false; 
	 }

     }  



function eImageSize($size) 
 {
	 
	if($size>=0 && $size<500000)
	{
      
      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("../itemimages/".$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){
	

 

    $site="../itemimages/".$fn;
	 
	 $data=array($itemid,$site,$itemname);
try{
	
	$Qr=$this->dbcon->prepare("insert into itemimages(itemid,directory,imagename) values(?,?,?)");
	$Qr->execute($data);
	 if($Qr->rowCount()>0)
	 {

     move_uploaded_file($tmp_name,$site);

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

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