-
Notifications
You must be signed in to change notification settings - Fork 0
/
sale_report_process.php
156 lines (141 loc) · 4.21 KB
/
sale_report_process.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
<?php
$page_title = 'Reporte de ventas';
$results = '';
require_once('includes/load.php');
// Verificar que nivel de usuario tiene permiso de ver esta página.
page_require_level(3);
if(isset($_POST['submit'])){
$req_dates = array('start-date','end-date');
validate_fields($req_dates);
if(empty($errors)):
$start_date = remove_junk($db->escape($_POST['start-date']));
$end_date = remove_junk($db->escape($_POST['end-date']));
$results = find_sale_by_dates($start_date,$end_date);
else:
$session->msg("d", $errors);
redirect('sales_report.php', false);
endif;
}else{
$session->msg("d", "Selecciona el rango de fechas.");
redirect('sales_report.php', false);
}
?>
<!doctype html>
<html lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Reporte de ventas</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<link rel="icon" href="libs/img/P&G-logo.png">
<style>
@media print {
html,body{
font-size: 9.5pt;
margin: 0;
padding: 0;
}
.page-break{
page-break-before:always;
width: auto;
margin: auto;
}
}
.page-break{
width: 980px;
margin: 0 auto;
}
.sale-head{
margin: 40px 0;
text-align: center;
}
.sale-head h1,.sale-head strong{
padding: 10px 20px;
display: block;
}
.sale-head h1{
margin: 0;
border-bottom: 1px solid #212121;
}
.table>thead:first-child>tr:first-child>th{
border-top: 1px solid #000;
}
table thead tr th {
text-align: center;
border: 1px solid #ededed;
}
table tbody tr td{
vertical-align: middle;
}
.sale-head,table.table thead tr th,table tbody tr td,table tfoot tr td{
border: 1px solid #212121;
white-space: nowrap;
}
.sale-head h1,table thead tr th,table tfoot tr td{
background-color: #f8f8f8;
}
tfoot{
color:#000;
text-transform: uppercase;
font-weight: 500;
}
</style>
</head>
<body>
<?php if($results): ?>
<div class="page-break">
<div class="pull-left">
<img src="libs/img/P&G.png" alt="" width=30% style="margin: 50px 0 0 0;">
</div>
<div class="sale-head pull-right">
<h1>Reporte de ventas</h1>
<strong><?php if(isset($start_date)){ echo $start_date;}?> a <?php if(isset($end_date)){echo $end_date;}?> </strong>
</div>
<table class="table table-border">
<thead>
<tr>
<th>Fecha</th>
<th>Descripción</th>
<th>Precio de compra</th>
<th>Precio de venta</th>
<th>Cantidad total</th>
<th>TOTAL</th>
</tr>
</thead>
<tbody>
<?php foreach($results as $result): ?>
<tr>
<td class="text-center"><?php echo remove_junk($result['date']);?></td>
<td class="desc">
<h6><?php echo remove_junk(ucfirst($result['name']));?></h6>
</td>
<td class="text-right"><?php echo remove_junk($result['buy_price']);?></td>
<td class="text-right"><?php echo remove_junk($result['sale_price']);?></td>
<td class="text-right"><?php echo remove_junk($result['total_sales']);?></td>
<td class="text-right"><?php echo remove_junk($result['total_saleing_price']);?></td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
<tr class="text-right">
<td colspan="5"> Total </td>
<td> $
<?php echo number_format(@total_price($results)[0], 2);?>
</td>
</tr>
<tr class="text-right">
<td colspan="5">Utilidad</td>
<td> $
<?php echo number_format(@total_price($results)[1], 2);?></td>
</tr>
</tfoot>
</table>
</div>
<?php
else:
$session->msg("d", "No se encontraron ventas. ");
redirect('sales_report.php', false);
endif;
?>
</body>
</html>
<?php if(isset($db)) { $db->db_disconnect(); } ?>