From af427a992a96519c00ac9f98db8745f9fc1198fb Mon Sep 17 00:00:00 2001 From: "jose.lausuch" Date: Wed, 1 Jun 2016 23:00:08 +0200 Subject: OPNFV Infra Dashboard JIRA: RELENG-12 Change-Id: I7451a3d234e4e5d946cdb905d5720be6159b6544 Signed-off-by: jose.lausuch --- tools/infra-dashboard/utils/book.php | 82 ++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 tools/infra-dashboard/utils/book.php (limited to 'tools/infra-dashboard/utils/book.php') diff --git a/tools/infra-dashboard/utils/book.php b/tools/infra-dashboard/utils/book.php new file mode 100644 index 00000000..6d4c5b20 --- /dev/null +++ b/tools/infra-dashboard/utils/book.php @@ -0,0 +1,82 @@ +0){ + echo "Booking successful. The resource '".$resource_name."' is booked from ".$start." to ".$end."."; + } + else{ + echo "Mysql Error : ".mysql_error().". Query = ".$query; + } + + } + + function getBookedDates() { + $resource_id = $_POST['resource_id']; + $query = "SELECT b.booking_id, b.resource_id,u.name as username,u.email,b.starttime,b.endtime,b.creation,b.purpose FROM booking as b,user as u WHERE b.resource_id=".$resource_id." AND b.user_id=u.user_id;"; + $result = mysql_query($query); + + $events = array(); + while ($row = mysql_fetch_array($result)) { + $e = array(); + $e['id'] = $row['booking_id']; + $e['booker_name'] = $row['username']; + $e['booker_email'] = $row['email']; + $e['title'] = $row['purpose']; + $e['start'] = $row['starttime']; + $e['end'] = $row['endtime']; + $e['bookdate'] = $row['creation']; + + // Merge the event array into the return array + array_push($events, $e); + } + + echo json_encode($events); + } + + + + $action = $_POST['action']; + + connectDB(); + if ($action == "book") { + book(); + } elseif ($action == "getBookedDates" ) { + getBookedDates(); + } else { + echo "Invalid POST action."; + } + closeDB(); +?> -- cgit 1.2.3-korg