Aktuelle Preise für =$product->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") {
+
+ }
+ }
+}