/**
  * Returns a new GastofacturacionQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param   GastofacturacionQuery|Criteria $criteria Optional Criteria to build the query from
  *
  * @return GastofacturacionQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof GastofacturacionQuery) {
         return $criteria;
     }
     $query = new GastofacturacionQuery(null, null, $modelAlias);
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
Example #2
0
 /**
  * Returns the number of related Gastofacturacion objects.
  *
  * @param Criteria $criteria
  * @param boolean $distinct
  * @param PropelPDO $con
  * @return int             Count of related Gastofacturacion objects.
  * @throws PropelException
  */
 public function countGastofacturacions(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     $partial = $this->collGastofacturacionsPartial && !$this->isNew();
     if (null === $this->collGastofacturacions || null !== $criteria || $partial) {
         if ($this->isNew() && null === $this->collGastofacturacions) {
             return 0;
         }
         if ($partial && !$criteria) {
             return count($this->getGastofacturacions());
         }
         $query = GastofacturacionQuery::create(null, $criteria);
         if ($distinct) {
             $query->distinct();
         }
         return $query->filterByCategoriagasto($this)->count($con);
     }
     return count($this->collGastofacturacions);
 }
 /**
  * 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(GastofacturacionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = GastofacturacionQuery::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;
     }
 }
Example #4
0
 public function eliminarAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $id = $request->getPost('id');
         $entity = \GastofacturacionQuery::create()->findPk($id);
         $entity->delete();
         //Agregamos un mensaje
         $this->flashMessenger()->addSuccessMessage('Registro eliminado exitosamente!');
         if ($entity->isDeleted()) {
             return $this->getResponse()->setContent(json_encode(true));
         }
     }
     $id = $this->params()->fromQuery('id');
     $viewModel = new ViewModel();
     $viewModel->setTerminal(true);
     $viewModel->setTemplate('admin/catalogo/gastos/eliminar');
     return $viewModel;
 }
 public function getcargosAction()
 {
     $idcategoria = $this->params()->fromQuery('idcategoria');
     $result = \GastofacturacionQuery::create()->filterByIdcategoriagasto($idcategoria)->find()->toArray(null, false, \BasePeer::TYPE_FIELDNAME);
     return $this->getResponse()->setContent(json_encode($result));
 }
Example #6
0
 /**
  * Get the associated Gastofacturacion object
  *
  * @param PropelPDO $con Optional Connection object.
  * @param $doQuery Executes a query to get the object if required
  * @return Gastofacturacion The associated Gastofacturacion object.
  * @throws PropelException
  */
 public function getGastofacturacion(PropelPDO $con = null, $doQuery = true)
 {
     if ($this->aGastofacturacion === null && $this->idgastofacturacion !== null && $doQuery) {
         $this->aGastofacturacion = GastofacturacionQuery::create()->findPk($this->idgastofacturacion, $con);
         /* The following can be used additionally to
               guarantee the related object contains a reference
               to this object.  This level of coupling may, however, be
               undesirable since it could result in an only partially populated collection
               in the referenced object.
               $this->aGastofacturacion->addExpedientegastos($this);
            */
     }
     return $this->aGastofacturacion;
 }