diff --git a/site/models/customer.php b/site/models/customer.php index a01f8ba..675b753 100644 --- a/site/models/customer.php +++ b/site/models/customer.php @@ -330,13 +330,15 @@ class Customer extends AppModel { } // Remove any contacts which are already destination customer contacts - $contacts = array_diff($contacts, array_keys($dst_contacts)); + $new_contacts = array_diff($contacts, array_keys($dst_contacts)); + $all_contacts = array_merge($new_contacts, array_keys($dst_contacts)); + $this->pr(17, compact('new_contacts', 'all_contacts')); // For now, we'll assume the operation will succeed. $ret = true; // Add each desired source customer contact to the destination customer - foreach ($contacts AS $contact_id) { + foreach ($new_contacts AS $contact_id) { $CM = new ContactsCustomer(); if (!$CM->save(array('customer_id' => $dst_id) + $src_contacts[$contact_id], false)) { @@ -372,7 +374,7 @@ class Customer extends AppModel { $this->delete($src_id); // Delete all the orphaned customers - foreach (array_diff(array_keys($src_contacts), $contacts) AS $contact_id) { + foreach (array_diff(array_keys($src_contacts), $all_contacts) AS $contact_id) { // Delete un-used or duplicate contacts // REVISIT 20100702: // Not sure if we really want to do this.