Browse Source

Some fixes

Johannes Zellner 5 years ago
parent
commit
e72d398bbd

+ 5 - 8
website/DataBase/Price.php

@@ -11,7 +11,7 @@ class Price
 
 	function exists($priceset_id, $product_id)
 	{
-		$query = "SELECT * FROM ".$this->db->price_table." WHERE priceset_id='".$priceset_id."' AND product_id='".$product_id."'";
+		$query = "SELECT * FROM ".$this->db->price_table." WHERE priceset_id=".$priceset_id." AND product_id='".$product_id."'";
 
 		if(count($this->db->fetchRows($this->db->query($query))) > 0)
 			return true;
@@ -19,12 +19,9 @@ class Price
 			return false;
 	}
 
-	function create($priceset_id, $product_id, $value)
+	function create($priceset_id, $product_id, $price)
 	{
-		$query = "INSERT INTO ".$this->db->price_table." VALUES('', '".$priceset_id."', '".$product_id."'";
-		for($i = 0; $i < count($value); $i++)
-			$query .= ", '".str_replace("'", "\'", $value[$i])."'";
-		$query .= ")";
+		$query = "INSERT INTO ".$this->db->price_table." VALUES(0, ".$priceset_id.", '".$product_id."', ".$price.")";
 
 		$this->db->query($query);
 	}
@@ -34,14 +31,14 @@ class Price
 		$query = "UPDATE ".$this->db->price_table." SET ";
 		$query .= "price='".$value[0]."' ";
 
-		$query .= "WHERE priceset_id='".$priceset_id."' AND product_id='".$product_id."'";
+		$query .= "WHERE priceset_id=".$priceset_id." AND product_id='".$product_id."'";
 
 		$this->db->query($query);
 	}
 
 	function delete($price_id)
 	{
-		$query = "DELETE FROM ".$this->db->price_table." WHERE price_id='$price_id'";
+		$query = "DELETE FROM ".$this->db->price_table." WHERE price_id=".$price_id."";
 
 		$this->db->query($query);
 	}

+ 11 - 11
website/DataBase/Priceset.php

@@ -9,13 +9,9 @@ class Priceset
 		$this->db = new Database();
 	}
 
-	function create($priceset_id, $value)
+	function create($name, $netto)
 	{
-		$query = "INSERT INTO ".$this->db->priceset_table." VALUES('".$priceset_id."'";
-		for($i = 0; $i < count($value); $i++)
-			$query .= ", '".str_replace("'", "\'", $value[$i])."'";
-		$query .= ")";
-
+		$query = "INSERT INTO ".$this->db->priceset_table." (name, netto) VALUES ('".str_replace("'", "\'", $name)."', ".$netto.")";
 		$this->db->query($query);
 	}
 
@@ -23,23 +19,27 @@ class Priceset
 	{
 		$query = "UPDATE ".$this->db->priceset_table." SET ";
 		$query .= "name='".$value[0]."', ";
-		$query .= "netto='".$value[1]."' ";
 
-		$query .= "WHERE priceset_id='".$priceset_id."'";
+		if (!$value[1])
+			$query .= "netto=0 ";
+		else
+			$query .= "netto=1 ";
+
+		$query .= "WHERE priceset_id=".$priceset_id."";
 
 		$this->db->query($query);
 	}
 
 	function delete($priceset_id)
 	{
-		$query = "DELETE FROM ".$this->db->priceset_table." WHERE priceset_id='$priceset_id'";
+		$query = "DELETE FROM ".$this->db->priceset_table." WHERE priceset_id=".$priceset_id."";
 
 		$this->db->query($query);
 	}
 
 	function exists($priceset_id)
 	{
-		$query = "SELECT priceset_id FROM ".$this->db->priceset_table." WHERE priceset_id='".$priceset_id."'";
+		$query = "SELECT priceset_id FROM ".$this->db->priceset_table." WHERE priceset_id=".$priceset_id."";
 
 		$result = $this->db->fetchRows($this->db->query($query));
 
@@ -82,7 +82,7 @@ class Priceset
 				$query .= " FROM ".$this->db->priceset_table;
 			}
 
-			$query .= " WHERE priceset_id='".$priceset_id."'";
+			$query .= " WHERE priceset_id=".$priceset_id."";
 			$query .= " ORDER BY priceset_id ASC";
 
 			return $this->db->fetchRows($this->db->query($query));

+ 7 - 11
website/DataBase/Tax.php

@@ -9,30 +9,26 @@ class Tax
 		$this->db = new Database();
 	}
 
-	function create($tax_id, $value)
+	function create($name, $rate)
 	{
-		$query = "INSERT INTO ".$this->db->tax_table." VALUES('".$tax_id."'";
-		for($i = 0; $i < count($value); $i++)
-			$query .= ", '".$value[$i]."'";
-		$query .= ")";
-
+		$query = "INSERT INTO ".$this->db->tax_table." (name, tax_rate) VALUES ('".str_replace("'", "\'", $name)."', ".$rate.")";
 		$this->db->query($query);
 	}
 
 	function update($tax_id, $value)
 	{
 		$query = "UPDATE ".$this->db->tax_table." SET ";
-		$query .= "name='".$value[0]."', ";
-		$query .= "tax_rate='".$value[1]."' ";
+		$query .= "name='".str_replace("'", "\'", $value[0])."', ";
+		$query .= "tax_rate=".$value[1]." ";
 
-		$query .= "WHERE tax_id='".$tax_id."'";
+		$query .= "WHERE tax_id=".$tax_id."";
 
 		$this->db->query($query);
 	}
 
 	function delete($tax_id)
 	{
-		$query = "DELETE FROM ".$this->db->tax_table." WHERE tax_id='$tax_id'";
+		$query = "DELETE FROM ".$this->db->tax_table." WHERE tax_id=".$tax_id."";
 
 		$this->db->query($query);
 	}
@@ -60,7 +56,7 @@ class Tax
 		}
 		else
 		{
-			$query = "SELECT * FROM ".$this->db->tax_table." WHERE tax_id='".$tax_id."'";
+			$query = "SELECT * FROM ".$this->db->tax_table." WHERE tax_id=".$tax_id."";
 			$query .= " ORDER BY tax_id ASC";
 
 			return $this->db->fetchRows($this->db->query($query));

+ 6 - 6
website/app/Modules/Configuration/priceset.php

@@ -3,16 +3,16 @@
 require_once("util.php");
 
 	$priceset = new Priceset();
-	
+
 	if($action == "new")
-		$priceset->create(var_post("priceset_id", ""), array(var_post("priceset_name", ""), var_post("priceset_netto", "")));
+		$priceset->create(var_post("priceset_name", ""), var_post("priceset_netto", ""));
 	elseif($action == "edit")
 		$priceset->update(var_post("priceset_id", ""), array(var_post("priceset_name", ""), var_post("priceset_netto", "")));
 	elseif($action == "delete")
 		$priceset->delete(var_get("priceset_id", ""));
 
 	$priceset_box = new NTKVBox("priceset_box", 0, 1, False);
-	
+
 	$label = new NTKLabel("priceset_label", "<h3>Preiss&auml;tze</h3>");
 	$priceset_box->add($label);
 
@@ -21,12 +21,12 @@ require_once("util.php");
 	{
 		$priceset_box->add(new NTKEPriceset($priceset_list[$i][0], $priceset_list[$i][1], $priceset_list[$i][2]));
 	}
-	
+
 	$label = new NTKLabel("priceset_label", "<h4>neuer Preissatz</h4>");
 	$priceset_box->add($label);
-	
+
 	$priceset_box->add(new NTKEPriceset("", "", 1, True), -1);
-	
+
 	$main_box->add($priceset_box, -1, -1, "background-color: #dfe7f3; vertical-align: top;");
 
 ?>

+ 7 - 7
website/app/Modules/Configuration/tax.php

@@ -3,16 +3,16 @@
 require_once("util.php");
 
 	$tax = new Tax();
-	
+
 	if($action == "new")
-		$tax->create(var_post("tax_id", ""), array(var_post("tax_name", ""), var_post("tax_rate", "")));
+		$tax->create(var_post("tax_name", ""), var_post("tax_rate", ""));
 	elseif($action == "edit")
 		$tax->update(var_post("tax_id", ""), array(var_post("tax_name", ""), var_post("tax_rate", "")));
 	elseif($action == "delete")
 		$tax->delete(var_get("tax_id", ""));
 
 	$tax_box = new NTKVBox("tax_box", 0, 0, False);
-	
+
 	$label = new NTKLabel("tax_label", "<h3>Steuers&auml;tze</h3>");
 	$tax_box->add($label);
 
@@ -21,12 +21,12 @@ require_once("util.php");
 	{
 		$tax_box->add(new NTKETax($taxlist[$i][0], $taxlist[$i][1], $taxlist[$i][2]));
 	}
-	
+
 	$label = new NTKLabel("tax_label", "<h4>neuer Steuersatz</h4>");
 	$tax_box->add($label);
-	
+
 	$tax_box->add(new NTKETax("", "", "", True), -1);
-	
+
 	$main_box->add($tax_box, -1, -1, "background-color: #dfe7f3; vertical-align: top;");
-	
+
 ?>

+ 2 - 2
website/app/Modules/Product/db_action.php

@@ -33,7 +33,7 @@ switch($db_action)
 									var_post("anmerkung", "")));
 		$priceset_list = $priceset->get();
 		for($i = 0; $i < count($priceset_list); $i++)
-			$price->create(var_post("priceset_id_".$i, ""), var_post("product_id", ""), array(var_post("priceset_price_".$i, "")));
+			$price->create(var_post("priceset_id_".$i, ""), var_post("product_id", ""), var_post("priceset_price_".$i, ""));
 		break;
 	case "edit":
 		$product->update(var_post("product_id", ""), array(	var_post("name", ""),
@@ -50,7 +50,7 @@ switch($db_action)
 			if($price->exists(var_post("priceset_id_".$i, ""), var_post("product_id", "")))
 				$price->update(var_post("priceset_id_".$i, ""), var_post("product_id", ""), array(var_post("priceset_price_".$i, "")));
 			else
-				$price->create(var_post("priceset_id_".$i, ""), var_post("product_id", ""), array(var_post("priceset_price_".$i, "")));
+				$price->create(var_post("priceset_id_".$i, ""), var_post("product_id", ""), var_post("priceset_price_".$i, ""));
 		}
 		break;
 	case "delete":