]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/MergeRecords/Step2.php
Release 6.2.0
[Github/sugarcrm.git] / modules / MergeRecords / Step2.php
1 <?php
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-2011 SugarCRM Inc.
6  * 
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.
13  * 
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
17  * details.
18  * 
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
22  * 02110-1301 USA.
23  * 
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.
26  * 
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.
30  * 
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  ********************************************************************************/
37
38 /*********************************************************************************
39
40  * Description:  TODO: To be written.
41  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
42  * All Rights Reserved.
43  * Contributor(s): ______________________________________..
44  ********************************************************************************/
45
46
47
48
49 require_once('include/ListView/ListViewSmarty.php');
50 require_once('include/MVC/View/views/view.list.php');
51 global $app_strings;
52 global $app_list_strings;
53 global $current_language;
54 global $urlPrefix;
55 global $currentModule;
56 global $theme;
57
58 $current_module_strings = return_module_language($current_language, 'MergeRecords');
59
60
61 $focus = new MergeRecord();
62 $focus->load_merge_bean($_REQUEST['merge_module'], true, $_REQUEST['record']);
63
64 $this->bean = $focus->merge_bean;
65
66 $params = array();
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);
71
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]:"";
75
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}' />";
84
85 $focus->populate_search_params($_REQUEST);
86 echo $focus->get_inputs_for_search_params($_REQUEST);
87
88 $where_clauses = Array();
89 $where_clauses = $focus->create_where_statement();
90 $where = $focus->generate_where_statement($where_clauses);
91
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'];
99 $metadataFile = null;
100 $foundViewDefs = false;
101 if(file_exists('custom/modules/' . $module. '/metadata/listviewdefs.php')){
102     $metadataFile = 'custom/modules/' . $module . '/metadata/listviewdefs.php';
103     $foundViewDefs = true;
104 }else{
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;
110         }
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;
116         }
117     }
118 }
119 if(!$foundViewDefs && file_exists('modules/'.$module.'/metadata/listviewdefs.php')){
120         $metadataFile = 'modules/'.$module.'/metadata/listviewdefs.php';
121 }
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];
128     }    
129 }
130 else {
131     foreach($listViewDefs[$module] as $col => $params) {
132         if(!empty($params['default']) && $params['default'])
133             $displayColumns[$col] = $params;
134     }
135
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->setup($this->bean, 'include/ListView/ListViewGeneric.tpl', $where, $params);
141 $ListView->force_mass_update=true;
142 $ListView->show_mass_update_form=false;
143 $ListView->show_export_button=false;
144 $ListView->keep_mass_update_form_open=true;
145
146 $return_id = $_REQUEST['record'];
147 $merge_module = $focus->merge_module;
148
149 $button_title = $current_module_strings['LBL_PERFORM_MERGE_BUTTON_TITLE'];
150 $button_key = $current_module_strings['LBL_PERFORM_MERGE_BUTTON_KEY'];
151 $button_label = $current_module_strings['LBL_PERFORM_MERGE_BUTTON_LABEL'];
152
153 $cancel_title=$app_strings['LBL_CANCEL_BUTTON_TITLE'];
154 $cancel_key=$app_strings['LBL_CANCEL_BUTTON_KEY'];
155 $cancel_label=$app_strings['LBL_CANCEL_BUTTON_LABEL'];
156
157 echo ($ListView->display());
158
159 $error_select=$current_module_strings['LBL_SELECT_ERROR'];
160 $form_top = <<<EOQ
161
162             <input type="hidden" id="selectCount" name="selectCount[]" value=0>
163                         <input type="hidden" name="merge_module" value="$merge_module">
164                         <input type="hidden" name="record" value="$return_id">
165                         <input type="hidden" name="return_module" value="$focus->merge_module">
166                         <input type="hidden" name="return_id" value="$return_id">
167                         <input type="hidden" name="return_action" value="DetailView">
168                         <input title="$button_title" accessKey="$button_key" class="button" onclick="return verify_selection(this);" type="submit" name="button" value="  $button_label  " >
169             <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   " >
170                 </form>
171         <script>
172            function verify_selection(theElement) {
173                 theElement.form.action.value='Step3';
174                 var selcount=document.getElementById('selectCount');
175                 if (parseInt(selcount.value) >0 ) {
176                     return true;
177                 } else {
178                     alert("$error_select");
179                     return false;
180                 }
181            }
182            sugarListView.prototype.order_checks = function(order,orderBy,moduleString){
183                 checks = sugarListView.get_checks();
184                 eval('document.MassUpdate.' + moduleString + '.value = orderBy');
185                 document.MassUpdate.lvso.value = order;
186                 if(typeof document.MassUpdate.massupdate != 'undefined') {
187                    document.MassUpdate.massupdate.value = 'false';
188                 }
189                 
190                 document.MassUpdate.return_module.value='';
191                 document.MassUpdate.return_action.value='';
192                 document.MassUpdate.submit();
193                 
194                 return !checks;
195             }
196
197             sugarListView.prototype.save_checks = function(offset, moduleString) {
198                 checks = sugarListView.get_checks();
199                 eval('document.MassUpdate.' + moduleString + '.value = offset');
200                 
201                 if(typeof document.MassUpdate.massupdate != 'undefined') {
202                    document.MassUpdate.massupdate.value = 'false';
203                 }
204                 
205                 document.MassUpdate.return_module.value='';
206                 document.MassUpdate.return_action.value='';
207                 document.MassUpdate.submit();
208                 
209                 return !checks;
210             }
211         </script>
212 EOQ;
213 echo $form_top;
214 ?>