Primer commit del sistema avantika sin cambios
This commit is contained in:
364
classes/evaluaPedido.class.php
Executable file
364
classes/evaluaPedido.class.php
Executable file
@@ -0,0 +1,364 @@
|
||||
<?php
|
||||
|
||||
class EvaluaPedido extends Main
|
||||
{
|
||||
private $pedidoId;
|
||||
private $pedidoPagoId;
|
||||
private $metodoPagoId;
|
||||
private $cuentaBancariaId;
|
||||
private $proveedorId;
|
||||
private $cantidad;
|
||||
private $fecha;
|
||||
private $noCheque;
|
||||
private $noFactura;
|
||||
private $status;
|
||||
private $plazo;
|
||||
private $bonificacion;
|
||||
private $prodItemId;
|
||||
private $productoId;
|
||||
|
||||
public function setProductoId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->productoId = $value;
|
||||
}
|
||||
|
||||
public function setBonificacion($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->bonificacion = $value;
|
||||
}
|
||||
|
||||
public function setPlazo($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->plazo = $value;
|
||||
}
|
||||
|
||||
public function setPedidoPagoId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->pedidoPagoId = $value;
|
||||
}
|
||||
|
||||
public function setPedidoId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->pedidoId = $value;
|
||||
}
|
||||
|
||||
public function setProdItemId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->prodItemId = $value;
|
||||
}
|
||||
|
||||
public function setMetodoPagoId($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Método de Pago');
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->metodoPagoId = $value;
|
||||
}
|
||||
|
||||
public function setCuentaBancariaId($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Cuenta Bancaria');
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->cuentaBancariaId = $value;
|
||||
}
|
||||
|
||||
public function setProveedorId($value)
|
||||
{
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->proveedorId = $value;
|
||||
}
|
||||
|
||||
public function setCantidad($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Cantidad');
|
||||
$this->cantidad = $value;
|
||||
}
|
||||
|
||||
public function setFecha($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Fecha');
|
||||
$this->fecha = $value;
|
||||
}
|
||||
|
||||
public function setNoCheque($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 0, 'No. de Cheque');
|
||||
$this->Util()->ValidateInteger($value);
|
||||
$this->noCheque = $value;
|
||||
}
|
||||
|
||||
public function setNoFactura($value)
|
||||
{
|
||||
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'No. de Factura');
|
||||
$this->noFactura = $value;
|
||||
}
|
||||
|
||||
public function setStatus($value)
|
||||
{
|
||||
$this->status = $value;
|
||||
}
|
||||
|
||||
public function InfoPago(){
|
||||
|
||||
$sql = 'SELECT * FROM pedidoPago
|
||||
WHERE pedidoPagoId = "'.$this->pedidoPagoId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
function Enumerate()
|
||||
{
|
||||
$sql = "SELECT * FROM pedido LEFT JOIN proveedor ON(proveedor.proveedorId = pedido.proveedorId) WHERE pedido.`status` LIKE 'EnvSuc' OR pedido.`status` LIKE 'OrdenCompIng'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
$pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/evaluar-pedidos");
|
||||
|
||||
//$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
|
||||
|
||||
$sql = "SELECT * FROM pedido LEFT JOIN proveedor ON(proveedor.proveedorId = pedido.proveedorId) WHERE pedido.`status` LIKE 'EnvSuc' OR pedido.`status` LIKE 'OrdenCompIng' ORDER BY `pedido`.`proveedorId`, pedido.fechaOrdenCompIng ASC ";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
$data["items"] = $result;
|
||||
$data["pages"] = $pages;
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
function EnumPagos(){
|
||||
|
||||
$sql = 'SELECT * FROM pedidoPago
|
||||
WHERE pedidoId = "'.$this->pedidoId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$pagos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
|
||||
|
||||
return $pagos;
|
||||
}
|
||||
|
||||
function GetTotalPagos(){
|
||||
|
||||
$sql = 'SELECT SUM(cantidad) FROM pedidoPago
|
||||
WHERE pedidoId = "'.$this->pedidoId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
function SavePago()
|
||||
{
|
||||
if($this->Util()->PrintErrors()){ return false; }
|
||||
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("
|
||||
INSERT INTO `pedidoPago` (
|
||||
pedidoId,
|
||||
metodoPagoId,
|
||||
cuentaBancariaId,
|
||||
proveedorId,
|
||||
cantidad,
|
||||
fecha,
|
||||
noCheque,
|
||||
noFactura
|
||||
)
|
||||
VALUES (
|
||||
'".$this->pedidoId."',
|
||||
'".$this->metodoPagoId."',
|
||||
'".$this->cuentaBancariaId."',
|
||||
'".$this->proveedorId."',
|
||||
'".$this->cantidad."',
|
||||
'".$this->fecha."',
|
||||
'".$this->noCheque."',
|
||||
'".$this->noFactura."'
|
||||
)"
|
||||
);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->InsertData();
|
||||
|
||||
$this->Util()->setError(30057, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function DeletePago(){
|
||||
|
||||
$sql = "DELETE FROM
|
||||
pedidoPago
|
||||
WHERE
|
||||
pedidoPagoId = '".$this->pedidoPagoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
|
||||
|
||||
$this->Util()->setError(30059, "complete");
|
||||
$this->Util()->PrintErrors();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getTotalVentas()
|
||||
{
|
||||
$sql = 'SELECT SUM(producto.precioVentaIva) FROM producto LEFT JOIN inventario ON(inventario.productoId = producto.productoId) WHERE inventario.status LIKE "Vendido" AND pedidoId = "'.$this->pedidoId.'" GROUP BY pedidoId';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
/* public function getTotalVendidos2()
|
||||
{
|
||||
$sql = 'SELECT COUNT(*) FROM pedido LEFT JOIN inventario ON(inventario.pedidoId = pedido.pedidoId) LEFT JOIN producto ON(producto.productoId = inventario.productoId) WHERE pedido.pedidoId = 2 AND inventario.status = "Vendido" AND pedido.pedidoId = "'.$this->pedidoId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
public function getTotalProductos()
|
||||
{
|
||||
$sql = 'SELECT COUNT(*) FROM pedido LEFT JOIN inventario ON(inventario.pedidoId = pedido.pedidoId) LEFT JOIN producto ON(producto.productoId = inventario.productoId) WHERE pedido.pedidoId = 2 AND pedido.pedidoId = "'.$this->pedidoId.'"';
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}*/
|
||||
|
||||
public function evaluar()
|
||||
{
|
||||
$opc = false;
|
||||
|
||||
$diasTranscurridos = round($this->Util()->GetDiffDates($this->fecha,$this->Util()->Today()));
|
||||
//echo $diasTranscurridos."<br>";
|
||||
|
||||
if(($diasTranscurridos >= ($this->plazo/2) && $diasTranscurridos < ($this->plazo)))
|
||||
$opc = true;
|
||||
return $opc;
|
||||
}
|
||||
|
||||
public function evaluar2()
|
||||
{
|
||||
$opc = false;
|
||||
|
||||
$diasTranscurridos = round($this->Util()->GetDiffDates($this->fecha,$this->Util()->Today()));
|
||||
//echo $diasTranscurridos."<br>";
|
||||
|
||||
if($diasTranscurridos >= $this->plazo)
|
||||
$opc = true;
|
||||
return $opc;
|
||||
}
|
||||
|
||||
public function evaluarVentas()
|
||||
{
|
||||
@$porcentajeVendidos = round(($this->getTotalVendidos()*100)/$this->GetTotalProductosPedido());
|
||||
return $porcentajeVendidos;
|
||||
}
|
||||
|
||||
function searchProductos()
|
||||
{
|
||||
$sql = 'SELECT * FROM producto LEFT JOIN pedidoProducto ON(pedidoProducto.productoId = producto.productoId) LEFT JOIN pedido ON(pedido.pedidoId = pedidoProducto.pedidoId) WHERE pedido.pedidoId = '.$this->pedidoId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$productos = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $productos;
|
||||
}
|
||||
|
||||
function GetTotalVendidos()
|
||||
{
|
||||
$totalVendidos = $this->GetTotalProductosPedido()-$this->GetDisponible();
|
||||
return $totalVendidos;
|
||||
}
|
||||
|
||||
function GetTotalProductosPedido()
|
||||
{
|
||||
$sql = "SELECT
|
||||
SUM(cantidad)
|
||||
FROM
|
||||
inventario
|
||||
WHERE
|
||||
pedidoId = '".$this->pedidoId."'
|
||||
AND
|
||||
productoId = '".$this->productoId."'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
function GetDisponible(){
|
||||
|
||||
$sql = "SELECT
|
||||
SUM(cantidad)
|
||||
FROM
|
||||
inventario
|
||||
WHERE
|
||||
pedidoId = '".$this->pedidoId."'
|
||||
AND
|
||||
productoId = '".$this->productoId."'
|
||||
AND
|
||||
`status` = 'Disponible'";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
function InfoPedidoProveedor()
|
||||
{
|
||||
$sql = "SELECT * FROM pedido LEFT JOIN proveedor ON(proveedor.proveedorId = pedido.proveedorId) WHERE pedido.pedidoId = ".$this->pedidoId." ORDER BY `pedido`.`proveedorId`, pedido.fechaEntrega ASC ";
|
||||
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
|
||||
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
function searchProductoById()
|
||||
{
|
||||
$sql = 'SELECT * FROM producto LEFT JOIN pedidoProducto ON(pedidoProducto.productoId = producto.productoId) LEFT JOIN pedido ON(pedido.pedidoId = pedidoProducto.pedidoId) LEFT JOIN productoItem ON(productoItem.productoId = producto.productoId) WHERE pedido.pedidoId = '.$this->pedidoId.' AND prodItemId = '.$this->prodItemId;
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$producto = $this->Util()->DBSelect($_SESSION['empresaId'])->GetRow();
|
||||
|
||||
return $producto;
|
||||
}
|
||||
|
||||
function ActualizaPendientes()
|
||||
{
|
||||
$sql = 'DELETE FROM bonificacion WHERE estatus LIKE "Pendiente"';
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$producto = $this->Util()->DBSelect($_SESSION['empresaId'])->DeleteData();
|
||||
}
|
||||
|
||||
function GetPedidos()
|
||||
{
|
||||
$sql = "SELECT bonificacion.pedidoId, proveedor.nombre, bonificacion.proveedorId, bonificacion.estatus FROM bonificacion LEFT JOIN proveedor ON(proveedor.proveedorId = bonificacion.proveedorId) GROUP BY pedidoId ORDER BY pedidoId";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$pedidos = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
|
||||
|
||||
return $pedidos;
|
||||
}
|
||||
|
||||
function getTotalBonificaciones()
|
||||
{
|
||||
$sql = "SELECT SUM(totalBonificacion) FROM bonificacion WHERE pedidoId = '".$this->pedidoId."' AND tipo LIKE 'Bonificacion'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
|
||||
function getTotalDevoluciones()
|
||||
{
|
||||
$sql = "SELECT SUM(totalBonificacion) FROM bonificacion WHERE pedidoId = '".$this->pedidoId."' AND tipo LIKE 'Devolucion'";
|
||||
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
|
||||
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
|
||||
|
||||
return $total;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user