Primer commit del sistema avantika sin cambios
This commit is contained in:
115
export/reporte-tickets.php
Executable file
115
export/reporte-tickets.php
Executable file
@@ -0,0 +1,115 @@
|
||||
<?php
|
||||
|
||||
include_once('../init.php');
|
||||
include_once('../config.php');
|
||||
include_once(DOC_ROOT.'/libraries.php');
|
||||
|
||||
$name = "reporte_tickets";
|
||||
|
||||
extract($_POST);
|
||||
|
||||
$codigoBarra = $_POST['codigoBarra2'];
|
||||
|
||||
$sql = 'SELECT prod.productoId, prod.codigoBarra, prod.modelo, prov.nombre AS proveedor
|
||||
FROM producto prod, proveedor prov
|
||||
WHERE prod.proveedorId = prov.proveedorId
|
||||
AND prod.codigoBarra = "'.$codigoBarra.'"';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$info = $util->DBSelect($_SESSION['empresaId'])->GetRow();
|
||||
|
||||
$productoId = $info['productoId'];
|
||||
|
||||
//Total de Ventas
|
||||
|
||||
$sql = 'SELECT SUM(vp.cantidad)
|
||||
FROM venta AS v, ventaProducto AS vp
|
||||
WHERE v.ventaId = vp.ventaId
|
||||
AND ((v.status = "Cancelado" AND v.cancelDev = "1") OR v.status <> "Cancelado")
|
||||
AND v.status <> "Descuento"
|
||||
AND vp.productoId = "'.$productoId.'"';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$info['totalVtas'] = $util->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
//Sucursal con mayor venta
|
||||
|
||||
$sql = 'SELECT SUM( vp.cantidad ) AS totalVentas, s.nombre AS sucursal
|
||||
FROM venta AS v, ventaProducto AS vp, sucursal AS s
|
||||
WHERE v.ventaId = vp.ventaId
|
||||
AND v.sucursalId = s.sucursalId
|
||||
AND ((v.status = "Cancelado" AND v.cancelDev = "1") OR v.status <> "Cancelado")
|
||||
AND v.status <> "Descuento"
|
||||
AND vp.productoId = "'.$productoId.'"
|
||||
GROUP BY v.sucursalId
|
||||
ORDER BY `totalVentas` DESC
|
||||
LIMIT 1';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$row = $util->DBSelect($_SESSION['empresaId'])->GetRow();
|
||||
|
||||
$info['sucMasVtas'] = urldecode($row['sucursal']).'<br>'.$row['totalVentas'].' Vtas';
|
||||
|
||||
//Sucursal con menos venta
|
||||
|
||||
$sql = 'SELECT SUM( vp.cantidad ) AS totalVentas, s.nombre AS sucursal
|
||||
FROM venta AS v, ventaProducto AS vp, sucursal AS s
|
||||
WHERE v.ventaId = vp.ventaId
|
||||
AND v.sucursalId = s.sucursalId
|
||||
AND ((v.status = "Cancelado" AND v.cancelDev = "1") OR v.status <> "Cancelado")
|
||||
AND v.status <> "Descuento"
|
||||
AND vp.productoId = "'.$productoId.'"
|
||||
GROUP BY v.sucursalId
|
||||
ORDER BY `totalVentas` ASC
|
||||
LIMIT 1';
|
||||
$util->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$row = $util->DBSelect($_SESSION['empresaId'])->GetRow();
|
||||
|
||||
$info['sucMenosVtas'] = urldecode($row['sucursal']).'<br>'.$row['totalVentas'].' Vtas';
|
||||
|
||||
$reportes->setProductoId($productoId);
|
||||
$fecha = $reportes->GetUltCompByProd();
|
||||
|
||||
if($fecha)
|
||||
$info['fechaIngreso'] = date('d-m-Y H:i:s',strtotime($fecha));
|
||||
else
|
||||
$info['fechaIngreso'] = '---';
|
||||
|
||||
$reportes->setProductoId($productoId);
|
||||
$info['disponibles'] = $reportes->GetTotalProdDispGral();
|
||||
|
||||
$x.="<table border=\"1\">";
|
||||
|
||||
$x .= "<thead>
|
||||
<tr>
|
||||
<th style=\"background:#E0E5E7;text-align:center\"><b>Proveedor</b></th>
|
||||
<th style=\"background:#E0E5E7;text-align:center\"><b>Codigo Barra</b></th>
|
||||
<th style=\"background:#E0E5E7;text-align:center\"><b>Modelo</b></th>
|
||||
<th style=\"background:#E0E5E7;text-align:center\"><b>Total Ventas</b></th>
|
||||
<th style=\"background:#E0E5E7;text-align:center\"><b>Suc. con Mas Ventas</b></th>
|
||||
<th style=\"background:#E0E5E7;text-align:center\"><b>Suc. con Menos Ventas</b></th>
|
||||
<th style=\"background:#E0E5E7;text-align:center\"><b>Fecha Ingreso</b></th>
|
||||
<th style=\"background:#E0E5E7;text-align:center\"><b>Disponibles</b></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>".$info['proveedor']."</td>
|
||||
<td style=\"text-align:center;\">".$info['codigoBarra']."</td>
|
||||
<td style=\"text-align:center;\">".$info['modelo']."</td>
|
||||
<td style=\"text-align:center;\">".$info['totalVtas']."</td>
|
||||
<td style=\"text-align:center;\">".$info['sucMasVtas']."</td>
|
||||
<td style=\"text-align:center;\">".$info['sucMenosVtas']."</td>
|
||||
<td style=\"text-align:center;\">".$info['fechaIngreso']."</td>
|
||||
<td style=\"text-align:center;\">".$info['disponibles']."</td>
|
||||
</tr>";
|
||||
|
||||
$x .= "</tbody>";
|
||||
$x .= "</table>";
|
||||
|
||||
header("Content-Type: application/vnd.ms-excel; charset=utf-8");
|
||||
header("Content-type: application/x-msexcel; charset=utf-8");
|
||||
header("Content-Disposition: attachment; filename=".$name.".xls");
|
||||
header("Pragma: no-cache");
|
||||
header("Expires: 0");
|
||||
|
||||
echo $x;
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user