/
orders.php
executable file
·66 lines (58 loc) · 1.46 KB
/
orders.php
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
<?php
// Create OAuth2Client object
require_once('./OAuth2Client/OAuth2Exception.php');
require_once('./OAuth2Client/OAuth2Client.php');
require_once('./OAuth2Client/FL_OAuth2Client.php');
$client = new FL_OAuth2Client();
// Get access token from the session
session_start();
$accessToken = $_SESSION['access_token'];
// Get attendees
$orders = NULL;
if (isset($_SESSION['access_token']))
{
if (isset($_REQUEST['eventid']))
{
// Get attendees from the Floktu API
curl_setopt_array($cha = curl_init(), array (
CURLOPT_URL => FLOKTU_API_BASE_URI . "events/" . $_REQUEST['eventid'] . "/orders",
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_HTTPHEADER => array('Authorization: Bearer ' . $accessToken),
CURLOPT_SSL_VERIFYPEER => 0
)
);
$result = curl_exec($cha);
curl_close($cha);
$orders = json_decode($result);
}
}
// Render the page
include('./includes/htmltop.php');
if (isset($_SESSION['access_token']))
{
if ($orders)
{
?>
<h2>Order List</h2>
<?php
foreach($orders as $order)
{
echo '<strong>' . $order->{'id'} . ' - ' . $order->{'first_name'} . ' ' . $order->{'last_name'} . '</strong>' . ' - ';
echo '<a href="./order.php?eventid=' . $_REQUEST['eventid'] . '&orderid=' . $order->{'id'} . '">View order details.</a><br>';
}
}
else
{
?>
<p>Could not load orders for this event.</p>
<?php
}
}
else
{
?>
<p>You need to connect to your Floktu account before you can view attendees.</p>
<?php
}
include('./includes/htmlbottom.php');
?>