1451 lines
49 KiB
PHP
Executable File
1451 lines
49 KiB
PHP
Executable File
<?php
|
|
|
|
class Reportes extends Main
|
|
{
|
|
private $proveedorId;
|
|
private $fechaI;
|
|
private $fechaF;
|
|
private $typeUser;
|
|
private $userUsuario;
|
|
private $idUser;
|
|
private $idSuc;
|
|
private $idTempo;
|
|
private $idFpago;
|
|
private $anio;
|
|
private $orden;
|
|
private $pedidoId;
|
|
private $ventaId;
|
|
private $productoId;
|
|
private $prodCatId;
|
|
private $prodSubcatId;
|
|
private $codigoBarra;
|
|
private $temporadaId;
|
|
private $promocionId;
|
|
|
|
private $fechaIni;
|
|
private $fechaFin;
|
|
|
|
public function setProveedor($value)
|
|
{
|
|
$this->proveedorId=$value;
|
|
}
|
|
|
|
public function setProveedorId($value)
|
|
{
|
|
$this->proveedorId = $value;
|
|
}
|
|
|
|
public function setProdCatId($value)
|
|
{
|
|
$this->prodCatId = $value;
|
|
}
|
|
|
|
public function setProdSubcatId($value)
|
|
{
|
|
$this->prodSubcatId = $value;
|
|
}
|
|
|
|
public function setFechaI($value)
|
|
{
|
|
$value= $this->Util()->FormatDateMySql($value);
|
|
$this->fechaI=$value;
|
|
}
|
|
|
|
public function setFechaF($value)
|
|
{
|
|
$value= $this->Util()->FormatDateMySql($value);
|
|
$this->fechaF=$value;
|
|
}
|
|
public function setTypeUser($value)
|
|
{
|
|
$this->typeUser=$value;
|
|
}
|
|
public function setUserUsuario($value)
|
|
{
|
|
$this->userUsuario=$value;
|
|
}
|
|
public function setIdSuc($value)
|
|
{
|
|
$this->idSuc=$value;
|
|
}
|
|
public function setIdUser($value)
|
|
{
|
|
$this->idUser=$value;
|
|
}
|
|
public function setOrden($value)
|
|
{
|
|
$this->orden=$value;
|
|
}
|
|
public function setPedidoId($value)
|
|
{
|
|
$this->pedidoId=$value;
|
|
}
|
|
public function setIdTempo($value)
|
|
{
|
|
$this->idTempo=$value;
|
|
}
|
|
public function setFpago($value)
|
|
{
|
|
$this->idFpago=$value;
|
|
}
|
|
public function setAnio($value)
|
|
{
|
|
$this->anio=$value;
|
|
}
|
|
|
|
function setVentaId($value)
|
|
{
|
|
$this->Util()->ValidateInteger($value);
|
|
$this->ventaId = $value;
|
|
}
|
|
|
|
function setProductoId($value)
|
|
{
|
|
$this->Util()->ValidateInteger($value);
|
|
$this->productoId = $value;
|
|
}
|
|
|
|
function setCodigoBarra($value){
|
|
$this->codigoBarra = $value;
|
|
}
|
|
|
|
function setTemporadaId($value)
|
|
{
|
|
$this->Util()->ValidateInteger($value);
|
|
$this->temporadaId = $value;
|
|
}
|
|
|
|
function setPromocionId($value)
|
|
{
|
|
$this->Util()->ValidateInteger($value);
|
|
$this->promocionId = $value;
|
|
}
|
|
|
|
function setFechaIni($value)
|
|
{
|
|
$this->fechaIni = $value;
|
|
}
|
|
|
|
function setFechaFin($value)
|
|
{
|
|
$this->fechaFin = $value;
|
|
}
|
|
|
|
|
|
public function dateNow()
|
|
{
|
|
return date('d-m-Y', time());
|
|
}
|
|
|
|
public function validaF($fechaIni,$fechaFin)
|
|
{
|
|
$validaFecha = true;
|
|
|
|
if ($fechaIni != '' && $fechaFin != '') {
|
|
|
|
$fechaIni = date('Y-m-d',strtotime($fechaIni));
|
|
$fechaFin = date('Y-m-d',strtotime($fechaFin));
|
|
|
|
if($fechaIni > $fechaFin)
|
|
$validaFecha = false;
|
|
|
|
}else{
|
|
$validaFecha = false;
|
|
} //else
|
|
|
|
return $validaFecha;
|
|
}
|
|
|
|
function orderMultiDimensionalArray ($toOrderArray, $field, $inverse = false)
|
|
{
|
|
$position = array();
|
|
$newRow = array();
|
|
foreach ($toOrderArray as $key => $row) {
|
|
$position[$key] = $row[$field];
|
|
$newRow[$key] = $row;
|
|
}
|
|
if ($inverse) {
|
|
arsort($position);
|
|
}
|
|
else {
|
|
asort($position);
|
|
}
|
|
$returnArray = array();
|
|
foreach ($position as $key => $pos) {
|
|
$returnArray[] = $newRow[$key];
|
|
}
|
|
return $returnArray;
|
|
}
|
|
|
|
public function EnumSucursales($tipo = '', $usuarioId = 0){
|
|
|
|
if($this->idSuc)
|
|
$sqlFilter = " AND suc.sucursalId = '".$this->idSuc."'";
|
|
|
|
if($tipo == 'supervisor')
|
|
$sql = 'SELECT suc.sucursalId, suc.nombre FROM sucursal suc, usuarioSuc user
|
|
WHERE user.sucursalId = suc.sucursalId
|
|
AND user.usuarioId = "'.$usuarioId.'"
|
|
'.$sqlFilter.'
|
|
ORDER BY suc.noSuc';
|
|
else
|
|
$sql = 'SELECT sucursalId, nombre FROM sucursal suc
|
|
WHERE 1 '.$sqlFilter.'
|
|
ORDER BY noSuc';
|
|
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$sucursales = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
return $sucursales;
|
|
}
|
|
|
|
public function proveedores()
|
|
{
|
|
$sql = 'SELECT * FROM proveedor ORDER BY nombre ASC';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$proveedores = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
return $proveedores;
|
|
}
|
|
|
|
public function VentaVentaId()
|
|
{
|
|
if(!empty($this->fechaI) && !empty($this->fechaF))
|
|
{
|
|
$AND=" WHERE venta.fecha>='".$this->fechaI." 00:00:00' AND venta.fecha <='".$this->fechaF." 23:59:59'";
|
|
}
|
|
$sql = 'SELECT venta.ventaId,venta.sucursalId FROM venta '.$AND.' ORDER BY venta.ventaId ASC';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$ventas = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
return $ventas;
|
|
}
|
|
public function DatosProveedor()
|
|
{
|
|
if(!empty($this->proveedorId)) { $AND=" WHERE proveedor.proveedorId='".$this->proveedorId."'";}
|
|
|
|
$sql='SELECT proveedor.proveedorId,proveedor.nombre FROM proveedor '.$AND.' ORDER BY proveedor.nombre';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$cons = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
return $cons;
|
|
|
|
}
|
|
|
|
|
|
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>REPORTE GENERAL>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
|
|
public function ventasGral()//ventas sin devoluciones,sin cancelar
|
|
{
|
|
$sql = 'SELECT venta.ventaId,venta.sucursalId,venta.fecha,venta.status,venta.subtotal,venta.iva,venta.total,venta.pago,venta.tipoDesc,venta.valDesc,venta.subtotalDesc,venta.ivaDesc,venta.totalDesc,
|
|
venta.pago,
|
|
IF( venta.totalDesc <>0, venta.totalDesc, venta.total ) AS ventaCiva,
|
|
IF( venta.totalDesc <>0, venta.subtotalDesc, venta.subtotal ) AS ventaSiva,
|
|
IF( venta.totalDesc <>0, venta.totalDesc, venta.total ) AS totalpagado
|
|
FROM venta
|
|
WHERE venta.status<>"Cancelado" AND venta.pago<>"0"
|
|
AND venta.fecha>="'.$this->fechaI.' 00:00:00" AND venta.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
ORDER BY venta.ventaId ASC';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$cons = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
return $cons;
|
|
}
|
|
|
|
//Ventas sin Devoluciones, sin Cancelar ni Descuentos
|
|
|
|
public function ventasGralSuc(){
|
|
|
|
$sql = 'SELECT * FROM venta
|
|
WHERE status <> "Cancelado"
|
|
AND status <> "Descuento"
|
|
AND pago <> "0"
|
|
AND fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND sucursalId = "'.$this->idSuc.'"
|
|
ORDER BY ventaId ASC';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$ventas = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
return $ventas;
|
|
}
|
|
|
|
public function ventasDev()//mostrar ventas que solo tienen devoluciones
|
|
{
|
|
$sql = 'SELECT venta.ventaId,venta.sucursalId,venta.fecha,venta.status,venta.subtotal,venta.iva,venta.total,venta.pago,venta.tipoDesc,venta.valDesc,venta.subtotalDesc,venta.ivaDesc,venta.totalDesc,
|
|
venta.pago,
|
|
IF( venta.totalDesc <>0, venta.totalDesc, venta.total ) AS ventaCiva,
|
|
IF( venta.totalDesc <>0, venta.subtotalDesc, venta.subtotal ) AS ventaSiva,
|
|
IF( venta.totalDesc <>0, venta.totalDesc, venta.total ) AS totalpagado
|
|
FROM venta INNER JOIN devolucion ON venta.ventaId=devolucion.ventaId
|
|
AND venta.fecha>="'.$this->fechaI.' 00:00:00" AND venta.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
ORDER BY venta.ventaId ASC';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$cons = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
return $cons;
|
|
}
|
|
|
|
public function ventasDevSuc(){//mostrar ventas que solo tienen devoluciones
|
|
|
|
$sql = 'SELECT venta.ventaId, venta.sucursalId, venta.fecha, venta.status, venta.subtotal, venta.iva, venta.total,
|
|
venta.pago, venta.tipoDesc, venta.valDesc, venta.subtotalDesc, venta.ivaDesc,venta.totalDesc,
|
|
venta.pago,
|
|
IF( venta.totalDesc <>0, venta.totalDesc, venta.total ) AS ventaCiva,
|
|
IF( venta.totalDesc <>0, venta.subtotalDesc, venta.subtotal ) AS ventaSiva,
|
|
IF( venta.totalDesc <>0, venta.totalDesc, venta.total ) AS totalpagado
|
|
FROM venta INNER JOIN devolucion ON venta.ventaId=devolucion.ventaId
|
|
AND venta.fecha>="'.$this->fechaI.' 00:00:00" AND venta.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND venta.sucursalId = "'.$this->idSuc.'"
|
|
ORDER BY venta.ventaId ASC';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$cons = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
return $cons;
|
|
}
|
|
|
|
public function GetTotalVtasDev()
|
|
{
|
|
$sql = 'SELECT SUM(d.total) FROM devolucion AS d, venta AS v
|
|
WHERE d.ventaId = v.ventaId
|
|
AND v.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND v.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND v.sucursalId = "'.$this->idSuc.'"';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $total;
|
|
}
|
|
|
|
public function ventasXdevolucion()//ventas por devoluciones(no tienen pago)
|
|
{
|
|
$sql = 'SELECT venta.ventaId, venta.sucursalId, venta.fecha, venta.status, venta.subtotal,venta.iva, venta.total,
|
|
venta.pago, venta.tipoDesc, venta.valDesc, venta.subtotalDesc,venta.ivaDesc, venta.totalDesc, venta.pago,
|
|
IF(venta.pago =0, 0.00,venta.total) AS ventaCiva,
|
|
IF(venta.pago =0, 0.00,venta.subtotal) AS ventaSiva,
|
|
IF(venta.pago =0, 0.00,venta.total) AS totalpagado
|
|
FROM venta
|
|
WHERE venta.pago ="0"
|
|
AND venta.fecha>="'.$this->fechaI.' 00:00:00" AND venta.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
ORDER BY venta.ventaId ASC';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$cons = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
return $cons;
|
|
}
|
|
|
|
public function ventasXdevolucionSuc(){//ventas por devoluciones(no tienen pago)
|
|
|
|
$sql = 'SELECT venta.ventaId, venta.sucursalId, venta.fecha, venta.status, venta.subtotal,venta.iva, venta.total,
|
|
venta.pago, venta.tipoDesc, venta.valDesc, venta.subtotalDesc,venta.ivaDesc, venta.totalDesc, venta.pago,
|
|
IF(venta.pago =0, 0.00,venta.total) AS ventaCiva,
|
|
IF(venta.pago =0, 0.00,venta.subtotal) AS ventaSiva,
|
|
IF(venta.pago =0, 0.00,venta.total) AS totalpagado
|
|
FROM venta
|
|
WHERE venta.pago ="0"
|
|
AND venta.fecha>="'.$this->fechaI.' 00:00:00" AND venta.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND venta.sucursalId = "'.$this->idSuc.'"
|
|
ORDER BY venta.ventaId ASC';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$cons = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
return $cons;
|
|
}
|
|
|
|
//->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
public function productosXventa()//mostrar ventas agrupadas por numero de ventas y producto
|
|
{
|
|
$sql='SELECT ventaProducto.ventaId,producto.costo,producto.precioVenta, ventaProducto.productoId,producto.modelo,producto.proveedorId, SUM( ventaProducto.cantidad ) AS ventaProducto
|
|
FROM ventaProducto
|
|
INNER JOIN producto ON producto.productoId = ventaProducto.productoId
|
|
GROUP BY ventaProducto.ventaId, ventaProducto.productoId';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$cons = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
return $cons;
|
|
}
|
|
public function devolucionesXventa()
|
|
{
|
|
$sql='SELECT devolucionProducto.ventaId,devolucionProducto.productoId,SUM(devolucionProducto.cantidad) AS ncantidadDevolucion FROM devolucionProducto GROUP BY devolucionProducto.ventaId,devolucionProducto.productoId';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$cons = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
return $cons;
|
|
}
|
|
|
|
/*** REPORTE POR VENDEDOR ***/
|
|
|
|
public function selectVend()
|
|
{
|
|
$sql='SELECT * FROM usuario WHERE usuario.sucursalId="'.$this->idSuc.'" AND usuario.type="vendedor"';
|
|
$this->Util()->DB()->setQuery($sql);
|
|
$cons = $this->Util()->DB()->GetResult();
|
|
return $cons;
|
|
}
|
|
|
|
public function vendedores()
|
|
{
|
|
if($this->idUser != "todos")
|
|
$AND = " AND usuario.usuarioId='".$this->idUser."'";
|
|
|
|
$sql = 'SELECT * FROM usuario WHERE usuario.type = "vendedor" '.$AND;
|
|
$this->Util()->DB()->setQuery($sql);
|
|
$cons = $this->Util()->DB()->GetResult();
|
|
|
|
return $cons;
|
|
}
|
|
|
|
public function GetVendedoresBySuc()
|
|
{
|
|
if($this->idUser != "todos")
|
|
$sqlFilter = " AND usuarioId = '".$this->idUser."'";
|
|
|
|
$sql = 'SELECT * FROM usuario
|
|
WHERE type = "vendedor"
|
|
AND sucursalId = "'.$this->idSuc.'"'.$sqlFilter;
|
|
$this->Util()->DB()->setQuery($sql);
|
|
$vendedores = $this->Util()->DB()->GetResult();
|
|
|
|
return $vendedores;
|
|
}
|
|
|
|
public function ventasVendedor($value)
|
|
{
|
|
$sql = 'SELECT IF( venta.totalDesc <>0, venta.totalDesc, venta.total ) AS totalventa,venta.* FROM venta
|
|
WHERE ((status = "Cancelado" AND cancelDev = "1") OR status <> "Cancelado")
|
|
AND ventaIdAnt = 0
|
|
AND status <> "Descuento"
|
|
AND venta.vendedorId = "'.$value.'"
|
|
AND venta.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND venta.fecha <= "'.$this->fechaF.' 23:59:59"';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$cons= $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
return $cons;
|
|
}
|
|
|
|
public function infVendSuc()
|
|
{
|
|
$sql='SELECT * FROM sucursal WHERE sucursal.sucursalId="'.$this->idSuc.'"';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$cons= $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
return $cons;
|
|
}
|
|
|
|
public function enumTemporada()
|
|
{
|
|
if($this->idTempo)
|
|
$sqlFilter = " WHERE temporada.temporadaId = ".$this->idTempo;
|
|
|
|
$sql = 'SELECT * FROM temporada '.$sqlFilter;
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$cons = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
return $cons;
|
|
}
|
|
|
|
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>REPORTE POR TEMPORADA>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
|
|
public function ventaTemporada()
|
|
{
|
|
if($this->anio!=NULL){$AND="AND YEAR(venta.fecha)=".$this->anio."";}
|
|
$sql='SELECT venta.fecha, ventaProducto.ventaProdId, producto.productoId,producto.codigoBarra, venta.sucursalId, producto.modelo, producto.temporadaId, SUM( ventaProducto.cantidad ) AS nvendidos, ventaProducto.precioUnitario, producto.costo, producto.precioVenta, producto.precioVentaIva, producto.utilidad, venta.ventaId, venta.status
|
|
FROM ventaProducto
|
|
INNER JOIN ventaPago ON ventaPago.ventaId = ventaProducto.ventaId
|
|
INNER JOIN producto ON producto.productoId = ventaProducto.productoId
|
|
INNER JOIN venta ON venta.ventaId = ventaProducto.ventaId '.$AND.'
|
|
GROUP BY ventaProducto.productoId, venta.sucursalId
|
|
ORDER BY venta.ventaId ASC ';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$cons = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
return $cons;
|
|
}
|
|
public function devoluciones()
|
|
{
|
|
if($this->anio!=NULL){$AND="AND YEAR(venta.fecha)=".$this->anio.""; }
|
|
$sql='SELECT venta.sucursalId, devolucionProducto.productoId, SUM( devolucionProducto.cantidad ) AS ndevueltos
|
|
FROM venta
|
|
INNER JOIN devolucionProducto ON venta.ventaId = devolucionProducto.ventaId '.$AND.'
|
|
GROUP BY devolucionProducto.productoId, venta.sucursalId';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$cons = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
return $cons;
|
|
|
|
}
|
|
|
|
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>REPORTE FORMAS DE PAGO>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
|
|
public function enumFpago()
|
|
{
|
|
if(!empty($this->idFpago)) { $WHERE=" WHERE metodoPago.metodoPagoId='".$this->idFpago."'";}
|
|
|
|
$sql='SELECT metodoPago.*,metodoPago.nombre AS nomMetodo FROM metodoPago '.$WHERE.'';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$cons = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
return $cons;
|
|
}
|
|
|
|
public function EnumFpago2()
|
|
{
|
|
if($this->idFpago)
|
|
$sqlFilter = ' AND metodoPagoId = "'.$this->idFpago.'"';
|
|
|
|
$sql = 'SELECT *, nombre AS nomMetodo
|
|
FROM metodoPago
|
|
WHERE metodoPagoId IN (10, 4, 1)'.$sqlFilter;
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$result = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
return $result;
|
|
}
|
|
|
|
public function FormaPagoVentasPorSucursal($sucursalId, $metodoPagoId)
|
|
{
|
|
if($this->typeUser=="admin")
|
|
{
|
|
if(!empty($this->idSuc)) { $ANDSUC=" AND venta.sucursalId='".$this->idSuc."'"; }
|
|
}
|
|
if($this->typeUser=="gerente")
|
|
{
|
|
$DANDSUC=" AND sucursal.sucursalId='".$this->idSuc."' AND venta.sucursalId='".$this->idSuc."'";
|
|
}
|
|
if(!empty($this->fechaI) && !empty($this->fechaF))
|
|
{
|
|
$AND=" AND venta.fecha>='".$this->fechaI." 00:00:00' AND venta.fecha <='".$this->fechaF." 23:59:59'";
|
|
}
|
|
|
|
$sql=' SELECT ventaPago.metodoPagoId AS mPago,metodoPago.nombre AS nombreMetodo, ventaProducto.cantidad AS cantidad,sucursal.nombre AS nombreSucursal,venta.total
|
|
FROM ventaPago INNER JOIN metodoPago ON metodoPago.metodoPagoId=ventaPago.metodoPagoId
|
|
INNER JOIN venta ON venta.ventaId=ventaPago.ventaId AND venta.status<>"Cancelado" '.$ANDSUC.' '.$AND.'
|
|
INNER JOIN ventaProducto ON ventaProducto.ventaId=venta.ventaId
|
|
INNER JOIN sucursal ON venta.sucursalId=sucursal.sucursalId '.$DANDSUC.'
|
|
WHERE
|
|
venta.sucursalId = '.$sucursalId.' AND
|
|
ventaPago.metodoPagoId = '.$metodoPagoId.'
|
|
GROUP BY ventaPago.ventaPagoId ORDER BY sucursal.sucursalId,ventaPago.ventaPagoId';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$cons = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
return $cons;
|
|
}
|
|
|
|
//->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>REPORTE DE PRODUCTOS>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
|
|
public function ProductosComprados()
|
|
{
|
|
if(!empty($this->fechaI) && !empty($this->fechaF))
|
|
{
|
|
$AND=" AND pedido.fecha>='".$this->fechaI." 00:00:00' AND pedido.fecha <='".$this->fechaF." 23:59:59'";
|
|
}
|
|
if($this->orden=="mayor") { $ORDEN="DESC"; }
|
|
if($this->orden=="menor") { $ORDEN="ASC"; }
|
|
|
|
$sql=' SELECT pedido.* , pedidoProducto.* , producto.* , (pedidoProducto.totalLote * pedidoProducto.cantLotes) AS nProductos
|
|
FROM pedido
|
|
INNER JOIN pedidoProducto ON pedido.pedidoId = pedidoProducto.pedidoId
|
|
AND pedidoProducto.status <> "Pendiente" '.$AND.'
|
|
AND pedido.status <> "Autorizado"
|
|
AND pedido.status <> "OrdenCompEnv"
|
|
INNER JOIN producto ON producto.productoId = pedidoProducto.productoId
|
|
GROUP BY pedido.fecha,pedidoProducto.productoId ORDER BY nProductos '.$ORDEN.'
|
|
LIMIT 0 , 100';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$cons = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
return $cons;
|
|
}
|
|
|
|
public function cuentasPorpagar()//reporte de cuentas pendientes de pago
|
|
{
|
|
if(!empty($this->proveedorId)) { $ANDP=" AND pedido.proveedorId='".$this->proveedorId."'"; }
|
|
|
|
if(!empty($this->fechaI) && !empty($this->fechaF))
|
|
{
|
|
echo $AN=" AND pedido.fecha>='".$this->fechaI." 00:00:00' AND pedido.fecha <='".$this->fechaF." 23:59:59'";
|
|
}
|
|
|
|
$sql='SELECT pedido. * , proveedor. * , SUM( pedidoPago.cantidad ) AS totalparcial,
|
|
(pedido.total - SUM( pedidoPago.cantidad )) AS saldo
|
|
FROM pedido
|
|
INNER JOIN proveedor ON proveedor.proveedorId = pedido.proveedorId
|
|
AND pedido.status <> "Rechazado"
|
|
AND pedido.status <> "OrdenCompEnv"
|
|
AND pedido.status <> "Autorizado" '.$ANDP.' '.$AN.'
|
|
LEFT JOIN pedidoPago ON pedido.pedidoId = pedidoPago.pedidoId
|
|
GROUP BY pedido.pedidoId';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$cons = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
return $cons;
|
|
}
|
|
|
|
function bonificaciones()
|
|
{
|
|
$sql = 'SELECT SUM(cantidad) FROM bonificacion WHERE pedidoId = '.$this->pedidoId.' AND estatus LIKE "Aprobado"';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$cons = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
return $cons;
|
|
}
|
|
|
|
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>REPORTE DE INVENTARIO>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
|
|
function disponibles()
|
|
{
|
|
if(!empty($this->proveedorId))
|
|
$ANDPROV=" AND producto.proveedorId='".$this->proveedorId."'";
|
|
if(!empty($this->idSuc))
|
|
$ANDSUC=" AND inventario.sucursalId='".$this->idSuc."'";
|
|
|
|
$sql = 'SELECT inventario.sucursalId, inventario.productoId, producto.proveedorId, inventario.precioVenta,
|
|
producto.costo, producto.modelo, SUM(inventario.cantidad) AS ndisponibles
|
|
FROM inventario
|
|
INNER JOIN producto ON inventario.productoId = producto.productoId
|
|
AND inventario.status = "Disponible" '.$ANDPROV.' '.$ANDSUC.'
|
|
GROUP BY inventario.productoId, inventario.sucursalId
|
|
ORDER BY producto.modelo';
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
|
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
|
|
|
return $total;
|
|
}
|
|
|
|
function EnumDisponibles()
|
|
{
|
|
$sqlFilter = '';
|
|
|
|
if($this->proveedorId)
|
|
$sqlFilter .= " AND prod.proveedorId = '".$this->proveedorId."'";
|
|
if($this->idSuc)
|
|
$sqlFilter .= " AND inv.sucursalId = '".$this->idSuc."'";
|
|
if($this->prodCatId)
|
|
$sqlFilter .= " AND prod.prodCatId = '".$this->prodCatId."'";
|
|
if($this->prodSubcatId)
|
|
$sqlFilter .= " AND prod.prodSubcatId = '".$this->prodSubcatId."'";
|
|
|
|
$sql = 'SELECT prod.modelo, prod.codigoBarra, prod.costo, prod.proveedorId, prod.productoId
|
|
FROM inventario AS inv, producto AS prod
|
|
WHERE inv.productoId = prod.productoId
|
|
AND inv.status = "Disponible"
|
|
'.$sqlFilter.'
|
|
GROUP BY inv.productoId
|
|
ORDER BY prod.codigoBarra ASC';
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
|
$productos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
|
|
|
return $productos;
|
|
}
|
|
|
|
function EnumDisponibles2()
|
|
{
|
|
$sqlFilter = '';
|
|
|
|
if($this->proveedorId)
|
|
$sqlFilter .= " AND prod.proveedorId = '".$this->proveedorId."'";
|
|
if($this->idSuc)
|
|
$sqlFilter .= " AND inv.sucursalId = '".$this->idSuc."'";
|
|
if($this->prodCatId)
|
|
$sqlFilter .= " AND prod.prodCatId = '".$this->prodCatId."'";
|
|
if($this->prodSubcatId)
|
|
$sqlFilter .= " AND prod.prodSubcatId = '".$this->prodSubcatId."'";
|
|
|
|
$sql = 'SELECT prod.modelo, prod.codigoBarra, prod.costo, prod.precioVentaIva, prod.proveedorId,
|
|
prod.productoId, prod.prodSubcatId
|
|
FROM inventario AS inv, producto AS prod, proveedor AS prov
|
|
WHERE inv.productoId = prod.productoId
|
|
AND prod.proveedorId = prov.proveedorId
|
|
AND inv.status = "Disponible"
|
|
'.$sqlFilter.'
|
|
GROUP BY inv.productoId
|
|
ORDER BY prov.nombre ASC';
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
|
$productos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
|
|
|
return $productos;
|
|
}
|
|
|
|
function GetTotalDisponible()
|
|
{
|
|
$sql = 'SELECT SUM(cantidad) FROM inventario
|
|
WHERE status = "Disponible"
|
|
AND productoId = "'.$this->productoId.'"
|
|
AND sucursalId = "'.$this->idSuc.'"';
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
|
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
|
|
|
return $total;
|
|
}
|
|
|
|
function GetProveedor($idProveedor)
|
|
{
|
|
$sql = "SELECT proveedor.nombre FROM proveedor WHERE proveedorId='".$idProveedor."'";
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
|
$proveedor = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
|
return $proveedor;
|
|
}
|
|
|
|
//>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>REPORTE DE PRODUCTOS>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
|
|
function VentasArray(){
|
|
|
|
if(!empty($this->fechaI) && !empty($this->fechaF))
|
|
$AND=" AND venta.fecha>='".$this->fechaI." 00:00:00' AND venta.fecha <='".$this->fechaF." 23:59:59'";
|
|
|
|
$sql = 'SELECT producto.modelo, producto.codigoBarra, venta.fecha, venta.sucursalId, ventaProducto.ventaId,
|
|
ventaProducto.productoId, SUM(ventaProducto.cantidad) as nvendidos
|
|
FROM ventaProducto INNER JOIN venta ON venta.ventaId=ventaProducto.ventaId
|
|
INNER JOIN producto ON producto.productoId=ventaProducto.productoId '.$AND.'
|
|
GROUP BY ventaProducto.ventaId,ventaProducto.productoId';
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
|
$cons = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
|
|
|
return $cons;
|
|
}
|
|
|
|
function DevolucionesArray()
|
|
{
|
|
if(!empty($this->fechaI) && !empty($this->fechaF))
|
|
{
|
|
$AND=" AND venta.fecha>='".$this->fechaI." 00:00:00' AND venta.fecha <='".$this->fechaF." 23:59:59'";
|
|
}
|
|
$sql='SELECT venta.fecha,venta.sucursalId, devolucionProducto.ventaId, devolucionProducto.productoId, SUM( devolucionProducto.cantidad ) AS nvendidos
|
|
FROM devolucionProducto
|
|
INNER JOIN venta ON venta.ventaId = devolucionProducto.ventaId '.$AND.'
|
|
GROUP BY devolucionProducto.ventaId, devolucionProducto.productoId';
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
|
$cons = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
|
return $cons;
|
|
}
|
|
|
|
//Others
|
|
|
|
function GetVentasGralBySuc(){
|
|
|
|
global $util;
|
|
|
|
$fechaI = $this->fechaI;
|
|
$fechaF = $this->fechaF;
|
|
|
|
$ventas = $this->ventasGralSuc();
|
|
|
|
$data['ventasRealizadasSucursal'] = count($ventas);
|
|
|
|
$data['totalSucursalVenta'] = 0;
|
|
|
|
foreach($ventas as $res){
|
|
|
|
if($res['totalDesc'] > 0)
|
|
$data['totalSucursalVenta'] += $res['totalDesc'];
|
|
else
|
|
$data['totalSucursalVenta'] += $res['total'];
|
|
|
|
$this->setVentaId($res['ventaId']);
|
|
$totalCosto = $this->CostoProdsVta();
|
|
$data['totalSucursalCosto'] += $totalCosto;
|
|
|
|
$data['totalSucursalUtilidad'] += ($res['total'] - $totalCosto);
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
}//GetVentasGralBySuc
|
|
|
|
public function VentasBySucReporte()
|
|
{
|
|
$sql = 'SELECT ventaId, total, totalDesc
|
|
FROM venta
|
|
WHERE ((status = "Cancelado" AND cancelDev = "1") OR status <> "Cancelado")
|
|
AND ventaIdAnt = 0
|
|
AND venta.status <> "Descuento"
|
|
AND venta.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND venta.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND venta.sucursalId = "'.$this->idSuc.'"
|
|
ORDER BY venta.ventaId ASC';
|
|
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$ventas = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
return $ventas;
|
|
}
|
|
|
|
public function TotalVentasBySucReporte()
|
|
{
|
|
$sql = 'SELECT COUNT(ventaId) AS ventas, SUM(IF(totalDesc > 0, totalDesc, total)) AS totalVenta
|
|
FROM venta
|
|
WHERE ((status = "Cancelado" AND cancelDev = "1") OR status <> "Cancelado")
|
|
AND ventaIdAnt = 0
|
|
AND venta.status <> "Descuento"
|
|
AND venta.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND venta.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND venta.sucursalId = "'.$this->idSuc.'"';
|
|
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$ventas = $this->Util()->DBSelect($_SESSION['empresaId'])->GetRow();
|
|
|
|
return $ventas;
|
|
}
|
|
|
|
public function TotalVentasBySucReporteByDay()
|
|
{
|
|
$sql = 'SELECT DATE(venta.fecha) AS fecha, COUNT(ventaId) AS ventas, SUM(IF(totalDesc > 0, totalDesc, total)) AS totalVenta
|
|
FROM venta
|
|
WHERE ((status = "Cancelado" AND cancelDev = "1") OR status <> "Cancelado")
|
|
AND ventaIdAnt = 0
|
|
AND venta.status <> "Descuento"
|
|
AND venta.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND venta.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND venta.sucursalId = "'.$this->idSuc.'"
|
|
GROUP BY DATE(venta.fecha)';
|
|
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$ventas = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
return $ventas;
|
|
}
|
|
|
|
|
|
function GetTotalSumProductosReporte(){
|
|
|
|
$sql = 'SELECT SUM(ventaProducto.cantidad * producto.costo) AS importe
|
|
FROM ventaProducto
|
|
LEFT JOIN producto ON producto.productoId = ventaProducto.productoId
|
|
LEFT JOIN venta ON venta.ventaId = ventaProducto.ventaId
|
|
WHERE ((venta.status = "Cancelado" AND venta.cancelDev = "1") OR venta.status <> "Cancelado")
|
|
AND venta.ventaIdAnt = 0
|
|
AND venta.status <> "Descuento"
|
|
AND venta.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND venta.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND venta.sucursalId = "'.$this->idSuc.'"';
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
|
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
|
|
|
return $result;
|
|
}
|
|
|
|
function GetTotalSumProductosReporteByDay(){
|
|
|
|
$sql = 'SELECT DATE(venta.fecha) AS fecha, SUM(ventaProducto.cantidad * producto.costo) AS importe
|
|
FROM ventaProducto
|
|
LEFT JOIN producto ON producto.productoId = ventaProducto.productoId
|
|
LEFT JOIN venta ON venta.ventaId = ventaProducto.ventaId
|
|
WHERE ((venta.status = "Cancelado" AND venta.cancelDev = "1") OR venta.status <> "Cancelado")
|
|
AND venta.ventaIdAnt = 0
|
|
AND venta.status <> "Descuento"
|
|
AND venta.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND venta.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND venta.sucursalId = "'.$this->idSuc.'"
|
|
GROUP BY DATE(venta.fecha)';
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
|
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
|
|
|
return $result;
|
|
}
|
|
|
|
|
|
public function VentasBySuc(){
|
|
|
|
$sql = 'SELECT * FROM venta
|
|
WHERE ((status = "Cancelado" AND cancelDev = "1") OR status <> "Cancelado")
|
|
AND ventaIdAnt = 0
|
|
AND status <> "Descuento"
|
|
AND fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND sucursalId = "'.$this->idSuc.'"
|
|
ORDER BY ventaId ASC';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$ventas = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
//print_r($ventas);
|
|
|
|
return $ventas;
|
|
}
|
|
|
|
public function GetTotalVtasBySucAndProd(){
|
|
|
|
$sql = 'SELECT SUM(vp.cantidad)
|
|
FROM venta AS v, ventaProducto AS vp
|
|
WHERE v.ventaId = vp.ventaId
|
|
AND v.status <> "Cancelado"
|
|
AND v.status <> "Descuento"
|
|
AND v.sucursalId = "'.$this->idSuc.'"
|
|
AND vp.productoId = "'.$this->productoId.'"';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$ventas = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $ventas;
|
|
}
|
|
|
|
public function VentasBySucAndProv(){
|
|
|
|
$sql = 'SELECT SUM(vp.cantidad)
|
|
FROM venta AS v, ventaProducto AS vp, producto AS p
|
|
WHERE v.ventaId = vp.ventaId
|
|
AND vp.productoId = p.productoId
|
|
AND v.status <> "Cancelado"
|
|
AND v.status <> "Descuento"
|
|
AND v.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND v.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND v.sucursalId = "'.$this->idSuc.'"
|
|
AND p.proveedorId = "'.$this->proveedorId.'"';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$ventas = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $ventas;
|
|
}
|
|
|
|
public function DevolucionesBySucAndProv(){
|
|
|
|
$sql = 'SELECT SUM(dp.cantidad)
|
|
FROM venta AS v, devolucion AS d, devolucionProducto AS dp, producto AS p
|
|
WHERE v.ventaId = d.ventaId
|
|
AND d.devolucionId = dp.devolucionId
|
|
AND dp.productoId = p.productoId
|
|
AND v.status <> "Cancelado"
|
|
AND v.status <> "Descuento"
|
|
AND v.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND v.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND v.sucursalId = "'.$this->idSuc.'"
|
|
AND p.proveedorId = "'.$this->proveedorId.'"';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$ventas = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $ventas;
|
|
}
|
|
|
|
public function TotalDevsBySucAndProv(){
|
|
|
|
$sql = 'SELECT SUM(dp.total)
|
|
FROM venta AS v, devolucion AS d, devolucionProducto AS dp, producto AS p
|
|
WHERE v.ventaId = d.ventaId
|
|
AND d.devolucionId = dp.devolucionId
|
|
AND dp.productoId = p.productoId
|
|
AND v.status <> "Cancelado"
|
|
AND v.status <> "Descuento"
|
|
AND v.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND v.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND v.sucursalId = "'.$this->idSuc.'"
|
|
AND p.proveedorId = "'.$this->proveedorId.'"';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$ventas = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $ventas;
|
|
}
|
|
|
|
public function TotalVentasBySucAndProv(){
|
|
|
|
$sql = 'SELECT SUM(vp.total)
|
|
FROM venta AS v, ventaProducto AS vp, producto AS p
|
|
WHERE v.ventaId = vp.ventaId
|
|
AND vp.productoId = p.productoId
|
|
AND v.status <> "Cancelado"
|
|
AND v.status <> "Descuento"
|
|
AND v.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND v.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND v.sucursalId = "'.$this->idSuc.'"
|
|
AND p.proveedorId = "'.$this->proveedorId.'"';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$ventas = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $ventas;
|
|
}
|
|
|
|
public function DevolucionesBySuc(){
|
|
|
|
$sql = 'SELECT dev.* FROM venta AS vta, devolucion AS dev
|
|
WHERE vta.ventaId = dev.ventaId
|
|
AND dev.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND dev.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND dev.sucursalId = "'.$this->idSuc.'"
|
|
ORDER BY vta.ventaId ASC';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$ventas = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
return $ventas;
|
|
}
|
|
|
|
public function DevolucionesBySucReporte(){
|
|
|
|
$sql = 'SELECT dev.devolucionId, dev.total FROM venta AS vta, devolucion AS dev
|
|
WHERE vta.ventaId = dev.ventaId
|
|
AND dev.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND dev.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND dev.sucursalId = "'.$this->idSuc.'"
|
|
ORDER BY vta.ventaId ASC';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$ventas = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
return $ventas;
|
|
}
|
|
|
|
public function TotalDevolucionesBySucReporte(){
|
|
|
|
$sql = 'SELECT SUM(dev.total) AS total FROM devolucion AS dev
|
|
WHERE
|
|
dev.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND dev.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND dev.sucursalId = "'.$this->idSuc.'"';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$ventas = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $ventas;
|
|
}
|
|
|
|
public function TotalDevolucionesBySucReporteByDay(){
|
|
|
|
$sql = 'SELECT DATE(dev.fecha) AS fecha, SUM(dev.total) AS total FROM devolucion AS dev
|
|
WHERE
|
|
dev.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND dev.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND dev.sucursalId = "'.$this->idSuc.'"
|
|
GROUP BY DATE(dev.fecha)';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$ventas = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
return $ventas;
|
|
}
|
|
|
|
function GetTotalCostoProductosReporte(){
|
|
|
|
$sql = 'SELECT SUM(devolucionProducto.cantidad * producto.costo) AS importe FROM devolucionProducto
|
|
LEFT JOIN producto ON producto.productoId = devolucionProducto.productoId
|
|
LEFT JOIN devolucion ON devolucion.devolucionId = devolucionProducto.devolucionId
|
|
WHERE devolucion.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND devolucion.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND devolucion.sucursalId = "'.$this->idSuc.'"';
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
|
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
function GetTotalCostoProductosReporteByDay(){
|
|
|
|
$sql = 'SELECT DATE(devolucion.fecha) AS fecha, SUM(devolucionProducto.cantidad * producto.costo) AS importe FROM devolucionProducto
|
|
LEFT JOIN producto ON producto.productoId = devolucionProducto.productoId
|
|
LEFT JOIN devolucion ON devolucion.devolucionId = devolucionProducto.devolucionId
|
|
WHERE devolucion.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND devolucion.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND devolucion.sucursalId = "'.$this->idSuc.'"
|
|
GROUP BY DATE(devolucion.fecha)';
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
|
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function CostoProdsVta(){
|
|
|
|
$sql = 'SELECT vp.cantidad, p.costo
|
|
FROM ventaProducto AS vp, producto AS p
|
|
WHERE vp.productoId = p.productoId
|
|
AND vp.ventaId = "'.$this->ventaId.'"';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$productos = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
$total = 0;
|
|
foreach($productos as $res)
|
|
$total += $res['cantidad'] * $res['costo'];
|
|
|
|
return $total;
|
|
}
|
|
|
|
function EnumProveedores()
|
|
{
|
|
if($this->proveedorId)
|
|
$sqlFilter = ' AND proveedorId = "'.$this->proveedorId.'"';
|
|
|
|
$sql = 'SELECT * FROM proveedor WHERE baja = "0" '.$sqlFilter.' ORDER BY proveedorId ASC';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$proveedores = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
return $proveedores;
|
|
}
|
|
|
|
function GetUltCompByProd(){
|
|
|
|
$sql = "SELECT p.fechaOrdenCompIng FROM pedido p, pedidoProducto pp
|
|
WHERE p.pedidoId = pp.pedidoId
|
|
AND p.folioProv NOT REGEXP '^FOLIO'
|
|
AND (p.status = 'OrdenCompIng'
|
|
OR p.status = 'EnvSuc')
|
|
AND pp.productoId = '".$this->productoId."'
|
|
ORDER BY fechaOrdenCompIng DESC
|
|
LIMIT 1";
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$fecha = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $fecha;
|
|
}
|
|
|
|
function GetTotalProdDispGral(){
|
|
|
|
$sql = "SELECT COUNT(*) FROM inventario
|
|
WHERE productoId = '".$this->productoId."'
|
|
AND status = 'Disponible'";
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
$sql = 'SELECT SUM(cantidad)
|
|
FROM inventario
|
|
LEFT JOIN pedido ON pedido.pedidoId = inventario.pedidoId
|
|
WHERE productoId = '.$this->productoId.'
|
|
AND ventaDesc = "Si"';
|
|
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
|
$totalDesc = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
|
|
|
return $total - $totalDesc;
|
|
}
|
|
|
|
function EnumAllProv()
|
|
{
|
|
if($this->proveedorId)
|
|
$sqlAdd = ' AND proveedorId = "'.$this->proveedorId.'"';
|
|
|
|
$sql = 'SELECT * FROM proveedor WHERE baja = "0" '.$sqlAdd.' ORDER BY nombre ASC';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$proveedores = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
return $proveedores;
|
|
}
|
|
|
|
function GetTotalFaltantesByProv(){
|
|
|
|
$sql = "SELECT SUM(er.faltantes) FROM envioRecibir er, producto p
|
|
WHERE er.productoId = p.productoId
|
|
AND p.proveedorId = '".$this->proveedorId."'";
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $total;
|
|
}
|
|
|
|
function GetFaltSucByProv(){
|
|
|
|
$sql = "SELECT e.sucursalId FROM envioRecibir er, envio e, producto p
|
|
WHERE e.envioId = er.envioId
|
|
AND er.productoId = p.productoId
|
|
AND p.proveedorId = '".$this->proveedorId."'
|
|
AND er.faltantes > 0
|
|
GROUP BY e.sucursalId";
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$result = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
return $result;
|
|
}
|
|
|
|
function GetProdFaltSucByProv(){
|
|
|
|
$sql = "SELECT er.productoId FROM envioRecibir er, envio e, producto p
|
|
WHERE e.envioId = er.envioId
|
|
AND er.productoId = p.productoId
|
|
AND p.proveedorId = '".$this->proveedorId."'
|
|
AND e.sucursalId = '".$this->idSuc."'
|
|
AND er.faltantes > 0
|
|
GROUP BY er.productoId";
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$result = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
return $result;
|
|
}
|
|
|
|
function GetTotalFaltSucByProv(){
|
|
|
|
$sql = "SELECT SUM(er.faltantes) FROM envioRecibir er, envio e, producto p
|
|
WHERE e.envioId = er.envioId
|
|
AND er.productoId = p.productoId
|
|
AND p.proveedorId = '".$this->proveedorId."'
|
|
AND e.sucursalId = '".$this->idSuc."'
|
|
AND er.productoId = '".$this->productoId."'";
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $total;
|
|
}
|
|
|
|
function GetProdVendBySuc(){
|
|
|
|
$sql = 'SELECT vp.* FROM ventaProducto AS vp, venta AS v
|
|
WHERE v.ventaId = vp.ventaId
|
|
AND status <> "Cancelado"
|
|
AND v.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND v.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND v.sucursalId = "'.$this->idSuc.'"
|
|
GROUP BY productoId';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$productos = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
return $productos;
|
|
}
|
|
|
|
function GetTotalProdVendBySuc(){
|
|
|
|
$sql = 'SELECT SUM(vp.cantidad) FROM ventaProducto AS vp, venta AS v
|
|
WHERE v.ventaId = vp.ventaId
|
|
AND status <> "Cancelado"
|
|
AND v.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND v.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND v.sucursalId = "'.$this->idSuc.'"
|
|
AND vp.productoId = "'.$this->productoId.'"';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $total;
|
|
}
|
|
|
|
function GetImpTotalProdVendBySuc(){
|
|
|
|
$sql = 'SELECT vp.* FROM ventaProducto AS vp, venta AS v
|
|
WHERE v.ventaId = vp.ventaId
|
|
AND status <> "Cancelado"
|
|
AND v.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND v.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND v.sucursalId = "'.$this->idSuc.'"
|
|
AND vp.productoId = "'.$this->productoId.'"';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$result = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
$total = 0;
|
|
foreach($result as $res2){
|
|
if($res2['tipoDesc'] == 'Porcentaje')
|
|
$res2['total'] -= ($res2['total'] * $res2['valDesc'] / 100);
|
|
elseif($res2['tipoDesc'] == 'Dinero')
|
|
$res2['total'] -= $res2['valDesc'];
|
|
|
|
$total += $res2['total'];
|
|
}
|
|
|
|
return $total;
|
|
}
|
|
|
|
function GetTotalProdDevBySuc(){
|
|
|
|
$sql = 'SELECT SUM(dp.cantidad) FROM devolucionProducto AS dp, venta AS v, devolucion AS d
|
|
WHERE d.ventaId = v.ventaId
|
|
AND dp.devolucionId = d.devolucionId
|
|
AND v.status <> "Cancelado"
|
|
AND v.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND v.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND v.sucursalId = "'.$this->idSuc.'"
|
|
AND dp.productoId = "'.$this->productoId.'"';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $total;
|
|
}
|
|
|
|
function GetImpTotalProdDevBySuc(){
|
|
|
|
$sql = 'SELECT SUM(dp.total) FROM devolucionProducto AS dp, venta AS v, devolucion AS d
|
|
WHERE d.ventaId = v.ventaId
|
|
AND dp.devolucionId = d.devolucionId
|
|
AND v.status <> "Cancelado"
|
|
AND v.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND v.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND v.sucursalId = "'.$this->idSuc.'"
|
|
AND dp.productoId = "'.$this->productoId.'"';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $total;
|
|
}
|
|
|
|
function GetProductosByTemp(){
|
|
|
|
$sql = 'SELECT p.* FROM venta v, ventaProducto vp, producto p
|
|
WHERE v.ventaId = vp.ventaId
|
|
AND p.productoId = vp.productoId
|
|
AND v.sucursalId = "'.$this->idSuc.'"
|
|
AND p.temporadaId = "'.$this->temporadaId.'"
|
|
GROUP BY vp.productoId';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$result = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
return $result;
|
|
}
|
|
|
|
function GetCantProdCedis(){
|
|
|
|
$sql = "SELECT SUM(pp.cantPrendas) FROM pedido p, pedidoProducto pp
|
|
WHERE p.pedidoId = pp.pedidoId
|
|
AND p.ajuste = '0'
|
|
AND p.folioProv NOT REGEXP '^FOLIO'
|
|
AND p.status = 'OrdenCompIng'
|
|
AND productoId = '".$this->productoId."'";
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $total;
|
|
}
|
|
|
|
function GetCantProdCedisBySuc(){
|
|
|
|
$sql = "SELECT SUM(pd.cantidad)
|
|
FROM pedido p, pedidoProducto pp, pedidoDistribucion pd
|
|
WHERE p.pedidoId = pp.pedidoId
|
|
AND pd.pedidoId = p.pedidoId
|
|
AND p.ajuste = '0'
|
|
AND p.folioProv NOT REGEXP '^FOLIO'
|
|
AND p.status = 'OrdenCompIng'
|
|
AND pp.productoId = '".$this->productoId."'
|
|
AND pd.productoId = '".$this->productoId."'
|
|
AND pd.sucursalId = '".$this->idSuc."'";
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $total;
|
|
}
|
|
|
|
function GetCantProdNoCedis(){
|
|
|
|
$sql = "SELECT SUM(pp.cantPrendas) FROM pedido p, pedidoProducto pp
|
|
WHERE p.pedidoId = pp.pedidoId
|
|
AND p.ajuste = '0'
|
|
AND p.folioProv NOT REGEXP '^FOLIO'
|
|
AND (p.status = 'Distribucion' OR p.status = 'Autorizado' OR p.status = 'Sugerencia' OR p.status = 'OrdenCompEnv')
|
|
AND productoId = '".$this->productoId."'";
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $total;
|
|
}
|
|
|
|
function GetCantProdNoCedisBySuc(){
|
|
|
|
$sql = "SELECT SUM(pd.cantidad)
|
|
FROM pedido p, pedidoProducto pp, pedidoDistribucion pd
|
|
WHERE p.pedidoId = pp.pedidoId
|
|
AND pd.pedidoId = p.pedidoId
|
|
AND p.ajuste = '0'
|
|
AND p.folioProv NOT REGEXP '^FOLIO'
|
|
AND (
|
|
p.status = 'Distribucion'
|
|
OR p.status = 'Autorizado'
|
|
OR p.status = 'Sugerencia'
|
|
OR p.status = 'OrdenCompEnv'
|
|
)
|
|
AND pp.productoId = '".$this->productoId."'
|
|
AND pd.productoId = '".$this->productoId."'
|
|
AND pd.sucursalId = '".$this->idSuc."'";
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $total;
|
|
}
|
|
|
|
public function VtasBySucAndProvBuenFin(){
|
|
|
|
$sql = 'SELECT SUM(vp.cantidad)
|
|
FROM venta AS v, ventaProducto AS vp, producto AS p
|
|
WHERE v.ventaId = vp.ventaId
|
|
AND vp.productoId = p.productoId
|
|
AND v.status <> "Cancelado"
|
|
AND v.status <> "Descuento"
|
|
AND vp.promocionId = "'.$this->promocionId.'"
|
|
AND v.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND v.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND v.sucursalId = "'.$this->idSuc.'"
|
|
AND p.proveedorId = "'.$this->proveedorId.'"';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$ventas = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $ventas;
|
|
}
|
|
|
|
public function CostoBySucAndProvBuenFin(){
|
|
|
|
$sql = 'SELECT SUM(vp.cantidad * p.costo)
|
|
FROM venta AS v, ventaProducto AS vp, producto AS p
|
|
WHERE v.ventaId = vp.ventaId
|
|
AND vp.productoId = p.productoId
|
|
AND v.status <> "Cancelado"
|
|
AND v.status <> "Descuento"
|
|
AND vp.promocionId = "'.$this->promocionId.'"
|
|
AND v.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND v.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND v.sucursalId = "'.$this->idSuc.'"
|
|
AND p.proveedorId = "'.$this->proveedorId.'"';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$costo = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $costo;
|
|
}
|
|
|
|
public function TotalVtasBySucAndProvBuenFin(){
|
|
|
|
$sql = 'SELECT SUM(vp.total)
|
|
FROM venta AS v, ventaProducto AS vp, producto AS p
|
|
WHERE v.ventaId = vp.ventaId
|
|
AND vp.productoId = p.productoId
|
|
AND v.status <> "Cancelado"
|
|
AND v.status <> "Descuento"
|
|
AND vp.promocionId = "'.$this->promocionId.'"
|
|
AND v.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND v.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND v.sucursalId = "'.$this->idSuc.'"
|
|
AND p.proveedorId = "'.$this->proveedorId.'"';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$ventas = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $ventas;
|
|
}
|
|
|
|
public function EnviosProdsTransito(){
|
|
|
|
$sql = 'SELECT e.envioId, e.sucursalId, ep.pedidoId, pd.sucursalId, pd.productoId, pd.cantidad
|
|
FROM envio e, envioPedido ep, pedidoDistribucion pd
|
|
WHERE e.envioId = ep.envioId
|
|
AND ep.pedidoId = pd.pedidoId
|
|
AND e.status = "Pendiente"
|
|
AND e.sucursalId = "'.$this->idSuc.'"
|
|
AND pd.sucursalId = "'.$this->idSuc.'"
|
|
AND pd.cantidad > 0
|
|
GROUP BY pd.productoId';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$envios = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
return $envios;
|
|
}
|
|
|
|
public function EnvTotalProdsTrans(){
|
|
|
|
$sql = 'SELECT SUM(pd.cantidad)
|
|
FROM envio e, envioPedido ep, pedidoDistribucion pd
|
|
WHERE e.envioId = ep.envioId
|
|
AND ep.pedidoId = pd.pedidoId
|
|
AND e.status = "Pendiente"
|
|
AND e.sucursalId = "'.$this->idSuc.'"
|
|
AND pd.sucursalId = "'.$this->idSuc.'"
|
|
AND pd.cantidad > 0
|
|
AND pd.productoId = "'.$this->productoId.'"';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $total;
|
|
}
|
|
|
|
public function DevTotalByUser(){
|
|
|
|
$sql = 'SELECT SUM(d.total)
|
|
FROM devolucion d, venta v
|
|
WHERE d.ventaId = v.ventaId
|
|
AND d.fecha >= "'.$this->fechaI.' 00:00:00"
|
|
AND d.fecha <= "'.$this->fechaF.' 23:59:59"
|
|
AND d.sucursalId = "'.$this->idSuc.'"
|
|
AND v.vendedorId = "'.$this->idUser.'"';
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$devoluciones = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
|
|
|
return $devoluciones;
|
|
}
|
|
|
|
function DevCedisProds(){
|
|
|
|
if($this->idSuc)
|
|
$sqlAdd = ' AND sucursalId = "'.$this->idSuc.'"';
|
|
|
|
$sql = 'SELECT dp.*, d.fecha FROM devolucionProdCedis dp, devolucionCedis d
|
|
WHERE dp.devCedisId = d.devCedisId
|
|
AND DATE(d.fecha) >= "'.$this->fechaIni.'"
|
|
AND DATE(d.fecha) <= "'.$this->fechaFin.'"
|
|
'.$sqlAdd;
|
|
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
|
$productos = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
|
|
|
return $productos;
|
|
}
|
|
|
|
}//Reportes
|
|
|
|
?>
|