Importing missing voicenumbers & disabled ivt button in Order
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user