Voiceplan Import: Added price multiplicator
This commit is contained in:
@@ -44,12 +44,19 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="name">Standardtaktung *</label>
|
||||
<label class="col-lg-2 col-form-label" for="increment">Standardtaktung *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="increment" class="form-control" name="increment" id="increment" value="<?=($plan->increment_first && $plan->increment) ? $plan->increment_first."/".$plan->increment : ""?>" placeholder="60/30" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-lg-2 col-form-label" for="price_multiplicator">Verkaufspreis Multipliator *</label>
|
||||
<div class="col-lg-10">
|
||||
<input type="price_multiplicator" class="form-control" name="price_multiplicator" id="price_multiplicator" value="<?=(float)$plan->price_multiplicator?>" placeholder="1" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr />
|
||||
|
||||
<div class="form-group row">
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
<th>Anzahl Tarifzonen</th>
|
||||
<th>Anzahl Destinations</th>
|
||||
<th>Standardtaktung</th>
|
||||
<th>Verkaufspreis Multiplikator</th>
|
||||
<th>Erstellt</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
@@ -81,6 +82,7 @@
|
||||
<td><?=count($plan->zones)?></td>
|
||||
<td><?=count($plan->destinations)?></td>
|
||||
<td><?=($plan->increment_first && $plan->increment) ? $plan->increment_first."/".$plan->increment : ""?></td>
|
||||
<td><?=str_replace(".",",",(float)$plan->price_multiplicator)?>x</td>
|
||||
<td><?=date("d.m.Y H:i", $plan->create)?> (<?=$plan->creator->name?>)</td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
<a href="<?=self::getUrl("Voiceplan", "view", ["id" => $plan->id])?>"><i class="far fa-eyes" title="Anzeigen"></i></a>
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
<?php foreach($zones as $zone): ?>
|
||||
<tr>
|
||||
<td><a href="<?=self::getUrl("Voiceplanzone", "view", ["id" => $zone->id])?>"><?=$zone->name?></a></td>
|
||||
<td><?=(count($zone->destinations) > 1) ? count($zone->destinations) : "<spam class='text-monospace'>+".$zone->destinations[0]->prefix."</span>"?></td>
|
||||
<td><?=(count($zone->destinations) > 1) ? count($zone->destinations)." Destinations" : "<spam class='text-monospace'>+".$zone->destinations[0]->prefix."</span>"?></td>
|
||||
<td><?=($zone->increment_first && $zone->increment) ? $zone->increment_first."/".$zone->increment : ""?></td>
|
||||
<td><?=$zone->purchase_price?></td>
|
||||
<td><?=$zone->price?></td>
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
<?php foreach($destinations as $destination): ?>
|
||||
<tr>
|
||||
<td><?=$destination->destination?></td>
|
||||
<td><?=$destination->prefix?></td>
|
||||
<td>+<?=$destination->prefix?></td>
|
||||
<td><?=date("d.m.Y H:i", $zone->create)?> (<?=$zone->creator->name?>)</td>
|
||||
<td><?=date("d.m.Y H:i", $zone->edit)?> (<?=$zone->editor->name?>)</td>
|
||||
<td style="text-align: left; letter-spacing: 4px; font-size: 1.1em;">
|
||||
|
||||
@@ -19,7 +19,7 @@ class Voiceplan extends mfBaseModel {
|
||||
$i = 0;
|
||||
$filename = $file->getFullPath();
|
||||
$input = fopen($filename, "r");
|
||||
while($csv = fgetcsv($input, 0, ";")) {
|
||||
while($csv = fgetcsv($input, 0, ",")) {
|
||||
$i++;
|
||||
if($i == 1) continue;
|
||||
|
||||
@@ -95,14 +95,13 @@ class Voiceplan extends mfBaseModel {
|
||||
$i = 0;
|
||||
$filename = $file->getFullPath();
|
||||
$input = fopen($filename, "r");
|
||||
while($csv = fgetcsv($input, 0, ";")) {
|
||||
while($csv = fgetcsv($input, 0, ",")) {
|
||||
$i++;
|
||||
if($i == 1) continue;
|
||||
|
||||
if(!trim($csv[0])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$name = trim($csv[0]);
|
||||
$extref = trim($csv[1]);
|
||||
$price_default = str_replace(",",".", trim($csv[4]));
|
||||
@@ -113,6 +112,11 @@ class Voiceplan extends mfBaseModel {
|
||||
$price_ek = $price_special;
|
||||
}
|
||||
|
||||
$price_vk = 0;
|
||||
if($price_ek && $this->price_multiplicator) {
|
||||
$price_vk = (float)$price_ek * (float)$this->price_multiplicator;
|
||||
}
|
||||
|
||||
if((!$name || !$price_ek) && $extref != "900") {
|
||||
$this->log->warning(__METHOD__.": not importing Voiceplanzone with empty value: name: $name | ek: $price_ek");
|
||||
continue;
|
||||
@@ -123,7 +127,7 @@ class Voiceplan extends mfBaseModel {
|
||||
"extref" => $extref,
|
||||
"name" => $name,
|
||||
"purchase_price" => $price_ek,
|
||||
"price" => 0,
|
||||
"price" => $price_vk,
|
||||
"increment_first" => $this->increment_first,
|
||||
"increment" => $this->increment
|
||||
]);
|
||||
|
||||
@@ -124,6 +124,8 @@ class VoiceplanController extends mfBaseController {
|
||||
$data = [];
|
||||
$data['name'] = $r->name;
|
||||
$data['description'] = $r->description;
|
||||
$data['price_multiplicator'] = ($r->price_multiplicator) ? $r->price_multiplicator : 1;
|
||||
|
||||
|
||||
if($r->increment) {
|
||||
$increments = explode("/",$r->increment);
|
||||
|
||||
@@ -7,6 +7,7 @@ class VoiceplanModel {
|
||||
public $source_id;
|
||||
public $increment_first;
|
||||
public $increment;
|
||||
public $price_multiplicator;
|
||||
|
||||
public $create_by;
|
||||
public $edit_by;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class VoiceplanAddPriceMultiplicator extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$table = $this->table("Voiceplan");
|
||||
$table->addColumn("price_multiplicator", "decimal", ["null" => false, "default" => 1.000, "precision" => 8, "scale" => 4, "after" => "increment"]);
|
||||
$table->update();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$this->table("Voiceplan")->removeColumn("price_multiplicator")->save();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user