Files
ventas_php/classes/pedido.class.php

1902 lines
46 KiB
PHP
Executable File

<?php
class Pedido extends Main
{
private $pedidoId;
private $pedProdId;
private $proveedorId;
private $noPedido;
private $folioProv;
private $fecha;
private $fechaEntrega;
private $fechaEntregaF;
private $metodoCompra;
private $resurtido;
private $frecuente;
private $subtotal;
private $iva;
private $total;
private $pagado;
private $status;
private $usuarioId;
private $productoId;
private $prodCatId;
private $prodSubcatId;
private $totalLote;
private $cantLotes;
private $cantPrendas;
private $prendasComp;
private $prendasRec;
private $costo;
private $precioVenta;
private $tallaId;
private $colorId;
private $cantidad;
private $motivoId;
private $otroMotivo;
private $sucursalId;
private $pedDistId;
private $usuario;
private $fechaFolio;
private $cajas;
private $prendas;
private $porcPub;
private $porcFlete;
private $porcDes;
private $porcEsp;
private $totalPub;
private $totalFlete;
private $totalDes;
private $totalEsp;
private $totalDesc;
private $ajuste;
private $recibido;
private $fechaEntExp;
public function setAjuste($value)
{
$this->Util()->ValidateInteger($value);
$this->ajuste = $value;
}
public function setCajas($value)
{
$this->cajas = $value;
}
public function setFechaFolio($value)
{
$this->Util()->ValidateString($value[0], $max_chars=50, $minChars = 0, 'Fecha de Folio');
$this->fechaFolio = $value;
}
public function setPedidoId($value)
{
$this->Util()->ValidateInteger($value);
$this->pedidoId = $value;
}
public function setPedProdId($value)
{
$this->Util()->ValidateInteger($value);
$this->pedProdId = $value;
}
public function setProveedorId($value)
{
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Proveedor');
$this->proveedorId = $value;
}
public function setFolioProv($value)
{
$this->Util()->ValidateString($value[0], $max_chars=50, $minChars = 0, 'Folio del Proveedor');
$this->folioProv = $value;
}
public function setNoPedido($value)
{
$this->Util()->ValidateInteger($value);
$this->noPedido = $value;
}
public function setFecha($value)
{
$this->fecha = $value;
}
public function setFechaEntrega($value)
{
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Fecha de Entrega Inicial');
$this->fechaEntrega = $value;
}
public function setFechaEntregaF($value)
{
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Fecha de Entrega Final');
$this->fechaEntregaF = $value;
}
public function setMetodoCompra($value)
{
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'M&eacute;todo de Compra');
$this->metodoCompra = $value;
}
public function setResurtido($value)
{
$this->resurtido = $value;
}
public function setFrecuente($value)
{
$this->frecuente = $value;
}
public function setSubtotal($value)
{
$this->subtotal = $value;
}
public function setIva($value)
{
$this->iva = $value;
}
public function setTotal($value)
{
$this->total = $value;
}
public function setPagado($value)
{
$this->Util()->ValidateInteger($value);
$this->pagado = $value;
}
public function setStatus($value)
{
$this->status = $value;
}
public function setUsuarioId($value)
{
$this->usuarioId = $value;
}
public function setProductoId($value)
{
$this->productoId = $value;
}
public function setProdCatId($value)
{
$this->prodCatId = $value;
}
public function setProdSubcatId($value)
{
$this->prodSubcatId = $value;
}
public function setTotalLote($value)
{
$this->totalLote = $value;
}
public function setCantLotes($value)
{
$this->cantLotes = $value;
}
public function setCantPrendas($value)
{
$this->cantPrendas = $value;
}
public function setPrendasComp($value)
{
$this->prendasComp = $value;
}
public function setPrendasRec($value)
{
$this->prendasRec = $value;
}
public function setCosto($value)
{
$this->costo = $value;
}
public function setPrecioVenta($value)
{
$this->precioVenta = $value;
}
public function setTallaId($value)
{
$this->tallaId = $value;
}
public function setColorId($value)
{
$this->colorId = $value;
}
public function setCantidad($value)
{
$this->cantidad = $value;
}
public function setMotivoId($value)
{
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Motivo');
$this->motivoId = $value;
}
public function setOtroMotivo($value)
{
$this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, 'Otro Motivo');
$this->otroMotivo = $value;
}
public function setSucursalId($value)
{
$this->Util()->ValidateInteger($value);
$this->sucursalId = $value;
}
public function setPedDistId($value)
{
$this->Util()->ValidateInteger($value);
$this->pedDistId = $value;
}
public function setUsuario($value)
{
$this->usuario = $value;
}
public function setPorcPub($value)
{
$this->Util()->ValidateInteger($value);
$this->porcPub = $value;
}
public function setPorcFlete($value)
{
$this->Util()->ValidateInteger($value);
$this->porcFlete = $value;
}
public function setPorcDes($value)
{
$this->Util()->ValidateInteger($value);
$this->porcDes = $value;
}
public function setPorcEsp($value)
{
$this->Util()->ValidateInteger($value);
$this->porcEsp = $value;
}
public function setTotalPub($value)
{
$this->totalPub = $value;
}
public function setTotalFlete($value)
{
$this->totalFlete = $value;
}
public function setTotalDes($value)
{
$this->totalDes = $value;
}
public function setTotalEsp($value)
{
$this->totalEsp = $value;
}
public function setTotalDesc($value)
{
$this->totalDesc = $value;
}
public function setPrendas($value)
{
$this->prendas = $value;
}
public function setRecibido($value)
{
$this->recibido = $value;
}
public function setFechaEntExp($value)
{
$this->fechaEntExp = $value;
}
public function Info()
{
$sql = 'SELECT
*
FROM
pedido
WHERE
pedidoId = "'.$this->pedidoId.'"';
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
$info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow();
return $info;
}
function Enumerate2()
{
$sql = "SELECT COUNT(*) FROM pedido
WHERE ajuste = '0'
AND folioProv NOT REGEXP '^FOLIO'";
$db = $this->Util()->DBSelect($_SESSION["empresaId"]);
$db->setQuery($sql);
$total = $db->GetSingle();
$pages = $this->Util()->HandleMultipages($this->page, $total ,WEB_ROOT."/pedidos", "pedidos");
$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
$sql = "SELECT *
FROM pedido WHERE ajuste = '0'
AND folioProv NOT REGEXP '^FOLIO'
ORDER BY fecha DESC ".$sqlAdd;
$db->setQuery($sql);
$result = $db->GetResult();
$data["items"] = $result;
$data["pages"] = $pages;
return $data;
}//Enumerate
function Enumerate()
{
$sql = "SELECT COUNT(*) FROM pedido WHERE ajuste = '0'";
$db = $this->Util()->DBSelect($_SESSION["empresaId"]);
$db->setQuery($sql);
$total = $db->GetSingle();
$pages = $this->Util()->HandleMultipages($this->page, $total ,WEB_ROOT."/pedidos", "pedidos");
$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
$sql = "SELECT *
FROM pedido WHERE ajuste = '0'
ORDER BY fecha DESC ".$sqlAdd;
$db->setQuery($sql);
$result = $db->GetResult();
$data["items"] = $result;
$data["pages"] = $pages;
return $data;
}//Enumerate
function EnumByStatus($orden = 'DESC')
{
$sql = "SELECT COUNT(*) FROM pedido WHERE status = '".$this->status."'";
$db = $this->Util()->DBSelect($_SESSION["empresaId"]);
$db->setQuery($sql);
$total = $db->GetSingle();
$pages = $this->Util()->HandleMultipages($this->page, $total ,WEB_ROOT."/pedidos", "pedidos");
$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
$sql = "SELECT *
FROM pedido
WHERE status = '".$this->status."'
ORDER BY fecha ".$orden." ".$sqlAdd;
$db->setQuery($sql);
$result = $db->GetResult();
$data["items"] = $result;
$data["pages"] = $pages;
return $data;
}//EnumByStatus
function EnumByStatus2($orden = 'DESC')
{
$sql = "SELECT *
FROM pedido
WHERE status = '".$this->status."'
ORDER BY fecha ".$orden;
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
$data["items"] = $result;
$data["pages"] = $pages;
return $data;
}//EnumByStatus2
function EnumParciales($orden = 'DESC')
{
$sql = "SELECT *
FROM pedido
WHERE status = 'OrdenCompIng' OR status = 'OrdenCompIngP'
ORDER BY fecha ".$orden;
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
$data["items"] = $result;
$data["pages"] = $pages;
return $data;
}//EnumParciales
function EnumConciliaciones($orden = 'DESC')
{
$sql = "SELECT COUNT(*) FROM pedido WHERE status = 'EnvSuc'";
$db = $this->Util()->DBSelect($_SESSION["empresaId"]);
$db->setQuery($sql);
$total = $db->GetSingle();
$pages = $this->Util()->HandleMultipages($this->page, $total ,WEB_ROOT."/conciliaciones", "conciliaciones");
$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
$sql = "SELECT *
FROM pedido
WHERE status = 'EnvSuc'
ORDER BY fecha ".$orden." ".$sqlAdd;
$db->setQuery($sql);
$result = $db->GetResult();
$data["items"] = $result;
$data["pages"] = $pages;
return $data;
}//EnumConciliaciones
function EnumAlmacen()
{
$sql = "SELECT COUNT(*) FROM pedido
WHERE status = 'OrdenCompEnv'
OR status = 'OrdenCompIng'
OR status = 'EnvSuc'";
$db = $this->Util()->DBSelect($_SESSION["empresaId"]);
$db->setQuery($sql);
$total = $db->GetSingle();
$pages = $this->Util()->HandleMultipages($this->page, $total ,WEB_ROOT."/pedidos", "pedidos");
$sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"];
$sql = "SELECT *
FROM pedido
WHERE status = 'OrdenCompEnv'
OR status = 'OrdenCompIng'
OR status = 'EnvSuc'
ORDER BY fecha DESC ".$sqlAdd;
$db->setQuery($sql);
$result = $db->GetResult();
$data["items"] = $result;
$data["pages"] = $pages;
return $data;
}//EnumAlmacen
function Search()
{
$sqlAdd = '';
if($this->proveedorId)
$sqlAdd .= ' AND proveedorId = "'.$this->proveedorId.'"';
if($this->metodoCompra)
$sqlAdd .= ' AND metodoCompra = "'.$this->metodoCompra.'"';
if($this->status)
$sqlAdd .= ' AND status = "'.$this->status.'"';
if($this->resurtido != '')
$sqlAdd .= ' AND resurtido = "'.$this->resurtido.'"';
if($this->noPedido)
$sqlAdd .= ' AND noPedido = "'.$this->noPedido.'"';
if($this->fecha)
$sqlAdd .= ' AND DATE(fecha) = "'.$this->fecha.'"';
if($this->ajuste)
$sqlAdd .= ' AND ajuste = "'.$this->ajuste.'"';
else
$sqlAdd .= " AND folioProv NOT REGEXP '^FOLIO'";
$sql = "SELECT *
FROM pedido
WHERE 1 ".$sqlAdd."
ORDER BY fecha DESC";
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
$pedidos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
return $pedidos;
}//Search
function SaveTemp(){
if($this->Util()->PrintErrors()){
return false;
}
return true;
}
function Save(){
if($this->Util()->PrintErrors()){
return false;
}
$sql = "INSERT INTO pedido (
proveedorId,
noPedido,
fecha,
fechaEntrega,
fechaEntregaF,
metodoCompra,
resurtido,
status,
usuarioId,
porcPub,
porcFlete,
porcDes,
porcEsp
)
VALUES (
'".$this->proveedorId."',
'".$this->noPedido."',
'".$this->fecha."',
'".$this->fechaEntrega."',
'".$this->fechaEntregaF."',
'".$this->metodoCompra."',
'".$this->resurtido."',
'".$this->status."',
'".$this->usuarioId."',
'".$this->porcPub."',
'".$this->porcFlete."',
'".$this->porcDes."',
'".$this->porcEsp."'
)";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$pedidoId = $this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
$this->Util()->setError(30045, 'complete');
$this->Util()->PrintErrors();
return $pedidoId;
}//Save
function Update(){
if($this->Util()->PrintErrors()){
return false;
}
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
UPDATE pedido SET
fechaEntrega = '".$this->fechaEntrega."',
fechaEntregaF = '".$this->fechaEntregaF."',
metodoCompra = '".$this->metodoCompra."',
porcPub = '".$this->porcPub."',
porcFlete = '".$this->porcFlete."',
porcDes = '".$this->porcDes."',
porcEsp = '".$this->porcEsp."'
WHERE
pedidoId = '".$this->pedidoId."'"
);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
$this->Util()->setError(30046, "complete");
$this->Util()->PrintErrors();
return true;
}//Update
function UpdateFolios($sqlAdd){
if($this->Util()->PrintErrors()){
return false;
}
$sql = "UPDATE pedido SET ".$sqlAdd."
WHERE pedidoId = '".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
return true;
}//UpdateFolios
function Delete(){
$sql = "DELETE FROM
pedido
WHERE
pedidoId = '".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
$sql = "DELETE FROM
pedidoProducto
WHERE
pedidoId = '".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
$sql = "DELETE FROM
pedidoTalla
WHERE
pedidoId = '".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
$sql = "DELETE FROM
pedidoColor
WHERE
pedidoId = '".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
$sql = "DELETE FROM
pedidoDistribucion
WHERE
pedidoId = '".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
$sql = "DELETE FROM
pedidoSugerencia
WHERE
pedidoId = '".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
$this->Util()->setError(30047, "complete");
$this->Util()->PrintErrors();
return true;
}//Delete
function UpdateFrecuente(){
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
UPDATE pedido SET
frecuente = '".$this->frecuente."'
WHERE
pedidoId = '".$this->pedidoId."'"
);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
return true;
}//UpdateFrecuente
function UpdateStatus(){
$sql = "UPDATE pedido SET
status = '".$this->status."'
WHERE
pedidoId = '".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
return true;
}//UpdateStatus
function UpdateTotales(){
if($this->Util()->PrintErrors()){
return false;
}
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
UPDATE pedido SET
subtotal = '".$this->subtotal."',
iva = '".$this->iva."',
total = '".$this->total."',
totalDesc = '".$this->totalDesc."',
totalPub = '".$this->totalPub."',
totalFlete = '".$this->totalFlete."',
totalDes = '".$this->totalDes."',
totalEsp = '".$this->totalEsp."'
WHERE
pedidoId = '".$this->pedidoId."'"
);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
return true;
}//UpdateTotales
function UpdateTotales2(){
if($this->Util()->PrintErrors()){
return false;
}
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
UPDATE pedido SET
subtotal2 = '".$this->subtotal."',
iva2 = '".$this->iva."',
total2 = '".$this->total."',
totalDesc = '".$this->totalDesc."',
totalPub = '".$this->totalPub."',
totalFlete = '".$this->totalFlete."',
totalDes = '".$this->totalDes."',
totalEsp = '".$this->totalEsp."'
WHERE
pedidoId = '".$this->pedidoId."'"
);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
return true;
}//UpdateTotales2
function GetNextNoPedido(){
$sql = "SELECT MAX(noPedido) FROM
pedido";
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
$noPedido = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle();
$noPedido++;
return $noPedido;
}//GetNextNoPedido
//PRODUCTOS
function SaveProducto(){
$sql = "INSERT INTO pedidoProducto (
pedidoId,
productoId,
prodCatId,
prodSubcatId,
totalLote,
cantLotes,
cantPrendas,
costo,
precioVenta
)
VALUES (
'".$this->pedidoId."',
'".$this->productoId."',
'".$this->prodCatId."',
'".$this->prodSubcatId."',
'".$this->totalLote."',
'".$this->cantLotes."',
'".$this->cantPrendas."',
'".$this->costo."',
'".$this->precioVenta."'
)";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$pedProdId = $this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
return $pedProdId;
}//SaveProducto
function SaveTalla(){
$sql = "INSERT INTO pedidoTalla (
pedidoId,
productoId,
tallaId,
cantidad
)
VALUES (
'".$this->pedidoId."',
'".$this->productoId."',
'".$this->tallaId."',
'".$this->cantidad."'
)";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
return true;
}//SaveTalla
function SaveColor(){
$sql = "INSERT INTO pedidoColor (
pedidoId,
productoId,
colorId,
cantidad
)
VALUES (
'".$this->pedidoId."',
'".$this->productoId."',
'".$this->colorId."',
'".$this->cantidad."'
)";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
return true;
}//SaveColor
function GetProductos(){
$sql = "SELECT * FROM pedidoProducto
WHERE pedidoId ='".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$productos = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
return $productos;
}//GetProductos
function GetProdsNoRec(){
$sql = "SELECT * FROM pedidoProducto
WHERE recibido = '0'
AND pedidoId ='".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$productos = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
return $productos;
}//GetProductos
function GetProdsDistribucion(){
$sql = "SELECT * FROM pedidoDistribucion
WHERE pedidoId ='".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$productos = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
return $productos;
}//GetProdsDistribucion
function GetDistSug(){
$sql = "SELECT * FROM pedidoSugerencia
WHERE pedidoId = '".$this->pedidoId."'
AND productoId = '".$this->productoId."'
AND usuario = '".$this->usuario."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$productos = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
return $productos;
}//GetDistSug
function GetProporcionByTalla(){
$sql = "SELECT cantidad FROM pedidoTalla
WHERE pedidoId ='".$this->pedidoId."'
AND productoId ='".$this->productoId."'
AND tallaId ='".$this->tallaId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$cantidad = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
return $cantidad;
}
function GetTallasByProd(){
$sql = "SELECT * FROM pedidoTalla
WHERE pedidoId ='".$this->pedidoId."'
AND productoId ='".$this->productoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$tallas = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
return $tallas;
}
function GetProporcionByColor(){
$sql = "SELECT cantidad FROM pedidoColor
WHERE pedidoId ='".$this->pedidoId."'
AND productoId ='".$this->productoId."'
AND colorId ='".$this->colorId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$cantidad = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
return $cantidad;
}
function GetColoresByProd(){
$sql = "SELECT * FROM pedidoColor
WHERE pedidoId ='".$this->pedidoId."'
AND productoId ='".$this->productoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$colores = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
return $colores;
}
function DeleteProductos(){
$sql = "DELETE FROM
pedidoProducto
WHERE
pedidoId = '".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
$sql = "DELETE FROM
pedidoTalla
WHERE
pedidoId = '".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
$sql = "DELETE FROM
pedidoColor
WHERE
pedidoId = '".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
$sql = "DELETE FROM
pedidoDistribucion
WHERE
pedidoId = '".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
$sql = "DELETE FROM
pedidoSugerencia
WHERE
pedidoId = '".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
return true;
}//DeleteProductos
function Aprobar(){
if($this->Util()->PrintErrors()){
return false;
}
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
UPDATE pedido SET
fechaAprobacion = '".date('Y-m-d H:i:s')."',
userIdAprobacion = '".$this->usuarioId."',
status = 'Aprobado'
WHERE
pedidoId = '".$this->pedidoId."'"
);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
return true;
}//Aprobar
function Autorizar(){
if($this->Util()->PrintErrors()){
return false;
}
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
UPDATE pedido SET
fechaAutorizacion = '".date('Y-m-d H:i:s')."',
userIdAutorizacion = '".$this->usuarioId."',
status = 'Autorizado'
WHERE
pedidoId = '".$this->pedidoId."'"
);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
return true;
}//Autorizar
function Sugerir(){
if($this->Util()->PrintErrors()){
return false;
}
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
UPDATE pedido SET
fechaSugerencia = '".date('Y-m-d H:i:s')."',
userIdSugerencia = '".$this->usuarioId."',
status = 'Sugerencia'
WHERE
pedidoId = '".$this->pedidoId."'"
);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
return true;
}//Sugerir
function Rechazar(){
if($this->Util()->PrintErrors()){
return false;
}
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
UPDATE pedido SET
fechaRechazo = '".date('Y-m-d H:i:s')."',
userIdRechazo = '".$this->usuarioId."',
motivoId = '".$this->motivoId."',
otroMotivo = '".utf8_decode($this->otroMotivo)."',
status = 'Rechazado'
WHERE
pedidoId = '".$this->pedidoId."'"
);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
return true;
}//Rechazar
function Distribucion(){
if($this->Util()->PrintErrors()){
return false;
}
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
UPDATE pedido SET
fechaDistribucion = '".date('Y-m-d H:i:s')."',
userIdDistribucion = '".$this->usuarioId."',
status = 'Distribucion'
WHERE
pedidoId = '".$this->pedidoId."'"
);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
return true;
}//Distribucion
function EnviarOrdenCompra(){
if($this->Util()->PrintErrors()){
return false;
}
$sql = "
UPDATE pedido SET
fechaOrdenCompEnv = '".date('Y-m-d H:i:s')."',
userIdOrdenCompEnv = '".$this->usuarioId."',
status = 'OrdenCompEnv'
WHERE
pedidoId = '".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
return true;
}//EnviarOrdenCompra
function CancelarOrdenCompraEnv(){
if($this->Util()->PrintErrors()){
return false;
}
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
UPDATE pedido SET
fechaOrdenCompEnvCan = '".date('Y-m-d H:i:s')."',
userIdOrdenCompEnvCan = '".$this->usuarioId."',
status = 'OrdenCompEnvCan'
WHERE
pedidoId = '".$this->pedidoId."'"
);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
return true;
}//CancelarOrdenCompraEnv
function ContinuarPedido(){
if($this->Util()->PrintErrors()){
return false;
}
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
UPDATE pedido SET
fechaOrdenCompEnvCan = '0000-00-00 00:00:00',
userIdOrdenCompEnvCan = '0',
status = 'OrdenCompEnv'
WHERE
pedidoId = '".$this->pedidoId."'"
);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
return true;
}//ContinuarPedido
function IngresarOrdenCompra(){
if($this->Util()->PrintErrors()){
return false;
}
$arrayCampoFolio = array("`folioProv`","`folioProv2`","`folioProv3`","`folioProv4`","`folioProv5`");
$arrayCampoFechaFolio = array("`fechaFolio`","`fechaFolio2`","`fechaFolio3`","`fechaFolio4`","`fechaFolio5`");
$updateFoliosFechas = "";
foreach($this->fechaFolio as $key => $resFechaFolio)
{
if(trim($resFechaFolio) != '')
$this->fechaFolio[$key] = date('Y-m-d',strtotime($resFechaFolio));
$updateFoliosFechas .= $arrayCampoFolio[$key]." = '".$this->folioProv[$key]."', ".$arrayCampoFechaFolio[$key]." = '".$this->fechaFolio[$key]."',";
}
$updateFoliosFechas = trim($updateFoliosFechas,",");
$infP = $this->Info();
if($infP['status'] != 'OrdenCompIngP'){
$sqlAdd = "fechaOrdenCompIng = '".date('Y-m-d H:i:s')."',
userIdOrdenCompIng = '".$this->usuarioId."',";
}
$sql = "UPDATE pedido SET status = 'OrdenCompIng',".$sqlAdd.$updateFoliosFechas."
WHERE pedidoId = '".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
foreach($this->cajas as $key => $resCajas)
{
$sql = "
UPDATE pedidoDistribucion SET
cajas = '".$resCajas['cantidad']."'
WHERE
pedDistId = '".$resCajas['pedDistId']."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
}
foreach($this->prendas as $key => $resPrendas)
{
$sql = "
UPDATE pedidoDistribucion SET
prendas = '".$resPrendas['cantidad']."'
WHERE
pedDistId = '".$resPrendas['pedDistId']."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
}
return true;
}//IngresarOrdenCompra
function UpdatePedProd(){
$sql = "
UPDATE pedidoProducto SET
prendasComp = '".$this->prendasComp."',
prendasRec = '".$this->prendasRec."',
recibido = '".$this->recibido."',
fechaRecibido = '".date('Y-m-d H:i:s')."'
WHERE
pedProdId = '".$this->pedProdId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
return true;
}//UpdatePedProd
function SaveDistribucion(){
$sql = "INSERT INTO pedidoDistribucion (
pedidoId,
productoId,
sucursalId,
cantidad,
status
)
VALUES (
'".$this->pedidoId."',
'".$this->productoId."',
'".$this->sucursalId."',
'".$this->cantidad."',
'Pendiente'
)";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
return true;
}//SaveDistribucion
function UpdateDistribucion(){
$sql = "UPDATE pedidoDistribucion SET cantidad = '".$this->cantidad."'
WHERE pedidoId = '".$this->pedidoId."'
AND productoId = '".$this->productoId."'
AND sucursalId = '".$this->sucursalId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
return true;
}//UpdateDistribucion
function UpdateDistByProd(){
$sql = "UPDATE pedidoDistribucion SET cantidad = '".$this->cantidad."'
WHERE pedidoId = '".$this->pedidoId."'
AND productoId = '".$this->productoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData();
return true;
}//UpdateDistByProd
function SaveSugerencia(){
$sql = "INSERT INTO pedidoSugerencia (
pedDistId,
pedidoId,
productoId,
sucursalId,
cantidad,
usuario
)
VALUES (
'".$this->pedDistId."',
'".$this->pedidoId."',
'".$this->productoId."',
'".$this->sucursalId."',
'".$this->cantidad."',
'".$this->usuario."'
)";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
return true;
}//SaveSugerencia
function DeleteSugerencia(){
$sql = "DELETE FROM pedidoSugerencia
WHERE pedidoId = '".$this->pedidoId."'
AND productoId = '".$this->productoId."'
AND usuario = '".$this->usuario."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION['empresaId'])->DeleteData();
return true;
}//DeleteSugerencia
function DeleteDistribucion(){
$sql = "DELETE FROM pedidoDistribucion
WHERE pedidoId = '".$this->pedidoId."'
AND productoId = '".$this->productoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION['empresaId'])->DeleteData();
return true;
}//DeleteDistribucion
function GetInfoProd(){
$sql = "SELECT * FROM pedidoProducto
WHERE pedidoId = '".$this->pedidoId."'
AND productoId = '".$this->productoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$info = $this->Util()->DBSelect($_SESSION['empresaId'])->GetRow();
return $info;
}//GetInfoProd
function GetInfoStatusProd(){
$sql = "SELECT status FROM pedidoProducto
WHERE pedidoId = '".$this->pedidoId."'
AND productoId = '".$this->productoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$status = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
return $status;
}//GetInfoStatusProd
function GetInfoProdSug(){
$sql = "SELECT * FROM pedidoSugerencia
WHERE pedidoId = '".$this->pedidoId."'
AND sucursalId = '".$this->sucursalId."'
AND productoId = '".$this->productoId."'
AND usuario = '".$this->usuario."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$info = $this->Util()->DBSelect($_SESSION['empresaId'])->GetRow();
return $info;
}//GetInfoProdSug
function GetInfoCantProdSug(){
$sql = "SELECT cantidad FROM pedidoSugerencia
WHERE pedidoId = '".$this->pedidoId."'
AND sucursalId = '".$this->sucursalId."'
AND productoId = '".$this->productoId."'
AND usuario = '".$this->usuario."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$cantidad = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
return $cantidad;
}//GetInfoCantProdSug
function UpdateStatusProd(){
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
UPDATE pedidoProducto SET
status = '".$this->status."'
WHERE
productoId = '".$this->productoId."'
AND
pedidoId = '".$this->pedidoId."'"
);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
return true;
}//UpdateStatusProd
function GetSucursales(){
$sql = "SELECT p.* FROM pedidoDistribucion AS p, sucursal AS s
WHERE p.pedidoId = '".$this->pedidoId."'
AND p.sucursalId = s.sucursalId
GROUP BY s.sucursalId
ORDER BY s.noSuc";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$sucursales = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
return $sucursales;
}//GetSucursales
function ExistDistSuc(){
$sql = "SELECT COUNT(*) FROM pedidoDistribucion
WHERE pedidoId = '".$this->pedidoId."'
AND sucursalId = '".$this->sucursalId."'
AND cantidad > 0
AND status = 'Pendiente'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$exist = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
return $exist;
}//ExistDistSuc
function ExistDistPte(){
$sql = "SELECT COUNT(*) FROM pedidoDistribucion
WHERE pedidoId = '".$this->pedidoId."'
AND cantidad > 0
AND status = 'Pendiente'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$exist = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
return $exist;
}//ExistDistSuc
function GetItemsDistSuc(){
if($this->status)
$sqlAdd = " AND status = '".$this->status."'";
$sql = "SELECT * FROM pedidoDistribucion
WHERE pedidoId = '".$this->pedidoId."'
AND sucursalId = '".$this->sucursalId."'
".$sqlAdd;
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$items = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
return $items;
}//GetItemsDistSuc
function GetInsertId(){
$sql = "SELECT MAX(pedidoId) FROM pedido";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$pedidoId = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
return $pedidoId;
}//GetInsertId
function GetCantDist(){
$sql = "SELECT cantidad FROM pedidoDistribucion
WHERE pedidoId = '".$this->pedidoId."'
AND sucursalId = '".$this->sucursalId."'
AND productoId = '".$this->productoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$cantidad = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
return $cantidad;
}//GetCantDist
function UpdatePagado(){
$sql = 'UPDATE
pedido
SET
pagado = "'.$this->pagado.'"
WHERE
pedidoId = "'.$this->pedidoId.'"';
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
return true;
}
function CheckAsRemove(){
$sql = 'UPDATE
pedidoProducto
SET
eliminar = "1"
WHERE
pedidoId = "'.$this->pedidoId.'"
AND
productoId = "'.$this->productoId.'"';
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
return true;
}
function InfoProdDist(){
$sql = "SELECT * FROM pedidoDistribucion
WHERE pedidoId = '".$this->pedidoId."'
AND productoId = '".$this->productoId."'
AND sucursalId = '".$this->sucursalId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$info = $this->Util()->DBSelect($_SESSION['empresaId'])->GetRow();
return $info;
}//InfoProdDist
function GetSucByPedido(){
$sql = "SELECT sucursalId FROM pedidoDistribucion
WHERE pedidoId = '".$this->pedidoId."'
AND cantidad > 0
GROUP BY sucursalId";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$result = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
return $result;
}//GetSucByPedido
function GetCantBySucAndPedido(){
$sql = "SELECT SUM(cantidad) FROM pedidoDistribucion
WHERE pedidoId = '".$this->pedidoId."'
AND sucursalId = '".$this->sucursalId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$cantidad = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
return $cantidad;
}//GetSucByPedido
function InfoPedDistById(){
$sql = "SELECT * FROM pedidoDistribucion
WHERE pedDistId = '".$this->pedDistId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$info = $this->Util()->DBSelect($_SESSION['empresaId'])->GetRow();
return $info;
}//InfoPedDistById
function UpdateTotalesByPedido(){
global $config;
$this->setPedidoId($this->pedidoId);
$infP = $this->Info();
$metodoCompra = $infP['metodoCompra'];
$resProducts = $this->GetProductos();
$subtotal = 0;
foreach($resProducts as $card){
$card['cantidad'] = $card['totalLote'] * $card['cantLotes'];
$totalP = $card['costo'] * $card['cantidad'];
$card['total'] = number_format($totalP,2);
$subtotalP += $totalP;
}//foreach
$ivaTotal = 0;
if($metodoCompra == 'conIva'){
$iva = $config->GetIva();
$ivaTotal = ($iva/100) * $subtotalP;
$total = $subtotalP + $ivaTotal;
}else{
$total = $subtotal;
}
$subtotalP = number_format($subtotalP,2,'.','');
$ivaTotal = number_format($ivaTotal,2,'.','');
$total = number_format($total,2,'.','');
$sql = "
UPDATE pedido SET
subtotal = '".$subtotalP."',
iva = '".$ivaTotal."',
total = '".$total."'
WHERE
pedidoId = '".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
}//UpdateTotalesByPedido
function UpdateTotalesByPedido2(){
global $config;
$infP = $this->Info();
$metodoCompra = $infP['metodoCompra'];
$resProducts = $this->GetProductos();
$subtotal = 0;
foreach($resProducts as $card){
if($card['prendasComp']){
$card['cantidad'] = $card['cantPrendas'];
}else{
$card['cantidad'] = $card['prendasRec'];
$pedidoComp = 0;
}
$totalP = $card['costo'] * $card['cantidad'];
$subtotal += $totalP;
}//foreach
$subtotal2 = number_format($subtotal,2,'.','');
$iva2 = 0;
if($infP['metodoCompra'] == 'conIva'){
$porcIva = $config->GetIva();
$iva2 = $subtotal2 * ($porcIva / 100);
$total2 = $subtotal2 + $iva2;
}else{
$total2 = $subtotal2;
}
if($infP['porcPub'] > 0)
$totalPub = ($infP['porcPub'] / 100) * $total2;
if($infP['porcFlete'] > 0)
$totalFlete = ($infP['porcFlete'] / 100) * $total2;
if($infP['porcDes'] > 0)
$totalDes = ($infP['porcDes'] / 100) * $total2;
if($infP['porcEsp'] > 0)
$totalEsp = ($infP['porcEsp'] / 100) * $total2;
$totalDesc = $total2 - $totalPub - $totalFlete - $totalDes - $totalEsp;
$sql = "
UPDATE pedido SET
subtotal2 = '".$subtotal2."',
iva2 = '".$iva2."',
total2 = '".$total2."',
totalDesc = '".$totalDesc."',
totalPub = '".$totalPub."',
totalFlete = '".$totalFlete."',
totalDes = '".$totalDes."',
totalEsp = '".$totalEsp."'
WHERE
pedidoId = '".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
}//UpdateTotalesByPedido2
function SaveNoCajas(){
$sql = "INSERT INTO pedidoCajas (pedidoId, sucursalId, cantidad)
VALUES ('".$this->pedidoId."', '".$this->sucursalId."', '".$this->cantidad."')";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION['empresaId'])->InsertData();
return true;
}//SaveNoCajas
function EnumSucCajas(){
$sql = "SELECT * FROM pedidoCajas
WHERE pedidoId = '".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$result = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult();
return $result;
}//EnumSucCajas
function GetTotalCajasBySucAndPed(){
$sql = "SELECT cantidad FROM pedidoCajas
WHERE pedidoId = '".$this->pedidoId."'
AND sucursalId = '".$this->sucursalId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
return $total;
}
function DeleteProdRepetidos(){
$sql = 'SELECT * FROM pedidoDistribucion
WHERE pedidoId = "'.$this->pedidoId.'"
ORDER BY productoId ASC, sucursalId ASC, pedDistId DESC';
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
$result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult();
$idPedido = 0;
$idProducto = 0;
$idSucursal = 0;
foreach($result as $res){
$pedDistId = $res['pedDistId'];
if($idPedido == $res['pedidoId'] && $idProducto == $res['productoId'] && $idSucursal == $res['sucursalId']){
$sql = 'DELETE FROM pedidoDistribucion
WHERE pedDistId = "'.$pedDistId.'"';
$this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
}
$idPedido = $res['pedidoId'];
$idProducto = $res['productoId'];
$idSucursal = $res['sucursalId'];
}//foreach
}
function UpdatePzasCaja(){
$sql = "
UPDATE pedidoProducto SET
piezasCaja = '".$this->cantidad."'
WHERE
pedProdId = '".$this->pedProdId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
return true;
}
function UpdatePedidoPzasCaja(){
$sql = "
UPDATE pedido SET
piezasCaja = '1'
WHERE
pedidoId = '".$this->pedidoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
return true;
}
function UpdateProduct(){
if($this->Util()->PrintErrors()){
return false;
}
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery("
UPDATE pedidoProducto SET
totalLote = '".$this->cantPrendas."',
cantPrendas = '".$this->cantPrendas."',
costo = '".$this->costo."',
precioVenta = '".$this->precioVenta."'
WHERE
pedProdId = '".$this->pedProdId."'"
);
$this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData();
return true;
}//Update
function InfoProd(){
$sql = "SELECT * FROM pedidoProducto
WHERE pedProdId = '".$this->pedProdId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$info = $this->Util()->DBSelect($_SESSION['empresaId'])->GetRow();
return $info;
}
function DelProducto(){
$sql = "DELETE FROM pedidoProducto
WHERE pedidoId = '".$this->pedidoId."'
AND productoId = '".$this->productoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
$sql = "DELETE FROM pedidoColor
WHERE pedidoId = '".$this->pedidoId."'
AND productoId = '".$this->productoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
$sql = "DELETE FROM pedidoDistribucion
WHERE pedidoId = '".$this->pedidoId."'
AND productoId = '".$this->productoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
$sql = "DELETE FROM pedidoSugerencia
WHERE pedidoId = '".$this->pedidoId."'
AND productoId = '".$this->productoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
$sql = "DELETE FROM pedidoTalla
WHERE pedidoId = '".$this->pedidoId."'
AND productoId = '".$this->productoId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData();
return true;
}
function DistCompleta(){
$completo = 1;
$productos = $this->GetProductos();
foreach($productos as $res){
$sql = "SELECT SUM(cantidad) FROM pedidoDistribucion
WHERE pedidoId = '".$this->pedidoId."'
AND productoId = '".$res['productoId']."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$totalDist = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
if($res['cantPrendas'] != $totalDist){
$completo = 0;
break;
}
}
return $completo;
}
function GetTotalDistByProd(){
$sql = "SELECT SUM(cantidad) FROM pedidoDistribucion
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 ProdRecComp(){
$sql = "SELECT COUNT(*) FROM pedidoProducto
WHERE pedidoId = '".$this->pedidoId."'
AND recibido = '0'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
return $total;
}
function GetCajasBySuc(){
$sql = "SELECT cantidad FROM pedidoCajas
WHERE pedidoId = '".$this->pedidoId."'
AND sucursalId = '".$this->sucursalId."'";
$this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql);
$total = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle();
return $total;
}
}//Pedido
?>