Browse Source

Ensure only available products are shown online

Johannes Zellner 5 năm trước cách đây
mục cha
commit
ac9d416256

+ 4 - 1
website/DataBase/Product.php

@@ -146,7 +146,7 @@ class Product
 	}
 	}
 
 
 
 
-	function getByFilter($search_product, $search_category, $item_offset, $item_count)
+	function getByFilter($search_product, $search_category, $item_offset, $item_count, $available)
 	{
 	{
 		$query = "SELECT * FROM ".$this->db->product_table." ";
 		$query = "SELECT * FROM ".$this->db->product_table." ";
 
 
@@ -154,6 +154,9 @@ class Product
 		{
 		{
 			$query .= " WHERE ";
 			$query .= " WHERE ";
 
 
+			if ($available) $query .= " available=1 AND ";
+			else $query .= " available=0 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."%') ";
 
 

+ 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);
+$list = $product->getByFilter($search_product, $search_category, $item_offset, $item_count, True /* available */);
 $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++)