Fixed a bug with customer merge. Common contacts were being deleted when selected as a source contact to keep.
git-svn-id: file:///svn-source/pmgr/branches/v0.3_work@1000 97e9348a-65ac-dc4b-aefc-98561f571b83
This commit is contained in:
@@ -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 <AP> 20100702:
|
||||
// Not sure if we really want to do this.
|
||||
|
||||
Reference in New Issue
Block a user