2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM Community Edition is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
40 * view.showduplicates.php
42 * This is the SugarView subclass to handle displaying the list of duplicate Leads found when attempting to create
43 * a new Lead. This class is called from the LeadFormBase class handleSave function.
45 class ViewShowDuplicates extends SugarView
51 global $app_list_strings;
53 global $current_language;
56 if(!isset($_SESSION['SHOW_DUPLICATES']))
58 $GLOBALS['log']->error("Unauthorized access to this area.");
59 sugar_die("Unauthorized access to this area.");
62 parse_str($_SESSION['SHOW_DUPLICATES'],$_POST);
63 unset($_SESSION['SHOW_DUPLICATES']);
67 require_once('modules/Leads/LeadFormBase.php');
68 $leadForm = new LeadFormBase();
69 $GLOBALS['check_notify'] = FALSE;
71 $query = 'SELECT id, first_name, last_name, title FROM leads WHERE deleted=0 ';
73 $duplicates = $_POST['duplicate'];
74 $count = count($duplicates);
79 foreach ($duplicates as $duplicate_id)
81 if (!$first) $query .= ' OR ';
83 $query .= "id='$duplicate_id' ";
88 $duplicateLeads = array();
89 $db = DBManagerFactory::getInstance();
90 $result = $db->query($query);
92 while (($row=$db->fetchByAssoc($result)) != null) {
93 $duplicateLeads[$i] = $row;
97 $this->ss->assign('FORMBODY', $leadForm->buildTableForm($duplicateLeads));
100 foreach ($lead->column_fields as $field)
102 if (!empty($_POST['Leads'.$field])) {
103 $input .= "<input type='hidden' name='$field' value='${_POST['Leads'.$field]}'>\n";
107 foreach ($lead->additional_column_fields as $field)
109 if (!empty($_POST['Leads'.$field])) {
110 $input .= "<input type='hidden' name='$field' value='${_POST['Leads'.$field]}'>\n";
114 // Bug 25311 - Add special handling for when the form specifies many-to-many relationships
115 if(!empty($_POST['Leadsrelate_to'])) {
116 $input .= "<input type='hidden' name='relate_to' value='{$_POST['Leadsrelate_to']}'>\n";
119 if(!empty($_POST['Leadsrelate_id'])) {
120 $input .= "<input type='hidden' name='relate_id' value='{$_POST['Leadsrelate_id']}'>\n";
124 $emailAddress = new SugarEmailAddress();
125 $input .= $emailAddress->getEmailAddressWidgetDuplicatesView($lead);
128 if(!empty($_POST['return_module']))
130 $this->ss->assign('RETURN_MODULE', $_POST['return_module']);
135 $get .= "&return_action=";
136 if(!empty($_POST['return_action']))
138 $this->ss->assign('RETURN_ACTION', $_POST['return_action']);
140 $get .= "DetailView";
143 ///////////////////////////////////////////////////////////////////////////////
144 //// INBOUND EMAIL WORKFLOW
145 if(isset($_REQUEST['inbound_email_id'])) {
146 $this->ss->assign('INBOUND_EMAIL_ID', $_REQUEST['inbound_email_id']);
147 $this->ss->assign('RETURN_MODULE', 'Emails');
148 $this->ss->assign('RETURN_ACTION', 'EditView');
149 if(isset($_REQUEST['start'])) {
150 $this->ss->assign('START', $_REQUEST['start']);
153 //// END INBOUND EMAIL WORKFLOW
154 ///////////////////////////////////////////////////////////////////////////////
155 if(!empty($_POST['popup']))
157 $input .= '<input type="hidden" name="popup" value="'.$_POST['popup'].'">';
159 $input .= '<input type="hidden" name="popup" value="false">';
162 if(!empty($_POST['to_pdf']))
164 $input .= '<input type="hidden" name="to_pdf" value="'.$_POST['to_pdf'].'">';
166 $input .= '<input type="hidden" name="to_pdf" value="false">';
169 if(!empty($_POST['create']))
171 $input .= '<input type="hidden" name="create" value="'.$_POST['create'].'">';
173 $input .= '<input type="hidden" name="create" value="false">';
176 if(!empty($_POST['return_id']))
178 $this->ss->assign('RETURN_ID', $_POST['return_id']);
181 $this->ss->assign('INPUT_FIELDS', $input);
183 //Load the appropriate template
184 $template = 'modules/Leads/tpls/ShowDuplicates.tpl';
185 if(file_exists('custom/' . $template))
187 $template = 'custom/' . $template;
190 $saveLabel = string_format($app_strings['LBL_SAVE_OBJECT'], array($this->module));
191 $this->ss->assign('TITLE', getClassicModuleTitle('Leads', array($this->module, $saveLabel), true));
192 $this->ss->display($template);