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.
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/JSON.php');
53 global $app_list_strings;
54 global $current_language;
55 global $currentModule;
58 $json=new JSON(JSON_LOOSE_TYPE);
60 $current_module_strings = return_module_language($current_language, 'MergeRecords');
62 if (!isset($where)) $where = "";
64 $focus = new MergeRecord();
66 ////////////////////////////////////////////////////////////
67 //get instance of master record and retrieve related record
69 ////////////////////////////////////////////////////////////
70 $focus->merge_module = $_REQUEST['return_module'];
71 $focus->load_merge_bean($focus->merge_module, true, $_REQUEST['record']);
74 //get all available column fields
75 //TO DO: add custom field handling
76 $avail_fields=array();
78 $temp_field_array = $focus->merge_bean->field_defs;
80 foreach($temp_field_array as $field_array)
82 if (isset($field_array['merge_filter'])
84 if (strtolower($field_array['merge_filter'])=='enabled' or strtolower($field_array['merge_filter'])=='selected') {
85 $col_name = $field_array['name'];
88 if(!isset($focus->merge_bean_strings[$field_array['vname']])) {
89 $col_label = $col_name;
92 $col_label = str_replace(':', '', $focus->merge_bean_strings[$field_array['vname']]);
95 if (strtolower($field_array['merge_filter'])=='selected') {
96 $sel_fields[$col_name]=$col_label;
98 $avail_fields[$col_name] = $col_label;
101 $bean_data[$col_name]=$focus->merge_bean->$col_name;
106 /////////////////////////////////////////////////////////
108 //Print the master record header to the page
110 $params[] = "<a href='index.php?module={$focus->merge_bean->module_dir}&action=index'>{$GLOBALS['app_list_strings']['moduleList'][$focus->merge_bean->module_dir]}</a>";
111 $params[] = "<a href='index.php?module={$focus->merge_bean->module_dir}&action=DetailView&record={$focus->merge_bean->id}'>{$focus->merge_bean->name}</a>";
112 $params[] = $mod_strings['LBL_LBL_MERGE_RECORDS_STEP_1'];
113 echo getClassicModuleTitle($focus->merge_bean->module_dir, $params, true);
115 $xtpl = new XTemplate ('modules/MergeRecords/Step1.html');
116 $xtpl->assign("MOD", $mod_strings);
117 $xtpl->assign("APP", $app_strings);
118 $xtpl->assign("BEANDATA",$json->encode($bean_data));
119 //This is for the implemetation of finding all dupes for a module, not just
120 //dupes for a particular record
121 //commenting this out for now
122 //$choose_master_by_options = array('First Record Found', 'Most Recent Record', 'Oldest Record', 'Record Containing Most Data');
123 //$xtpl->assign("CHOOSE_MASTER_BY_OPTIONS", get_select_options_with_id($choose_master_by_options, 'First Record Found'));
125 $xtpl->assign("MERGE_MODULE", $focus->merge_module);
126 $xtpl->assign("ID", $focus->merge_bean->id);
128 $xtpl->assign("FIELD_AVAIL_OPTIONS", get_select_options_with_id($avail_fields,''));
129 $xtpl->assign("LBL_ADD_BUTTON", translate('LBL_ADD_BUTTON'));
131 if(isset($_REQUEST['return_id'])) $xtpl->assign("RETURN_ID", $_REQUEST['return_id']);
132 $xtpl->assign("RETURN_ACTION", $_REQUEST['return_action']);
133 $xtpl->assign("RETURN_MODULE", $_REQUEST['return_module']);
137 if(isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != 80 && $_SERVER['SERVER_PORT'] != 443) {
138 $port = $_SERVER['SERVER_PORT'];
140 $xtpl->assign("URL", appendPortToHost($sugar_config['site_url'], $port));
142 $xtpl->assign("RIGHTARROW_BIG_IMAGE", SugarThemeRegistry::current()->getImageURL('rightarrow_big.gif'));
143 $xtpl->assign("DELETE_INLINE_IMAGE", SugarThemeRegistry::current()->getImageURL('delete_inline.gif'));
145 //process preloaded filter.
147 foreach ($sel_fields as $colName=>$colLabel) {
148 $pre_loaded.=addFieldRow($colName,$colLabel,$bean_data[$colName]);
150 $xtpl->assign("PRE_LOADED_FIELDS",$pre_loaded);
151 $xtpl->assign("OPERATOR_OPTIONS",$json->encode($app_list_strings['merge_operators_dom']));
154 $xtpl->parse("main.field_select_block");
156 $xtpl->parse("main");
161 * This function is equivalent of AddFieldRow in merge.js. is being used to
162 * preload the filter criteria based on the vardef.
163 * <span><table><tr><td></td><td></td><td></td></tr></table></span>
165 function addFieldRow($colName,$colLabel,$colValue) {
166 global $theme, $app_list_strings;
168 static $operator_options;
169 if (empty($operator_options)) {
170 $operator_options= get_select_options_with_id($app_list_strings['merge_operators_dom'],'');
173 $LBL_REMOVE = translate('LBL_REMOVE');
174 $deleteInlineImage = SugarThemeRegistry::current()->getImageURL('delete_inline.gif');
176 <span id=filter_{$colName} style='visibility:visible' value="{$colLabel}" valueId="{$colName}">
177 <table width='100%' border='0' cellpadding='0'>
179 <td width='2%'><a class="listViewTdToolsS1" href="javascript:remove_filter('filter_{$colName}')"><!--not_in_theme!--><img src='{$deleteInlineImage}' align='absmiddle' alt='{$LBL_REMOVE}' border='0' height='12' width='12'> </a></td>
180 <td width='20%'>{$colLabel}: </td>
181 <td width='10%'><select name='{$colName}SearchType'>{$operator_options}</select></td>
182 <td width='68%'><input value="{$colValue}" id="{$colName}SearchField" name="{$colName}SearchField" type="text"></td>