#!/usr/bin/perl # ***************************************************************************************** # camp_schedule.cgi # # this page is for scheduling the email # # History # name removed, 7/30/01, Creation # name removed, 08/07/01, Added logic to allow editing of campaign # name removed, 04/30/02, Added Logic to specify number of emails to send # ***************************************************************************************** # include Perl Modules use strict; use CGI; use empire; # get some objects to use later my $pms = empire->new; my $query = CGI->new; my $sth; my $sth2; my $sql; my $dbh; my $campaign_id = $query->param('campaign_id'); my $list_id; my $status; my $cname; my $schedule_date; my $shour; my $smin; my $max_emails; my $old_mid; my $old_dname; my $clast60; my $openflag; my $aolflag; my $yahoo_flag; my $yahoo_only_flag; my $yahoo_no_flag; my $yes_flag; my $no_flag; my $seven_flag; my $last90_flag; my $last120_flag; my $last240_flag; my $yes_open_flag; my $no_open_flag; my $aol_yes_flag; my $aol_no_flag; my $both_flag; my $light_table_bg = $pms->get_light_table_bg; my $images = $pms->get_images_url; my $list_members = 1; my $counter; # connect to the pms database $pms->db_connect(); $dbh = $pms->get_dbh; # check for login my $user_id = empire::check_security(); if ($user_id == 0) { print "Location: notloggedin.cgi\n\n"; $pms->clean_up(); exit(0); } # make sure this campaign has some valid member list or lists assigned to it before # allowing the user to schedule it to be sent. $sql = "select list_id from campaign_list where campaign_id = $campaign_id"; $sth = $dbh->prepare($sql); $sth->execute(); while (($list_id) = $sth->fetchrow_array()) { $sql = "select member_cnt from list where list_id = $list_id and status = 'A'"; $sth2 = $dbh->prepare($sql); $sth2->execute(); ($counter) = $sth2->fetchrow_array(); $sth2->finish(); $list_members = $list_members + $counter; } $sth->finish(); if ($list_members == 0) { empire::logerror("Error, the campaign you selected does not have any email member lists
assigned to it. You must assign at least one email list that contains
some active members to this campaign before it can be scheduled."); $pms->clean_up(); exit(0); } # print out the html page my $cdate; $sql = "select now()"; $sth = $dbh->prepare($sql); $sth->execute(); ($cdate)=$sth->fetchrow_array(); $sth->finish(); empire::header("Campaign Schedule"); $sql = "select status,curdate(),max_emails,last60_flag,aol_flag,open_flag,yahoo_flag,hour(schedule_time),minute(schedule_time),mid,redirect_domain,campaign_name from campaign where campaign_id=$campaign_id"; $sth = $dbh->prepare($sql); $sth->execute(); ($status,$schedule_date,$max_emails,$clast60,$aolflag,$openflag,$yahoo_flag,$shour,$smin,$old_mid,$old_dname,$cname) = $sth->fetchrow_array(); print << "end_of_html";
Schedule Your Campaign
Set your Campaign status to either Draft or Scheduled. Your Campaign will remain in Draft mode until you move it to Scheduled. If you schedule your Campaign, it will be sent on the date specified beginning around midnight. If you schedule your Campaign for today, it will begin going out in the next 5 minutes.
Campaign Status  Current Datetime: $cdate
New Campaign Name:
end_of_html # get schedule information for this campaign if ($old_dname eq "") { $old_dname="NONE"; } if ($status eq "D") { my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(); $year = $year + 1900; $mon = $mon + 1; if ($mon < 10) { $mon = "0$mon"; } if ($mday < 10) { $mday = "0$mday"; } $schedule_date = "$mon/$mday/$year"; print<<"end_of_html"; end_of_html print qq { Draft
Scheduled for \n }; print qq { }; } else { $schedule_date = substr($schedule_date,5,2) . "/" . substr($schedule_date,8,2) . "/" . substr($schedule_date,0,4); print qq { Draft
Scheduled for \n }; print qq { }; } $sth->finish(); my $i=0; print "  Hour: "; my $i=0; print "  Minute: "; if ($clast60 eq "Y") { $yes_flag="checked"; $no_flag = ""; $seven_flag = ""; $last90_flag = ""; $last120_flag = ""; $last240_flag = ""; } elsif ($clast60 eq "7") { $no_flag=""; $yes_flag = ""; $seven_flag = "checked"; $last90_flag = ""; $last120_flag = ""; $last240_flag = ""; } elsif ($clast60 eq "9") { $no_flag=""; $yes_flag = ""; $seven_flag = ""; $last90_flag = "checked"; $last120_flag = ""; $last240_flag = ""; } elsif ($clast60 eq "2") { $no_flag=""; $yes_flag = ""; $seven_flag = ""; $last90_flag = ""; $last120_flag = "checked"; $last240_flag = ""; } elsif ($clast60 eq "4") { $no_flag=""; $yes_flag = ""; $seven_flag = ""; $last90_flag = ""; $last120_flag = ""; $last240_flag = "checked"; } else { $no_flag="checked"; $yes_flag = ""; $seven_flag = ""; $last90_flag = ""; $last120_flag = ""; $last240_flag = ""; } if ($openflag eq "Y") { $yes_open_flag="checked"; $no_open_flag = ""; } else { $no_open_flag="checked"; $yes_open_flag = ""; } if ($aolflag eq "N") { $aol_yes_flag=""; $aol_no_flag = "checked"; $both_flag = ""; } elsif ($aolflag eq "A") { $aol_yes_flag="checked"; $aol_no_flag = ""; $both_flag = ""; } else { $aol_yes_flag=""; $aol_no_flag = ""; $both_flag = "checked"; } if ($yahoo_flag eq "Y") { $yahoo_flag = "checked"; $yahoo_no_flag = ""; $yahoo_only_flag =""; } elsif ($yahoo_flag eq "O") { $yahoo_flag = ""; $yahoo_no_flag = ""; $yahoo_only_flag ="checked"; } else { $yahoo_flag = ""; $yahoo_only_flag =""; $yahoo_no_flag = "checked"; } print << "end_of_html";
Send To: All  Last 60 Days   Last 90 Days   Last 7 Days   Last 120 Days   Last 240 Days
Send To: No AOL  AOL Only   Both
Include Yahoo: Yes  No  Only Yahoo
Openers Only: No  Yes
 
Max E-mails To Send (-1 means all):
IP to Use:
Redirect Domain:
end_of_html $pms->footer(); $pms->clean_up(); exit(0);