]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/MailMerge/Step2.html
Release 6.2.2
[Github/sugarcrm.git] / modules / MailMerge / Step2.html
1 <!--
2 /*********************************************************************************
3  * SugarCRM Community Edition is a customer relationship management program developed by
4  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
5  * 
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.
12  * 
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
16  * details.
17  * 
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
21  * 02110-1301 USA.
22  * 
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.
25  * 
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.
29  * 
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  ********************************************************************************/
36
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  ********************************************************************************/
40 -->
41 <!-- BEGIN: main -->
42 <!-- BEGIN: error -->
43 <span class="error">{ERROR}</span>
44 <!-- END: error -->
45
46
47                         <form enctype="multipart/form-data" name="MailMerge" method="POST" action="index.php">
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">
55 <p>
56 <table width="100%" border="0" cellspacing="0" cellpadding="0" class="edit view">
57 <tr>
58 <td>
59         <table border="0" cellspacing="0" cellpadding="0">
60         <tr>
61         <th align="left" scope="row" colspan="2"><h4 class="">{MAIL_MERGE_HEADER_STEP_2}</h4></th>
62         </tr>
63         <tr><td><slot>&nbsp;</slot></td></tr>
64         <tr>
65         <td><input type='text' id="searchText" name="searchText"></td>
66         <td><input type="button" id="searchSubmit" value="Search" onClick="search();" class='button'></td>
67         </tr>
68         <tr><td>{MAIL_MERGE_CAMPAIGN_PROSPECT_SELECTOR}</td></tr>
69         </table>
70         <table>
71         <tr>
72                 <td>
73                 {MAILMERGE_PREV}
74                 <span id="result_count"></span>
75                 {MAILMERGE_NEXT}
76                 </td>
77                 </tr>
78         <tr>
79         <td  colspan='1'>
80         
81                 <table border="0" cellspacing="0" cellpadding="0">
82                         <tr>
83                                 <td scope="row">Available
84                                         <table>
85                                                 <tr>
86                                                         <td><slot><select id="display_objs" name="display_objs[]" size="10" multiple="multiple" ></select></slot></td>
87                                                 </tr>
88                                         </table>
89                                 </td>
90                         </tr>
91                 </table>
92         </td>
93         <td>
94         {MAILMERGE_LEFT_TO_RIGHT}
95         <br>
96         {MAILMERGE_RIGHT_TO_LEFT}
97         </td>
98         <td  colspan='1'>
99         
100                 <table border="0" cellspacing="0" cellpadding="0">
101                         <tr>
102                                 <td scope="row">Selected
103                                         <table>
104                                                 <tr>
105                                                         <td><slot><select id="selected_objs" name="selected_objs[]" size="10" multiple="multiple" >{MAILMERGE_PRESELECTED_OBJECTS}</select></slot></td>
106                                                 </tr>
107                                         </table>
108                                 </td>
109                         </tr>
110                 </table>
111         </td>
112         </tr>
113 </table>
114 </td>
115 </tr>
116 <tr><td>{MAIL_MERGE_CONTAINS_CONTACT_INFO}</td></tr>
117 </table>
118 </p>
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 true;"></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>
122 </tr>
123 </table>  </p>
124         </form>
125 {JAVASCRIPT}
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>
129
130 <script>
131 var module = "{MAILMERGE_MODULE}";
132 var mOffset = 0;
133 var max = 20;
134 var mWhere = "{MAILMERGE_WHERE}";
135 var orderBy = '';
136
137 function ResponseObj()
138 {
139 }
140
141 ResponseObj.prototype.response = function (result) 
142 {        
143
144         var prevButton = document.getElementById("prevButton");
145         var nextButton = document.getElementById("nextButton");
146         
147         var prevItems = document.getElementById("prevItems");
148         var nextItems= document.getElementById("nextItems");
149         var dispCount = max;
150         var dispMin = mOffset;
151         if(result.result_count < max)
152         {
153                 dispCount = result.result_count;
154                 nextItems.disabled = true;
155         }
156         if(result.result_count - max == mOffset)
157         {
158                 nextItems.disabled = true;
159         }
160         else
161         {
162                 nextItems.disabled = false;
163         }
164         if(mOffset == 0)
165         {
166                 prevItems.disabled = true;
167         }
168         else
169         {
170                 prevItems.disabled = false;
171         }
172         if(result.result_count > 0)
173         {
174                 dispMin = mOffset + 1;
175         }
176         var spanText = "("+(dispMin) + " - " +(mOffset+dispCount) + " of " + result.result_count+")";
177         document.getElementById("result_count").innerHTML = spanText;
178         var displayObjs = document.getElementById("display_objs");
179         displayObjs.options.length = 0;
180         var isLeadOrContact = false;
181         if(module == 'Contacts' || module == 'Leads' || module == 'CampaignProspects')
182         {
183                 isLeadOrContact = true;
184         }
185         for (i = 0; i < result.entry_list.length; i++)
186         {
187                 var id = '';
188                 var name = '';
189                 var name1 = '';
190                 var name2 = '';
191                 id = result.entry_list[i]['name_value_list'].id.value;
192                 if(isLeadOrContact)
193                 {
194                         name1 = result.entry_list[i]['name_value_list'].first_name.value;
195                         name2 = result.entry_list[i]['name_value_list'].last_name.value;
196                 }
197                 else
198                 {
199                         name1 = '';
200                         name2 = result.entry_list[i]['name_value_list'].name.value;
201                 }
202                 name = name1 + ' ' + name2;
203                 displayObjs.options[displayObjs.length] = new Option(name, id);
204         }
205             
206         prevButton.disabled = false;
207         nextButton.disabled = false;
208 }
209 function increaseOffset()
210 {
211         mOffset += 20;
212 }
213
214 function decreaseOffset()
215 {
216         mOffset -= 20;
217 }
218
219 function getObjects()
220 {
221         var prevButton = document.getElementById("prevButton");
222         var nextButton = document.getElementById("nextButton");
223         
224         prevButton.disabled = true;
225         nextButton.disabled = true;
226         getOrderBy();
227         
228         //rrs
229         //mWhere = "campaigns.id = '9be5dd91-d20b-c5fd-1769-4554d8eede05'";
230
231         query = {"module":module, "offset":mOffset, "where":mWhere, "max":max, "order_by":orderBy};
232
233         req_id = global_rpcClient.call_method('get_objects_from_module',query);
234         
235         var res = new ResponseObj();
236     global_request_registry[req_id] = [ res,'response']; 
237
238 }
239
240 function moveRight()
241 {
242         var displayObjs =  document.getElementById("display_objs");
243         var selObjs = document.getElementById("selected_objs");
244         
245         for (i=0;i<displayObjs.options.length;i++)
246         {
247                 if(displayObjs[i].selected)
248                 {
249                         var current = displayObjs.options[i];
250                         selObjs.options.add(new Option(current.text, current.value));
251                 }
252         }
253         //remove them now
254         for (i = displayObjs.length - 1; i>=0; i--) {
255         try
256         {
257                 if(displayObjs.options[i].selected)
258                 {
259                         displayObjs.remove(i);          
260                 }
261         }
262                 catch(e){}
263                 
264         }
265 }
266
267 function moveLeft()
268 {
269         var selObjs = document.getElementById("selected_objs");
270         var displayObjs =  document.getElementById("display_objs");
271         for (i=0;i<selObjs.options.length;i++)
272         {
273                 if(selObjs[i].selected)
274                 {
275                         var current = selObjs.options[i];
276                         displayObjs.options.add(new Option(current.text, current.value));
277                 }
278         }
279         for (i = selObjs.length - 1; i>=0; i--) {
280         try
281         {
282                 if(selObjs.options[i].selected)
283                 {
284                         selObjs.remove(i);
285
286                 }
287         }
288                 catch(e){}
289                 
290         }
291 }
292
293 function set_selected_items()
294 {
295 var selObjs = document.getElementById("selected_objs");
296
297 var containsContactInfo = document.getElementById("contains_contact_info");
298 var step = document.getElementById("step");
299 var selected_objects = '';
300
301 for(i=0; i < selObjs.options.length ;i++)
302 {
303          selected_objects += selObjs.options[i].value+"="+selObjs.options[i].text.replace(/&/g, "##")+"&";
304 }
305
306         document.MailMerge.selected_objects.value = selected_objects;
307 //BEGIN CHANGE 38959 -- raagaard
308         if(containsContactInfo != null && containsContactInfo.options[containsContactInfo.selectedIndex].value)
309 //END CHANGE 38959 -- raagaard
310         {
311                 step.value = "3";
312         }
313         else
314         {
315                 step.value = "4";
316         }
317
318 }
319
320 function search(searchText)
321 {
322         var searchInput = document.getElementById("searchText");
323         searchText = searchInput.value;
324         var where = '';
325         if(searchText != '')
326         {
327                 if(module == 'Contacts' || module == 'Leads')
328                 {
329                         where = module+".first_name like '%"+searchText+"%' OR "+module+".last_name like '%"+searchText+"%'";
330                 }
331                 else if(module == 'CampaignProspects'){
332                         var prospectType = document.getElementById("campaign_prospect_type");
333                         var lmodule = prospectType.value.toLowerCase();
334                         var campign_where = "{MAILMERGE_WHERE}";
335                         where = lmodule+".first_name like '%"+searchText+"%' OR "+lmodule+".last_name like '%"+searchText+"%'";
336                         if(campign_where)
337                                 where += " AND "+campign_where ;
338                         where += "  AND related_type = #"+lmodule+"#"
339                 }
340                 else
341                 {
342                         where = module+".name like '"+searchText+"%'";
343                 }
344         }
345         mWhere = where.toLowerCase();
346         getObjects();
347 }
348
349 function getOrderBy()
350 {
351         var order = '';
352         if(module == 'Contacts' || module == 'Leads')
353         {
354                 order = module+".last_name";
355         }
356         else
357         {
358                 order = module+".name";
359         }
360         
361         orderBy = order.toLowerCase();
362 }
363 function validateForm()
364 {
365         var selObjs = document.getElementById("selected_objs");
366         
367         if(selObjs.options.length > 0)
368         {
369                 return true;
370         }
371         else
372         {
373                 alert("Please select at least one item.");
374                 return false;
375         }       
376 }
377 if({MAILMERGE_GET_OBJECTS}){
378         getObjects();
379 }
380 </script>
381 <!-- END: main -->