Tweaks to Ivt Import
This commit is contained in:
@@ -26,7 +26,6 @@ class Admin_IvtContractImport {
|
|||||||
* WHERE `cid` = 1840;
|
* WHERE `cid` = 1840;
|
||||||
*/
|
*/
|
||||||
$this->static_ivt_order_match = [
|
$this->static_ivt_order_match = [
|
||||||
9 => false,
|
|
||||||
17245 => 3946, // lugitsch 1840
|
17245 => 3946, // lugitsch 1840
|
||||||
16704 => 3342,
|
16704 => 3342,
|
||||||
16703 => 3342,
|
16703 => 3342,
|
||||||
@@ -84,7 +83,8 @@ class Admin_IvtContractImport {
|
|||||||
14189 => 3322, // andeßner-angleitner
|
14189 => 3322, // andeßner-angleitner
|
||||||
16722 => 3322,
|
16722 => 3322,
|
||||||
16267 => 3079, // schmuck marianne
|
16267 => 3079, // schmuck marianne
|
||||||
16786 => 3079
|
16786 => 3079,
|
||||||
|
17821 => 2364, // johann höfler
|
||||||
];
|
];
|
||||||
$this->no_matchcode = [
|
$this->no_matchcode = [
|
||||||
9,
|
9,
|
||||||
@@ -111,7 +111,6 @@ class Admin_IvtContractImport {
|
|||||||
echo "Importing from $maxIvtContracts Ivt customer_products\n";
|
echo "Importing from $maxIvtContracts Ivt customer_products\n";
|
||||||
|
|
||||||
foreach(IvtCustomerProductModel::getAll() as $ivt_contract) {
|
foreach(IvtCustomerProductModel::getAll() as $ivt_contract) {
|
||||||
//if($ivt_contract->cid < 104200) continue;
|
|
||||||
//if($i > 1000 && $ivt_contract->cid != $last_cid) break; // only break after the last ivtcontract of this customer
|
//if($i > 1000 && $ivt_contract->cid != $last_cid) break; // only break after the last ivtcontract of this customer
|
||||||
$last_cid = $ivt_contract->cid;
|
$last_cid = $ivt_contract->cid;
|
||||||
|
|
||||||
@@ -204,13 +203,21 @@ class Admin_IvtContractImport {
|
|||||||
$contract_data['create_by'] = 1;
|
$contract_data['create_by'] = 1;
|
||||||
$contract_data['edit_by'] = 1;
|
$contract_data['edit_by'] = 1;
|
||||||
|
|
||||||
$finish_date = new DateTime($ivt_contract->lastdate);
|
if(!$ivt_contract->lastdate) {
|
||||||
|
$finish_date = new DateTime("now");
|
||||||
|
} else {
|
||||||
|
$finish_date = new DateTime($ivt_contract->lastdate);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$finish_date->modify("first day of this month");
|
$finish_date->modify("first day of this month");
|
||||||
|
|
||||||
switch($ip->interval) {
|
switch($ip->interval) {
|
||||||
case 0:
|
case 0:
|
||||||
$contract_data['billing_period'] = 1;
|
$contract_data['billing_period'] = 1;
|
||||||
$finish_date->modify("+1 month");
|
if($ivt_contract->lastdate) {
|
||||||
|
$finish_date->modify("+1 month");
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
$contract_data['billing_period'] = 12;
|
$contract_data['billing_period'] = 12;
|
||||||
@@ -340,6 +347,7 @@ class Admin_IvtContractImport {
|
|||||||
|
|
||||||
if($doit) {
|
if($doit) {
|
||||||
$this->log->debug("Linking new contracts, creating missing matchcodes and adding voip data");
|
$this->log->debug("Linking new contracts, creating missing matchcodes and adding voip data");
|
||||||
|
echo "Linking new contracts, creating missing matchcodes and adding voip data\n";
|
||||||
//var_dump($new_contracts[1789]);exit;
|
//var_dump($new_contracts[1789]);exit;
|
||||||
foreach($new_contracts as $ivt_customer_id => $contracts) {
|
foreach($new_contracts as $ivt_customer_id => $contracts) {
|
||||||
$this->addVoipData($ivt_customer_id, $contracts);
|
$this->addVoipData($ivt_customer_id, $contracts);
|
||||||
@@ -886,7 +894,9 @@ class Admin_IvtContractImport {
|
|||||||
|
|
||||||
foreach($ivtnumbers as $ivtnum) {
|
foreach($ivtnumbers as $ivtnum) {
|
||||||
$number = preg_replace('/^0043/', '43', $ivtnum->number);
|
$number = preg_replace('/^0043/', '43', $ivtnum->number);
|
||||||
if(!$number) continue;
|
if(!$number) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -937,12 +947,9 @@ class Admin_IvtContractImport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!$voice_contract) {
|
if(!$voice_contract) {
|
||||||
$voice_contract = $this->createVoiceContract($contracts, $new_nolink_contract);
|
$voice_contract = $this->createVoiceContract($contracts, $new_nolink_contract, $ivt_customer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//var_dump($voice_contract);exit;
|
//var_dump($voice_contract);exit;
|
||||||
|
|
||||||
// put all numbers in $all_numbers array
|
// put all numbers in $all_numbers array
|
||||||
@@ -1039,7 +1046,7 @@ class Admin_IvtContractImport {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createVoiceContract($contracts, $nolink = false) {
|
private function createVoiceContract($contracts, $nolink = false, $ivt_customer_id = false) {
|
||||||
// find rufnummer only product (residential or business)
|
// find rufnummer only product (residential or business)
|
||||||
$product = new Product(101); // Telefonie (nur Rufnummer - Privat)
|
$product = new Product(101); // Telefonie (nur Rufnummer - Privat)
|
||||||
$sla_id = 4;
|
$sla_id = 4;
|
||||||
@@ -1052,6 +1059,12 @@ class Admin_IvtContractImport {
|
|||||||
|
|
||||||
// first contract
|
// first contract
|
||||||
$fc = $contracts[0];
|
$fc = $contracts[0];
|
||||||
|
if($fc) {
|
||||||
|
$finish_date = new DateTime("@".$fc->finish_date);
|
||||||
|
} else {
|
||||||
|
$finish_date = new DateTime("now");
|
||||||
|
$finish_date->modify("first day of this month");
|
||||||
|
}
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
$data["orderproduct_id"] = null;
|
$data["orderproduct_id"] = null;
|
||||||
@@ -1073,11 +1086,12 @@ class Admin_IvtContractImport {
|
|||||||
$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"] = $fc->order_date;
|
||||||
$data["finish_date"] = $fc->finish_date;
|
$data["finish_date"] = $finish_date->format("U");
|
||||||
$data["finish_date_by"] = 1;
|
$data["finish_date_by"] = 1;
|
||||||
$data["note"] = null;
|
$data["note"] = null;
|
||||||
|
|
||||||
$voice_contract = ContractModel::create($data);
|
$voice_contract = ContractModel::create($data);
|
||||||
|
|
||||||
if(!$voice_contract->save()) {
|
if(!$voice_contract->save()) {
|
||||||
$this->log->error("Unable to create voice contract for cust " . $fc->customer_number);
|
$this->log->error("Unable to create voice contract for cust " . $fc->customer_number);
|
||||||
exit;
|
exit;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class Contract extends mfBaseModel {
|
|||||||
private $configvalues;
|
private $configvalues;
|
||||||
private $isCancelled;
|
private $isCancelled;
|
||||||
private $journals;
|
private $journals;
|
||||||
|
private $orderjournals;
|
||||||
private $links;
|
private $links;
|
||||||
private $linksWithCredit;
|
private $linksWithCredit;
|
||||||
private $linkFrom;
|
private $linkFrom;
|
||||||
@@ -333,6 +334,24 @@ class Contract extends mfBaseModel {
|
|||||||
$this->journals = array_reverse(ContractjournalModel::search(["contract_id" => $this->id]));
|
$this->journals = array_reverse(ContractjournalModel::search(["contract_id" => $this->id]));
|
||||||
return $this->journals;
|
return $this->journals;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($name == "orderjournals") {
|
||||||
|
if(!$this->orderproduct_id) return null;
|
||||||
|
|
||||||
|
$journals = [];
|
||||||
|
|
||||||
|
$order = $this->getProperty("orderproduct")->order;
|
||||||
|
foreach($order->journal as $j) {
|
||||||
|
$oj = new Contractjournal();
|
||||||
|
$oj->type = "order_comment";
|
||||||
|
$oj->value = "";
|
||||||
|
$oj->text = $j->text;
|
||||||
|
$journals[] = $oj;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->orderjournals = $journals;
|
||||||
|
return $this->orderjournals;
|
||||||
|
}
|
||||||
|
|
||||||
if($name == "links") {
|
if($name == "links") {
|
||||||
$this->links = ContractLinkModel::includesContractId($this->id, ["type" => "link"]);
|
$this->links = ContractLinkModel::includesContractId($this->id, ["type" => "link"]);
|
||||||
|
|||||||
Reference in New Issue
Block a user