Added more filtering to Preorder/Index

This commit is contained in:
Frank Schubert
2023-04-24 13:26:55 +02:00
parent 9f96fc4cf1
commit f89909014a
7 changed files with 33 additions and 8 deletions

View File

@@ -65,7 +65,7 @@ class NetworkModel {
}
public static function getFirst() {
public static function getFirst($filter = false) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);
@@ -124,6 +124,15 @@ class NetworkModel {
}
}
if(array_key_exists("adb_network_id", $filter)) {
$adb_network_id = $filter['adb_network_id'];
if(is_numeric($adb_network_id)) {
$where .= " AND adb_network_id=$adb_network_id";
} elseif(is_array($adb_network_id) && count($adb_network_id)) {
$where .= " AND adb_network_id IN (". implode(",", $adb_network_id).")";
}
}
//var_dump($filter, $where);exit;

View File

@@ -124,7 +124,9 @@ class PreorderController extends mfBaseController {
if(array_key_exists("address", $filter) && $filter["address"]) {
$address = $this->db()->escape($filter['address']);
$new_filter['add-where'] .= " AND (adb_hausnummer.gemeinde like '%$address%' OR adb_hausnummer.plz like '%$address%' OR adb_hausnummer.strasse like '%$address%')";
$new_filter['add-where'] .= " AND (adb_hausnummer.gemeinde like '%$address%' OR adb_hausnummer.plz like '%$address%' OR adb_hausnummer.strasse like '%$address%'
OR adb_hausnummer.hausnummer like '%$address%' OR CONCAT (adb_hausnummer.strasse, ' ', adb_hausnummer.hausnummer) like '%$address%'
OR CONCAT (adb_hausnummer.strasse, ' ', adb_hausnummer.hausnummer) like '%".str_replace(" ", "%", $address)."%')";
}
if(array_key_exists("hausnummer", $filter) && $filter["hausnummer"]) {

View File

@@ -88,7 +88,7 @@ class PreorderModel {
$me->loadMe();
mfValuecache::singleton()->set("me", $me);
}
if($model->create_by === null) {
$model->create_by = $me->id;
}

View File

@@ -64,7 +64,7 @@ class PreordercampaignModel {
}
public static function getFirst() {
public static function getFirst($filter = false) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);

View File

@@ -90,11 +90,25 @@ class ProductModel {
}
public static function getFirst() {
public static function getFirst($filter = false) {
$db = FronkDB::singleton();
//var_dump($db);exit;
$where = self::getSqlFilter($filter);
$res = $db->select("Product", "*", "$where ORDER BY producttech_id, name LIMIT 1");
$sql = "SELECT Product.* FROM `Product`
LEFT JOIN Productgroup ON (Productgroup.id = Product.id)
LEFT JOIN ProductAttribute ON (ProductAttribute.product_id = Product.id)
LEFT JOIN Producttech ON (Product.producttech_id = Producttech.id)
LEFT JOIN ProducttechAttribute ON (ProducttechAttribute.producttech_id = Producttech.id)
WHERE $where
GROUP BY Product.id
ORDER BY Productgroup.name,Producttech.name,Product.name LIMIT 1
";
//$res = $db->select("Product", "*", "$where ORDER BY producttech_id, name LIMIT 1");
mfLoghandler::singleton()->debug($sql);
$res = $db->query($sql);
if($db->num_rows($res)) {
$data = $db->fetch_object($res);
$item = new Product($data);
@@ -107,7 +121,7 @@ class ProductModel {
return null;
}
public static function count($filter) {
public static function count($filter = false) {
$db = FronkDB::singleton();
$where = self::getSqlFilter($filter);