Merge branch 'fronkdev' into 'master'
Fixed finding orders in ivt import See merge request fronk/thetool!434
This commit is contained in:
@@ -429,6 +429,7 @@ class Admin_IvtContractImport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(array_key_exists($owner->id, $this->ownerIdToBillingAddress)) {
|
if(array_key_exists($owner->id, $this->ownerIdToBillingAddress)) {
|
||||||
|
//echo "1 produkt: '".$product->name."': Billingaddress id: ".$this->ownerIdToBillingAddress[$owner->id]."\n";
|
||||||
return ["billingaddress_id" => $this->ownerIdToBillingAddress[$owner->id]];
|
return ["billingaddress_id" => $this->ownerIdToBillingAddress[$owner->id]];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,11 +450,13 @@ class Admin_IvtContractImport {
|
|||||||
|
|
||||||
$billingaddress = new Address($order->billingaddress_id);
|
$billingaddress = new Address($order->billingaddress_id);
|
||||||
if (!$billingaddress->id) {
|
if (!$billingaddress->id) {
|
||||||
die("Billingaddress " . $order->billingaddress_id . " does not exist (order " . $order->id . "; ivt customer $ivt_custnum)");
|
die("Billingaddress " . $order->billingaddress_id . " does not exist (order " . $order->id . "; ivt customer $ivt_custnum)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
$compare_address = $billingaddress;
|
$compare_address = $billingaddress;
|
||||||
$compare_type = "billingaddress";
|
$compare_type = "billingaddress";
|
||||||
|
//echo "setting compare_type = billingaddress\n";
|
||||||
|
//var_dump($order);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -467,6 +470,8 @@ class Admin_IvtContractImport {
|
|||||||
|
|
||||||
$address_update = $this->compareBillingAddresses($ivt_customer, $compare_address);
|
$address_update = $this->compareBillingAddresses($ivt_customer, $compare_address);
|
||||||
if($address_update === true) {
|
if($address_update === true) {
|
||||||
|
//echo "addressupdate == true; compare type: $compare_type\n";
|
||||||
|
//var_dump($address_update);
|
||||||
$return["billingaddress_id"] = $compare_address->id;
|
$return["billingaddress_id"] = $compare_address->id;
|
||||||
} elseif(is_array($address_update) && count($address_update)) {
|
} elseif(is_array($address_update) && count($address_update)) {
|
||||||
if($compare_type == "billingaddress") {
|
if($compare_type == "billingaddress") {
|
||||||
@@ -476,15 +481,17 @@ class Admin_IvtContractImport {
|
|||||||
die("error updateing Billingaddress");
|
die("error updateing Billingaddress");
|
||||||
}
|
}
|
||||||
$this->ownerIdToBillingAddress[$owner->id] = $compare_address->id;
|
$this->ownerIdToBillingAddress[$owner->id] = $compare_address->id;
|
||||||
|
//echo "address_update has data\n";
|
||||||
$return["billingaddress_id"] = $compare_address->id;
|
$return["billingaddress_id"] = $compare_address->id;
|
||||||
} else {
|
} else {
|
||||||
// create billingaddress
|
// create billingaddress
|
||||||
$billingaddress = AddressModel::create($address_update);
|
$billingaddress = AddressModel::create($address_update);
|
||||||
try {
|
try {
|
||||||
if(!$billingaddress->save()) {
|
if(!$billingaddress->save()) {
|
||||||
var_dump($address_update);
|
//var_dump($address_update);
|
||||||
die("error creating Billingaddress");
|
die("error creating Billingaddress");
|
||||||
}
|
}
|
||||||
|
//echo "create billingaddress\n";
|
||||||
$return["billingaddress_id"] = $billingaddress->id;
|
$return["billingaddress_id"] = $billingaddress->id;
|
||||||
if(!array_key_exists($owner->id, $this->ownerIdToBillingAddress)) {
|
if(!array_key_exists($owner->id, $this->ownerIdToBillingAddress)) {
|
||||||
$this->ownerIdToBillingAddress[$owner->id] = $billingaddress->id;
|
$this->ownerIdToBillingAddress[$owner->id] = $billingaddress->id;
|
||||||
@@ -505,7 +512,7 @@ class Admin_IvtContractImport {
|
|||||||
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
echo "Exception: ".$e->getMessage()."\n";
|
echo "Exception: ".$e->getMessage()."\n";
|
||||||
var_dump($address_update);
|
//var_dump($address_update);
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,6 +520,7 @@ class Admin_IvtContractImport {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//echo "2 produkt: '".$product->name."': Billingaddress id: ".$return["billingaddress_id"]."\n";
|
||||||
return $return;
|
return $return;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -819,6 +827,7 @@ class Admin_IvtContractImport {
|
|||||||
if(!$order->id) {
|
if(!$order->id) {
|
||||||
die("Manually specified order id ".$this->static_ivt_order_match[$ivt_contract->id]." not found for customer ".$ivt_customer->id);
|
die("Manually specified order id ".$this->static_ivt_order_match[$ivt_contract->id]." not found for customer ".$ivt_customer->id);
|
||||||
}
|
}
|
||||||
|
//echo "order 1\n";
|
||||||
return $order;
|
return $order;
|
||||||
} else {
|
} else {
|
||||||
$order_count = OrderModel::count(["owner_id" => $owner->id, "finish_date" => true]);
|
$order_count = OrderModel::count(["owner_id" => $owner->id, "finish_date" => true]);
|
||||||
@@ -827,9 +836,10 @@ class Admin_IvtContractImport {
|
|||||||
if ($order_count > 1) {
|
if ($order_count > 1) {
|
||||||
$found_product = 0;
|
$found_product = 0;
|
||||||
foreach(OrderModel::search(["owner_id" => $owner->id, "finish_date" => true]) as $o) {
|
foreach(OrderModel::search(["owner_id" => $owner->id, "finish_date" => true]) as $o) {
|
||||||
|
//var_dump($o);exit;
|
||||||
// find the one with the right product
|
// find the one with the right product
|
||||||
foreach(OrderProductModel::search(["order_id" => $o->id, "product_id" => $product->id]) as $op) {
|
foreach(OrderProductModel::search(["order_id" => $o->id, "product_id" => $product->id]) as $op) {
|
||||||
$order_id = $op->id;
|
$order_id = $op->order_id;
|
||||||
$found_product++;
|
$found_product++;
|
||||||
}
|
}
|
||||||
if($found_product > 1) {
|
if($found_product > 1) {
|
||||||
@@ -840,6 +850,7 @@ class Admin_IvtContractImport {
|
|||||||
if(!$order) {
|
if(!$order) {
|
||||||
die("Order $order_id not found");
|
die("Order $order_id not found");
|
||||||
}
|
}
|
||||||
|
//echo "order 2 (owner_id $owner->id)\n";
|
||||||
return $order;
|
return $order;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user