1 /*********************************************************************************
2 * SugarCRM Community Edition is a customer relationship management program developed by
3 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Affero General Public License version 3 as published by the
7 * Free Software Foundation with the addition of the following permission added
8 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
9 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
10 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
17 * You should have received a copy of the GNU Affero General Public License along with
18 * this program; if not, see http://www.gnu.org/licenses or write to the Free
19 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
23 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
25 * The interactive user interfaces in modified source and object code versions
26 * of this program must display Appropriate Legal Notices, as required under
27 * Section 5 of the GNU Affero General Public License version 3.
29 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
30 * these Appropriate Legal Notices must retain the display of the "Powered by
31 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
32 * technical reasons, the Appropriate Legal Notices must display the words
33 * "Powered by SugarCRM".
34 ********************************************************************************/
39 var lbl_remove = SUGAR.language.get('app_strings', 'LBL_REMOVE');
41 function remove_filter(spanfieldid) {
42 var selspan = document.getElementById(spanfieldid);
44 selspan.setAttribute("style","visibility:hidden");
45 selspan.innerHTML='';//' '
47 //and id to avail list.
48 var ops=object_refs['field_avail_list'].options;
49 var newoption = new Option(selspan.getAttribute("Value"),selspan.getAttribute("ValueId"),false,true);
52 function ajax_fetch_sync(url,post_data)
54 global_xmlhttp = getXMLHTTPinstance();
57 if ( typeof(post_data) != 'undefined' )
64 global_xmlhttp.open(method, url,false);
68 alert('message:'+error.message+":url:"+url);
71 if ( method == 'POST')
73 global_xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
76 global_xmlhttp.send(post_data);
77 var ajax_response = {"responseText":global_xmlhttp.responseText,"responseXML":global_xmlhttp.responseXML};
82 //----------------------------------------------------
83 //----------------------------------------------------
84 //----------------------------------------------------
85 function get_fields_to_dedup(parent_mod)
87 var rel_map_div_obj = document.getElementById('rel_map');
92 var url = site_url + '/index.php?to_pdf=1&sugar_body_only=1&inline=1&parent_module=' + parent_mod + '&module=MigrationMappings&action=GetRelationshipsToMap';
93 var ajax_return_obj = ajax_fetch_sync(url);
95 try { eval("var responseObj =" + ajax_return_obj['responseText']); }
96 catch(e) { alert(ajax_return_obj['responseText']); }
98 build_avail_rels_array(responseObj);
100 rel_map_div_obj.innerHTML = responseObj['html_content'];
104 rel_map_div_obj.innerHTML = '';
110 function get_dedup_fields()
112 var parent_div = document.getElementById('filter_def');
118 document.DedupSetup.dedup_fields.value='';
119 for (node in parent_div.childNodes) {
120 spannode=parent_div.childNodes[node];
121 if (spannode.tagName=='SPAN') {
122 value= spannode.getAttribute('value');
123 valueid=spannode.getAttribute('valueid');
124 style=spannode.getAttribute('style');
125 if (typeof(style) == 'undefined' || style==null || style=='' || style.lastIndexOf('hidden') == -1 ) {
126 if (document.DedupSetup.dedup_fields.value != '') {
127 document.DedupSetup.dedup_fields.value=document.DedupSetup.dedup_fields.value + '#';
129 document.DedupSetup.dedup_fields.value = document.DedupSetup.dedup_fields.value + valueid;
134 //var selected_fields_obj = document.getElementById('field_include_list[]');
136 //for(i=0; i < selected_fields_obj.length; i++)
138 // document.DedupSetup.dedup_fields.value = document.DedupSetup.dedup_fields.value + selected_fields_obj.options[i].value;
139 // if(i != (selected_fields_obj.length - 1)) { document.DedupSetup.dedup_fields.value += '#'; }
142 // document.DedupSetup.submit();
145 //-------------------------------------------------------------------
146 //-------------------------------------------------------------------
147 //-------------------------------------------------------------------
148 //-------------------------------------------------------------------
149 //-------------------------------------------------------------------
150 //-------------------------------------------------------------------
151 var object_refs = new Object();
152 object_refs['field_include_list'] = document.DedupSetup['field_include_list'];
153 object_refs['field_avail_list'] = document.DedupSetup['field_avail_list'];
155 function setselected(included_name,avail_name)
157 var included_columns_ref = object_refs[included_name];
158 var avail_columns_ref = object_refs[avail_name];
160 var included_td = document.getElementById(included_name+'_td');
161 var avail_td = document.getElementById(avail_name+'_td');
163 var selected_avail = new Array();
164 var notselected_avail = new Array();
165 var notselected_include = new Array();
167 for (i=0; i < avail_columns_ref.options.length; i++)
169 if (avail_columns_ref.options[i].selected == true)
171 selected_avail[selected_avail.length] = {text:avail_columns_ref.options[i].text, value:avail_columns_ref.options[i].value};
175 notselected_avail[notselected_avail.length] = {text:avail_columns_ref.options[i].text, value:avail_columns_ref.options[i].value};
180 var right_select_html_info = new Object();
181 var right_options = new Array();
182 var right_select = new Object();
184 right_select['name'] = avail_name+ '[]';
185 right_select['id'] = avail_name;
186 right_select['multiple'] = 'true';
187 right_select['size'] = '10';
189 for (i=0;i < notselected_avail.length;i++)
191 right_options[right_options.length] = notselected_avail[i];
194 right_select_html_info['options'] = right_options;
195 right_select_html_info['select'] = right_select;
197 var right_html = buildSelectHTML(right_select_html_info);
199 avail_td.innerHTML = right_html;
200 object_refs[avail_name] = avail_td.getElementsByTagName('select')[0];
202 //////////////////////////////
203 for(p=0; p < selected_avail.length; p++)
205 addFieldRow(selected_avail[p].value, selected_avail[p].text)
207 ///////////////////////////
213 var td = document.getElementById(name+'_td');
214 var obj = td.getElementsByTagName('select')[0];
215 obj = (typeof obj == "string") ? document.getElementById(obj) : obj;
216 if (obj.tagName.toLowerCase() != "select" && obj.length < 2)
218 var sel = new Array();
220 for (i=0; i<obj.length; i++) {
221 if (obj[i].selected == true) {
226 if (sel[i] != 0 && !obj[sel[i]-1].selected) {
227 var tmp = new Array(obj[sel[i]-1].text, obj[sel[i]-1].value);
228 obj[sel[i]-1].text = obj[sel[i]].text;
229 obj[sel[i]-1].value = obj[sel[i]].value;
230 obj[sel[i]].text = tmp[0];
231 obj[sel[i]].value = tmp[1];
232 obj[sel[i]-1].selected = true;
233 obj[sel[i]].selected = false;
239 function down(name) {
240 var td = document.getElementById(name+'_td');
241 var obj = td.getElementsByTagName('select')[0];
242 if (obj.tagName.toLowerCase() != "select" && obj.length < 2)
244 var sel = new Array();
245 for (i=obj.length-1; i>-1; i--) {
246 if (obj[i].selected == true) {
251 if (sel[i] != obj.length-1 && !obj[sel[i]+1].selected) {
252 var tmp = new Array(obj[sel[i]+1].text, obj[sel[i]+1].value);
253 obj[sel[i]+1].text = obj[sel[i]].text;
254 obj[sel[i]+1].value = obj[sel[i]].value;
255 obj[sel[i]].text = tmp[0];
256 obj[sel[i]].value = tmp[1];
257 obj[sel[i]+1].selected = true;
258 obj[sel[i]].selected = false;
263 function buildSelectHTML(info)
266 text = "<div align='left'><select";
268 if ( typeof (info['select']['size']) != 'undefined')
270 text +=" size=\""+ info['select']['size'] +"\"";
273 if ( typeof (info['select']['name']) != 'undefined')
275 text +=" name=\""+ info['select']['name'] +"\"";
278 if ( typeof (info['select']['style']) != 'undefined')
280 text +=" style=\""+ info['select']['style'] +"\"";
283 if ( typeof (info['select']['onchange']) != 'undefined')
285 text +=" onChange=\""+ info['select']['onchange'] +"\"";
288 if ( typeof (info['select']['multiple']) != 'undefined')
294 for(i=0; i<info['options'].length;i++)
296 option = info['options'][i];
297 text += "<option value=\""+option['value']+"\" ";
298 if ( typeof (option['selected']) != 'undefined' && option['selected']== true)
302 text += ">"+option['text']+"</option>";
304 text += "</select></div>";
308 //////////////////////////////////////////////
310 function addFieldRow(colName, colLabel) {
311 var tableId = 'search_type';
312 var rowIdName = 'field';
317 var optionsIndex = 0;
319 fieldCount = fieldCount + 1;
320 document.DedupSetup.num_fields.value = fieldCount;
322 var selElement = document.createElement("select");
323 var selectName = colName + "SearchType";
324 selElement.setAttribute("name", selectName);
327 for (theoption in operator_options) {
328 selElement.options[i] = new Option(operator_options[theoption],theoption, false, false);
332 var aElement = document.createElement("a");
333 aElement.setAttribute("href","javascript:remove_filter('filter_" + colName + "')");
334 aElement.setAttribute("class","listViewTdToolsS1");
336 var imgElement = document.createElement("img");
337 imgElement.setAttribute("src", delete_inline_image);
338 imgElement.setAttribute("align","absmiddle");
339 imgElement.setAttribute("alt",lbl_remove);
340 imgElement.setAttribute("border","0");
341 imgElement.setAttribute("height","12");
342 imgElement.setAttribute("width","12");
344 aElement.appendChild(imgElement);
345 aElement.appendChild(document.createTextNode(" "));
347 var div = document.getElementById('filter_def');
348 var span1 = document.getElementById('filter_'+colName);
349 if (span1 == null || span1=='' || typeof(span1)=='undefined') {
350 span1=document.createElement("span");
352 span1.setAttribute("style","visibility:visible");
355 span1.setAttribute("id",'filter_'+colName);
356 span1.setAttribute("Value",colLabel);
357 span1.setAttribute("ValueId",colName);
359 //table as a child of span element.
360 //table with only row only.
361 var table = document.createElement("table");
362 //usage or insertRow is required by IE, ironically this call
363 //produces bad UI when using IE on mac.
364 var row = table.insertRow(table.rows.length );
365 table.setAttribute("width","100%");
366 table.setAttribute("border","0");
367 table.setAttribute("cellpadding","0");
369 var td1= document.createElement("td");
370 td1.setAttribute("width","2%");
372 td1.appendChild(aElement);
375 var td2= document.createElement("td");
376 td2.setAttribute("width","20%");
377 td2.appendChild(document.createTextNode(colLabel + ': '));
380 var td3= document.createElement("td");
381 td3.setAttribute("width","10%");
382 td3.appendChild(selElement);
383 row.appendChild(td3);
386 eval("coldata=bean_data."+ colName+ ";");
388 var edit=document.createElement("input");
389 edit.setAttribute("type","text");
390 edit.setAttribute("name",colName + 'SearchField');
391 edit.setAttribute("id",colName + 'SearchField');
392 edit.setAttribute("value",coldata);
395 var td5= document.createElement("td");
396 td5.setAttribute("width","68%");
397 td5.appendChild(edit);
398 row.appendChild(td5);
401 //table.appendChild(row);
402 span1.appendChild(table);
403 div.appendChild(span1);