WIP PreorderProduct 2025-02-17
This commit is contained in:
@@ -1,180 +1,5 @@
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/menu.php"); ?>
|
||||
|
||||
<div class="container">
|
||||
<h1 class="mt-5">Preorder Product Management</h1>
|
||||
|
||||
<h2 class="mt-4">Create Preorder</h2>
|
||||
<form id="createPreorderForm" class="mb-4">
|
||||
<div class="form-group">
|
||||
<label for="rimo_service_id">Rimo Service ID:</label>
|
||||
<input type="number" class="form-control" id="rimo_service_id" name="rimo_service_id">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Create Preorder</button>
|
||||
</form>
|
||||
|
||||
<h2 class="mt-4">Create Preorder Product</h2>
|
||||
<form id="createPreorderProductForm" class="mb-4">
|
||||
<div class="form-group">
|
||||
<label for="type">Type:</label>
|
||||
<select class="form-control" id="type" name="type">
|
||||
<option value="enduser_setup">Enduser Setup</option>
|
||||
<option value="provider_setup">Provider Setup</option>
|
||||
<option value="provider_usage">Provider Usage</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="name">Name:</label>
|
||||
<input type="text" class="form-control" id="name" name="name">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="vatgroup_id">VAT Group ID:</label>
|
||||
<input type="number" class="form-control" id="vatgroup_id" name="vatgroup_id">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="price_inet">Price Inet:</label>
|
||||
<input type="number" step="0.0001" class="form-control" id="price_inet" name="price_inet">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="price_inet_tv">Price Inet TV:</label>
|
||||
<input type="number" step="0.0001" class="form-control" id="price_inet_tv" name="price_inet_tv">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="price_catv">Price CATV:</label>
|
||||
<input type="number" step="0.0001" class="form-control" id="price_catv" name="price_catv">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="price_passive">Price Passive:</label>
|
||||
<input type="number" step="0.0001" class="form-control" id="price_passive" name="price_passive">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="create_by">Created By:</label>
|
||||
<input type="number" class="form-control" id="create_by" name="create_by">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="edit_by">Edited By:</label>
|
||||
<input type="number" class="form-control" id="edit_by" name="edit_by">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Create Preorder Product</button>
|
||||
</form>
|
||||
|
||||
<h2 class="mt-4">Create Preorder Product Price</h2>
|
||||
<form id="createPreorderProductPriceForm" class="mb-4">
|
||||
<div class="form-group">
|
||||
<label for="preorderproduct_id">Preorder Product ID:</label>
|
||||
<input type="number" class="form-control" id="preorderproduct_id" name="preorderproduct_id">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="netowner_id">Netowner ID:</label>
|
||||
<input type="number" class="form-control" id="netowner_id" name="netowner_id">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="preordercampaign_id">Preorder Campaign ID:</label>
|
||||
<input type="number" class="form-control" id="preordercampaign_id" name="preordercampaign_id">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="description">Description:</label>
|
||||
<textarea class="form-control" id="description" name="description"></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="start_date">Start Date:</label>
|
||||
<input type="date" class="form-control" id="start_date" name="start_date">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="end_date">End Date:</label>
|
||||
<input type="date" class="form-control" id="end_date" name="end_date">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="price_inet">Price Inet:</label>
|
||||
<input type="number" step="0.0001" class="form-control" id="price_inet" name="price_inet">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="price_inet_tv">Price Inet TV:</label>
|
||||
<input type="number" step="0.0001" class="form-control" id="price_inet_tv" name="price_inet_tv">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="price_catv">Price CATV:</label>
|
||||
<input type="number" step="0.0001" class="form-control" id="price_catv" name="price_catv">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="price_passive">Price Passive:</label>
|
||||
<input type="number" step="0.0001" class="form-control" id="price_passive" name="price_passive">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="billing_delay">Billing Delay:</label>
|
||||
<input type="number" class="form-control" id="billing_delay" name="billing_delay">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="billing_period">Billing Period:</label>
|
||||
<input type="number" class="form-control" id="billing_period" name="billing_period">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="contract_term">Contract Term:</label>
|
||||
<input type="number" class="form-control" id="contract_term" name="contract_term">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="note">Note:</label>
|
||||
<textarea class="form-control" id="note" name="note"></textarea>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="create_by">Created By:</label>
|
||||
<input type="number" class="form-control" id="create_by" name="create_by">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="edit_by">Edited By:</label>
|
||||
<input type="number" class="form-control" id="edit_by" name="edit_by">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Create Preorder Product Price</button>
|
||||
</form>
|
||||
|
||||
<h2 class="mt-4">Create Preorder Product Marketshare Discount</h2>
|
||||
<form id="createPreorderProductMarketshareDiscountForm" class="mb-4">
|
||||
<div class="form-group">
|
||||
<label for="preorderproductprice_id">Preorder Product Price ID:</label>
|
||||
<input type="number" class="form-control" id="preorderproductprice_id" name="preorderproductprice_id">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="price_15">Price 15%:</label>
|
||||
<input type="number" step="0.0001" class="form-control" id="price_15" name="price_15">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="price_20">Price 20%:</label>
|
||||
<input type="number" step="0.0001" class="form-control" id="price_20" name="price_20">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="price_25">Price 25%:</label>
|
||||
<input type="number" step="0.0001" class="form-control" id="price_25" name="price_25">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="price_30">Price 30%:</label>
|
||||
<input type="number" step="0.0001" class="form-control" id="price_30" name="price_30">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="price_35">Price 35%:</label>
|
||||
<input type="number" step="0.0001" class="form-control" id="price_35" name="price_35">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="price_40">Price 40%:</label>
|
||||
<input type="number" step="0.0001" class="form-control" id="price_40" name="price_40">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="price_45">Price 45%:</label>
|
||||
<input type="number" step="0.0001" class="form-control" id="price_45" name="price_45">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="price_50">Price 50%:</label>
|
||||
<input type="number" step="0.0001" class="form-control" id="price_50" name="price_50">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="create_by">Created By:</label>
|
||||
<input type="number" class="form-control" id="create_by" name="create_by">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="edit_by">Edited By:</label>
|
||||
<input type="number" class="form-control" id="edit_by" name="edit_by">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Create Preorder Product Marketshare Discount</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
87
Layout/default/PreorderProduct/Index.php
Normal file
87
Layout/default/PreorderProduct/Index.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/header.php"); ?>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="page-title-box">
|
||||
<div class="page-title-right">
|
||||
<ol class="breadcrumb m-0">
|
||||
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Dashboard")?>"><?=MFAPPNAME_SLUG?></a></li>
|
||||
<li class="breadcrumb-item"><a href="<?=self::getUrl("Preordercampaign")?>">Vorbestellkampagnen</a></li>
|
||||
<li class="breadcrumb-item active">Bepreisung</li>
|
||||
</ol>
|
||||
</div>
|
||||
<h4 class="page-title">Preise</h4>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end page title -->
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body mb-3 bg-light">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h4 class="header-title">Preise</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<?php foreach($netoperators as $netoperator): // TODO: Netoperators als Tabs anzeigen ?>
|
||||
<h4><span class="text-pink"><?=$netoperator->getCompanyOrName()?> (<?=$netoperator->id?>)</span></h4>
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<form method="post" action="<?=self::getUrl("PreorderProduct", "save")?>">
|
||||
<h4>Produkte</h4>
|
||||
<?php foreach($products as $product): ?>
|
||||
<?php $product->setNetoperatorId($netoperator->id) ?>
|
||||
<?php $prices = (array_key_exists($netoperator->id, $product->prices)) ? $product->prices[$netoperator->id] : false; ?>
|
||||
<?php //var_dump($prices); ?>
|
||||
<div class="card">
|
||||
<div class="card-body mb-3">
|
||||
<h4>Preiseinstellungen für <?=$product->name?></h4>
|
||||
<?php if($product->type == "operator_setup"): ?>
|
||||
<?php include(__DIR__."/include/netoperator-prices-setup.php"); ?>
|
||||
<?php elseif($product->type == "enduser_setup"): ?>
|
||||
<?php include(__DIR__."/include/enduser-prices-setup.php"); ?>
|
||||
<?php elseif($product->type == "operatr_usage"): ?>
|
||||
<?php include(__DIR__."/include/netoperator-prices-usage.php"); ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<?php endforeach; ?>
|
||||
|
||||
<input type="submit" class="btn btn-primary mt-2" value="Speichern" />
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$('.datepicker').datepicker({
|
||||
language: 'de',
|
||||
format: "dd.mm.yyyy",
|
||||
showWeekDays: true,
|
||||
todayBtn: 'linked',
|
||||
autoclose: true
|
||||
});
|
||||
</script>
|
||||
<?php include(realpath(dirname(__FILE__)."/../../$mfLayoutPackage")."/footer.php"); ?>
|
||||
@@ -0,0 +1 @@
|
||||
<?php
|
||||
@@ -0,0 +1,82 @@
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
Derzeit gültiger Preis: <strong><?=$product->current_price->price_setup?></strong>
|
||||
<?php if($product->current_price->end_date): ?>
|
||||
(bis <?=(new DateTime($product->current_price->end_date))->format("d.m.Y")?>)
|
||||
<?php endif; ?>
|
||||
<br />
|
||||
Derzeit regulärer Preis: <strong><?=$product->current_regular_price->price_setup?></strong><br />
|
||||
Originalpreis: <?=$product->first_price->price_setup?>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<button type="button" class="btn btn-outline-success" onclick='$("#pricehistory-<?=$netoperator->id?>-<?=$product->id?>").toggle()'><i class="fas fa-fw fa-list"></i> Preishistory anzeigen</button>
|
||||
</div>
|
||||
|
||||
<div class="row hidden" id="pricehistory-<?=$netoperator->id?>-<?=$product->id?>">
|
||||
<table class="table table-sm table-striped table-hover">
|
||||
<tr>
|
||||
<th>Preis</th>
|
||||
<th>Gültig von</th>
|
||||
<th>Gültig bis</th>
|
||||
|
||||
</tr>
|
||||
<?php foreach(PreorderProductPrice::search(["netowner_id" => $netowner->id,"preorderproduct_id" => $product->id, "netoperator_id" => $netoperator->id]) as $line): ?>
|
||||
<tr>
|
||||
<td><?=$line->price_setup?></td>
|
||||
<td><?=($line->start_date) ? (new DateTime($line->start_date))->format("d.m.Y") : "-"?></td>
|
||||
<td><?=($line->end_date) ? (new DateTime($line->end_date))->format("d.m.Y") : "-"?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<h4>Neuer Preis</h4>
|
||||
<div class="form-group">
|
||||
<label>Bereitstellungsentgelt</label>
|
||||
<div class="input-group mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">€</span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][price_setup]" value="" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Neuer Preis Gültigkeit</label>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="input-group mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">Preis gültig von</span>
|
||||
</div>
|
||||
<input type="text" class="form-control datepicker" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][start_date]" value="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-6">
|
||||
<div class="input-group mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text">Preis gültig bis</span>
|
||||
</div>
|
||||
<input type="text" class="form-control datepicker" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][end_date]" value="" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<small>
|
||||
Ohne <strong>Gültig-Bis-Datum</strong> gilt der neue Preis für immer, bis ein neuer Preis eingetragen wird.<br />
|
||||
Mit <strong>Gültig-Bis-Datum</strong> gilt der neue Preis bis einschließlich dem <strong>Gültig-Bis-Datum</strong>, danach gilt der vorige Preis wieder.
|
||||
</small>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1 @@
|
||||
<?php
|
||||
@@ -107,7 +107,11 @@ class PreorderModel {
|
||||
return $model;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function createFromRimoWorkorder($workorder) {
|
||||
|
||||
}
|
||||
|
||||
public static function getAll() {
|
||||
$items = [];
|
||||
|
||||
|
||||
@@ -1,24 +1,125 @@
|
||||
<?php
|
||||
|
||||
class PreorderProduct extends mfBaseModel {
|
||||
private $preorder;
|
||||
private $createor;
|
||||
private $filter_netowner_id;
|
||||
private $filter_netoperator_id;
|
||||
private $prices;
|
||||
private $first_price;
|
||||
private $current_price;
|
||||
private $current_regular_price;
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
protected static $types = ["operator_setup", "enduser_setup", "operator_usage"];
|
||||
|
||||
|
||||
|
||||
public function setNetownerId($netowner_id) {
|
||||
if(!$netowner_id) {
|
||||
$this->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";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
|
||||
}
|
||||
}
|
||||
335
application/PreorderProductPrice/PreorderProductPrice.php
Normal file
335
application/PreorderProductPrice/PreorderProductPrice.php
Normal file
@@ -0,0 +1,335 @@
|
||||
<?php
|
||||
|
||||
class PreorderProductPrice extends mfBaseModel {
|
||||
private $preorderprduct;
|
||||
private $netowner;
|
||||
private $preordercampaign;
|
||||
private $campaign;
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$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;
|
||||
}
|
||||
|
||||
}
|
||||
86
db/migrations/20250129155121_create_preorder_product.php
Normal file
86
db/migrations/20250129155121_create_preorder_product.php
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class CreatePreorderProduct extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if($this->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") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
37
db/migrations/20250217133744_preorder_product_change.php
Normal file
37
db/migrations/20250217133744_preorder_product_change.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class PreorderProductChange extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
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->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") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user