diff --git a/Layout/default/Contractqueue/Index.php b/Layout/default/Contractqueue/Index.php
index 9d8c4d85a..72d61d33c 100644
--- a/Layout/default/Contractqueue/Index.php
+++ b/Layout/default/Contractqueue/Index.php
@@ -87,7 +87,7 @@
diff --git a/application/Contract/Contract.php b/application/Contract/Contract.php
index 1c173d0e5..f217fc7fa 100644
--- a/application/Contract/Contract.php
+++ b/application/Contract/Contract.php
@@ -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) {
diff --git a/application/Contract/ContractModel.php b/application/Contract/ContractModel.php
index ef52a750b..a59b6d8ba 100644
--- a/application/Contract/ContractModel.php
+++ b/application/Contract/ContractModel.php
@@ -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;
}
diff --git a/application/ContractconfigItem/ContractconfigItem.php b/application/ContractconfigItem/ContractconfigItem.php
index 0da900e1f..6b92140dd 100644
--- a/application/ContractconfigItem/ContractconfigItem.php
+++ b/application/ContractconfigItem/ContractconfigItem.php
@@ -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;
}
diff --git a/application/Contractqueue/Contractqueue.php b/application/Contractqueue/Contractqueue.php
index 4c2b2b0b4..f496a3e3f 100644
--- a/application/Contractqueue/Contractqueue.php
+++ b/application/Contractqueue/Contractqueue.php
@@ -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) {
diff --git a/application/Contractqueue/ContractqueueController.php b/application/Contractqueue/ContractqueueController.php
index 70eeec244..3b60a8d72 100644
--- a/application/Contractqueue/ContractqueueController.php
+++ b/application/Contractqueue/ContractqueueController.php
@@ -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;
diff --git a/application/Contractqueue/ContractqueueModel.php b/application/Contractqueue/ContractqueueModel.php
index 51d6cf481..02cbbd9a8 100644
--- a/application/Contractqueue/ContractqueueModel.php
+++ b/application/Contractqueue/ContractqueueModel.php
@@ -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;
diff --git a/db/migrations/20240806174939_contractqueue_add_voicenumber.php b/db/migrations/20240806174939_contractqueue_add_voicenumber.php
new file mode 100644
index 000000000..7202c14d1
--- /dev/null
+++ b/db/migrations/20240806174939_contractqueue_add_voicenumber.php
@@ -0,0 +1,35 @@
+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") {
+
+ }
+ }
+}