-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreports.php
More file actions
87 lines (82 loc) · 3.04 KB
/
reports.php
File metadata and controls
87 lines (82 loc) · 3.04 KB
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
<?php
include('header.php');
checkUser();
userArea();
$cat_id='';
$sub_sql='';
$from='';
$to='';
if(isset($_GET['category_id']) && $_GET['category_id']>0){
$cat_id=get_safe_value($_GET['category_id']);
$sub_sql=" and category.id=$cat_id ";
}
if(isset($_GET['from'])){
$from=get_safe_value($_GET['from']);
}
if(isset($_GET['to'])){
$to=get_safe_value($_GET['to']);
}
if($from!=='' && $to!=''){
$sub_sql.=" and expense.expense_date between '$from' and '$to' ";
}
$res=mysqli_query($con,"select sum(expense.price) as price,category.name from expense,category where expense.category_id=category.id and expense.added_by='".$_SESSION['UID']."' $sub_sql group by expense.category_id");
?>
<script>
setTitle("Reports");
selectLink('reports_link');
</script>
<div class="main-content">
<div class="section__content section__content--p30">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<div class="filter_form">
<form type="get">
From <input type="date" name="from" value="<?php echo $from?>" max="<?php echo date('Y-m-d')?>" onchange="set_to_date()" id="from_date" class="form-control w250">
To <input type="date" name="to" value="<?php echo $to?>" max="<?php echo date('Y-m-d')?>" id="to_date" class="form-control w250">
<?php echo getCategory($cat_id,'reports');?>
<input type="submit" name="submit" value="Submit" class="btn btn-lg btn-info btn-block">
<a href="reports.php">Reset</a>
</form>
</div>
<?php
if(mysqli_num_rows($res)>0){
?>
<br/><br/>
<div class="table-responsive table--no-card m-b-30">
<table class="table table-borderless table-striped table-earning">
<tr>
<th>Category</th>
<th>Price</th>
</tr>
<tbody>
<?php
$final_price=0;
while($row=mysqli_fetch_assoc($res)){
$final_price=$final_price+$row['price'];
?>
<tr>
<td><?php echo $row['name']?></td>
<td><?php echo $row['price']?></td>
</tr>
<?php } ?>
<tr>
<th>Total</th>
<th><?php echo $final_price?></th>
</tr>
</tbody>
</table>
</div>
<?php } else {
echo "<b>No data found</b>";
}
?>
</div>
</div>
</div>
</div>
</div>
<?php
include('footer.php');
?>