-
Notifications
You must be signed in to change notification settings - Fork 140
/
Copy pathdashboard.php
176 lines (136 loc) · 4.56 KB
/
dashboard.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
<?php require_once 'includes/header.php'; ?>
<?php
$sql = "SELECT * FROM product WHERE status = 1";
$query = $connect->query($sql);
$countProduct = $query->num_rows;
$orderSql = "SELECT * FROM orders WHERE order_status = 1";
$orderQuery = $connect->query($orderSql);
$countOrder = $orderQuery->num_rows;
$totalRevenue = "";
while ($orderResult = $orderQuery->fetch_assoc()) {
$totalRevenue += $orderResult['paid'];
}
$lowStockSql = "SELECT * FROM product WHERE quantity <= 3 AND status = 1";
$lowStockQuery = $connect->query($lowStockSql);
$countLowStock = $lowStockQuery->num_rows;
$userwisesql = "SELECT users.username , SUM(orders.grand_total) as totalorder FROM orders INNER JOIN users ON orders.user_id = users.user_id WHERE orders.order_status = 1 GROUP BY orders.user_id";
$userwiseQuery = $connect->query($userwisesql);
$userwieseOrder = $userwiseQuery->num_rows;
$connect->close();
?>
<style type="text/css">
.ui-datepicker-calendar {
display: none;
}
</style>
<!-- fullCalendar 2.2.5-->
<link rel="stylesheet" href="assests/plugins/fullcalendar/fullcalendar.min.css">
<link rel="stylesheet" href="assests/plugins/fullcalendar/fullcalendar.print.css" media="print">
<div class="row">
<?php if(isset($_SESSION['userId']) && $_SESSION['userId']==1) { ?>
<div class="col-md-4">
<div class="panel panel-success">
<div class="panel-heading">
<a href="product.php" style="text-decoration:none;color:black;">
Total Product
<span class="badge pull pull-right"><?php echo $countProduct; ?></span>
</a>
</div> <!--/panel-hdeaing-->
</div> <!--/panel-->
</div> <!--/col-md-4-->
<div class="col-md-4">
<div class="panel panel-danger">
<div class="panel-heading">
<a href="product.php" style="text-decoration:none;color:black;">
Low Stock
<span class="badge pull pull-right"><?php echo $countLowStock; ?></span>
</a>
</div> <!--/panel-hdeaing-->
</div> <!--/panel-->
</div> <!--/col-md-4-->
<?php } ?>
<div class="col-md-4">
<div class="panel panel-info">
<div class="panel-heading">
<a href="orders.php?o=manord" style="text-decoration:none;color:black;">
Total Orders
<span class="badge pull pull-right"><?php echo $countOrder; ?></span>
</a>
</div> <!--/panel-hdeaing-->
</div> <!--/panel-->
</div> <!--/col-md-4-->
<div class="col-md-4">
<div class="card">
<div class="cardHeader">
<h1><?php echo date('d'); ?></h1>
</div>
<div class="cardContainer">
<p><?php echo date('l') .' '.date('d').', '.date('Y'); ?></p>
</div>
</div>
<br/>
<div class="card">
<div class="cardHeader" style="background-color:#245580;">
<h1><?php if($totalRevenue) {
echo $totalRevenue;
} else {
echo '0';
} ?></h1>
</div>
<div class="cardContainer">
<p> INR Total Revenue</p>
</div>
</div>
</div>
<?php if(isset($_SESSION['userId']) && $_SESSION['userId']==1) { ?>
<div class="col-md-8">
<div class="panel panel-default">
<div class="panel-heading"> <i class="glyphicon glyphicon-calendar"></i> User Wise Order</div>
<div class="panel-body">
<table class="table" id="productTable">
<thead>
<tr>
<th style="width:40%;">Name</th>
<th style="width:20%;">Orders in Rupees</th>
</tr>
</thead>
<tbody>
<?php while ($orderResult = $userwiseQuery->fetch_assoc()) { ?>
<tr>
<td><?php echo $orderResult['username']?></td>
<td><?php echo $orderResult['totalorder']?></td>
</tr>
<?php } ?>
</tbody>
</table>
<!--<div id="calendar"></div>-->
</div>
</div>
</div>
<?php } ?>
</div> <!--/row-->
<!-- fullCalendar 2.2.5 -->
<script src="assests/plugins/moment/moment.min.js"></script>
<script src="assests/plugins/fullcalendar/fullcalendar.min.js"></script>
<script type="text/javascript">
$(function () {
// top bar active
$('#navDashboard').addClass('active');
//Date for the calendar events (dummy data)
var date = new Date();
var d = date.getDate(),
m = date.getMonth(),
y = date.getFullYear();
$('#calendar').fullCalendar({
header: {
left: '',
center: 'title'
},
buttonText: {
today: 'today',
month: 'month'
}
});
});
</script>
<?php require_once 'includes/footer.php'; ?>