Added Voicenumber to Contractqueue
This commit is contained in:
@@ -87,7 +87,7 @@
|
||||
<h4 class="header-title">Fertiggestellte Bestellungen</h4>
|
||||
</div>
|
||||
<div class="float-right">
|
||||
<a class="btn btn-outline-primary mb-2" href="<?=self::getUrl("Contractqueue", "importFinishedOrders")?>"><i class="fas fa-fw fa-file-import"></i> Fertiggestellte Bestellungen importieren</a>
|
||||
<a class="btn btn-outline-danger mb-2" href="<?=self::getUrl("Contractqueue", "deleteOpenOrders")?>"><i class="fas fa-fw fa-file-import"></i> Offene löschen und neu importieren</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -260,7 +260,15 @@
|
||||
<!--i class="fas fa-fw fa-pencil pointer text-primary" onclick="toggleEdit('contract', <?=$contract->id?>, 'product')"></i--> <span class="value"><?=$contract->product_name?></span>
|
||||
<?php if($contract->termination_id && $contract->termination): ?>
|
||||
<br /><small class="text-pink"><?=$contract->termination->code?> - <?= str_replace("\n", " - ", $contract->termination->getAddress())?></small>
|
||||
<?php endif ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php $voicenumbers = []; ?>
|
||||
<?php foreach($contract->voicenumbers as $voicenumber): ?>
|
||||
<?php $voicenumbers[] = $voicenumber->number; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php if(count($voicenumbers)): ?>
|
||||
<br /><strong><?=implode(", ", $voicenumbers);?></strong>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="edit hidden">
|
||||
<div class="input-group mb-3">
|
||||
|
||||
@@ -277,6 +277,62 @@ class Contract extends mfBaseModel {
|
||||
return false;
|
||||
}
|
||||
|
||||
public function addVoiceFromContractQueue($cq) {
|
||||
if($cq->voicenumber) {
|
||||
$voicenumbers = [];
|
||||
$json = json_decode($cq->voicenumber);
|
||||
|
||||
if(is_array($json) && count($json)) {
|
||||
foreach($json as $number) {
|
||||
$number = str_replace("+", "", $number);
|
||||
$voicenumber = VoicenumberModel::getFirst(["number" => $number]);
|
||||
if($voicenumber) {
|
||||
$voicenumbers[] = $voicenumber;
|
||||
} else {
|
||||
// find block
|
||||
$block_id = null;
|
||||
|
||||
$block = Voicenumberblock::findBlock($number);
|
||||
if($block) {
|
||||
$block_id = $block->id;
|
||||
}
|
||||
$voicenumber = VoicenumberModel::create([
|
||||
'voicenumberblock_id' => $block_id,
|
||||
"contract_id" => null,
|
||||
'active' => 1,
|
||||
'activated_date' => date('U'),
|
||||
'routing' => "kolmisoft",
|
||||
'number' => $number,
|
||||
'disabled' => 0
|
||||
]);
|
||||
$voicenumbers[] = $voicenumber;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
foreach($voicenumbers as $vn) {
|
||||
$vn->contract_id = $this->id;
|
||||
$vn->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($cq->voiceplan_id) {
|
||||
$config_values = $this->getProperty("configvalues");
|
||||
if(is_array($config_values) && array_key_exists("voicenumberblock_voiceplan_id", $config_values)) {
|
||||
$cc_item = $config_values["voicenumberblock_voiceplan_id"];
|
||||
$cc_item->setContractId($this->id);
|
||||
} else {
|
||||
$cc_item = ContractconfigItemModel::getFirst(["name" => "voicenumberblock_voiceplan_id"]);
|
||||
$cc_item->setContractId($this->id);
|
||||
}
|
||||
|
||||
//var_dump($cc_item, $cc_item->value);
|
||||
|
||||
$cc_item->value->set($cq->voiceplan_id);
|
||||
$cc_item->value->save();
|
||||
}
|
||||
}
|
||||
|
||||
public function addFilesFromOrder() {
|
||||
if(!$this->orderproduct_id) {
|
||||
|
||||
@@ -171,6 +171,10 @@ class ContractModel {
|
||||
}
|
||||
$crediting_price *= -1;
|
||||
|
||||
/*if($crediting_price == 0) {
|
||||
return true;
|
||||
}*/
|
||||
|
||||
$data["matchcode"] = $cq->crediting_matchcode;
|
||||
$data["owner_id"] = $cq->crediting_partner_id;
|
||||
$data["billingaddress_id"] = $cq->crediting_partner_id;
|
||||
@@ -185,6 +189,8 @@ class ContractModel {
|
||||
$contract = ContractModel::create($data);
|
||||
//var_dump($contract);exit;
|
||||
|
||||
|
||||
|
||||
return $contract;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class ContractconfigItem extends mfBaseModel {
|
||||
$value->create_by = $me->id;
|
||||
$value->edit_by = $me->id;
|
||||
}
|
||||
//var_dump($value);exit;
|
||||
|
||||
$this->value = $value;
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ class Contractqueue extends mfBaseModel {
|
||||
private $product;
|
||||
private $orderproduct;
|
||||
private $termination;
|
||||
private $voicenumbers;
|
||||
private $sla;
|
||||
private $creator;
|
||||
private $editor;
|
||||
@@ -132,6 +133,46 @@ class Contractqueue extends mfBaseModel {
|
||||
}
|
||||
return $this->orderproduct;
|
||||
}
|
||||
|
||||
if($name == "voicenumbers") {
|
||||
$this->voicenumbers = [];
|
||||
if(!$this->voicenumber) return [];
|
||||
|
||||
$json = json_decode($this->voicenumber);
|
||||
//var_dump($json);exit;
|
||||
|
||||
if(!is_array($json)) return [];
|
||||
|
||||
$voicenumbers = [];
|
||||
foreach($json as $number) {
|
||||
$number = str_replace("+","",$number);
|
||||
if(!$number) continue;
|
||||
$voicenumber = VoicenumberModel::getFirst(["number" => $number]);
|
||||
if($voicenumber) {
|
||||
$voicenumbers[] = $voicenumber;
|
||||
} else {
|
||||
// find block
|
||||
$block_id = null;
|
||||
|
||||
$block = Voicenumberblock::findBlock($number);
|
||||
if($block) {
|
||||
$block_id = $block->id;
|
||||
}
|
||||
$voicenumber = VoicenumberModel::create([
|
||||
'voicenumberblock_id' => $block_id,
|
||||
"contract_id" => null,
|
||||
'active' => 1,
|
||||
'activated_date' => date('U'),
|
||||
'routing' => "kolmisoft",
|
||||
'number' => $number,
|
||||
'disabled' => 0
|
||||
]);
|
||||
$voicenumbers[] = $voicenumber;
|
||||
}
|
||||
}
|
||||
$this->voicenumbers = $voicenumbers;
|
||||
return $this->voicenumbers;
|
||||
}
|
||||
|
||||
|
||||
if($name == "creator" && $this->id) {
|
||||
|
||||
@@ -116,6 +116,15 @@ class ContractqueueController extends mfBaseController {
|
||||
|
||||
}
|
||||
|
||||
protected function deleteOpenOrdersAction() {
|
||||
foreach(ContractqueueModel::search(["contract_id" => null]) as $cq) {
|
||||
$cq->delete();
|
||||
}
|
||||
|
||||
$this->layout()->setFlash("Offene Queue Einträge gelöscht und neu importiert.", "success");
|
||||
$this->redirect("Contractqueue");
|
||||
}
|
||||
|
||||
private function importOrders() {
|
||||
$o = 0;
|
||||
//$max_orders = 1500;
|
||||
@@ -252,6 +261,10 @@ class ContractqueueController extends mfBaseController {
|
||||
continue;
|
||||
}
|
||||
|
||||
if($cq->voicenumber) {
|
||||
$contract->addVoiceFromContractqueue($cq);
|
||||
}
|
||||
|
||||
$c++;
|
||||
|
||||
$cq->contract_id = $contract->id;
|
||||
|
||||
@@ -15,6 +15,8 @@ class ContractqueueModel {
|
||||
public $product_info;
|
||||
public $matchcode;
|
||||
public $crediting_matchcode;
|
||||
public $voicenumber;
|
||||
public $voiceplan_id;
|
||||
public $amount;
|
||||
public $sla_id = null;
|
||||
public $product_external;
|
||||
@@ -97,6 +99,8 @@ class ContractqueueModel {
|
||||
$data["sla_id"] = $product->sla_id;
|
||||
$data["product_external"] = ($product->external) ? $product->external : 0;
|
||||
$data["product_external_id"] = ($product->external) ? $product->external_id : null;
|
||||
$data["voicenumber"] = $op->voicenumber;
|
||||
$data["voiceplan_id"] = $op->voiceplan_id;
|
||||
$data["price"] = $op->price;
|
||||
$data["price_setup"] = $op->price_setup;
|
||||
$data["price_nne"] = $op->price_nne;
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class ContractqueueAddVoicenumber extends AbstractMigration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$table = $this->table("Contractqueue");
|
||||
$table->addColumn("voicenumber", "json", ["null" => true, "default" => null, "after" => "crediting_matchcode"]);
|
||||
$table->addColumn("voiceplan_id", "integer", ["null" => true, "default" => null, "after" => "voicenumber"]);
|
||||
$table->update();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
if($this->getEnvironment() == "thetool") {
|
||||
$this->table("Contractqueue")
|
||||
->removeColumn("voiceplan_id")
|
||||
->removeColumn("voicenumber")
|
||||
->update();
|
||||
}
|
||||
|
||||
if($this->getEnvironment() == "addressdb") {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user