]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Campaigns/WizardNewsletter.php
Release 6.4.0
[Github/sugarcrm.git] / modules / Campaigns / WizardNewsletter.php
1 <?php
2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4  * SugarCRM Community Edition is a customer relationship management program developed by
5  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
6  * 
7  * This program is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU Affero General Public License version 3 as published by the
9  * Free Software Foundation with the addition of the following permission added
10  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13  * 
14  * This program is distributed in the hope that it will be useful, but WITHOUT
15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
17  * details.
18  * 
19  * You should have received a copy of the GNU Affero General Public License along with
20  * this program; if not, see http://www.gnu.org/licenses or write to the Free
21  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22  * 02110-1301 USA.
23  * 
24  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26  * 
27  * The interactive user interfaces in modified source and object code versions
28  * of this program must display Appropriate Legal Notices, as required under
29  * Section 5 of the GNU Affero General Public License version 3.
30  * 
31  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32  * these Appropriate Legal Notices must retain the display of the "Powered by
33  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34  * technical reasons, the Appropriate Legal Notices must display the words
35  * "Powered by SugarCRM".
36  ********************************************************************************/
37
38 /*********************************************************************************
39
40  * Description:  TODO: To be written.
41  * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
42  * All Rights Reserved.
43  * Contributor(s): ______________________________________..
44  ********************************************************************************/
45
46 /******** general UI Stuff ***********/
47
48
49
50 require_once('modules/Campaigns/utils.php');
51
52
53 global $app_strings;
54 global $timedate;
55 global $app_list_strings;
56 global $mod_strings;
57 global $current_user;
58 global $sugar_version, $sugar_config;
59
60
61 /*************** GENERAL SETUP WORK **********/
62
63 $focus = new Campaign();
64 if(isset($_REQUEST['record'])) {
65     $focus->retrieve($_REQUEST['record']);
66 }
67 if(isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true') {
68     $focus->id = "";
69 }
70 global $theme;
71
72
73
74 $json = getJSONobj();
75
76 $GLOBALS['log']->info("Campaign NewsLetter Wizard");
77
78 if( (isset($_REQUEST['wizardtype'])  && $_REQUEST['wizardtype']==1)  ||  ($focus->campaign_type=='NewsLetter')){
79     echo getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_NEWSLETTER WIZARD_TITLE'].$focus->name), true, false);
80 }else{
81     echo getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_CAMPAIGN'].$focus->name), true, false);   
82 }
83
84
85 $ss = new Sugar_Smarty();
86 $ss->assign("MOD", $mod_strings);
87 $ss->assign("APP", $app_strings);
88
89 if (isset($_REQUEST['return_module'])) $ss->assign("RETURN_MODULE", $_REQUEST['return_module']);
90 if (isset($_REQUEST['return_action'])) $ss->assign("RETURN_ACTION", $_REQUEST['return_action']);
91 if (isset($_REQUEST['return_id'])) $ss->assign("RETURN_ID", $_REQUEST['return_id']);
92 // handle Create $module then Cancel
93 if (empty($_REQUEST['return_id'])) {
94     $ss->assign("RETURN_ACTION", 'index');
95 }
96 $ss->assign("PRINT_URL", "index.php?".$GLOBALS['request_string']);
97
98 require_once('include/QuickSearchDefaults.php');
99 $qsd = new QuickSearchDefaults();
100 $qsd->setFormName('wizform');
101 $sqs_objects = array('parent_name' => $qsd->getQSParent(), 
102                     'assigned_user_name' => $qsd->getQSUser(),
103                     //'prospect_list_name' => getProspectListQSObjects(),
104                     'test_name' => getProspectListQSObjects('prospect_list_type_test', 'test_name','wiz_step3_test_name_id'),
105                     'unsubscription_name' => getProspectListQSObjects('prospect_list_type_exempt', 'unsubscription_name','wiz_step3_unsubscription_name_id'),
106                     'subscription_name' => getProspectListQSObjects('prospect_list_type_default', 'subscription_name','wiz_step3_subscription_name_id'),
107                     );
108                     
109
110 $quicksearch_js = '<script type="text/javascript" language="javascript">sqs_objects = ' . $json->encode($sqs_objects) . '</script>';
111
112 $ss->assign("JAVASCRIPT", $quicksearch_js);
113
114
115 //set the campaign type based on wizardtype value from request object
116 $campaign_type = 'newsletter';
117 if( (isset($_REQUEST['wizardtype'])  && $_REQUEST['wizardtype']==1)  ||  ($focus->campaign_type=='NewsLetter')){
118     $campaign_type = 'newsletter';
119     $ss->assign("CAMPAIGN_DIAGNOSTIC_LINK", diagnose());    
120 }elseif( (isset($_REQUEST['wizardtype'])  && $_REQUEST['wizardtype']==2)  || ($focus->campaign_type=='Email') ){
121     $campaign_type = 'email';
122     $ss->assign("CAMPAIGN_DIAGNOSTIC_LINK", diagnose());
123 }else{
124     $campaign_type = 'general';
125 }
126
127
128 //******** CAMPAIGN HEADER AND BUDGET UI DIV Stuff (both divs) **********/
129 /// Users Popup
130 $popup_request_data = array(
131     'call_back_function' => 'set_return',
132     'form_name' => 'wizform',
133     'field_to_name_array' => array(
134         'id' => 'assigned_user_id',
135         'user_name' => 'assigned_user_name',
136         ),
137     );
138 $ss->assign('encoded_users_popup_request_data', $json->encode($popup_request_data));
139
140
141 //set default values
142 $ss->assign("CALENDAR_LANG", "en");
143 $ss->assign("USER_DATEFORMAT", '('. $timedate->get_user_date_format().')');
144 $ss->assign("CALENDAR_DATEFORMAT", $timedate->get_cal_date_format());
145 $ss->assign("CAMP_DATE_ENTERED", $focus->date_entered);
146 $ss->assign("CAMP_DATE_MODIFIED", $focus->date_modified);
147 $ss->assign("CAMP_CREATED_BY", $focus->created_by_name);
148 $ss->assign("CAMP_MODIFIED_BY", $focus->modified_by_name);
149 $ss->assign("ID", $focus->id);
150 $ss->assign("CAMP_TRACKER_TEXT", $focus->tracker_text);
151 $ss->assign("CAMP_START_DATE", $focus->start_date);
152 $ss->assign("CAMP_END_DATE", $focus->end_date);
153 $ss->assign("CAMP_BUDGET", $focus->budget);
154 $ss->assign("CAMP_ACTUAL_COST", $focus->actual_cost);
155 $ss->assign("CAMP_EXPECTED_REVENUE", $focus->expected_revenue);
156 $ss->assign("CAMP_EXPECTED_COST", $focus->expected_cost);
157 $ss->assign("CAMP_OBJECTIVE", $focus->objective);
158 $ss->assign("CAMP_CONTENT", $focus->content);
159 $ss->assign("CAMP_NAME", $focus->name);
160 $ss->assign("CAMP_RECORD", $focus->id);
161 $ss->assign("CAMP_IMPRESSIONS", $focus->impressions);
162 if (empty($focus->assigned_user_id) && empty($focus->id))  $focus->assigned_user_id = $current_user->id;
163 if (empty($focus->assigned_name) && empty($focus->id))  $focus->assigned_user_name = $current_user->user_name;
164 $ss->assign("ASSIGNED_USER_OPTIONS", get_select_options_with_id(get_user_array(TRUE, "Active", $focus->assigned_user_id), $focus->assigned_user_id));
165 $ss->assign("ASSIGNED_USER_NAME", $focus->assigned_user_name);
166 $ss->assign("ASSIGNED_USER_ID", $focus->assigned_user_id );
167
168 if((!isset($focus->status)) && (!isset($focus->id)))
169     $ss->assign("STATUS_OPTIONS", get_select_options_with_id($app_list_strings['campaign_status_dom'], 'Planning'));
170 else
171     $ss->assign("STATUS_OPTIONS", get_select_options_with_id($app_list_strings['campaign_status_dom'], $focus->status));
172
173 //hide frequency options if this is not a newsletter
174 if($campaign_type == 'newsletter'){
175     $ss->assign("HIDE_FREQUENCY_IF_NEWSLETTER", "Select");
176     $ss->assign("FREQUENCY_LABEL", $mod_strings['LBL_CAMPAIGN_FREQUENCY']);
177     if((!isset($focus->frequency)) && (!isset($focus->id))){
178         $ss->assign("FREQ_OPTIONS", get_select_options_with_id($app_list_strings['newsletter_frequency_dom'], 'Monthly'));
179     }else{
180         $ss->assign("FREQ_OPTIONS", get_select_options_with_id($app_list_strings['newsletter_frequency_dom'], $focus->frequency));
181     }
182 }else{
183     $ss->assign("HIDE_FREQUENCY_IF_NEWSLETTER", "input type='hidden'");
184     $ss->assign("FREQUENCY_LABEL", '&nbsp;');
185 }
186 global $current_user;
187 require_once('modules/Currencies/ListCurrency.php');
188 $currency = new ListCurrency();
189 if(isset($focus->currency_id) && !empty($focus->currency_id)){
190     $selectCurrency = $currency->getSelectOptions($focus->currency_id);
191     $ss->assign("CURRENCY", $selectCurrency);
192 }
193 else if($current_user->getPreference('currency') && !isset($focus->id))
194 {
195     $selectCurrency = $currency->getSelectOptions($current_user->getPreference('currency'));
196     $ss->assign("CURRENCY", $selectCurrency);
197 }else{
198
199     $selectCurrency = $currency->getSelectOptions();
200     $ss->assign("CURRENCY", $selectCurrency);
201
202 }
203 global $current_user;
204 if(is_admin($current_user) && $_REQUEST['module'] != 'DynamicLayout' && !empty($_SESSION['editinplace'])){  
205     $record = '';
206     if(!empty($_REQUEST['record'])){
207         $record =   $_REQUEST['record'];
208     }
209     $ss->assign("ADMIN_EDIT","<a href='index.php?action=index&module=DynamicLayout&from_action=".$_REQUEST['action'] ."&from_module=".$_REQUEST['module'] ."&record=".$record. "'>".SugarThemeRegistry::current()->getImage("EditLayout","border='0' align='bottom'",null,null,'.gif',$mod_strings['LBL_EDIT_LAYOUT'])."</a>");
210
211 }
212
213 echo $currency->getJavascript();
214
215 $seps = get_number_seperators();
216 $ss->assign("NUM_GRP_SEP", $seps[0]);
217 $ss->assign("DEC_SEP", $seps[1]);
218
219
220 //fill out the campaign type dropdown based on type of campaign being created
221 if($campaign_type == 'general'){
222     //get regular campaign dom object and strip out entries for email and newsletter
223     $myTypeOptionsArr = array();
224     $OptionsArr = $app_list_strings['campaign_type_dom'];
225     foreach($OptionsArr as $key=>$val){
226         if($val =='Newsletter' || $val =='Email' || $val =='' ){
227             //do not add   
228         }else{
229             $myTypeOptionsArr[$key] = $val;
230         }
231     }
232     
233     //now create select option html without the newsletter/email, or blank ('') options
234     $type_option_html =' ';
235     $selected = false;
236     foreach($myTypeOptionsArr as $optionKey=>$optionName){
237         //if the selected flag is set to true, then just populate
238         if($selected){
239             $type_option_html .="<option value='$optionKey' >$optionName</option>";
240         }else{//if not selected yet, check to see if this option should be selected
241             //if the campaign type is not empty, then select the retrieved type
242             if(!empty($focus->campaign_type)){
243                 //check to see if key matches campaign type
244                 if($optionKey == $focus->campaign_type){
245                     //mark as selected
246                     $type_option_html .="<option value='$optionKey' selected>$optionName</option>";
247                     //mark as selected for next time
248                     $selected=true;
249                 }else{
250                     //key does not match, just populate
251                     $type_option_html .="<option value='$optionKey' >$optionName</option>";
252                 }
253             }else{
254             //since the campaign type is empty, then select first one                
255                 $type_option_html .="<option value='$optionKey' selected>$optionName</option>";    
256                 //mark as selected for next time
257                 $selected=true;
258             }
259         }    
260     }
261     //assign the modified dropdown for general campaign creation
262     $ss->assign("CAMPAIGN_TYPE_OPTIONS", $type_option_html);
263     $ss->assign("SHOULD_TYPE_BE_DISABLED", "select");    
264 }elseif($campaign_type == 'email'){
265     //Assign Email as type of campaign being created an disable the select widget
266     $ss->assign("CAMPAIGN_TYPE_OPTIONS", $mod_strings['LBL_EMAIL']);
267     $ss->assign("SHOULD_TYPE_BE_DISABLED", "input type='hidden' value='Email'");
268 }else{
269     //Assign NewsLetter as type of campaign being created an disable the select widget
270     $ss->assign("CAMPAIGN_TYPE_OPTIONS", $mod_strings['LBL_NEWSLETTER']);
271     $ss->assign("SHOULD_TYPE_BE_DISABLED", "input type='hidden' value='NewsLetter'");
272
273 }
274
275
276
277
278
279 /***************  TRACKER UI DIV Stuff ***************/
280 //retrieve the trackers
281 $focus->load_relationship('tracked_urls');
282
283 $trkr_lists = $focus->tracked_urls->get();
284 $trkr_html ='';    
285 $ss->assign('TRACKER_COUNT',count($trkr_lists));
286 if(count($trkr_lists)>0){
287 global $odd_bg, $even_bg, $hilite_bg;
288     
289     $trkr_count = 0;
290 //create the html to create tracker table
291     foreach($trkr_lists as $trkr_id){
292         $ct_focus = new CampaignTracker();
293         $ct_focus->retrieve($trkr_id);
294       if(isset($ct_focus->tracker_name) && !empty($ct_focus->tracker_name)){
295             if($ct_focus->is_optout){$opt = 'checked';}else{$opt = '';}
296             $trkr_html .= "<div id='existing_trkr".$trkr_count."'> <table width='100%' border='0' cellspacing='0' cellpadding='0'>" ;
297             $trkr_html .= "<tr class='evenListRowS1'><td width='15%'><input name='wiz_step3_is_optout".$trkr_count."' title='".$mod_strings['LBL_EDIT_OPT_OUT'] . $trkr_count ."' id='existing_is_optout". $trkr_count ."' class='checkbox' type='checkbox' $opt  /><input name='wiz_step3_id".$trkr_count."' value='".$ct_focus->id."' id='existing_tracker_id". $trkr_count ."'type='hidden''/></td>";
298             $trkr_html .= "<td width='40%'> <input id='existing_tracker_name". $trkr_count ."' type='text' size='20' maxlength='255' name='wiz_step3_tracker_name". $trkr_count ."' title='".$mod_strings['LBL_EDIT_TRACKER_NAME']. $trkr_count ."' value='".$ct_focus->tracker_name."' ></td>";
299             $trkr_html .= "<td width='40%'><input type='text' size='60' maxlength='255' name='wiz_step3_tracker_url". $trkr_count ."' title='".$mod_strings['LBL_EDIT_TRACKER_URL']. $trkr_count ."' id='existing_tracker_url". $trkr_count ."' value='".$ct_focus->tracker_url."' ></td>";
300             $trkr_html .= "<td><a href='#' onclick=\"javascript:remove_existing_tracker('existing_trkr".$trkr_count."','".$ct_focus->id."'); \" >  ";
301             $trkr_html .= SugarThemeRegistry::current()->getImage('delete_inline', "border='0'  align='absmiddle'", 12, 12, ".gif", $mod_strings['LBL_DELETE'])."</a></td></tr></table></div>";
302
303
304
305       }
306       $trkr_count =$trkr_count+1;
307     }
308     
309     $trkr_html .= "<div id='no_trackers'></div>";
310     }else{
311         $trkr_html .= "<div id='no_trackers'><table width='100%' border='0' cellspacing='0' cellpadding='0'><tr class='evenListRowS1'><td>".$mod_strings['LBL_NONE']."</td></tr></table></div>";
312     }
313     $ss->assign('EXISTING_TRACKERS', $trkr_html);
314
315
316
317
318
319
320
321
322
323 /************** SUBSCRIPTION UI DIV Stuff ***************/
324 //fill in popups for target list options
325     $popup_request_data = array(
326         'call_back_function' => 'set_return', 
327         'form_name' => 'wizform',
328         'field_to_name_array' => array(
329             'id' => 'wiz_step3_subscription_name_id',
330             'name' => 'wiz_step3_subscription_name',
331             
332             ),
333         );
334
335 $json = getJSONobj();
336 $encoded_newsletter_popup_request_data = $json->encode($popup_request_data);
337 $ss->assign('encoded_subscription_popup_request_data', $encoded_newsletter_popup_request_data);
338
339     $popup_request_data = array(
340         'call_back_function' => 'set_return', 
341         'form_name' => 'wizform',
342         'field_to_name_array' => array(
343             'id' => 'wiz_step3_unsubscription_name_id',
344             'name' => 'unsubscription_name',
345             
346             ),
347         );
348
349 $json = getJSONobj();
350 $encoded_newsletter_popup_request_data = $json->encode($popup_request_data);
351 $ss->assign('encoded_unsubscription_popup_request_data', $encoded_newsletter_popup_request_data);
352
353     $popup_request_data = array(
354         'call_back_function' => 'set_return', //set_return_and_save_background
355         'form_name' => 'wizform',
356         'field_to_name_array' => array(
357             'id' => 'wiz_step3_test_name_id',
358             'name' => 'test_name',
359             
360             ),
361         );
362
363 $json = getJSONobj();
364 $encoded_newsletter_popup_request_data = $json->encode($popup_request_data);
365 $ss->assign('encoded_test_popup_request_data', $encoded_newsletter_popup_request_data);
366
367
368     $popup_request_data = array(
369         'call_back_function' => 'set_return_prospect_list', 
370         'form_name' => 'wizform',
371         'field_to_name_array' => array(
372             'id' => 'popup_target_list_id',
373             'name' => 'popup_target_list_name',
374             'list_type' => 'popup_target_list_type',
375             
376             ),
377         );
378
379 $json = getJSONobj();
380 $encoded_newsletter_popup_request_data = $json->encode($popup_request_data);
381 $ss->assign('encoded_target_list_popup_request_data', $encoded_newsletter_popup_request_data);
382
383 $ss->assign('TARGET_OPTIONS', get_select_options_with_id($app_list_strings['prospect_list_type_dom'], 'default'));
384
385 //retrieve the subscriptions
386 $focus->load_relationship('prospectlists');
387
388 $prospect_lists = $focus->prospectlists->get();
389
390 if((isset($_REQUEST['wizardtype']) && $_REQUEST['wizardtype'] ==1) || ($focus->campaign_type=='NewsLetter')){
391  //this is a newsletter type campaign, fill in subscription values   
392
393 //if prospect lists are returned, then iterate through and populate form values
394 if(count($prospect_lists)>0){
395     
396     foreach($prospect_lists as $pl_id){
397     //retrieve prospect list
398      $pl = new ProspectList();   
399      $pl->retrieve($pl_id);
400
401       if(isset($pl->list_type) && !empty($pl->list_type)){
402          //assign values based on type
403          if(($pl->list_type == 'default') || ($pl->list_type == 'seed')){            
404             $ss->assign('SUBSCRIPTION_ID', $pl->id);
405             $ss->assign('SUBSCRIPTION_NAME', $pl->name);
406          };
407          if($pl->list_type == 'exempt'){
408             $ss->assign('UNSUBSCRIPTION_ID', $pl->id);
409             $ss->assign('UNSUBSCRIPTION_NAME', $pl->name);
410          
411          };
412          if($pl->list_type == 'test'){
413             $ss->assign('TEST_ID', $pl->id);
414             $ss->assign('TEST_NAME', $pl->name);
415          
416          };
417       }
418      
419     }
420 }
421
422
423
424 }else{
425  //this is not a newlsetter campaign, so fill in target list table
426     //create array for javascript, this will help to display the option text, not the value
427     $dom_txt =' ';
428     foreach($app_list_strings['prospect_list_type_dom'] as $key=>$val){
429         $dom_txt .="if(trgt_type_text =='$key'){trgt_type_text='$val';}";
430     }
431     $ss->assign("PL_DOM_STMT", $dom_txt); 
432     $trgt_count = 0;
433     $trgt_html = ' ';
434     if(count($prospect_lists)>0){
435         
436         foreach($prospect_lists as $pl_id){
437         //retrieve prospect list
438              $pl = new ProspectList();   
439              $pl_focus = $pl->retrieve($pl_id);
440              $trgt_html .= "<div id='existing_trgt".$trgt_count."'> <table class='tabDetailViewDL2' width='100%'>" ;
441              $trgt_html .= "<td width='25%'> <input id='existing_target_name". $trgt_count ."' type='hidden' type='text' size='60' maxlength='255' name='existing_target_name". $trgt_count ."'  value='". $pl_focus->name."' >". $pl_focus->name."</td>";
442              $trgt_html .= "<td width='25%'><input type='hidden' size='60' maxlength='255' name='existing_tracker_list_type". $trgt_count ."'   id='existing_tracker_list_type". $trgt_count ."' value='".$pl_focus->list_type."' >".$app_list_strings['prospect_list_type_dom'][$pl_focus->list_type];
443              $trgt_html .= "<input type='hidden' name='added_target_id". $trgt_count ."' id='added_target_id". $trgt_count ."' value='". $pl_focus->id ."' ></td>";
444              $trgt_html .= "<td><a href='#' onclick=\"javascript:remove_existing_target('existing_trgt".$trgt_count."','".$pl_focus->id."'); \" >  ";
445              $trgt_html .= SugarThemeRegistry::current()->getImage('delete_inline', "border='0' align='absmiddle'", 12, 12, ".gif", $mod_string['LBL_DELETE'])."</a></td></tr></table></div>";
446
447
448     
449           
450           $trgt_count =$trgt_count +1;
451         }
452         
453         $trgt_html  .= "<div id='no_targets'></div>";
454     }else{
455         $trgt_html  .= "<div id='no_targets'><table width='100%' border='0' cellspacing='0' cellpadding='0'><tr class='evenListRowS1'><td>".$mod_strings['LBL_NONE']."</td></tr></table></div>";
456         
457     }
458     $ss->assign('EXISTING_TARGETS', $trgt_html );
459
460 }
461
462     
463 /**************************** WIZARD UI DIV Stuff *******************/
464 $mrkt_string = $mod_strings['LBL_NAVIGATION_MENU_MARKETING'];
465 if(!empty($focus->id)){
466     $mrkt_url = "<a  href='index.php?action=WizardMarketing&module=Campaigns&return_module=Campaigns&return_action=WizardHome";
467     $mrkt_url .= "&return_id=".$focus->id."&campaign_id=".$focus->id;
468     $mrkt_url .= "'>". $mrkt_string."</a>";
469     $mrkt_string = $mrkt_url;
470 }
471     $summ_url = $mod_strings['LBL_NAVIGATION_MENU_SUMMARY'];
472     if(!empty($focus->id)){
473         $summ_url = "<a  href='index.php?action=WizardHome&module=Campaigns";
474         $summ_url .= "&return_id=".$focus->id."&record=".$focus->id;
475         $summ_url .= "'> ". $mod_strings['LBL_NAVIGATION_MENU_SUMMARY']."</a>";
476     } 
477    
478
479
480 $script_to_call ='';
481     if (!empty($focus->id)){
482         $script_to_call = "link_navs(1,4);";
483         if(isset($_REQUEST['direct_step']) and !empty($_REQUEST['direct_step'])){
484             $script_to_call .='   direct('.$_REQUEST['direct_step'].');';
485         }
486     } 
487     $ss->assign("HILITE_ALL", $script_to_call);
488
489
490 //  this is the wizard control script that resides in page    
491  $divScript = <<<EOQ
492
493  <script type="text/javascript" language="javascript">
494    
495     /*
496      * this is the custom validation script that will call the right validation for each div
497      */
498     function validate_wiz_form(step){
499         switch (step){
500             case 'step1':
501             if(!validate_step1()){return false;}
502             break;
503             case 'step2':
504             if(!validate_step2()){return false;} 
505             break;                  
506             default://no additional validation needed      
507         }
508         return true;
509     
510     }
511
512     showfirst('newsletter');
513 </script>
514 EOQ;
515
516 $ss->assign("DIV_JAVASCRIPT", $divScript);
517
518
519 $sshtml = ' ';
520     $i = 1;
521
522 //Create the html to fill in the wizard steps
523
524 if($campaign_type == 'general'){
525     $steps = create_campaign_steps();    
526     $ss->assign('NAV_ITEMS',create_wiz_menu_items($steps,'campaign',$mrkt_string,$summ_url));
527     $ss->assign('HIDE_CONTINUE','hidden');
528
529 }elseif($campaign_type == 'email'){
530     $steps = create_email_steps();  
531     $ss->assign('NAV_ITEMS',create_wiz_menu_items($steps,'email',$mrkt_string,$summ_url));
532     $ss->assign('HIDE_CONTINUE','submit');
533 }else{
534     $steps = create_newsletter_steps();  
535     $ss->assign('NAV_ITEMS',create_wiz_menu_items($steps,'newsletter',$mrkt_string,$summ_url));
536     $ss->assign('HIDE_CONTINUE','submit');
537 }
538
539 $ss->assign('TOTAL_STEPS', count($steps));
540 $sshtml = create_wiz_step_divs($steps,$ss);
541 $ss->assign('STEPS',$sshtml);
542                 
543
544 /**************************** FINAL END OF PAGE UI Stuff *******************/
545
546 $ss->display(file_exists('custom/modules/Campaigns/tpls/WizardNewsletter.tpl') ? 'custom/modules/Campaigns/tpls/WizardNewsletter.tpl' : 'modules/Campaigns/tpls/WizardNewsletter.tpl');
547
548
549 function create_newsletter_steps(){
550     global $mod_strings;
551     $steps[$mod_strings['LBL_NAVIGATION_MENU_GEN1']]          = file_exists('custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl' : 'modules/Campaigns/tpls/WizardCampaignHeader.tpl';
552     $steps[$mod_strings['LBL_NAVIGATION_MENU_GEN2']]          = file_exists('custom/modules/Campaigns/tpls/WizardCampaignBudget.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignBudget.tpl' : 'modules/Campaigns/tpls/WizardCampaignBudget.tpl';
553     $steps[$mod_strings['LBL_NAVIGATION_MENU_TRACKERS']]      = file_exists('custom/modules/Campaigns/tpls/WizardCampaignTracker.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignTracker.tpl' : 'modules/Campaigns/tpls/WizardCampaignTracker.tpl';
554     $steps[$mod_strings['LBL_NAVIGATION_MENU_SUBSCRIPTIONS']] = file_exists('custom/modules/Campaigns/tpls/WizardCampaignTargetList.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignTargetList.tpl' : 'modules/Campaigns/tpls/WizardCampaignTargetList.tpl';
555     return  $steps;
556 }
557
558 function create_campaign_steps(){
559     global $mod_strings;
560     $steps[$mod_strings['LBL_NAVIGATION_MENU_GEN1']]          = file_exists('custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl' : 'modules/Campaigns/tpls/WizardCampaignHeader.tpl';
561     $steps[$mod_strings['LBL_NAVIGATION_MENU_GEN2']]          = file_exists('custom/modules/Campaigns/tpls/WizardCampaignBudget.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignBudget.tpl' : 'modules/Campaigns/tpls/WizardCampaignBudget.tpl';
562     $steps[$mod_strings['LBL_NAVIGATION_MENU_TRACKERS']]      = file_exists('custom/modules/Campaigns/tpls/WizardCampaignTracker.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignTracker.tpl' : 'modules/Campaigns/tpls/WizardCampaignTracker.tpl';
563     $steps[$mod_strings['LBL_TARGET_LISTS']]                   = file_exists('custom/modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl' : 'modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl';
564     return  $steps;
565 }
566
567 function create_email_steps(){
568     global $mod_strings;
569     $steps[$mod_strings['LBL_NAVIGATION_MENU_GEN1']]          = file_exists('custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignHeader.tpl' : 'modules/Campaigns/tpls/WizardCampaignHeader.tpl';
570     $steps[$mod_strings['LBL_NAVIGATION_MENU_GEN2']]          = file_exists('custom/modules/Campaigns/tpls/WizardCampaignBudget.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignBudget.tpl' : 'modules/Campaigns/tpls/WizardCampaignBudget.tpl';
571     $steps[$mod_strings['LBL_NAVIGATION_MENU_TRACKERS']]      = file_exists('custom/modules/Campaigns/tpls/WizardCampaignTracker.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignTracker.tpl' : 'modules/Campaigns/tpls/WizardCampaignTracker.tpl';
572     $steps[$mod_strings['LBL_TARGET_LISTS']]                   = file_exists('custom/modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl') ? 'custom/modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl' : 'modules/Campaigns/tpls/WizardCampaignTargetListForNonNewsLetter.tpl';
573     return  $steps;
574 }
575
576
577 function create_wiz_step_divs($steps,$ss){
578     $step_html = '';
579     if(isset($steps)  && !empty($steps)){
580         $i=1;
581         foreach($steps as $name=>$step){
582             $step_html .="<p><div id='step$i'>";
583             $step_html .= $ss->fetch($step);
584             $step_html .="</div></p>";
585             $i = $i+1;
586         }    
587     }
588     return $step_html;
589 }
590  
591 function create_wiz_menu_items($steps,$type,$mrkt_string,$summ_url){
592     global $mod_strings;
593     $nav_html = '<table border="0" cellspacing="0" cellpadding="0" width="100%" >';
594     if(isset($steps)  && !empty($steps)){
595         $i=1;
596         foreach($steps as $name=>$step){
597             $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step$i'>$name</div></td></tr>";
598             $i=$i+1;
599         }
600     }
601     if($type == 'newsletter'  ||  $type == 'email'){
602         $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i+1).">$mrkt_string</div></td></tr>";
603         $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i+2).">".$mod_strings['LBL_NAVIGATION_MENU_SEND_EMAIL']."</div></li>";
604         $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i+3).">".$summ_url."</div></td></tr>";
605     }else{
606      $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i+1).">".$summ_url."</div></td></tr>";   
607     }
608        
609     $nav_html .= '</table>';
610   
611     return $nav_html;
612 }
613     
614
615
616 ?>