-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreporte.php
More file actions
34 lines (26 loc) · 734 Bytes
/
reporte.php
File metadata and controls
34 lines (26 loc) · 734 Bytes
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
<?php
$dia = date("d");
$mes = date("m");
$anio = date("Y");
header("Content-Type: text/csv; charset=utf-8");
header("Content-Disposition: attachment; filename=reporte-$anio-$mes-$dia.csv");
include_once "config.php";
include_once "entidades/venta.php";
$ventaEntidad = new Venta();
$aVentas = $ventaEntidad->cargarGrilla();
$fp = fopen('php://output', 'w');
fputs($fp, $bom =( chr(0xEF) . chr(0xBB) . chr(0xBF) ));
$aTitulos = array("Fecha", "Cliente", "Producto", "Cantidad", "Total");
fputcsv($fp, $aTitulos, ";");
foreach ($aVentas as $venta) {
$aFila = array(
$venta->fecha,
$venta->nombre_cliente,
$venta->nombre_producto,
$venta->cantidad,
$venta->total
);
fputcsv($fp, $aFila, ";");
}
fclose($fp);
?>