]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/MergeRecords/Step2.php
Release 6.5.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-2012 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[] = $mod_strings['LBL_STEP2_FORM_TITLE'];
69 $params[] = $focus->merge_bean->name;
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->delete = false;
97 $module = $_REQUEST['merge_module'];
98 $metadataFile = null;
99 $foundViewDefs = false;
100 if(file_exists('custom/modules/' . $module. '/metadata/listviewdefs.php')){
101     $metadataFile = 'custom/modules/' . $module . '/metadata/listviewdefs.php';
102     $foundViewDefs = true;
103 }else{
104     if(file_exists('custom/modules/'.$module.'/metadata/metafiles.php')){
105         require_once('custom/modules/'.$module.'/metadata/metafiles.php');
106         if(!empty($metafiles[$module]['listviewdefs'])){
107             $metadataFile = $metafiles[$module]['listviewdefs'];
108             $foundViewDefs = true;
109         }
110     }elseif(file_exists('modules/'.$module.'/metadata/metafiles.php')){
111         require_once('modules/'.$module.'/metadata/metafiles.php');
112         if(!empty($metafiles[$module]['listviewdefs'])){
113             $metadataFile = $metafiles[$module]['listviewdefs'];
114             $foundViewDefs = true;
115         }
116     }
117 }
118 if(!$foundViewDefs && file_exists('modules/'.$module.'/metadata/listviewdefs.php')){
119         $metadataFile = 'modules/'.$module.'/metadata/listviewdefs.php';
120 }
121 require_once($metadataFile);
122 $displayColumns = array();
123 if(!empty($_REQUEST['displayColumns'])) {
124     foreach(explode('|', $_REQUEST['displayColumns']) as $num => $col) {
125         if(!empty($listViewDefs[$module][$col])) 
126             $displayColumns[$col] = $listViewDefs[$module][$col];
127     }    
128 }
129 else {
130     foreach($listViewDefs[$module] as $col => $params) {
131         if(!empty($params['default']) && $params['default'])
132             $displayColumns[$col] = $params;
133     }
134
135 $params = array('massupdate' => true, 'export' => false, 'handleMassupdate' => false );
136 $ListView->displayColumns = $displayColumns;
137 $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.
138 $where = $focus->generate_where_statement($focus->create_where_statement());
139 $ListView->showMassupdateFields=false;
140 $ListView->email=false;
141 $ListView->setup($this->bean, 'include/ListView/ListViewGeneric.tpl', $where, $params);
142 $ListView->force_mass_update=true;
143 $ListView->show_mass_update_form=false;
144 $ListView->show_export_button=false;
145 $ListView->keep_mass_update_form_open=true;
146
147 $return_id = $_REQUEST['record'];
148 $merge_module = $focus->merge_module;
149
150 $button_title = $current_module_strings['LBL_PERFORM_MERGE_BUTTON_TITLE'];
151 $button_key = $current_module_strings['LBL_PERFORM_MERGE_BUTTON_KEY'];
152 $button_label = $current_module_strings['LBL_PERFORM_MERGE_BUTTON_LABEL'];
153
154 $cancel_title=$app_strings['LBL_CANCEL_BUTTON_TITLE'];
155 $cancel_key=$app_strings['LBL_CANCEL_BUTTON_KEY'];
156 $cancel_label=$app_strings['LBL_CANCEL_BUTTON_LABEL'];
157
158 echo ($ListView->display());
159
160 $error_select=$current_module_strings['LBL_SELECT_ERROR'];
161 $form_top = <<<EOQ
162
163             <input type="hidden" id="selectCount" name="selectCount[]" value=0>
164                         <input type="hidden" name="merge_module" value="$merge_module">
165                         <input type="hidden" name="record" value="$return_id">
166                         <input type="hidden" name="return_module" value="$focus->merge_module">
167                         <input type="hidden" name="return_id" value="$return_id">
168                         <input type="hidden" name="return_action" value="DetailView">
169                         <input title="$button_title" class="button" onclick="return verify_selection(this);" type="submit" name="button" value="  $button_label  " >
170             <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   " >
171                 </form>
172         <script>
173            function verify_selection(theElement) {
174                 theElement.form.action.value='Step3';
175                 var selcount=document.getElementById('selectCountTop');
176                 if (parseInt(selcount.value) >0 ) {
177                     return true;
178                 } else {
179                     alert("$error_select");
180                     return false;
181                 }
182            }
183            sugarListView.prototype.order_checks = function(order,orderBy,moduleString){
184                 checks = sugarListView.get_checks();
185                 eval('document.MassUpdate.' + moduleString + '.value = orderBy');
186                 document.MassUpdate.lvso.value = order;
187                 if(typeof document.MassUpdate.massupdate != 'undefined') {
188                    document.MassUpdate.massupdate.value = 'false';
189                 }
190                 
191                 document.MassUpdate.return_module.value='';
192                 document.MassUpdate.return_action.value='';
193                 document.MassUpdate.submit();
194                 
195                 return !checks;
196             }
197
198             sugarListView.prototype.save_checks = function(offset, moduleString) {
199                 checks = sugarListView.get_checks();
200                 eval('document.MassUpdate.' + moduleString + '.value = offset');
201                 
202                 if(typeof document.MassUpdate.massupdate != 'undefined') {
203                    document.MassUpdate.massupdate.value = 'false';
204                 }
205                 
206                 document.MassUpdate.return_module.value='';
207                 document.MassUpdate.return_action.value='';
208                 document.MassUpdate.submit();
209                 
210                 return !checks;
211             }
212         </script>
213 EOQ;
214 echo $form_top;
215 ?>