error("Unauthorized access to this area."); sugar_die("Unauthorized access to this area."); } parse_str($_SESSION['SHOW_DUPLICATES'],$_POST); unset($_SESSION['SHOW_DUPLICATES']); $lead = new Lead(); require_once('modules/Leads/LeadFormBase.php'); $leadForm = new LeadFormBase(); $GLOBALS['check_notify'] = FALSE; $query = 'SELECT id, first_name, last_name, title FROM leads WHERE deleted=0 '; $duplicates = $_POST['duplicate']; $count = count($duplicates); if ($count > 0) { $query .= "and ("; $first = true; foreach ($duplicates as $duplicate_id) { if (!$first) $query .= ' OR '; $first = false; $query .= "id='$duplicate_id' "; } $query .= ')'; } $duplicateLeads = array(); $db = DBManagerFactory::getInstance(); $result = $db->query($query); $i=0; while (($row=$db->fetchByAssoc($result)) != null) { $duplicateLeads[$i] = $row; $i++; } $this->ss->assign('FORMBODY', $leadForm->buildTableForm($duplicateLeads)); $input = ''; foreach ($lead->column_fields as $field) { if (!empty($_POST['Leads'.$field])) { $input .= "\n"; } } foreach ($lead->additional_column_fields as $field) { if (!empty($_POST['Leads'.$field])) { $input .= "\n"; } } // Bug 25311 - Add special handling for when the form specifies many-to-many relationships if(!empty($_POST['Leadsrelate_to'])) { $input .= "\n"; } if(!empty($_POST['Leadsrelate_id'])) { $input .= "\n"; } $emailAddress = new SugarEmailAddress(); $input .= $emailAddress->getEmailAddressWidgetDuplicatesView($lead); $get = ''; if(!empty($_POST['return_module'])) { $this->ss->assign('RETURN_MODULE', $_POST['return_module']); } else { $get .= "Leads"; } $get .= "&return_action="; if(!empty($_POST['return_action'])) { $this->ss->assign('RETURN_ACTION', $_POST['return_action']); } else { $get .= "DetailView"; } /////////////////////////////////////////////////////////////////////////////// //// INBOUND EMAIL WORKFLOW if(isset($_REQUEST['inbound_email_id'])) { $this->ss->assign('INBOUND_EMAIL_ID', $_REQUEST['inbound_email_id']); $this->ss->assign('RETURN_MODULE', 'Emails'); $this->ss->assign('RETURN_ACTION', 'EditView'); if(isset($_REQUEST['start'])) { $this->ss->assign('START', $_REQUEST['start']); } } //// END INBOUND EMAIL WORKFLOW /////////////////////////////////////////////////////////////////////////////// if(!empty($_POST['popup'])) { $input .= ''; } else { $input .= ''; } if(!empty($_POST['to_pdf'])) { $input .= ''; } else { $input .= ''; } if(!empty($_POST['create'])) { $input .= ''; } else { $input .= ''; } if(!empty($_POST['return_id'])) { $this->ss->assign('RETURN_ID', $_POST['return_id']); } $this->ss->assign('INPUT_FIELDS', $input); //Load the appropriate template $template = 'modules/Leads/tpls/ShowDuplicates.tpl'; if(file_exists('custom/' . $template)) { $template = 'custom/' . $template; } $saveLabel = string_format($app_strings['LBL_SAVE_OBJECT'], array($this->module)); $this->ss->assign('TITLE', getClassicModuleTitle('Leads', array($this->module, $saveLabel), true)); $this->ss->display($template); } }