Преглед изворни кода

Only add products to shopping cart if available

Johannes Zellner пре 5 година
родитељ
комит
572b28ecda

+ 6 - 2
website/Class/ShoppingCart.php

@@ -154,8 +154,12 @@ class ShoppingCart
 	function loadTemplate()
 	{
 		$list = $this->customer_template->get($this->customer_id);
-		for($i = 0; $i < count($list); $i++)
-			$this->addProduct($list[$i][1], $list[$i][2], $list[$i][3]);
+		for($i = 0; $i < count($list); $i++) {
+			// check if still exists and available
+			$result = $this->product->get($list[$i][1]);
+			$product = $result[0];
+			if ($product && $product[5]) $this->addProduct($list[$i][1], $list[$i][2], $list[$i][3]);
+		}
 		$this->saveShoppingCartSession();
 
 	}

+ 10 - 10
website/app/NTK_Extensions/NTKEBillPosition.php

@@ -13,20 +13,20 @@ class NTKEBillPosition
 		$this->product_name = $product_name;
 		$this->new = $new;
 	}
-	
+
 	function getHtml()
 	{
 		$html .= "<div width=\"100%\" height=\"100%\">\n";
-		
+
 		$html .= "<form name=\"bill_product_form_".$this->bill_product_id."\" action=\"bill.php\" method=\"POST\">\n";
 		$html .= "<input type=\"hidden\" name=\"bill_product_id\" value=\"".$this->bill_product_id."\">\n";
 		$html .= "<input type=\"hidden\" name=\"bill_id\" value=\"".$this->bill_id."\">\n";
 		$html .= "<input type=\"hidden\" name=\"product_id\" value=\"".$this->product_id."\">\n";
 		$html .= "<input type=\"hidden\" name=\"action\" value=\"edit\">\n";
-		
+
 		$html .= "<table width=\"100%\" height=\"100%\" border=0>\n";
 		$html .= "<tr>\n";
-		
+
 		$html .= "<td align=right width=1>\n";
 		$label = new NTKLabel("product_label", "Produktnummer");
 		$html .= $label->getHtml();
@@ -63,7 +63,7 @@ class NTKEBillPosition
 		$entry = new NTKEntry("rabatt", $this->rabatt, "width: 50px;");
 		$html .= $entry->getHtml();
 		$html .= "</td>\n";
-		
+
 		if($this->new)
 		{
 			$html .= "<td colspan=\"2\">\n";
@@ -81,17 +81,17 @@ class NTKEBillPosition
 			$html .= "<td>\n";
 			$button = new NTKButton("button_delete", "l&ouml;schen", "location.href = 'bill.php?action=edit&bill_id=".$this->bill_id."&db_action=position_delete&bill_product_id=".$this->bill_product_id."';");
 			$html .= $button->getHtml();
-			$html .= "</td>\n";	
+			$html .= "</td>\n";
 			$html .= "<input type=\"hidden\" name=\"db_action\" value=\"position_edit\">\n";
 		}
-		
+
 		$html .= "</tr>\n";
 		$html .= "</table>\n";
-		
+
 		$html .= "</form>\n";
-		
+
 		$html .= "</div>\n";
-		
+
 		return $html;
 	}
 }

+ 11 - 11
website/app/NTK_Extensions/NTKEGroup.php

@@ -8,15 +8,15 @@ class NTKEGroup
 		$this->name = $name;
 		$this->new = $new;
 	}
-	
+
 	function getHtml()
 	{
 		$html = "";
 		$html .= "<div width=\"100%\" height=\"100%\">\n";
-		
+
 		$html .= "<form name=\"group_form_".$this->group_id."\" action=\"configuration.php\" method=\"POST\">\n";
 		$html .= "<input type=\"hidden\" name=\"page\" value=\"group\">\n";
-		
+
 		$html .= "<table width=\"100%\" height=\"100%\">\n";
 		$html .= "<tr>\n";
 		$html .= "<td>\n";
@@ -35,11 +35,11 @@ class NTKEGroup
 		$entry = new NTKEntry("group_name", $this->name);
 		$html .= $entry->getHtml();
 		$html .= "</td>\n";
-		
+
 		if($this->new)
 		{
 			$html .= "<td colspan=\"2\">\n";
-			$button = new NTKButton("button_delete", "hinzuf&uuml;gen", "document.forms['group_form_".$this->group_id."'].submit();");
+			$button = new NTKButton("button_new", "hinzuf&uuml;gen", "document.forms['group_form_".$this->group_id."'].submit();");
 			$html .= $button->getHtml();
 			$html .= "</td>\n";
 			$html .= "<input type=\"hidden\" name=\"action\" value=\"new\">\n";
@@ -52,18 +52,18 @@ class NTKEGroup
 			$html .= "</td>\n";
 			$html .= "<input type=\"hidden\" name=\"action\" value=\"edit\">\n";
 			$html .= "<td>\n";
-			$button = new NTKButton("button_delete", "l&ouml;schen", "location.href = 'configuration.php?page=group&action=delete&group_id=".$this->group_id."';");
+			$button = new NTKButton("button_delete", "l&ouml;schen", "if(confirm('Wirklich loeschen?')) location.href = 'configuration.php?page=group&action=delete&group_id=".$this->group_id."';");
 			$html .= $button->getHtml();
-			$html .= "</td>\n";	
+			$html .= "</td>\n";
 		}
-		
+
 		$html .= "</tr>\n";
 		$html .= "</table>\n";
-		
+
 		$html .= "</form>\n";
-		
+
 		$html .= "</div>\n";
-		
+
 		return $html;
 	}
 }

+ 11 - 11
website/app/NTK_Extensions/NTKEPriceset.php

@@ -9,16 +9,16 @@ class NTKEPriceset
 		$this->netto = $netto;
 		$this->new = $new;
 	}
-	
+
 	function getHtml()
 	{
 		$html = "";
 		$html .= "<div width=\"100%\" height=\"100%\">\n";
-		
+
 		$html .= "<form name=\"priceset_form_".$this->priceset_id."\" action=\"configuration.php\" method=\"POST\">\n";
 		$html .= "<input type=\"hidden\" name=\"page\" value=\"priceset\">\n";
 		$html .= "<input type=\"hidden\" name=\"priceset_id\" value=\"".$this->priceset_id."\">\n";
-		
+
 		$html .= "<table width=\"100%\" height=\"100%\">\n";
 		$html .= "<tr>\n";
 		$html .= "<td>\n";
@@ -37,11 +37,11 @@ class NTKEPriceset
 		$entry = new NTKCheckbox("priceset_netto", 1, $this->netto);
 		$html .= $entry->getHtml();
 		$html .= "</td>\n";
-		
+
 		if($this->new)
 		{
 			$html .= "<td colspan=\"2\">\n";
-			$button = new NTKButton("button_delete", "hinzuf&uuml;gen", "document.forms['priceset_form_".$this->priceset_id."'].submit();");
+			$button = new NTKButton("button_new", "hinzuf&uuml;gen", "document.forms['priceset_form_".$this->priceset_id."'].submit();");
 			$html .= $button->getHtml();
 			$html .= "</td>\n";
 			$html .= "<input type=\"hidden\" name=\"action\" value=\"new\">\n";
@@ -54,18 +54,18 @@ class NTKEPriceset
 			$html .= "</td>\n";
 			$html .= "<input type=\"hidden\" name=\"action\" value=\"edit\">\n";
 			$html .= "<td>\n";
-			$button = new NTKButton("button_delete", "l&ouml;schen", "location.href = 'configuration.php?page=priceset&action=delete&priceset_id=".$this->priceset_id."';");
+			$button = new NTKButton("button_delete", "l&ouml;schen", "if(confirm('Wirklich loeschen?')) location.href = 'configuration.php?page=priceset&action=delete&priceset_id=".$this->priceset_id."';");
 			$html .= $button->getHtml();
-			$html .= "</td>\n";	
+			$html .= "</td>\n";
 		}
-		
+
 		$html .= "</tr>\n";
 		$html .= "</table>\n";
-		
+
 		$html .= "</form>\n";
-		
+
 		$html .= "</div>\n";
-		
+
 		return $html;
 	}
 }

+ 11 - 11
website/app/NTK_Extensions/NTKETax.php

@@ -9,16 +9,16 @@ class NTKETax
 		$this->tax_rate = $tax_rate;
 		$this->new = $new;
 	}
-	
+
 	function getHtml()
 	{
 		$html = "";
 		$html .= "<div width=\"100%\" height=\"100%\">\n";
-		
+
 		$html .= "<form name=\"tax_form_".$this->tax_id."\" action=\"configuration.php\" method=\"POST\">\n";
 		$html .= "<input type=\"hidden\" name=\"page\" value=\"tax\">\n";
 		$html .= "<input type=\"hidden\" name=\"tax_id\" value=\"".$this->tax_id."\">\n";
-		
+
 		$html .= "<table width=\"100%\" height=\"100%\">\n";
 		$html .= "<tr>\n";
 		$html .= "<td>\n";
@@ -37,11 +37,11 @@ class NTKETax
 		$entry = new NTKEntry("tax_rate", $this->tax_rate);
 		$html .= $entry->getHtml();
 		$html .= "</td>\n";
-		
+
 		if($this->new)
 		{
 			$html .= "<td colspan=\"2\">\n";
-			$button = new NTKButton("button_delete", "hinzuf&uuml;gen", "document.forms['tax_form_".$this->tax_id."'].submit();");
+			$button = new NTKButton("button_new", "hinzuf&uuml;gen", "document.forms['tax_form_".$this->tax_id."'].submit();");
 			$html .= $button->getHtml();
 			$html .= "</td>\n";
 			$html .= "<input type=\"hidden\" name=\"action\" value=\"new\">\n";
@@ -54,18 +54,18 @@ class NTKETax
 			$html .= "</td>\n";
 			$html .= "<input type=\"hidden\" name=\"action\" value=\"edit\">\n";
 			$html .= "<td>\n";
-			$button = new NTKButton("button_delete", "l&ouml;schen", "location.href = 'configuration.php?page=tax&action=delete&tax_id=".$this->tax_id."';");
+			$button = new NTKButton("button_delete", "l&ouml;schen", "if(confirm('Wirklich loeschen?')) location.href = 'configuration.php?page=tax&action=delete&tax_id=".$this->tax_id."';");
 			$html .= $button->getHtml();
-			$html .= "</td>\n";	
+			$html .= "</td>\n";
 		}
-		
+
 		$html .= "</tr>\n";
 		$html .= "</table>\n";
-		
+
 		$html .= "</form>\n";
-		
+
 		$html .= "</div>\n";
-		
+
 		return $html;
 	}
 }