/** * Realiza validaciones logicas antes de crear/actualizar el objeto: * * 1.- Comprueba la existencia del lote y ubicación (si procede) * 2.- Agrupa con código de artículo, lote ubicación */ public function validaLogico() { parent::validaLogico(); // Control Lote y Ubicación $articulo = new Articulos($this->IDArticulo); if ($articulo->getStatus()) { $trazabilidad = $articulo->getTrazabilidad()->getIDTipo() == 1; $this->Descripcion = $articulo->getDescripcion(); } else { $this->_errores[] = "El artículo no existe"; } unset($articulo); $inventario = new InventariosCab($this->IDInventario); $controlUbicaciones = $inventario->getIDAlmacen()->getControlUbicaciones()->getIDTipo() == 1; unset($inventario); if ($trazabilidad) { if ($this->IDLote == 0) { $this->_errores[] = "Debe indicar un lote"; } else { // Comprobar que el lote pertenezca al artículo $lote = new Lotes($this->IDLote); if ($lote->getIDArticulo()->getIDArticulo() != $this->IDArticulo) { $this->_errores[] = "El lote no pertenece al artículo"; } unset($lote); } } if ($controlUbicaciones and $this->IDUbicacion == 0) { $this->_errores[] = "Debe indicar la ubicación"; } // Agrupar en la misma línea de inventario las entradas // que coinciden en el código de articulo, lote y ubicación $rows = $this->cargaCondicion("*", "IDArticulo='{$this->IDArticulo}' and IDLote='{$this->IDLote}' and IDUbicacion='{$this->IDUbicacion}' and IDInventario='{$this->IDInventario}'"); if (count($rows)) { $this->_idLineaNueva = $rows[0]['IDLinea']; $this->Stock += $rows[0]['Stock']; $this->Cajas += $rows[0]['Cajas']; $this->Pales += $rows[0]['Pales']; $this->_flagAgrupa = true; } }
/** * Construye un tag html <select> con todas las ubicaciones donde hay stock * para el lote y almacen indicado en el parametro * @param string $filtro El id de lote y el id de almacen separados por un guion * @param string $nameSelect El Name del select * @param string $idSelect El Id del select * @return string Codigo html con el tag select */ function ubicacionesLoteStock($filtro, $nameSelect = '', $idSelect = '') { if ($nameSelect == '') { $nameSelect = $_GET['nameselect']; } if ($idSelect == '') { $idSelect = $_GET['idselect']; } // En el filtro viene separado por un guión el id del lote y el id del almacen $valores = explode("-", $filtro); $idLote = $valores[0]; $idAlmacen = $valores[1]; $lote = new Lotes($idLote); $rows = $lote->getUbicacionesStock($idAlmacen); $uma = $lote->getIDArticulo()->getUMA(); unset($lote); if (count($rows)) { $ch .= "<select name='" . $nameSelect . "' id='" . $idSelect . "' class='Select' style='width:190px;'>"; foreach ($rows as $row) { $ch .= "<option value='" . $row['Id'] . "'>" . $row['Value'] . " -> " . sprintf("%9.2f", $row['Reales']) . " {$uma}</option>"; } $ch .= "</select>"; } else { $ch .= "No hay ubicaciones"; } return $ch; }