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/Layout/default/PreorderProduct/Index.php b/Layout/default/PreorderProduct/Index.php new file mode 100644 index 000000000..06bbc571a --- /dev/null +++ b/Layout/default/PreorderProduct/Index.php @@ -0,0 +1,192 @@ + + + +
+
+
+
+ +
+

Kampagnenmanagement Preise

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

Kampagnenmanagement Preise

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

Produkte für Netzbetreiber getCompanyOrName()?>

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

+ name?> +

+
+
+ type == "operator_setup"): ?> + + type == "enduser_setup"): ?> + + type == "operator_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 @@ + + +
+ 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?>
+
+
+ +
+ +
+
"> + +
+ +
+ + + + + + +
+
+

+ 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. +
+ + + +

Netzdurchdringung

+
+
+

Rabattierte Preise für das Erreichen on Netzdurchdringungszielen

+

0 - 15% ist der Standardpreis

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
ZielINETINET+TVCATVPassive
0 - 15%
15,01% - 20%
20,01% - 25%
25,01% - 30%
30,01% - 35%
35,01% - 40%
40,01% - 45%
+
+
+ +
+ +
+
+
+ + +
+
\ No newline at end of file diff --git a/Layout/default/PreorderProduct/include/prices-setup.php b/Layout/default/PreorderProduct/include/prices-setup.php new file mode 100644 index 000000000..8ed2c69be --- /dev/null +++ b/Layout/default/PreorderProduct/include/prices-setup.php @@ -0,0 +1,185 @@ + + +
+ 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()?>
+
+
+ +
+
+
"> + +
+ +
+ + + + + + +
+
+

+ 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. + +
+
+
+ +
+ +
+
+
+ +
+
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/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, diff --git a/application/Preorder/PreorderModel.php b/application/Preorder/PreorderModel.php index a14989916..0992ad40a 100644 --- a/application/Preorder/PreorderModel.php +++ b/application/Preorder/PreorderModel.php @@ -107,7 +107,11 @@ class PreorderModel { return $model; } - + + public function createFromRimoWorkorder($workorder) { + + } + public static function getAll() { $items = []; diff --git a/application/PreorderProduct/PreorderProduct.php b/application/PreorderProduct/PreorderProduct.php new file mode 100644 index 000000000..432126f5b --- /dev/null +++ b/application/PreorderProduct/PreorderProduct.php @@ -0,0 +1,734 @@ +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 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) { + + 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; + } + return []; + } + + 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, + ], "`create` ASC"); + 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->first_campaign_price = $price; + return $price; + //return $this->first_campaign_price; + } + return null; + } + + 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($this->today_date), + "end_date>" => null, + ], "`create` ASC"); + + if($price) { + //$this->current_campaign_regular_price = $price; + return $price; + //return $this->current_campaign_regular_price; + } else { + return $this->getProperty("first_campaign_price"); + } + return null; + } + + 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($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($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" => $this->filter_campaign_id, + "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" => $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) { + return $price; + } else { + return $this->getProperty("current_campaign_regular_price"); + } + return 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; + + } + + 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 + */ + + public static function create(Array $data) { + $model = new PreorderProduct(); + + $table_fields = [ + "type", "name", "vatgroup_id", "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 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("PreorderProduct", "*", "1 = 1 ORDER BY type"); + if($db->num_rows($res)) { + while($data = $db->fetch_object($res)) { + $items[] = new PreorderProduct($data); + } + } + return $items; + + } + + public static function getFirst($filter) { + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $sql = "SELECT * FROM PreorderProduct + WHERE $where + 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 PreorderProduct($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 PreorderProduct + 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 = "type ASC"; + } + + $db = FronkDB::singleton(); + + $where = self::getSqlFilter($filter); + $sql = "SELECT * FROM PreorderProduct + 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 PreorderProduct($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 PreorderProduct.preorderProductproject_id=$project_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 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 PreorderProduct.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..b91695625 --- /dev/null +++ b/application/PreorderProduct/PreorderProductController.php @@ -0,0 +1,166 @@ +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"); + + $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; + } + } + } + } + + $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); + } + + 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("Netzbetreiber nicht gefunden", "error"); + $this->layout()->redirect("PreorderProduct"); + } + foreach($product_data as $product_id => $price_data) { + //var_dump($price_data);exit; + $product = new PreorderProduct($product_id); + if(!$product->id) { + $this->layout()->setFlash("Produkt $product_id nicht gefunden", "error"); + $this->layout()->redirect("PreorderProduct","",[], "product-".$netoperator_id); + } + + // create new PreorderProductPrice + $price = PreorderProductPrice::create([ + "netowner_id" => $netowner_id, + "preorderproduct_id" => $product->id, + "netoperator_id" => $netoperator_id, + ]); + 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","",[], "product-".$netoperator_id."-".$product_id); + } else { + try { + $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) { + $this->layout()->setFlash("Fehler im Von-datum bei Produkt '".$product->name."' für '".$netoperator->getCompanyOrName()."'", "error"); + $this->redirect("PreorderProduct","",[], "product-".$netoperator_id."-".$product_id); + } + } + if(trim($price_data["end_date"])) { + try { + $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) { + $this->layout()->setFlash("Fehler im Bis-Datum bei Produkt '".$product->name."' für '".$netoperator->getCompanyOrName()."'", "error"); + $this->redirect("PreorderProduct","",[], "product-".$netoperator_id."-".$product_id); + } + } + + //var_dump($product, $price); + + $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); + if(!$campaign->id) { + $this->layout()->setFlash("Ungültige Kampagne bei Produkt '".$product->name."' für '".$netoperator->getCompanyOrName()."'", "error"); + $this->layout()->redirect("PreorderProduct","",[], "product-".$netoperator_id."-".$product_id); + } + $price_campaign = PreorderProductPriceCampaign::create([ + "preorderproductprice_id" => $price->id, + "preordercampaign_id" => $campaign->id, + ]); + $price_campaign->save(); + } + } + + } + + $this->layout()->setFlash("Neue Preise erflgreich gespeichert", "success"); + $this->redirect("PreorderProduct","",[], "product-".$netoperator_id."-".$product_id); + + } +} \ No newline at end of file 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 new file mode 100644 index 000000000..a7e1a0e4c --- /dev/null +++ b/application/PreorderProductPrice/PreorderProductPrice.php @@ -0,0 +1,381 @@ +$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 == "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 == "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); + 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", "description", "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(); + + $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); + } + } + return $items; + + } + + public static function getFirst($filter = [], $order = false) { + $db = FronkDB::singleton(); + + if(!$order) { + $order = "start_date ASC"; + } + + $where = self::getSqlFilter($filter); + $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); + + $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 + 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); + + $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 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)) { + 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($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($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"; + } + } + + + 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/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/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/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..9390cb078 --- /dev/null +++ b/db/migrations/20250217133744_preorder_product_change.php @@ -0,0 +1,46 @@ +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") { + $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..dc6341f61 --- /dev/null +++ b/db/migrations/20250218141907_preorder_product_change_2.php @@ -0,0 +1,34 @@ +getEnvironment() == "thetool") { + $ppp = $this->table("PreorderProductPrice"); + $ppp->changeColumn("netoperator_id", "integer", ["null" => true]); + $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") { + + } + } +} 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") { + + } + } +} 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 dd26c87b8..eda6f6491 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; }