Overview
To make bookings, the main change is performed in the drawResult function, which adds a javascript call to the resources that have not been booked. There is also a function that makes the booking and a function that redraws the display once a booking has been displayed using the processinputbox function from the previous examples.

drawResult
The function called drawResult is for the most part identical to the previous example.
The only change is in the highlighted part of the function which draws the available resources. An onclick handler is given to those table items and the javascript function called bookPosition is passed the number of the current item (from the booking position counter stored in the variable i).

bookPosition
The function called bookPosition is called each time the user clicks on a free slot in the list of bookings. The value of the parameter is generated automatically by the drawResult function.

makeResourceBooking
booking/makebooking_XML.php makes a booking and returns the status for the booking that was made. It returns the number of remaining resources for the given date and the exact cost that was computed and stored in the database (as the cost may change when more bookings are made and fewer bookings are available). It is very important to note that no check is made that the resource is actually available at the given date.
It is thus very important to first use the resource available function to verify that the resource in fact is available for booking.

The class attribute that is returned is the cost class of the booking. If the category of the resource has the value 1 the pricing of the booking varies depending on the number of remaining positions. If the class is low the pricing is low, if the class is high, the price increases (look at the example for resource availability for in-depth coverage of pricing).

Call Example:

$.ajax({
	type: 'POST',
	url: 'booking/makebooking_XML.php',
	data: {
		type: company,
		resourceID: resource,
		date: bookingdate,
		customerID: customer,
		rebate: rebate,
		status: "2", // 2 = "Real" booking.
		position: position,
	},
	success:  bookingmade,
	error: errormsg		
});


Returned Data Example:

<result 
    category='1'
    size='24' 
    bookingcost='224.99' 
    bokingclass='2' 
    remaining='20' 
/>