-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstep1.php
More file actions
106 lines (90 loc) · 3.13 KB
/
step1.php
File metadata and controls
106 lines (90 loc) · 3.13 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
/*
step1.php
Calls the "Show Tour" API method
Displays passenger number and date selection form
based on the data returned
*/
$title = "Numbers of people and dates";
include_once("inc/top.php");
// Include the config file
include('inc/config.php');
// Tour ID based on previous selection should be in the querystring
isset($_GET['tour']) ? $tour = (int)$_GET['tour'] : exit();
// Channel ID based on previous selection should be in the querystring
isset($_GET['channel']) ? $channel = (int)$_GET['channel'] : exit();
// Query the TourCMS API, get back all the info on this Tour/Hotel
$result = $tourcms->show_tour($tour, $channel);
// Jump straight to the bit of XML related to making a new booking panel
// includes rate and date info
$booking_criteria = $result->tour->new_booking;
?>
<h1><?php print $title; ?></h1>
<p>Below you should be able to select the number of people for each rate that is loaded against this Tour/Hotel (Adults, Children, Premium etc) plus a start date entry. In the case of hotel products there will also be a box for the duration.</p>
<form action="step2.php" method="post">
<?php
$rates = array();
// Process the available rates for this Tour/Hotel
foreach ($booking_criteria->people_selection->rate as $rate) {
$rates[] = (string)$rate->rate_id;
// Process the labels
// Label_1 might be blank, for
(string)$rate->label_1 != "" ? $label = $rate->label_1 : $label = "Number of People";
(string)$rate->label_2 != "" ? $label .= "(" . $rate->label_2 . ")" : null;
?>
<label><?php print $label; ?>
<select name="<?php print $rate->rate_id; ?>">
<?php
$count = (int)$rate->minimum;
$max = (int)$rate->maximum;
while($count <= $max) {
?>
<option><?php print $count; ?></option>
<?php
$count ++;
}
?>
</select>
</label>
<?php
}
// Set some sensible default time
$default_date = strtotime("+2 weeks Saturday");
?>
<label>Date:<input type="text" name="date" value="<?php print date("Y-m-d", $default_date); ?>" /></label>
<?php
$date_type = $booking_criteria->date_selection->date_type;
if($date_type == "DATE_NIGHTS" || $date_type == "DATE_DAYS"):
$min_hdur = $booking_criteria->date_selection->duration_minimum;
$max_hdur = $booking_criteria->date_selection->duration_maximum;
$def_hdur = (int)$result->tour->duration;
if($min_hdur == $max_hdur):
?>
<input type="text" name="hdur" value="3" readonly="true" />
<?
else :
?>
<select name="hdur">
<?php
for($i=$min_hdur; $i<=$max_hdur; $i++):
?>
<option value="<?php print $i; ?>"<?php
$i==$def_hdur ? print ' selected="selected"' : null;
?>><?php print $i; ?></option>
<?php
endfor;
?>
</select>
<?php
endif;
endif;
?>
<input type="hidden" name="rates" value="<?php print implode(",", $rates); ?>" />
<input type="hidden" name="tour" value="<?php print $tour; ?>" />
<input type="hidden" name="channel" value="<?php print $channel; ?>" />
<input type="submit" name="submit" value="Go" />
</form>
<?php
include_once("inc/debug.php");
include_once("inc/bottom.php");
?>