session_start();
$manage=0;
if (session_is_registered("LLC"))
{
$manage=1;
$user = $_SESSION['UNAME'];
}
else
{ // if session check fails, invoke error handler
header("Location: ../loginform.php");
exit();
}
//$Date = $_POST['date'];
//list ($Year, $Month, $Day) = split ('-', $Date);
include("../SendMail.php");
/*
$Weekly = $_POST['weekly'];
$Department = isset($_POST['dpt']) ? $_POST['dpt'] : "AMLA";
$Tag = $_POST['tag'];
$Semester = $_POST['semester'];
$Room = $_POST['room'];
$Title = $_POST['title'];
$StartTime = $_POST['starttime'];
$EndTime = $_POST['endtime'];
$Course = $_POST['course'];
$Student = $_POST['student'];
$Tasks = $_POST['tasks'];
$Needs = $_POST['needs'];
list ($semester, $syear) = split (' ', $Semester);
*/
$Semester = $_GET['semester'];
include("../include/dbconfig.php");
$connection = mysql_connect($db_host, $db_user, $db_pass) or die ("Unable to connect!");
mysql_select_db($db_name);
$dif = date("w");
$today = mktime();
$nextmonday = $today + (8-$dif)*86400;
$nextsaturday = date("Y-m-d", $nextmonday+432000);
$nextmonday = date("Y-m-d", $nextmonday);
$query = "SELECT Title, Date, TIME_FORMAT(StartTime, \"%I:%i %p\"), TIME_FORMAT(SR_reservation.EndTime, \"%I:%i %p\"), CourseID, FirstName, LastName, SR_reservation.ClassID, SR_reservation.RoomNo, Email, CourseTitle, Days, SR_course.BeginTime, SR_course.EndTime, SR_reservation.InstructorID from SR_reservation, SR_instructor, SR_course, SR_room WHERE Date <= '$nextsaturday' and Date >= '$nextmonday' and ";
$query .= "(SR_reservation.Status='1' or SR_reservation.Status='2') and SR_reservation.RoomNo=SR_room.RoomNo and SR_reservation.ClassID=SR_course.ClassID and SR_reservation.InstructorID=SR_instructor.InstructorID and CONCAT(SR_course.Semester, ' ', SR_course.Year) = '$Semester' order by SR_reservation.InstructorID, Date, StartTime";
// echo $query;
$result = mysql_query($query, $connection) or die ("Error in query: $query. " . mysql_error());
$num_rows = mysql_num_rows($result);
$i=0;
$e=0;
if ($num_rows == 0)
{
print "
No reservations are found for next week.
";
exit();
}
else
{
print "Total number of reservations for next week: ".$num_rows."
";
$ID = '';
while ($row = mysql_fetch_row($result)){
$Title = $row[0];
$Date = $row[1];
$StartTime = $row[2];
$EndTime = $row[3];
$Room = $row[8];
$Course = $row[7].' '.$row[4].' - '.$row[11].' - From '.$row[12].' to '.$row[13];
$FirstName = $row[5];
$LastName = $row[6];
$Email = $row[9];
list ($Year, $Month, $Day) = split ('-', $Date);
$Weekday = date("l", mktime(0, 0, 0, $Month, $Day, $Year));
if ( $ID != $row[14])
{
if ( $ID != '')
{
$TEXT=$TEXT."---------------------------------------------------------------------------------\n\n";
$TEXT=$TEXT."If you have any question, please call our at 909-274-4580, or simply reply to this email. We will get back to you as soon as we can.\n\n";
$TEXT=$TEXT."Thank you, Language Learning Center\n";
$i++;
if ($Email0 != '')
{
SendMail(
"langlab@mtsac.edu","Language Learning Center", //sender
$Email0, $FirstName0." ".$LastName0, //recipient
"", // copy to
"Reminder: you have LLC reservations next week ", //subject
$TEXT,$HTML,$ATTM); //body and attachment(s)
$e++;
print "
Email sent to ".$Email0." for ".$FirstName0." ".$LastName0;
}
else
{ print "
No email address for ".$FirstName0." ".$LastName0;
}
}
$ID = $row[14];
$TEXT="Dear Prof. $FirstName $LastName\n\n";
$TEXT=$TEXT."This email is to remind you that you have reservations for next week. It is important to cancel if you cannot make it.\n\n";
}
$TEXT=$TEXT."---------------------------------------------------------------------------------\n";
$TEXT=$TEXT."On $Month/$Day/$Year $Weekday\n";
$TEXT=$TEXT."$Title - $Room\n";
$TEXT=$TEXT."From $StartTime to $EndTime\n";
$TEXT=$TEXT."For class: $Course\n";
$FirstName0 = $FirstName;
$LastName0 = $LastName;
$Email0 = $Email;
}
$TEXT=$TEXT."---------------------------------------------------------------------------------\n\n";
$TEXT=$TEXT."If you have any question, please call us at 909-274-4580, or simply reply to this email. We will get back to you as soon as we can.\n\n";
$TEXT=$TEXT."Thank you, Language Learning Center\n";
$i++;
if ($Email0 != '')
{
SendMail(
"langlab@mtsac.edu","Language Learning Center", //sender
$Email0, $FirstName0." ".$LastName0, //recipient
"", // copy to
"Reminder of your next week's Language Learning Center reservations ", //subject
$TEXT,$HTML,$ATTM); //body and attachment(s)
$e++;
print "
Email sent to ".$Email0." for ".$FirstName0." ".$LastName0;
}
else
{ print "
No email address for ".$FirstName0." ".$LastName0;
}
print "Number of instructors: ".$i."
";
print "Number of emails sent: ".$e."
";
}
$query = "insert into SR_reminder set Date=CURDATE(), Time=CURTIME(), User='$user'";
$result = mysql_query($query, $connection) or die ("Error in query: $query. " . mysql_error());
?>