grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026retrieve($_REQUEST['record']);
/*
$marketingLink = "index.php?action=WizardMarketing&module=Campaigns&return_module=Campaigns&return_action=WizardHome";
$marketingLink .= "&return_id=".$focus->id."&campaign_id=".$focus->id."&jump=3";
SugarApplication::redirect($marketingLink);
return;
*/
global $mod_strings;
global $app_list_strings;
global $app_strings;
global $current_user;
//if (!is_admin($current_user)) sugar_die("Unauthorized access to administration.");
//account for use within wizards
if ($focus->campaign_type == 'NewsLetter') {
echo getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_NEWSLETTER_WIZARD_START_TITLE'].$focus->name), true, false);
} else {
echo getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_CAMPAIGN_WIZARD_START_TITLE'].$focus->name), true, false);
}
global $theme;
global $currentModule;
$ss = new Sugar_Smarty();
$ss->assign("MOD", $mod_strings);
$ss->assign("APP", $app_strings);
//if this page has been refreshed as a result of sending emails, then display status
if (isset($_REQUEST['from'])) {
$mess = $mod_strings['LBL_TEST_EMAILS_SENT'];
if ($_REQUEST['from']=='send') {
$mess = $mod_strings['LBL_EMAILS_SCHEDULED'];
}
$confirm_msg = "var ajaxWizStatus = new SUGAR.ajaxStatusClass(); ";
$confirm_msg .= "window.setTimeout(\"ajaxWizStatus.showStatus('".$mess."')\",1000); ";
$confirm_msg .= "window.setTimeout('ajaxWizStatus.hideStatus()', 1500); ";
$confirm_msg .= "window.setTimeout(\"ajaxWizStatus.showStatus('".$mess."')\",2000); ";
$confirm_msg .= "window.setTimeout('ajaxWizStatus.hideStatus()', 5000); ";
$ss->assign("MSG_SCRIPT", $confirm_msg);
}
if (isset($_REQUEST['return_module'])) {
$ss->assign("RETURN_MODULE", $_REQUEST['return_module']);
}
if (isset($_REQUEST['return_action'])) {
$ss->assign("RETURN_ACTION", $_REQUEST['return_action']);
}
if (isset($_REQUEST['return_id'])) {
$ss->assign("RETURN_ID", $_REQUEST['return_id']);
}
if (isset($_REQUEST['record'])) {
$ss->assign("ID", $_REQUEST['record']);
}
// handle Create $module then Cancel
if (empty($_REQUEST['return_id'])) {
$ss->assign("RETURN_ACTION", 'index');
}
$ss->assign("CAMPAIGN_TBL", create_campaign_summary($focus));
$ss->assign("TARGETS_TBL", create_target_summary($focus));
if ($focus->campaign_type =='NewsLetter' || $focus->campaign_type =='Email') {
$ss->assign("MARKETING_TBL", create_marketing_summary($focus));
$ss->assign("TRACKERS_TBL", create_tracker_summary($focus));
}
$camp_url = "index.php?action=WizardNewsletter&module=Campaigns&return_module=Campaigns&return_action=WizardHome";
$camp_url .= "&return_id=".$focus->id."&record=".$focus->id."&direct_step=";
$ss->assign("CAMP_WIZ_URL", $camp_url);
$mrkt_string = $mod_strings['LBL_NAVIGATION_MENU_MARKETING'];
if (!empty($focus->id)) {
$mrkt_url = "". $mrkt_string."";
$mrkt_string = $mrkt_url;
}
$mrkt_url = "". $mod_strings['LBL_NAVIGATION_MENU_MARKETING']."";
$ss->assign("MRKT_WIZ_URL", $mrkt_url);
$summ_url = " ". $mod_strings['LBL_NAVIGATION_MENU_SUMMARY']."";
//Create the html to fill in the wizard steps
if ($focus->campaign_type == 'NewsLetter') {
$ss->assign('NAV_ITEMS', create_wiz_menu_items('newsletter', $mrkt_string, $camp_url, $summ_url));
$ss->assign("CAMPAIGN_DIAGNOSTIC_LINK", diagnose());
} elseif ($focus->campaign_type == 'Email') {
$ss->assign('NAV_ITEMS', create_wiz_menu_items('email', $mrkt_string, $camp_url, $summ_url));
$ss->assign("CAMPAIGN_DIAGNOSTIC_LINK", diagnose());
} else {
$ss->assign('NAV_ITEMS', create_wiz_menu_items('general', $mrkt_string, $camp_url, $summ_url));
}
/********** FINAL END OF PAGE UI Stuff ********/
$ss->display(file_exists('custom/modules/Campaigns/WizardHome.html') ? 'custom/modules/Campaigns/WizardHome.html' : 'modules/Campaigns/WizardHome.html');
function isWizardSummary()
{
return $_REQUEST['action'] == 'WizardHome';
}
function getFirstMarketingId($campaignId)
{
$db = DBManagerFactory::getInstance();
$campaignId = $db->quote($campaignId);
$emailMarketings = BeanFactory::getBean('EmailMarketing')->get_full_list("", "campaign_id = '$campaignId'");
$firstEmailMarketing = $emailMarketings[0];
if (!is_object($firstEmailMarketing)) {
$ret = null;
LoggerManager::getLogger()->warn('Campaign Wisard Home trying to get first marketing id but the email marketings does not contains it');
} else {
$ret = $firstEmailMarketing->id;
}
return $ret;
}
function getMarketingId()
{
$campaignId = isset($_REQUEST['campaign_id']) && $_REQUEST['campaign_id'] ? $_REQUEST['campaign_id'] : $_REQUEST['record'];
$ret = isset($_POST['marketing_id']) && $_POST['marketing_id'] ? $_POST['marketing_id'] : (
isset($_REQUEST['marketing_id']) && $_REQUEST['marketing_id'] ? $_REQUEST['marketing_id'] : getFirstMarketingId($campaignId)
);
return $ret;
}
if ((isset($_REQUEST['WizardMarketingSave']) && $_REQUEST['WizardMarketingSave']) || isWizardSummary()) {
$campaign_id = $focus->id;
$marketing_id = getMarketingId();
if (!$marketing_id && $_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['action'] == 'WizardHome') {
$header_URL = "Location: index.php?module=Campaigns&offset=1&return_module=Campaigns&action=DetailView&record=" . $campaign_id;
} else {
$header_URL = "Location: index.php?action=WizardMarketing&module=Campaigns&return_module=Campaigns&return_action=WizardHome&return_id=" . $campaign_id . "&campaign_id=" . $campaign_id . "&jump=3&show_wizard_marketing=1&marketing_id=" . $marketing_id . "&record=" . $marketing_id . '&campaign_type=' . $focus->campaign_type . (isset($_REQUEST['template_id']) && $_REQUEST['template_id'] ? '&template_id=' . $_REQUEST['template_id'] : '');
}
SugarApplication::headerRedirect($header_URL);
}
} else {
//there is no record to retrieve, so ask which type of campaign wizard to launch
/* $header_URL = "Location: index.php?module=Campaigns&action=index";
$GLOBALS['log']->debug("about to post header URL of: $header_URL");
header($header_URL);
*/
global $mod_strings;
global $app_list_strings;
global $app_strings;
global $current_user;
//if (!is_admin($current_user)) sugar_die("Unauthorized access to administration.");
//account for use within wizards
echo getClassicModuleTitle($mod_strings['LBL_MODULE_NAME'], array($mod_strings['LBL_CAMPAIGN_WIZARD'].$focus->name), true, false);
$ss = new Sugar_Smarty();
$ss->assign("MOD", $mod_strings);
$ss->assign("APP", $app_strings);
unset($_SESSION['campaignWizard'][isset($campaign_id) ? $campaign_id : null]['defaultSelectedTemplateId']);
$ss->display(file_exists('custom/modules/Campaigns/tpls/WizardHomeStart.tpl') ? 'custom/modules/Campaigns/tpls/WizardHomeStart.tpl' : 'modules/Campaigns/tpls/WizardHomeStart.tpl');
}
function create_campaign_summary($focus)
{
global $mod_strings,$app_strings;
$fields = array();
$fields[] = 'name';
$fields[] = 'assigned_user_name';
$fields[] = 'status';
$fields[] = 'team_name';
$fields[] = 'start_date';
$fields[] = 'end_date';
if ($focus->campaign_type=='NewsLetter') {
$fields[] = 'frequency';
}
$fields[] = 'content';
$fields[] = 'budget';
$fields[] = 'actual_cost';
$fields[] = 'expected_revenue';
$fields[] = 'expected_cost';
$fields[] = 'impressions';
$fields[] = 'objective';
//create edit view status and input buttons
$cmp_input = '';
//create edit campaign button
$cmp_input = "id."';";
$cmp_input.= "this.form.return_id.value='".$focus->id."';\" ";
$cmp_input.= "class='button' value='".$mod_strings['LBL_EDIT_EXISTING']."' type='submit'> ";
//create view status button
if (($focus->campaign_type == 'NewsLetter') || ($focus->campaign_type == 'Email')) {
$cmp_input .= " id."';";
$cmp_input.= "this.form.return_id.value='".$focus->id."';\" ";
$cmp_input.= "class='button' value='".$mod_strings['LBL_TRACK_BUTTON_TITLE']."' type='submit'>";
}
//create view roi button
$cmp_input .= " id."';";
$cmp_input.= "this.form.return_id.value='".$focus->id."';\" ";
$cmp_input.= "class='button' value='".$mod_strings['LBL_TRACK_ROI_BUTTON_LABEL']."' type='submit'>";
//Create Campaign Header
$cmpgn_tbl = "
";
$cmpgn_tbl .= " ".$mod_strings['LBL_LIST_CAMPAIGN_NAME'].' '. $mod_strings['LBL_WIZ_NEWSLETTER_TITLE_SUMMARY']." | ";
$cmpgn_tbl .= "$cmp_input |
";
$colorclass = '';
foreach ($fields as $key) {
if (!empty($focus->$key) && !empty($mod_strings[$focus->field_name_map[$key]['vname']])) {
$cmpgn_tbl .= "| ".$mod_strings[$focus->field_name_map[$key]['vname']]." | \n";
if ($key == 'team_name') {
require_once('modules/Teams/TeamSetManager.php');
$cmpgn_tbl .= "".TeamSetManager::getCommaDelimitedTeams($focus->team_set_id, $focus->team_id, true)." |
\n";
} else {
$cmpgn_tbl .= "".$focus->$key." | \n";
}
}
}
$cmpgn_tbl .= "
";
return $cmpgn_tbl ;
}
function create_marketing_summary($focus)
{
global $mod_strings,$app_strings;
$colorclass = '';
//create new marketing button input
$new_mrkt_input = "id."';";
$new_mrkt_input .= "this.form.return_id.value='".$focus->id."';\" ";
$new_mrkt_input .= "class='button' value='".$mod_strings['LBL_CREATE_NEW_MARKETING_EMAIL']."' type='submit'>";
//create marketing email table
$mrkt_tbl='';
$focus->load_relationship('emailmarketing');
$mrkt_lists = $focus->emailmarketing->get();
$mrkt_tbl = "";
return $mrkt_tbl ;
}
function create_target_summary($focus)
{
global $mod_strings,$app_strings,$app_list_strings;
$colorclass = '';
$camp_type = $focus->campaign_type;
//create schedule table
$pltbl='';
//set the title based on campaign type
$target_title = $mod_strings['LBL_TARGET_LISTS'];
if ($camp_type=='NewsLetter') {
$target_title = $mod_strings['LBL_NAVIGATION_MENU_SUBSCRIPTIONS'];
}
$focus->load_relationship('prospectlists');
$pl_lists = $focus->prospectlists->get();
$pl_tbl = "";
$pl_tbl .= " ".$target_title." |
";
$pl_tbl .= "| ".$mod_strings['LBL_LIST_NAME']." | ".$mod_strings['LBL_LIST_TYPE']." | ";
$pl_tbl .= "".$mod_strings['LBL_TOTAL_ENTRIES']." | |
";
if (count($pl_lists)>0) {
$pl_focus = new ProspectList();
foreach ($pl_lists as $pl_id) {
if ($colorclass== "class='evenListRowS1'") {
$colorclass= "class='oddListRowS1'";
} else {
$colorclass= "class='evenListRowS1'";
}
$pl_focus->retrieve($pl_id);
//set the list type if this is a newsletter
$type=$pl_focus->list_type;
if ($camp_type=='NewsLetter') {
if (($pl_focus->list_type == 'default') || ($pl_focus->list_type == 'seed')) {
$type = $mod_strings['LBL_SUBSCRIPTION_TYPE_NAME'];
}
if ($pl_focus->list_type == 'exempt') {
$type = $mod_strings['LBL_UNSUBSCRIPTION_TYPE_NAME'];
}
if ($pl_focus->list_type == 'test') {
$type = $mod_strings['LBL_TEST_TYPE_NAME'];
}
} else {
$type = $app_list_strings['prospect_list_type_dom'][$pl_focus->list_type];
}
if (isset($pl_focus->id) && !empty($pl_focus->id)) {
$pl_tbl .= "";
$pl_tbl .= "| ";
$pl_tbl .= $pl_focus->name." | ";
$pl_tbl .= "$type | ";
$pl_tbl .= "".$pl_focus->get_entry_count()." | ";
$pl_tbl .= "";
$pl_tbl .= SugarThemeRegistry::current()->getImage('edit_inline', 'border=0', null, null, ".gif", $mod_strings['LBL_EDIT_INLINE']) . " ";
$pl_tbl .= "";
$pl_tbl .= SugarThemeRegistry::current()->getImage('view_inline', 'border=0', null, null, ".gif", $mod_strings['LBL_VIEW_INLINE'])." | ";
}
}
} else {
$pl_tbl .= "
| ".$mod_strings['LBL_NONE']." |
";
}
$pl_tbl .= "
";
return $pl_tbl;
}
function create_tracker_summary($focus)
{
global $mod_strings,$app_strings;
$colorclass = '';
$trkr_tbl='';
//create tracker table
$focus->load_relationship('tracked_urls');
$trkr_lists = $focus->tracked_urls->get();
$trkr_tbl = "";
return $trkr_tbl ;
}
function create_wiz_menu_items($type, $mrkt_string, $camp_url, $summ_url)
{
global $mod_strings;
$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';
$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';
//do not show tracker step for general campaigns (only for newsletter/email)
if ($type != 'general') {
$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';
}
if ($type == 'newsletter') {
$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';
} else {
$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';
}
$nav_html = '';
if (isset($steps) && !empty($steps)) {
$i=1;
foreach ($steps as $name=>$step) {
$nav_html .= " |
";
$i=$i+1;
}
}
if ($type == 'newsletter' || $type == 'email') {
$nav_html .= "$mrkt_string | ";
$nav_html .= "".$mod_strings['LBL_NAVIGATION_MENU_SEND_EMAIL']." | ";
$nav_html .= "".$summ_url." | ";
} else {
$nav_html .= "".$summ_url." | ";
}
$nav_html .= '
';
return $nav_html;
}