Jelajahi Sumber

Fix customer creation roughly

Johannes Zellner 5 tahun lalu
induk
melakukan
abd141ad1b

+ 33 - 26
website/DataBase/Customer.php

@@ -9,12 +9,19 @@ class Customer
 		$this->db = new Database();
 		$this->db = new Database();
 	}
 	}
 
 
-	function create($customer_id, $value)
+	function create($customer_id, $password, $prename, $postname, $street, $streetnumber, $plz, $city, $telephone, $telefax, $email, $pricelist_id, $tour_id, $rabatt, $details, $bank_name, $bank_account, $blz)
 	{
 	{
-		$query = "INSERT INTO ".$this->db->customer_table." VALUES('".$customer_id."'";
-		for($i = 0; $i < count($value); $i++)
-			$query .= ", '".str_replace("'", "\'", $value[$i])."'";
-		$query .= ")";
+		$customer_id = $customer_id ? $customer_id : 0;
+		$plz = $plz ? $plz : 0;
+		$pricelist_id = $pricelist_id ? $pricelist_id : 0;
+		$tour_id = $tour_id ? $tour_id : 0;
+		$rabatt = $rabatt ? $rabatt : 0;
+		$blz = $blz ? $blz : 0;
+
+		$query = "INSERT INTO ".$this->db->customer_table." ";
+		$query .= " (customer_id, password, prename, postname, street, streetnumber, plz, city, telephone, telefax, email, pricelist_id, tour_id, rabatt, details, bank_name, bank_account, blz) ";
+		$query .= " VALUES ";
+		$query .= " (".$customer_id.", '".str_replace("'", "\'", $password)."', '".str_replace("'", "\'", $prename)."',  '".str_replace("'", "\'", $postname)."',  '".str_replace("'", "\'", $street)."',  '".str_replace("'", "\'", $streetnumber)."',  ".$plz.",  '".str_replace("'", "\'", $city)."',  '".str_replace("'", "\'", $telephone)."',  '".str_replace("'", "\'", $telefax)."',  '".str_replace("'", "\'", $email)."',  ".$pricelist_id.",  ".$tour_id.",  ".$rabatt.",  '".str_replace("'", "\'", $details)."',  '".str_replace("'", "\'", $bank_name)."',  '".str_replace("'", "\'", $bank_account)."',  ".$blz.") ";
 
 
 		$this->db->query($query);
 		$this->db->query($query);
 	}
 	}
@@ -24,37 +31,37 @@ class Customer
 		$query = "UPDATE ".$this->db->customer_table." SET ";
 		$query = "UPDATE ".$this->db->customer_table." SET ";
 		$query .= "password='".str_replace("'", "\'", $value[0])."', ";
 		$query .= "password='".str_replace("'", "\'", $value[0])."', ";
 		$query .= "prename='".str_replace("'", "\'", $value[1])."', ";
 		$query .= "prename='".str_replace("'", "\'", $value[1])."', ";
-		$query .= "postname='".$value[2]."', ";
-		$query .= "street='".$value[3]."', ";
-		$query .= "streetnumber='".$value[4]."', ";
-		$query .= "plz='".$value[5]."', ";
-		$query .= "city='".$value[6]."', ";
-		$query .= "telephone='".$value[7]."', ";
-		$query .= "telefax='".$value[8]."', ";
-		$query .= "email='".$value[9]."', ";
-		$query .= "pricelist_id='".$value[10]."', ";
-		$query .= "tour_id='".$value[11]."', ";
-		$query .= "rabatt='".$value[12]."', ";
-		$query .= "details='".$value[13]."', ";
-		$query .= "bank_name='".$value[14]."', ";
-		$query .= "bank_account='".$value[15]."', ";
-		$query .= "blz='".$value[16]."' ";
-
-		$query .= "WHERE customer_id='".$customer_id."'";
+		$query .= "postname='".str_replace("'", "\'", $value[2])."', ";
+		$query .= "street='".str_replace("'", "\'", $value[3])."', ";
+		$query .= "streetnumber='".str_replace("'", "\'", $value[4])."', ";
+		$query .= "plz=".$value[5].", ";
+		$query .= "city='".str_replace("'", "\'", $value[6])."', ";
+		$query .= "telephone='".str_replace("'", "\'", $value[7])."', ";
+		$query .= "telefax='".str_replace("'", "\'", $value[8])."', ";
+		$query .= "email='".str_replace("'", "\'", $value[9])."', ";
+		$query .= "pricelist_id=".$value[10].", ";
+		$query .= "tour_id=".$value[11].", ";
+		$query .= "rabatt=".$value[12].", ";
+		$query .= "details='".str_replace("'", "\'", $value[13])."', ";
+		$query .= "bank_name='".str_replace("'", "\'", $value[14])."', ";
+		$query .= "bank_account='".str_replace("'", "\'", $value[15])."', ";
+		$query .= "blz=".$value[16]." ";
+
+		$query .= "WHERE customer_id=".$customer_id."";
 
 
 		$this->db->query($query);
 		$this->db->query($query);
 	}
 	}
 
 
 	function delete($customer_id)
 	function delete($customer_id)
 	{
 	{
-		$query = "DELETE FROM ".$this->db->customer_table." WHERE customer_id='$customer_id'";
+		$query = "DELETE FROM ".$this->db->customer_table." WHERE customer_id=".$customer_id."";
 
 
 		$this->db->query($query);
 		$this->db->query($query);
 	}
 	}
 
 
 	function exists($customer_id)
 	function exists($customer_id)
 	{
 	{
-		$query = "SELECT customer_id FROM ".$this->db->customer_table." WHERE customer_id='".$customer_id."'";
+		$query = "SELECT customer_id FROM ".$this->db->customer_table." WHERE customer_id=".$customer_id."";
 
 
 		$result = $this->db->fetchRows($this->db->query($query));
 		$result = $this->db->fetchRows($this->db->query($query));
 
 
@@ -97,7 +104,7 @@ class Customer
 				$query .= " FROM ".$this->db->customer_table;
 				$query .= " FROM ".$this->db->customer_table;
 			}
 			}
 
 
-			$query .= " WHERE customer_id='".$customer_id."'";
+			$query .= " WHERE customer_id=".$customer_id."";
 			$query .= " ORDER BY customer_id ASC";
 			$query .= " ORDER BY customer_id ASC";
 
 
 			return $this->db->fetchRows($this->db->query($query));
 			return $this->db->fetchRows($this->db->query($query));
@@ -110,7 +117,7 @@ class Customer
 			return false;
 			return false;
 
 
 		/* TODO: use hash (sha512) for password */
 		/* TODO: use hash (sha512) for password */
-		$query = "SELECT * FROM ".$this->db->customer_table." WHERE customer_id='".$customer_id."'";
+		$query = "SELECT * FROM ".$this->db->customer_table." WHERE customer_id=".$customer_id."";
 		$result = $this->db->fetchRows($this->db->query($query));
 		$result = $this->db->fetchRows($this->db->query($query));
 		if(count($result) == 0)
 		if(count($result) == 0)
 			return false;
 			return false;

+ 3 - 6
website/DataBase/Product.php

@@ -146,16 +146,13 @@ class Product
 	}
 	}
 
 
 
 
-	function getByFilter($search_product, $search_category, $item_offset, $item_count, $available)
+	function getAvailableByFilter($search_product, $search_category, $item_offset, $item_count)
 	{
 	{
-		$query = "SELECT * FROM ".$this->db->product_table." ";
+		$query = "SELECT * FROM ".$this->db->product_table." WHERE available=1 ";
 
 
 		if($search_product != "" || $search_category != "")
 		if($search_product != "" || $search_category != "")
 		{
 		{
-			$query .= " WHERE ";
-
-			if ($available) $query .= " available=1 AND ";
-			else $query .= " available=0 AND ";
+			$query .= " AND ";
 
 
 			if($search_product != "")
 			if($search_product != "")
 				$query .= " (product_id LIKE '%".$search_product."%' OR name LIKE '%".$search_product."%' OR details LIKE '%".$search_product."%') ";
 				$query .= " (product_id LIKE '%".$search_product."%' OR name LIKE '%".$search_product."%' OR details LIKE '%".$search_product."%') ";

+ 19 - 17
website/app/Modules/Customer/db_action.php

@@ -15,23 +15,25 @@ $priceset = new Priceset();
 switch($db_action)
 switch($db_action)
 {
 {
 	case "new":
 	case "new":
-		$customer->create(var_post("customer_number", ""), array(	var_post("password", ""),
-										var_post("prename", ""),
-										var_post("postname", ""),
-										var_post("street", ""),
-										var_post("streetnumber", ""),
-										var_post("plz", ""),
-										var_post("city", ""),
-										var_post("telephone", ""),
-										var_post("telefax", ""),
-										var_post("email", ""),
-										var_post("pricelist_id", ""),
-										var_post("tour_id", ""),
-										var_post("rabatt", ""),
-										var_post("details", ""),
-										var_post("bank_name", ""),
-										var_post("bank_account", ""),
-										var_post("blz", "")));
+		$customer->create(var_post("customer_number", ""),
+						  var_post("password", ""),
+						  var_post("prename", ""),
+						  var_post("postname", ""),
+						  var_post("street", ""),
+						  var_post("streetnumber", ""),
+						  var_post("plz", ""),
+						  var_post("city", ""),
+						  var_post("telephone", ""),
+						  var_post("telefax", ""),
+						  var_post("email", ""),
+						  var_post("pricelist_id", ""),
+						  var_post("tour_id", ""),
+						  var_post("rabatt", ""),
+						  var_post("details", ""),
+						  var_post("bank_name", ""),
+						  var_post("bank_account", ""),
+						  var_post("blz", "")
+						);
 		break;
 		break;
 	case "edit":
 	case "edit":
 		$customer->update(var_post("customer_number", ""),array(	var_post("password", ""),
 		$customer->update(var_post("customer_number", ""),array(	var_post("password", ""),

+ 6 - 6
website/app/NTK/NTKImageButton.php

@@ -10,17 +10,17 @@ class NTKImageButton
 		$this->action = $action;
 		$this->action = $action;
 		$this->tooltip = $tooltip;
 		$this->tooltip = $tooltip;
 	}
 	}
-	
+
 	function setTooltip($tooltip)
 	function setTooltip($tooltip)
 	{
 	{
 		$this->tooltip = $tooltip;
 		$this->tooltip = $tooltip;
 	}
 	}
-	
+
 	function getHtml()
 	function getHtml()
 	{
 	{
 		$actions = "";
 		$actions = "";
 		$html = "";
 		$html = "";
-		
+
 		$actions .= " onclick=\"$this->action\"";
 		$actions .= " onclick=\"$this->action\"";
 		$actions .= " onmousedown=\"this.className = 'imagebutton_down'\"";
 		$actions .= " onmousedown=\"this.className = 'imagebutton_down'\"";
 		$actions .= " onmouseup=\"this.className = 'imagebutton'\"";
 		$actions .= " onmouseup=\"this.className = 'imagebutton'\"";
@@ -35,9 +35,9 @@ class NTKImageButton
 			$actions .= " onmouseout=\"this.className = 'imagebutton';\"";
 			$actions .= " onmouseout=\"this.className = 'imagebutton';\"";
 			$actions .= " onmousemove=\"\"";
 			$actions .= " onmousemove=\"\"";
 		}
 		}
-		
-		$html .= "<div id=\"$this->id\" class=\"imagebutton\" $actions><img src=\"$this->icon\" border=\"0\"></div>\n";
-		
+
+		$html .= "<div id=\"$this->id\" class=\"imagebutton\" style=\"background-image: url('$this->icon');\" $actions></div>\n";
+
 		return $html;
 		return $html;
 	}
 	}
 }
 }

+ 15 - 3
website/app/NTK/Style/NTKImageButton.css

@@ -8,8 +8,12 @@
 	border-right-color:	#7b757b;
 	border-right-color:	#7b757b;
 	border-width:			1px;
 	border-width:			1px;
 	border-style:			solid;
 	border-style:			solid;
-	padding:					2px;
 	text-align: center;
 	text-align: center;
+	background-position: center;
+	background-repeat: no-repeat;
+	background-size: contain;
+	width: 100%;
+	height: 100%;
 }
 }
 
 
 .imagebutton_over
 .imagebutton_over
@@ -22,8 +26,12 @@
 	border-right-color:	#7b757b;
 	border-right-color:	#7b757b;
 	border-width:			1px;
 	border-width:			1px;
 	border-style:			solid;
 	border-style:			solid;
-	padding:					2px;
 	text-align: center;
 	text-align: center;
+	background-position: center;
+	background-repeat: no-repeat;
+	background-size: contain;
+	width: 100%;
+	height: 100%;
 }
 }
 
 
 .imagebutton_down
 .imagebutton_down
@@ -36,6 +44,10 @@
 	border-right-color:	#ffffff;
 	border-right-color:	#ffffff;
 	border-width:			1px;
 	border-width:			1px;
 	border-style:			solid;
 	border-style:			solid;
-	padding:					2px;
 	text-align: center;
 	text-align: center;
+	background-position: center;
+	background-repeat: no-repeat;
+	background-size: contain;
+	width: 100%;
+	height: 100%;
 }
 }

+ 3 - 0
website/app/stat_toolbar.php

@@ -26,6 +26,9 @@ $toolbar_box->add($bill_button, 60, 60, $style);
 $customer_list_button = new NTKImageButton("button_customer_list", "Icons/customer.png", "Kundenliste", "parent.frames['main'].location.replace('stat_customer_list.php');", "Kundenliste");
 $customer_list_button = new NTKImageButton("button_customer_list", "Icons/customer.png", "Kundenliste", "parent.frames['main'].location.replace('stat_customer_list.php');", "Kundenliste");
 $toolbar_box->add($customer_list_button, 60, 60, $style);
 $toolbar_box->add($customer_list_button, 60, 60, $style);
 
 
+$bill_button = new NTKImageButton("button_bill_merge", "Icons/kspread.png", "Steuerzusammenfassung", "parent.frames['main'].location.replace('stat_monthly_vat.php');", "Steuerzusammenfassung");
+$toolbar_box->add($bill_button, 60, 60, $style);
+
 $toolbar_box->add($spacer);
 $toolbar_box->add($spacer);
 
 
 $print_button = new NTKImageButton("print_button", "Icons/print.png", "Drucken", "parent.frames['main'].print();", "Druckerdialog");
 $print_button = new NTKImageButton("print_button", "Icons/print.png", "Drucken", "parent.frames['main'].print();", "Druckerdialog");

+ 1 - 1
website/product_list.php

@@ -62,7 +62,7 @@ if($search_category != "")
 	</tr>
 	</tr>
 <?php
 <?php
 
 
-$list = $product->getByFilter($search_product, $search_category, $item_offset, $item_count, True /* available */);
+$list = $product->getAvailableByFilter($search_product, $search_category, $item_offset, $item_count);
 $count = $product->getCountByFilter($search_product, $search_category);
 $count = $product->getCountByFilter($search_product, $search_category);
 
 
 for($i = 0; $i < count($list); $i++)
 for($i = 0; $i < count($list); $i++)