97 lines
3.1 KiB
PHP
Executable File
97 lines
3.1 KiB
PHP
Executable File
<?php
|
|
|
|
include_once('../init.php');
|
|
include_once('../config.php');
|
|
include_once(DOC_ROOT.'/libraries.php');
|
|
|
|
$Usr = $user->Info();
|
|
$smarty->assign('Usr', $Usr);
|
|
|
|
switch($_POST["type"]){
|
|
|
|
case "search":
|
|
|
|
$start = microtime(true);
|
|
|
|
$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();
|
|
|
|
echo 'ok[#]';
|
|
|
|
$smarty->assign('info', $info);
|
|
$smarty->assign('DOC_ROOT', DOC_ROOT);
|
|
$smarty->display(DOC_ROOT.'/templates/lists/reportes-tickets.tpl');
|
|
|
|
$end = microtime(true);
|
|
echo "Tiempo de Ejecución: ";
|
|
echo $time = number_format(($end - $start), 2);
|
|
|
|
break;
|
|
|
|
}//switch
|
|
|
|
?>
|