]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/MailMerge/Step2.html
Release 6.4.0
[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" 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">
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" ONKEYDOWN="javascript:return displayKeyCode(event)"></td>
66         <td><input type="submit" id="searchSubmit" value="Search" accessKey="" 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 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>
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?v={VERSION_MARK}"></script>
128 <script type="text/javascript" src="include/javascript/jsclass_async.js?v={VERSION_MARK}"></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 var relModule = '';
137 var mTerm = '';
138 YAHOO.namespace("mailmerge");
139 YAHOO.mailmerge.cObj = null;
140
141 function submit_form()
142 {
143         document.MailMerge.submit();
144 }
145
146 function ResponseObj()
147 {
148 }
149
150 function ajaxSuccess(data)
151 {        
152     var result = YAHOO.lang.JSON.parse(data.responseText);
153     result = result.result;
154         var prevButton = document.getElementById("prevButton");
155         var nextButton = document.getElementById("nextButton");
156         
157         var prevItems = document.getElementById("prevItems");
158         var nextItems= document.getElementById("nextItems");
159         var dispCount = max;
160         var dispMin = mOffset;
161         if(result.result_count < max)
162         {
163                 dispCount = result.result_count;
164                 nextItems_disabled = true;
165         }
166         if(result.result_count <= (mOffset + max))
167         {
168                 nextItems_disabled = true;
169         }
170         else
171         {
172                 nextItems_disabled = false;
173         }
174         if(mOffset == 0)
175         {
176                 prevItems_disabled = true;
177         }
178         else
179         {
180                 prevItems_disabled = false;
181         }
182         if(result.result_count > 0)
183         {
184                 dispMin = mOffset + 1;
185         }
186     var spanMax = 0 + parseInt(mOffset,10) + parseInt(dispCount,10);
187     if ( spanMax > parseInt(result.result_count,10) ) {
188         spanMax = parseInt(result.result_count);
189     }
190         var spanText = "("+(dispMin) + " - " + spanMax + " of " + result.result_count+")";
191         document.getElementById("result_count").innerHTML = spanText;
192         var displayObjs = document.getElementById("display_objs");
193         displayObjs.options.length = 0;
194         var isLeadOrContact = false;
195         if(module == 'Contacts' || module == 'Leads' || module == 'CampaignProspects')
196         {
197                 isLeadOrContact = true;
198         }
199         for (i = 0; i < result.entry_list.length; i++)
200         {
201                 var id = '';
202                 var name = '';
203                 var name1 = '';
204                 var name2 = '';
205                 id = result.entry_list[i]['name_value_list'].id.value;
206                 if(isLeadOrContact)
207                 {
208                         name1 = result.entry_list[i]['name_value_list'].first_name.value;
209                         name2 = result.entry_list[i]['name_value_list'].last_name.value;
210                 }
211                 else
212                 {
213                         name1 = '';
214                         name2 = result.entry_list[i]['name_value_list'].name.value;
215                 }
216                 name = name1 + ' ' + name2;
217                 displayObjs.options[displayObjs.length] = new Option(name, id);
218         }
219             
220         prevButton.disabled = false;
221         nextButton.disabled = false;
222 }
223 function increaseOffset()
224 {
225     if(isCallInProgress())
226         return;
227
228     if(!nextItems_disabled) {
229         mOffset += 20;
230         getObjects();
231     }
232 }
233
234 function decreaseOffset()
235 {
236     if(isCallInProgress())
237         return;
238
239     if(!prevItems_disabled) {
240             mOffset -= 20;
241         getObjects();
242     }
243 }
244
245 function isCallInProgress()
246 {
247     if(YAHOO.mailmerge.cObj)
248         return YAHOO.util.Connect.isCallInProgress(YAHOO.mailmerge.cObj);
249     else
250         return false;
251 }
252
253 function getObjects()
254 {
255         var prevButton = document.getElementById("prevButton");
256         var nextButton = document.getElementById("nextButton");
257         
258         prevButton.disabled = true;
259         nextButton.disabled = true;
260         getOrderBy();
261         
262         //rrs
263     var qs = 'index.php?module=MailMerge&action=search&qModule='+module+'&rel_module='+relModule+'&term='+mTerm+'&max='+max+'&order_by='+orderBy+'&offset='+mOffset;
264         YAHOO.mailmerge.cObj = YAHOO.util.Connect.asyncRequest('GET', qs,{success: ajaxSuccess, failure: ajaxSuccess}, null);
265 }
266
267 function moveRight()
268 {
269         var displayObjs =  document.getElementById("display_objs");
270         var selObjs = document.getElementById("selected_objs");
271         
272         for (i=0;i<displayObjs.options.length;i++)
273         {
274                 if(displayObjs[i].selected)
275                 {
276                         var current = displayObjs.options[i];
277                         selObjs.options.add(new Option(current.text, current.value));
278                 }
279         }
280         //remove them now
281         for (i = displayObjs.length - 1; i>=0; i--) {
282         try
283         {
284                 if(displayObjs.options[i].selected)
285                 {
286                         displayObjs.remove(i);          
287                 }
288         }
289                 catch(e){}
290                 
291         }
292 }
293
294 function moveLeft()
295 {
296         var selObjs = document.getElementById("selected_objs");
297         var displayObjs =  document.getElementById("display_objs");
298         for (i=0;i<selObjs.options.length;i++)
299         {
300                 if(selObjs[i].selected)
301                 {
302                         var current = selObjs.options[i];
303                         displayObjs.options.add(new Option(current.text, current.value));
304                 }
305         }
306         for (i = selObjs.length - 1; i>=0; i--) {
307         try
308         {
309                 if(selObjs.options[i].selected)
310                 {
311                         selObjs.remove(i);
312
313                 }
314         }
315                 catch(e){}
316                 
317         }
318 }
319
320 function set_selected_items()
321 {
322 var selObjs = document.getElementById("selected_objs");
323
324 var containsContactInfo = document.getElementById("contains_contact_info");
325 var step = document.getElementById("step");
326 var selected_objects = '';
327
328 for(i=0; i < selObjs.options.length ;i++)
329 {
330          selected_objects += selObjs.options[i].value+"="+selObjs.options[i].text.replace(/&/g, "##")+"&";
331 }
332
333         document.MailMerge.selected_objects.value = selected_objects;
334 //BEGIN CHANGE 38959 -- raagaard
335         if(containsContactInfo != null && containsContactInfo.options[containsContactInfo.selectedIndex].value)
336 //END CHANGE 38959 -- raagaard
337         {
338                 step.value = "3";
339         }
340         else
341         {
342                 step.value = "4";
343         }
344
345 }
346
347 function displayKeyCode(evt)
348  {
349          var charCode = (evt.which) ? evt.which : event.keyCode;
350          if(charCode=='13')
351          {
352                  search();
353          }
354  }
355
356 function search(searchText)
357 {
358         var searchInput = document.getElementById("searchText");
359         mTerm = searchInput.value;
360     if(module == 'CampaignProspects'){
361                         var prospectType = document.getElementById("campaign_prospect_type");
362                         var lmodule = prospectType.value.toLowerCase();
363             relModule = lmodule;
364     }
365     mOffset = 0;
366         getObjects();
367 }
368
369 function getOrderBy()
370 {
371         var order = '';
372     var tmpModule = module.toLowerCase();
373     if(module == 'CampaignProspects'){
374         tmpModule = document.getElementById("campaign_prospect_type").value.toLowerCase();
375     }
376
377         if(tmpModule == 'contacts' || tmpModule == 'leads' || tmpModule == 'prospects')
378         {
379                 order = tmpModule+".last_name";
380         }
381         else
382         {
383                 order = tmpModule+".name";
384         }
385         
386         orderBy = order.toLowerCase();
387 }
388 function validateForm()
389 {
390         var selObjs = document.getElementById("selected_objs");
391         
392         if(selObjs.options.length > 0)
393         {
394                 document.MailMerge.submit();
395                 return true;
396         }
397         else
398         {
399                 alert("Please select at least one item.");
400                 return false;
401         }       
402 }
403 if({MAILMERGE_GET_OBJECTS}){
404         getObjects();
405 }
406 </script>
407 <!-- END: main -->