WIP PreorderProduct 2025-02-24
This commit is contained in:
@@ -139,7 +139,26 @@
|
||||
} else {
|
||||
$(selector + " i.collapse-indicator").removeClass(itype + "-down").addClass(itype + "-right");
|
||||
}
|
||||
}
|
||||
|
||||
function priceToMarketshare(netop_id, product_id, type) {
|
||||
console.log(netop_id, product_id, type);
|
||||
|
||||
let price = $("#price-" + type + "-" + netop_id + "-" + product_id).val();
|
||||
console.log(price);
|
||||
if(!price.length) return;
|
||||
|
||||
$("#marketshare-0-" + netop_id + "-" + product_id + "-" + type).val(price);
|
||||
}
|
||||
|
||||
function marketshareToPrice(netop_id, product_id, type) {
|
||||
console.log(netop_id, product_id, type);
|
||||
|
||||
let price = $("#marketshare-0-" + netop_id + "-" + product_id + "-" + type).val();
|
||||
console.log(price);
|
||||
if(!price.length) return;
|
||||
|
||||
$("#price-" + type + "-" + netop_id + "-" + product_id).val(price);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="col-5">
|
||||
<form method="post" action="<?=self::getUrl("PreorderProduct", "save")?>">
|
||||
|
||||
<div class="form-group">
|
||||
@@ -72,7 +72,7 @@
|
||||
<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_inet]" value="" />
|
||||
<input type="text" class="form-control" id="price-inet-<?=$netoperator->id?>-<?=$product->id?>" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][price_inet]" value="" onchange="priceToMarketshare(<?=$netoperator->id?>, <?=$product->id?>, 'inet')" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -81,7 +81,7 @@
|
||||
<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_inet_tv]" value="" />
|
||||
<input type="text" class="form-control" id="price-inet_tv-<?=$netoperator->id?>-<?=$product->id?>" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][price_inet_tv]" value="" onchange="priceToMarketshare(<?=$netoperator->id?>, <?=$product->id?>, 'inet_tv')" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -90,7 +90,7 @@
|
||||
<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_catv]" value="" />
|
||||
<input type="text" class="form-control" id="price-catv-<?=$netoperator->id?>-<?=$product->id?>" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][price_catv]" value="" onchange="priceToMarketshare(<?=$netoperator->id?>, <?=$product->id?>, 'catv')" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@@ -99,7 +99,7 @@
|
||||
<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_passive]" value="" />
|
||||
<input type="text" class="form-control" id="price-passive-<?=$netoperator->id?>-<?=$product->id?>" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][price_passive]" value="" onchange="priceToMarketshare(<?=$netoperator->id?>, <?=$product->id?>, 'passive')" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -131,7 +131,7 @@
|
||||
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 class="row mt-3">
|
||||
<!--div class="row mt-3">
|
||||
<div class="col">
|
||||
<div class="form-group">
|
||||
<label>Nur gültig in folgenden Kampagnen</label>
|
||||
@@ -145,13 +145,13 @@
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div-->
|
||||
|
||||
<h4>Netzdurchdringung</h4>
|
||||
<h4 class="mt-3">Netzdurchdringung</h4>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<p>Rabattierte Preise für das Erreichen on Netzdurchdringungszielen</p>
|
||||
<p>0 - 15% ist der Standardpreis. Falls keine Netzdurchdringung </p>
|
||||
<p>0 - 15% ist der Standardpreis </p>
|
||||
<table class="table table-sm table-bordered table-striped table-hover">
|
||||
<tr>
|
||||
<th>Ziel</th>
|
||||
@@ -161,46 +161,46 @@
|
||||
<th>Passive</th>
|
||||
</tr><tr>
|
||||
<th>0 - 15%</th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][0-15][inet]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][0-15][inet_tv]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][0-15][catv]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][0-15][passive]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-0-<?=$netoperator->id?>-<?=$product->id?>-inet" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][0][inet]" onchange="marketshareToPrice(<?=$netoperator->id?>, <?=$product->id?>, 'inet')" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-0-<?=$netoperator->id?>-<?=$product->id?>-inet_tv" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][0][inet_tv]" onchange="marketshareToPrice(<?=$netoperator->id?>, <?=$product->id?>, 'inet_tv')" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-0-<?=$netoperator->id?>-<?=$product->id?>-catv" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][0][catv]" onchange="marketshareToPrice(<?=$netoperator->id?>, <?=$product->id?>, 'catv')" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-0-<?=$netoperator->id?>-<?=$product->id?>-passive" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][0][passive]" onchange="marketshareToPrice(<?=$netoperator->id?>, <?=$product->id?>, 'passive')" /></th>
|
||||
</tr><tr>
|
||||
<th>15,01% - 20%</th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][15-20][inet]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][15-20][inet_tv]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][15-20][catv]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][15-20][passive]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-15-<?=$netoperator->id?>-<?=$product->id?>-inet" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][15][inet]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-15-<?=$netoperator->id?>-<?=$product->id?>-inet_tv" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][15][inet_tv]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-15-<?=$netoperator->id?>-<?=$product->id?>-catv" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][15][catv]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-15-<?=$netoperator->id?>-<?=$product->id?>-passive" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][15][passive]" /></th>
|
||||
</tr><tr>
|
||||
<th>20,01% - 25%</th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][20-25][inet]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][20-25][inet_tv]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][20-25][catv]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][20-25][passive]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-20-<?=$netoperator->id?>-<?=$product->id?>-inet" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][20][inet]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-20-<?=$netoperator->id?>-<?=$product->id?>-inet_tv" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][20][inet_tv]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-20-<?=$netoperator->id?>-<?=$product->id?>-catv" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][20][catv]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-20-<?=$netoperator->id?>-<?=$product->id?>-passive" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][20][passive]" /></th>
|
||||
</tr><tr>
|
||||
<th>25,01% - 30%</th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][25-30][inet]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][25-30][inet_tv]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][25-30][catv]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][25-30][passive]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-25-<?=$netoperator->id?>-<?=$product->id?>-inet" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][25][inet]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-25-<?=$netoperator->id?>-<?=$product->id?>-inet_tv" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][25][inet_tv]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-25-<?=$netoperator->id?>-<?=$product->id?>-catv" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][25][catv]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-25-<?=$netoperator->id?>-<?=$product->id?>-passive" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][25][passive]" /></th>
|
||||
</tr><tr>
|
||||
<th>30,01% - 35%</th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][30-35][inet]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][30-35][inet_tv]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][30-35][catv]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][30-35][passive]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-30-<?=$netoperator->id?>-<?=$product->id?>-inet" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][30][inet]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-30-<?=$netoperator->id?>-<?=$product->id?>-inet_tv" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][30][inet_tv]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-30-<?=$netoperator->id?>-<?=$product->id?>-catv" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][30][catv]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-30-<?=$netoperator->id?>-<?=$product->id?>-passive" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][30][passive]" /></th>
|
||||
</tr><tr>
|
||||
<th>35,01% - 40%</th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][35-40][inet]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][35-40][inet_tv]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][35-40][catv]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][35-40][passive]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-35-<?=$netoperator->id?>-<?=$product->id?>-inet" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][35][inet]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-35-<?=$netoperator->id?>-<?=$product->id?>-inet_tv" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][35][inet_tv]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-35-<?=$netoperator->id?>-<?=$product->id?>-catv" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][35][catv]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-35-<?=$netoperator->id?>-<?=$product->id?>-passive" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][35][passive]" /></th>
|
||||
</tr><tr>
|
||||
<th>40,01% - 45%</th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][40-45][inet]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][40-45][inet_tv]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][40-45][catv]" /></th>
|
||||
<th><input type="text" class="form-control" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][40-45][passive]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-40-<?=$netoperator->id?>-<?=$product->id?>-inet" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][40][inet]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-40-<?=$netoperator->id?>-<?=$product->id?>-inet_tv" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][40][inet_tv]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-40-<?=$netoperator->id?>-<?=$product->id?>-catv" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][40][catv]" /></th>
|
||||
<th><input type="text" class="form-control" id="marketshare-40-<?=$netoperator->id?>-<?=$product->id?>-passive" name="netoperators[<?=$netoperator->id?>][<?=$product->id?>][marketshareprice][40][passive]" /></th>
|
||||
</tr>
|
||||
|
||||
</table>
|
||||
@@ -223,7 +223,7 @@
|
||||
$current_regular_price = $product->getCurrentRegularPrice($today_date, true);
|
||||
$first_price = $product->getFirstPrice($today_date);
|
||||
?>
|
||||
<div class="col-6">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h4>Aktuelle Preise für <?=$product->getTodayDate()?></h4>
|
||||
@@ -270,33 +270,36 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h4>Preis Pro Kampagne</h4>
|
||||
<h4>Preise Netzdurchdringung</h4>
|
||||
|
||||
<h5>Heute gültige Preise</h5>
|
||||
Gültig von: <?=($current_price->start_date) ? (new DateTime($current_price->start_date))->format("d.m.Y") : ""?><br />
|
||||
Gültig bis: <?=($current_price->end_date) ? (new DateTime($current_price->end_date))->format("d.m.Y") : ""?>
|
||||
<table class="table table-sm table-striped table-hover">
|
||||
<tr>
|
||||
<th>Kampagne</th>
|
||||
<th>Gruppe</th>
|
||||
<th>INET</th>
|
||||
<th>INET+TV</th>
|
||||
<th>CATV</th>
|
||||
<th>Passive</th>
|
||||
<th>Gültig von</th>
|
||||
<th>Gültig bis</th>
|
||||
<th>Beschreibung</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
<?php foreach($campaigns as $campaign): ?>
|
||||
<?php $cprice = $product->getCampaignPrice($campaign->id, $today_date); ?>
|
||||
<tr>
|
||||
<td><?=$campaign->name?></td>
|
||||
<td class="text-monospace">€ <?=number_format($cprice->price_inet, 2, ",", ".")?></td>
|
||||
<td class="text-monospace">€ <?=number_format($cprice->price_inet_tv, 2, ",", ".")?></td>
|
||||
<td class="text-monospace">€ <?=number_format($cprice->price_catv, 2, ",", ".")?></td>
|
||||
<td class="text-monospace">€ <?=number_format($cprice->price_passive, 2, ",", ".")?></td>
|
||||
<td class="text-monospace"><?=($cprice->start_date) ? (new DateTime($cprice->start_date))->format("d.m.Y") : "-"?></td>
|
||||
<td class="text-monospace"><?=($cprice->end_date) ? (new DateTime($cprice->end_date))->format("d.m.Y") : "-"?></td>
|
||||
<td><?=$cprice->description?></td>
|
||||
<td><?=$product->getTodayDate()?></td>
|
||||
<td>0 - 15%</td>
|
||||
<td><?=$current_price->price_inet?></td>
|
||||
<td><?=$current_price->price_inet_tv?></td>
|
||||
<td><?=$current_price->price_catv?></td>
|
||||
<td><?=$current_price->price_passive?></td>
|
||||
</tr>
|
||||
<?php foreach($current_price->marketsharediscounts as $bracket => $discount): ?>
|
||||
<tr>
|
||||
<td><?=$bracket?>% - <?=($bracket+5)?>%</td>
|
||||
<td><?=$discount->price_inet?></td>
|
||||
<td><?=$discount->price_inet_tv?></td>
|
||||
<td><?=$discount->price_catv?></td>
|
||||
<td><?=$discount->price_passive?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="col-4">
|
||||
<form method="post" action="<?=self::getUrl("PreorderProduct", "save")?>">
|
||||
|
||||
<div class="form-group">
|
||||
@@ -130,7 +130,7 @@
|
||||
$current_regular_price = $product->getCurrentRegularPrice($today_date, true);
|
||||
$first_price = $product->getFirstPrice($today_date);
|
||||
?>
|
||||
<div class="col-6">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<h4>Aktuelle Preise für <?=$product->getTodayDate()?></h4>
|
||||
|
||||
@@ -123,6 +123,25 @@ class PreorderProductController extends mfBaseController {
|
||||
|
||||
$price->save();
|
||||
|
||||
// marketshare prices
|
||||
if(array_key_exists("marketshareprice", $price_data) && is_array($price_data["marketshareprice"])) {
|
||||
foreach($price_data["marketshareprice"] as $msbracket => $msprice) {
|
||||
if(!is_numeric($msbracket)) continue;
|
||||
if(!$msbracket) continue; // dont save 0
|
||||
|
||||
$msp = PreorderProductMarketshareDiscount::create([
|
||||
"preorderproductprice_id" => $price->id,
|
||||
"bracket" => $msbracket,
|
||||
"price_inet" => Layout::commaToDot(trim($msprice["inet"])),
|
||||
"price_inet_tv" => Layout::commaToDot(trim($msprice["inet_tv"])),
|
||||
"price_catv" => Layout::commaToDot(trim($msprice["catv"])),
|
||||
"price_passive" => Layout::commaToDot(trim($msprice["passive"])),
|
||||
]);
|
||||
$msp->save();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// create PreorderProductPriceCampaign for all submitted campaign_ids
|
||||
foreach($price_data["campaigns"] as $campaign_id) {
|
||||
$campaign = new Preordercampaign($campaign_id);
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
<?php
|
||||
|
||||
class PreorderProductMarketshareDiscount extends mfBaseModel {
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@ class PreorderProductPrice extends mfBaseModel {
|
||||
private $preordercampaign;
|
||||
private $campaigns;
|
||||
private $campaign;
|
||||
private $marketsharediscounts;
|
||||
private $creator;
|
||||
private $editor;
|
||||
|
||||
@@ -53,6 +54,13 @@ class PreorderProductPrice extends mfBaseModel {
|
||||
return $this->campaigns;
|
||||
}
|
||||
|
||||
if($name == "marketsharediscounts") {
|
||||
if(!PreorderProductMarketshareDiscount::count(["preorderproductprice_id" => $this->id])) return [];
|
||||
foreach(PreorderProductMarketshareDiscount::search(["preorderproductprice_id" => $this->id]) as $discount) {
|
||||
$this->marketsharediscounts[$discount->bracket] = $discount;
|
||||
}
|
||||
return $this->marketsharediscounts;
|
||||
}
|
||||
|
||||
if($name == "creator") {
|
||||
$creator = mfValuecache::singleton()->get("Worker-id-".$this->create_by);
|
||||
|
||||
@@ -10,7 +10,6 @@ final class PreorderProductChange2 extends AbstractMigration
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$ppp = $this->table("PreorderProductPrice");
|
||||
$ppp->changeColumn("netoperator_id", "integer", ["null" => true]);
|
||||
$ppp->addColumn("description", "text", ["null" => true, "default" => null, "after" => "contract_term"]);
|
||||
$ppp->update();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class PreorderProductMarketshareDiscountBracket extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if($this->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") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user