/
report.php
246 lines (220 loc) · 10.9 KB
/
report.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<?php
session_start();
require 'helpers/adminManager.php';
require 'PropertiesDatabase.php';
require 'UsersDatabase.php';
$error;
if ( isset($_SESSION['username']) && isAdmin($_SESSION['username']) ) {
$propertiesDatabase = new PropertiesDatabase('data/properties.json');
$usersDatabase = new UsersDatabase('data/users.json');
$allProperties = $propertiesDatabase->dataArray();
$soldProperties = $propertiesDatabase->soldProperties();
$unsoldProperties = $propertiesDatabase->unsoldProperties();
} else {
// unauthorised accces
$error = "You are not authorized to access this content, please login with an admin account.";
}
?>
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Sales Report</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<!-- Add your site or application content here -->
<div class="container report_container">
<?php if( empty($error) ): ?>
<div role="tabpanel">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active">
<a href="#all_properties" aria-controls="home" role="tab" data-toggle="tab">All Properties</a>
</li>
<li role="presentation">
<a href="#sold_properties" aria-controls="tab" role="tab" data-toggle="tab">Sold Properties</a>
</li>
<li role="presentation">
<a href="#unsold_properties" aria-controls="tab" role="tab" data-toggle="tab">Unsold Properties</a>
</li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div class="report__propertyRow__header">
<div class="row">
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
PROPERTY
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
OWNER
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
BUYER
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
PRICE
</div>
</div>
</div>
<?php
$totalPriceAllProperties = 0;
$totalPriceSoldProperties= 0;
$totalPriceUnsoldProperties = 0;
?>
<!-- All properties -->
<div role="tabpanel" class="tab-pane active" id="all_properties">
<?php foreach( $allProperties as $property ): ?>
<div class="report__propertyRow">
<div class="row">
<!-- Property Name -->
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 report__propertyRow__name">
<?php echo $property['name']; ?>
</div>
<!-- Property Owner -->
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?php echo $usersDatabase->userFullName($property['owner']); ?>
</div>
<!-- Propertry Buyer if exists -->
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?php echo $usersDatabase->userFullName($property['buyer']); ?>
</div>
<!-- Property price -->
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 report__propertyRow__price">
₹<?php
$currentPropertyPrice = $property['price'];
$totalPriceAllProperties += $currentPropertyPrice;
echo $currentPropertyPrice;
?>
</div>
</div>
</div>
<?php endforeach; ?>
<div class="report__propertyRow--total">
<div class="row">
<div class="col-xs-9 col-sm-9 col-md-9 col-lg-9 report__propertyRow--total__name">
TOTAL
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 report__propertyRow__price">
₹<?php
echo $totalPriceAllProperties;
?>
</div>
</div>
</div>
</div>
<!-- Sold Properties -->
<div role="tabpanel" class="tab-pane" id="sold_properties">
<?php foreach( $soldProperties as $property ): ?>
<div class="report__propertyRow">
<div class="row">
<!-- Property Name -->
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 report__propertyRow__name">
<?php echo $property['name']; ?>
</div>
<!-- Property Owner -->
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?php echo $usersDatabase->userFullName($property['owner']); ?>
</div>
<!-- Propertry Buyer if exists -->
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?php echo $usersDatabase->userFullName($property['buyer']); ?>
</div>
<!-- Property price -->
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 report__propertyRow__price">
₹<?php
$currentPropertyPrice = $property['price'];
$totalPriceSoldProperties += $currentPropertyPrice;
echo $currentPropertyPrice;
?>
</div>
</div>
</div>
<?php endforeach; ?>
<div class="report__propertyRow--total">
<div class="row">
<div class="col-xs-9 col-sm-9 col-md-9 col-lg-9 report__propertyRow--total__name">
TOTAL
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 report__propertyRow__price">
₹<?php
echo $totalPriceSoldProperties;
?>
</div>
</div>
</div>
</div>
<!-- Unsold Properties -->
<div role="tabpanel" class="tab-pane" id="unsold_properties">
<?php foreach( $unsoldProperties as $property ): ?>
<div class="report__propertyRow">
<div class="row">
<!-- Property Name -->
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 report__propertyRow__name">
<?php echo $property['name']; ?>
</div>
<!-- Property Owner -->
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?php echo $usersDatabase->userFullName($property['owner']); ?>
</div>
<!-- Propertry Buyer if exists -->
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<?php echo $usersDatabase->userFullName($property['buyer']); ?>
</div>
<!-- Property price -->
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 report__propertyRow__price">
₹<?php
$currentPropertyPrice = $property['price'];
$totalPriceUnsoldProperties += $currentPropertyPrice;
echo $currentPropertyPrice;
?>
</div>
</div>
</div>
<?php endforeach; ?>
<div class="report__propertyRow--total">
<div class="row">
<div class="col-xs-9 col-sm-9 col-md-9 col-lg-9 report__propertyRow--total__name">
TOTAL
</div>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3 report__propertyRow__price">
₹<?php
echo $totalPriceUnsoldProperties;
?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php else: ?>
<br>
<br>
<div class="panel panel-danger">
<div class="panel-heading">
<h3 class="panel-title">Unauthorized access!</h3>
</div>
<div class="panel-body">
<?php echo $error; ?>
</div>
</div>
<?php endif; ?>
</div>
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
<script src = "js/jquery.min.js"></script>
<script src = "js/bootstrap.min.js"></script>
<script src = "js/main.js"></script>
</body>
</html>