/**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param Articulovariantereorden $obj A Articulovariantereorden object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getIdarticulovariantereorden();
         }
         // if key === null
         ArticulovariantereordenPeer::$instances[$key] = $obj;
     }
 }
Beispiel #2
0
 /**
  * Filter the query by a related Articulovariantereorden object
  *
  * @param   Articulovariantereorden|PropelObjectCollection $articulovariantereorden  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 LugarQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByArticulovariantereorden($articulovariantereorden, $comparison = null)
 {
     if ($articulovariantereorden instanceof Articulovariantereorden) {
         return $this->addUsingAlias(LugarPeer::IDLUGAR, $articulovariantereorden->getIdlugar(), $comparison);
     } elseif ($articulovariantereorden instanceof PropelObjectCollection) {
         return $this->useArticulovariantereordenQuery()->filterByPrimaryKeys($articulovariantereorden->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByArticulovariantereorden() only accepts arguments of type Articulovariantereorden or PropelCollection');
     }
 }
 /**
  * Exclude object from result
  *
  * @param   Articulovariantereorden $articulovariantereorden Object to remove from the list of results
  *
  * @return ArticulovariantereordenQuery The current query, for fluid interface
  */
 public function prune($articulovariantereorden = null)
 {
     if ($articulovariantereorden) {
         $this->addUsingAlias(ArticulovariantereordenPeer::IDARTICULOVARIANTEREORDEN, $articulovariantereorden->getIdarticulovariantereorden(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Beispiel #4
0
 public function definirAction()
 {
     //obtenemos nuestros almacenes
     $lugarCollection = \LugarQuery::create()->find();
     $lugarCollectionArray = array();
     foreach ($lugarCollection as $kl => $vl) {
         $lugarCollectionArray[] = array('nombre' => $vl->getLugarNombre(), 'id' => $vl->getIdLugar());
     }
     $request = $this->request;
     if ($request->isPost()) {
         $post_data = $request->getPost();
         if ($post_data['aplicar_todos'] == 'true') {
             foreach ($post_data as $data) {
                 if (is_array($data)) {
                     $min = $data['min'];
                     $reorden = $data['reorden'];
                     $max = $data['max'];
                     break;
                 }
             }
             $almacenes = \LugarQuery::create()->find();
             foreach ($almacenes as $almacen) {
                 $articuloReorderExist = \ArticulovariantereordenQuery::create()->filterByIdarticulovariante($post_data['idproducto'])->filterByIdlugar($almacen->getIdLugar())->exists();
                 if ($articuloReorderExist) {
                     $articuloReorder = \ArticulovariantereordenQuery::create()->filterByIdarticulovariante($post_data['idproducto'])->filterByIdlugar($almacen->getIdLugar())->findOne();
                     $articuloReorder->setMinimo($min)->setReorden($reorden)->setMaximo($max)->save();
                 } else {
                     $articuloReorden = new \Articulovariantereorden();
                     $articuloReorden->setIdarticulovariante($post_data['idproducto'])->setIdlugar($almacen->getIdLugar())->setMinimo($min)->setReorden($reorden)->setMaximo($max)->save();
                 }
             }
         } else {
             foreach ($post_data as $data) {
                 if (is_array($data)) {
                     $idproducto = $post_data['idproducto'];
                     $idlugar = $data['id'];
                     $min = $data['min'];
                     $reorden = $data['reorden'];
                     $max = $data['max'];
                     $articuloReorderExist = \ArticulovariantereordenQuery::create()->filterByIdarticulovariante($idproducto)->filterByIdlugar($idlugar)->exists();
                     if ($articuloReorderExist) {
                         $articuloReorder = \ArticulovariantereordenQuery::create()->filterByIdarticulovariante($idproducto)->filterByIdlugar($idlugar)->findOne();
                         $articuloReorder->setMinimo($min)->setReorden($reorden)->setMaximo($max)->save();
                     } else {
                         $articuloReorden = new \Articulovariantereorden();
                         $articuloReorden->setIdarticulovariante($idproducto)->setIdlugar($idlugar)->setMinimo($min)->setReorden($reorden)->setMaximo($max)->save();
                     }
                 }
             }
         }
     }
     //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) {
             //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'] = NULL;
                     $tmp['reorden'][$vl->getLugarNombre()]['reorden'] = NULL;
                     $tmp['reorden'][$vl->getLugarNombre()]['max'] = NULL;
                 }
             }
             $tmp['id'] = $vav->getIdarticulovariante();
             //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'] .= ' - ';
                 }
             }
             array_push($productos, $tmp);
         }
     }
     return new ViewModel(array('flashMessages' => $this->flashMessenger()->getMessages(), 'lugares' => $lugarCollectionArray, 'productos' => $productos));
 }
Beispiel #5
0
 /**
  * @param	Articulovariantereorden $articulovariantereorden The articulovariantereorden object to add.
  */
 protected function doAddArticulovariantereorden($articulovariantereorden)
 {
     $this->collArticulovariantereordens[] = $articulovariantereorden;
     $articulovariantereorden->setLugar($this);
 }