function displaySections($crs, $sched, $sem) { //convert the sections to a calendar-like 2D array $data = array(); $dept = substr($crs, 0, DEPTCODELEN) . "_{$sem}"; $result = Query("SHOW TABLES LIKE '{$dept}'"); if (!mysql_num_rows($result)) { return "Sorry, the course could not be found.<br>"; } $result = Query("SELECT DISTINCT * FROM {$dept} WHERE NAME='{$crs}'"); if (!mysql_num_rows($result)) { return "Sorry, the course could not be found.<br>"; } while (list($name, $section, $day, $start, $end, $loc) = mysql_fetch_row($result)) { // get the currently occupied timings to make it easier for // the student to see what could conflict $numconflicts = checkConflicts($sched, $sem, $name, $section, $day, $start, $end); $start = convertTime($start); $end = convertTime($end); if ($numconflicts) { $data[] = array($section, $day, $start, $end, $loc, 1); } else { $data[] = array($section, $day, $start, $end, $loc, 0); } } // dynamically generate the table in HTML $table = "<table class='records' border='1' align='center' \n\t\t\t\tcellspacing='0' cellpadding='2'>\n\t\t\t\t<tr><th>Section<th>Day<th>Start<th>End<th>Location</tr>"; $table .= "<tr><th colspan=5>Lectures</th></tr>"; // If a section occurs more than once a week, display its name as // a large cell spanning multiple rows for easier differentiation $last = FALSE; $leccount = 0; $tutcount = 0; $pracount = 0; for ($i = 0; $i < count($data); $i++) { $rowspan = 0; list($section, $day, $start, $end, $loc, $conf) = $data[$i]; if ($section[0] == 'T' && $tutcount == 0) { $table .= "<tr><th colspan=5>Tutorials</th></tr>"; } if ($section[0] == 'P' && $pracount == 0) { $table .= "<tr><th colspan=5>Practicals</th></tr>"; } $table .= "<tr>"; // track multiple occurences of section names and adjust rowspan for ($j = $i; $data[$j][0] !== $last && $j < count($data) && $data[$j][0] == $data[$i][0]; $j++) { $rowspan++; } if ($rowspan > 0) { $last = $section; $table .= "<td rowspan='{$rowspan}'>"; $table .= "<input type='radio' "; switch ($section[0]) { case 'L': $table .= "name='lec' "; $leccount++; $table .= $leccount == 1 ? "checked " : ""; break; case 'T': $table .= "name='tut' "; $tutcount++; $table .= $tutcount == 1 ? "checked " : ""; break; case 'P': $table .= "name='pra' "; $pracount++; $table .= $pracount == 1 ? "checked " : ""; break; default: break; } $table .= "value='{$section}'>{$section}</td>"; } if ($conf == 1) { $table .= "<td bgcolor='F1433F'>{$day}</td>\n\t\t\t\t\t\t<td bgcolor='F1433F'>{$start}</td>\n\t\t\t\t\t\t<td bgcolor='F1433F'>{$end}</td>\n\t\t\t\t\t\t<td bgcolor='F1433F'>{$loc}</td>"; } else { $table .= "<td>{$day}</td><td>{$start}</td><td>{$end}</td><td>{$loc}</td>"; } $table .= "</tr>"; } $table .= "</table>"; return $table; }
break; case 'nonConflicts': $nonConflicts = "(" . arrayToCSV(checkNonConflicts()) . ")"; $query = "SELECT reqNo,creator,room,eventTitle,eventStartDate,eventStartTime,reqType,appStatus FROM Requests where reqNo in " . $nonConflicts . ""; getRequests("nonConflicts", $query); break; case 'Cancelled': $query = "SELECT reqNo,creator,room,eventTitle,eventStartDate,eventStartTime,reqType,appStatus FROM Requests where appStatus = 'Cancelled'"; getRequests("Cancelled", $query); break; case 'Accepted': $query = "SELECT reqNo,creator,room,eventTitle,eventStartDate,eventStartTime,reqType,appStatus FROM Requests where appStatus = 'Accepted'"; getRequests("Accepted", $query); break; case 'Conflicts': clashMux(checkConflicts()); if (isset($_GET['st'])) { $mstart = $_GET['st']; } else { $mstart = 0; } } ?> </table> <form method='POST' action='cancelReq.php' id='cancelForm'> <table> <tr> <td>Request Number</td> <td><input type='text' readonly name='reqNo'></td> </tr>
<?php include "essential.php"; dbconnect(); //print_r($_POST); //echo $_POST['forwardID']; $a = "accept"; $b = "reject"; $c = "forward"; $d = "Specify a reason for rejection (optional) )"; $rID = getIDFromHash($_POST['reqID']); $reqArray = getRequestByID(getIDFromHash($_POST['reqID'])); //print_r($reqArray); $clashArrays = clashMux(checkConflicts()); foreach ($clashArrays as $clashArray) { if (in_array($rID, $clashArray)) { break; } } $_POST['reqID'] = getIDFromHash($_POST['reqID']); //Get comma separated string of concerned persons, insert into db $reqID = getIDFromHash($_POST['reqID']); $cc = $_POST['cc']; $ccPersons = CSVToArray($cc); foreach ($ccPersons as $guy) { $query = "INSERT INTO ccPerson(reqNo, email) values(\"{$reqID}\", \"{$guy}\");"; //echo $query; execute($query); } //clashArray now has all elements clashing with the current request, including the current request //