return; } } if (isset($_POST['newopportunity']) && $_POST['newopportunity'] == 'on' && !isset($_POST['selectedOpportunity']) && !isset($_POST['ContinueOpportunity'])) { $duplicateOpps = $oppForm->checkForDuplicates('Opportunities'); if (isset($duplicateOpps)) { $sugar_smarty->assign('DUPLICATEFORMBODY', $oppForm->buildTableForm($duplicateOpps)); $selected_menu = 'form'; echo $sugar_smarty->fetch('modules/Leads/ConvertLead.tpl'); return; } } if (!isset($_POST['selectedLeads']) && !isset($_POST['ContinueLead'])) { $duplicateLeads = $leadForm->checkForDuplicates('Contacts', $_REQUEST['record']); if (isset($duplicateLeads)) { $sugar_smarty->assign('DUPLICATEFORMBODY', $leadForm->buildTableForm($duplicateLeads, 'Leads')); $selected_menu = 'form'; echo $sugar_smarty->fetch('modules/Leads/ConvertLead.tpl'); return; } } if (isset($_POST['selectedContact']) && !empty($_POST['selectedContact'])) { $contact = new Contact(); $contact->retrieve($_POST['selectedContact']); } else { if (isset($lead->campaign_id) && $lead->campaign_id != null) { $_POST['Contactscampaign_id'] = $lead->campaign_id; } $contact = $contactForm->handleSave('Contacts', false, false); if (isset($lead->campaign_id) && $lead->campaign_id != null) { campaign_log_lead_entry($lead->campaign_id, $lead, $contact, 'contact');
function display() { global $app_strings; global $app_list_strings; global $theme; global $current_language; global $mod_strings; if (!isset($_SESSION['SHOW_DUPLICATES'])) { Log::error("Unauthorized access to this area."); sugar_die("Unauthorized access to this area."); } parse_str($_SESSION['SHOW_DUPLICATES'], $_POST); $post = array_map("securexss", $_POST); foreach ($post as $k => $v) { $_POST[$k] = $v; } 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 = []; $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 .= "<input type='hidden' name='{$field}' value='{$_POST['Leads' . $field]}'>\n"; } } foreach ($lead->additional_column_fields as $field) { if (!empty($_POST['Leads' . $field])) { $input .= "<input type='hidden' name='{$field}' value='{$_POST['Leads' . $field]}'>\n"; } } // Bug 25311 - Add special handling for when the form specifies many-to-many relationships if (!empty($_POST['Leadsrelate_to'])) { $input .= "<input type='hidden' name='relate_to' value='{$_POST['Leadsrelate_to']}'>\n"; } if (!empty($_POST['Leadsrelate_id'])) { $input .= "<input type='hidden' name='relate_id' value='{$_POST['Leadsrelate_id']}'>\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 .= '<input type="hidden" name="popup" value="' . $_POST['popup'] . '">'; } else { $input .= '<input type="hidden" name="popup" value="false">'; } if (!empty($_POST['to_pdf'])) { $input .= '<input type="hidden" name="to_pdf" value="' . $_POST['to_pdf'] . '">'; } else { $input .= '<input type="hidden" name="to_pdf" value="false">'; } if (!empty($_POST['create'])) { $input .= '<input type="hidden" name="create" value="' . $_POST['create'] . '">'; } else { $input .= '<input type="hidden" name="create" value="false">'; } 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'], [$this->module]); $this->ss->assign('TITLE', getClassicModuleTitle('Leads', [$this->module, $saveLabel], true)); $this->ss->display($template); }
} } if (isset($_POST['newopportunity']) && $_POST['newopportunity'] == 'on' && !isset($_POST['selectedOpportunity']) && !isset($_POST['ContinueOpportunity'])) { $duplicateOpps = $oppForm->checkForDuplicates('Opportunities'); if (isset($duplicateOpps)) { $xtpl->assign('FORMBODY', $oppForm->buildTableForm($duplicateOpps)); $xtpl->parse('main.form'); $xtpl->parse('main'); $xtpl->out('main'); return; } } if (!isset($_POST['selectedLeads']) && !isset($_POST['ContinueLead'])) { $duplicateLeads = $leadForm->checkForDuplicates('Contacts', $_REQUEST['record']); if (isset($duplicateLeads)) { $xtpl->assign('FORMBODY', $leadForm->buildTableForm($duplicateLeads, 'Leads')); $xtpl->parse('main.form'); $xtpl->parse('main'); $xtpl->out('main'); return; } } if (isset($_POST['selectedContact']) && !empty($_POST['selectedContact'])) { $contact = new Contact(); $contact->retrieve($_POST['selectedContact']); } else { $contact = $contactForm->handleSave('Contacts', false, false); } if (isset($_POST['selectedAccount']) && !empty($_POST['selectedAccount']) || isset($_POST['newaccount']) && $_POST['newaccount'] == 'on') { if (isset($_POST['selectedAccount']) && !empty($_POST['selectedAccount'])) { $account = new Account();