Voiceplan import: fixed price destination zones sales price is now purchase
price
This commit is contained in:
@@ -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) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user