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']).'
'.$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']).'
'.$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.="
| Proveedor | Codigo Barra | Modelo | Total Ventas | Suc. con Mas Ventas | Suc. con Menos Ventas | Fecha Ingreso | Disponibles |
|---|---|---|---|---|---|---|---|
| ".$info['proveedor']." | ".$info['codigoBarra']." | ".$info['modelo']." | ".$info['totalVtas']." | ".$info['sucMasVtas']." | ".$info['sucMenosVtas']." | ".$info['fechaIngreso']." | ".$info['disponibles']." |