-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorders-preview.php
136 lines (102 loc) · 3.78 KB
/
orders-preview.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
128
129
130
131
132
133
134
135
136
<?php
/*
NEW.PHP
Add data to 'orders' table
*/
// header
include('header.php');
// connect to the database
function ordersForm($orderNumber, $orderDate, $requiredDate, $shippedDate, $status, $comments, $customerNumber, $error)
{
// if there are any errors, display them
if ($error != '')
{
echo '<div class="alert alert-danger"> '.$error.'</div>';
}
?>
<div id="orders" class="section form-md-1">
<div class="fixed-wrapper"><h1>Orders Preview</h1></div>
<div class="container">
<div class="content">
<div class="pricing">
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="wrapper block">
<table class="table">
<thead>
<tr><th colspan="3"><span class="price"><b>Order No.:</b><?php echo $orderNumber; ?></span></th></tr>
</thead>
<tbody>
<tr><td colspan="3">
<div class="bs-callout bs-callout-info">
<h3><b><?php echo 'The order on '.$orderDate.' is schedule to arrive on '.$shippedDate.''; ?></b></h3>
<h3>Contact:
<?php
//$result = mysql_query("SELECT employeeNumber FROM 'classicmodels'.'employees' WHERE 'employeeNumber' !=0 ORDER BY employeeNumber DESC");
$result = mysql_query("SELECT o.customerNumber, e.employeeNumber, e.lastName, e.firstName FROM orders o, employees e WHERE customerNumber='$customerNumber' LIMIT 1")
or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
echo ' <a href="emp-preview.php?employeeNumber=' . $row['employeeNumber'] . '" >' . $row['lastName'] . ' ' . $row['firstName'] . ' - ' . $row['customerNumber'] . '</a> ';
}
?></h3> </div></td></tr>
<tr><td><h3>OrderDate:</h3><?php echo $orderDate; ?></td><td><h3>RequiredDate:</h3><?php echo $requiredDate; ?></td><td><h3>ShippedDate:</h3><?php echo $shippedDate; ?></td></tr>
<tr><td colspan="3"><?php echo $comments; ?></td></tr>
</tbody>
</table>
<span class="price"><?php echo $status; ?></span>
</div>
</div>
</div>
</div>
</div>
</div>
</div><!-- /.container -->
<?php
}
include('linkupdb.php');
// get the 'id' value from the URL (if it exists), making sure that it is valid (checing that it is numeric/larger than 0)
if (isset($_GET['orderNumber']) && is_numeric($_GET['orderNumber']) && $_GET['orderNumber'] > 0 || isset($_GET['customerNumber']) || $_GET['customerNumber'] > 0)
{
// query db
$orderNumber = $_GET['orderNumber'];
$result = mysql_query("SELECT * FROM orders WHERE orderNumber='$orderNumber' OR customerNumber='$orderNumber'")
or die(mysql_error());
$row = mysql_fetch_array($result);
// check that the 'id' matches up with a row in the database
if($row)
{
// get data from db
$orderNumber = $row['orderNumber'];
$orderDate = $row['orderDate'];
$requiredDate = $row['requiredDate'];
$shippedDate = $row['shippedDate'];
$status = $row['status'];
$comments = $row['comments'];
$customerNumber = $row['customerNumber'];
// show form
ordersForm($orderNumber, $orderDate, $requiredDate, $shippedDate, $status, $comments, $customerNumber, $error);
}
else
// if no match, display result
{
?>
<div class="jumbotron">
<h1>No Information!</h1>
<p> <?php echo '<div class="alert alert-danger">Unable to find your order within the database </div>';?> </p>
</div>
<?php
}
}
else
// if the 'id' in the URL isn't valid, or if there is no 'id' value, display an error
{
?>
<div class="jumbotron">
<h1>No Information!</h1>
<p> <?php echo '<div class="alert alert-danger">Unable to find your order within the database </div>';?> </p>
</div>
<?php
}
// footer
include('footer.php');
?>