2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
6 * This program is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Affero General Public License version 3 as published by the
8 * Free Software Foundation with the addition of the following permission added
9 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
11 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
18 * You should have received a copy of the GNU Affero General Public License along with
19 * this program; if not, see http://www.gnu.org/licenses or write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
24 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26 * The interactive user interfaces in modified source and object code versions
27 * of this program must display Appropriate Legal Notices, as required under
28 * Section 5 of the GNU Affero General Public License version 3.
30 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31 * these Appropriate Legal Notices must retain the display of the "Powered by
32 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
33 * technical reasons, the Appropriate Legal Notices must display the words
34 * "Powered by SugarCRM".
35 ********************************************************************************/
37 /*********************************************************************************
38 * {APP.LBL_CURRENCY_SYM}Header: /cvsroot/sugarcrm/sugarcrm/modules/Contacts/EditView.html,v 1.22 2004/07/16 04:04:42 sugarclint Exp {APP.LBL_CURRENCY_SYM}
39 ********************************************************************************/
43 <span class="error">{ERROR}</span>
47 <form enctype="multipart/form-data" name="MailMerge" method="POST" action="index.php" onsubmit='return false'>
48 <input type="hidden" name="module" value="MailMerge">
49 <input type="hidden" name="step" id="step" value="{STEP}">
50 <input type="hidden" name="action" value="index">
51 <input type="hidden" name="return_module" value="{RETURN_MODULE}">
52 <input type="hidden" name="return_id" value="{RETURN_ID}">
53 <input type="hidden" name="return_action" value="{RETURN_ACTION}">
54 <input type="hidden" name="selected_objects" id="selected_objects">
56 <table width="100%" border="0" cellspacing="0" cellpadding="0" class="edit view">
59 <table border="0" cellspacing="0" cellpadding="0">
61 <th align="left" scope="row" colspan="2"><h4 class="">{MAIL_MERGE_HEADER_STEP_2}</h4></th>
63 <tr><td><slot> </slot></td></tr>
65 <td><input type='text' id="searchText" name="searchText" ONKEYDOWN="javascript:return displayKeyCode(event)"></td>
66 <td><input type="submit" id="searchSubmit" value="Search" accessKey="" onClick="search();" class='button'></td>
68 <tr><td>{MAIL_MERGE_CAMPAIGN_PROSPECT_SELECTOR}</td></tr>
74 <span id="result_count"></span>
81 <table border="0" cellspacing="0" cellpadding="0">
83 <td scope="row">Available
86 <td><slot><select id="display_objs" name="display_objs[]" size="10" multiple="multiple" ></select></slot></td>
94 {MAILMERGE_LEFT_TO_RIGHT}
96 {MAILMERGE_RIGHT_TO_LEFT}
100 <table border="0" cellspacing="0" cellpadding="0">
102 <td scope="row">Selected
105 <td><slot><select id="selected_objs" name="selected_objs[]" size="10" multiple="multiple" >{MAILMERGE_PRESELECTED_OBJECTS}</select></slot></td>
116 <tr><td>{MAIL_MERGE_CONTAINS_CONTACT_INFO}</td></tr>
119 <p><table width="100%" cellpadding="2" cellspacing="0" border="0"><tr>
120 <td align="left"><input id="prevButton" title="{MOD.LBL_BACK}" accessKey="" class="button" type="submit" name="button" value=" {MOD.LBL_BACK} " onclick="this.form.step.value='1'; return submit_form();"></td>
121 <td align="right"><input id="nextButton" title="{MOD.LBL_NEXT}" accessKey="" class="button" type="submit" name="button" value=" {MOD.LBL_NEXT} " onclick="set_selected_items();return validateForm();"></td>
126 <script type="text/javascript">{JSON_CONFIG_JAVASCRIPT}</script>
127 <script type="text/javascript" src="include/javascript/jsclass_base.js?s={SUGAR_VERSION}&c={JS_CUSTOM_VERSION}"></script>
128 <script type="text/javascript" src="include/javascript/jsclass_async.js?s={SUGAR_VERSION}&c={JS_CUSTOM_VERSION}"></script>
131 var module = "{MAILMERGE_MODULE}";
134 var mWhere = "{MAILMERGE_WHERE}";
137 function submit_form()
139 document.MailMerge.action='index.php';
140 document.MailMerge.submit();
143 function ResponseObj()
147 ResponseObj.prototype.response = function (result)
150 var prevButton = document.getElementById("prevButton");
151 var nextButton = document.getElementById("nextButton");
153 var prevItems = document.getElementById("prevItems");
154 var nextItems= document.getElementById("nextItems");
156 var dispMin = mOffset;
157 if(result.result_count < max)
159 dispCount = result.result_count;
160 nextItems_disabled = true;
162 if(result.result_count < (mOffset + max))
164 nextItems_disabled = true;
168 nextItems_disabled = false;
172 prevItems_disabled = true;
176 prevItems_disabled = false;
178 if(result.result_count > 0)
180 dispMin = mOffset + 1;
182 var spanMax = 0 + parseInt(mOffset,10) + parseInt(dispCount,10);
183 if ( spanMax > parseInt(result.result_count,10) ) {
184 spanMax = parseInt(result.result_count);
186 var spanText = "("+(dispMin) + " - " + spanMax + " of " + result.result_count+")";
187 document.getElementById("result_count").innerHTML = spanText;
188 var displayObjs = document.getElementById("display_objs");
189 displayObjs.options.length = 0;
190 var isLeadOrContact = false;
191 if(module == 'Contacts' || module == 'Leads' || module == 'CampaignProspects')
193 isLeadOrContact = true;
195 for (i = 0; i < result.entry_list.length; i++)
201 id = result.entry_list[i]['name_value_list'].id.value;
204 name1 = result.entry_list[i]['name_value_list'].first_name.value;
205 name2 = result.entry_list[i]['name_value_list'].last_name.value;
210 name2 = result.entry_list[i]['name_value_list'].name.value;
212 name = name1 + ' ' + name2;
213 displayObjs.options[displayObjs.length] = new Option(name, id);
216 prevButton.disabled = false;
217 nextButton.disabled = false;
219 function increaseOffset()
221 if(!nextItems_disabled) {
227 function decreaseOffset()
229 if(!prevItems_disabled) {
235 function getObjects()
237 var prevButton = document.getElementById("prevButton");
238 var nextButton = document.getElementById("nextButton");
240 prevButton.disabled = true;
241 nextButton.disabled = true;
245 //mWhere = "campaigns.id = '9be5dd91-d20b-c5fd-1769-4554d8eede05'";
247 query = {"module":module, "offset":mOffset, "where":mWhere, "max":max, "order_by":orderBy};
249 req_id = global_rpcClient.call_method('get_objects_from_module',query);
251 var res = new ResponseObj();
252 global_request_registry[req_id] = [ res,'response'];
258 var displayObjs = document.getElementById("display_objs");
259 var selObjs = document.getElementById("selected_objs");
261 for (i=0;i<displayObjs.options.length;i++)
263 if(displayObjs[i].selected)
265 var current = displayObjs.options[i];
266 selObjs.options.add(new Option(current.text, current.value));
270 for (i = displayObjs.length - 1; i>=0; i--) {
273 if(displayObjs.options[i].selected)
275 displayObjs.remove(i);
285 var selObjs = document.getElementById("selected_objs");
286 var displayObjs = document.getElementById("display_objs");
287 for (i=0;i<selObjs.options.length;i++)
289 if(selObjs[i].selected)
291 var current = selObjs.options[i];
292 displayObjs.options.add(new Option(current.text, current.value));
295 for (i = selObjs.length - 1; i>=0; i--) {
298 if(selObjs.options[i].selected)
309 function set_selected_items()
311 var selObjs = document.getElementById("selected_objs");
313 var containsContactInfo = document.getElementById("contains_contact_info");
314 var step = document.getElementById("step");
315 var selected_objects = '';
317 for(i=0; i < selObjs.options.length ;i++)
319 selected_objects += selObjs.options[i].value+"="+selObjs.options[i].text.replace(/&/g, "##")+"&";
322 document.MailMerge.selected_objects.value = selected_objects;
323 //BEGIN CHANGE 38959 -- raagaard
324 if(containsContactInfo != null && containsContactInfo.options[containsContactInfo.selectedIndex].value)
325 //END CHANGE 38959 -- raagaard
336 function displayKeyCode(evt)
338 var charCode = (evt.which) ? evt.which : event.keyCode;
345 function search(searchText)
347 var searchInput = document.getElementById("searchText");
348 searchText = searchInput.value;
352 if(module == 'Contacts' || module == 'Leads')
354 where = module+".first_name like '%"+searchText+"%' OR "+module+".last_name like '%"+searchText+"%'";
356 else if(module == 'CampaignProspects'){
357 var prospectType = document.getElementById("campaign_prospect_type");
358 var lmodule = prospectType.value.toLowerCase();
359 var campign_where = "{MAILMERGE_WHERE}";
360 where = lmodule+".first_name like '%"+searchText+"%' OR "+lmodule+".last_name like '%"+searchText+"%'";
362 where += " AND "+campign_where ;
363 where += " AND related_type = #"+lmodule+"#"
367 where = module+".name like '"+searchText+"%'";
370 mWhere = where.toLowerCase();
375 function getOrderBy()
378 if(module == 'Contacts' || module == 'Leads')
380 order = module+".last_name";
384 order = module+".name";
387 orderBy = order.toLowerCase();
389 function validateForm()
391 var selObjs = document.getElementById("selected_objs");
393 if(selObjs.options.length > 0)
395 document.MailMerge.action='index.php';
396 document.MailMerge.submit();
401 alert("Please select at least one item.");
405 if({MAILMERGE_GET_OBJECTS}){