diff --git a/application/Network/NetworkModel.php b/application/Network/NetworkModel.php index ee5f47946..9388a0fcc 100644 --- a/application/Network/NetworkModel.php +++ b/application/Network/NetworkModel.php @@ -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; diff --git a/application/Preorder/PreorderController.php b/application/Preorder/PreorderController.php index a70158b07..f81e1dc13 100644 --- a/application/Preorder/PreorderController.php +++ b/application/Preorder/PreorderController.php @@ -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"]) { diff --git a/application/Preorder/PreorderModel.php b/application/Preorder/PreorderModel.php index 6854b4e21..30c171222 100644 --- a/application/Preorder/PreorderModel.php +++ b/application/Preorder/PreorderModel.php @@ -88,7 +88,7 @@ class PreorderModel { $me->loadMe(); mfValuecache::singleton()->set("me", $me); } - + if($model->create_by === null) { $model->create_by = $me->id; } diff --git a/application/Preordercampaign/PreordercampaignModel.php b/application/Preordercampaign/PreordercampaignModel.php index b742e7331..978b02bce 100644 --- a/application/Preordercampaign/PreordercampaignModel.php +++ b/application/Preordercampaign/PreordercampaignModel.php @@ -64,7 +64,7 @@ class PreordercampaignModel { } - public static function getFirst() { + public static function getFirst($filter = false) { $db = FronkDB::singleton(); $where = self::getSqlFilter($filter); diff --git a/application/Product/ProductModel.php b/application/Product/ProductModel.php index f19113951..b7ccc17a1 100644 --- a/application/Product/ProductModel.php +++ b/application/Product/ProductModel.php @@ -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); diff --git a/scripts/preorders-split-multiple-connections.php b/scripts/preorder/preorders-split-multiple-connections.php similarity index 100% rename from scripts/preorders-split-multiple-connections.php rename to scripts/preorder/preorders-split-multiple-connections.php diff --git a/scripts/update-preorder-add-unit.php b/scripts/preorder/update-preorder-add-unit.php similarity index 100% rename from scripts/update-preorder-add-unit.php rename to scripts/preorder/update-preorder-add-unit.php