/** * Returns a new ArticulovariantereordenQuery object. * * @param string $modelAlias The alias of a model in the query * @param ArticulovariantereordenQuery|Criteria $criteria Optional Criteria to build the query from * * @return ArticulovariantereordenQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof ArticulovariantereordenQuery) { return $criteria; } $query = new ArticulovariantereordenQuery(null, null, $modelAlias); if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
public function listaAction() { //obtenemos nuestros almacenes $lugarCollection = \LugarQuery::create()->find(); $lugarCollectionArray = array(); foreach ($lugarCollection as $kl => $vl) { $lugarCollectionArray[] = array('nombre' => $vl->getLugarNombre(), 'id' => $vl->getIdLugar()); } //Obtenemos nuestros productos $articuloCollection = \ArticuloQuery::create()->find(); //De cada articulo obtenemos sus variaciones (articulovariante) $productos = array(); foreach ($articuloCollection as $ka => $av) { $tmp = array(); $tmp['nombre'] = $av->getArticuloNombre(); $articulovarianteCollection = $av->getArticulovariantes(); foreach ($articulovarianteCollection as $kav => $vav) { $tmp['id'] = $vav->getIdarticulovariante(); $tmp['codigo_barras'] = $vav->getArticulovarianteCodigoBarras(); $tmp['precio'] = $vav->getArticulovariantePrecio(); $tmp['imagen'] = $vav->getArticuloVarianteImagen(); //Por cada valor obtenemos su variaciones $articuloVarianteValorCollection = \ArticulovariantevalorQuery::create()->filterByIdarticulovariante($vav->getIdarticulovariante())->find(); $tmp['descripcion'] = ''; $propiedadCount = 0; foreach ($articuloVarianteValorCollection as $kavv => $vavv) { $propiedadCount++; $tmp['descripcion'] .= \PropiedadQuery::create()->findOneByIdpropiedad($vavv->getIdpropiedad())->getPropiedadNombre(); //Propiedad $tmp['descripcion'] .= ':' . \PropiedadvalorQuery::create()->findOneByIdpropiedadvalor($vavv->getIdpropiedadvalor())->getPropiedadvalorNombre(); //PropiedadValor if ($propiedadCount < $articuloVarianteValorCollection->count()) { $tmp['descripcion'] .= ' - '; } } //Por cada variacion obtenemos los datos de reorden $reordenCollection = \ArticulovariantereordenQuery::create()->findByIdarticulovariante($vav->getIdArticulovariante()); $reordenArray = $reordenCollection->toArray(); if (!empty($reordenArray)) { //Itineramos en el foreach ($reordenCollection as $krc => $vro) { $tmp['reorden']['id'] = $vro->getIdArticulovariantereorden(); $tmp['reorden'][$vro->getLugar()->getLugarNombre()]['min'] = (int) $vro->getMinimo(); $tmp['reorden'][$vro->getLugar()->getLugarNombre()]['reorden'] = (int) $vro->getReorden(); $tmp['reorden'][$vro->getLugar()->getLugarNombre()]['max'] = (int) $vro->getMaximo(); } } else { foreach ($lugarCollection as $kl => $vl) { $tmp['reorden'][$vl->getLugarNombre()]['min'] = 0; $tmp['reorden'][$vl->getLugarNombre()]['reorden'] = 0; $tmp['reorden'][$vl->getLugarNombre()]['max'] = 0; } } //Comenzamos a itinerar sobre los lugares disponibles foreach ($lugarCollection as $kl => $vl) { //Los agregamos a nuestro arreglo $tmp['reorden'][$vl->getLugarNombre()]['existencias'] = 0; } //Obtenemos las compras que se han realizado del articulo variante $compraDetalleCollection = \OrdencompradetalleQuery::create()->findByIdarticulovariante($vav->getIdArticuloVariante()); //Itineramos en la coleccion de compras foreach ($compraDetalleCollection as $kcd => $vcd) { $idCompraDetalle = $vcd->getIdOrdenCompraDetalle(); //por cada compra detalle la buscamos en lugar inventario $lugarInventarioCollection = \LugarinventarioQuery::create()->findByIdordencompradetalle($idCompraDetalle); //empezamos a itinerar en los registros para irlos sumando a nuestro lugar foreach ($lugarInventarioCollection as $kli => $vli) { $lugarNombre = $vli->getLugar()->getLugarNombre(); $cantidad = $vli->getLugarinventarioCantidad(); $tmp['reorden'][$lugarNombre]['existencias'] += $cantidad; } } array_push($productos, $tmp); } } return new ViewModel(array('lugares' => $lugarCollectionArray, 'productos' => $productos)); }
/** * Removes this object from datastore and sets delete attribute. * * @param PropelPDO $con * @return void * @throws PropelException * @throws Exception * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete(PropelPDO $con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) { $con = Propel::getConnection(ArticulovariantereordenPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = ArticulovariantereordenQuery::create()->filterByPrimaryKey($this->getPrimaryKey()); $ret = $this->preDelete($con); if ($ret) { $deleteQuery->delete($con); $this->postDelete($con); $con->commit(); $this->setDeleted(true); } else { $con->commit(); } } catch (Exception $e) { $con->rollBack(); throw $e; } }
/** * If this collection has already been initialized with * an identical criteria, it returns the collection. * Otherwise if this Lugar is new, it will return * an empty collection; or if this Lugar has previously * been saved, it will retrieve related Articulovariantereordens from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you * actually need in Lugar. * * @param Criteria $criteria optional Criteria object to narrow the query * @param PropelPDO $con optional connection object * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) * @return PropelObjectCollection|Articulovariantereorden[] List of Articulovariantereorden objects */ public function getArticulovariantereordensJoinArticulovariante($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $query = ArticulovariantereordenQuery::create(null, $criteria); $query->joinWith('Articulovariante', $join_behavior); return $this->getArticulovariantereordens($query, $con); }