WIP PreorderPrice 2025-02-21
This commit is contained in:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user