-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyearbysearch.php
267 lines (230 loc) · 10.3 KB
/
yearbysearch.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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<?php
session_start();
if(isset($_SESSION['User'])){
?>
<?php
require_once('connection.php');
// $conn = new mysqli("localhost", "aurexaac_buja", "bu!ja4#20,38?kd", "aurexaac_anan") or die("cannot connect database");
$date = $_POST['search'];
$strdate = strval($date);
// echo $strdate;
$sql = "SELECT *,COUNT(*), SUM(`total`) AS asb FROM invoice WHERE year = '$strdate' GROUP BY `uid`";
$result = mysqli_query($conn, $sql) or die("cannot execute query");
// echo $result;
$sql2 = "SELECT SUM(`total`) AS sum FROM `invoice` WHERE `year`='$strdate';";
$result2 = mysqli_query($conn, $sql2) or die("cannot execute query2");
$totaltk = 0;
while($row2 = mysqli_fetch_assoc($result2)){
$totaltk += $row2['sum'];
}
$btnid = "";
// echo $totaltk;
$sqldc = "SELECT SUM(`discount`) AS discsum FROM orders WHERE `year` = '$strdate';";
$resultdc = mysqli_query($conn, $sqldc) or die(" cannot collect sum of discount");
$sumdc = 0;
while($rowdc = mysqli_fetch_assoc($resultdc)){
$sumdc += $rowdc['discsum'];
}
$afterdc = $totaltk - $sumdc;
$sqlprofit = "SELECT SUM(`total_profit`) AS prosum FROM invoice WHERE `year` = '$strdate';";
$resultprofit = mysqli_query($conn, $sqlprofit) or die("cannot collect profit");
$profitdate = 0;
while($rowpro = mysqli_fetch_assoc($resultprofit)){
$profitdate += $rowpro['prosum'];
}
$afterprofit = $profitdate - $sumdc;
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Summary</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="js/getdate.js"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" dashboard.php>Noor Wares Market</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mx-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link" href="dashboard.php">Dashboard</a>
</li>
<li class="nav-item">
<a class="nav-link" href="product.php">Product</a>
</li>
<li class="nav-item">
<a class="nav-link" href="displayajex.php">Company</a>
</li>
<li class="nav-item">
<a class="nav-link" href="billing2.php">Billing</a>
</li>
<li class="nav-item">
<a class="nav-link" onclick="movetodatebysearch()">Total Bill</a>
</li>
</ul>
</div>
<button onclick="window.print()" class= "btn btn-primary">Print</button>
<a class="btn btn-danger" href="logout.php?logout">Log-Out</a>
</div>
</nav>
<section class="list_bill container-fluid mt-5">
<div class="container ">
<div class="row">
<div class="col">
<level class="fw-bold mb-3">Search By Date</level>
<form method="post" action="datebysearch2.php" class="row g-3 mb-5">
<input type="date" class="w-50 form-control" name="search">
<button type="submit" class="ms-1 w-25 btn btn-outline-primary"> Search</button>
</form>
</div>
<div class="col">
<level class="fw-bold mb-3">Search By Month</level>
<form method="post" action="monthbysearch.php" class="row g-3 mb-5">
<select class="form-select w-50 form-control " name="search">
<option>January</option>
<option>February</option>
<option>March</option>
<option>April</option>
<option>May</option>
<option>June</option>
<option>July</option>
<option>August</option>
<option>September</option>
<option>October</option>
<option>November</option>
<option>December</option>
</select>
<button type="submit" class="ms-1 w-25 btn btn-outline-primary"> Search</button>
</form>
</div>
<div class="col">
<level class="fw-bold mb-3">Search By Year</level>
<form method="post" action="yearbysearch.php" class="row g-3 mb-5">
<input type="text" class="w-50 form-control" name="search">
<button type="submit" class="ms-1 w-25 btn btn-outline-primary"> Search</button>
</form>
</div>
<div class="col">
<level class="fw-bold mb-3">Search By OrderID</level>
<form method="post" action="orderidsearch.php" class="row g-3 mb-5">
<input type="text" class="w-50 form-control" name="search">
<button type="submit" class="ms-1 w-25 btn btn-outline-primary"> Search</button>
</form>
</div>
</div>
</div>
<div class="table-responsive">
<table class="table">
<thead class="table-dark">
<tr>
<th scope="col">Seq</th>
<th scope="col">Date</th>
<th scope="col">Order ID</th>
<th scope="col">Order Number</th>
<th scope="col">Customer Name</th>
<th scope="col">Customer Phone</th>
<th scope="col">Product Name</th>
<th scope="col">Quantity</th>
<th scope="col">Price</th>
</tr>
</thead>
<tbody>
<?php
$i=1;
while ($row = mysqli_fetch_assoc($result)){
?>
<tr>
<td> <?php echo $i ?> </td>
<td><?php echo $row['date']; ?></td>
<td><?php echo $row['uid']; ?></td>
<td><?php echo $row['id']; ?></td>
<td><?php echo $row['cust_name']; ?></td>
<td><?php echo $row['phn']; ?></td>
<td><?php echo $row['pro_name']; ?></td>
<td><?php echo $row['qty']; ?></td>
<td><?php echo $row['asb']; ?></td>
<td>
<a href="sortlist.php?id=<?php echo $row['uid'];?>&dt=<?php echo $row['date'];?>" >
<button type="button" class="btn btn-primary">
View
</button>
</a>
</td>
<?php
$i++;
} ?>
</tr>
<tr class="bg-light">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td colspan="2" align="center" class="fw-bolder text-danger">Total Amount</td>
<td class="fw-bolder text-danger"><?php echo $totaltk; ?></td>
</tr>
<tr class="bg-light">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td colspan="2" align="center" class="fw-bolder text-danger">Total Discount</td>
<td class="fw-bolder text-danger"><?php echo $sumdc; ?></td>
</tr>
<tr class="bg-light">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td colspan="2" align="center" class="fw-bolder text-danger">Total TK After Discount</td>
<td class="fw-bolder text-danger"><?php echo $afterdc; ?></td>
</tr>
<tr class="bg-light">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td colspan="2" align="center" class="fw-bolder text-success">Total Profit</td>
<td class="fw-bolder text-danger"><?php echo $profitdate; ?></td>
</tr>
<tr class="bg-light">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td colspan="2" align="center" class="fw-bolder text-success">Total Profit After Discount</td>
<td class="fw-bolder text-danger"><?php echo $afterprofit; ?></td>
</tr>
</tbody>
</table>
</div>
</section>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
<?php
}
else{
header("location:index.php");
}
?>