<?php // Add the new term if one is being added // if ($_POST["addterm"] == 1 && $_POST["startdate"] != "" && $_POST["title"] != "" && $_POST["enddate"] != "") { $_POST["startdate"] = converttodb($_POST["startdate"]); $_POST["enddate"] = converttodb($_POST["enddate"]); $query = mysql_query("INSERT INTO terms VALUES ('', '{$_POST['title']}', '{$_POST['startdate']}', '{$_POST['enddate']}')") or die("ManageTerms.php: Unable to insert new term - " . mysql_error()); } // Edit the term if one is being edited // if ($_POST["editterm"] == 1 && $_POST["startdate"] != "" && $_POST["title"] != "" && $_POST["enddate"] != "") { $_POST["startdate"] = converttodb($_POST["startdate"]); $_POST["enddate"] = converttodb($_POST["enddate"]); $query = mysql_query("UPDATE `terms` SET `title`='{$_POST['title']}', `startdate`='{$_POST['startdate']}', `enddate`='{$_POST['enddate']}' WHERE `termid`='{$_POST['termid']}' LIMIT 1") or die("ManageTerms.php: Unable to update the term information - " . mysql_error()); } // Delete the terms that the user has requested as well as the classes belonging to those terms // if ($_POST["deleteterm"] == 1) { require_once "DeleteFunctions.php"; $delete = $_POST["delete"]; for ($i = 0; $i < sizeof($delete); $i++) { deleteTerm($delete[$i]); } } print "<script language='JavaScript'>\n // Function to make sure the user wants to delete the term(s) //\n function validate()\n {\n if( document.terms.selectterm.value > 0 )\n {\n\tvar confirmed = confirm(\"Deleteing a term will also delete the semesters, classes, bulletins, tardies, attendance, assignments, and registrations that occured during that term. \\n \\nAre you sure?\");\n\n\tif( confirmed == true )\n\t{\n\t document.terms.submit();\n\t}\n }\n else\n {\n\talert('You must select a term to delete.');\n }\n }\n\n\n // Function to make sure only one checkbox has been selected //\n function checkboxes()\n {\n if( document.terms.selectterm.value == 1 )\n {\n\tdocument.terms.submit();\n }\n else\n {\n\tif( document.terms.selectterm.value > 1 )\n\t{\n\t alert('You can only edit one term at a time.');\n\t}\n\telse\n\t{\n\t alert('You must select a term to edit.');\n\t}\n }\n }\n\n\n // Function to keep track of how many checkboxes are checked //\n function updateboxes(row)\n {\n row = row + 2;\n if(document.terms.elements[row].checked)\n {\n\tdocument.terms.selectterm.value = Math.round(document.terms.selectterm.value) + 1;\n }\n else\n {\n\tdocument.terms.selectterm.value = Math.round(document.terms.selectterm.value) - 1;\n }\n }\n </script>\n\n <h1>Manage Terms</h1>\n <br><br>\n <table align='center' width='450' cellspacing='0' cellpadding='0' border='0'>\n <tr>\n <td>\n <form name='terms' action='./index.php' method='POST'>\n <input type='button' value='Add' onClick='document.terms.page2.value=8;document.terms.submit();'>\n <input type='button' value='Edit' onClick='document.terms.page2.value=12;checkboxes();'>\n <input type='button' value='Delete' onClick='document.terms.deleteterm.value=1;validate();'>\n <br><br>\n <table cellspacing='0' width='450' cellpadding='8' class='dynamiclist'>\n <tr class='header'>\n <td> </td>\n <th>Term Name</th>\n <th>Start Date</th>\n <th>End Date</th>\n </tr>"; // Get the total number of teachers to know how many pages to have // $query = mysql_query("SELECT COUNT(*) FROM terms") or die("ManageTerms.php: Unable to retrieve total number of terms - " . mysql_error()); $numrows = mysql_result($query, 0); $numpages = ceil($numrows / 25); if ($_POST["onpage"] == "") { $_POST["onpage"] = 1; } // Get and display the terms //
$middate = strtotime($dates[0]); $assigndate = strtotime($_POST['assigneddate']); if ($assigndate < $middate) { $query = mysql_query("UPDATE courses SET q1points = (q1points + {$_POST['total']}), totalpoints = (totalpoints + {$_POST['total']}) WHERE courseid = {$_POST['selectclass']}"); } else { $query = mysql_query("UPDATE courses SET q2points = (q2points + {$_POST['total']}), totalpoints = (totalpoints + {$_POST['total']}) WHERE courseid = {$_POST['selectclass']}"); } } } ################ # EDIT # ################ // Edit the assignment if one is being edited // if ($_POST["editassignment"] == 1) { require_once "DBFunctions.php"; $query = mysql_query("UPDATE `assignments` SET title = '{$_POST['title']}', assignmentinformation = '{$_POST['task']}', totalpoints = '{$_POST['total']}', assigneddate = '" . converttodb($_POST[assigneddate]) . "', duedate = '" . converttodb($_POST[duedate]) . "' WHERE `assignmentid`='{$_POST['assignmentid']}' LIMIT 1") or die("ManageAssignments.php: Unable to update the assignment information - " . mysql_error()); // Update the amount of points the student has accumulated for this class // $query = mysql_query("SELECT semesterid FROM courses WHERE courseid = {$_POST['selectclass']}"); $id = mysql_fetch_row($query); $query = mysql_query("SELECT midtermdate FROM semesters WHERE semesterid = {$id['0']}"); $dates = mysql_fetch_row($query); $middate = strtotime($dates[0]); $duedate = strtotime($_POST['duedate']); $wasdate = strtotime($_POST['wasdate']); if ($duedate < $middate) { if ($wasdate < $middate) { $query = mysql_query("UPDATE courses SET q1points=(q1points + {$_POST['total']} - {$_POST['wastotal']}), totalpoints=(totalpoints + {$_POST['total']} - {$_POST['wastotal']}) WHERE courseid = {$_POST['selectclass']}"); } else { $query = mysql_query("UPDATE courses SET q2points=(q2points - {$_POST['wastotal']}), q1points=(q1points + {$_POST['total']}), totalpoints=(totalpoints + {$_POST['total']} - {$_POST['wastotal']}) WHERE courseid = {$_POST['selectclass']}"); } } else {
<?php // Add the new announcement if one is being added // if ($_POST["addannouncement"] == 1 && $_POST["title"] != "" && $_POST["message"] != "") { $_POST["date"] = date("Y-m-d"); $query = mysql_query("INSERT INTO schoolbulletins (title, message, bulletindate) VALUES('{$_POST['title']}', '{$_POST['message']}', '{$_POST['date']}')") or die("ManageAnnouncements.php: Unable to insert new announcement - " . mysql_error()); } // Edit the announcement if one is being edited // if ($_POST["editannouncement"] == 1 && $_POST["title"] != "" && $_POST["message"] != "" && $_POST["date"] != "") { $query = mysql_query("UPDATE `schoolbulletins` SET `title`='{$_POST['title']}', `message`='{$_POST['message']}', `bulletindate`='" . converttodb($_POST["date"]) . "' WHERE `sbulletinid`='{$_POST['announcementid']}' LIMIT 1") or die("ManageAnnouncements.php: Unable to update the announcement information - " . mysql_error()); } // Delete the announcement(s) that the announcement has requested as well as the classes belonging to those announcements // if ($_POST["deleteannouncement"] == 1) { require_once "DeleteFunctions.php"; $delete = $_POST["delete"]; for ($i = 0; $i < sizeof($delete); $i++) { deleteAnnouncement($delete[$i]); } } print "<script language='JavaScript'>\n\n // Function to make sure the announcement wants to delete the announcement(s) //\n function validate()\n {\n if( document.announcements.selectannouncement.value > 0 )\n {\n\tvar confirmed = confirm(\"Are you sure you want to delete this announcement?\");\n\n\tif( confirmed == true )\n\t{\n\t document.announcements.submit();\n\t}\n }\n else\n {\n\talert('You must select a announcement to delete.');\n }\n }\n\n\n // Function to make sure only one checkbox has been selected //\n function checkboxes()\n {\n if( document.announcements.selectannouncement.value == 1 )\n {\n\tdocument.announcements.submit();\n }\n else\n {\n\tif( document.announcements.selectannouncement.value > 1 )\n\t{\n\t alert('You can only edit one announcement at a time.');\n\t}\n\telse\n\t{\n\t alert('You must select a announcement to edit.');\n\t}\n }\n }\n\n\n // Function to keep track of how many checkboxes are checked //\n function updateboxes(row)\n {\n row = row + 2;\n if(document.announcements.elements[row].checked)\n {\n\tdocument.announcements.selectannouncement.value = Math.round(document.announcements.selectannouncement.value) + 1;\n }\n else\n {\n\tdocument.announcements.selectannouncement.value = Math.round(document.announcements.selectannouncement.value) - 1;\n }\n }\n </script>\n\n <h1>Manage Announcements</h1>\n <br><br>\n <table align='center' width='600' cellspacing='0' cellpadding='0' border='0'>\n <tr>\n <td>\n <form name='announcements' action='./index.php' method='POST'>\n <input type='button' value='Add' onClick='document.announcements.page2.value=18;document.announcements.submit();'>\n <input type='button' value='Edit' onClick='document.announcements.page2.value=19;checkboxes();'>\n <input type='button' value='Delete' onClick='document.announcements.deleteannouncement.value=1;validate();'>\n <br><br>\n <table cellspacing='0' width='600' cellpadding='8' class='dynamiclist'>\n <tr class='header'>\n\t<td> </td>\n\t<th>Title</th>\n\t<th>Message</th>\n\t<th>Date</th>\n </tr>"; // Get the total number of announcements to know how many pages to have // $query = mysql_query("SELECT COUNT(*) FROM schoolbulletins") or die("ManageAnnouncements.php: Unable to retrieve total number of announcements - " . mysql_error()); $numrows = mysql_result($query, 0); $numpages = ceil($numrows / 25); if ($_POST["onpage"] == "") { $_POST["onpage"] = 1; } // Get and display the announcements // $query = mysql_query("SELECT * FROM schoolbulletins ORDER BY bulletindate DESC") or die("ManageAnnouncements.php: Unable to retrieve the announcements - " . mysql_error()); $row = 0; $actualrow = 0;
<?php // Edit the grade when it is to be edited // if ($_POST['editgrade'] == 1) { require_once "DBFunctions.php"; // If a grade has already been inserted, then just update it. // // Otherwise add a new grade // if ($_POST['gradeid'] != '') { $query = mysql_query("UPDATE grades SET submitdate = '" . converttodb($_POST['gradedate']) . "', points = '{$_POST['points']}', comment = '{$_POST['comment']}', islate = '" . ($_POST['late'] == 1 ? "1" : "0") . "' WHERE gradeid = {$_POST['gradeid']}") or die("ManageGrades.php: Unable to update the grade - " . mysql_error()); } else { // Get the semester and term ids from the class to be inserted // $query = mysql_query('SELECT semesterid,termid FROM courses WHERE courseid = ' . $_POST["selectclass"]); $ids = mysql_fetch_row($query); $query = mysql_query("INSERT INTO grades (assignmentid, courseid, semesterid, termid, studentid, points, comment, submitdate, islate) VALUES( '{$_POST['assignment']}', '{$_POST['selectclass']}', '{$ids['0']}', '{$ids['1']}', '{$_POST['student']}', '{$_POST['points']}', '{$_POST['comment']}', '" . converttodb($_POST['gradedate']) . "', '" . ($_POST['late'] == 1 ? "1" : "0") . "')") or die("ManageGrades.php: Unable to insert the new grade - " . mysql_error()); } // Update the amount of points the student has accumulated for this class // $query = mysql_query("SELECT semesterid FROM courses WHERE courseid = {$_POST['selectclass']}"); $id = mysql_fetch_row($query); $query = mysql_query("SELECT midtermdate FROM semesters WHERE semesterid = {$id['0']}"); $dates = mysql_fetch_row($query); $middate = strtotime($dates[0]); $submitdate = strtotime($_POST['gradedate']); $wasdate = strtotime($_POST['wasdate']); if ($submitdate < $middate) { if ($wasdate < $middate) { $query = mysql_query("UPDATE registrations SET q1currpoints=(q1currpoints + {$_POST['points']} - {$_POST['wasgrade']}), currentpoints=(currentpoints + {$_POST['points']} - {$_POST['wasgrade']}) WHERE courseid = {$_POST['selectclass']} AND studentid = {$_POST['student']}"); } else { $query = mysql_query("UPDATE registrations SET q2currpoints=(q2currpoints - {$_POST['wasgrade']}), q1currpoints=(q1currpoints + {$_POST['points']}), currentpoints=(currentpoints + {$_POST['points']} - {$_POST['wasgrade']}) WHERE courseid = {$_POST['selectclass']} AND studentid = {$_POST['student']}"); } } else { if ($wasdate < $middate) {
<?php // Add the attendance record if the user is adding one // if ($_POST["addattendance"] == 1) { require_once "DBFunctions.php"; // Get the termid from the semester // $query = mysql_query('SELECT termid FROM semesters WHERE semesterid = ' . $_POST["semester"]); $id = mysql_result($query, 0); // Insert the attendance record // $query = mysql_query("INSERT INTO schoolattendance VALUES('', '{$_POST['student']}', '" . converttodb($_POST["attdate"]) . "', '{$_POST['semester']}', {$id}, '{$_POST['type']}')") or die("ManageAttendance.php: Unable to insert new attendance record - " . mysql_error()); } // Delete the selected attendance record // if ($_POST["deletereg"] == 1) { require_once "DeleteFunctions.php"; $delete = $_POST["delete"]; for ($i = 0; $i < sizeof($delete); $i++) { deleteAttendance($delete[$i]); } } print "<script language='JavaScript'>\n\n // Function to make sure the student wants to delete the registration(s) //\n function validate()\n {\n if( document.registration.selectreg.value > 0 )\n {\n\tvar confirmed = confirm(\"Are you sure you want to delete this attendance record?\");\n\n\tif( confirmed == true )\n\t{\n\t document.registration.submit();\n\t}\n }\n else\n {\n\talert('You must select an attendance record to delete.');\n }\n }\n\n\n // Function to make sure only one checkbox has been selected //\n function checkboxes()\n {\n if( document.registration.selectreg.value == 1 )\n {\n\tdocument.registration.submit();\n }\n else\n {\n\tif( document.registration.selectreg.value > 1 )\n\t{\n\t alert('You can only edit one student at a time.');\n\t}\n\telse\n\t{\n\t alert('You must select a registration to edit.');\n\t}\n }\n }\n\n\n // Function to keep track of how many checkboxes are checked //\n function updateboxes(row)\n {\n row = row + 1;\n if(document.registration.elements[row].checked)\n {\n\tdocument.registration.selectreg.value = Math.round(document.registration.selectreg.value) + 1;\n }\n else\n {\n\tdocument.registration.selectreg.value = Math.round(document.registration.selectreg.value) - 1;\n }\n //alert(document.registration.selectreg.value);\n }\n </script>\n <h1>Attendance</h1>\n <br>\n <table align='center' width='400' cellspacing='0' cellpadding='0' border='0'>\n <tr>\n <td>\n <form name='registration' action='./index.php' method='POST'>\n <b>Semester: </b> <select name='semester' onChange='document.registration.addattend.value=0;document.registration.deletereg.value=0;document.registration.submit();'>\n "; // Get a list of semesters // $query = mysql_query("SELECT semesterid, title FROM semesters") or die("Registration.php: Unable to get a list of semesters for drop-down - " . mysql_error()); if ($_POST['semester'] == NULL) { $q = mysql_query("SELECT semesterid, title FROM semesters WHERE startdate < CURDATE() < enddate"); $temp = mysql_fetch_row($q); $_POST['semester'] = $temp[0]; if ($_POST['semester'] == NULL) { $_POST['semester'] = ''; } } while ($semester = mysql_fetch_row($query)) {
<?php // Edit the grade when it is to be edited // if ($_POST['editgrade'] == 1) { require_once "DBFunctions.php"; // If a grade has already been inserted, then just update it. // // Otherwise add a new grade // if ($_POST['gradeid'] != '') { $query = mysql_query("UPDATE grades SET submitdate = '" . converttodb($_POST['gradedate']) . "', points = '{$_POST['points']}', comment = '{$_POST['comment']}', islate = '" . ($_POST['late'] == 1 ? "1" : "0") . "' WHERE gradeid = {$_POST['gradeid']}") or die("ManageGrades.php: Unable to update the grade - " . mysql_error()); } else { // Get the semester and term ids from the class to be inserted // $query = mysql_query('SELECT semesterid,termid FROM courses WHERE courseid = ' . $_POST["selectclass"]); $ids = mysql_fetch_row($query); $query = mysql_query("INSERT INTO grades VALUES('', '{$_POST['assignment']}', '{$_POST['selectclass']}', '{$ids['0']}', '{$ids['1']}', '{$_POST['student']}', '{$_POST['points']}', '{$_POST['comment']}', '" . converttodb($_POST['gradedate']) . "', '" . ($_POST['late'] == 1 ? "1" : "0") . "')") or die("ManageGrades.php: Unable to insert the new grade - " . mysql_error()); } // Update the amount of points the student has accumulated for this class // $query = mysql_query("SELECT semesterid FROM courses WHERE courseid = {$_POST['selectclass']}"); $id = mysql_fetch_row($query); $query = mysql_query("SELECT midtermdate FROM semesters WHERE semesterid = {$id['0']}"); $dates = mysql_fetch_row($query); $middate = strtotime($dates[0]); $submitdate = strtotime($_POST['gradedate']); $wasdate = strtotime($_POST['wasdate']); if ($submitdate < $middate) { if ($wasdate < $middate) { $query = mysql_query("UPDATE registrations SET q1currpoints=(q1currpoints + {$_POST['points']} - {$_POST['wasgrade']}), currentpoints=(currentpoints + {$_POST['points']} - {$_POST['wasgrade']}) WHERE courseid = {$_POST['selectclass']} AND studentid = {$_POST['student']}"); } else { $query = mysql_query("UPDATE registrations SET q2currpoints=(q2currpoints - {$_POST['wasgrade']}), q1currpoints=(q1currpoints + {$_POST['points']}), currentpoints=(currentpoints + {$_POST['points']} - {$_POST['wasgrade']}) WHERE courseid = {$_POST['selectclass']} AND studentid = {$_POST['student']}"); } } else { if ($wasdate < $middate) {