function setPenaltyLUT($tempVar) { if (is_array($tempVar)) { $tempVar = arrayToCSV($tempVar); } $this->penaltyLUT = $tempVar; }
function arrayToCSV($array, $seperator = ';') { if (count($array) > 0) { $csv = ''; foreach ($array as $value) { if (is_array($value) > 0) { $csv .= arrayToCSV($value); } else { $csv .= $value . $seperator; } } return $csv . ' '; } else { return false; } }
<?php include "essential.php"; dbconnect(); print_r($_POST); $query = "UPDATE Requests SET appStatus = 'Cancelled', reqRejectReason='" . $_POST['cancelReason'] . "' WHERE reqNo = " . $_POST['reqNo'] . ";"; execute($query); $query = "DELETE FROM Instances WHERE reqNo = " . $_POST['reqNo'] . ";"; execute($query); $query = "SELECT creator, creatorEmail, room from Requests WHERE reqNo = " . $_POST['reqNo'] . ";"; $result = mysql_fetch_assoc(execute($query)); $query = "SELECT email from ccPerson WHERE reqNo = " . $_POST['reqNo'] . ";"; $cc = array(); $result2 = execute($query); while ($res = mysql_fetch_assoc($result2)) { $cc[] = $res['email']; } $cc = arrayToCSV($cc); cancel($result['creator'], $result['creatorEmail'], $result['room'], $_POST['reqNo'], $_POST['cancelReason'], $cc); header("Location: table.php?view=Accepted");
} switch ($_GET[view]) { case 'All': $query = "SELECT reqNo,creator,room,eventTitle,eventStartDate,eventStartTime,reqType,appStatus FROM Requests "; getRequests("All", $query); break; case 'Pending': $query = "SELECT reqNo,creator,room,eventTitle,eventStartDate,eventStartTime,reqType,appStatus FROM Requests where appStatus = 'Pending'"; getRequests("Pending", $query); break; case 'Rejected': $query = "SELECT reqNo,creator,room,eventTitle,eventStartDate,eventStartTime,reqType,appStatus FROM Requests where appStatus = 'Rejected'"; getRequests("Rejected", $query); 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'];
function clashMux($clashTuples) { $clashGroups = array(); $clashed = array(); foreach ($clashTuples as $tuple1) { $currGroup = array(); if (!in_array($tuple1[0], $clashed)) { $clashed[] = $tuple1[0]; $currGroup[] = $tuple1[0]; } if (!in_array($tuple1[1], $clashed)) { $clashed[] = $tuple1[1]; $currGroup[] = $tuple1[1]; } foreach ($clashTuples as $tuple2) { if (in_array($tuple2[0], $currGroup)) { if (!in_array($tuple2[1], $clashed)) { $clashed[] = $tuple2[1]; $currGroup = array_merge($currGroup, array($tuple2[1])); } } else { if (in_array($tuple2[1], $currGroup)) { if (!in_array($tuple2[0], $clashed)) { $clashed[] = $tuple2[0]; $currGroup = array_merge($currGroup, array($tuple2[0])); } } } } if (sizeof($currGroup)) { $clashGroups[] = $currGroup; } } foreach ($clashGroups as $group) { $currGroup = arrayToCSV($group); $query = "SELECT reqNo,creator,room,eventTitle,eventStartDate,eventStartTime,reqType,appStatus FROM Requests WHERE reqNo IN (" . $currGroup . ");"; $events = execute($query); ?> <tr><td style="visibility:hidden"></td></tr> <?php while ($roomRecords = mysql_fetch_assoc($events)) { ?> <tr> <?php foreach ($roomRecords as $record) { ?> <td> <?php echo $record; ?> </td> <?php } ?> <td><a href='req_detail.php?id=<?php echo $roomRecords['reqNo']; ?> '>Details</a></td> </tr> <?php } } //print_r($roomRecords); return $clashGroups; }