Example #1
0
 /**
  * Resets all references to other model objects or collections of model objects.
  *
  * This method is a user-space workaround for PHP's inability to garbage collect
  * objects with circular references (even in PHP 5.3). This is currently necessary
  * when using Propel in certain daemon or large-volume/high-memory operations.
  *
  * @param boolean $deep Whether to also clear the references on all referrer objects.
  */
 public function clearAllReferences($deep = false)
 {
     if ($deep && !$this->alreadyInClearAllReferencesDeep) {
         $this->alreadyInClearAllReferencesDeep = true;
         if ($this->aCajachica instanceof Persistent) {
             $this->aCajachica->clearAllReferences($deep);
         }
         if ($this->aGasto instanceof Persistent) {
             $this->aGasto->clearAllReferences($deep);
         }
         $this->alreadyInClearAllReferencesDeep = false;
     }
     // if ($deep)
     $this->aCajachica = null;
     $this->aGasto = null;
 }
 /**
  * Filter the query by a related Gasto object
  *
  * @param   Gasto|PropelObjectCollection $gasto The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 CajachicadetalleQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByGasto($gasto, $comparison = null)
 {
     if ($gasto instanceof Gasto) {
         return $this->addUsingAlias(CajachicadetallePeer::IDGASTO, $gasto->getIdgasto(), $comparison);
     } elseif ($gasto instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(CajachicadetallePeer::IDGASTO, $gasto->toKeyValue('PrimaryKey', 'Idgasto'), $comparison);
     } else {
         throw new PropelException('filterByGasto() only accepts arguments of type Gasto or PropelCollection');
     }
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $id the ID of the model to be loaded
  * @return Gasto the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Gasto::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Example #4
0
 /**
  * Exclude object from result
  *
  * @param   Gasto $gasto Object to remove from the list of results
  *
  * @return GastoQuery The current query, for fluid interface
  */
 public function prune($gasto = null)
 {
     if ($gasto) {
         $this->addUsingAlias(GastoPeer::IDGASTO, $gasto->getIdgasto(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Example #5
0
 public function postRegistrarGasto()
 {
     $gasto = Gasto::create(['importetotal' => Input::get('importetotal'), 'detallecaja_id' => $this->detallecaja->id, 'tipogasto_id' => Input::get('tipodegasto_id'), 'descripcion' => Input::get('descripcion'), 'numero' => Input::get('numero'), 'serie' => Input::get('serie')]);
     return Redirect::to('/caja');
 }
 /**
  *
  * Registrar un gasto. El usuario y la sucursal que lo registran ser?tomados de la sesi?ctual.
  * 
  * <br/><br/><b>Update :</b>Ademas deber?tambi?de tomar la fecha de ingreso del gasto del servidor y agregar tambi?como par?tro una fecha a la cual se deber?de aplicar el gasto. Por ejemplo si el d?09/09/11 (viernes) se tomo dinero para pagar la luz, pero resulta que ese d?se olvidaron de registrar el gasto y lo registran el 12/09/11 (lunes). Entonces tambien se deberia de tomar como parametro una <b>fecha</b> a la cual aplicar el gasto, tambien se deberia de enviar como parametro una <b>nota</b>
  *
  * @param fecha_gasto string Fecha del gasto
  * @param id_empresa int Id de la empresa a la que pertenece este gasto
  * @param billetes json Los billetes que se retiran de la caja por pagar este gasto
  * @param descripcion string Descripcion del gasto en caso de que no este contemplado en la lista de concpetos de gasto
  * @param folio string Folio de la factura del gasto
  * @param id_caja int Id de la caja de la que se sustrae el dinero para pagar el gasto
  * @param id_concepto_gasto int Id del concepto al que  hace referencia el gasto
  * @param id_orden_de_servicio int Id de la orden del servicio que genero este gasto
  * @param id_sucursal int Id de la sucursal a la que pertenece este gasto
  * @param monto float Monto del gasto en caso de que no este contemplado por el concepto de gasto o sea diferente a este
  * @param nota string Nota del gasto
  * @return id_gasto int Id generado por la insercin del nuevo gasto
  **/
 public static function NuevoGasto($fecha_gasto, $id_empresa, $billetes = null, $descripcion = null, $folio = null, $id_caja = null, $id_concepto_gasto = null, $id_orden_de_servicio = null, $id_sucursal = null, $monto = null, $nota = null)
 {
     //obtiene al usuario de la sesion actual
     $id_usuario = SesionController::Actual();
     $id_usuario = $id_usuario["id_usuario"];
     if (is_null($id_usuario)) {
         throw new Exception("No se pudo obtener el usuario de la sesion, ya inicio sesion?");
     }
     //Se validan los parametros
     $validar = self::validarParametrosGasto(null, $id_empresa, $id_concepto_gasto, $id_orden_de_servicio, $fecha_gasto, $id_sucursal, $id_caja, $nota, $descripcion, $folio, $monto);
     //Si no se recibio monto, se toma del concepto de gasto.
     //Si no se recibio concepto de gasto o este no cuenta con un monto se manda una excepcion
     if (is_null($monto)) {
         if (is_null($id_concepto_gasto)) {
             throw new Exception("No se recibio un concepto de gasto ni un monto");
         }
         $concepto_gasto = ConceptoGastoDAO::getByPK($id_concepto_gasto);
         if (is_null($concepto_gasto)) {
             throw new Exception("El concepto de gasto recibido no existe.");
         }
         $monto = $concepto_gasto->getMonto();
         if (is_null($monto)) {
             throw new Exception("El concepto de gasto recibido no cuenta con un monto ni se recibio un monto");
         }
     }
     //Si no se recibe sucursal ni caja se intenta tomar las actuales
     if (!$id_sucursal) {
         $id_sucursal = self::getSucursal();
     }
     if (!$id_caja) {
         $id_caja = self::getCaja();
     }
     if (!is_null($id_caja)) {
         try {
             CajasController::modificarCaja($id_caja, 0, $billetes, $monto);
         } catch (Exception $e) {
             throw $e;
         }
     }
     //Se inicializa el registro de gasto
     $gasto = new Gasto();
     // fecha_gasto might be in the format : 2012-10-21T00:00:00
     // if this is the case then act acordingly
     if (is_int($fecha_gasto)) {
         $gasto->setFechaDelGasto($fecha_gasto);
     } else {
         $gasto->setFechaDelGasto(strtotime($fecha_gasto));
     }
     $gasto->setIdEmpresa($id_empresa);
     $gasto->setMonto($monto);
     $gasto->setIdSucursal($id_sucursal);
     $gasto->setIdCaja($id_caja);
     $gasto->setIdOrdenDeServicio($id_orden_de_servicio);
     $gasto->setIdConceptoGasto($id_concepto_gasto);
     $gasto->setDescripcion($descripcion);
     $gasto->setFolio($folio);
     $gasto->setNota($nota);
     $gasto->setFechaDeRegistro(time());
     $gasto->setIdUsuario($id_usuario);
     $gasto->setCancelado(0);
     //Se incrementa el costo de la orden de servicio si este gasto se le asigna a alguna
     $orden_de_servicio = null;
     if (!is_null($id_orden_de_servicio)) {
         $orden_de_servicio = OrdenDeServicioDAO::getByPK($id_orden_de_servicio);
         $orden_de_servicio->setPrecio($monto + $orden_de_servicio->getPrecio());
     }
     DAO::transBegin();
     try {
         GastoDAO::save($gasto);
         if (!is_null($orden_de_servicio)) {
             OrdenDeServicioDAO::save($orden_de_servicio);
         }
     } catch (Exception $e) {
         DAO::transRollback();
         Logger::error("No se pudo crear el gasto: " . $e);
         throw new Exception("No se pudo crear el gasto");
     }
     DAO::transEnd();
     Logger::log("Gasto creado exitosamente");
     return array("id_gasto" => $gasto->getIdGasto());
 }
Example #7
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 Gasto $obj A Gasto 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->getIdgasto();
         }
         // if key === null
         GastoPeer::$instances[$key] = $obj;
     }
 }