Only showing active products in IvtProductMatch
This commit is contained in:
@@ -37,7 +37,6 @@
|
||||
<th>Preis</th>
|
||||
<th>Interval</th>
|
||||
<th>Typ</th>
|
||||
<th></th>
|
||||
<th style="border-left: 1px solid #000">thetool Produkt</th>
|
||||
<th>ivt_id hinterlegt</th>
|
||||
</tr>
|
||||
@@ -49,7 +48,6 @@
|
||||
<td><?=$ip->price?></td>
|
||||
<td><?=$ip->interval?></td>
|
||||
<td><?=$ip->typ?></td>
|
||||
<td><?=$ip->id?></td>
|
||||
<td style="border-left: 1px solid #000">
|
||||
<select class="form-control" name="product[<?=$ip->id?>]" id="product_<?=$ip->id?>">
|
||||
<option></option>
|
||||
|
||||
@@ -68,6 +68,7 @@ class AdminController extends mfBaseController {
|
||||
if(is_numeric($this->request->s)) {
|
||||
$pagination['start'] = intval($this->request->s);
|
||||
}
|
||||
$filter["customer_product_id"] = true;
|
||||
//var_dump($filter);exit;
|
||||
$pagination['maxItems'] = IvtProductModel::count($filter);
|
||||
$ivtproducts = IvtProductModel::search($filter, $pagination);
|
||||
|
||||
@@ -20,11 +20,20 @@ class IvtProductModel {
|
||||
return $items;
|
||||
}
|
||||
|
||||
public static function getFirst() {
|
||||
public static function getFirst($filter) {
|
||||
$db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$res = $db->select("products", "*", "$where ORDER BY id LIMIT 1");
|
||||
|
||||
$sql = "SELECT products.* FROM products
|
||||
LEFT JOIN customer_product ON (products.id = customer_product.pid)
|
||||
WHERE $where
|
||||
GROUP BY products.id
|
||||
ORDER by products.name LIMIT 1";
|
||||
|
||||
|
||||
//$res = $db->select("products", "*", "$where ORDER BY id LIMIT 1");
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
$data = $db->fetch_object($res);
|
||||
$item = new IvtProduct($data);
|
||||
@@ -41,7 +50,15 @@ class IvtProductModel {
|
||||
$db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT COUNT(*) cnt FROM products WHERE $where ORDER by id";
|
||||
//$sql = "SELECT COUNT(*) cnt FROM products WHERE $where ORDER by id";
|
||||
$sql = "SELECT COUNT(*) as cnt FROM (
|
||||
SELECT products.* FROM products
|
||||
LEFT JOIN customer_product ON (products.id = customer_product.pid)
|
||||
WHERE $where
|
||||
GROUP BY products.id
|
||||
ORDER by products.name
|
||||
) as p
|
||||
";
|
||||
|
||||
$res = $db->query($sql);
|
||||
if($db->num_rows($res)) {
|
||||
@@ -56,7 +73,12 @@ class IvtProductModel {
|
||||
$db = FronkDB::singleton(IVT_DBHOST, IVT_DBUSER, IVT_DBPASS, IVT_DBNAME);
|
||||
|
||||
$where = self::getSqlFilter($filter);
|
||||
$sql = "SELECT * FROM products WHERE $where ORDER by id";
|
||||
//$sql = "SELECT * FROM products WHERE $where ORDER by id";
|
||||
$sql = "SELECT products.* FROM products
|
||||
LEFT JOIN customer_product ON (products.id = customer_product.pid)
|
||||
WHERE $where
|
||||
GROUP BY products.id
|
||||
ORDER by products.name";
|
||||
|
||||
mfLoghandler::singleton()->debug($sql);
|
||||
if(is_array($limit) && count($limit)) {
|
||||
@@ -79,11 +101,21 @@ class IvtProductModel {
|
||||
private static function getSqlFilter($filter) {
|
||||
$where = "1=1 ";
|
||||
|
||||
if(array_key_exists("customer_product_id", $filter)) {
|
||||
$customer_product_id = $filter["customer_product_id"];
|
||||
if($customer_product_id === true) {
|
||||
$where .= " AND customer_product.id IS NOT NULL";
|
||||
}
|
||||
if($customer_product_id === false) {
|
||||
$where .= " AND customer_product.id IS NULL";
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
if(array_key_exists("status_id", $filter)) {
|
||||
$status_id = $filter['status_id'];
|
||||
if(is_numeric($status_id)) {
|
||||
$where .= " AND IvtProduct.status_id=$status_id";
|
||||
if(array_key_exists("street", $filter)) {
|
||||
$street = FronkDB::singleton()->escape($filter["street"]);
|
||||
if($street) {
|
||||
$where .= " AND street like '%$street%'";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +128,8 @@ class IvtProductModel {
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
//var_dump($filter, $where);exit;
|
||||
return $where;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user