diff --git a/Layout/default/Order/Form.php b/Layout/default/Order/Form.php index fe8e21ea7..df6b57189 100644 --- a/Layout/default/Order/Form.php +++ b/Layout/default/Order/Form.php @@ -961,17 +961,6 @@ is("Admin", "netoperator")): ?> - - id && !$includes_external_product): ?> -
");
- $.get("=self::getUrl("IvtCustomer","create", ["order_id" => $order->id])?>",
- {},
- function(data) {
- console.log(data);
- if(data.status == "OK") {
- $('#savetoivt-info').removeClass("text-danger");
- $('#savetoivt-info').addClass("text-success");
- $('#savetoivt-info').text("Kunde erfolgreich an IVT übertragen!");
- $('#savetoivt-button').remove();
- } else {
- $('#savetoivt-info').removeClass("text-success");
- $('#savetoivt-info').addClass("text-danger");
- if(data.reason) {
- if(data.reason == "no-cust-num") {
- $('#savetoivt-info').text("Inhaber und/oder Rechungsempfänger hat keine Kundennummer!");
- }
- if(data.reason == "ivt-exist") {
- $('#savetoivt-info').text("Kunde existiert bereits im IVT!");
- }
- } else {
- $('#savetoivt-info').text("Fehler bei übertragung.");
- }
- $('#savetoivt-button').prop("disabled", false);
- }
- },
- "json"
- );
- });
-
-
+
$('#owner_new').change(function() {
if($('#owner_new').prop('checked')) {
$('#owner-form').show();
diff --git a/application/Admin/functions/IvtContractImport.php b/application/Admin/functions/IvtContractImport.php
index 86c630513..fd3c6459d 100644
--- a/application/Admin/functions/IvtContractImport.php
+++ b/application/Admin/functions/IvtContractImport.php
@@ -899,8 +899,6 @@ class Admin_IvtContractImport {
continue;
}
-
-
// find number in block
$voicenumberblock = Voicenumberblock::findBlock($number);
if(!$voicenumberblock) {
@@ -938,6 +936,8 @@ class Admin_IvtContractImport {
$voice_contract = $this->createVoiceContract($contracts, true);*/
}
+ if(!$contracts) $new_nolink_contract = true;
+
if(!$new_nolink_contract) {
// try finding voice contract, otherwise create it
foreach ($contracts as $contract) {
@@ -1058,19 +1058,34 @@ class Admin_IvtContractImport {
}
}
+ $fc = false;
+
// first contract
- $fc = $contracts[0];
+ if(count($contracts)) {
+ $fc = $contracts[0];
+ }
+
if($fc) {
$finish_date = new DateTime("@".$fc->finish_date);
+ $order_date = new DateTime("@".$fc->order_date);
+ $owner_id = $fc->owner_id;
+ $billingaddress_id = $fc->billingaddress_id;
} else {
$finish_date = new DateTime("now");
$finish_date->modify("first day of this month");
+ $order_date = $finish_date;
+ $address = AddressModel::getFirst(["customer_number" => $ivt_customer_id]);
+ if(!$address) {
+ die(__METHOD__. ": Address cid $ivt_customer_id not found");
+ }
+ $owner_id = $address->id;
+ $billingaddress_id = $owner_id;
}
$data = [];
$data["orderproduct_id"] = null;
- $data["owner_id"] = $fc->owner_id;
- $data["billingaddress_id"] = $fc->billingaddress_id;
+ $data["owner_id"] = $owner_id;
+ $data["billingaddress_id"] = $billingaddress_id;
$data["termination_id"] = null;
$data["product_id"] = $product->id;
$data["product_name"] = "Telefonie (nur Rufnummer)";
@@ -1086,7 +1101,7 @@ class Admin_IvtContractImport {
$data["vatgroup_id"] = $product->vatgroup_id;
$data["billing_delay"] = $product->billing_delay;
$data["billing_period"] = $product->billing_period;
- $data["order_date"] = $fc->order_date;
+ $data["order_date"] = $order_date->format("U");
$data["finish_date"] = $finish_date->format("U");
$data["finish_date_by"] = 1;
$data["note"] = null;
@@ -1200,5 +1215,40 @@ class Admin_IvtContractImport {
return 4; // if ivt sla is unknown -> return residential
}
+
+ public function importNumbersFromIvt() {
+ foreach(IvtCustomerTelephoneNrModel::getAll() as $ivtnum) {
+ $number = preg_replace('/^0043/', '43', trim($ivtnum->number));
+ if(!$number) {
+ continue;
+ }
+
+ $voicenumber = VoicenumberModel::getFirst(["number" => $number]);
+ if($voicenumber && $voicenumber->contract_id) continue;
+
+ $cid = $ivtnum->cid;
+
+ $ivt_customer = new IvtCustomer($cid);
+ if(!$ivt_customer) continue;
+
+ echo "number $number, cid $cid\n";
+
+ foreach(['deleted', 'deletet', 'deleded', 'delete', 'deledet'] as $word) {
+ if(strtolower(trim($ivt_customer->company)) == $word || strtolower(trim($ivt_customer->surname)) == $word || strtolower(trim($ivt_customer->firstname)) == $word) {
+ continue 2;
+ }
+ }
+
+ $address = AddressModel::getFirst(["customer_number" => $cid]);
+ if(!$address) {
+ die("Address not found customer_number ".$cid);
+ }
+
+ echo "create\n";
+ //continue;
+ $this->addVoipData($cid, []);
+ //$this->createVoiceContract([], true, $cid);
+ }
+ }
}
diff --git a/scripts/contract/import-ivt.php b/scripts/contract/import-ivt.php
index e2451c6ed..9298cbf78 100644
--- a/scripts/contract/import-ivt.php
+++ b/scripts/contract/import-ivt.php
@@ -21,6 +21,8 @@ echo "Import Contracts from IVT\n";
$import = new Admin_IvtContractImport();
$data = $import->run(1);
+echo "Import Missing Voicenumbers\n";
+$import->importNumbersFromIvt();
//exit;