public function destroy($kitTypeID)
 {
     // This Shall be fun!
     // We have to deconstruct the types based on the forign key dependencys
     // First iterate all the kits, for each kit remove all contents,
     // and then all bookings (and all booking details)
     // then finally we can remove the kit type and then all the logs for that
     // kit type.
     foreach (Kits::where('KitType', '=', $kitTypeID)->get() as $kit) {
         foreach (KitContents::where("KitID", '=', $kit->ID)->get() as $content) {
             KitContents::destroy($content->ID);
         }
         foreach (Booking::where("KitID", '=', $kit->ID)->get() as $booking) {
             foreach (BookingDetails::where("BookingID", '=', $booking->ID)->get() as $detail) {
                 BookingDetails::destroy($detail->ID);
             }
             Booking::destroy($booking->ID);
         }
         Kits::destroy($kit->ID);
     }
     KitTypes::destroy($kitTypeID);
     // Do the logs last, as all the deletes will log the changes of deleting the bits.
     Logs::where('LogKey1', '=', $kitTypeID)->delete();
     return "OK";
 }
 function getBookings($userId)
 {
     ini_set('display_errors', 'On');
     $db = "w4111c.cs.columbia.edu:1521/adb";
     $conn = oci_connect("kpg2108", "test123", $db);
     $stmt = oci_parse($conn, "Select T.ticket_id, F.FLIGHT_DESC,C.CLASS_NAME,T.BOOKING_DATE,F.DEPARTURE_DATE,AA.A_NAME,A.A_NAME,FC.COST , T.TICKET_MILES from ticket t join flight_class fc on T.FLIGHT_CLASS_ID=FC.FLIGHT_CLASS_ID JOIN FLIGHT F ON FC.FLIGHT_ID = F.FLIGHT_ID\r\n\t\tJOIN CLASS C ON FC.CLASS_ID = C.CLASS_ID JOIN ROUTE R ON F.ROUTE_ID = R.ROUTE_ID JOIN AIRPORT A ON R.DESTINATION_AIRPORT_ID = A.AIRPORT_ID\r\n\t\tJOIN AIRPORT AA ON R.SOURCE_AIRPORT_ID = AA.AIRPORT_ID WHERE T.USER_ID = " . $userId);
     oci_execute($stmt);
     oci_close($conn);
     $arrayOfBookingDetails = array();
     $count = 1;
     while ($row = oci_fetch_row($stmt)) {
         $boookingDetails = new BookingDetails();
         $boookingDetails->setTicketId($row[0]);
         $boookingDetails->setFlightName($row[1]);
         $boookingDetails->setClassName($row[2]);
         $boookingDetails->setBookingDate($row[3]);
         $boookingDetails->setDepartureDate($row[4]);
         $boookingDetails->setSource($row[5]);
         $boookingDetails->setDestination($row[6]);
         $boookingDetails->setFare($row[7]);
         $boookingDetails->setTicketMiles($row[8]);
         array_push($arrayOfBookingDetails, $boookingDetails);
         $count = $count + 1;
     }
     foreach ($arrayOfBookingDetails as $value) {
         echo $value->getFare();
     }
     //$arrayOfBookings=
     return $arrayOfBookingDetails;
 }
 public function getKitBookings()
 {
     if (!Request::ajax()) {
         return "not a json request";
     }
     $index = Input::get('ID');
     $query = "select " . "   concat(K.Name, ' - ', K.SpecializedName) as 'Name'," . "   B.ID as 'ID'," . "   B.KitID as 'KitID'," . "   B.ForBranch as 'ForBranch'," . "   B.Purpose as 'Purpose'," . "   B.ShadowStartDate as 'ShadowStartDate'," . "   B.ShadowEndDate as 'ShadowEndDate'," . "   B.StartDate as 'StartDate'," . "   B.EndDate as 'EndDate' " . "from Booking as B" . "   inner join Kits as K" . "       on B.KitID = K.ID " . "where B.KitID = '" . $index . "'";
     $bookings = DB::select(DB::raw($query));
     foreach ($bookings as $booking) {
         $user = BookingDetails::select('UserID')->where('BookingID', $booking->ID)->where('Booker', 1)->first();
         $recipients = BookingDetails::where('BookingID', $booking->ID)->where('Booker', 0)->get();
         $booking->UserID = $user->UserID;
         $booking->KitRecipients = $recipients;
     }
     return $bookings;
 }
 public function destroy($kitID)
 {
     $kit = Kits::find($kitID);
     foreach (Booking::where('KitID', '=', $kitID)->get() as $book) {
         foreach (BookingDetails::where('BookingID', '=', $book->ID)->get() as $detail) {
             BookingDetails::destroy($detail->ID);
         }
         Booking::destroy($book->ID);
     }
     foreach ($kit->contents as $content) {
         KitContents::destroy($content->ID);
     }
     Kits::destroy($kitID);
 }
    $_SESSION['errors'] = $searchCriteria->errors;
    header('Location: booking-failure.php');
} else {
    if (!$systemConfiguration->isSearchEgineEnabled()) {
        $logger->LogError("Search engine is disabled!");
        $_SESSION['errors'] = array(0 => BOOKING_SEARCH_DISABLED);
        header('Location: booking-failure.php');
    } else {
        $bookingDetails->searchCriteria = $searchCriteria;
        $bookingDetailsSerialized = serialize($bookingDetails);
        $_SESSION['bookingDetails'] = $bookingDetailsSerialized;
    }
}
// Clear bookings for which payment was not made
$logger->LogInfo("Clearing expired bookings ...");
BookingDetails::clearExpiredBookings();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="description" content="<?php 
echo $systemConfiguration->getSiteDescription();
?>
" />
	<meta name="keywords" content="<?php 
echo $systemConfiguration->getSiteKeywords();
?>
" />
	<meta http-equiv="Content-Type" content="text/html;charset=<?php