function AddBooking()
 {
     $this->id = 0;
     $this->resourceMap = ResourceDBO::getAllResources();
     $this->allocationTable = new AllocationTable($this->resourceMap);
     $this->commentLog = new BookingCommentLog();
 }
 function AllocationAvailability($resourceId, $numF, $numM, $numX, $reqRoomType, $bookingDates, $resourceProps, &$existingAllocationRows, &$newAllocationRows, $resourceMap = null)
 {
     $this->resourceId = $resourceId;
     $this->numF = $numF;
     $this->numM = $numM;
     $this->numX = $numX;
     $this->reqRoomType = $reqRoomType;
     $this->bookingDates = $bookingDates;
     $this->resourceProps = $resourceProps;
     $this->existingAllocationRows = $existingAllocationRows;
     $this->newAllocationRows = $newAllocationRows;
     $this->resourceMap = $resourceMap == null ? ResourceDBO::getAllResources() : $resourceMap;
 }
 /**
  * Default constructor.
  * $name : guest name
  * $gender : guest gender
  * $resourceId : resource to assign to guest
  * $reqRoomSize : requested room size (e.g. 8, 10, 10+, P, etc..)
  * $reqRoomType : requested room type (M/F/X)
  * $status : current status of allocation (default: reserved)
  * $resourceMap : array() of resource id -> resource recordset (if not specified, query db for all resources)
  */
 function AllocationRow($name, $gender, $resourceId, $reqRoomSize, $reqRoomType, $resourceMap = null)
 {
     $this->rowid = null;
     $this->id = 0;
     $this->name = $name;
     $this->gender = $gender;
     $this->resourceId = $resourceId;
     $this->reqRoomSize = $reqRoomSize;
     $this->reqRoomType = $reqRoomType;
     $this->isAvailable = true;
     if ($resourceMap == null) {
         $this->resourceMap = ResourceDBO::getAllResources();
     } else {
         $this->resourceMap = $resourceMap;
     }
 }
 /**
  * Adds this allocation table to the DOMDocument/XMLElement specified.
  * See toXml() for details.
  * $domtree : DOM document root
  * $parentElement : DOM element where this row will be added
  */
 function addSelfToDocument($domtree, $parentElement)
 {
     // create the root element for this class and append it to our parent
     $xmlRoot = $parentElement->appendChild($domtree->createElement('resources'));
     // if we are editing, then we create a new element
     if ($this->editResourceId != '') {
         $xmlRoot->appendChild($domtree->createElement('editResource', $this->editResourceId));
     }
     foreach (ResourceDBO::getAllResources() as $res) {
         $resourceRow = $domtree->createElement('resource');
         $resourceRow->appendChild($domtree->createElement('resources_url', home_url() . "/" . get_option('hbo_resources_url')));
         $resourceRow->appendChild($domtree->createElement('id', $res->resource_id));
         $resourceRow->appendChild($domtree->createElement('name', $res->name));
         $resourceRow->appendChild($domtree->createElement('path', $res->path));
         $resourceRow->appendChild($domtree->createElement('level', $res->level));
         $resourceRow->appendChild($domtree->createElement('numberChildren', $res->number_children));
         $resourceRow->appendChild($domtree->createElement('type', $res->resource_type));
         $resourceRow->appendChild($domtree->createElement('roomType', $res->room_type));
         $xmlRoot->appendChild($resourceRow);
     }
 }
 /**
  * This will fetch all allocations for the given booking.
  * $bookingId : existing booking id
  * $resourceMap : map of resource id => resource recordset; if null, load all resources
  * $loadBookingDates : true to load booking dates, false to leave uninitialised (default true)
  * Returns array() of AllocationRow for booking id indexed by id
  */
 static function fetchAllocationRowsForBookingId($bookingId, $resourceMap = null, $loadBookingDates = true)
 {
     global $wpdb;
     $resourceMap = $resourceMap == null ? ResourceDBO::getAllResources() : $resourceMap;
     $resultset = $wpdb->get_results($wpdb->prepare("SELECT a.allocation_id, a.guest_name, a.gender, a.resource_id, a.req_room_size, IFNULL(a.req_room_type, 'X') AS req_room_type\r\n               FROM " . $wpdb->prefix . "allocation a\r\n              WHERE a.booking_id = %d\r\n              ORDER BY a.resource_id, a.guest_name", $bookingId));
     if ($wpdb->last_error) {
         throw new DatabaseException($wpdb->last_error);
     }
     $return_val = array();
     foreach ($resultset as $res) {
         $ar = new AllocationRow($res->guest_name, $res->gender, $res->resource_id, $res->req_room_size, $res->req_room_type, $resourceMap);
         $ar->id = $res->allocation_id;
         if ($loadBookingDates) {
             $ar->bookingDates = self::fetchBookingDates($res->allocation_id);
         }
         $return_val[$ar->id] = $ar;
         $ar->rowid = $ar->id;
     }
     return $return_val;
 }
 /**
  * Default constructor.
  * $resourceMap : (optional) map of resource id -> resource recordset
  *                if not set, all resources will be fetched from dbo
  */
 function AllocationTable($resourceMap = null)
 {
     $this->resourceMap = $resourceMap == null ? ResourceDBO::getAllResources() : $resourceMap;
     $this->allocationStrategy = new AllocationStrategy($this->resourceMap);
 }
 /**
  * Default constructor.
  * $resourceMap : (optional) map of resource id -> resource recordset
  *                if not set, all resources will be fetched from dbo
  */
 function AllocationStrategy($resourceMap = null)
 {
     $this->resourceMap = $resourceMap == null ? ResourceDBO::getAllResources() : $resourceMap;
 }