bzr branch
http://gegoxaren.bato24.eu/bzr/lenasys/trunk
12.1.2
by elof.bigestans at gmail
* Added description files for code examples. These were removed on a previous clean-up job, when they shouldn't have been. |
1 |
<span class="description"> |
2 |
<br> |
|
3 |
<div class="descriptionheading">Overview</div> |
|
4 |
||
5 |
The bookings list is a typical function in booking systems that shows the number of bookings of a resource a certain date. |
|
6 |
This can for example be a list of rooms in a hotel that have been booked on a date.<br><br> |
|
7 |
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. |
|
8 |
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. |
|
9 |
This example adds a function to count the available resources and a nicer display for the bookings. |
|
10 |
<br><br> |
|
11 |
||
12 |
<div class="descriptionheading">processinputbox</div> |
|
13 |
The function called <span class="interestingdescription">processinputbox</span> is executed by the keyup and onchange events for the text boxes in the form. |
|
14 |
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. |
|
15 |
||
16 |
<br><br> |
|
17 |
||
18 |
<div class="descriptionheading">resultBooking</div> |
|
19 |
||
20 |
The <span class="interestingdescription">resultBookings</span> function calls the <span class="interestingdescription">drawResult</span> function and |
|
21 |
updates a boolean so that the engine knows that the resource size is valid. |
|
22 |
<br><br> |
|
23 |
||
24 |
<div class="descriptionheading">resultSize</div> |
|
25 |
||
26 |
The <span class="interestingdescription">booking/getresourcesize_XML.php</span> returns a very simple dataset with a single element containing a single attribute. |
|
27 |
<br><br> |
|
28 |
||
29 |
<div class="descriptionheading">drawResult</div> |
|
30 |
||
31 |
The most important new function is the <span class="interestingdescription">drawResult</span> function which draws a table containing the avtilable resources. |
|
32 |
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 |
|
33 |
the bookings are drawn using html5 rather than using a table as in this example. |
|
34 |
<br><br> |
|
35 |
The code is mostly the same as in the previous example, except for the counter i, which is increased for each possible booking position. |
|
36 |
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. |
|
37 |
||
38 |
<br><br><div class="descriptionheading">getBookingsForDate</div> |
|
39 |
||
40 |
The <span class="interestingdescription">booking/getbookings_XML.php</span> can |
|
41 |
retrieves all bookings of a <span class="interestingdescription">resourceID</span> for a certain <span class="interestingdescription">date</span>. |
|
42 |
This was detailed in the previous example. |
|
43 |
||
44 |
<br><br><div class="descriptionheading">getResourceSize</div> |
|
45 |
||
46 |
<span class="interestingdescription">booking/getresourcesize_XML.php</span> |
|
47 |
Retrieves the size of a resource with a given <span class="interestingdescription">resourceID</span>. |
|
48 |
||
49 |
<br><br><div class='exampleheading'>Call Example:<br><br> |
|
50 |
<pre><span class="codeexample">$.ajax({ |
|
51 |
type: 'POST', |
|
52 |
url: 'booking/getresourcesize_XML.php', |
|
53 |
data: { resourceID: resource}, |
|
54 |
success: ResultSize |
|
55 |
}); |
|
56 |
</span></pre> |
|
57 |
</div> |
|
58 |
||
59 |
<br> |
|
60 |
||
61 |
<br><div class='exampleheading'>Returned Data Example:<br> |
|
62 |
<pre><span class="codeexample"> |
|
63 |
<resources> |
|
64 |
<resource
|
|
65 |
size='24' |
|
66 |
/>
|
|
67 |
</resources> |
|
68 |
</span> |
|
69 |
</div> |
|
70 |
||
71 |
</span></pre> |
|
72 |