Skip to content

Commit 3aac541

Browse files
committed
General tidy up
1 parent 28cde8a commit 3aac541

5 files changed

Lines changed: 54 additions & 35 deletions

File tree

inc/config-example.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<?php
2+
// START CONFIGURATION
3+
24
// Include the TourCMS API wrapper
35
include_once($_SERVER['DOCUMENT_ROOT'] . '/tourcms.php');
46

@@ -18,10 +20,24 @@
1820
$result_type = 'simplexml';
1921

2022
// Set the response URL, only required if being used by a Tour Operator
21-
// Point this to ".....step3.php?tour_id={tour_id}"
23+
// Point this to ".....step3.php"
2224
// Explanation here: http://www.tourcms.com/support/api/mp/booking_getkey.php
23-
$response_url = "http://www.example.com/very-basic-booking-engine/step3.php?tour={tour_id}";
25+
$response_url = "http://www.example.com/very-basic-booking-engine/step3.php";
26+
27+
// Format for prettifying dates
28+
// http://php.net/manual/en/function.date.php
29+
$date_format = "l jS F";
2430

2531
// Create a new Instance of the TourCMS API class
2632
$tourcms = new TourCMS($marketplace_account_id, $api_private_key, $result_type);
33+
34+
// END CONFIGURATION
35+
?><?php
36+
37+
function prettify_date($date) {
38+
global $date_format;
39+
40+
return date($date_format, strtotime($date));
41+
}
42+
2743
?>

step2.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@
1212

1313

1414
// Process the form
15+
// We don't actually need any of this on this step, we will just be passing it on
16+
// in the querystring to Step 3
1517
$qs = "";
18+
// Tour ID
19+
isset($_POST['tour']) ? $tour = $_POST['tour'] : exit();
20+
$qs .= "?tour=" . $tour;
1621
// Date
1722
isset($_POST['date']) ? $date = $_POST['date'] : $date = "";
1823
$qs .= "&date=" . $date;
@@ -35,14 +40,18 @@
3540
}
3641
}
3742
$qs .= "&total_people=" . $total_people;
43+
44+
// If this is a Marketplace partner we can just redirect to Step 3
45+
if($marketplace_account_id > 0) {
46+
header("Location: " . $response_url . $qs);
47+
exit();
48+
}
49+
50+
// Otherwise we need to redirect via TourCMS
3851

3952
// Create a new SimpleXMLElement to hold the response url
4053
$url_data = new SimpleXMLElement('<url />');
41-
42-
// Add the response url, TourCMS will redirect to this, appending the key
43-
$response_url = str_replace("{tour_id}", (int)$_POST['tour'], $response_url) . $qs;
44-
$url_data->addChild('response_url', htmlentities($response_url));
45-
//$url_data->addChild('response_url', "http://tourcmsdev.macbook/scratch/api/bookings/step3.php?qs=" . urlencode("tour=" . (int)$_POST['tour'] . $qs));
54+
$url_data->addChild('response_url', htmlentities($response_url . $qs));
4655

4756
// Send the response URL to TourCMS
4857
$result = $tourcms->get_booking_redirect_url($url_data, $channel_id);
@@ -51,7 +60,8 @@
5160
$redirect_url = $result->url->redirect_url;
5261

5362
// Redirect the customer to the URL obtained from TourCMS
63+
// Comment these next two lines if you want to see the data sent and returned
5464
header("Location: " . $redirect_url);
5565
exit();
5666

57-
?><pre><?php htmlspecialchars(print($url_data->asXML())); ?></pre><pre><?php print_r($result); ?></pre><pre><?php print $redirect_url; ?></pre>
67+
?><pre><?php htmlentities(print($url_data->asXML())); ?></pre><pre><?php print_r($result); ?></pre><pre><?php print $redirect_url; ?></pre>

step3.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// Include the config file
1515
include('inc/config.php');
1616

17-
//$qs = "id=" . $tour;
17+
1818
$qs = "";
1919

2020
if($marketplace_account_id == 0)
@@ -79,10 +79,20 @@
7979
<td><input type="radio" name="component_key" value="<?php print $component->component_key; ?>"<?php
8080
($counter==1) ? print "checked" : null;
8181
?> /></td>
82-
<td><?php print $component->date_code; ?></td>
83-
<td><?php print $component->start_date; ?></td>
84-
<td><?php print ($component->end_date != $component->start_date ? $component->end_date : null ); ?></td>
85-
<td><?php print $component->note . $component->special_offer_note; ?></td>
82+
<td><?php ($hdur>0) ? null : print $component->date_code ; ?></td>
83+
<td><?php print prettify_date($component->start_date); ?></td>
84+
<td><?php print ($component->end_date != $component->start_date ? prettify_date($component->end_date) : null ); ?></td>
85+
<td><?php
86+
// For hotel type products, lets show the room type
87+
if ($hdur > 0):
88+
foreach ($component->price_breakdown->price_row as $price_row) {
89+
print "<strong>" . $price_row . "</strong> ";
90+
}
91+
print "(" . $component->note . ")";
92+
else:
93+
print $component->note;
94+
endif;
95+
?></td>
8696
<td><?php print $component->total_price_display; ?></td>
8797
</tr>
8898
<?php

step4.php

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
step4.php
44
55
6-
Calls "Check Availability" to see actual live availability
7-
If there's a choice then that's displayed to the customer
8-
Boxes for customer details displayed
6+
Builds up an XML document representing the customers booking
7+
Posts that XML to TourCMS creating a temporary booking
8+
Temporary booking will be holding off space on any departures / rooms selected
99
1010
*/
1111
$title = "Temporary booking created, prompt for creation of confirmed booking";
@@ -14,9 +14,6 @@
1414
// Include the config file
1515
include('inc/config.php');
1616

17-
18-
19-
2017
$component_key = isset($_POST['component_key']) ? $_POST['component_key'] : null;
2118

2219
$total_people = (int)$_POST['total_people'];
@@ -25,20 +22,6 @@
2522
$firstnames = $_POST['firstname'];
2623
$surnames = $_POST['surname'];
2724
$email = $_POST['email'];
28-
29-
/*<booking>
30-
<total_customers>5</total_customers>
31-
<components> <component_key>HJ9bTSGoEDggHp8dsqabg6svjs0oaZiIx06jUrncRCt3gqWj5nNZOhRzjICSqeaFeh0MxgEanx7Dd5oLR3fQB4qFNQjr0wzxJ18odj2px0pJY/X33Umude2SskWytAVLQjbrpDb2cY7a7VoDgxVzGMIylZ8xX1AKeBoPE+6j8ZI=</component_key>
32-
</components>
33-
<customers>
34-
<customer>
35-
<customer_id>4496</customer_id>
36-
</customer>
37-
<customer>
38-
<customer_id>4496</customer_id>
39-
</customer>
40-
</customers>
41-
</booking>*/
4225

4326
// Create a new SimpleXMLElement to hold the booking details
4427
$booking = new SimpleXMLElement('<booking />');
@@ -68,7 +51,7 @@
6851

6952
?>
7053
<h1><?php print $title; ?></h1>
71-
<p>Are you sure you wish to book this Tour?</p>
54+
<p>Are you sure you wish to book this Tour/Hotel?</p>
7255
<form method="post" action="step5.php">
7356
<input type="hidden" name="booking_id" value="<?php print $result->booking->booking_id; ?>" />
7457
<input type="submit" name="submit" value="Go" />

step5.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
?>
2727
<h1>Booking <?php print $result->booking->booking_id; ?> complete</h1>
2828

29-
29+
<p><a href="step0.php">Start a new booking</a></p>
3030
<?php
3131
include_once("inc/debug.php");
3232
include_once("inc/bottom.php");

0 commit comments

Comments
 (0)