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 /*********************************************************************************
39 ********************************************************************************/
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="">
50 <table width="100%" border="0" cellspacing="0" cellpadding="0">
52 <th colspan="5" align="left" ><h4>{$MOD.LBL_TARGET_LISTS}</h4></th>
55 <td colspan="5">{$MOD.LBL_WIZARD_TARGET_MESSAGE1}<br></td>
57 <tr><td colspan=5> </td></tr>
59 <td scope="row" colspan="4">{$MOD.LBL_SELECT_TARGET}
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);'>
69 <tr><td colspan=5> </td></tr>
71 <td scope="row" colspan="5">{$MOD.LBL_WIZARD_TARGET_MESSAGE2}<br></td>
74 <td width='10%' scope="col">{$MOD.LBL_TARGET_NAME}</td>
76 <input id="target_list_name" name="target_list_name" type='text' size='40'>
78 <td width='10%' scope="col">
79 <span sugar='slot28'>{$MOD.LBL_TARGET_TYPE}</span sugar='slot'>
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=''>
87 <td width='30%'><input type='button' value ='{$MOD.LBL_CREATE_TARGET}' class= 'button' onclick="add_target('false');"></td>
89 <tr><td colspan=5> </td></tr>
91 <table width = '100%' class='detail view'>
92 <tr><td>{$MOD.LBL_TRACKERS_ADDED}</td></tr>
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> </td>
98 <td width='25%'><b> </b></td>
101 <div id='added_targets'>
113 var image_path = '{$IMAGE_PATH}';
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();
121 //this function adds selected target to list
122 function add_target(from_popup){
125 if(validate_step4(from_popup)){
126 TRGTNAME = 'target_list_name';
127 TRGTID = 'target_list_id';
128 TRGTYPE = 'target_list_type';
130 if(from_popup == 'true'){
131 TRGTNAME = 'popup_target_list_name'
132 TRGTID = 'popup_target_list_id'
133 TRGTYPE = 'popup_target_list_type'
136 //increment target count value
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 ;
147 //display the selected display text, not the value
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;
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;
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();
166 //now lets clear the form to allow input of new target
167 trgt_name.value = '';
169 trgt_type.value = 'default';
172 if(targets_added ==1){
173 document.getElementById('no_targets').style.display='none';
178 //this function will remove the selected target from the ui, and from the target array
179 function remove_target(div,num){
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();
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){
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;
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
208 function validate_step4(from_popup){
209 if(from_popup=='true'){
212 requiredTxt = SUGAR.language.get('app_strings', 'ERR_MISSING_REQUIRED_FIELDS');
213 var stepname = 'wiz_step3_';
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 );
229 //no values have been entered, return false without error
232 //error has been thrown, return false
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
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)
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;
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();
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)
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;
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();
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
287 function set_return_prospect_list(popup_reply_data)
289 var form_name = popup_reply_data.form_name;
290 var name_to_value_array = popup_reply_data.name_to_value_array;
293 for (var the_key in name_to_value_array)
295 if(the_key == 'toJSON')
301 window.document.forms[form_name].elements[the_key].value = name_to_value_array[the_key];