Util()->ValidateInteger($value); $this->inventarioId = $value; } public function setSucursalId($value) { $this->sucursalId = $value; } public function setSucursalId2($value) { $this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, "Sucursal"); $this->sucursalId = $value; } public function setPedidoId($value) { $this->pedidoId = $value; } public function setEnvioId($value) { $this->envioId = $value; } public function setProductoId($value) { $this->productoId = $value; } public function setProdItemId($value) { $this->prodItemId = $value; } public function setCantidad($value) { $this->cantidad = $value; } public function setProveedorId($value) { $this->proveedorId = $value; } public function setProdCatId($value) { $this->prodCatId = $value; } public function setProdSubcatId($value) { $this->prodSubcatId = $value; } public function setModelo($value) { $this->modelo = $value; } public function setDescripcion($value) { $this->descripcion = $value; } public function setPrecioVenta($value) { $this->precioVenta = $value; } public function setRebajado($value) { $this->rebajado = $value; } public function setTipo($value) { $this->Util()->ValidateString($value, $max_chars=50, $minChars = 1, "Tipo"); $this->tipo = $value; } public function setRepInvParcialId($value) { $this->Util()->ValidateInteger($value); $this->repInvParcialId = $value; } public function setCantReal($value) { $this->cantReal = $value; } public function setFecha($value) { $this->fecha = $value; } public function setUsuarioId($value) { $this->usuarioId = $value; } public function setInvFisicoId($value) { $this->invFisicoId = $value; } public function setInvFisProdId($value) { $this->invFisProdId = $value; } public function setInvSolId($value) { $this->invSolId = $value; } public function setInvSolProdId($value) { $this->invSolProdId = $value; } public function setInvWizardId($value) { $this->invWizardId = $value; } function Enumerate() { $sql = "SELECT COUNT(*) FROM producto"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); $pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/inventario"); $sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"]; $sql = "SELECT * FROM producto ORDER BY modelo ".$sqlAdd; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult(); $data["items"] = $result; $data["pages"] = $pages; return $data; }//Enumerate function EnumDisponible() { $sql = 'SELECT i.sucursalId FROM producto AS p, inventario AS i WHERE p.productoId = i.productoId AND i.status = "Disponible" AND i.sucursalId = "'.$this->sucursalId.'" GROUP BY i.productoId'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult(); $total = count($result); $pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/inventario"); $sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"]; $sql = 'SELECT p.* FROM producto AS p, inventario AS i WHERE p.productoId = i.productoId AND i.status = "Disponible" AND i.sucursalId = "'.$this->sucursalId.'" GROUP BY i.productoId '.$sqlAdd; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult(); $data["items"] = $result; $data["pages"] = $pages; return $data; }//EnumDisponible function EnumDisponibleByRand() { $limit = rand(1,5); $sql = 'SELECT p.* FROM producto AS p, inventario AS i WHERE p.productoId = i.productoId AND i.status = "Disponible" AND i.sucursalId = "'.$this->sucursalId.'" GROUP BY i.productoId LIMIT '.$limit; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult(); $data["items"] = $result; $data["pages"] = $pages; return $data; }//EnumDisponibleByRand function EnumerateAll() { $sql = "SELECT * FROM producto ORDER BY modelo "; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult(); return $result; }//EnumerateAll function SaveProducto(){ if($this->Util()->PrintErrors()){ return false; } $sql = "INSERT INTO inventario ( envioId, pedidoId, sucursalId, productoId, prodItemId, precioVenta, cantidad, rebajado, status ) VALUES ( '".$this->envioId."', '".$this->pedidoId."', '".$this->sucursalId."', '".$this->productoId."', '".$this->prodItemId."', '".$this->precioVenta."', '".$this->cantidad."', '".$this->rebajado."', 'Disponible' )"; $this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql); $this->Util()->DBSelect($_SESSION['empresaId'])->InsertData(); return true; } //REPORTE PARCIAL function EnumReporteParcial() { $sql = "SELECT COUNT(*) FROM reporteInvParcial"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); $pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/reportes-invparcial"); $sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"]; $sql = "SELECT * FROM reporteInvParcial ORDER BY fecha DESC, repInvParcialId DESC ".$sqlAdd; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult(); $data["items"] = $result; $data["pages"] = $pages; return $data; }//EnumReporteParcial function SaveReporteParcial(){ if($this->Util()->PrintErrors()){ return false; } $sql = "INSERT INTO reporteInvParcial ( sucursalId, tipo, fecha, status ) VALUES ( '".$this->sucursalId."', '".$this->tipo."', '".date('Y-m-d H:i:s')."', 'Pendiente' )"; $this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql); $this->Util()->DBSelect($_SESSION['empresaId'])->InsertData(); $this->Util()->setError(30071, "complete"); $this->Util()->PrintErrors(); return true; } function UpdateStatusRepParcial($status){ $sql = "UPDATE reporteInvParcial SET fechaGenerado = '".date('Y-m-d H:i:s')."', status = '".$status."' WHERE repInvParcialId = '".$this->repInvParcialId."'"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData(); return true; } function UpdateFileRepParcial($archivo){ $sql = "UPDATE reporteInvParcial SET archivo = '".$archivo."' WHERE repInvParcialId = '".$this->repInvParcialId."'"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData(); return true; } function DeleteReporteParcial(){ $sql = "DELETE FROM reporteInvParcial WHERE repInvParcialId = '".$this->repInvParcialId."'"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData(); $sql = "DELETE FROM reporteInvProd WHERE repInvParcialId = '".$this->repInvParcialId."'"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData(); $this->Util()->setError(30072, "complete"); $this->Util()->PrintErrors(); return true; } function SaveRepProd(){ $sql = "INSERT INTO reporteInvProd ( repInvParcialId, productoId, cantidad, cantReal ) VALUES ( '".$this->repInvParcialId."', '".$this->productoId."', '".$this->cantidad."', '".$this->cantReal."' )"; $this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql); $this->Util()->DBSelect($_SESSION['empresaId'])->InsertData(); return true; } function ExistReport(){ $sql = 'SELECT repInvParcialId FROM reporteInvParcial WHERE sucursalId = "'.$this->sucursalId.'" AND status = "Pendiente"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $exist = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); return $exist; } function InfoInvParcial(){ $sql = 'SELECT * FROM reporteInvParcial WHERE sucursalId = "'.$this->sucursalId.'" AND status = "Pendiente"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow(); return $info; } function InfoInvParcialById(){ $sql = 'SELECT * FROM reporteInvParcial WHERE repInvParcialId = "'.$this->repInvParcialId.'"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow(); return $info; } function GetProdsByReport(){ $sql = 'SELECT * FROM reporteInvProd WHERE repInvParcialId = "'.$this->repInvParcialId.'"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult(); return $result; } /***/ function AddStockXX(){ $sql = "UPDATE inventario SET cantidad = cantidad + '".$this->cantidad."' WHERE inventarioId = '".$this->inventarioId."'"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData(); return true; } function ExistProducto(){ $sql = "SELECT inventarioId FROM inventario WHERE sucursalId = '".$this->sucursalId."' AND productoId = '".$this->productoId."' AND prodItemId = '".$this->prodItemId."'"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $inventarioId = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); return $inventarioId; } function GetDisponible(){ $sql = "SELECT SUM(cantidad) FROM inventario WHERE sucursalId = '".$this->sucursalId."' AND prodItemId = '".$this->prodItemId."' AND status = 'Disponible'"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); $this->setProductoId($this->prodItemId); $total -= $this->VentasDescontadas(); return $total; } function GetDispByProd(){ $sql = "SELECT SUM(cantidad) FROM inventario WHERE sucursalId = '".$this->sucursalId."' AND productoId = '".$this->productoId."' AND status = 'Disponible'"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); //Descontamos las Ventas que fueron Ajustadas $total -= $this->VentasDescontadas(); return $total; } function GetBloqueados(){ $sql = "SELECT SUM(cantidad) FROM inventario WHERE sucursalId = '".$this->sucursalId."' AND prodItemId = '".$this->prodItemId."' AND status = 'Bloqueado'"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); return $total; } function GetTotalItemsBySuc(){ $sql = "SELECT SUM(cantidad) FROM inventario WHERE sucursalId = '".$this->sucursalId."' AND productoId = '".$this->productoId."' AND status = 'Disponible'"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); //Descontamos las Ventas que fueron Ajustadas $total -= $this->VentasDescontadas(); return $total; } function GetTotalItemsBloqBySuc(){ $sql = "SELECT prodItemId FROM productoItem WHERE productoId ='".$this->productoId."'"; $this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql); $result = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult(); $total = 0; foreach($result as $res){ $this->setProdItemId($res['prodItemId']); $total += $this->GetBloqueados(); } return $total; } function GetSingleProds(){ $sql = "SELECT i.productoId FROM `inventario` AS i, envio AS e WHERE i.envioId = e.envioId AND e.status = 'Recibido' AND i.sucursalId = '".$this->sucursalId."' AND DATE(fechaRecibido) = '".$this->fecha."' GROUP BY productoId"; $this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql); $result = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult(); return $result; } function GetCantByProd(){ $sql = "SELECT SUM(i.cantidad) FROM `inventario` AS i, envio AS e WHERE i.envioId = e.envioId AND e.status = 'Recibido' AND i.sucursalId = '".$this->sucursalId."' AND i.productoId = '".$this->productoId."' AND DATE(fechaRecibido) = '".$this->fecha."'"; $this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql); $cantidad = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle(); return $cantidad; } function Search() { $sqlAdd = ''; if($this->proveedorId) $sqlAdd .= ' AND proveedorId = '.$this->proveedorId; if($this->prodCatId) $sqlAdd .= ' AND prodCatId = '.$this->prodCatId; if($this->prodSubcatId) $sqlAdd .= ' AND prodSubcatId = '.$this->prodSubcatId; if($this->modelo) $sqlAdd .= ' AND (modelo LIKE "%'.$this->modelo.'%" OR codigoBarra = "'.$this->modelo.'")'; if($this->descripcion) $sqlAdd .= ' AND descripcion LIKE "%'.$this->descripcion.'%"'; $sql = 'SELECT * FROM producto WHERE 1 '.$sqlAdd.' ORDER BY modelo '; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult(); return $result; }//Search function AjustarProductos(){ global $util; $sql = 'SELECT inventarioId FROM inventario AS inv, envio AS env WHERE inv.envioId = env.envioId AND inv.sucursalId = "'.$this->sucursalId.'" AND inv.productoId = "'.$this->productoId.'" AND inv.status = "Disponible" ORDER BY env.fechaRecibido DESC, inv.inventarioId ASC LIMIT '.$this->cantidad; $this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql); $result = $this->Util()->DBSelect($_SESSION['empresaId'])->GetResult(); $result = $util->CheckArray($result); foreach($result as $res){ $sql = 'UPDATE inventario SET status = "Ajuste" WHERE inventarioId = "'.$res['inventarioId'].'"'; $this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql); $this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData(); } $this->Util()->setError(20109, "complete"); $this->Util()->PrintErrors(); return true; } //Inventario Fisico function InfoInvFisico(){ $sql = 'SELECT * FROM inventarioFisico WHERE invFisicoId = "'.$this->invFisicoId.'"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow(); return $info; } function CrearInvFisico(){ $sql = 'INSERT INTO inventarioFisico (fecha, usuarioId, status) VALUES ("'.$this->fecha.'", "'.$this->usuarioId.'", "Pendiente")'; $this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql); $invFisicoId = $this->Util()->DBSelect($_SESSION['empresaId'])->InsertData(); return $invFisicoId; } function UpdSucInvFisico(){ $sql = 'UPDATE inventarioFisico SET sucursalId = "'.$this->sucursalId.'" WHERE invFisicoId = "'.$this->invFisicoId.'"'; $this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql); $this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData(); return true; } function SaveInvProd(){ $sql = 'INSERT INTO inventarioFisicoProd (invFisicoId, productoId, cantidad) VALUES ("'.$this->invFisicoId.'", "'.$this->productoId.'", "'.$this->cantidad.'")'; $this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql); $this->Util()->DBSelect($_SESSION['empresaId'])->InsertData(); return true; } function ExistProdInvFis(){ $sql = 'SELECT invFisProdId FROM inventarioFisicoProd WHERE invFisicoId = "'.$this->invFisicoId.'" AND productoId = "'.$this->productoId.'"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $exist = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); return $exist; } function GetInvFisicoProds(){ $sql = 'SELECT * FROM inventarioFisicoProd WHERE invFisicoId = "'.$this->invFisicoId.'" ORDER BY invFisProdId DESC'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $productos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult(); return $productos; } function EnumRepInvFis() { $sql = "SELECT COUNT(*) FROM inventarioFisico"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); $pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/inventario-fisico"); $sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"]; $sql = "SELECT * FROM inventarioFisico ORDER BY fecha DESC ".$sqlAdd; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult(); $data["items"] = $result; $data["pages"] = $pages; return $data; } function EnumRepInvFisByUser() { $sql = "SELECT COUNT(*) FROM inventarioFisico WHERE usuarioId = '".$this->usuarioId."'"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); $pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/inventario-fisico"); $sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"]; $sql = "SELECT * FROM inventarioFisico WHERE usuarioId = '".$this->usuarioId."' ORDER BY fecha DESC ".$sqlAdd; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult(); $data["items"] = $result; $data["pages"] = $pages; return $data; } function DeleteInvFisico(){ $sql = 'DELETE FROM inventarioFisico WHERE invFisicoId = "'.$this->invFisicoId.'"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData(); $sql = 'DELETE FROM inventarioFisicoProd WHERE invFisicoId = "'.$this->invFisicoId.'"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData(); $this->Util()->setError(20138, "complete"); $this->Util()->PrintErrors(); return true; } function InfoInvFisProd(){ $sql = 'SELECT * FROM inventarioFisicoProd WHERE invFisProdId = "'.$this->invFisProdId.'"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow(); return $info; } function DelInvFisProd(){ $sql = 'DELETE FROM inventarioFisicoProd WHERE invFisProdId = "'.$this->invFisProdId.'"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData(); $this->Util()->setError(20015, "complete"); $this->Util()->PrintErrors(); return true; } //Inventario Solicitud function InfoInvSol(){ $sql = 'SELECT * FROM inventarioSolicitud WHERE invSolId = "'.$this->invSolId.'"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow(); return $info; } function CrearSolicitudProds(){ $sql = 'INSERT INTO inventarioSolicitud (fecha, sucursalId, usuarioId, status) VALUES ("'.$this->fecha.'", "'.$this->sucursalId.'", "'.$this->usuarioId.'", "Pendiente")'; $this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql); $invSolId = $this->Util()->DBSelect($_SESSION['empresaId'])->InsertData(); return $invSolId; } function SaveInvSolProd(){ $sql = 'INSERT INTO inventarioSolicitudProd (invSolId, productoId, cantidad) VALUES ("'.$this->invSolId.'", "'.$this->productoId.'", "'.$this->cantidad.'")'; $this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql); $this->Util()->DBSelect($_SESSION['empresaId'])->InsertData(); return true; } function ExistProdSol(){ $sql = 'SELECT invSolProdId FROM inventarioSolicitudProd WHERE invSolId = "'.$this->invSolId.'" AND productoId = "'.$this->productoId.'"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $exist = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); return $exist; } function GetInvSolProds(){ $sql = 'SELECT * FROM inventarioSolicitudProd WHERE invSolId = "'.$this->invSolId.'" ORDER BY invSolProdId ASC'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $productos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult(); return $productos; } function InfoInvSolProd(){ $sql = 'SELECT * FROM inventarioSolicitudProd WHERE invSolProdId = "'.$this->invSolProdId.'"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow(); return $info; } function DelInvSolProd(){ $sql = 'DELETE FROM inventarioSolicitudProd WHERE invSolProdId = "'.$this->invSolProdId.'"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData(); $this->Util()->setError(20015, "complete"); $this->Util()->PrintErrors(); return true; } function EnumRepInvSol() { $sql = "SELECT COUNT(*) FROM inventarioSolicitud"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); $pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/inventario-solicitar"); $sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"]; $sql = "SELECT * FROM inventarioSolicitud ORDER BY fecha DESC ".$sqlAdd; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult(); $data["items"] = $result; $data["pages"] = $pages; return $data; } function DeleteInvSol(){ $sql = 'DELETE FROM inventarioSolicitud WHERE invSolId = "'.$this->invSolId.'"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData(); $sql = 'DELETE FROM inventarioSolicitudProd WHERE invSolId = "'.$this->invSolId.'"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $this->Util()->DBSelect($_SESSION["empresaId"])->DeleteData(); $this->Util()->setError(20140, "complete"); $this->Util()->PrintErrors(); return true; } function RechazarInvSol(){ $sql = 'UPDATE inventarioSolicitud SET status = "Rechazado", fechaAR = "'.date('Y-m-d H:i:s').'", usuarioIdAR = "'.$this->usuarioId.'" WHERE invSolId = "'.$this->invSolId.'"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData(); $this->Util()->setError(20141, "complete"); $this->Util()->PrintErrors(); return true; } function AutorizarInvSol(){ $sql = 'UPDATE inventarioSolicitud SET status = "Autorizado", fechaAR = "'.date('Y-m-d H:i:s').'", usuarioIdAR = "'.$this->usuarioId.'" WHERE invSolId = "'.$this->invSolId.'"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $this->Util()->DBSelect($_SESSION["empresaId"])->UpdateData(); $this->Util()->setError(20142, "complete"); $this->Util()->PrintErrors(); return true; } function EnumAjustes() { $sql = "SELECT COUNT(*) FROM ajustes"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); $pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/inventario-ajustar-list"); $sqlAdd = "LIMIT ".$pages["start"].", ".$pages["items_per_page"]; $sql = "SELECT * FROM ajustes ORDER BY fecha DESC ".$sqlAdd; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $result = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult(); $data["items"] = $result; $data["pages"] = $pages; return $data; } //Ajustes Wizard function EnumWizard() { $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT COUNT(*) FROM inventarioWizard"); $total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); $pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/inventario-wizard-list"); $sqlAdd = " LIMIT ".$pages["start"].", ".$pages["items_per_page"]; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM inventarioWizard ORDER BY fecha DESC".$sqlAdd); $ajustes = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult(); $data["items"] = $ajustes; $data["pages"] = $pages; return $data; } function EnumWizardProds() { $sql = 'SELECT * FROM inventarioWizardProd WHERE invWizardId = "'.$this->invWizardId.'"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $productos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult(); return $productos; } function InfoWizard() { $sql = 'SELECT * FROM inventarioWizard WHERE invWizardId = "'.$this->invWizardId.'"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow(); return $info; } //Ajustes Wizard2 function EnumWizard2() { $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT COUNT(*) FROM inventarioWizard2"); $total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); $pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/inventario-wizard-list2"); $sqlAdd = " LIMIT ".$pages["start"].", ".$pages["items_per_page"]; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM inventarioWizard2 ORDER BY fecha DESC".$sqlAdd); $ajustes = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult(); $data["items"] = $ajustes; $data["pages"] = $pages; return $data; } function EnumWizardProds2() { $sql = 'SELECT * FROM inventarioWizardProd2 WHERE invWizardId = "'.$this->invWizardId.'"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $productos = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult(); return $productos; } function InfoWizard2() { $sql = 'SELECT * FROM inventarioWizard2 WHERE invWizardId = "'.$this->invWizardId.'"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $info = $this->Util()->DBSelect($_SESSION["empresaId"])->GetRow(); return $info; } function VentasDescontadas(){ $sql = 'SELECT SUM(cantidad) FROM inventario LEFT JOIN pedido ON pedido.pedidoId = inventario.pedidoId WHERE productoId = '.$this->productoId.' AND sucursalId = '.$this->sucursalId.' AND ventaDesc = "Si"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); return $total; } function VentasDescontadasBest(){ $sql = 'SELECT SUM( i.cantidad ) FROM inventario i, pedido p WHERE i.pedidoId = p.pedidoId AND i.productoId = '.$this->productoId.' AND i.sucursalId = '.$this->sucursalId.' AND p.ventaDesc = "Si"'; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); return $total; } }//Inventario ?>