<?php 
/****************************************************************/
/*          e-mo.pl © 2017                                      */
/*          http://www.e-mo.com.pl                              */
/*          e-mail: info@e-mo.pl                                */
/*          produkt: Action2osCommerce                          */
/*          wersja: 1.9.7                                       */
/*          webserwis: oscGold                                  */
/*          sciezka: https://www.e-mo.com.pl/plikit,1918,533545b244d7d.php*/
/*          data: 2017-09-25                                    */
/*          godz: 10:45:35                                      */
/****************************************************************/


class products_poziom { 
	public $Conn = 0;
	public $errMsg = '';
	public $errNo= 0;
	public $products_id=0;
	public $pcz_Netto1= 0;		
	public $pcz_Netto2= 0;
	public $pcz_Netto3=0;
	public $pcz_Netto4= 0;
	public $pcz_Netto5=0;
	public $pcz_Netto6= 0;
	public $pcz_Netto7=0;
	public $pcz_Netto8=0;
	public $pcz_Netto9=0;
	
	
	public static function Check($_Conn){
		$zwrot=false;
		$i=0;
		$query="SHOW COLUMNS FROM products like '%products_price_2%'";
		$sth = $_Conn->prepare($query);
		$sth->execute();
		
		while ($row = $sth->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT))
		{
			$i++;
		}

		$query="SHOW COLUMNS FROM products like '%products_price_3%'";
		$sth = $_Conn->prepare($query);
		$sth->execute();
			
		while ($row = $sth->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT))
		{
			$i++;
		}
		$query="SHOW COLUMNS FROM products like '%products_price_4%'";
		$sth = $_Conn->prepare($query);
		$sth->execute();
			
		while ($row = $sth->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT))
		{
			$i++;
		}
		$query="SHOW COLUMNS FROM products like '%products_price_5%'";
		$sth = $_Conn->prepare($query);
		$sth->execute();
			
		while ($row = $sth->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT))
		{
			$i++;
		}
		$query="SHOW COLUMNS FROM products like '%products_price_6%'";
		$sth = $_Conn->prepare($query);
		$sth->execute();
			
		while ($row = $sth->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT))
		{
			$i++;
		}
		$query="SHOW COLUMNS FROM products like '%products_price_7%'";
		$sth = $_Conn->prepare($query);
		$sth->execute();
			
		while ($row = $sth->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT))
		{
			$i++;
		}
		$query="SHOW COLUMNS FROM products like '%products_price_8%'";
		$sth = $_Conn->prepare($query);
		$sth->execute();
			
		while ($row = $sth->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT))
		{
			$i++;
		}
		$query="SHOW COLUMNS FROM products like '%products_price_9%'";
		$sth = $_Conn->prepare($query);
		$sth->execute();
			
		while ($row = $sth->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT))
		{
			$i++;
		}
		$query="SHOW COLUMNS FROM products like '%products_price_10%'";
		$sth = $_Conn->prepare($query);
		$sth->execute();
			
		while ($row = $sth->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_NEXT))
		{
			$i++;
		}
		
		if($i==9)
			$zwrot = true;
		
		return $zwrot;

	}
	public function Dodaj(){
		$zwrot=true;
		$query="Update products SET products_price_2=:cena2, products_price_3=:cena3, products_price_4=:cena4, products_price_5=:cena5, products_price_6=:cena6, products_price_7=:cena7, products_price_8=:cena8, products_price_9=:cena9, products_price_10=:cena10 Where products_id=:products_id";
		$sth = $this->Conn->prepare($query);

		
		$sth->bindParam(':cena2', $this->pcz_Netto1, PDO::PARAM_STR);
		$sth->bindParam(':cena3', $this->pcz_Netto2, PDO::PARAM_STR);
		$sth->bindParam(':cena4', $this->pcz_Netto3, PDO::PARAM_STR);
		$sth->bindParam(':cena5', $this->pcz_Netto4, PDO::PARAM_STR);
		$sth->bindParam(':cena6', $this->pcz_Netto5, PDO::PARAM_STR);
		$sth->bindParam(':cena7', $this->pcz_Netto6, PDO::PARAM_STR);
		$sth->bindParam(':cena8', $this->pcz_Netto7, PDO::PARAM_STR);
		$sth->bindParam(':cena9', $this->pcz_Netto8, PDO::PARAM_STR);
		$sth->bindParam(':cena10', $this->pcz_Netto9, PDO::PARAM_STR);
		$sth->bindParam(':products_id', $this->products_id, PDO::PARAM_INT);

		$sth->execute();
		
		if($sth->errorCode() != 0){
			$zwrot=false;
			$this->errMsg = $sth->errorInfo();
			$this->errNo = $sth->errorCode();
		}

		 return $zwrot;
	 } 
}
?>
