From 2c67a78ece25cadaf0bae1d61d36e2550ccb5eb5 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Mon, 17 Feb 2025 13:39:04 +0100 Subject: [PATCH 1/6] WIP PreorderProduct --- Layout/default/PreorderProduct/Form.php | 180 +++++++++++ .../PreorderProduct/PreorderProduct.php | 296 ++++++++++++++++++ .../PreorderProductController.php | 22 ++ 3 files changed, 498 insertions(+) create mode 100644 Layout/default/PreorderProduct/Form.php create mode 100644 application/PreorderProduct/PreorderProduct.php create mode 100644 application/PreorderProduct/PreorderProductController.php diff --git a/Layout/default/PreorderProduct/Form.php b/Layout/default/PreorderProduct/Form.php new file mode 100644 index 000000000..67cfb0251 --- /dev/null +++ b/Layout/default/PreorderProduct/Form.php @@ -0,0 +1,180 @@ + + + +
+

Preorder Product Management

+ +

Create Preorder

+
+
+ + +
+ +
+ +

Create Preorder Product

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ +

Create Preorder Product Price

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ +

Create Preorder Product Marketshare Discount

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+
+ + \ No newline at end of file diff --git a/application/PreorderProduct/PreorderProduct.php b/application/PreorderProduct/PreorderProduct.php new file mode 100644 index 000000000..f558929a6 --- /dev/null +++ b/application/PreorderProduct/PreorderProduct.php @@ -0,0 +1,296 @@ +$name == null) { + + if($name == "preorder") { + $preorder = PreorderModel::getFirst(["id" => $this->preorder_id]); + if(!$preorder) { + $this->log->debug(__METHOD__ . ": Preorder " . $this->preorder_id . " not found"); + return null; + } + $this->preorder = $preorder; + return $this->preorder; + } + + if($name == "creator") { + $creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by); + if($creator) { + $this->creator = $creator; + return $this->creator; + } + $this->creator = new User($this->create_by); + + if(!$this->creator->id) { + return null; + } + mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator); + return $this->creator; + } + + if($name == "editor") { + $editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by); + if($editor) { + $this->editor = $editor; + return $this->editor; + } + $this->editor = new User($this->edit_by); + if(!$this->editor->id) { + return null; + } + mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor); + return $this->editor; + } + + if($name == "product") { + $product = ProductModel::getFirst(["id" => $this->product_id]); + if(!$product) { + $this->log->debug(__METHOD__ . ": Product " . $this->product_id . " not found"); + return null; + } + $this->product = $product; + return $this->product; + } + } + return parent::getProperty($name); + } + + /******************************** + * Begin static Model functions + */ + + public static function create(Array $data) { + $model = new ConstructionConsent(); + + $table_fields = [ + "type", "name", "vatgroup_id", "price", "price_setup", + "create_by","edit_by","create","edit" + ]; + + foreach($data as $field => $value) { + if(in_array($field, $table_fields)) { + $model->$field = $value; + } + } + + $me = new User(); + $me->loadMe(); + + if($model->create_by === null) { + $model->create_by = $me->id; + } + if($model->edit_by === null) { + $model->edit_by = $me->id; + } + + return $model; + } + + public static function getAll() { + $items = []; + + $db = FronkDB::singleton(); + + $res = $db->select("ConstructionConsent", "*", "1 = 1 ORDER BY adb_hausnummer_id"); + if($db->num_rows($res)) { + while($data = $db->fetch_object($res)) { + $items[] = new ConstructionConsent($data); + } + } + return $items; + + } + + public static function getFirst($filter) { + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $sql = "SELECT * FROM ConstructionConsent + WHERE $where + ORDER BY adb_hausnummer_id LIMIT 1"; + //var_dump($sql);exit; + $res = $db->query($sql); + if($db->num_rows($res)) { + $data = $db->fetch_object($res); + $item = new ConstructionConsent($data); + if($item->id) { + return $item; + } else { + return null; + } + } + return null; + } + + public static function count($filter) { + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $sql = "SELECT COUNT(*) as cnt FROM ConstructionConsent + LEFT JOIN ".ADDRESSDB_DBNAME.".view_hausnummer ON (ConstructionConsent.adb_hausnummer_id = view_hausnummer.hausnummer_id) + WHERE $where"; + + //mfLoghandler::singleton()->debug($sql); + + $res = $db->query($sql); + if($db->num_rows($res)) { + $data = $db->fetch_object($res); + return $data->cnt; + } + return 0; + } + + public static function search($filter, $limit = false, $order = false) { + //var_dump($filter);exit; + $items = []; + + if(!$order) { + $order = "adb_hausnummer_id ASC"; + } + + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $sql = "SELECT * FROM ConstructionConsent + LEFT JOIN ".ADDRESSDB_DBNAME.".view_hausnummer ON (ConstructionConsent.adb_hausnummer_id = view_hausnummer.hausnummer_id) + WHERE $where + ORDER BY $order"; + + if(is_array($limit) && count($limit)) { + if(is_numeric($limit['start']) && is_numeric($limit['count'])) { + $sql .= " LIMIT ".$limit['start'].", ".$limit['count']; + } elseif(is_numeric($limit['count'])) { + $sql .= " LIMIT ".$limit['count']; + } + } + + mfLoghandler::singleton()->debug($sql); + + $res = $db->query($sql); + if($db->num_rows($res)) { + while($data = $db->fetch_object($res)) { + $items[$data->id] = new ConstructionConsent($data); + } + } + + return $items; + } + + private static function getSqlFilter($filter) { + $where = "1=1 "; + + if(array_key_exists("project_id", $filter)) { + $project_id = $filter['project_id']; + if(is_numeric($project_id)) { + $where .= " AND ConstructionConsent.constructionconsentproject_id=$project_id"; + } + } + + if(array_key_exists("constructionconsentproject_id", $filter)) { + $constructionconsentproject_id = $filter['constructionconsentproject_id']; + if(is_numeric($constructionconsentproject_id)) { + $where .= " AND ConstructionConsent.constructionconsentproject_id=$constructionconsentproject_id"; + } + } + + if(array_key_exists("adb_wohneinheit_id", $filter)) { + $adb_wohneinheit_id = $filter['adb_wohneinheit_id']; + if(is_numeric($adb_wohneinheit_id)) { + $where .= " AND ConstructionConsent.adb_wohneinheit_id=$adb_wohneinheit_id"; + } + } + + if(array_key_exists("termination_id", $filter)) { + $termination_id = $filter['termination_id']; + if(is_numeric($termination_id)) { + $where .= " AND ConstructionConsent.termination_id=$termination_id"; + } + } + + if(array_key_exists("object_type", $filter)) { + $object_type = FronkDB::singleton()->escape($filter["object_type"]); + if($object_type) { + $where .= " AND object_type='$object_type'"; + } + } + + if(array_key_exists("ez", $filter)) { + $ez = FronkDB::singleton()->escape($filter["ez"]); + if($ez) { + $where .= " AND ez='$ez'"; + } + } + + if(array_key_exists("status", $filter)) { + $status = FronkDB::singleton()->escape($filter["status"]); + if($status) { + $where .= " AND status='$status'"; + } + } + + if(array_key_exists("result", $filter)) { + $result = FronkDB::singleton()->escape($filter["result"]); + if($result) { + $where .= " AND result='$result'"; + } + } + + if(array_key_exists("owner_name", $filter)) { + $owner_name = FronkDB::singleton()->escape($filter["owner_name"]); + if($owner_name) { + $where .= " AND owner_name like '%$owner_name%'"; + } + } + + if(array_key_exists("owner_street", $filter)) { + $owner_street = FronkDB::singleton()->escape($filter["owner_street"]); + if($owner_street) { + $where .= " AND owner_street like '%$owner_street%'"; + } + } + + if(array_key_exists("owner_zip", $filter)) { + $owner_zip = FronkDB::singleton()->escape($filter["owner_zip"]); + if($owner_zip) { + $where .= " AND owner_zip like '%$owner_zip%'"; + } + } + + if(array_key_exists("owner_city", $filter)) { + $owner_city = FronkDB::singleton()->escape($filter["owner_city"]); + if($owner_city) { + $where .= " AND owner_city like '%$owner_city%'"; + } + } + + if(array_key_exists("owner_country", $filter)) { + $owner_country = FronkDB::singleton()->escape($filter["owner_country"]); + if($owner_country) { + $where .= " AND owner_country like '%$owner_country%'"; + } + } + + if(array_key_exists("network", $filter)) { + $network = FronkDB::singleton()->escape($filter["network"]); + if($network) { + $where .= " AND view_hausnummer.netzgebiet_id=$network"; + } + } + + + + if(array_key_exists("add-where", $filter)) { + $where .= " ".$filter['add-where']; + } + + //var_dump($filter, $where);exit; + return $where; + } + +} \ No newline at end of file diff --git a/application/PreorderProduct/PreorderProductController.php b/application/PreorderProduct/PreorderProductController.php new file mode 100644 index 000000000..4f519e3f5 --- /dev/null +++ b/application/PreorderProduct/PreorderProductController.php @@ -0,0 +1,22 @@ +needlogin=true; + $me = new User(); + $me->loadMe(); + $this->me = $me; + $this->layout()->set("me",$me); + + if(!$me->is(["Admin", "netowner", "salespartner"]) && !$me->can("Preorder")) { + $this->redirect("Dashboard"); + } + } + + protected function indexAction() { + $this->layout()->setTemplate("PreorderProduct/Index"); + + //$product = + } +} \ No newline at end of file From fdd6ed7ebb2ccc4b1f10884e2a1bd2d7a69485a9 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Tue, 18 Feb 2025 13:52:35 +0100 Subject: [PATCH 2/6] WIP PreorderProduct 2025-02-17 --- Layout/default/PreorderProduct/Form.php | 175 --------- Layout/default/PreorderProduct/Index.php | 87 +++++ .../include/enduser-prices-setup.php | 1 + .../include/netoperator-prices-setup.php | 82 +++++ .../include/netoperator-prices-usage.php | 1 + application/Preorder/PreorderModel.php | 6 +- .../PreorderProduct/PreorderProduct.php | 208 ++++++++--- .../PreorderProductController.php | 94 ++++- .../PreorderProductPrice.php | 335 ++++++++++++++++++ ...20250129155121_create_preorder_product.php | 86 +++++ ...20250217133744_preorder_product_change.php | 37 ++ 11 files changed, 893 insertions(+), 219 deletions(-) create mode 100644 Layout/default/PreorderProduct/Index.php create mode 100644 Layout/default/PreorderProduct/include/enduser-prices-setup.php create mode 100644 Layout/default/PreorderProduct/include/netoperator-prices-setup.php create mode 100644 Layout/default/PreorderProduct/include/netoperator-prices-usage.php create mode 100644 application/PreorderProductPrice/PreorderProductPrice.php create mode 100644 db/migrations/20250129155121_create_preorder_product.php create mode 100644 db/migrations/20250217133744_preorder_product_change.php diff --git a/Layout/default/PreorderProduct/Form.php b/Layout/default/PreorderProduct/Form.php index 67cfb0251..8d4a7a33b 100644 --- a/Layout/default/PreorderProduct/Form.php +++ b/Layout/default/PreorderProduct/Form.php @@ -1,180 +1,5 @@ - -
-

Preorder Product Management

-

Create Preorder

-
-
- - -
- -
- -

Create Preorder Product

-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- -
- -

Create Preorder Product Price

-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- -
- -

Create Preorder Product Marketshare Discount

-
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
\ No newline at end of file diff --git a/Layout/default/PreorderProduct/Index.php b/Layout/default/PreorderProduct/Index.php new file mode 100644 index 000000000..a23651dd5 --- /dev/null +++ b/Layout/default/PreorderProduct/Index.php @@ -0,0 +1,87 @@ + + + +
+
+
+
+ +
+

Preise

+
+
+
+ + +
+
+ + +
+
+
+
+

Preise

+
+
+ +
+
+ +

getCompanyOrName()?> (id?>)

+
+
+
"> +

Produkte

+ + setNetoperatorId($netoperator->id) ?> + id, $product->prices)) ? $product->prices[$netoperator->id] : false; ?> + +
+
+

Preiseinstellungen für name?>

+ type == "operator_setup"): ?> + + type == "enduser_setup"): ?> + + type == "operatr_usage"): ?> + + +
+
+
+ + + + +
+
+
+ + + +
+
+ + +
+
+ +
+
+ + + \ No newline at end of file diff --git a/Layout/default/PreorderProduct/include/enduser-prices-setup.php b/Layout/default/PreorderProduct/include/enduser-prices-setup.php new file mode 100644 index 000000000..b3d9bbc7f --- /dev/null +++ b/Layout/default/PreorderProduct/include/enduser-prices-setup.php @@ -0,0 +1 @@ + +
+ + + +
+ Derzeit gültiger Preis: current_price->price_setup?> + current_price->end_date): ?> + (bis current_price->end_date))->format("d.m.Y")?>) + +
+ Derzeit regulärer Preis: current_regular_price->price_setup?>
+ Originalpreis: first_price->price_setup?> + +
+ +
+ +
+ + + + +

Neuer Preis

+
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+
+
+ Preis gültig von +
+ +
+
+ +
+
+
+ Preis gültig bis +
+ +
+ +
+
+ + + Ohne Gültig-Bis-Datum gilt der neue Preis für immer, bis ein neuer Preis eingetragen wird.
+ Mit Gültig-Bis-Datum gilt der neue Preis bis einschließlich dem Gültig-Bis-Datum, danach gilt der vorige Preis wieder. +
+
+ +
+ diff --git a/Layout/default/PreorderProduct/include/netoperator-prices-usage.php b/Layout/default/PreorderProduct/include/netoperator-prices-usage.php new file mode 100644 index 000000000..b3d9bbc7f --- /dev/null +++ b/Layout/default/PreorderProduct/include/netoperator-prices-usage.php @@ -0,0 +1 @@ +filter_netowner_id = null; + return true; + } + $this->filter_netowner_id = $netowner_id; + return true; + } + + public function setNetoperatorId($netoperator_id) { + if(!$netoperator_id) { + $this->filter_netoperator_id = null; + return true; + } + $this->filter_netoperator_id = $netoperator_id; + return true; + } + public function getProperty($name) { if($this->$name == null) { - - if($name == "preorder") { - $preorder = PreorderModel::getFirst(["id" => $this->preorder_id]); - if(!$preorder) { - $this->log->debug(__METHOD__ . ": Preorder " . $this->preorder_id . " not found"); - return null; + + if($name == "prices") { + $prices = PreorderProductPrice::search(["netowner_id" => $this->filter_netowner_id, "preorderproduct_id" => $this->id]); + if(count($prices)) { + foreach($prices as $price) { + $this->prices[$price->netoperator_id] = $price; + } + return $this->prices; } - $this->preorder = $preorder; - return $this->preorder; + return []; } - + + if($name == "first_price") { + $price = PreorderProductPrice::getFirst([ + "netowner_id" => $this->filter_netowner_id, + "netoperator_id" => $this->filter_netoperator_id, + "preorderproduct_id" => $this->id, + "start_date>=" => null, + "end_date>" => null, + ], "`create` ASC"); + if(!$price) { + $price = PreorderProductPrice::getFirst([ + "netowner_id" => $this->filter_netowner_id, + "preorderproduct_id" => $this->id, + "start_date>=" => null, + "end_date>" => null, + ], "`create` ASC"); + } + if($price) { + $this->current_price = $price; + return $this->current_price; + } + return null; + } + + if($name == "current_regular_price") { + $price = PreorderProductPrice::getFirst([ + "netowner_id" => $this->filter_netowner_id, + "netoperator_id" => $this->filter_netoperator_id, + "preorderproduct_id" => $this->id, + "start_date<=" => date("Y-m-d"), + "end_date>" => null, + ], "`create` ASC"); + + if($price) { + $this->current_price = $price; + return $this->current_price; + } else { + return $this->getProperty("first_price"); + } + return null; + } + + if($name == "current_price") { + $price = PreorderProductPrice::getFirst([ + "netowner_id" => $this->filter_netowner_id, + "netoperator_id" => $this->filter_netoperator_id, + "preorderproduct_id" => $this->id, + "start_date<=" => date("Y-m-d"), + "end_date>" => date("Y-m-d"), + ], "start_date"); + if(!$price) { + $price = PreorderProductPrice::getFirst([ + "netowner_id" => $this->filter_netowner_id, + "netoperator_id" => $this->filter_netoperator_id, + "preorderproduct_id" => $this->id, + "start_date<=" => date("Y-m-d"), + "end_date" => null, + ], "start_date"); + } + if(!$price) { + $price = PreorderProductPrice::getFirst([ + "netowner_id" => $this->filter_netowner_id, + "netoperator_id" => $this->filter_netoperator_id, + "preorderproduct_id" => $this->id, + "start_date" => null, + "end_date" => null, + ], "start_date"); + } + + if($price) { + $this->current_price = $price; + return $this->current_price; + } + return null; + } + if($name == "creator") { $creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by); if($creator) { @@ -47,18 +148,24 @@ class PreorderProduct extends mfBaseModel { mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor); return $this->editor; } - - if($name == "product") { - $product = ProductModel::getFirst(["id" => $this->product_id]); - if(!$product) { - $this->log->debug(__METHOD__ . ": Product " . $this->product_id . " not found"); - return null; - } - $this->product = $product; - return $this->product; + + $classname = ucfirst($name); + $idfield = $name . "_id"; + $this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-" . $this->$idfield); + if(!$this->$name) { + $this->$name = new $classname($this->$idfield); + } + + if($this->$name->id) { + mfValuecache::singleton()->set("mfObjectmodel-$name-" . $this->$name->id, $this->$name); + return $this->$name; + } else { + return null; } } - return parent::getProperty($name); + + return $this->$name; + } /******************************** @@ -66,10 +173,10 @@ class PreorderProduct extends mfBaseModel { */ public static function create(Array $data) { - $model = new ConstructionConsent(); + $model = new PreorderProduct(); $table_fields = [ - "type", "name", "vatgroup_id", "price", "price_setup", + "type", "name", "vatgroup_id", "price_inet", "price_inet_tv", "price_catv", "price_passive", "create_by","edit_by","create","edit" ]; @@ -92,15 +199,34 @@ class PreorderProduct extends mfBaseModel { return $model; } + public static function getWithTypes($netowner_id = false) { + $types = []; + + foreach(self::$types as $type) { + $types[$type] = null; + } + + foreach(self::getAll() as $product) { + if(array_key_exists($product->type, $types)) { + if($netowner_id) { + $product->setNetownerId($netowner_id); + } + $types[$product->type] = $product; + } + } + + return $types; + } + public static function getAll() { $items = []; $db = FronkDB::singleton(); - $res = $db->select("ConstructionConsent", "*", "1 = 1 ORDER BY adb_hausnummer_id"); + $res = $db->select("PreorderProduct", "*", "1 = 1 ORDER BY type"); if($db->num_rows($res)) { while($data = $db->fetch_object($res)) { - $items[] = new ConstructionConsent($data); + $items[] = new PreorderProduct($data); } } return $items; @@ -111,14 +237,14 @@ class PreorderProduct extends mfBaseModel { $db = FronkDB::singleton(); $where = self::getSqlFilter($filter); - $sql = "SELECT * FROM ConstructionConsent + $sql = "SELECT * FROM PreorderProduct WHERE $where - ORDER BY adb_hausnummer_id LIMIT 1"; + ORDER BY type LIMIT 1"; //var_dump($sql);exit; $res = $db->query($sql); if($db->num_rows($res)) { $data = $db->fetch_object($res); - $item = new ConstructionConsent($data); + $item = new PreorderProduct($data); if($item->id) { return $item; } else { @@ -132,8 +258,7 @@ class PreorderProduct extends mfBaseModel { $db = FronkDB::singleton(); $where = self::getSqlFilter($filter); - $sql = "SELECT COUNT(*) as cnt FROM ConstructionConsent - LEFT JOIN ".ADDRESSDB_DBNAME.".view_hausnummer ON (ConstructionConsent.adb_hausnummer_id = view_hausnummer.hausnummer_id) + $sql = "SELECT COUNT(*) as cnt FROM PreorderProduct WHERE $where"; //mfLoghandler::singleton()->debug($sql); @@ -151,14 +276,13 @@ class PreorderProduct extends mfBaseModel { $items = []; if(!$order) { - $order = "adb_hausnummer_id ASC"; + $order = "type ASC"; } $db = FronkDB::singleton(); $where = self::getSqlFilter($filter); - $sql = "SELECT * FROM ConstructionConsent - LEFT JOIN ".ADDRESSDB_DBNAME.".view_hausnummer ON (ConstructionConsent.adb_hausnummer_id = view_hausnummer.hausnummer_id) + $sql = "SELECT * FROM PreorderProduct WHERE $where ORDER BY $order"; @@ -175,7 +299,7 @@ class PreorderProduct extends mfBaseModel { $res = $db->query($sql); if($db->num_rows($res)) { while($data = $db->fetch_object($res)) { - $items[$data->id] = new ConstructionConsent($data); + $items[$data->id] = new PreorderProduct($data); } } @@ -188,28 +312,28 @@ class PreorderProduct extends mfBaseModel { if(array_key_exists("project_id", $filter)) { $project_id = $filter['project_id']; if(is_numeric($project_id)) { - $where .= " AND ConstructionConsent.constructionconsentproject_id=$project_id"; + $where .= " AND PreorderProduct.preorderProductproject_id=$project_id"; } } - if(array_key_exists("constructionconsentproject_id", $filter)) { - $constructionconsentproject_id = $filter['constructionconsentproject_id']; - if(is_numeric($constructionconsentproject_id)) { - $where .= " AND ConstructionConsent.constructionconsentproject_id=$constructionconsentproject_id"; + if(array_key_exists("preorderProductproject_id", $filter)) { + $preorderProductproject_id = $filter['preorderProductproject_id']; + if(is_numeric($preorderProductproject_id)) { + $where .= " AND PreorderProduct.preorderProductproject_id=$preorderProductproject_id"; } } if(array_key_exists("adb_wohneinheit_id", $filter)) { $adb_wohneinheit_id = $filter['adb_wohneinheit_id']; if(is_numeric($adb_wohneinheit_id)) { - $where .= " AND ConstructionConsent.adb_wohneinheit_id=$adb_wohneinheit_id"; + $where .= " AND PreorderProduct.adb_wohneinheit_id=$adb_wohneinheit_id"; } } if(array_key_exists("termination_id", $filter)) { $termination_id = $filter['termination_id']; if(is_numeric($termination_id)) { - $where .= " AND ConstructionConsent.termination_id=$termination_id"; + $where .= " AND PreorderProduct.termination_id=$termination_id"; } } diff --git a/application/PreorderProduct/PreorderProductController.php b/application/PreorderProduct/PreorderProductController.php index 4f519e3f5..e421c4413 100644 --- a/application/PreorderProduct/PreorderProductController.php +++ b/application/PreorderProduct/PreorderProductController.php @@ -17,6 +17,98 @@ class PreorderProductController extends mfBaseController { protected function indexAction() { $this->layout()->setTemplate("PreorderProduct/Index"); - //$product = + $netowner_id = 4807; // $this->me->address_id; + $netowner = new Address($netowner_id); + + $products = PreorderProduct::getWithTypes($netowner_id); + $this->layout()->set("products", $products); + + $netoperators = []; + foreach(PreordercampaignModel::search(["owner_id" => $netowner_id]) as $campaign) { + foreach($campaign->active_operators as $op) { + if(!array_key_exists($op->operator_id, $netoperators)) { + $nop = new Address($op->operator_id); + if($nop->id) { + $netoperators[$nop->id] = $nop; + } + + } + } + foreach($campaign->passive_operators as $op) { + if(!array_key_exists($op->operator_id, $netoperators)) { + $nop = new Address($op->operator_id); + if($nop->id) { + $netoperators[$nop->id] = $nop; + } + } + } + } + + $this->layout()->set("netoperators", $netoperators); + $this->layout()->set("netowner", $netowner); + } + + protected function saveAction() { + $r = $this->request; + //var_dump($r->get());exit; + + $netowner_id = 4807; // $this->me->address_id; + + foreach($r->netoperators as $netoperator_id => $product_data) { + $netoperator = new Address($netoperator_id); + if(!$netoperator->id) { + $this->layout()->setFlash("Betzbetreiber nicht gefunden", "error"); + $this->layout()->redirect("PreorderProduct"); + } + foreach($product_data as $product_id => $price_data) { + var_dump($price_data); + $product = new PreorderProduct($product_id); + if(!$product->id) { + $this->layout()->setFlash("Produkt $product_id nicht gefunden", "error"); + $this->layout()->redirect("PreorderProduct"); + } + + // create new PreorderProductPrice + $price = PreorderProductPrice::create([ + "netowner_id" => $netowner_id, + "preorderproduct_id" => $product->id, + "netoperator_id" => $netoperator_id, + ]); + if($price_data["price_setup"]) $price->price_setup = $price_data["price_setup"]; + + if(!$price_data["start_date"]) { + $this->layout()->setFlash("Von-datum fehlt bei Produkt '".$product->name."' für '".$netoperator->getCompanyOrName()."'", "error"); + $this->redirect("PreorderProduct"); + } else { + try { + $start_date = new DateTime("@" . $this->dateToTimestamp($price_data["start_date"])); + $start_date->setTimezone(new DateTimeZone("Europe/Vienna")); + $price->start_date = $start_date->format("Y-m-d"); + } catch(Exception $e) { + $this->layout()->setFlash("Fehler im Von-datum bei Produkt '".$product->name."' für '".$netoperator->getCompanyOrName()."'", "error"); + $this->redirect("PreorderProduct"); + } + } + if($price_data["end_date"]) { + try { + $end_date = new DateTime("@" . $this->dateToTimestamp($price_data["end_date"])); + $end_date->setTimezone(new DateTimeZone("Europe/Vienna")); + $price->end_date = $end_date->format("Y-m-d"); + } catch(Exception $e) { + $this->layout()->setFlash("Fehler im Bis-Datum bei Produkt '".$product->name."' für '".$netoperator->getCompanyOrName()."'", "error"); + $this->redirect("PreorderProduct"); + } + } + + + //var_dump($product, $price); + + $price->save(); + } + } + + $this->layout()->setFlash("Neue Preise erflgreich gespeichert", "success"); + $this->redirect("PreorderProduct"); + } } \ No newline at end of file diff --git a/application/PreorderProductPrice/PreorderProductPrice.php b/application/PreorderProductPrice/PreorderProductPrice.php new file mode 100644 index 000000000..91878175d --- /dev/null +++ b/application/PreorderProductPrice/PreorderProductPrice.php @@ -0,0 +1,335 @@ +$name == null) { + + if($name == "preorderproduct") { + $product = new PreorderProduct($this->preorderprduct_id); + if(!$product->id) { + return null; + } + $this->preorderprduct = $product; + return $this->preorderprduct; + } + + if($name == "netowner") { + $netowner = new Address($this->netowner_id); + if(!$netowner->id) { + return null; + } + $this->netowner = $netowner; + return $this->netowner; + } + + if($name == "preordercampaign" || $name == "campaign") { + $campaign = new PreorderCampaign($this->preordercampgin_id); + if(!$campaign->id) { + return null; + } + $this->preorderprduct = $campaign; + $this->campaign = $campaign; + return $this->preordercampaign; + } + + + if($name == "creator") { + $creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by); + if($creator) { + $this->creator = $creator; + return $this->creator; + } + $this->creator = new User($this->create_by); + + if(!$this->creator->id) { + return null; + } + mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator); + return $this->creator; + } + + if($name == "editor") { + $editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by); + if($editor) { + $this->editor = $editor; + return $this->editor; + } + $this->editor = new User($this->edit_by); + if(!$this->editor->id) { + return null; + } + mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor); + return $this->editor; + } + + $classname = ucfirst($name); + $idfield = $name . "_id"; + $this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-" . $this->$idfield); + if(!$this->$name) { + $this->$name = new $classname($this->$idfield); + } + + if($this->$name->id) { + mfValuecache::singleton()->set("mfObjectmodel-$name-" . $this->$name->id, $this->$name); + return $this->$name; + } else { + return null; + } + + } + return $this->$name; + } + + /******************************** + * Begin static Model functions + */ + + public static function create(Array $data) { + $model = new PreorderProductPrice(); + + $table_fields = [ + "preorderproduct_id", "netowner_id", "netoperator_id", "preordercampaign_id", "description", + "start_date", "end_date", "price_inet", "price_inet_tv", "price_catv", "price_passive", + "billing_delay", "billing_period", "contract_term", "note", + "create_by","edit_by","create","edit" + ]; + + foreach($data as $field => $value) { + if(in_array($field, $table_fields)) { + $model->$field = $value; + } + } + + $me = new User(); + $me->loadMe(); + + if($model->create_by === null) { + $model->create_by = $me->id; + } + if($model->edit_by === null) { + $model->edit_by = $me->id; + } + + return $model; + } + + public static function getAll() { + $items = []; + + $db = FronkDB::singleton(); + + $res = $db->select("PreorderProductPrice", "*", "1 = 1 ORDER BY start_date"); + if($db->num_rows($res)) { + while($data = $db->fetch_object($res)) { + $items[] = new PreorderProductPrice($data); + } + } + return $items; + + } + + public static function getFirst($filter = [], $order = false) { + $db = FronkDB::singleton(); + + if(!$order) { + $order = "start_date ASC"; + } + + $where = self::getSqlFilter($filter); + $sql = "SELECT * FROM PreorderProductPrice + WHERE $where + ORDER BY $order LIMIT 1"; + + mfLoghandler::singleton()->debug($sql); + + $res = $db->query($sql); + if($db->num_rows($res)) { + $data = $db->fetch_object($res); + $item = new PreorderProductPrice($data); + if($item->id) { + return $item; + } else { + return null; + } + } + return null; + } + + public static function count($filter) { + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $sql = "SELECT COUNT(*) as cnt FROM PreorderProductPrice + WHERE $where"; + + //mfLoghandler::singleton()->debug($sql); + + $res = $db->query($sql); + if($db->num_rows($res)) { + $data = $db->fetch_object($res); + return $data->cnt; + } + return 0; + } + + public static function search($filter, $limit = false, $order = false) { + //var_dump($filter);exit; + $items = []; + + if(!$order) { + $order = "start_date ASC"; + } + + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $sql = "SELECT * FROM PreorderProductPrice + WHERE $where + ORDER BY $order"; + + if(is_array($limit) && count($limit)) { + if(is_numeric($limit['start']) && is_numeric($limit['count'])) { + $sql .= " LIMIT ".$limit['start'].", ".$limit['count']; + } elseif(is_numeric($limit['count'])) { + $sql .= " LIMIT ".$limit['count']; + } + } + + mfLoghandler::singleton()->debug($sql); + + $res = $db->query($sql); + if($db->num_rows($res)) { + while($data = $db->fetch_object($res)) { + $items[$data->id] = new PreorderProductPrice($data); + } + } + + return $items; + } + + private static function getSqlFilter($filter) { + $where = "1=1 "; + + if(array_key_exists("preorderproduct_id", $filter)) { + $preorderproduct_id = $filter['preorderproduct_id']; + if(is_numeric($preorderproduct_id)) { + $where .= " AND PreorderProductPrice.preorderproduct_id=$preorderproduct_id"; + } + } + + if(array_key_exists("netowner_id", $filter)) { + $netowner_id = $filter['netowner_id']; + if(is_numeric($netowner_id)) { + $where .= " AND PreorderProductPrice.netowner_id=$netowner_id"; + } + } + + if(array_key_exists("netoperator_id", $filter)) { + $netoperator_id = $filter['netoperator_id']; + if(is_numeric($netoperator_id)) { + $where .= " AND PreorderProductPrice.netoperator_id=$netoperator_id"; + } + } + + if(array_key_exists("preordercampaign_id", $filter)) { + $preordercampaign_id = $filter['preordercampaign_id']; + if(is_numeric($preordercampaign_id)) { + $where .= " AND PreorderProductPrice.preordercampaign_id=$preordercampaign_id"; + } + } + + + if(array_key_exists("start_date", $filter)) { + $start_date = $filter["start_date"]; + if($start_date === null || $start_date === false) { + $where .= " AND PreorderProductPrice.start_date IS NULL"; + } elseif($start_date) { + $start_date = FronkDB::singleton()->escape($filter["start_date"]); + $where .= " AND PreorderProductPrice.start_date='$start_date'"; + } + } + + if(array_key_exists("start_date>", $filter)) { + $start_date = FronkDB::singleton()->escape($filter['start_date>']); + if($start_date) { + $where .= " AND PreorderProductPrice.start_date > '$start_date'"; + } + } + + if(array_key_exists("start_date<", $filter)) { + $start_date = FronkDB::singleton()->escape($filter['start_date<']); + if($start_date) { + $where .= " AND PreorderProductPrice.start_date < '$start_date'"; + } + } + + if(array_key_exists("start_date>=", $filter)) { + $start_date = FronkDB::singleton()->escape($filter['start_date>=']); + if($start_date) { + $where .= " AND PreorderProductPrice.start_date >= '$start_date'"; + } + } + + if(array_key_exists("start_date<=", $filter)) { + $start_date = FronkDB::singleton()->escape($filter['start_date<=']); + if($start_date) { + $where .= " AND PreorderProductPrice.start_date <= '$start_date'"; + } + } + + if(array_key_exists("end_date", $filter)) { + $end_date = $filter["end_date"]; + if($end_date === null || $end_date === false) { + $where .= " AND PreorderProductPrice.end_date IS NULL"; + } elseif($end_date) { + $end_date = FronkDB::singleton()->escape($filter["end_date"]); + $where .= " AND PreorderProductPrice.end_date='$end_date'"; + } + } + + if(array_key_exists("end_date>", $filter)) { + $end_date = FronkDB::singleton()->escape($filter['end_date>']); + if($end_date) { + $where .= " AND PreorderProductPrice.end_date > '$end_date'"; + } + } + + if(array_key_exists("end_date<", $filter)) { + $end_date = FronkDB::singleton()->escape($filter['end_date<']); + if($end_date) { + $where .= " AND PreorderProductPrice.end_date < '$end_date'"; + } + } + + if(array_key_exists("end_date>=", $filter)) { + $end_date = FronkDB::singleton()->escape($filter['end_date>=']); + if($end_date) { + $where .= " AND PreorderProductPrice.end_date >= '$end_date'"; + } + } + + if(array_key_exists("end_date<=", $filter)) { + $end_date = FronkDB::singleton()->escape($filter['end_date<=']); + if($end_date) { + $where .= " AND PreorderProductPrice.end_date <= '$end_date'"; + } + } + + + + if(array_key_exists("add-where", $filter)) { + $where .= " ".$filter['add-where']; + } + + //var_dump($filter, $where);exit; + return $where; + } + +} \ No newline at end of file diff --git a/db/migrations/20250129155121_create_preorder_product.php b/db/migrations/20250129155121_create_preorder_product.php new file mode 100644 index 000000000..9dcac3699 --- /dev/null +++ b/db/migrations/20250129155121_create_preorder_product.php @@ -0,0 +1,86 @@ +getEnvironment() == "thetool") { + $po = $this->table("Preorder"); + $po->addColumn("rimo_service_id", "integer", ["null" => true, "default" => null]); + $po->update(); + + $pp = $this->table("PreorderProduct"); + $pp->addColumn("type", "enum", ["null" => false, "values" => "enduser_setup, provider_setup, provider_usage"]); + $pp->addColumn("name", "string", ["null" => true, "default" => null, "length" => 64]); + $pp->addColumn("vatgroup_id", "integer", ["null" => true, "default" => null]); + $pp->addColumn("price_inet", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]); + $pp->addColumn("price_inet_tv", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]); + $pp->addColumn("price_catv", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]); + $pp->addColumn("price_passive", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]); + $pp->addColumn("create_by", "integer", ["null" => false]); + $pp->addColumn("edit_by", "integer", ["null" => false]); + $pp->addColumn("create", "integer", ["null" => false]); + $pp->addColumn("edit", "integer", ["null" => false]); + $pp->create(); + + $ppp = $this->table("PreorderProductPrice"); + $ppp->addColumn("preorderproduct_id", "integer", ["null" => false]); + $ppp->addColumn("netowner_id", "integer", ["null" => false]); + $ppp->addColumn("preordercampaign_id", "integer", ["null" => true, "default" => null]); + $ppp->addColumn("description", "text", ["null" => true, "default" => null]); + $ppp->addColumn("start_date", "date", ["null" => true, "default" => null]); + $ppp->addColumn("end_date", "date", ["null" => true, "default" => null]); + $ppp->addColumn("price_inet", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]); + $ppp->addColumn("price_inet_tv", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]); + $ppp->addColumn("price_catv", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]); + $ppp->addColumn("price_passive", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]); + $ppp->addColumn("billing_delay", "integer", ["null" => false, "default" => 0]); + $ppp->addColumn("billing_period", "integer", ["null" => true, "default" => null]); + $ppp->addColumn("contract_term", "integer", ["null" => true, "default" => null]); + $ppp->addColumn("note", "text", ["null" => true, "default" => null]); + $ppp->addColumn("create_by", "integer", ["null" => false]); + $ppp->addColumn("edit_by", "integer", ["null" => false]); + $ppp->addColumn("create", "integer", ["null" => false]); + $ppp->addColumn("edit", "integer", ["null" => false]); + $ppp->create(); + + $ppmd = $this->table("PreorderProductMarketshareDiscount"); + $ppmd->addColumn("preorderproductprice_id", "integer", ["null" => false]); + $ppmd->addColumn("price_15", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]); + $ppmd->addColumn("price_20", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]); + $ppmd->addColumn("price_25", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]); + $ppmd->addColumn("price_30", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]); + $ppmd->addColumn("price_35", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]); + $ppmd->addColumn("price_40", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]); + $ppmd->addColumn("price_45", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]); + $ppmd->addColumn("price_50", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4]); + $ppmd->addColumn("create_by", "integer", ["null" => false]); + $ppmd->addColumn("edit_by", "integer", ["null" => false]); + $ppmd->addColumn("create", "integer", ["null" => false]); + $ppmd->addColumn("edit", "integer", ["null" => false]); + $ppmd->create(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + $this->table("PreorderProductMarketshareDiscount")->drop()->save(); + $this->table("PreorderProductPrice")->drop()->save(); + $this->table("PreorderProduct")->drop()->save(); + $this->table("Preorder")->removeColumn("rimo_service_id")->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } +} + diff --git a/db/migrations/20250217133744_preorder_product_change.php b/db/migrations/20250217133744_preorder_product_change.php new file mode 100644 index 000000000..914c3f574 --- /dev/null +++ b/db/migrations/20250217133744_preorder_product_change.php @@ -0,0 +1,37 @@ +getEnvironment() == "thetool") { + $pp = $this->table("PreorderProduct"); + //$pp->changeColumn("type", "enum", ["null" => false, "values" => "enduser_setup, operator_setup, operator_usage"]); + //$pp->addColumn("price_setup", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4, "after" => "vatgroup_id"]); + $pp->update(); + + $ppp = $this->table("PreorderProductPrice"); + $ppp->addColumn("netoperator_id", "integer", ["null" => false, "after" => "netowner_id"]); + //$ppp->addColumn("price_setup", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4, "after" => "end_date"]); + $ppp->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + + } + + if($this->getEnvironment() == "addressdb") { + + } + } +} From 99bdbd3b39a0d987e28b43b59ff86c123e5a7c55 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Mon, 24 Feb 2025 12:37:33 +0100 Subject: [PATCH 3/6] WIP PreorderPrice 2025-02-21 --- Layout/default/PreorderProduct/Form.php | 5 - Layout/default/PreorderProduct/Index.php | 86 ++++- .../include/netoperator-prices-setup.php | 82 ----- .../include/netoperator-prices-usage.php | 305 +++++++++++++++ .../PreorderProduct/include/prices-setup.php | 190 ++++++++++ .../PreorderProduct/PreorderProduct.php | 346 +++++++++++++++++- .../PreorderProductController.php | 45 ++- .../PreorderProductPrice.php | 56 ++- .../PreorderProductPriceCampaign.php | 253 +++++++++++++ ...20250217133744_preorder_product_change.php | 17 +- ...250218141907_preorder_product_change_2.php | 35 ++ ...create_preorder_product_price_campaign.php | 44 +++ 12 files changed, 1329 insertions(+), 135 deletions(-) delete mode 100644 Layout/default/PreorderProduct/Form.php delete mode 100644 Layout/default/PreorderProduct/include/netoperator-prices-setup.php create mode 100644 Layout/default/PreorderProduct/include/prices-setup.php create mode 100644 application/PreorderProductPriceCampaign/PreorderProductPriceCampaign.php create mode 100644 db/migrations/20250218141907_preorder_product_change_2.php create mode 100644 db/migrations/20250218144547_create_preorder_product_price_campaign.php diff --git a/Layout/default/PreorderProduct/Form.php b/Layout/default/PreorderProduct/Form.php deleted file mode 100644 index 8d4a7a33b..000000000 --- a/Layout/default/PreorderProduct/Form.php +++ /dev/null @@ -1,5 +0,0 @@ - - - - - \ No newline at end of file diff --git a/Layout/default/PreorderProduct/Index.php b/Layout/default/PreorderProduct/Index.php index a23651dd5..249ba29d9 100644 --- a/Layout/default/PreorderProduct/Index.php +++ b/Layout/default/PreorderProduct/Index.php @@ -30,36 +30,61 @@ +
+
+
+
+
"> +
+ + +
+ +
+
+
+ +
+
+
-

getCompanyOrName()?> (id?>)

+ +

getCompanyOrName()?> (id?>)

-
"> +

Produkte

- setNetoperatorId($netoperator->id) ?> - id, $product->prices)) ? $product->prices[$netoperator->id] : false; ?> - + setNetoperatorId($netoperator->id) ?> + setTodayDate($today_date); ?> + id, $product->prices)) ? $product->prices[$netoperator->id] : false; ?>
-
-

Preiseinstellungen für name?>

+
+

+ Preiseinstellungen für name?> +

+
+
type == "operator_setup"): ?> - + type == "enduser_setup"): ?> - - type == "operatr_usage"): ?> + + type == "operator_usage"): ?>
-
+ - - + +
@@ -83,5 +108,40 @@ todayBtn: 'linked', autoclose: true }); + $('.datepicker-sys').datepicker({ + language: 'de', + format: "yyyy-mm-dd", + showWeekDays: true, + todayBtn: 'linked', + autoclose: true + }); + + $(".select2").select2({ + allowClear: true, + placeholder: "", + closeOnSelect: true + }); + + $(".select2-nc").select2({ + allowClear: true, + placeholder: "", + closeOnSelect: false + }); + + function toggleCollapseIndicator(elem) { + var selector = "#" + $(elem).attr("id"); + var itype = $(elem).data("collapse-indicator"); + + //console.log("selector: " + selector); + + if($(selector + " i.collapse-indicator").hasClass(itype + "-right")) { + $(selector + " i.collapse-indicator").removeClass(itype + "-right").addClass(itype + "-down"); + } else { + $(selector + " i.collapse-indicator").removeClass(itype + "-down").addClass(itype + "-right"); + } + + } + + \ No newline at end of file diff --git a/Layout/default/PreorderProduct/include/netoperator-prices-setup.php b/Layout/default/PreorderProduct/include/netoperator-prices-setup.php deleted file mode 100644 index ce2378595..000000000 --- a/Layout/default/PreorderProduct/include/netoperator-prices-setup.php +++ /dev/null @@ -1,82 +0,0 @@ -
-
- - - -
- Derzeit gültiger Preis: current_price->price_setup?> - current_price->end_date): ?> - (bis current_price->end_date))->format("d.m.Y")?>) - -
- Derzeit regulärer Preis: current_regular_price->price_setup?>
- Originalpreis: first_price->price_setup?> - -
- -
- -
- - - - -

Neuer Preis

-
- -
-
- -
- -
- -
- -
- -
-
-
-
- Preis gültig von -
- -
-
- -
-
-
- Preis gültig bis -
- -
- -
-
- - - Ohne Gültig-Bis-Datum gilt der neue Preis für immer, bis ein neuer Preis eingetragen wird.
- Mit Gültig-Bis-Datum gilt der neue Preis bis einschließlich dem Gültig-Bis-Datum, danach gilt der vorige Preis wieder. -
-
- -
-
diff --git a/Layout/default/PreorderProduct/include/netoperator-prices-usage.php b/Layout/default/PreorderProduct/include/netoperator-prices-usage.php index b3d9bbc7f..12d4df175 100644 --- a/Layout/default/PreorderProduct/include/netoperator-prices-usage.php +++ b/Layout/default/PreorderProduct/include/netoperator-prices-usage.php @@ -1 +1,306 @@ + +
+
+
"> + +
+ +
+ + + + + + +
+
+

+ Neuen Preis eingeben +

+
+
+
+
+
+ + +
+
+
+ +
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+
+ +
+
+ +
+ +
+
+ + +
+ +
+
+
+
+ Preis gültig von +
+ +
+
+ +
+
+
+ Preis gültig bis +
+ +
+ +
+
+ + Ohne Gültig-Bis-Datum gilt der neue Preis für immer, bis ein neuer Preis eingetragen wird.
+ Mit Gültig-Bis-Datum gilt der neue Preis bis einschließlich dem Gültig-Bis-Datum, danach gilt der vorige Preis wieder. +
+ +
+
+
+ + + + Wenn keine Kampagne ausgewählt wird, gilt der Preis für alle Kampagnen. + +
+
+
+ +

Netzdurchdringung

+
+
+

Rabattierte Preise für das Erreichen on Netzdurchdringungszielen

+

0 - 15% ist der Standardpreis. Falls keine Netzdurchdringung

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ZielINETINET+TVCATVPassive
0 - 15%
15,01% - 20%
20,01% - 25%
25,01% - 30%
30,01% - 35%
35,01% - 40%
40,01% - 45%
+
+
+ +
+ +
+
+
+ +
+ + + + + getCurrentPrice($today_date, true); + $current_regular_price = $product->getCurrentRegularPrice($today_date, true); + $first_price = $product->getFirstPrice($today_date); + ?> +
+
+
+

Aktuelle Preise für getTodayDate()?>

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
INETINET+TVCATVPassive
Heute gültiger Preisprice_inet, 2, ",", ".")?>price_inet_tv, 2, ",", ".")?>price_catv, 2, ",", ".")?>price_passive, 2, ",", ".")?> + description?> + end_date): ?> + bis end_date))->format("d.m.Y")?> + +
Derzeit regulärer Preisprice_inet, 2, ",", ".")?>price_inet_tv, 2, ",", ".")?>price_catv, 2, ",", ".")?>price_passive, 2, ",", ".")?>description?>
Initialpreisprice_inet, 2, ",", ".")?>price_inet_tv, 2, ",", ".")?>price_catv, 2, ",", ".")?>price_passive, 2, ",", ".")?>
+ +
+
+ +
+
+

Preis Pro Kampagne

+ + + + + + + + + + + + + + getCampaignPrice($campaign->id, $today_date); ?> + + + + + + + + + + + + +
KampagneINETINET+TVCATVPassiveGültig vonGültig bisBeschreibung
name?>price_inet, 2, ",", ".")?>price_inet_tv, 2, ",", ".")?>price_catv, 2, ",", ".")?>price_passive, 2, ",", ".")?>start_date) ? (new DateTime($cprice->start_date))->format("d.m.Y") : "-"?>end_date) ? (new DateTime($cprice->end_date))->format("d.m.Y") : "-"?>description?>getTodayDate()?>
+
+
+ +
+ +
diff --git a/Layout/default/PreorderProduct/include/prices-setup.php b/Layout/default/PreorderProduct/include/prices-setup.php new file mode 100644 index 000000000..232703823 --- /dev/null +++ b/Layout/default/PreorderProduct/include/prices-setup.php @@ -0,0 +1,190 @@ + + +
+
+
"> + +
+ +
+ + + + + + +
+
+

+ Neuen Preis eingeben +

+
+
+
+
+
+ + +
+
+
+ +
+ +
+
+ +
+ +
+ +
+ +
+ +
+
+
+
+ Preis gültig von +
+ +
+
+ +
+
+
+ Preis gültig bis +
+ +
+ +
+
+ + Ohne Gültig-Bis-Datum gilt der neue Preis für immer, bis ein neuer Preis eingetragen wird.
+ Mit Gültig-Bis-Datum gilt der neue Preis bis einschließlich dem Gültig-Bis-Datum, danach gilt der vorige Preis wieder. +
+ +
+
+
+ + + + Wenn keine Kampagne ausgewählt wird, gilt der Preis für alle Kampagnen. + +
+
+
+ +
+ +
+
+
+ +
+ + + + + getCurrentPrice($today_date, true); + $current_regular_price = $product->getCurrentRegularPrice($today_date, true); + $first_price = $product->getFirstPrice($today_date); + ?> +
+
+
+

Aktuelle Preise für getTodayDate()?>

+ + + + + + + + + + + + + + +
Heute gültiger Preisprice_setup, 2, ",", ".")?> + description?> + end_date): ?> + bis end_date))->format("d.m.Y")?> + +
Derzeit regulärer Preisprice_setup, 2, ",", ".")?>description?>
Initialpreis price_setup, 2, ",", ".")?>
+ +
+
+ +
+
+

Preis Pro Kampagne

+ + + + + + + + + + + getCampaignPrice($campaign->id, $today_date); ?> + + + + + + + + + +
KampagnePreisGültig vonGültig bisBeschreibung
name?>price_setup, 2, ",", ".")?>start_date) ? (new DateTime($cprice->start_date))->format("d.m.Y") : "-"?>end_date) ? (new DateTime($cprice->end_date))->format("d.m.Y") : "-"?>description?>getTodayDate()?>
+
+
+ +
+ +
diff --git a/application/PreorderProduct/PreorderProduct.php b/application/PreorderProduct/PreorderProduct.php index 59776280e..432126f5b 100644 --- a/application/PreorderProduct/PreorderProduct.php +++ b/application/PreorderProduct/PreorderProduct.php @@ -3,12 +3,17 @@ class PreorderProduct extends mfBaseModel { private $filter_netowner_id; private $filter_netoperator_id; + private $filter_campaign_id; private $prices; private $first_price; private $current_price; private $current_regular_price; + private $first_campaign_price; + private $current_campaign_price; + private $current_campaign_regular_price; private $creator; private $editor; + private $today_date; protected static $types = ["operator_setup", "enduser_setup", "operator_usage"]; @@ -31,6 +36,230 @@ class PreorderProduct extends mfBaseModel { return true; } + public function setCampaignId($campaign_id) { + if(!$campaign_id) { + $this->filter_campaign_id = null; + return true; + } + $this->filter_campaign_id = $campaign_id; + return true; + } + + public function setTodayDate($date) { + $this->today_date = date($date); + } + + public function getTodayDate() { + return $this->today_date; + } + + public function getCampaignFirstPrice($campaign_id, $date = null) { + if(!$date) $date = date("Y-m-d"); + + + $price = PreorderProductPrice::getFirst([ + "netowner_id" => $this->filter_netowner_id, + "netoperator_id" => $this->filter_netoperator_id, + "campaign_id" => $campaign_id, + "preorderproduct_id" => $this->id, + "start_date" => null, + "end_date" => null, + ], "`create` DESC"); + if($price) { + //$this->first_campaign_price = $price; + return $price; + //return $this->first_campaign_price; + } + return null; + } + + public function getCampaignCurrentRegularPrice($campaign_id, $date) { + if(!$date) $date = date("Y-m-d"); + + $price = PreorderProductPrice::getFirst([ + "netowner_id" => $this->filter_netowner_id, + "netoperator_id" => $this->filter_netoperator_id, + "campaign_id" => $campaign_id, + "preorderproduct_id" => $this->id, + "start_date<=" => $date, + "end_date" => null, + ], "start_date DESC, `create` DESC"); + + if($price) { + //$this->current_campaign_regular_price = $price; + return $price; + //return $this->current_campaign_regular_price; + } else { + $this->log->debug(__METHOD__.": TRY FIRST PRICE"); + return $this->getCampaignFirstPrice($campaign_id, $date); + } + return null; + } + + public function getCampaignCurrentPrice($campaign_id, $date = null) { + if(!$date) $date = date("Y-m-d"); + + // search for discounted price (with startdate and enddate + $price = PreorderProductPrice::getFirst([ + "netowner_id" => $this->filter_netowner_id, + "netoperator_id" => $this->filter_netoperator_id, + "campaign_id" => $campaign_id, + "preorderproduct_id" => $this->id, + "start_date<=" => $date, + "end_date>" => $date, + ], "start_date DESC, end_date ASC, `create` DESC"); + + if(!$price) { + // search for current regular price (with startdate and no enddate) + $price = PreorderProductPrice::getFirst([ + "netowner_id" => $this->filter_netowner_id, + "netoperator_id" => $this->filter_netoperator_id, + "campaign_id" => $campaign_id, + "preorderproduct_id" => $this->id, + "start_date<=" => $date, + "end_date" => null, + ], "start_date DESC, `create` DESC"); + } + + return $price; + } + + + + public function getCampaignPrice($campaign_id, $date = null) { + $this->log->debug("=== in ".__METHOD__); + if(!$date) $date = date("Y-m-d"); + + $this->log->debug(__METHOD__.": TRY CURRENT PRICE"); + $price = $this->getCampaignCurrentPrice($campaign_id, $date); + if(!$price) { + $this->log->debug(__METHOD__.": TRY CURRENT REGULAR PRICE"); + $price = $this->getCampaignCurrentRegularPrice($campaign_id, $date); + } + if(!$price) { + $this->log->debug(__METHOD__.": TRY FIRST PRICE"); + $price = $this->getCampaignFirstPrice($campaign_id, $date); + } + if(!$price) { + $this->log->debug(__METHOD__.": No Campaign price found. GET NETOP CURRENT PRICE"); + $price = $this->getPrice(); + } + + if($price) { + $this->log->debug("=== done in ".__METHOD__); + return $price; + } + return null; + + } + + public function getFirstPrice($date = null) { + if(!$date) $date = date("Y-m-d"); + + $price = PreorderProductPrice::getFirst([ + "netowner_id" => $this->filter_netowner_id, + "netoperator_id" => $this->filter_netoperator_id, + "campaign_id" => null, + "preorderproduct_id" => $this->id, + "start_date" => null, + "end_date" => null, + ], "`create` DESC"); + if(!$price) { + $price = PreorderProductPrice::getFirst([ + "netowner_id" => $this->filter_netowner_id, + "netoperator_id" => null, + "campaign_id" => null, + "preorderproduct_id" => $this->id, + "start_date" => null, + "end_date" => null, + ], "`create` DESC"); + } + + return $price; + } + + public function getCurrentRegularPrice($date = null, $allowCascading = false) { + if(!$date) $date = date("Y-m-d"); + + $price = PreorderProductPrice::getFirst([ + "netowner_id" => $this->filter_netowner_id, + "netoperator_id" => $this->filter_netoperator_id, + "campaign_id" => null, + "preorderproduct_id" => $this->id, + "start_date<=" => date($this->today_date), + "end_date" => null, + ], "start_date DESC, `create` DESC"); + + if(!$price && $allowCascading) { + $this->log->debug(__METHOD__.": Cascading to getFirstPrice()"); + return $this->getFirstPrice($date, true); + } + return $price; + } + + public function getCurrentPrice($date = null, $allowCascading = false) { + if(!$date) $date = date("Y-m-d"); + + $price = PreorderProductPrice::getFirst([ + "netowner_id" => $this->filter_netowner_id, + "netoperator_id" => $this->filter_netoperator_id, + "campaign_id" => null, + "preorderproduct_id" => $this->id, + "start_date<=" => date($this->today_date), + "end_date>" => date($this->today_date), + ], "start_date DESC, end_date ASC, `create` DESC"); + if(!$price) { + $price = PreorderProductPrice::getFirst([ + "netowner_id" => $this->filter_netowner_id, + "netoperator_id" => $this->filter_netoperator_id, + "campaign_id" => null, + "preorderproduct_id" => $this->id, + "start_date<=" => date($this->today_date), + "end_date" => null, + ], "start_date DESC, `create` DESC"); + } + if(!$price) { + $price = PreorderProductPrice::getFirst([ + "netowner_id" => $this->filter_netowner_id, + "netoperator_id" => $this->filter_netoperator_id, + "campaign_id" => null, + "preorderproduct_id" => $this->id, + "start_date" => null, + "end_date" => null, + ], "`create` DESC"); + } + + if(!$price && $allowCascading) { + $this->log->debug(__METHOD__.": Cascading to getCurrentRegularPrice()"); + return $this->getCurrentRegularPrice($date, true); + } + return $price; + } + + public function getPrice($date = null) { + if(!$date) $date = date("Y-m-d"); + + $this->log->debug("=== in ".__METHOD__); + $this->log->debug(__METHOD__.": TRY CURRENT PRICE"); + $price = $this->getCurrentPrice($date); + if(!$price) { + $this->log->debug(__METHOD__.": TRY CURRENT REGULAR PRICE"); + $price = $this->getCurrentRegularPrice($date); + } + if(!$price) { + $this->log->debug(__METHOD__.": TRY FIRST PRICE"); + $price = $this->getFirstPrice($date); + } + + if(!$price) { + $this->log->error(__METHOD__.": Unable to find price! netowner_id: ".$this->filter_netowner_id, " netoperator_id: ".$this->filter_netoperator_id." date: $date"); + return null; + } + $this->log->debug("=== done in ".__METHOD__); + return $price; + } + + public function getProperty($name) { if($this->$name == null) { @@ -46,9 +275,30 @@ class PreorderProduct extends mfBaseModel { } if($name == "first_price") { + if(!$this->today_date) $this->today_date = date("Y-m-d"); + + + } + + if($name == "current_regular_price") { + if(!$this->today_date) $this->today_date = date("Y-m-d"); + + + } + + if($name == "current_price") { + if(!$this->today_date) $this->today_date = date("Y-m-d"); + + + } + + if($name == "first_campaign_price") { + if(!$this->today_date) $this->today_date = date("Y-m-d"); + $price = PreorderProductPrice::getFirst([ "netowner_id" => $this->filter_netowner_id, "netoperator_id" => $this->filter_netoperator_id, + "campaign_id" => $this->filter_campaign_id, "preorderproduct_id" => $this->id, "start_date>=" => null, "end_date>" => null, @@ -56,66 +306,112 @@ class PreorderProduct extends mfBaseModel { if(!$price) { $price = PreorderProductPrice::getFirst([ "netowner_id" => $this->filter_netowner_id, + "netoperator_id" => $this->filter_netoperator_id, + "campaign_id" => null, + "preorderproduct_id" => $this->id, + "start_date>=" => null, + "end_date>" => null, + ], "`create` ASC"); + } + if(!$price) { + $price = PreorderProductPrice::getFirst([ + "netowner_id" => $this->filter_netowner_id, + "netoperator_id" => null, + "campaign_id" => null, "preorderproduct_id" => $this->id, "start_date>=" => null, "end_date>" => null, ], "`create` ASC"); } if($price) { - $this->current_price = $price; - return $this->current_price; + //$this->first_campaign_price = $price; + return $price; + //return $this->first_campaign_price; } return null; } - if($name == "current_regular_price") { + if($name == "current_campaign_regular_price") { + if(!$this->today_date) $this->today_date = date("Y-m-d"); + $price = PreorderProductPrice::getFirst([ "netowner_id" => $this->filter_netowner_id, "netoperator_id" => $this->filter_netoperator_id, + "campaign_id" => $this->filter_campaign_id, "preorderproduct_id" => $this->id, - "start_date<=" => date("Y-m-d"), + "start_date<=" => date($this->today_date), "end_date>" => null, ], "`create` ASC"); if($price) { - $this->current_price = $price; - return $this->current_price; + //$this->current_campaign_regular_price = $price; + return $price; + //return $this->current_campaign_regular_price; } else { - return $this->getProperty("first_price"); + return $this->getProperty("first_campaign_price"); } return null; } - if($name == "current_price") { + if($name == "current_campaign_price") { + if(!$this->today_date) $this->today_date = date("Y-m-d"); + $price = PreorderProductPrice::getFirst([ "netowner_id" => $this->filter_netowner_id, "netoperator_id" => $this->filter_netoperator_id, + "campaign_id" => $this->filter_campaign_id, "preorderproduct_id" => $this->id, - "start_date<=" => date("Y-m-d"), - "end_date>" => date("Y-m-d"), - ], "start_date"); + "start_date<=" => date($this->today_date), + "end_date>" => date($this->today_date), + ], "start_date DESC, end_date ASC, `create` DESC"); + if(!$price) { $price = PreorderProductPrice::getFirst([ "netowner_id" => $this->filter_netowner_id, "netoperator_id" => $this->filter_netoperator_id, + "campaign_id" => $this->filter_campaign_id, "preorderproduct_id" => $this->id, - "start_date<=" => date("Y-m-d"), + "start_date<=" => date($this->today_date), "end_date" => null, - ], "start_date"); + ], "start_date DESC, `create` DESC"); } + if(!$price) { $price = PreorderProductPrice::getFirst([ "netowner_id" => $this->filter_netowner_id, "netoperator_id" => $this->filter_netoperator_id, + "campaign_id" => $this->filter_campaign_id, "preorderproduct_id" => $this->id, "start_date" => null, "end_date" => null, - ], "start_date"); + ], "`create` DESC"); } + if(!$price) { + $price = PreorderProductPrice::getFirst([ + "netowner_id" => $this->filter_netowner_id, + "netoperator_id" => $this->filter_netoperator_id, + "campaign_id" => null, + "preorderproduct_id" => $this->id, + "start_date<=" => date($this->today_date), + "end_date>" => date($this->today_date), + ], "start_date DESC, end_date ASC, `create` DESC"); + } + + if(!$price) { + $price = PreorderProductPrice::getFirst([ + "netowner_id" => $this->filter_netowner_id, + "netoperator_id" => $this->filter_netoperator_id, + "campaign_id" => null, + "preorderproduct_id" => $this->id, + "start_date<=" => date($this->today_date), + "end_date" => null, + ], "start_date DESC, `create` DESC"); + } if($price) { - $this->current_price = $price; - return $this->current_price; + return $price; + } else { + return $this->getProperty("current_campaign_regular_price"); } return null; } @@ -168,6 +464,24 @@ class PreorderProduct extends mfBaseModel { } + public function __clone() { + $this->prices = null; + + $this->first_price = null; + $this->current_price = null; + $this->current_regular_price = null; + + $this->first_campaign_price = null; + $this->current_campaign_price = null; + $this->current_campaign_regular_price = null; + + $this->creator = null; + $this->editor = null; + //$this->filter_netoperator_id = null; + //$this->filter_netowner_id = null; + //$this->filter_campaign_id = null; + } + /******************************** * Begin static Model functions */ diff --git a/application/PreorderProduct/PreorderProductController.php b/application/PreorderProduct/PreorderProductController.php index e421c4413..18049b5e7 100644 --- a/application/PreorderProduct/PreorderProductController.php +++ b/application/PreorderProduct/PreorderProductController.php @@ -44,6 +44,16 @@ class PreorderProductController extends mfBaseController { } } + $campaigns = PreordercampaignModel::search(["owner_id" => $netowner_id]); + + $today_date = date("Y-m-d"); + + if($this->request->view_date) { + $today_date = $this->request->view_date; + } + + $this->layout()->set("today_date", $today_date); + $this->layout()->set("campaigns", $campaigns); $this->layout()->set("netoperators", $netoperators); $this->layout()->set("netowner", $netowner); } @@ -61,7 +71,7 @@ class PreorderProductController extends mfBaseController { $this->layout()->redirect("PreorderProduct"); } foreach($product_data as $product_id => $price_data) { - var_dump($price_data); + //var_dump($price_data);exit; $product = new PreorderProduct($product_id); if(!$product->id) { $this->layout()->setFlash("Produkt $product_id nicht gefunden", "error"); @@ -74,14 +84,23 @@ class PreorderProductController extends mfBaseController { "preorderproduct_id" => $product->id, "netoperator_id" => $netoperator_id, ]); - if($price_data["price_setup"]) $price->price_setup = $price_data["price_setup"]; + if($price_data["description"]) $price->description = trim($price_data["description"]); + + if($product->type == "operator_setup" || $product->type == "enduser_setup") { + if($price_data["price_setup"]) $price->price_setup = Layout::commaToDot(trim($price_data["price_setup"])); + } elseif($product->type == "operator_usage") { + if($price_data["price_inet"]) $price->price_inet = Layout::commaToDot(trim($price_data["price_inet"])); + if($price_data["price_inet_tv"]) $price->price_inet_tv = Layout::commaToDot(trim($price_data["price_inet_tv"])); + if($price_data["price_catv"]) $price->price_catv = Layout::commaToDot(trim($price_data["price_catv"])); + if($price_data["price_passive"]) $price->price_passive = Layout::commaToDot(trim($price_data["price_passive"])); + } if(!$price_data["start_date"]) { $this->layout()->setFlash("Von-datum fehlt bei Produkt '".$product->name."' für '".$netoperator->getCompanyOrName()."'", "error"); $this->redirect("PreorderProduct"); } else { try { - $start_date = new DateTime("@" . $this->dateToTimestamp($price_data["start_date"])); + $start_date = new DateTime("@" . $this->dateToTimestamp(trim($price_data["start_date"]))); $start_date->setTimezone(new DateTimeZone("Europe/Vienna")); $price->start_date = $start_date->format("Y-m-d"); } catch(Exception $e) { @@ -89,9 +108,9 @@ class PreorderProductController extends mfBaseController { $this->redirect("PreorderProduct"); } } - if($price_data["end_date"]) { + if(trim($price_data["end_date"])) { try { - $end_date = new DateTime("@" . $this->dateToTimestamp($price_data["end_date"])); + $end_date = new DateTime("@" . $this->dateToTimestamp(trim($price_data["end_date"]))); $end_date->setTimezone(new DateTimeZone("Europe/Vienna")); $price->end_date = $end_date->format("Y-m-d"); } catch(Exception $e) { @@ -100,11 +119,25 @@ class PreorderProductController extends mfBaseController { } } - //var_dump($product, $price); $price->save(); + + // create PreorderProductPriceCampaign for all submitted campaign_ids + foreach($price_data["campaigns"] as $campaign_id) { + $campaign = new Preordercampaign($campaign_id); + if(!$campaign->id) { + $this->layout()->setFlash("Ungültige Kampagne bei Produkt '".$product->name."' für '".$netoperator->getCompanyOrName()."'", "error"); + $this->layout()->redirect("PreorderProduct"); + } + $price_campaign = PreorderProductPriceCampaign::create([ + "preorderproductprice_id" => $price->id, + "preordercampaign_id" => $campaign->id, + ]); + $price_campaign->save(); + } } + } $this->layout()->setFlash("Neue Preise erflgreich gespeichert", "success"); diff --git a/application/PreorderProductPrice/PreorderProductPrice.php b/application/PreorderProductPrice/PreorderProductPrice.php index 91878175d..b6d1f244e 100644 --- a/application/PreorderProductPrice/PreorderProductPrice.php +++ b/application/PreorderProductPrice/PreorderProductPrice.php @@ -4,6 +4,7 @@ class PreorderProductPrice extends mfBaseModel { private $preorderprduct; private $netowner; private $preordercampaign; + private $campaigns; private $campaign; private $creator; private $editor; @@ -39,6 +40,19 @@ class PreorderProductPrice extends mfBaseModel { return $this->preordercampaign; } + if($name == "campaigns") { + $ccount = PreorderProductPriceCampaign::count(["preorderproductprice_id" => $this->id]); + $this->log->debug("Counted $ccount Campaigns for Price ".$this->id); + if(!$ccount) return []; + $this->campaigns = []; + foreach(PreorderProductPriceCampaign::search(["preorderproductprice_id" => $this->id]) as $pppc) { + $campaign = $pppc->campaign; + if(!$campaign || !$campaign->id) continue; + $this->campaigns[$campaign->id] = new PreorderCampaign($campaign->id); + } + return $this->campaigns; + } + if($name == "creator") { $creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by); @@ -97,7 +111,7 @@ class PreorderProductPrice extends mfBaseModel { $table_fields = [ "preorderproduct_id", "netowner_id", "netoperator_id", "preordercampaign_id", "description", "start_date", "end_date", "price_inet", "price_inet_tv", "price_catv", "price_passive", - "billing_delay", "billing_period", "contract_term", "note", + "billing_delay", "billing_period", "contract_term", "description", "note", "create_by","edit_by","create","edit" ]; @@ -125,7 +139,12 @@ class PreorderProductPrice extends mfBaseModel { $db = FronkDB::singleton(); - $res = $db->select("PreorderProductPrice", "*", "1 = 1 ORDER BY start_date"); + $sql = "SELECT PreorderProductPrice.* FROM PreorderProductPrice + LEFT OUTER JOIN (SELECT COUNT(*) as cnt, preorderproductprice_id, preordercampaign_id as preordercampaign_id FROM PreorderProductPriceCampaign GROUP BY PreorderProductPriceCampaign.preorderproductprice_id, PreorderProductPriceCampaign.preordercampaign_id) pppc ON PreorderProductPrice.id = pppc.preorderproductprice_id + GROUP BY PreorderProductPrice.id + ORDER BY start_date"; + + $res = $db->query($sql); if($db->num_rows($res)) { while($data = $db->fetch_object($res)) { $items[] = new PreorderProductPrice($data); @@ -143,8 +162,10 @@ class PreorderProductPrice extends mfBaseModel { } $where = self::getSqlFilter($filter); - $sql = "SELECT * FROM PreorderProductPrice - WHERE $where + $sql = "SELECT PreorderProductPrice.* FROM PreorderProductPrice + LEFT OUTER JOIN (SELECT COUNT(*) as cnt, preorderproductprice_id, preordercampaign_id as preordercampaign_id FROM PreorderProductPriceCampaign GROUP BY PreorderProductPriceCampaign.preorderproductprice_id, PreorderProductPriceCampaign.preordercampaign_id) pppc ON PreorderProductPrice.id = pppc.preorderproductprice_id + WHERE $where + GROUP BY PreorderProductPrice.id ORDER BY $order LIMIT 1"; mfLoghandler::singleton()->debug($sql); @@ -167,7 +188,9 @@ class PreorderProductPrice extends mfBaseModel { $where = self::getSqlFilter($filter); $sql = "SELECT COUNT(*) as cnt FROM PreorderProductPrice - WHERE $where"; + LEFT OUTER JOIN (SELECT COUNT(*) as cnt, preorderproductprice_id, preordercampaign_id as preordercampaign_id FROM PreorderProductPriceCampaign GROUP BY PreorderProductPriceCampaign.preorderproductprice_id, PreorderProductPriceCampaign.preordercampaign_id) pppc ON PreorderProductPrice.id = pppc.preorderproductprice_id + WHERE $where + GROUP BY PreorderProductPrice.id"; //mfLoghandler::singleton()->debug($sql); @@ -190,8 +213,10 @@ class PreorderProductPrice extends mfBaseModel { $db = FronkDB::singleton(); $where = self::getSqlFilter($filter); - $sql = "SELECT * FROM PreorderProductPrice + $sql = "SELECT PreorderProductPrice.* FROM PreorderProductPrice + LEFT OUTER JOIN (SELECT COUNT(*) as cnt, preorderproductprice_id, preordercampaign_id as preordercampaign_id FROM PreorderProductPriceCampaign GROUP BY PreorderProductPriceCampaign.preorderproductprice_id, PreorderProductPriceCampaign.preordercampaign_id) pppc ON PreorderProductPrice.id = pppc.preorderproductprice_id WHERE $where + GROUP BY PreorderProductPrice.id ORDER BY $order"; if(is_array($limit) && count($limit)) { @@ -233,15 +258,28 @@ class PreorderProductPrice extends mfBaseModel { if(array_key_exists("netoperator_id", $filter)) { $netoperator_id = $filter['netoperator_id']; - if(is_numeric($netoperator_id)) { + if($netoperator_id === null || $netoperator_id === false) { + $where .= " AND PreorderProductPrice.netoperator_id IS NULL"; + } elseif(is_numeric($netoperator_id)) { $where .= " AND PreorderProductPrice.netoperator_id=$netoperator_id"; } } if(array_key_exists("preordercampaign_id", $filter)) { $preordercampaign_id = $filter['preordercampaign_id']; - if(is_numeric($preordercampaign_id)) { - $where .= " AND PreorderProductPrice.preordercampaign_id=$preordercampaign_id"; + if($preordercampaign_id === null || $preordercampaign_id === false) { + $where .= " AND (pppc.cnt IS NULL OR pppc.cnt = 0)"; + } elseif(is_numeric($preordercampaign_id)) { + $where .= " AND pppc.preordercampaign_id=$preordercampaign_id"; + } + } + + if(array_key_exists("campaign_id", $filter)) { + $preordercampaign_id = $filter['campaign_id']; + if($preordercampaign_id === null || $preordercampaign_id === false) { + $where .= " AND (pppc.cnt IS NULL OR pppc.cnt = 0)"; + } elseif(is_numeric($preordercampaign_id)) { + $where .= " AND pppc.preordercampaign_id=$preordercampaign_id"; } } diff --git a/application/PreorderProductPriceCampaign/PreorderProductPriceCampaign.php b/application/PreorderProductPriceCampaign/PreorderProductPriceCampaign.php new file mode 100644 index 000000000..612f81fb7 --- /dev/null +++ b/application/PreorderProductPriceCampaign/PreorderProductPriceCampaign.php @@ -0,0 +1,253 @@ +$name == null) { + + if($name == "preorderproduct") { + $price = $this->getProperty("price"); + $product = $price->preorderproduct; + if(!$product || !$product->id) { + return null; + } + $this->preorderproduct = $product; + return $this->preorderproduct; + } + + if($name == "price") { + $price = new PreorderProductPrice($this->preorderproductprice_id); + if(!$price->id) { + return null; + } + $this->price = $price; + return $this->price; + } + + if($name == "netowner") { + $netowner = new Address($this->netowner_id); + if(!$netowner->id) { + return null; + } + $this->netowner = $netowner; + return $this->netowner; + } + + if($name == "preordercampaign" || $name == "campaign") { + $campaign = new PreorderCampaign($this->preordercampaign_id); + if(!$campaign->id) { + return null; + } + $this->preordercampaign = $campaign; + $this->campaign = $campaign; + return $this->preordercampaign; + } + + + if($name == "creator") { + $creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by); + if($creator) { + $this->creator = $creator; + return $this->creator; + } + $this->creator = new User($this->create_by); + + if(!$this->creator->id) { + return null; + } + mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator); + return $this->creator; + } + + if($name == "editor") { + $editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by); + if($editor) { + $this->editor = $editor; + return $this->editor; + } + $this->editor = new User($this->edit_by); + if(!$this->editor->id) { + return null; + } + mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor); + return $this->editor; + } + + $classname = ucfirst($name); + $idfield = $name . "_id"; + $this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-" . $this->$idfield); + if(!$this->$name) { + $this->$name = new $classname($this->$idfield); + } + + if($this->$name->id) { + mfValuecache::singleton()->set("mfObjectmodel-$name-" . $this->$name->id, $this->$name); + return $this->$name; + } else { + return null; + } + + } + return $this->$name; + } + + /******************************** + * Begin static Model functions + */ + + public static function create(Array $data) { + $model = new PreorderProductPriceCampaign(); + + $table_fields = [ + "preorderproductprice_id", "preordercampaign_id", + "create_by","edit_by","create","edit" + ]; + + foreach($data as $field => $value) { + if(in_array($field, $table_fields)) { + $model->$field = $value; + } + } + + $me = new User(); + $me->loadMe(); + + if($model->create_by === null) { + $model->create_by = $me->id; + } + if($model->edit_by === null) { + $model->edit_by = $me->id; + } + + return $model; + } + + public static function getAll() { + $items = []; + + $db = FronkDB::singleton(); + + $res = $db->select("PreorderProductPriceCampaign", "*", "1 = 1 ORDER BY preorderproductprice_id"); + if($db->num_rows($res)) { + while($data = $db->fetch_object($res)) { + $items[] = new PreorderProductPriceCampaign($data); + } + } + return $items; + + } + + public static function getFirst($filter = [], $order = false) { + $db = FronkDB::singleton(); + + if(!$order) { + $order = "preorderproductprice_id ASC"; + } + + $where = self::getSqlFilter($filter); + $sql = "SELECT * FROM PreorderProductPriceCampaign + WHERE $where + ORDER BY $order LIMIT 1"; + + mfLoghandler::singleton()->debug($sql); + + $res = $db->query($sql); + if($db->num_rows($res)) { + $data = $db->fetch_object($res); + $item = new PreorderProductPriceCampaign($data); + if($item->id) { + return $item; + } else { + return null; + } + } + return null; + } + + public static function count($filter) { + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $sql = "SELECT COUNT(*) as cnt FROM PreorderProductPriceCampaign + WHERE $where"; + + mfLoghandler::singleton()->debug($sql); + + $res = $db->query($sql); + if($db->num_rows($res)) { + $data = $db->fetch_object($res); + return $data->cnt; + } + return 0; + } + + public static function search($filter, $limit = false, $order = false) { + //var_dump($filter);exit; + $items = []; + + if(!$order) { + $order = "preorderproductprice_id ASC"; + } + + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $sql = "SELECT * FROM PreorderProductPriceCampaign + WHERE $where + ORDER BY $order"; + + if(is_array($limit) && count($limit)) { + if(is_numeric($limit['start']) && is_numeric($limit['count'])) { + $sql .= " LIMIT ".$limit['start'].", ".$limit['count']; + } elseif(is_numeric($limit['count'])) { + $sql .= " LIMIT ".$limit['count']; + } + } + + mfLoghandler::singleton()->debug($sql); + + $res = $db->query($sql); + if($db->num_rows($res)) { + while($data = $db->fetch_object($res)) { + $items[$data->id] = new PreorderProductPriceCampaign($data); + } + } + + return $items; + } + + private static function getSqlFilter($filter) { + $where = "1=1 "; + + if(array_key_exists("preordercampaign_id", $filter)) { + $preordercampaign_id = $filter['preordercampaign_id']; + if(is_numeric($preordercampaign_id)) { + $where .= " AND PreorderProductPriceCampaign.preordercampaign_id=$preordercampaign_id"; + } + } + + if(array_key_exists("preorderproductprice_id", $filter)) { + $preorderproductprice_id = $filter['preorderproductprice_id']; + if(is_numeric($preorderproductprice_id)) { + $where .= " AND PreorderProductPriceCampaign.preorderproductprice_id=$preorderproductprice_id"; + } + } + + + + + if(array_key_exists("add-where", $filter)) { + $where .= " ".$filter['add-where']; + } + + //var_dump($filter, $where);exit; + return $where; + } + +} \ No newline at end of file diff --git a/db/migrations/20250217133744_preorder_product_change.php b/db/migrations/20250217133744_preorder_product_change.php index 914c3f574..9390cb078 100644 --- a/db/migrations/20250217133744_preorder_product_change.php +++ b/db/migrations/20250217133744_preorder_product_change.php @@ -9,13 +9,13 @@ final class PreorderProductChange extends AbstractMigration { if($this->getEnvironment() == "thetool") { $pp = $this->table("PreorderProduct"); - //$pp->changeColumn("type", "enum", ["null" => false, "values" => "enduser_setup, operator_setup, operator_usage"]); - //$pp->addColumn("price_setup", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4, "after" => "vatgroup_id"]); + $pp->changeColumn("type", "enum", ["null" => false, "values" => "enduser_setup, operator_setup, operator_usage"]); + $pp->addColumn("price_setup", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4, "after" => "vatgroup_id"]); $pp->update(); $ppp = $this->table("PreorderProductPrice"); $ppp->addColumn("netoperator_id", "integer", ["null" => false, "after" => "netowner_id"]); - //$ppp->addColumn("price_setup", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4, "after" => "end_date"]); + $ppp->addColumn("price_setup", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4, "after" => "end_date"]); $ppp->update(); } @@ -27,7 +27,16 @@ final class PreorderProductChange extends AbstractMigration public function down(): void { if($this->getEnvironment() == "thetool") { - + $pp = $this->table("PreorderProduct"); + $pp->changeColumn("type", "enum", ["null" => false, "values" => "enduser_setup, provider_setup, provider_usage"]); + $pp->removeColumn("price_setup"); + $pp->update(); + + $ppp = $this->table("PreorderProductPrice"); + $ppp->removeColumn("netoperator_id"); + $ppp->removeColumn("price_setup"); + //$ppp->removeColumn("description"); + $ppp->update(); } if($this->getEnvironment() == "addressdb") { diff --git a/db/migrations/20250218141907_preorder_product_change_2.php b/db/migrations/20250218141907_preorder_product_change_2.php new file mode 100644 index 000000000..e2688b9c4 --- /dev/null +++ b/db/migrations/20250218141907_preorder_product_change_2.php @@ -0,0 +1,35 @@ +getEnvironment() == "thetool") { + $ppp = $this->table("PreorderProductPrice"); + $ppp->changeColumn("netoperator_id", "integer", ["null" => true]); + $ppp->addColumn("description", "text", ["null" => true, "default" => null, "after" => "contract_term"]); + $ppp->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + $ppp = $this->table("PreorderProductPrice"); + $ppp->removeColumn("description"); + $ppp->changeColumn("netoperator_id", "integer", ["null" => false]); + $ppp->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } +} diff --git a/db/migrations/20250218144547_create_preorder_product_price_campaign.php b/db/migrations/20250218144547_create_preorder_product_price_campaign.php new file mode 100644 index 000000000..49876450d --- /dev/null +++ b/db/migrations/20250218144547_create_preorder_product_price_campaign.php @@ -0,0 +1,44 @@ +getEnvironment() == "thetool") { + $pppc = $this->table("PreorderProductPriceCampaign"); + $pppc->addColumn("preorderproductprice_id", "integer", ["null" => false]); + $pppc->addColumn("preordercampaign_id", "integer", ["null" => false]); + + $pppc->addColumn("create_by", "integer", ["null" => false]); + $pppc->addColumn("edit_by", "integer", ["null" => false]); + $pppc->addColumn("create", "integer", ["null" => false]); + $pppc->addColumn("edit", "integer", ["null" => false]); + $pppc->create(); + + $ppp = $this->table("PreorderProductPrice"); + $ppp->removeColumn("preordercampaign_id"); + $ppp->save(); + + + } + + if($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + $this->table("PreorderProductPriceCampaign")->drop()->save(); + $this->table("PreorderProductPrice")->addColumn("preordercampaign_id", "integer", ["null" => true, "default" => null, "after" => "netowner_id"])->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } +} From 236932d45269fc8f846ed899c514badc59d2daab Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Tue, 25 Feb 2025 13:45:23 +0100 Subject: [PATCH 4/6] WIP PreorderProduct 2025-02-24 --- Layout/default/PreorderProduct/Index.php | 19 ++ .../include/netoperator-prices-usage.php | 117 +++++----- .../PreorderProduct/include/prices-setup.php | 4 +- .../PreorderProductController.php | 19 ++ .../PreorderProductMarketshareDiscount.php | 204 ++++++++++++++++++ .../PreorderProductPrice.php | 8 + ...250218141907_preorder_product_change_2.php | 1 - ...r_product_marketshare_discount_bracket.php | 43 ++++ 8 files changed, 355 insertions(+), 60 deletions(-) create mode 100644 application/PreorderProductMarketshareDiscount/PreorderProductMarketshareDiscount.php create mode 100644 db/migrations/20250224124143_preorder_product_marketshare_discount_bracket.php diff --git a/Layout/default/PreorderProduct/Index.php b/Layout/default/PreorderProduct/Index.php index 249ba29d9..ffc68c5c8 100644 --- a/Layout/default/PreorderProduct/Index.php +++ b/Layout/default/PreorderProduct/Index.php @@ -139,7 +139,26 @@ } else { $(selector + " i.collapse-indicator").removeClass(itype + "-down").addClass(itype + "-right"); } + } + function priceToMarketshare(netop_id, product_id, type) { + console.log(netop_id, product_id, type); + + let price = $("#price-" + type + "-" + netop_id + "-" + product_id).val(); + console.log(price); + if(!price.length) return; + + $("#marketshare-0-" + netop_id + "-" + product_id + "-" + type).val(price); + } + + function marketshareToPrice(netop_id, product_id, type) { + console.log(netop_id, product_id, type); + + let price = $("#marketshare-0-" + netop_id + "-" + product_id + "-" + type).val(); + console.log(price); + if(!price.length) return; + + $("#price-" + type + "-" + netop_id + "-" + product_id).val(price); } diff --git a/Layout/default/PreorderProduct/include/netoperator-prices-usage.php b/Layout/default/PreorderProduct/include/netoperator-prices-usage.php index 12d4df175..84a501791 100644 --- a/Layout/default/PreorderProduct/include/netoperator-prices-usage.php +++ b/Layout/default/PreorderProduct/include/netoperator-prices-usage.php @@ -9,7 +9,7 @@ ?>
-
+
">
@@ -72,7 +72,7 @@
- +
@@ -81,7 +81,7 @@
- +
@@ -90,7 +90,7 @@
- +
@@ -99,7 +99,7 @@
- +
@@ -131,7 +131,7 @@ Mit Gültig-Bis-Datum gilt der neue Preis bis einschließlich dem Gültig-Bis-Datum, danach gilt der vorige Preis wieder. -
+ -

Netzdurchdringung

+

Netzdurchdringung

Rabattierte Preise für das Erreichen on Netzdurchdringungszielen

-

0 - 15% ist der Standardpreis. Falls keine Netzdurchdringung

+

0 - 15% ist der Standardpreis

@@ -161,46 +161,46 @@ - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + +
ZielPassive
0 - 15%
15,01% - 20%
20,01% - 25%
25,01% - 30%
30,01% - 35%
35,01% - 40%
40,01% - 45%
@@ -223,7 +223,7 @@ $current_regular_price = $product->getCurrentRegularPrice($today_date, true); $first_price = $product->getFirstPrice($today_date); ?> -
+

Aktuelle Preise für getTodayDate()?>

@@ -270,33 +270,36 @@
-

Preis Pro Kampagne

+

Preise Netzdurchdringung

+ +
Heute gültige Preise
+ Gültig von: start_date) ? (new DateTime($current_price->start_date))->format("d.m.Y") : ""?>
+ Gültig bis: end_date) ? (new DateTime($current_price->end_date))->format("d.m.Y") : ""?> - + - - - - - - getCampaignPrice($campaign->id, $today_date); ?> - - - - - - - - - - - + + + + + + + + marketsharediscounts as $bracket => $discount): ?> + + + + + + + +
KampagneGruppe INET INET+TV CATV PassiveGültig vonGültig bisBeschreibung
name?>price_inet, 2, ",", ".")?>price_inet_tv, 2, ",", ".")?>price_catv, 2, ",", ".")?>price_passive, 2, ",", ".")?>start_date) ? (new DateTime($cprice->start_date))->format("d.m.Y") : "-"?>end_date) ? (new DateTime($cprice->end_date))->format("d.m.Y") : "-"?>description?>getTodayDate()?>
0 - 15%price_inet?>price_inet_tv?>price_catv?>price_passive?>
% - %price_inet?>price_inet_tv?>price_catv?>price_passive?>
diff --git a/Layout/default/PreorderProduct/include/prices-setup.php b/Layout/default/PreorderProduct/include/prices-setup.php index 232703823..c808caee3 100644 --- a/Layout/default/PreorderProduct/include/prices-setup.php +++ b/Layout/default/PreorderProduct/include/prices-setup.php @@ -9,7 +9,7 @@ ?>
-
+
">
@@ -130,7 +130,7 @@ $current_regular_price = $product->getCurrentRegularPrice($today_date, true); $first_price = $product->getFirstPrice($today_date); ?> -
+

Aktuelle Preise für getTodayDate()?>

diff --git a/application/PreorderProduct/PreorderProductController.php b/application/PreorderProduct/PreorderProductController.php index 18049b5e7..970fdbbed 100644 --- a/application/PreorderProduct/PreorderProductController.php +++ b/application/PreorderProduct/PreorderProductController.php @@ -123,6 +123,25 @@ class PreorderProductController extends mfBaseController { $price->save(); + // marketshare prices + if(array_key_exists("marketshareprice", $price_data) && is_array($price_data["marketshareprice"])) { + foreach($price_data["marketshareprice"] as $msbracket => $msprice) { + if(!is_numeric($msbracket)) continue; + if(!$msbracket) continue; // dont save 0 + + $msp = PreorderProductMarketshareDiscount::create([ + "preorderproductprice_id" => $price->id, + "bracket" => $msbracket, + "price_inet" => Layout::commaToDot(trim($msprice["inet"])), + "price_inet_tv" => Layout::commaToDot(trim($msprice["inet_tv"])), + "price_catv" => Layout::commaToDot(trim($msprice["catv"])), + "price_passive" => Layout::commaToDot(trim($msprice["passive"])), + ]); + $msp->save(); + + } + } + // create PreorderProductPriceCampaign for all submitted campaign_ids foreach($price_data["campaigns"] as $campaign_id) { $campaign = new Preordercampaign($campaign_id); diff --git a/application/PreorderProductMarketshareDiscount/PreorderProductMarketshareDiscount.php b/application/PreorderProductMarketshareDiscount/PreorderProductMarketshareDiscount.php new file mode 100644 index 000000000..37992bfeb --- /dev/null +++ b/application/PreorderProductMarketshareDiscount/PreorderProductMarketshareDiscount.php @@ -0,0 +1,204 @@ +$name == null) { + + if($name == "creator") { + $creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by); + if($creator) { + $this->creator = $creator; + return $this->creator; + } + $this->creator = new User($this->create_by); + + if(!$this->creator->id) { + return null; + } + mfValuecache::singleton()->set("Worker-id-".$this->create_by, $this->creator); + return $this->creator; + } + + if($name == "editor") { + $editor = mfValuecache::singleton()->get("Worker-id-".$this->edit_by); + if($editor) { + $this->editor = $editor; + return $this->editor; + } + $this->editor = new User($this->edit_by); + if(!$this->editor->id) { + return null; + } + mfValuecache::singleton()->set("Worker-id-".$this->edit_by, $this->editor); + return $this->editor; + } + + $classname = ucfirst($name); + $idfield = $name . "_id"; + $this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-" . $this->$idfield); + if(!$this->$name) { + $this->$name = new $classname($this->$idfield); + } + + if($this->$name->id) { + mfValuecache::singleton()->set("mfObjectmodel-$name-" . $this->$name->id, $this->$name); + return $this->$name; + } else { + return null; + } + } + + return $this->$name; + + } + + /******************************** + * Begin static Model functions + */ + + public static function create(Array $data) { + $model = new PreorderProductMarketshareDiscount(); + + $table_fields = [ + "preorderproductprice_id", "bracket", "price_inet", "price_inet_tv", "price_catv", "price_passive", + "create_by","edit_by","create","edit" + ]; + + foreach($data as $field => $value) { + if(in_array($field, $table_fields)) { + $model->$field = $value; + } + } + + $me = new User(); + $me->loadMe(); + + if($model->create_by === null) { + $model->create_by = $me->id; + } + if($model->edit_by === null) { + $model->edit_by = $me->id; + } + + return $model; + } + + public static function getAll() { + $items = []; + + $db = FronkDB::singleton(); + + $res = $db->select("PreorderProductMarketshareDiscount", "*", "1 = 1 ORDER BY preorderproductprice_id,bracket"); + if($db->num_rows($res)) { + while($data = $db->fetch_object($res)) { + $items[] = new PreorderProductMarketshareDiscount($data); + } + } + return $items; + + } + + public static function getFirst($filter) { + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $sql = "SELECT * FROM PreorderProductMarketshareDiscount + WHERE $where + ORDER BY preorderproductprice_id,bracket LIMIT 1"; + //var_dump($sql);exit; + $res = $db->query($sql); + if($db->num_rows($res)) { + $data = $db->fetch_object($res); + $item = new PreorderProductMarketshareDiscount($data); + if($item->id) { + return $item; + } else { + return null; + } + } + return null; + } + + public static function count($filter) { + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $sql = "SELECT COUNT(*) as cnt FROM PreorderProductMarketshareDiscount + WHERE $where"; + + //mfLoghandler::singleton()->debug($sql); + + $res = $db->query($sql); + if($db->num_rows($res)) { + $data = $db->fetch_object($res); + return $data->cnt; + } + return 0; + } + + public static function search($filter, $limit = false, $order = false) { + //var_dump($filter);exit; + $items = []; + + if(!$order) { + $order = "preorderproductprice_id ASC, bracket ASC"; + } + + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $sql = "SELECT * FROM PreorderProductMarketshareDiscount + WHERE $where + ORDER BY $order"; + + if(is_array($limit) && count($limit)) { + if(is_numeric($limit['start']) && is_numeric($limit['count'])) { + $sql .= " LIMIT ".$limit['start'].", ".$limit['count']; + } elseif(is_numeric($limit['count'])) { + $sql .= " LIMIT ".$limit['count']; + } + } + + mfLoghandler::singleton()->debug($sql); + + $res = $db->query($sql); + if($db->num_rows($res)) { + while($data = $db->fetch_object($res)) { + $items[$data->id] = new PreorderProductMarketshareDiscount($data); + } + } + + return $items; + } + + private static function getSqlFilter($filter) { + $where = "1=1 "; + + if(array_key_exists("preorderproductprice_id", $filter)) { + $preorderproductprice_id = $filter['preorderproductprice_id']; + if(is_numeric($preorderproductprice_id)) { + $where .= " AND PreorderProductMarketshareDiscount.preorderproductprice_id=$preorderproductprice_id"; + } + } + + if(array_key_exists("bracket", $filter)) { + $bracket = $filter['bracket']; + if(is_numeric($bracket)) { + $where .= " AND PreorderProductMarketshareDiscount.bracket=$bracket"; + } + } + + + if(array_key_exists("add-where", $filter)) { + $where .= " ".$filter['add-where']; + } + + //var_dump($filter, $where);exit; + return $where; + } + +} \ No newline at end of file diff --git a/application/PreorderProductPrice/PreorderProductPrice.php b/application/PreorderProductPrice/PreorderProductPrice.php index b6d1f244e..a7e1a0e4c 100644 --- a/application/PreorderProductPrice/PreorderProductPrice.php +++ b/application/PreorderProductPrice/PreorderProductPrice.php @@ -6,6 +6,7 @@ class PreorderProductPrice extends mfBaseModel { private $preordercampaign; private $campaigns; private $campaign; + private $marketsharediscounts; private $creator; private $editor; @@ -53,6 +54,13 @@ class PreorderProductPrice extends mfBaseModel { return $this->campaigns; } + if($name == "marketsharediscounts") { + if(!PreorderProductMarketshareDiscount::count(["preorderproductprice_id" => $this->id])) return []; + foreach(PreorderProductMarketshareDiscount::search(["preorderproductprice_id" => $this->id]) as $discount) { + $this->marketsharediscounts[$discount->bracket] = $discount; + } + return $this->marketsharediscounts; + } if($name == "creator") { $creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by); diff --git a/db/migrations/20250218141907_preorder_product_change_2.php b/db/migrations/20250218141907_preorder_product_change_2.php index e2688b9c4..dc6341f61 100644 --- a/db/migrations/20250218141907_preorder_product_change_2.php +++ b/db/migrations/20250218141907_preorder_product_change_2.php @@ -10,7 +10,6 @@ final class PreorderProductChange2 extends AbstractMigration if($this->getEnvironment() == "thetool") { $ppp = $this->table("PreorderProductPrice"); $ppp->changeColumn("netoperator_id", "integer", ["null" => true]); - $ppp->addColumn("description", "text", ["null" => true, "default" => null, "after" => "contract_term"]); $ppp->update(); } diff --git a/db/migrations/20250224124143_preorder_product_marketshare_discount_bracket.php b/db/migrations/20250224124143_preorder_product_marketshare_discount_bracket.php new file mode 100644 index 000000000..b61c8d51f --- /dev/null +++ b/db/migrations/20250224124143_preorder_product_marketshare_discount_bracket.php @@ -0,0 +1,43 @@ +getEnvironment() == "thetool") { + $ppmsd = $this->table("PreorderProductMarketshareDiscount"); + $ppmsd->addColumn("bracket", "integer", ["null" => false, "after" => "preorderproductprice_id"]); + $ppmsd->addColumn("price_inet", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4, "after" => "bracket"]); + $ppmsd->addColumn("price_inet_tv", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4, "after" => "price_inet"]); + $ppmsd->addColumn("price_catv", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4, "after" => "price_inet_tv"]); + $ppmsd->addColumn("price_passive", "decimal", ["null" => false, "default" => 0, "precision" => 14, "scale" => 4, "after" => "price_catv"]); + $ppmsd->removeColumn("price_15"); + $ppmsd->removeColumn("price_20"); + $ppmsd->removeColumn("price_25"); + $ppmsd->removeColumn("price_30"); + $ppmsd->removeColumn("price_35"); + $ppmsd->removeColumn("price_40"); + $ppmsd->removeColumn("price_45"); + $ppmsd->removeColumn("price_50"); + $ppmsd->save(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + + } + + if($this->getEnvironment() == "addressdb") { + + } + } +} From 11b1357c520a055dbaed3fbebc2acc56e2ece677 Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Tue, 25 Feb 2025 20:33:47 +0100 Subject: [PATCH 5/6] Added Preorderbilling permissions --- Layout/default/PreorderProduct/Index.php | 62 +- .../include/netoperator-prices-usage.php | 185 ++-- .../PreorderProduct/include/prices-setup.php | 133 ++- Layout/default/User/Form.php | 831 ++++++++++-------- Layout/default/menu.php | 55 +- .../PreorderProductController.php | 14 +- application/User/UserController.php | 4 + ...151428_add_preorderbilling_permissions.php | 37 + public/assets/css/thetool.css | 4 + 9 files changed, 768 insertions(+), 557 deletions(-) create mode 100644 db/migrations/20250225151428_add_preorderbilling_permissions.php diff --git a/Layout/default/PreorderProduct/Index.php b/Layout/default/PreorderProduct/Index.php index ffc68c5c8..06bbc571a 100644 --- a/Layout/default/PreorderProduct/Index.php +++ b/Layout/default/PreorderProduct/Index.php @@ -12,7 +12,7 @@
-

Preise

+

Kampagnenmanagement Preise

@@ -26,7 +26,7 @@
-

Preise

+

Kampagnenmanagement Preise

@@ -49,24 +49,36 @@
- - -

getCompanyOrName()?> (id?>)

-
-
-

Produkte

+ + +
+ +
" id="netop-id?>" role="tabpanel"> +
+
+ +

Produkte für Netzbetreiber getCompanyOrName()?>

setNetoperatorId($netoperator->id) ?> setTodayDate($today_date); ?> id, $product->prices)) ? $product->prices[$netoperator->id] : false; ?> -
+

- Preiseinstellungen für name?> + name?>

@@ -79,17 +91,13 @@
- - - - - - + +
- - + +
@@ -162,5 +170,23 @@ } + $(document).ready(() => { + + var hash = window.location.hash.substring(1); + var match = hash.match(/product-(\d+)(?:-(\d)+)?/); + console.log(match); + if(match && typeof match[1] !== 'undefined') { + var netop = match[1]; + + console.log('$("#netop-' + netop + '-tab").tab("show");'); + $("#netop-" + netop + "-tab").tab('show'); + if(typeof match[2] !== 'undefined') { + let prod_id = match[2]; + $("#price-detail-" + netop + "-" + prod_id).collapse('toggle'); + } + + } + }); + \ No newline at end of file diff --git a/Layout/default/PreorderProduct/include/netoperator-prices-usage.php b/Layout/default/PreorderProduct/include/netoperator-prices-usage.php index 84a501791..361fbaa32 100644 --- a/Layout/default/PreorderProduct/include/netoperator-prices-usage.php +++ b/Layout/default/PreorderProduct/include/netoperator-prices-usage.php @@ -8,7 +8,95 @@ */ ?> -
+
+ getCurrentPrice($today_date, true); + $current_regular_price = $product->getCurrentRegularPrice($today_date, true); + $first_price = $product->getFirstPrice($today_date); + ?> +
+
+
+

Aktuelle Preise für getTodayDate()?>

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
INETINET+TVCATVPassive
Heute gültiger Preisprice_inet, 2, ",", ".")?>price_inet_tv, 2, ",", ".")?>price_catv, 2, ",", ".")?>price_passive, 2, ",", ".")?> + description?> + end_date): ?> + bis end_date))->format("d.m.Y")?> + +
Derzeit regulärer Preisprice_inet, 2, ",", ".")?>price_inet_tv, 2, ",", ".")?>price_catv, 2, ",", ".")?>price_passive, 2, ",", ".")?>description?>
Initialpreisprice_inet, 2, ",", ".")?>price_inet_tv, 2, ",", ".")?>price_catv, 2, ",", ".")?>price_passive, 2, ",", ".")?>
+ +
+
+ +
+
+

Preise Netzdurchdringung

+ +
Heute gültige Preise
+ Gültig von: start_date) ? (new DateTime($current_price->start_date))->format("d.m.Y") : ""?>
+ Gültig bis: end_date) ? (new DateTime($current_price->end_date))->format("d.m.Y") : ""?> + + + + + + + + + + + + + + + + marketsharediscounts as $bracket => $discount): ?> + + + + + + + + + +
GruppeINETINET+TVCATVPassive
0 - 15%price_inet?>price_inet_tv?>price_catv?>price_passive?>
% - %price_inet?>price_inet_tv?>price_catv?>price_passive?>
+
+
+ +
+
"> @@ -39,7 +127,7 @@ end_date) ? (new DateTime($line->end_date))->format("d.m.Y") : "-"?> campaigns) && count($line->campaigns)) ? count($line->campaigns) : ""?> description?> - creator->name?> + create)?>">creator->name?> @@ -213,97 +301,6 @@
-
- - - - - getCurrentPrice($today_date, true); - $current_regular_price = $product->getCurrentRegularPrice($today_date, true); - $first_price = $product->getFirstPrice($today_date); - ?> -
-
-
-

Aktuelle Preise für getTodayDate()?>

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
INETINET+TVCATVPassive
Heute gültiger Preisprice_inet, 2, ",", ".")?>price_inet_tv, 2, ",", ".")?>price_catv, 2, ",", ".")?>price_passive, 2, ",", ".")?> - description?> - end_date): ?> - bis end_date))->format("d.m.Y")?> - -
Derzeit regulärer Preisprice_inet, 2, ",", ".")?>price_inet_tv, 2, ",", ".")?>price_catv, 2, ",", ".")?>price_passive, 2, ",", ".")?>description?>
Initialpreisprice_inet, 2, ",", ".")?>price_inet_tv, 2, ",", ".")?>price_catv, 2, ",", ".")?>price_passive, 2, ",", ".")?>
- -
-
- -
-
-

Preise Netzdurchdringung

- -
Heute gültige Preise
- Gültig von: start_date) ? (new DateTime($current_price->start_date))->format("d.m.Y") : ""?>
- Gültig bis: end_date) ? (new DateTime($current_price->end_date))->format("d.m.Y") : ""?> - - - - - - - - - - - - - - - - marketsharediscounts as $bracket => $discount): ?> - - - - - - - - - -
GruppeINETINET+TVCATVPassive
0 - 15%price_inet?>price_inet_tv?>price_catv?>price_passive?>
% - %price_inet?>price_inet_tv?>price_catv?>price_passive?>
-
-
- -
+
\ No newline at end of file diff --git a/Layout/default/PreorderProduct/include/prices-setup.php b/Layout/default/PreorderProduct/include/prices-setup.php index c808caee3..8ed2c69be 100644 --- a/Layout/default/PreorderProduct/include/prices-setup.php +++ b/Layout/default/PreorderProduct/include/prices-setup.php @@ -8,8 +8,69 @@ */ ?> -
-
+
+ getCurrentPrice($today_date, true); + $current_regular_price = $product->getCurrentRegularPrice($today_date, true); + $first_price = $product->getFirstPrice($today_date); + ?> +
+
+
+

Aktuelle Preise für getTodayDate()?>

+ + + + + + + + + + + + + + +
Heute gültiger Preisprice_setup, 2, ",", ".")?> + description?> + end_date): ?> + bis end_date))->format("d.m.Y")?> + +
Derzeit regulärer Preisprice_setup, 2, ",", ".")?>description?>
Initialpreis price_setup, 2, ",", ".")?>
+ +
+
+ +
+
+

Preis Pro Kampagne

+ + + + + + + + + + + getCampaignPrice($campaign->id, $today_date); ?> + + + + + + + + + +
KampagnePreisGültig vonGültig bisBeschreibung
name?>price_setup, 2, ",", ".")?>start_date) ? (new DateTime($cprice->start_date))->format("d.m.Y") : "-"?>end_date) ? (new DateTime($cprice->end_date))->format("d.m.Y") : "-"?>description?>getTodayDate()?>
+
+
+ +
+
">
@@ -33,7 +94,7 @@ end_date) ? (new DateTime($line->end_date))->format("d.m.Y") : "-"?> campaigns) && count($line->campaigns)) ? count($line->campaigns) : ""?> description?> - creator->name?> + create)?>">creator->name?> @@ -121,70 +182,4 @@
- - - - - getCurrentPrice($today_date, true); - $current_regular_price = $product->getCurrentRegularPrice($today_date, true); - $first_price = $product->getFirstPrice($today_date); - ?> -
-
-
-

Aktuelle Preise für getTodayDate()?>

- - - - - - - - - - - - - - -
Heute gültiger Preisprice_setup, 2, ",", ".")?> - description?> - end_date): ?> - bis end_date))->format("d.m.Y")?> - -
Derzeit regulärer Preisprice_setup, 2, ",", ".")?>description?>
Initialpreis price_setup, 2, ",", ".")?>
- -
-
- -
-
-

Preis Pro Kampagne

- - - - - - - - - - - getCampaignPrice($campaign->id, $today_date); ?> - - - - - - - - - -
KampagnePreisGültig vonGültig bisBeschreibung
name?>price_setup, 2, ",", ".")?>start_date) ? (new DateTime($cprice->start_date))->format("d.m.Y") : "-"?>end_date) ? (new DateTime($cprice->end_date))->format("d.m.Y") : "-"?>description?>getTodayDate()?>
-
-
- -
-
diff --git a/Layout/default/User/Form.php b/Layout/default/User/Form.php index 6626590de..4060ad1f2 100644 --- a/Layout/default/User/Form.php +++ b/Layout/default/User/Form.php @@ -1,377 +1,516 @@ - +
-
-
-
- -
-

Benutzer

+
+
+
+ +
+

Benutzer

+
-
- -
-
-
-
-

Benutzer bearbeiten

+
"> + +
+
+
+
+

Benutzer bearbeiten

+
+
- "> - -
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
- - -
-
" id="employee-number-container"> - - value() : ""?>" /> -
-
" id="project-api-key-container"> - - value() : ""?>" /> -
-
- - -
-
- - -
- -
- - - z.B. Meridiam -
- -
- - -
- -
- - -
-
- - -
- -
- -
- - -
- -
- -

Beschränkungen

- -
- - id) { - $pns = json_decode((new WorkerFlag($user->id,"preorder_networks"))->value()); - if(!$pns) { - $pns = []; - } - } - - ?> - - Beschränkt Benutzer auf Netzgebiete. Überschreibt Netzgebiete der Firma. Wenn leer werden Netzgebiete der Firma angezeigt -
-
- - -
+ +
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
" + id="employee-number-container"> + + value() : ""?>"/> +
+
" + id="project-api-key-container"> + + value() : ""?>"/> +
-
- -

Modulberechtigungen

- -
-
-
- can("Building")) ? "checked='checked'" : ""?> /> - -
-
-
-
- can("Pipework") ? "checked='checked'" : ""?> /> - -
-
-
-
- can("Linework") ? "checked='checked'" : ""?> /> - -
-
-
-
-
-
- can("Patching") ? "checked='checked'" : ""?> /> - -
-
-
-
- can("Filestore") ? "checked='checked'" : ""?> /> - -
-
-
-
- can("Cpeprovisioning") ? "checked='checked'" : ""?> /> - -
-
-
-
-
-
- can("Cpeshipping") ? "checked='checked'" : ""?> /> - -
-
-
-
- can("Voipnumbering") ? "checked='checked'" : ""?> /> - -
-
-
-
- can("Preorder") ? "checked='checked'" : ""?> /> - -
-
-
-
-
-
- can("Order") ? "checked='checked'" : ""?> /> - -
-
-
-
- can("Billing") ? "checked='checked'" : ""?> /> - -
-
-
-

Lager

+
+ + +
+
+ + +
-
-
-
- can("WarehouseAdmin")) ? "checked='checked'" : ""?> /> - +
+ +
+ + +
+
-
-
-
- can("WarehouseUser")) ? "checked='checked'" : ""?> /> - +
+
+ +

Preorder

+ +
+ + +
+ +
+ + + z.B. Meridiam +
+ +
+ + +
+ +
+ + id) { + $pns = json_decode((new WorkerFlag($user->id, "preorder_networks"))->value()); + if(!$pns) { + $pns = []; + } + } + + ?> + + Beschränkt Benutzer auf Netzgebiete. Überschreibt Netzgebiete der Firma. Wenn + leer werden Netzgebiete der Firma angezeigt +
+ +
+ + +
+ +

Preorder Module

+
+
+
+ can("Preorderpricing")) ? "checked='checked'" : ""?> /> + +
+
+ can("PreorderpricingReadonly") ? "checked='checked'" : ""?> /> + +
+
+
+
+ can("Preorderbilling")) ? "checked='checked'" : ""?> /> + +
+
+ can("PreorderbillingReadonly") ? "checked='checked'" : ""?> /> + +
+
+
+
-
+
+
+ +

Modulberechtigungen

+ +
+
+
+ can("Building")) ? "checked='checked'" : ""?> /> + +
+
+
+
+ can("Pipework") ? "checked='checked'" : ""?> /> + +
+
+
+
+ can("Linework") ? "checked='checked'" : ""?> /> + +
+
+
+
+
+
+ can("Patching") ? "checked='checked'" : ""?> /> + +
+
+
+
+ can("Filestore") ? "checked='checked'" : ""?> /> + +
+
+
+
+ can("Cpeprovisioning") ? "checked='checked'" : ""?> /> + +
+
+
+
+
+
+ can("Cpeshipping") ? "checked='checked'" : ""?> /> + +
+
+
+
+ can("Voipnumbering") ? "checked='checked'" : ""?> /> + +
+
+
+
+ can("Preorder") ? "checked='checked'" : ""?> /> + +
+
+
+
+
+
+ can("Order") ? "checked='checked'" : ""?> /> + +
+
+
+
+ can("Billing") ? "checked='checked'" : ""?> /> + +
+
+
+ +

Lager

+ +
+
+
+ can("WarehouseAdmin")) ? "checked='checked'" : ""?> /> + +
+
+ +
+
+ can("WarehouseUser")) ? "checked='checked'" : ""?> /> + +
+
+ +
+
+ can("WarehouseEShop")) ? "checked='checked'" : ""?> /> + +
+
+
+ +

Zusatzberechtigungen

+ +
+
+
+ can("Fibu")) ? "checked='checked'" : ""?> /> + +
+
+ +
+
+ can("Statistics")) ? "checked='checked'" : ""?> /> + +
+
+
+ +
+ +
+ +
+ +
-
-
- can("WarehouseEShop")) ? "checked='checked'" : ""?> /> -
- -

Zusatzberechtigungen

- -
-
-
- can("Fibu")) ? "checked='checked'" : ""?> /> - -
-
- -
-
- can("Statistics")) ? "checked='checked'" : ""?> /> - -
-
- -
- -
- -
- -
-
-
-
- - id): ?> + + +id): ?>
-
-
-
-

API Key

-
-
-
- -
-
-
"> - - apikey): ?> - - - - -
-
+
+
+
+

API Key

+
+
+
+ +
+
+
"> + + apikey): ?> + + + + -
+
+
+ +
-
- - + + + \ No newline at end of file diff --git a/Layout/default/menu.php b/Layout/default/menu.php index 4ac0041c7..b2a321c0f 100644 --- a/Layout/default/menu.php +++ b/Layout/default/menu.php @@ -59,40 +59,40 @@ - is(["Admin"])): ?> + is(["Admin", "netowner", "salespartner"]) && ($me->is("employee") || $me->can(["Fibu", "Billing", "Preorderpricing", "Preorderbilling"]))): ?>
  • Backoffice
    @@ -102,11 +102,21 @@ can('Fibu')): ?>
  • "> Kalender Verwaltung
  • "> Contracts
  • is(["Admin"]) && $me->can("Billing")): ?>
  • "> Contract Queue
  • -
  • "> Erweiterte Suche
  • is(["Admin"]) && $me->can("Billing")): ?>
  • "> Verrechnung
  • is(["Admin"]) && $me->can("Billing")): ?>
  • "> Rechnungen
  • is(["Admin"]) && $me->can("Billing")): ?>
  • "> Historische Rechnungen
  • - is(["Admin"])): ?>
  • "> Emailaussendung
  • + + is(["Admin","netowner","salespartner"]) && $me->can("Preorderpricing")): ?> +
  • "> Vorbestellkampagnen Bepreisung
  • + + is(["Admin","netowner","salespartner"]) && $me->can("Preorderbilling")): ?> +
  • "> Vorbestellkampagnen Verrechnung
  • + + is(["Admin","netowner","salespartner"]) && in_array($me->address_id, [1,209,5908,2187])): ?> +
  • "> Zustimmungserklärungen
  • + + + is(["Admin"])): ?>
  • "> Emailaussendungen
  • @@ -196,14 +206,13 @@ diff --git a/application/PreorderProduct/PreorderProductController.php b/application/PreorderProduct/PreorderProductController.php index 970fdbbed..b91695625 100644 --- a/application/PreorderProduct/PreorderProductController.php +++ b/application/PreorderProduct/PreorderProductController.php @@ -67,7 +67,7 @@ class PreorderProductController extends mfBaseController { foreach($r->netoperators as $netoperator_id => $product_data) { $netoperator = new Address($netoperator_id); if(!$netoperator->id) { - $this->layout()->setFlash("Betzbetreiber nicht gefunden", "error"); + $this->layout()->setFlash("Netzbetreiber nicht gefunden", "error"); $this->layout()->redirect("PreorderProduct"); } foreach($product_data as $product_id => $price_data) { @@ -75,7 +75,7 @@ class PreorderProductController extends mfBaseController { $product = new PreorderProduct($product_id); if(!$product->id) { $this->layout()->setFlash("Produkt $product_id nicht gefunden", "error"); - $this->layout()->redirect("PreorderProduct"); + $this->layout()->redirect("PreorderProduct","",[], "product-".$netoperator_id); } // create new PreorderProductPrice @@ -97,7 +97,7 @@ class PreorderProductController extends mfBaseController { if(!$price_data["start_date"]) { $this->layout()->setFlash("Von-datum fehlt bei Produkt '".$product->name."' für '".$netoperator->getCompanyOrName()."'", "error"); - $this->redirect("PreorderProduct"); + $this->redirect("PreorderProduct","",[], "product-".$netoperator_id."-".$product_id); } else { try { $start_date = new DateTime("@" . $this->dateToTimestamp(trim($price_data["start_date"]))); @@ -105,7 +105,7 @@ class PreorderProductController extends mfBaseController { $price->start_date = $start_date->format("Y-m-d"); } catch(Exception $e) { $this->layout()->setFlash("Fehler im Von-datum bei Produkt '".$product->name."' für '".$netoperator->getCompanyOrName()."'", "error"); - $this->redirect("PreorderProduct"); + $this->redirect("PreorderProduct","",[], "product-".$netoperator_id."-".$product_id); } } if(trim($price_data["end_date"])) { @@ -115,7 +115,7 @@ class PreorderProductController extends mfBaseController { $price->end_date = $end_date->format("Y-m-d"); } catch(Exception $e) { $this->layout()->setFlash("Fehler im Bis-Datum bei Produkt '".$product->name."' für '".$netoperator->getCompanyOrName()."'", "error"); - $this->redirect("PreorderProduct"); + $this->redirect("PreorderProduct","",[], "product-".$netoperator_id."-".$product_id); } } @@ -147,7 +147,7 @@ class PreorderProductController extends mfBaseController { $campaign = new Preordercampaign($campaign_id); if(!$campaign->id) { $this->layout()->setFlash("Ungültige Kampagne bei Produkt '".$product->name."' für '".$netoperator->getCompanyOrName()."'", "error"); - $this->layout()->redirect("PreorderProduct"); + $this->layout()->redirect("PreorderProduct","",[], "product-".$netoperator_id."-".$product_id); } $price_campaign = PreorderProductPriceCampaign::create([ "preorderproductprice_id" => $price->id, @@ -160,7 +160,7 @@ class PreorderProductController extends mfBaseController { } $this->layout()->setFlash("Neue Preise erflgreich gespeichert", "success"); - $this->redirect("PreorderProduct"); + $this->redirect("PreorderProduct","",[], "product-".$netoperator_id."-".$product_id); } } \ No newline at end of file diff --git a/application/User/UserController.php b/application/User/UserController.php index 5d61ef44d..8b7a1a2fb 100644 --- a/application/User/UserController.php +++ b/application/User/UserController.php @@ -242,6 +242,10 @@ class UserController extends mfBaseController $user->permissions->canCpeshipping = "false"; $user->permissions->canVoipnumbering = "false"; $user->permissions->canPreorder = "false"; + $user->permissions->canPreorderpricing = "false"; + $user->permissions->canPreorderpricingReadonly = "false"; + $user->permissions->canPreorderbilling = "false"; + $user->permissions->canPreorderbillingReadonly = "false"; $user->permissions->canOrder = "false"; $user->permissions->canBilling = "false"; $user->permissions->canFibu = "false"; diff --git a/db/migrations/20250225151428_add_preorderbilling_permissions.php b/db/migrations/20250225151428_add_preorderbilling_permissions.php new file mode 100644 index 000000000..a0fcc041a --- /dev/null +++ b/db/migrations/20250225151428_add_preorderbilling_permissions.php @@ -0,0 +1,37 @@ +getEnvironment() == "thetool") { + $table = $this->table("WorkerPermission"); + $table->addColumn("canPreorderpricing", "enum", ["values" => 'false,true', "default" => "false", "after" => "canPreorder"]); + $table->addColumn("canPreorderpricingReadonly", "enum", ["values" => 'false,true', "default" => "false", "after" => "canPreorderpricing"]); + $table->addColumn("canPreorderbilling", "enum", ["values" => 'false,true', "default" => "false", "after" => "canPreorderpricingReadonly"]); + $table->addColumn("canPreorderbillingReadonly", "enum", ["values" => 'false,true', "default" => "false", "after" => "canPreorderbilling"]); + $table->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } + + public function down(): void + { + if($this->getEnvironment() == "thetool") { + $this->table("WorkerPermission")->removeColumn("canPreorderpricing")->update(); + $this->table("WorkerPermission")->removeColumn("canPreorderpricingReadonly")->update(); + $this->table("WorkerPermission")->removeColumn("canPreorderbilling")->update(); + $this->table("WorkerPermission")->removeColumn("canPreorderbillingReadonly")->update(); + } + + if($this->getEnvironment() == "addressdb") { + + } + } +} diff --git a/public/assets/css/thetool.css b/public/assets/css/thetool.css index 49edbc532..d15ae87d5 100644 --- a/public/assets/css/thetool.css +++ b/public/assets/css/thetool.css @@ -203,6 +203,10 @@ h1, h2, h3, h4, h5, h6 { border-bottom: 1px solid #eee; } +.submenu .border-top { + border-top: 1px solid #eee !important; +} + .sub-submenu { padding-left: 12px !important; } From a7a4f05f1f426fabecc8bd02e116b09503f458cf Mon Sep 17 00:00:00 2001 From: Frank Schubert Date: Wed, 26 Feb 2025 15:29:00 +0100 Subject: [PATCH 6/6] added home trench to Borderpoint image in ConstructionConsent --- Layout/default/ConstructionConsent/Form.php | 8 +++++++- .../ConstructionConsent/ConstructionConsent.php | 4 ++-- .../ConstructionConsentController.php | 14 +++++++++++++- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Layout/default/ConstructionConsent/Form.php b/Layout/default/ConstructionConsent/Form.php index 93c7b43ce..df597d02e 100644 --- a/Layout/default/ConstructionConsent/Form.php +++ b/Layout/default/ConstructionConsent/Form.php @@ -331,10 +331,16 @@ if(!$("#plan_adb_hausnummer_id").val()) return; var building_id = $('#plan_adb_hausnummer_id').val(); + var type = $("#object_type").val(); // get plan image preview try { - var response = await fetch(' "getRimoPlanPreview"])?>&building_id=' + building_id); + var response; + if(type == "building" ) { + response = await fetch(' "getRimoPlanPreview"])?>&building_id=' + building_id + '&include_home_trench=1'); + } else { + response = await fetch(' "getRimoPlanPreview"])?>&building_id=' + building_id); + } if (!response.ok) { return false; } diff --git a/application/ConstructionConsent/ConstructionConsent.php b/application/ConstructionConsent/ConstructionConsent.php index 70882420b..4d71d4e3b 100644 --- a/application/ConstructionConsent/ConstructionConsent.php +++ b/application/ConstructionConsent/ConstructionConsent.php @@ -411,8 +411,8 @@ class ConstructionConsent extends mfBaseModel { END AS status_light FROM ConstructionConsent LEFT JOIN ConstructionConsentOwner cwo ON ConstructionConsent.id = cwo.constructionconsent_id - LEFT JOIN addressdb.view_hausnummer vh ON ConstructionConsent.adb_hausnummer_id = vh.hausnummer_id - LEFT JOIN addressdb.Strasse vs ON ConstructionConsent.adb_strasse_id = vs.id + LEFT JOIN `".ADDRESSDB_DBNAME."`.view_hausnummer vh ON ConstructionConsent.adb_hausnummer_id = vh.hausnummer_id + LEFT JOIN `".ADDRESSDB_DBNAME."`.Strasse vs ON ConstructionConsent.adb_strasse_id = vs.id WHERE $where GROUP BY ConstructionConsent.id $having diff --git a/application/ConstructionConsent/ConstructionConsentController.php b/application/ConstructionConsent/ConstructionConsentController.php index e416c3c19..1411cab87 100644 --- a/application/ConstructionConsent/ConstructionConsentController.php +++ b/application/ConstructionConsent/ConstructionConsentController.php @@ -766,6 +766,7 @@ class ConstructionConsentController extends mfBaseController { private function getRimoPlanPreviewApi() { $adb_hausnummer_id = $this->request->building_id; + $include_home_trench = $this->request->include_home_trench ? true : false; $hausnummer = new ADBHausnummer($adb_hausnummer_id); if(!$hausnummer->id) { @@ -849,7 +850,18 @@ class ConstructionConsentController extends mfBaseController { ]; if($hausnummer->trenches) { - $trenches = json_decode($hausnummer->trenches); + $trenches = []; + if($include_home_trench && $hausnummer->home_trench) { + $trenches = [json_decode($hausnummer->home_trench)]; + } + + $street_trenches = json_decode($hausnummer->trenches); + foreach($street_trenches as $t) { + if(is_array($t) && count($t)) { + $trenches[] = $t; + } + } + $this->log->debug(print_r($trenches, true)); $params["paths"] = [ "line_width" => 5,