Voiceplan import: fixed price destination zones sales price is now purchase

price
This commit is contained in:
Frank Schubert
2024-01-11 20:39:35 +01:00
parent f86190d72c
commit c16df5077a
4 changed files with 32 additions and 4 deletions

View File

@@ -147,7 +147,7 @@ $chartColors = [
<div class="card">
<div class="card-body">
<h4 class="card-title">Kunden pro Provider</h4>
<h4 class="card-title">Kunden je Partner</h4>
<hr />
<div class="row">
<?php if(1): ?>

View File

@@ -19,7 +19,8 @@ class Voiceplan extends mfBaseModel {
$i = 0;
$filename = $file->getFullPath();
$input = fopen($filename, "r");
while($csv = fgetcsv($input, 0, ";")) {
//while($csv = fgetcsv($input, 0, ";")) {
while($csv = fgetcsv($input, 0, ",")) {
$i++;
if($i == 1) continue;
@@ -74,6 +75,8 @@ class Voiceplan extends mfBaseModel {
}
}
$this->checkFixpriceZones();
if($errors) {
$this->import_errors = $errors;
}
@@ -95,7 +98,8 @@ class Voiceplan extends mfBaseModel {
$i = 0;
$filename = $file->getFullPath();
$input = fopen($filename, "r");
while($csv = fgetcsv($input, 0, ";")) {
//while($csv = fgetcsv($input, 0, ";")) {
while($csv = fgetcsv($input, 0, ",")) {
$i++;
if($i == 1) continue;
@@ -117,6 +121,8 @@ class Voiceplan extends mfBaseModel {
$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;
@@ -145,6 +151,27 @@ class Voiceplan extends mfBaseModel {
}
}
public function checkFixpriceZones() {
$destinations = [];
foreach(VoiceplandestinationModel::search(["voiceplan_id" => $this->id, "prefix" => "438%"]) as $dest) {
if(!preg_match('/^4386/', $dest->prefix)) {
$destinations[] = $dest;
}
}
foreach(VoiceplandestinationModel::search(["voiceplan_id" => $this->id, "prefix" => "439%"]) as $dest) {
$destinations[] = $dest;
}
foreach($destinations as $dest) {
if($dest->voiceplanzone->purchase_price != $dest->voiceplanzone->price) {
$dest->voiceplanzone->price = $dest->voiceplanzone->purchase_price;
$dest->voiceplanzone->save();
}
}
return true;
}
public function getProperty($name) {
if($this->$name == null) {

View File

@@ -4,6 +4,7 @@ class Voiceplandestination extends mfBaseModel {
protected $forcestr = ["name", "destination", "prefix"];
private $voiceplan;
private $voiceplanzone;
public function getProperty($name) {
if($this->$name == null) {

View File

@@ -106,7 +106,7 @@ class VoiceplandestinationModel {
$res = $db->query($sql);
//mfLoghandler::singleton()->debug($sql);
mfLoghandler::singleton()->debug($sql);
if($db->num_rows($res)) {
while($data = $db->fetch_object($res)) {