Пример #1
0
 public function nuevoAction()
 {
     $tipoQuery = \TipoQuery::create()->find();
     $tipoArray = array();
     foreach ($tipoQuery as $tipo) {
         $tipoArray[$tipo->getIdtipo()] = $tipo->getTipoNombre();
     }
     $productoForm = new ProductoForm($tipoArray);
     $request = $this->getRequest();
     if ($request->isPost()) {
         $productoFilter = new ProductoFilter();
         $productoForm->setInputFilter($productoFilter->getInputFilter());
         $productoForm->setData($request->getPost());
         if ($productoForm->isValid()) {
             if (\ArticuloQuery::create()->filterByArticuloNombre($request->getPost()->articulo_nombre)->exists()) {
                 $ProductoQuery = \ArticuloQuery::create()->filterByArticuloNombre($request->getPost()->articulo_nombre)->findOne();
                 if (\PropiedadQuery::create()->filterByPropiedadNombre($request->getPost()->propiedad_nombre)->exists()) {
                     $PropiedadQuery = \PropiedadQuery::create()->filterByPropiedadNombre($request->getPost()->propiedad_nombre)->findOne();
                     $Propiedadvalor = new \Propiedadvalor();
                     $Propiedadvalor->setIdarticulo($ProductoQuery->getIdarticulo());
                     $Propiedadvalor->setIdpropiedad($PropiedadQuery->getIdpropiedad());
                     $Propiedadvalor->setPropiedadvalorNombre($request->getPost()->propiedadvalor_nombre);
                     $Propiedadvalor->save();
                 }
             }
             $Producto = new \Articulo();
             foreach ($productoForm->getData() as $ProductoKey => $ProductoValue) {
                 if ($ProductoKey != 'idarticulo' && $ProductoKey != 'propiedad_nombre' && $ProductoKey != 'idpropiedad' && $ProductoKey != 'propiedadvalor_nombre' && $ProductoKey != 'submit') {
                     $Producto->setByName($ProductoKey, $ProductoValue, BasePeer::TYPE_FIELDNAME);
                 }
             }
             $Producto->save();
             $Propiedad = new \Propiedad();
             $Propiedad->setIdarticulo($Producto->getIdarticulo());
             $Propiedad->setPropiedadNombre($request->getPost()->propiedad_nombre);
             $Propiedad->save();
             $Propiedadvalor = new \Propiedadvalor();
             $Propiedadvalor->setIdarticulo($Producto->getIdarticulo());
             $Propiedadvalor->setIdpropiedad($Propiedad->getIdpropiedad());
             $Propiedadvalor->setPropiedadvalorNombre($request->getPost()->propiedadvalor_nombre);
             $Propiedadvalor->save();
             $propiedadvalorQuery = \PropiedadvalorQuery::create()->filterByPropiedadvalorNombre($Propiedadvalor->getPropiedadvalorNombre())->find();
             $propiedadvalorArray = array();
             foreach ($propiedadvalorQuery as $propiedadvalorEntity) {
                 $propiedadvalorArray[$propiedadvalorEntity->getIdpropiedadvalor()] = $propiedadvalorEntity->getPropiedadvalorNombre();
             }
             /*
             return array(
                 'productoForm' => $productoForm,
                 'propiedadvalor' => $propiedadvalorArray,
             );
             */
             if ($error = !null) {
                 return $this->redirect()->toRoute('producto');
             }
         }
     }
     return array('productoForm' => $productoForm);
 }
Пример #2
0
 /**
  * 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 Propiedad $obj A Propiedad 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->getIdpropiedad();
         }
         // if key === null
         PropiedadPeer::$instances[$key] = $obj;
     }
 }
Пример #3
0
 /**
  * Declares an association between this object and a Propiedad object.
  *
  * @param                  Propiedad $v
  * @return Propiedadvalor The current object (for fluent API support)
  * @throws PropelException
  */
 public function setPropiedad(Propiedad $v = null)
 {
     if ($v === null) {
         $this->setIdpropiedad(NULL);
     } else {
         $this->setIdpropiedad($v->getIdpropiedad());
     }
     $this->aPropiedad = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Propiedad object, it will not be re-added.
     if ($v !== null) {
         $v->addPropiedadvalor($this);
     }
     return $this;
 }
Пример #4
0
 /**
  * Exclude object from result
  *
  * @param   Propiedad $propiedad Object to remove from the list of results
  *
  * @return PropiedadQuery The current query, for fluid interface
  */
 public function prune($propiedad = null)
 {
     if ($propiedad) {
         $this->addUsingAlias(PropiedadPeer::IDPROPIEDAD, $propiedad->getIdpropiedad(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Пример #5
0
 /**
  * Filter the query by a related Propiedad object
  *
  * @param   Propiedad|PropelObjectCollection $propiedad The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 PropiedadvalorQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByPropiedad($propiedad, $comparison = null)
 {
     if ($propiedad instanceof Propiedad) {
         return $this->addUsingAlias(PropiedadvalorPeer::IDPROPIEDAD, $propiedad->getIdpropiedad(), $comparison);
     } elseif ($propiedad instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(PropiedadvalorPeer::IDPROPIEDAD, $propiedad->toKeyValue('PrimaryKey', 'Idpropiedad'), $comparison);
     } else {
         throw new PropelException('filterByPropiedad() only accepts arguments of type Propiedad or PropelCollection');
     }
 }