Util()->ValidateString($value, $max_chars=255, $minChars = 1, "Justificacion"); $this->justificanteRechazo = $value; } public function setStatus($value) { //$this->Util()->ValidateInteger($value); $this->status = $value; } public function setBonificacionId($value) { $this->Util()->ValidateInteger($value); $this->bonificacionId = $value; } public function setRestante($value) { //$this->Util()->ValidateInteger($value); $this->restante = $value; } public function setCantidad($value) { //$this->Util()->ValidateInteger($value); $this->cantidad = $value; } public function setPorcentajeBonifica($value) { //$this->Util()->ValidateInteger($value); $this->porcentajeBonifica = $value; } public function setPagoTotal($value) { //$this->Util()->ValidateInteger($value); $this->pagoTotal = $value; } public function setPorcentajeVendido($value) { //$this->Util()->ValidateInteger($value); $this->porcentajeVendido = $value; } public function setPorcentajeAplicado($value) { //$this->Util()->ValidateInteger($value); $this->porcentajeAplicado = $value; } public function setVendido($value) { //$this->Util()->ValidateInteger($value); $this->vendido = $value; } public function setDisponible($value) { //$this->Util()->ValidateInteger($value); $this->disponible = $value; } public function setTotal($value) { //$this->Util()->ValidateInteger($value); $this->total = $value; } public function setCosto($value) { //$this->Util()->ValidateInteger($value); $this->costo = $value; } public function setProductoId($value) { $this->Util()->ValidateInteger($value); $this->productoId = $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 setProveedorId($value) { $this->Util()->ValidateInteger($value); $this->proveedorId = $value; } public 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; } public function Save() { $sql = "INSERT INTO bonificacion( `prodItemId`, `proveedorId`, `pedidoId`, `productoId`, `porcentajeBonifica`, `totalBonificacion`, `restanteBonificacion`, `porcentajeAplicado`, `fechaBonificacion`, `totalProductos`, `costoProducto`, `disponible`, `vendido`, `porcentajeVendido`, `cantidad`) VALUES ('".$this->prodItemId."', '".$this->proveedorId."', '".$this->pedidoId."', '".$this->productoId."', '".$this->porcentajeBonifica."', '".$this->pagoTotal."', '".$this->restante."', '".$this->porcentajeAplicado."', '".$this->Util()->TodayHour()."', '".$this->total."', '".$this->costo."', '".$this->disponible."', '".$this->vendido."', '".$this->porcentajeVendido."', '".$this->cantidad."')"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $this->Util()->DBSelect($_SESSION["empresaId"])->InsertData(); $this->Util()->setError(30066, "complete"); $this->Util()->PrintErrors(); return true; } public function checkBonificacion() { $value = true; $sql = "SELECT COUNT(*) FROM bonificacion WHERE prodItemId = '".$this->prodItemId."' AND proveedorId = '".$this->proveedorId."' AND pedidoId = '".$this->pedidoId."' AND productoId = '".$this->productoId."'"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); if($this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle() > 0) $value = false; return $value; } function checkBonificacion2() { $value = true; $sql = "SELECT COUNT(*) FROM bonificacion WHERE prodItemId = '".$this->prodItemId."' AND proveedorId = '".$this->proveedorId."' AND pedidoId = '".$this->pedidoId."' AND productoId = '".$this->productoId."' AND estatus LIKE 'Aprobado'"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $aprobado = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); $sql = "SELECT COUNT(*) FROM bonificacion WHERE prodItemId = '".$this->prodItemId."' AND proveedorId = '".$this->proveedorId."' AND pedidoId = '".$this->pedidoId."' AND productoId = '".$this->productoId."' AND estatus LIKE 'Pendiente'"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $pendiente = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); if($aprobado >= 2 || $pendiente > 0) $value = false; return $value; } function Enumerate() { $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT COUNT(*) FROM bonificacion"); $total = $this->Util()->DBSelect($_SESSION["empresaId"])->GetSingle(); $pages = $this->Util->HandleMultipages($this->page, $total ,WEB_ROOT."/bonificaciones-pendientes"); $sqlAdd = " LIMIT ".$pages["start"].", ".$pages["items_per_page"]; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery("SELECT * FROM bonificacion ORDER BY fechaBonificacion ASC".$sqlAdd); $bonificaciones = $this->Util()->DBSelect($_SESSION["empresaId"])->GetResult(); $data["items"] = $bonificaciones; $data["pages"] = $pages; return $data; } function updateStatus() { $sql = "UPDATE bonificacion SET estatus = 'Aprobado', cantidad = '".$this->cantidad."' WHERE bonificacionId = ".$this->bonificacionId; $this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql); $this->Util()->DBSelect($_SESSION['empresaId'])->UpdateData(); $this->Util()->setError(30067, 'complete'); $this->Util()->PrintErrors(); return true; } function getBonificaciones() { $sql = 'SELECT SUM(cantidad) FROM bonificacion WHERE pedidoId = '.$this->pedidoId.' AND estatus LIKE "Aprobado"'; $this->Util()->DBSelect($_SESSION['empresaId'])->setQuery($sql); $producto = $this->Util()->DBSelect($_SESSION['empresaId'])->GetSingle(); return $producto; } public function SaveDevolucion() { $sql = "INSERT INTO devolucionPedido( `prodItemId`, `proveedorId`, `pedidoId`, `productoId`, `totalDevolucion`, `porcentajeAplicado`, `fechaDevolucion`, `totalProductos`, `costoProducto`, `disponible`, `vendido`, `porcentajeVendido`, `cantidad`) VALUES ('".$this->prodItemId."', '".$this->proveedorId."', '".$this->pedidoId."', '".$this->productoId."', '".$this->pagoTotal."', '".$this->porcentajeAplicado."', '".$this->Util()->TodayHour()."', '".$this->total."', '".$this->costo."', '".$this->disponible."', '".$this->vendido."', '".$this->porcentajeVendido."', '".$this->cantidad."')"; $this->Util()->DBSelect($_SESSION["empresaId"])->setQuery($sql); $this->Util()->DBSelect($_SESSION["empresaId"])->InsertData(); $this->Util()->setError(30066, "complete"); $this->Util()->PrintErrors(); return true; } } ?>