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-2012 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 ********************************************************************************/
38 /*********************************************************************************
40 * Description: TODO: To be written.
41 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
42 * All Rights Reserved.
43 * Contributor(s): ______________________________________..
44 ********************************************************************************/
49 require_once('include/ListView/ListViewSmarty.php');
50 require_once('include/MVC/View/views/view.list.php');
52 global $app_list_strings;
53 global $current_language;
55 global $currentModule;
58 $current_module_strings = return_module_language($current_language, 'MergeRecords');
61 $focus = new MergeRecord();
62 $focus->load_merge_bean($_REQUEST['merge_module'], true, $_REQUEST['record']);
64 $this->bean = $focus->merge_bean;
67 $params[] = "<a href='index.php?module={$focus->merge_bean->module_dir}&action=index'>{$GLOBALS['app_list_strings']['moduleList'][$focus->merge_bean->module_dir]}</a>";
68 $params[] = "<a href='index.php?module={$focus->merge_bean->module_dir}&action=DetailView&record={$focus->merge_bean->id}'>{$focus->merge_bean->name}</a>";
69 $params[] = $mod_strings['LBL_STEP2_FORM_TITLE'];
70 echo getClassicModuleTitle($focus->merge_bean->module_dir, $params, true);
72 $order_by_name = $focus->merge_module.'2_'.strtoupper($focus->merge_bean->object_name).'_ORDER_BY' ;
73 $lvso = isset($_REQUEST['lvso'])?$_REQUEST['lvso']:"";
74 $request_order_by_name = isset($_REQUEST[$order_by_name])?$_REQUEST[$order_by_name]:"";
76 echo '<form onsubmit="return check_form(\'MassUpdate\');" id="MassUpdate" name="MassUpdate" method="post" action="index.php">'
77 .'<input type="hidden" value="Step2" name="action"/>'
78 .'<input type="hidden" value="true" name="massupdate"/>'
79 .'<input type="hidden" value="false" name="delete"/>'
80 .'<input type="hidden" value="false" name="merge"/>'
81 .'<input type="hidden" value="MergeRecords" name="module"/>'
82 ."<input type='hidden' name='lvso' value='{$lvso}' />"
83 ."<input type='hidden' name='{$order_by_name}' value='{$request_order_by_name}' />";
85 $focus->populate_search_params($_REQUEST);
86 echo $focus->get_inputs_for_search_params($_REQUEST);
88 $where_clauses = Array();
89 $where_clauses = $focus->create_where_statement();
90 $where = $focus->generate_where_statement($where_clauses);
92 $ListView = new ListViewSmarty();
93 $ListView->should_process = true;
94 $ListView->mergeduplicates = false;
95 $ListView->export = false;
96 $ListView->select = false;
97 $ListView->delete = false;
98 $module = $_REQUEST['merge_module'];
100 $foundViewDefs = false;
101 if(file_exists('custom/modules/' . $module. '/metadata/listviewdefs.php')){
102 $metadataFile = 'custom/modules/' . $module . '/metadata/listviewdefs.php';
103 $foundViewDefs = true;
105 if(file_exists('custom/modules/'.$module.'/metadata/metafiles.php')){
106 require_once('custom/modules/'.$module.'/metadata/metafiles.php');
107 if(!empty($metafiles[$module]['listviewdefs'])){
108 $metadataFile = $metafiles[$module]['listviewdefs'];
109 $foundViewDefs = true;
111 }elseif(file_exists('modules/'.$module.'/metadata/metafiles.php')){
112 require_once('modules/'.$module.'/metadata/metafiles.php');
113 if(!empty($metafiles[$module]['listviewdefs'])){
114 $metadataFile = $metafiles[$module]['listviewdefs'];
115 $foundViewDefs = true;
119 if(!$foundViewDefs && file_exists('modules/'.$module.'/metadata/listviewdefs.php')){
120 $metadataFile = 'modules/'.$module.'/metadata/listviewdefs.php';
122 require_once($metadataFile);
123 $displayColumns = array();
124 if(!empty($_REQUEST['displayColumns'])) {
125 foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) {
126 if(!empty($listViewDefs[$module][$col]))
127 $displayColumns[$col] = $listViewDefs[$module][$col];
131 foreach($listViewDefs[$module] as $col => $params) {
132 if(!empty($params['default']) && $params['default'])
133 $displayColumns[$col] = $params;
136 $params = array('massupdate' => true, 'export' => false, 'handleMassupdate' => false );
137 $ListView->displayColumns = $displayColumns;
138 $ListView->lvd->listviewName = $focus->merge_module; //27633, this will make the $module to be merge_module instead of 'MergeRecords'. Then the key of offset and orderby will be correct.
139 $where = $focus->generate_where_statement($focus->create_where_statement());
140 $ListView->showMassupdateFields=false;
141 $ListView->email=false;
142 $ListView->setup($this->bean, 'include/ListView/ListViewGeneric.tpl', $where, $params);
143 $ListView->force_mass_update=true;
144 $ListView->show_mass_update_form=false;
145 $ListView->show_export_button=false;
146 $ListView->keep_mass_update_form_open=true;
148 $return_id = $_REQUEST['record'];
149 $merge_module = $focus->merge_module;
151 $button_title = $current_module_strings['LBL_PERFORM_MERGE_BUTTON_TITLE'];
152 $button_key = $current_module_strings['LBL_PERFORM_MERGE_BUTTON_KEY'];
153 $button_label = $current_module_strings['LBL_PERFORM_MERGE_BUTTON_LABEL'];
155 $cancel_title=$app_strings['LBL_CANCEL_BUTTON_TITLE'];
156 $cancel_key=$app_strings['LBL_CANCEL_BUTTON_KEY'];
157 $cancel_label=$app_strings['LBL_CANCEL_BUTTON_LABEL'];
159 echo ($ListView->display());
161 $error_select=$current_module_strings['LBL_SELECT_ERROR'];
164 <input type="hidden" id="selectCount" name="selectCount[]" value=0>
165 <input type="hidden" name="merge_module" value="$merge_module">
166 <input type="hidden" name="record" value="$return_id">
167 <input type="hidden" name="return_module" value="$focus->merge_module">
168 <input type="hidden" name="return_id" value="$return_id">
169 <input type="hidden" name="return_action" value="DetailView">
170 <input title="$button_title" class="button" onclick="return verify_selection(this);" type="submit" name="button" value=" $button_label " >
171 <input title="$cancel_title" accessKey="$cancel_key" class="button" onclick="this.form.action.value='DetailView';this.form.module.value='$focus->merge_module';this.form.module.record='$return_id'" type="submit" name="button" value=" $cancel_label " >
174 function verify_selection(theElement) {
175 theElement.form.action.value='Step3';
176 var selcount=document.getElementById('selectCount');
177 if (parseInt(selcount.value) >0 ) {
180 alert("$error_select");
184 sugarListView.prototype.order_checks = function(order,orderBy,moduleString){
185 checks = sugarListView.get_checks();
186 eval('document.MassUpdate.' + moduleString + '.value = orderBy');
187 document.MassUpdate.lvso.value = order;
188 if(typeof document.MassUpdate.massupdate != 'undefined') {
189 document.MassUpdate.massupdate.value = 'false';
192 document.MassUpdate.return_module.value='';
193 document.MassUpdate.return_action.value='';
194 document.MassUpdate.submit();
199 sugarListView.prototype.save_checks = function(offset, moduleString) {
200 checks = sugarListView.get_checks();
201 eval('document.MassUpdate.' + moduleString + '.value = offset');
203 if(typeof document.MassUpdate.massupdate != 'undefined') {
204 document.MassUpdate.massupdate.value = 'false';
207 document.MassUpdate.return_module.value='';
208 document.MassUpdate.return_action.value='';
209 document.MassUpdate.submit();