-
Notifications
You must be signed in to change notification settings - Fork 0
/
order-template.php
127 lines (120 loc) · 5.16 KB
/
order-template.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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
require './class/customer-link.class.php';
require './product-template.php';
function echo_single_order($order)
{
$id = $order['id'];
$customer_id = $order['customer_id'];
$date = $order['date'];
$state = $order['state'];
$total_price = $order['total_price'];
$customer_link = new customer_link();
$customer = $customer_link->get_customer_from_id($customer_id);
if (isset($_SESSION['customer'])) {
$state_field = $state;
} else if (isset($_SESSION['admin'])) {
$options = ['Nouvelle', 'Annulée', 'En cours', 'Terminée'];
$options_string = "";
foreach ($options as $option) {
if ($option == $state) {
$options_string .= '<option selected>' . $option . '</option>';
} else {
$options_string .= '<option>' . $option . '</option>';
}
}
$state_field = '<select class="p-1 stateSelector" id="' . $id . '-stateSelector" value="' . $state . '">
' . $options_string . '
</select>
<p id="' . $id . '-stateChangedDisplay"></p>';
} else {
$state_field = '';
}
echo
'<div id="' . $id . '-container" class="row">
<div class="col-lg-12 mx-auto">
<div class="wrapper-product mb-4">
<h3 role="presentation"><a href="order.php?id=' . $id . '">Numéro de Commande #' . $id . '</a></h3>
<div class="card p-4">
<div class="row">
<div class="col-3">
' . $customer['last_name'] . ' ' . $customer['first_name'] . '</br>' . $customer['email'] . '
</div>
<div class="col-3">
Date de la commande : ' . $order['date'] . '
</div>
<div class="col-3">
État de la commande : ' . $state_field . '
</div>
<div class="col-3">
<p id="' . $id . '-priceDisplay" style="text-align: right">Prix total : ' . $total_price . '€</p>
</div>
</div>
</div>
</div>
</div>
</div>';
}
function echo_full_order($order)
{
$id = $order['id'];
$customer_id = $order['customer_id'];
$date = $order['date'];
$state = $order['state'];
$total_price = $order['total_price'];
$customer_link = new customer_link();
$customer = $customer_link->get_customer_from_id($customer_id);
$state_field = '';
if (isset($_SESSION['customer'])) {
$state_field = $state;
} else if (isset($_SESSION['admin'])) {
$options = ['Nouvelle', 'Annulée', 'En cours', 'Terminée'];
$options_string = "";
foreach ($options as $option) {
if ($option == $state) {
$options_string .= '<option selected>' . $option . '</option>';
} else {
$options_string .= '<option>' . $option . '</option>';
}
}
$state_field = '<select class="p-1 stateSelector" id="' . $id . '-stateSelector" value="' . $state . '">
' . $options_string . '
</select>
<p id="' . $id . '-stateChangedDisplay"></p>';
}
$lines_field = '';
foreach ($order['lines'] as $line) {
$lines_field .= get_product_in_order($line);
}
echo
'<div id="' . $id . '-container" class="row mt-5">
<div class="col-lg-12 mx-auto">
<div class="wrapper-product text-dark">
<h3 role="presentation"><a href="order.php?id=' . $id . '">Numéro de commande #' . $id . '</a></h3>
<div class="wrapper-order card">
<div class="card p-4">
<div class="row">
<div class="col-3">
' . $customer['last_name'] . ' ' . $customer['first_name'] . '</br>' . $customer['email'] . '
</div>
<div class="col-3">
Date de la commande : ' . $order['date'] . '
</div>
<div class="col-3">
État de la commande : ' . $state_field . '
</div>
<div class="col-3">
<p id="' . $id . '-priceDisplay" style="text-align: right">Prix total : ' . $total_price . '€</p>
</div>
</div>
</div>
<div class="wrapper-product-list row">
' . $lines_field . '
</div>
</div>
</div>
</div>
</div>';
}