/**
  * Filter the query by a related Cajachica object
  *
  * @param   Cajachica|PropelObjectCollection $cajachica 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 filterByCajachica($cajachica, $comparison = null)
 {
     if ($cajachica instanceof Cajachica) {
         return $this->addUsingAlias(CajachicadetallePeer::IDCAJACHICA, $cajachica->getIdcajachica(), $comparison);
     } elseif ($cajachica instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(CajachicadetallePeer::IDCAJACHICA, $cajachica->toKeyValue('PrimaryKey', 'Idcajachica'), $comparison);
     } else {
         throw new PropelException('filterByCajachica() only accepts arguments of type Cajachica or PropelCollection');
     }
 }
示例#2
0
 /**
  * Exclude object from result
  *
  * @param   Cajachica $cajachica Object to remove from the list of results
  *
  * @return CajachicaQuery The current query, for fluid interface
  */
 public function prune($cajachica = null)
 {
     if ($cajachica) {
         $this->addUsingAlias(CajachicaPeer::IDCAJACHICA, $cajachica->getIdcajachica(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
示例#3
0
 public function nuevomovimientoAction()
 {
     $request = $this->request;
     if ($request->isPost()) {
         $post_data = $request->getPost();
         $fecha = \DateTime::createFromFormat('d/m/Y', $post_data['cajachica_fecha']);
         //Creamos nuestro movimiento
         $cajachica = new \Cajachica();
         $cajachica->setCajachicaFecha($fecha->format('Y-m-d'))->setIdconceptocajachica($post_data['idconcepto'])->setCajachicaTipomovimiento($post_data['cajachica_tipomoviento'])->setCajachicaCantidad($post_data['cajachica_cantidad'])->setCajachicaComprobante($post_data['cajachica_comprobante'])->setCajachicaPacientedoctor($post_data['cajachica_pacientedoctor'])->setCajachicaNota($post_data['cajachica_nota']);
         //Ya existe un movimiento?
         if (\CajachicaQuery::create()->exists()) {
             //Modificamos el balance de nuestra caja
             $first_row = \CajachicaQuery::create()->orderByIdcajachica('asc')->findOne();
             $current_balance = $first_row->getCajachicaBalance();
             if ($post_data['cajachica_tipomoviento'] == 'cargo') {
                 $new_balance = $current_balance + $post_data['cajachica_cantidad'];
             } else {
                 $new_balance = $current_balance - $post_data['cajachica_cantidad'];
             }
             $first_row->setCajachicaBalance($new_balance);
             $first_row->save();
         } else {
             if ($post_data['cajachica_tipomoviento'] == 'cargo') {
                 $new_balance = 0 + $post_data['cajachica_cantidad'];
                 $cajachica->setCajachicaBalance($new_balance);
             } else {
                 $new_balance = 0 - $post_data['cajachica_cantidad'];
                 $cajachica->setCajachicaBalance($new_balance);
             }
         }
         $cajachica->save();
         if (!$cajachica->isPrimaryKeyNull()) {
             return $this->getResponse()->setContent(\Zend\Json\Json::encode(array('response' => true, 'data' => array('idconceptocajachica' => $cajachica->getIdconceptocajachica(), 'id' => $cajachica->getIdcajachica(), 'fecha' => $cajachica->getCajachicaFecha('d-m-Y'), 'fecha_js' => $cajachica->getCajachicaFecha('m/d/Y')))));
         } else {
             return $this->getResponse()->setContent(\Zend\Json\Json::encode(array('response' => false)));
         }
     }
 }
示例#4
0
 /**
  * Declares an association between this object and a Cajachica object.
  *
  * @param                  Cajachica $v
  * @return Cajachicadetalle The current object (for fluent API support)
  * @throws PropelException
  */
 public function setCajachica(Cajachica $v = null)
 {
     if ($v === null) {
         $this->setIdcajachica(NULL);
     } else {
         $this->setIdcajachica($v->getIdcajachica());
     }
     $this->aCajachica = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Cajachica object, it will not be re-added.
     if ($v !== null) {
         $v->addCajachicadetalle($this);
     }
     return $this;
 }
示例#5
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 Cajachica $obj A Cajachica 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->getIdcajachica();
         }
         // if key === null
         CajachicaPeer::$instances[$key] = $obj;
     }
 }