-
Notifications
You must be signed in to change notification settings - Fork 0
/
BookRepCRM.php
144 lines (110 loc) · 5.16 KB
/
BookRepCRM.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
137
138
139
140
141
142
143
144
<?php
// Read data from customers.txt into an array
$customerData = file("customers.txt", FILE_IGNORE_NEW_LINES);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>Book Template</title>
<link rel="shortcut icon" href="../../assets/ico/favicon.png">
<!-- Google fonts used in this theme -->
<link href='http://fonts.googleapis.com/css?family=Roboto+Slab:400,700' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic,700italic' rel='stylesheet' type='text/css'>
<!-- Bootstrap core CSS -->
<link href="dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Bootstrap theme CSS -->
<link href="theme.css" rel="stylesheet">
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="assets/js/html5shiv.js"></script>
<script src="assets/js/respond.min.js"></script>
<![endif]-->
</head>
<body>
<?php include 'book-header.inc.php'; ?>
<div class="container">
<div class="row"> <!-- start main content row -->
<div class="col-md-2"> <!-- start left navigation rail column -->
<?php include 'book-left-nav.inc.php'; ?>
</div> <!-- end left navigation rail -->
<div class="col-md-10"> <!-- start main content column -->
<!-- Customer panel -->
<div class="panel panel-danger spaceabove">
<div class="panel-heading"><h4>My Customers</h4></div>
<table class="table">
<tr>
<th>Name</th>
<th>Email</th>
<th>University</th>
<th>City</th>
</tr>
<?php
foreach ($customerData as $customer) {
$customerInfo = explode(",", $customer);
$customerId = $customerInfo[0];
$name = $customerInfo[1] . ' ' . $customerInfo[2]; // Combine first and last names
$email = $customerInfo[3];
$university = $customerInfo[4];
$city = $customerInfo[6];
// Display only specified information with customer name as a link
echo "<tr><td><a href='BookRepCRM.php?customerId=$customerId'>$name</a></td><td>$email</td><td>$university</td><td>$city</td></tr>";
}
?>
</table>
</div>
<?php
if (isset($_GET['customerId'])) {
// Read data from orders.txt into an array
$orderData = file("orders.txt", FILE_IGNORE_NEW_LINES);
$customerId = $_GET['customerId'];
// Filter orders for the specific customer
$customerOrders = array_filter($orderData, function ($order) use ($customerId) {
$orderInfo = explode(",", $order);
return $orderInfo[1] == $customerId;
});
$customerName = '';
foreach ($customerData as $customer) {
$customerInfo = explode(",", $customer);
if ($customerInfo[0] == $customerId) {
$customerName = $customerInfo[1] . ' ' . $customerInfo[2];
break;
}
}
echo "<div class='panel panel-danger spaceabove'>";
echo "<div class='panel-heading'><h4>Orders for $customerName</h4></div>";
if (!empty($customerOrders)) {
// Display order information in a table
echo "<table class='table'>";
echo "<tr><th>Book ISBN</th><th>Book Title</th><th>Book Category</th></tr>";
foreach ($customerOrders as $order) {
$orderInfo = explode(",", $order);
$bookISBN = $orderInfo[2];
$bookTitle = $orderInfo[3];
$bookCategory = $orderInfo[4];
// Display only specified information
echo "<tr><td>$bookISBN</td><td>$bookTitle</td><td>$bookCategory</td></tr>";
}
echo "</table>";
} else {
// Display a message when there is no order information
echo "<p>No orders for this customer.</p>";
}
}
?>
</div>
</div> <!-- end main content column -->
</div> <!-- end main content row -->
</div> <!-- end container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="assets/js/jquery.js"></script>
<script src="dist/js/bootstrap.min.js"></script>
<script src="assets/js/holder.js"></script>
</body>
</html>