-
Notifications
You must be signed in to change notification settings - Fork 1
/
daily_sales.php
136 lines (125 loc) · 4.88 KB
/
daily_sales.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
<?php
$page_title = 'Ventas diarias';
require_once('include/load.php');
// Checkin What level user has permission to view this page
page_require_level(3);
?>
<?php
/* take the current date */
$year = date('Y');
$month = date('m');
$day = date('d');
if (isset($_POST['btn_build_report'])) {
if (isset($_POST['date'])) {
$date = $_POST['date'];
if ($date = strptime($date,'%Y-%m-%d')) {
/* valid date */
if (isset($date['tm_year']) && isset($date['tm_mon']) && isset($date['tm_mday'])) {
$year = sprintf('%04d', $date['tm_year'] + 1900);
$month = sprintf('%02d', $date['tm_mon'] + 1);
$day = sprintf('%02d', $date['tm_mday']);
}
}
}
else {
/* continue normally */
}
}
if (($sales = dailySales($year, $month, $day)) == NULL) {
/*$session->msg("w", sprintf("No se encontraron ventas para {$day}/{$month}/{$year}"));*/
}
?>
<?php include_once('layouts/header.php'); ?>
<div class="row">
<div class="col-md-6">
<?php echo display_msg($session->msg()); ?>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading clearfix">
<strong>
<i class="glyphicon glyphicon-tasks"></i>
<span>Reporte de salidas del día <?php echo $year.'-'.$month.'-'.$day;?> </span>
</strong>
</div>
<div class="panel-body">
<form method="post" action="daily_sales.php" class="clearfix">
<div class="form-group d-block" style="">
<div class="form-row border-0">
<div class="col border-0 d-inline-block" style="">
<label for="date" class="control-label">Fecha</label>
<input type="text" class="form-control rounded" name="date" id="date" data-date data-date-format="yyyy-mm-dd" placeholder="aaaa-mm-dd" value="<?php
if ($year > 0 && $month > 0 && $day > 0) echo $year.'-'.$month.'-'.$day; else echo ''; ?>">
</div>
<div class="col border-0 d-inline-block" style="margin-left: 2em;">
<button type="submit" name="btn_build_report" id="btn_build_report" class="btn btn-primary rounded">Generar</button>
</div>
</div>
</div>
</form>
<table class="table table-striped" id="tbl-sales">
<thead>
<tr>
<th class="text-center" style="width: 50px;"></th>
<th style="width: 10%;"> Part No. </th>
<th> Nombre del producto </th>
<th> Cliente/destino </th>
<th> Fecha </th>
<th class="text-center" style="width: 10%;"> Cantidad </th>
<th class="text-right" style="width: 10%;"> Total Venta </th>
<th class="text-right" style="width: 10%;"> Profit </th>
</tr>
</thead>
<tbody>
<?php
$total_qty = 0;
$total_sale = 0;
$total_profit = 0;
?>
<?php foreach ($sales as $sale):?>
<tr>
<td class="text-center"><?php echo count_id(); ?></td>
<td><?php echo remove_junk($sale['partNo']); ?></td>
<td><?php echo remove_junk($sale['name']); ?></td>
<td><?php echo remove_junk($sale['destination']); ?></td>
<td><?php echo remove_junk($sale['date']); ?></td>
<td class="text-center"><?php echo (int)$sale['total_qty']; ?></td>
<td class="text-right"><?php echo number_format( $sale['total_sale'], 2 ); ?></td>
<td class="text-right"><?php echo number_format( $sale['total_profit'], 2 ); ?></td>
</tr>
<?php
$total_qty += (int)$sale['total_qty'];
$total_sale += $sale['total_sale'];
$total_profit += $sale['total_profit'];
?>
<?php endforeach;?>
<tr>
<td class="text-center"><?php echo count_id(); ?></td>
<td><strong>Total</strong></td>
<td></td>
<td></td>
<td></td>
<td class="text-center"><strong><?php echo (int)$total_qty; ?></strong></td>
<td class="text-right"><strong><?php echo number_format($total_sale, 2); ?></strong></td>
<td class="text-right"><strong><?php echo number_format($total_profit, 2); ?></strong></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- This is the jQuery background for this page -->
<script type="text/javascript" src="lib/js/daily_sales.js"></script>
<!-- DataTable (only for more than 10 items)-->
<?php if (count_id() > 10): ?>
<script type="text/javascript">
$(document).ready(function() {
$('#tbl-sales').DataTable({
})
})
</script>
<?php endif; ?>
<?php include_once('layouts/footer.php'); ?>