2 /*********************************************************************************
3 * SugarCRM 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 scope="row" 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" tabindex='1' 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);'>
67 <td scope="row"> </td>
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="row">{$MOD.LBL_TARGET_NAME}</td>
75 <td width='20%' scope="row">
76 <input id="target_list_name" name="target_list_name" type='text' size='40'>
78 <td width='10%' scope="row">
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 bprder=1 width='100%'><tr class='detail view'>
96 <td width='25%'><b>{$MOD.LBL_TARGET_NAME}</b></td>
97 <td width='25%'><b>{$MOD.LBL_TARGET_TYPE}</b></td><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 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+"'); \" > <img src='{sugar_getimagepath file='delete_inline.gif'}' alt='rem' align='absmiddle' border='0' height='12' width='12'>{$MOD.LBL_REMOVE}</a></td></tr></table></div>";
158 document.getElementById('added_targets').innerHTML = document.getElementById('added_targets').innerHTML + trgt_html;
160 //add values to array in string, seperated by "@@" characters
161 wiz_list_of_targets_array[targets_added] = trgt_id.value+"@@"+trgt_name.value+"@@"+trgt_type.value;
162 //assign array to hidden input, which will be used by server to process array of targets
163 document.getElementById('wiz_list_of_targets').value = wiz_list_of_targets_array.toString();
165 //now lets clear the form to allow input of new target
166 trgt_name.value = '';
168 trgt_type.value = 'default';
171 if(targets_added ==1){
172 document.getElementById('no_targets').style.display='none';
177 //this function will remove the selected target from the ui, and from the target array
178 function remove_target(div,num){
180 var trgt_div = document.getElementById(div);
181 trgt_div.style.display = 'none';
182 parentNE=trgt_div.parentNode;
183 parentNE.removeChild(trgt_div);
184 //clear target array from this entry and assign to form input
185 wiz_list_of_targets_array[num] = '';
186 document.getElementById('wiz_list_of_targets').value = wiz_list_of_targets_array.toString();
189 //this function will remove the existing target from the ui, and add it's value to an array for removal upon save
190 function remove_existing_target(div,id){
192 var trgt_div = document.getElementById(div);
193 trgt_div.style.display = 'none';
194 parentNE=trgt_div.parentNode;
195 parentNE.removeChild(trgt_div);
196 //assign this id to form input for removal
197 document.getElementById('wiz_remove_target_list').value += ','+id;
203 * this is the custom validation script that will validate the fields on step3 of wizard
204 * this is called directly from the add target button
207 function validate_step4(from_popup){
208 if(from_popup=='true'){
211 requiredTxt = SUGAR.language.get('app_strings', 'ERR_MISSING_REQUIRED_FIELDS');
212 var stepname = 'wiz_step3_';
214 var fields = new Array();
215 fields[0] = 'target_list_name';
216 fields[1] = 'target_list_type';
217 //loop through and check for empty strings (' ')
218 var field_value = '';
219 if( (trim(document.getElementById(fields[0]).value) !='') || (trim(document.getElementById(fields[1]).value) !='')){
220 for (i=0; i < fields.length; i++){
221 field_value = trim(document.getElementById(fields[i]).value);
222 if(field_value.length<1){
223 add_error_style('wizform', fields[i], requiredTxt +' ' +document.getElementById(fields[i]).title );
228 //no values have been entered, return false without error
231 //error has been thrown, return false
241 *This function will iterate through list of targets and gather all the values. It will
242 *populate these values, seperated by delimiters into hidden inputs for processing
244 function gathertargets(){
245 //start with the newly added targets, get count of total added
246 count = parseInt(targets_added);
247 final_list_of_targets_array = new Array();
248 //iterate through list of added targets
249 for(i=1;i<=count;i++){
250 //make sure all values exist
251 if( document.getElementById('target_name'+i) && document.getElementById('is_optout'+i) && document.getElementById('target_url'+i) ){
252 //make sure the check box value is int (0/1)
254 if(document.getElementById('is_optout'+i).checked){opt_val =1;}
255 //add values for this target entry into array of target entries
256 final_list_of_targets_array[i] = document.getElementById('target_name'+i).value+"@@"+opt_val+"@@"+document.getElementById('target_url'+i).value;
259 //assign array of target entries to hidden input, which will be used by server to process array of targets
260 document.getElementById('wiz_list_of_targets').value = final_list_of_targets_array.toString();
262 //Now lets process existing targets, get count of existing targets
263 count = parseInt(document.getElementById('existing_target_count').value);
264 final_list_of_existing_targets_array = new Array();
265 //iterate through list of existing targets
266 for(i=0;i<count;i++){
267 //make sure all values exist
268 if( document.getElementById('existing_target_name'+i) && document.getElementById('existing_is_optout'+i) && document.getElementById('existing_target_url'+i) ){
269 //make sure the check box value is int (0/1)
271 if(document.getElementById('existing_is_optout'+i).checked){opt_val =1;}
272 //add values for this target entry into array of target entries
273 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;
276 //assign array of target entries to hidden input, which will be used by server to process array of targets
277 document.getElementById('wiz_list_of_existing_targets').value = final_list_of_existing_targets_array.toString();
283 *This function will populate values based on popup selection, and then call the
284 *function to add the entry to the list of targets
286 function set_return_prospect_list(popup_reply_data)
288 var form_name = popup_reply_data.form_name;
289 var name_to_value_array = popup_reply_data.name_to_value_array;
292 for (var the_key in name_to_value_array)
294 if(the_key == 'toJSON')
300 window.document.forms[form_name].elements[the_key].value = name_to_value_array[the_key];