]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/Campaigns/WizardNewsletter.php
Release 6.2.3
[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' alt='Edit Layout' align='bottom'")."</a>");    
210 }
211
212 echo $currency->getJavascript();
213
214 $seps = get_number_seperators();
215 $ss->assign("NUM_GRP_SEP", $seps[0]);
216 $ss->assign("DEC_SEP", $seps[1]);
217
218
219 //fill out the campaign type dropdown based on type of campaign being created
220 if($campaign_type == 'general'){
221     //get regular campaign dom object and strip out entries for email and newsletter
222     $myTypeOptionsArr = array();
223     $OptionsArr = $app_list_strings['campaign_type_dom'];
224     foreach($OptionsArr as $key=>$val){
225         if($val =='Newsletter' || $val =='Email' || $val =='' ){
226             //do not add   
227         }else{
228             $myTypeOptionsArr[$key] = $val;
229         }
230     }
231     
232     //now create select option html without the newsletter/email, or blank ('') options
233     $type_option_html =' ';
234     $selected = false;
235     foreach($myTypeOptionsArr as $optionKey=>$optionName){
236         //if the selected flag is set to true, then just populate
237         if($selected){
238             $type_option_html .="<option value='$optionKey' >$optionName</option>";
239         }else{//if not selected yet, check to see if this option should be selected
240             //if the campaign type is not empty, then select the retrieved type
241             if(!empty($focus->campaign_type)){
242                 //check to see if key matches campaign type
243                 if($optionKey == $focus->campaign_type){
244                     //mark as selected
245                     $type_option_html .="<option value='$optionKey' selected>$optionName</option>";
246                     //mark as selected for next time
247                     $selected=true;
248                 }else{
249                     //key does not match, just populate
250                     $type_option_html .="<option value='$optionKey' >$optionName</option>";
251                 }
252             }else{
253             //since the campaign type is empty, then select first one                
254                 $type_option_html .="<option value='$optionKey' selected>$optionName</option>";    
255                 //mark as selected for next time
256                 $selected=true;
257             }
258         }    
259     }
260     //assign the modified dropdown for general campaign creation
261     $ss->assign("CAMPAIGN_TYPE_OPTIONS", $type_option_html);
262     $ss->assign("SHOULD_TYPE_BE_DISABLED", "select");    
263 }elseif($campaign_type == 'email'){
264     //Assign Email as type of campaign being created an disable the select widget
265     $ss->assign("CAMPAIGN_TYPE_OPTIONS", $mod_strings['LBL_EMAIL']);
266     $ss->assign("SHOULD_TYPE_BE_DISABLED", "input type='hidden' value='Email'");
267 }else{
268     //Assign NewsLetter as type of campaign being created an disable the select widget
269     $ss->assign("CAMPAIGN_TYPE_OPTIONS", $mod_strings['LBL_NEWSLETTER']);
270     $ss->assign("SHOULD_TYPE_BE_DISABLED", "input type='hidden' value='NewsLetter'");
271
272 }
273
274
275
276
277
278 /***************  TRACKER UI DIV Stuff ***************/
279 //retrieve the trackers
280 $focus->load_relationship('tracked_urls');
281
282 $trkr_lists = $focus->tracked_urls->get();
283 $trkr_html ='';    
284 $ss->assign('TRACKER_COUNT',count($trkr_lists));
285 if(count($trkr_lists)>0){
286 global $odd_bg, $even_bg, $hilite_bg;
287     
288     $trkr_count = 0;
289 //create the html to create tracker table
290     foreach($trkr_lists as $trkr_id){
291         $ct_focus = new CampaignTracker();
292         $ct_focus->retrieve($trkr_id);
293       if(isset($ct_focus->tracker_name) && !empty($ct_focus->tracker_name)){
294             if($ct_focus->is_optout){$opt = 'checked';}else{$opt = '';}
295             $trkr_html .= "<div id='existing_trkr".$trkr_count."'> <table width='100%' border='0' cellspacing='0' cellpadding='0'>" ;
296             $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>";
297             $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>";
298             $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>";
299             $trkr_html .= "<td><a href='#' onclick=\"javascript:remove_existing_tracker('existing_trkr".$trkr_count."','".$ct_focus->id."'); \" >  ";
300             $trkr_html .= "<img src='".SugarThemeRegistry::current()->getImageURL("delete_inline.gif")."' border='0' alt='rem' align='absmiddle' border='0' height='12' width='12'>". $mod_strings['LBL_REMOVE']."</a></td></tr></table></div>";
301
302       }
303       $trkr_count =$trkr_count+1;
304     }
305     
306     $trkr_html .= "<div id='no_trackers'></div>";
307     }else{
308         $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>";
309     }
310     $ss->assign('EXISTING_TRACKERS', $trkr_html);
311
312
313
314
315
316
317
318
319
320 /************** SUBSCRIPTION UI DIV Stuff ***************/
321 //fill in popups for target list options
322     $popup_request_data = array(
323         'call_back_function' => 'set_return', 
324         'form_name' => 'wizform',
325         'field_to_name_array' => array(
326             'id' => 'wiz_step3_subscription_name_id',
327             'name' => 'wiz_step3_subscription_name',
328             
329             ),
330         );
331
332 $json = getJSONobj();
333 $encoded_newsletter_popup_request_data = $json->encode($popup_request_data);
334 $ss->assign('encoded_subscription_popup_request_data', $encoded_newsletter_popup_request_data);
335
336     $popup_request_data = array(
337         'call_back_function' => 'set_return', 
338         'form_name' => 'wizform',
339         'field_to_name_array' => array(
340             'id' => 'wiz_step3_unsubscription_name_id',
341             'name' => 'unsubscription_name',
342             
343             ),
344         );
345
346 $json = getJSONobj();
347 $encoded_newsletter_popup_request_data = $json->encode($popup_request_data);
348 $ss->assign('encoded_unsubscription_popup_request_data', $encoded_newsletter_popup_request_data);
349
350     $popup_request_data = array(
351         'call_back_function' => 'set_return', //set_return_and_save_background
352         'form_name' => 'wizform',
353         'field_to_name_array' => array(
354             'id' => 'wiz_step3_test_name_id',
355             'name' => 'test_name',
356             
357             ),
358         );
359
360 $json = getJSONobj();
361 $encoded_newsletter_popup_request_data = $json->encode($popup_request_data);
362 $ss->assign('encoded_test_popup_request_data', $encoded_newsletter_popup_request_data);
363
364
365     $popup_request_data = array(
366         'call_back_function' => 'set_return_prospect_list', 
367         'form_name' => 'wizform',
368         'field_to_name_array' => array(
369             'id' => 'popup_target_list_id',
370             'name' => 'popup_target_list_name',
371             'list_type' => 'popup_target_list_type',
372             
373             ),
374         );
375
376 $json = getJSONobj();
377 $encoded_newsletter_popup_request_data = $json->encode($popup_request_data);
378 $ss->assign('encoded_target_list_popup_request_data', $encoded_newsletter_popup_request_data);
379
380 $ss->assign('TARGET_OPTIONS', get_select_options_with_id($app_list_strings['prospect_list_type_dom'], 'default'));
381
382 //retrieve the subscriptions
383 $focus->load_relationship('prospectlists');
384
385 $prospect_lists = $focus->prospectlists->get();
386
387 if((isset($_REQUEST['wizardtype']) && $_REQUEST['wizardtype'] ==1) || ($focus->campaign_type=='NewsLetter')){
388  //this is a newsletter type campaign, fill in subscription values   
389
390 //if prospect lists are returned, then iterate through and populate form values
391 if(count($prospect_lists)>0){
392     
393     foreach($prospect_lists as $pl_id){
394     //retrieve prospect list
395      $pl = new ProspectList();   
396      $pl->retrieve($pl_id);
397
398       if(isset($pl->list_type) && !empty($pl->list_type)){
399          //assign values based on type
400          if(($pl->list_type == 'default') || ($pl->list_type == 'seed')){            
401             $ss->assign('SUBSCRIPTION_ID', $pl->id);
402             $ss->assign('SUBSCRIPTION_NAME', $pl->name);
403          };
404          if($pl->list_type == 'exempt'){
405             $ss->assign('UNSUBSCRIPTION_ID', $pl->id);
406             $ss->assign('UNSUBSCRIPTION_NAME', $pl->name);
407          
408          };
409          if($pl->list_type == 'test'){
410             $ss->assign('TEST_ID', $pl->id);
411             $ss->assign('TEST_NAME', $pl->name);
412          
413          };
414       }
415      
416     }
417 }
418
419
420
421 }else{
422  //this is not a newlsetter campaign, so fill in target list table
423     //create array for javascript, this will help to display the option text, not the value
424     $dom_txt =' ';
425     foreach($app_list_strings['prospect_list_type_dom'] as $key=>$val){
426         $dom_txt .="if(trgt_type_text =='$key'){trgt_type_text='$val';}";
427     }
428     $ss->assign("PL_DOM_STMT", $dom_txt); 
429     $trgt_count = 0;
430     $trgt_html = ' ';
431     if(count($prospect_lists)>0){
432         
433         foreach($prospect_lists as $pl_id){
434         //retrieve prospect list
435              $pl = new ProspectList();   
436              $pl_focus = $pl->retrieve($pl_id);
437              $trgt_html .= "<div id='existing_trgt".$trgt_count."'> <table class='tabDetailViewDL2' width='100%'>" ;
438              $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>";
439              $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];
440              $trgt_html .= "<input type='hidden' name='added_target_id". $trgt_count ."' id='added_target_id". $trgt_count ."' value='". $pl_focus->id ."' ></td>";
441              $trgt_html .= "<td><a href='#' onclick=\"javascript:remove_existing_target('existing_trgt".$trgt_count."','".$pl_focus->id."'); \" >  ";
442              $trgt_html .= "<img src='".SugarThemeRegistry::current()->getImageURL("delete_inline.gif")."' border='0' alt='rem' align='absmiddle' border='0' height='12' width='12'>". $mod_strings['LBL_REMOVE']."</a></td></tr></table></div>";
443     
444           
445           $trgt_count =$trgt_count +1;
446         }
447         
448         $trgt_html  .= "<div id='no_targets'></div>";
449     }else{
450         $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>";
451         
452     }
453     $ss->assign('EXISTING_TARGETS', $trgt_html );
454
455 }
456
457     
458 /**************************** WIZARD UI DIV Stuff *******************/
459 $mrkt_string = $mod_strings['LBL_NAVIGATION_MENU_MARKETING'];
460 if(!empty($focus->id)){
461     $mrkt_url = "<a  href='index.php?action=WizardMarketing&module=Campaigns&return_module=Campaigns&return_action=WizardHome";
462     $mrkt_url .= "&return_id=".$focus->id."&campaign_id=".$focus->id;
463     $mrkt_url .= "'>". $mrkt_string."</a>";
464     $mrkt_string = $mrkt_url;
465 }
466     $summ_url = $mod_strings['LBL_NAVIGATION_MENU_SUMMARY'];
467     if(!empty($focus->id)){
468         $summ_url = "<a  href='index.php?action=WizardHome&module=Campaigns";
469         $summ_url .= "&return_id=".$focus->id."&record=".$focus->id;
470         $summ_url .= "'> ". $mod_strings['LBL_NAVIGATION_MENU_SUMMARY']."</a>";
471     } 
472    
473
474
475 $script_to_call ='';
476     if (!empty($focus->id)){
477         $script_to_call = "link_navs(1,4);";
478         if(isset($_REQUEST['direct_step']) and !empty($_REQUEST['direct_step'])){
479             $script_to_call .='   direct('.$_REQUEST['direct_step'].');';
480         }
481     } 
482     $ss->assign("HILITE_ALL", $script_to_call);
483
484
485 //  this is the wizard control script that resides in page    
486  $divScript = <<<EOQ
487
488  <script type="text/javascript" language="javascript">
489    
490     /*
491      * this is the custom validation script that will call the right validation for each div
492      */
493     function validate_wiz_form(step){
494         switch (step){
495             case 'step1':
496             if(!validate_step1()){return false;}
497             break;
498             case 'step2':
499             if(!validate_step2()){return false;} 
500             break;                  
501             default://no additional validation needed      
502         }
503         return true;
504     
505     }
506
507     showfirst('newsletter');
508 </script>
509 EOQ;
510
511 $ss->assign("DIV_JAVASCRIPT", $divScript);
512
513
514 $sshtml = ' ';
515     $i = 1;
516
517 //Create the html to fill in the wizard steps
518
519 if($campaign_type == 'general'){
520     $steps = create_campaign_steps();    
521     $ss->assign('NAV_ITEMS',create_wiz_menu_items($steps,'campaign',$mrkt_string,$summ_url));
522     $ss->assign('HIDE_CONTINUE','hidden');
523
524 }elseif($campaign_type == 'email'){
525     $steps = create_email_steps();  
526     $ss->assign('NAV_ITEMS',create_wiz_menu_items($steps,'email',$mrkt_string,$summ_url));
527     $ss->assign('HIDE_CONTINUE','submit');
528 }else{
529     $steps = create_newsletter_steps();  
530     $ss->assign('NAV_ITEMS',create_wiz_menu_items($steps,'newsletter',$mrkt_string,$summ_url));
531     $ss->assign('HIDE_CONTINUE','submit');
532 }
533
534 $ss->assign('TOTAL_STEPS', count($steps));
535 $sshtml = create_wiz_step_divs($steps,$ss);
536 $ss->assign('STEPS',$sshtml);
537                 
538
539 /**************************** FINAL END OF PAGE UI Stuff *******************/
540
541 $ss->display(file_exists('custom/modules/Campaigns/tpls/WizardNewsletter.tpl') ? 'custom/modules/Campaigns/tpls/WizardNewsletter.tpl' : 'modules/Campaigns/tpls/WizardNewsletter.tpl');
542
543
544 function create_newsletter_steps(){
545     global $mod_strings;
546     $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';
547     $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';
548     $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';
549     $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';
550     return  $steps;
551 }
552
553 function create_campaign_steps(){
554     global $mod_strings;
555     $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';
556     $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';
557     $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';
558     $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';
559     return  $steps;
560 }
561
562 function create_email_steps(){
563     global $mod_strings;
564     $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';
565     $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';
566     $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';
567     $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';
568     return  $steps;
569 }
570
571
572 function create_wiz_step_divs($steps,$ss){
573     $step_html = '';
574     if(isset($steps)  && !empty($steps)){
575         $i=1;
576         foreach($steps as $name=>$step){
577             $step_html .="<p><div id='step$i'>";
578             $step_html .= $ss->fetch($step);
579             $step_html .="</div></p>";
580             $i = $i+1;
581         }    
582     }
583     return $step_html;
584 }
585  
586 function create_wiz_menu_items($steps,$type,$mrkt_string,$summ_url){
587     global $mod_strings;
588     $nav_html = '<table border="0" cellspacing="0" cellpadding="0" width="100%" >';
589     if(isset($steps)  && !empty($steps)){
590         $i=1;
591         foreach($steps as $name=>$step){
592             $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step$i'>$name</div></td></tr>";
593             $i=$i+1;
594         }
595     }
596     if($type == 'newsletter'  ||  $type == 'email'){
597         $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i+1).">$mrkt_string</div></td></tr>";
598         $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i+2).">".$mod_strings['LBL_NAVIGATION_MENU_SEND_EMAIL']."</div></li>";
599         $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i+3).">".$summ_url."</div></td></tr>";
600     }else{
601      $nav_html .= "<tr><td scope='row' nowrap><div id='nav_step'".($i+1).">".$summ_url."</div></td></tr>";   
602     }
603        
604     $nav_html .= '</table>';
605   
606     return $nav_html;
607 }
608     
609
610
611 ?>