/**
  * Filter the query by a related Categoriagasto object
  *
  * @param   Categoriagasto|PropelObjectCollection $categoriagasto The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 GastofacturacionQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByCategoriagasto($categoriagasto, $comparison = null)
 {
     if ($categoriagasto instanceof Categoriagasto) {
         return $this->addUsingAlias(GastofacturacionPeer::IDCATEGORIAGASTO, $categoriagasto->getIdcategoriagasto(), $comparison);
     } elseif ($categoriagasto instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(GastofacturacionPeer::IDCATEGORIAGASTO, $categoriagasto->toKeyValue('PrimaryKey', 'Idcategoriagasto'), $comparison);
     } else {
         throw new PropelException('filterByCategoriagasto() only accepts arguments of type Categoriagasto or PropelCollection');
     }
 }
 /**
  * Declares an association between this object and a Categoriagasto object.
  *
  * @param                  Categoriagasto $v
  * @return Gastofacturacion The current object (for fluent API support)
  * @throws PropelException
  */
 public function setCategoriagasto(Categoriagasto $v = null)
 {
     if ($v === null) {
         $this->setIdcategoriagasto(NULL);
     } else {
         $this->setIdcategoriagasto($v->getIdcategoriagasto());
     }
     $this->aCategoriagasto = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Categoriagasto object, it will not be re-added.
     if ($v !== null) {
         $v->addGastofacturacion($this);
     }
     return $this;
 }
 /**
  * Exclude object from result
  *
  * @param   Categoriagasto $categoriagasto Object to remove from the list of results
  *
  * @return CategoriagastoQuery The current query, for fluid interface
  */
 public function prune($categoriagasto = null)
 {
     if ($categoriagasto) {
         $this->addUsingAlias(CategoriagastoPeer::IDCATEGORIAGASTO, $categoriagasto->getIdcategoriagasto(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
 public function nuevoAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $post_data = $request->getPost();
         $entity = new \Categoriagasto();
         foreach ($post_data as $key => $value) {
             if (\CategoriagastoPeer::getTableMap()->hasColumn($key) && !empty($value)) {
                 $entity->setByName($key, $value, \BasePeer::TYPE_FIELDNAME);
             }
         }
         $entity->save();
         //Agregamos un mensaje
         $this->flashMessenger()->addSuccessMessage('Registro guardado exitosamente!');
         //REDIRECCIONAMOS A LA ENTIDAD QUE ACABAMOS DE CREAR
         return $this->redirect()->toRoute('admin/catalogo/catergoria-gastos', array('action' => 'editar', 'id' => $entity->getIdcategoriagasto()));
     }
     //INSTANCIAMOS NUESTRO FORMULARIO
     $form = new \Catalogo\Form\CategoriagastosForm();
     //RETORNAMOS A NUESTRA VISTA
     $view_model = new ViewModel();
     $view_model->setTemplate('admin/catalogo/categoriasgastos/nuevo');
     $view_model->setVariable('form', $form);
     return $view_model;
 }
 /**
  * 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 Categoriagasto $obj A Categoriagasto 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->getIdcategoriagasto();
         }
         // if key === null
         CategoriagastoPeer::$instances[$key] = $obj;
     }
 }