/lenasys/0.1

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/lenasys/0.1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<span class="description">
<br>
<div class="descriptionheading">Overview</div>

The bookings list is a typical function in booking systems that shows the number of bookings of a resource a certain date. 
This can for example be a list of rooms in a hotel that have been booked on a date.<br><br>
One key flaw of the previous example is that we can only se the booked resources and that there is no way to see which resources are available.
The reason for this is that we do not know the number of available resources, and therefore we do not know if there are more resources available.
This example adds a function to count the available resources and a nicer display for the bookings.
<br><br>

<div class="descriptionheading">processinputbox</div>
The function called <span class="interestingdescription">processinputbox</span> is executed by the keyup and onchange events for the text boxes in the form. 
The main difference compared to the previous examples is that two functions are called, one for collecting bookings and one for retrieving the resource size.

<br><br>

<div class="descriptionheading">resultBooking</div>

The <span class="interestingdescription">resultBookings</span> function calls the <span class="interestingdescription">drawResult</span> function and
updates a boolean so that the engine knows that the resource size is valid.
<br><br>

<div class="descriptionheading">resultSize</div>

The <span class="interestingdescription">booking/getresourcesize_XML.php</span> returns a very simple dataset with a single element containing a single attribute.
<br><br>

<div class="descriptionheading">drawResult</div>

The most important new function is the <span class="interestingdescription">drawResult</span> function which draws a table containing the avtilable resources. 
The reason for moving this into a separate function is that this function can be called outside of the scope of the AJAX engine for example if 
the bookings are drawn using html5 rather than using a table as in this example.
<br><br>
The code is mostly the same as in the previous example, except for the counter i, which is increased for each possible booking position. 
The counter is then used to insert table rows using modulo (division rest function) i%4==3 means that a table row is inserted every 4th booking.

<br><br><div class="descriptionheading">getBookingsForDate</div>

The <span class="interestingdescription">booking/getbookings_XML.php</span> can
retrieves all bookings of a <span class="interestingdescription">resourceID</span> for a certain <span class="interestingdescription">date</span>. 
This was detailed in the previous example.

<br><br><div class="descriptionheading">getResourceSize</div>

<span class="interestingdescription">booking/getresourcesize_XML.php</span> 
Retrieves the size of a resource with a given <span class="interestingdescription">resourceID</span>. 

<br><br><div class='exampleheading'>Call Example:<br><br>
<pre><span class="codeexample">$.ajax({
	type: 'POST',
	url: 'booking/getresourcesize_XML.php',
	data: {	resourceID: resource},
	success:  ResultSize
});												
</span></pre>
</div>

<br>

<br><div class='exampleheading'>Returned Data Example:<br>
<pre><span class="codeexample">
&lt;resources&gt;
&lt;resource 
    size='24'
 /&gt;
&lt;/resources&gt;
</span>
</div>
																	
</span></pre>