]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl
Release 6.4.0
[Github/sugarcrm.git] / modules / Campaigns / tpls / WizardCampaignTargetListForNonNewsLetter.tpl
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
39  ********************************************************************************/
40 *}
41
42         <input type="hidden" id="existing_target_count" name="existing_target_count" value={$TARGET_COUNT}>                     
43         <input type="hidden" id="added_target_count" name="added_target_count" value=''>                                
44         <input type="hidden" id="wiz_list_of_existing_targets" name="wiz_list_of_existing_targets" value="">                            
45         <input type="hidden" id="wiz_list_of_targets" name="wiz_list_of_targets" value="">                              
46         <input type="hidden" id="wiz_remove_target_list" name="wiz_remove_target_list" value="">                                
47
48
49
50         <table width="100%" border="0" cellspacing="0" cellpadding="0">
51         <tr>
52         <th colspan="5" align="left" ><h4>{$MOD.LBL_TARGET_LISTS}</h4></th>
53         </tr>
54         <tr>
55         <td colspan="5">{$MOD.LBL_WIZARD_TARGET_MESSAGE1}<br></td>
56         </tr>
57         <tr><td colspan=5>&nbsp;</td></tr>
58         <tr>
59         <td scope="row" colspan="4">{$MOD.LBL_SELECT_TARGET}&nbsp;
60         <input id="popup_target_list_type" name="popup_target_list_type" type='hidden'>
61         <input id="popup_target_list_name" name="popup_target_list_name" type="hidden" value="">
62         <input id='popup_target_list_id' name='popup_target_list_id' title='List ID' type="hidden" value=''>
63         <input title="{$APP.LBL_SELECT_BUTTON_TITLE}" type="button"  class="button" value='{$APP.LBL_SELECT_BUTTON_LABEL}' name=btn3 id='target_list_button'
64         onclick='open_popup("ProspectLists", 600, 400, "", true, false,  {$encoded_target_list_popup_request_data}, "single", true);'>  
65         </span sugar='slot'>    
66         </td>
67         <td>&nbsp;</td>
68         </tr>
69         <tr><td colspan=5>&nbsp;</td></tr>
70         <tr>
71         <td scope="row" colspan="5">{$MOD.LBL_WIZARD_TARGET_MESSAGE2}<br></td>
72         </tr>
73         <tr>
74         <td width='10%' scope="col">{$MOD.LBL_TARGET_NAME}</td>
75         <td width='20%'>
76                 <input id="target_list_name" name="target_list_name" type='text' size='40'>
77         </td>
78         <td width='10%' scope="col">
79                 <span sugar='slot28'>{$MOD.LBL_TARGET_TYPE}</span sugar='slot'>
80         </td>
81         <td  width='20%' >
82                 <span sugar='slot28b'>
83                 <select id="target_list_type" name="target_list_type">{$TARGET_OPTIONS}</select>
84                 <input id='target_list_id' name='target_list_id' title='List ID' type="hidden" value=''>
85                 </span sugar='slot'>
86         </td>
87         <td width='30%'><input type='button' value ='{$MOD.LBL_CREATE_TARGET}' class= 'button' onclick="add_target('false');"></td>
88         </tr>
89         <tr><td colspan=5>&nbsp;</td></tr>
90         </table>
91         <table width = '100%' class='detail view'>
92                 <tr><td>{$MOD.LBL_TRACKERS_ADDED}</td></tr>
93                 <tr><td>
94                 
95                         <table border=1 width='100%'><tr class='detail view'>
96                                 <th scope='col' width='25%'><b>{$MOD.LBL_TARGET_NAME}</b></th>
97                             <th scope='col' width='25%'><b>{$MOD.LBL_TARGET_TYPE}</b></th><td>&nbsp;</td>
98                             <td width='25%'><b>&nbsp;</b></td>                      
99                     </tr>
100                         </table>
101                         <div id='added_targets'>
102                                 {$EXISTING_TARGETS}
103                         </div>
104         
105         
106                 </td></tr>
107         </table>
108         
109         <p>
110
111
112                 <script>
113                 var image_path = '{$IMAGE_PATH}';
114                 {literal}
115                 
116                         //create variables that will be used to monitor the number of target url
117                         var targets_added = 0;
118                         //variable that will be passed back to server to specify list of targets
119                         var wiz_list_of_targets_array = new Array();
120                         
121                         //this function adds selected target to list
122                         function add_target(from_popup){
123
124                                 //perform validation
125                                 if(validate_step4(from_popup)){
126                                         TRGTNAME = 'target_list_name';
127                                         TRGTID = 'target_list_id';
128                                         TRGTYPE = 'target_list_type';
129
130                                 if(from_popup == 'true'){
131                                         TRGTNAME = 'popup_target_list_name'
132                                         TRGTID = 'popup_target_list_id'
133                                         TRGTYPE = 'popup_target_list_type'                                                                              
134                                 }
135                                 
136                                 //increment target count value
137                                         targets_added++;
138                                         document.getElementById('added_target_count').value = targets_added ;
139                                         //get the appropriate values from target form
140                                         var trgt_name = document.getElementById(TRGTNAME);
141                                         var trgt_id = document.getElementById(TRGTID);
142                                         var trgt_type = document.getElementById(TRGTYPE);
143 //                                      var selInd = trgt_type.selectedIndex;
144 //                    trgt_type_text_value = trgt_type.options[selInd].text             
145                                         var trgt_type_text = trgt_type.value ;
146                                         {/literal}
147                                         //display the selected display text, not the value
148                                         {$PL_DOM_STMT}                  
149                                         {literal}
150                                         //construct html to display chosen tracker
151                                         var trgt_name_html = "<input id='target_name"+targets_added +"' type='hidden' size='20' maxlength='255' name='added_target_name"+targets_added+"' value='"+trgt_name.value+"' >"+trgt_name.value;
152                                         var trgt_id_html = "<input type='hidden' name='added_target_id"+trackers_added+"' id='added_target_id"+trackers_added+"' value='"+trgt_id.value+"' >";
153                                         var trgt_type_html = "<input name='added_target_type"+trackers_added+"' id='added_target_type"+trackers_added+"' type='hidden' value='"+trgt_type.value+"'/>"+trgt_type_text;
154
155                                         {/literal}
156                                         //display the html
157                                         {capture assign='alt_remove' }{sugar_translate label='LBL_DELETE' module='CAMPAIGNS'}{/capture}
158                     var trgt_html = "<div id='trgt_added_"+targets_added+"'> <table width='100%' class='tabDetailViewDL2'><tr class='tabDetailViewDL2' ><td width='25%'>"+trgt_name_html+"</td><td width='25%'>"+trgt_type_html+"</td><td>"+trgt_id_html+"<a href='#' onclick=\"remove_target('trgt_added_"+targets_added+"','"+targets_added+"'); \" >  "+'{sugar_getimage name="delete_inline" ext=".gif" width="12" height="12" alt=$alt_remove other_attributes='align="absmiddle" border="0" '}'+"{$MOD.LBL_REMOVE}</a></td></tr></table></div>";
159                                         document.getElementById('added_targets').innerHTML = document.getElementById('added_targets').innerHTML + trgt_html;
160
161                                         //add values to array in string, seperated by "@@" characters
162                                         wiz_list_of_targets_array[targets_added] = trgt_id.value+"@@"+trgt_name.value+"@@"+trgt_type.value;                                     
163                                         //assign array to hidden input, which will be used by server to process array of targets
164                                         document.getElementById('wiz_list_of_targets').value = wiz_list_of_targets_array.toString();                                    
165                                         
166                                         //now lets clear the form to allow input of new target  
167                                         trgt_name.value = '';
168                                         trgt_id.value = '';
169                                         trgt_type.value = 'default';                            
170
171                                         {literal}
172                                         if(targets_added ==1){
173                                                 document.getElementById('no_targets').style.display='none';
174                                         }
175                                 }
176                         }
177                         
178                         //this function will remove the selected target from the ui, and from the target array
179                         function remove_target(div,num){
180                                         //clear UI
181                                         var trgt_div = document.getElementById(div);
182                                         trgt_div.style.display = 'none';
183                                         parentNE=trgt_div.parentNode;
184                                         parentNE.removeChild(trgt_div);
185                                         //clear target array from this entry and assign to form input
186                                         wiz_list_of_targets_array[num] = '';                                                                            
187                                         document.getElementById('wiz_list_of_targets').value = wiz_list_of_targets_array.toString();                                    
188                         }
189
190                         //this function will remove the existing target from the ui, and add it's value to an array for removal upon save
191                         function remove_existing_target(div,id){
192                                         //clear UI
193                                         var trgt_div = document.getElementById(div);
194                                         trgt_div.style.display = 'none';
195                                         parentNE=trgt_div.parentNode;
196                                         parentNE.removeChild(trgt_div);
197                                         //assign this id to form input for removal
198                                         document.getElementById('wiz_remove_target_list').value += ','+id;                                      
199                         }
200
201                                         
202                 
203            /*
204              * this is the custom validation script that will validate the fields on step3 of wizard
205              * this is called directly from the add target button
206              */
207             
208             function validate_step4(from_popup){
209                         if(from_popup=='true'){
210                                 return true;
211                         }
212                 requiredTxt = SUGAR.language.get('app_strings', 'ERR_MISSING_REQUIRED_FIELDS');
213                 var stepname = 'wiz_step3_';
214                 var has_error = 0;
215                 var fields = new Array();
216                 fields[0] = 'target_list_name'; 
217                 fields[1] = 'target_list_type';
218                 //loop through and check for empty strings ('  ')
219                 var field_value = ''; 
220                 if( (trim(document.getElementById(fields[0]).value) !='') ||  (trim(document.getElementById(fields[1]).value) !='')){
221                     for (i=0; i < fields.length; i++){
222                         field_value = trim(document.getElementById(fields[i]).value);
223                         if(field_value.length<1){
224                           add_error_style('wizform', fields[i], requiredTxt +' ' +document.getElementById(fields[i]).title );
225                           has_error = 1;
226                         }
227                     }
228                 }else{
229                     //no values have been entered, return false without error
230                     return false;
231                 }
232                 //error has been thrown, return false
233                 if(has_error == 1){
234                     return false;
235                 }
236                 return true;
237         
238             } 
239
240
241                         /**
242                         *This function will iterate through list of targets and gather all the values.  It will
243                         *populate these values, seperated by delimiters into hidden inputs for processing
244                         */
245                         function gathertargets(){
246                                 //start with the newly added targets, get count of total added
247                                 count = parseInt(targets_added);
248                                 final_list_of_targets_array = new Array();
249                                 //iterate through list of added targets
250                                 for(i=1;i<=count;i++){
251                                         //make sure all values exist
252                                         if( document.getElementById('target_name'+i)  &&  document.getElementById('is_optout'+i)  &&  document.getElementById('target_url'+i) ){
253                                                 //make sure the check box value is int (0/1)
254                                                 var opt_val = '0';
255                                                 if(document.getElementById('is_optout'+i).checked){opt_val =1;}
256                                                 //add values for this target entry into array of target entries
257                                                 final_list_of_targets_array[i] = document.getElementById('target_name'+i).value+"@@"+opt_val+"@@"+document.getElementById('target_url'+i).value;
258                                         }
259                                 }
260                                 //assign array of target entries to hidden input, which will be used by server to process array of targets                              
261                                 document.getElementById('wiz_list_of_targets').value = final_list_of_targets_array.toString();                                  
262
263                                 //Now lets process existing targets, get count of existing targets
264                                 count = parseInt(document.getElementById('existing_target_count').value);
265                                 final_list_of_existing_targets_array = new Array();
266                                 //iterate through list of existing targets
267                                 for(i=0;i<count;i++){
268                                         //make sure all values exist
269                                         if( document.getElementById('existing_target_name'+i)  &&  document.getElementById('existing_is_optout'+i)  &&  document.getElementById('existing_target_url'+i) ){
270                                                 //make sure the check box value is int (0/1)
271                                                 var opt_val = '0';
272                                                 if(document.getElementById('existing_is_optout'+i).checked){opt_val =1;}
273                                                 //add values for this target entry into array of target entries
274                                                 final_list_of_existing_targets_array[i] = document.getElementById('existing_target_id'+i).value+"@@"+document.getElementById('existing_target_name'+i).value+"@@"+opt_val+"@@"+document.getElementById('existing_target_url'+i).value;
275                                         }
276                                 }
277                                 //assign array of target entries to hidden input, which will be used by server to process array of targets                              
278                                 document.getElementById('wiz_list_of_existing_targets').value = final_list_of_existing_targets_array.toString();                                        
279
280
281                         }
282
283                         /*
284                         *This function will populate values based on popup selection, and then call the
285                         *function to add the entry to the list of targets
286                         */
287                         function set_return_prospect_list(popup_reply_data)
288                         {
289                                 var form_name = popup_reply_data.form_name;
290                                 var name_to_value_array = popup_reply_data.name_to_value_array;
291                                 
292                                 
293                                 for (var the_key in name_to_value_array)
294                                 {
295                                         if(the_key == 'toJSON')
296                                         {
297                                                 /* just ignore */
298                                         }
299                                         else
300                                         {
301                                                 window.document.forms[form_name].elements[the_key].value = name_to_value_array[the_key];
302                                         }
303                                 }
304                                 add_target('true');
305                         }
306
307
308                         </script>
309                         {/literal}