public function admin_duplicate_account() {
$this->User->unBindModel(array('hasOne' => array('Admin')));
if ($this->request->is('post') || $this->request->is('put')) {
// pr($this->request->data); exit;
if ($this->request->data['User']['email'] == 1) {
$arr_having = array();
$arr_having['fields'] = 'User.email';
$arr_having['group'] = 'User.email HAVING COUNT(*) > 1';
$regs = $this->User->find('all', $arr_having, array('conditions' => array('User.role' => array('U', 'P'), 'User.user_status' => array('active', 'lead', 'inactive'))));
$names = array();
foreach ($regs as $reg) {
if ($reg['User']['email']) {
$names[] = $reg['User']['email'];
}
}
$this->set('allusers', $this->User->find('all', array(
'conditions' => array('User.email' => $names, 'User.role' => array('U', 'P'), 'User.user_status' => array('active', 'lead', 'inactive')))));
}
if ($this->request->data['User']['first_name'] == 1) {
$arr_having = array();
$arr_having['fields'] = 'PersonalInformation.first_name';
$arr_having['group'] = 'PersonalInformation.first_name HAVING COUNT(*) > 1';
$regs = $this->User->find('all', $arr_having, array('conditions' => array('User.role' => array('U', 'P'), 'User.user_status' => array('active', 'lead', 'inactive'))));
//pr($regs); exit;
$names = array();
foreach ($regs as $reg) {
if ($reg['PersonalInformation']['first_name']) {
$names[] = $reg['PersonalInformation']['first_name'];
}
//$names[] = $reg['PersonalInformation']['first_name'];
}
//pr($names);
$data = $this->User->find('all', array(
'conditions' => array('PersonalInformation.first_name' => $names, 'User.role' => array('U', 'P'), 'User.user_status' => array('active', 'lead', 'inactive'))));
//pr($data); exit;
$this->set('allusers', $data);
}
if ($this->request->data['User']['last_name'] == 1) {
$arr_having = array();
$arr_having['fields'] = 'PersonalInformation.last_name';
$arr_having['group'] = 'PersonalInformation.last_name HAVING COUNT(*) > 1';
$regs = $this->User->find('all', $arr_having, array('conditions' => array('User.role' => array('U', 'P'), 'User.user_status' => array('active', 'lead', 'inactive'))));
//pr($regs); exit;
$names = array();
foreach ($regs as $reg) {
if ($reg['PersonalInformation']['last_name']) {
$names[] = $reg['PersonalInformation']['last_name'];
}
//$names[] = $reg['PersonalInformation']['first_name'];
}
//pr($names);
$data = $this->User->find('all', array(
'conditions' => array('PersonalInformation.last_name' => $names, 'User.role' => array('U', 'P'), 'User.user_status' => array('active', 'lead', 'inactive'))));
//pr($data); exit;
$this->set('allusers', $data);
}
if ($this->request->data['User']['primary_phone'] == 1) {
$arr_having = array();
$arr_having['fields'] = 'PersonalInformation.primary_phone';
$arr_having['group'] = 'PersonalInformation.primary_phone HAVING COUNT(*) > 1';
$regs = $this->User->find('all', $arr_having, array('conditions' => array('User.role' => array('U', 'P'), 'User.user_status' => array('active', 'lead', 'inactive'))));
//pr($regs); exit;
$names = array();
foreach ($regs as $reg) {
if ($reg['PersonalInformation']['primary_phone']) {
$names[] = $reg['PersonalInformation']['primary_phone'];
}
}
//pr($names);
$data = $this->User->find('all', array(
'conditions' => array('PersonalInformation.primary_phone' => $names, 'User.role' => array('U', 'P'), 'User.user_status' => array('active', 'lead', 'inactive'))));
//pr($data); exit;
$this->set('allusers', $data);
}
if ($this->request->data['User']['dob'] == 1) {
$arr_having = array();
$arr_having['fields'] = 'PersonalInformation.dob';
$arr_having['group'] = 'PersonalInformation.dob HAVING COUNT(*) > 1';
$regs = $this->User->find('all', $arr_having, array('conditions' => array('User.role' => array('U', 'P'), 'User.user_status' => array('active', 'lead', 'inactive'))));
//pr($regs); exit;
$names = array();
foreach ($regs as $reg) {
if ($reg['PersonalInformation']['dob']) {
$names[] = $reg['PersonalInformation']['dob'];
}
}
//pr($names);
$data = $this->User->find('all', array(
'conditions' => array('PersonalInformation.dob' => $names, 'User.role' => array('U', 'P'), 'User.user_status' => array('active', 'lead', 'inactive'))));
//pr($data); exit;
$this->set('allusers', $data);
}
} else {
$this->set('allusers', $this->User->find('all', array(
'conditions' => array('User.role' => array('U', 'P'), 'User.user_status' => array('active', 'lead', 'inactive')))));
}
$this->layout = 'admin';
}