Importing missing voicenumbers & disabled ivt button in Order
This commit is contained in:
@@ -961,17 +961,6 @@
|
|||||||
|
|
||||||
|
|
||||||
<?php if($me->is("Admin", "netoperator")): ?>
|
<?php if($me->is("Admin", "netoperator")): ?>
|
||||||
<?php if(TT_FEATURE_IVT): ?>
|
|
||||||
<?php if($order->id && !$includes_external_product): ?>
|
|
||||||
<div class="form-group row">
|
|
||||||
<label class="col-lg-2"></label>
|
|
||||||
<div class="col-lg-10 mb-2">
|
|
||||||
<button type="button" id="savetoivt-button" class="btn btn-pink">Kunde an IVT übertragen</button>
|
|
||||||
<span id="savetoivt-info"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
<div class="form-group row">
|
<div class="form-group row">
|
||||||
<label class="col-lg-2"></label>
|
<label class="col-lg-2"></label>
|
||||||
<div class="col-lg-10">
|
<div class="col-lg-10">
|
||||||
@@ -1135,41 +1124,7 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
<?php if($order->id): ?>
|
|
||||||
$('#savetoivt-button').click(function() {
|
|
||||||
$('#savetoivt-button').prop("disabled", true);
|
|
||||||
$('#savetoivt-info').html("<img src='<?=self::getResourcePath()?>img/ajax-loader.gif' />");
|
|
||||||
$.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"
|
|
||||||
);
|
|
||||||
});
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
$('#owner_new').change(function() {
|
$('#owner_new').change(function() {
|
||||||
if($('#owner_new').prop('checked')) {
|
if($('#owner_new').prop('checked')) {
|
||||||
$('#owner-form').show();
|
$('#owner-form').show();
|
||||||
|
|||||||
@@ -899,8 +899,6 @@ class Admin_IvtContractImport {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// find number in block
|
// find number in block
|
||||||
$voicenumberblock = Voicenumberblock::findBlock($number);
|
$voicenumberblock = Voicenumberblock::findBlock($number);
|
||||||
if(!$voicenumberblock) {
|
if(!$voicenumberblock) {
|
||||||
@@ -938,6 +936,8 @@ class Admin_IvtContractImport {
|
|||||||
$voice_contract = $this->createVoiceContract($contracts, true);*/
|
$voice_contract = $this->createVoiceContract($contracts, true);*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!$contracts) $new_nolink_contract = true;
|
||||||
|
|
||||||
if(!$new_nolink_contract) {
|
if(!$new_nolink_contract) {
|
||||||
// try finding voice contract, otherwise create it
|
// try finding voice contract, otherwise create it
|
||||||
foreach ($contracts as $contract) {
|
foreach ($contracts as $contract) {
|
||||||
@@ -1058,19 +1058,34 @@ class Admin_IvtContractImport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$fc = false;
|
||||||
|
|
||||||
// first contract
|
// first contract
|
||||||
$fc = $contracts[0];
|
if(count($contracts)) {
|
||||||
|
$fc = $contracts[0];
|
||||||
|
}
|
||||||
|
|
||||||
if($fc) {
|
if($fc) {
|
||||||
$finish_date = new DateTime("@".$fc->finish_date);
|
$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 {
|
} else {
|
||||||
$finish_date = new DateTime("now");
|
$finish_date = new DateTime("now");
|
||||||
$finish_date->modify("first day of this month");
|
$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 = [];
|
||||||
$data["orderproduct_id"] = null;
|
$data["orderproduct_id"] = null;
|
||||||
$data["owner_id"] = $fc->owner_id;
|
$data["owner_id"] = $owner_id;
|
||||||
$data["billingaddress_id"] = $fc->billingaddress_id;
|
$data["billingaddress_id"] = $billingaddress_id;
|
||||||
$data["termination_id"] = null;
|
$data["termination_id"] = null;
|
||||||
$data["product_id"] = $product->id;
|
$data["product_id"] = $product->id;
|
||||||
$data["product_name"] = "Telefonie (nur Rufnummer)";
|
$data["product_name"] = "Telefonie (nur Rufnummer)";
|
||||||
@@ -1086,7 +1101,7 @@ class Admin_IvtContractImport {
|
|||||||
$data["vatgroup_id"] = $product->vatgroup_id;
|
$data["vatgroup_id"] = $product->vatgroup_id;
|
||||||
$data["billing_delay"] = $product->billing_delay;
|
$data["billing_delay"] = $product->billing_delay;
|
||||||
$data["billing_period"] = $product->billing_period;
|
$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"] = $finish_date->format("U");
|
||||||
$data["finish_date_by"] = 1;
|
$data["finish_date_by"] = 1;
|
||||||
$data["note"] = null;
|
$data["note"] = null;
|
||||||
@@ -1200,5 +1215,40 @@ class Admin_IvtContractImport {
|
|||||||
|
|
||||||
return 4; // if ivt sla is unknown -> return residential
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ echo "Import Contracts from IVT\n";
|
|||||||
$import = new Admin_IvtContractImport();
|
$import = new Admin_IvtContractImport();
|
||||||
$data = $import->run(1);
|
$data = $import->run(1);
|
||||||
|
|
||||||
|
echo "Import Missing Voicenumbers\n";
|
||||||
|
$import->importNumbersFromIvt();
|
||||||
|
|
||||||
//exit;
|
//exit;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user