/** * Returns the number of related Cajachica objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related Cajachica objects. * @throws PropelException */ public function countCajachicas(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { $partial = $this->collCajachicasPartial && !$this->isNew(); if (null === $this->collCajachicas || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collCajachicas) { return 0; } if ($partial && !$criteria) { return count($this->getCajachicas()); } $query = CajachicaQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query->filterByConceptocajachica($this)->count($con); } return count($this->collCajachicas); }
/** * Returns a new CajachicaQuery object. * * @param string $modelAlias The alias of a model in the query * @param CajachicaQuery|Criteria $criteria Optional Criteria to build the query from * * @return CajachicaQuery */ public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof CajachicaQuery) { return $criteria; } $query = new CajachicaQuery(null, null, $modelAlias); if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
/** * 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(CajachicaPeer::DATABASE_NAME, Propel::CONNECTION_WRITE); } $con->beginTransaction(); try { $deleteQuery = CajachicaQuery::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; } }
/** * Get the associated Cajachica object * * @param PropelPDO $con Optional Connection object. * @param $doQuery Executes a query to get the object if required * @return Cajachica The associated Cajachica object. * @throws PropelException */ public function getCajachica(PropelPDO $con = null, $doQuery = true) { if ($this->aCajachica === null && $this->idcajachica !== null && $doQuery) { $this->aCajachica = CajachicaQuery::create()->findPk($this->idcajachica, $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->aCajachica->addCajachicadetalles($this); */ } return $this->aCajachica; }
public function editarmovmientoAction() { $request = $this->request; if ($request->isPost()) { $post_data = $request->getPost(); $id = $post_data['idcajachica']; $caja = \CajachicaQuery::create()->findOneByIdcajachica($id); $caja_old = $caja->toArray(\BasePeer::TYPE_FIELDNAME); $caja_fecha = \DateTime::createFromFormat('d-m-Y', $post_data['cajachica_fecha']); $caja->setIdconceptocajachica($post_data['idconcepto'])->setCajachicaFecha($caja_fecha->format('Y-m-d'))->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']); $caja->save(); //Actualizamos nustro balance $first_row = \CajachicaQuery::create()->orderByIdcajachica('asc')->findOne(); $current_balance = $first_row->getCajachicaBalance(); if ($caja_old['cajachica_tipomovimiento'] == 'cargo') { $reset_balance = $current_balance - $caja_old['cajachica_cantidad']; $newbalance = $reset_balance + $caja->getCajachicaCantidad(); } else { $reset_balance = $current_balance + $caja_old['cajachica_cantidad']; $newbalance = $reset_balance - $caja->getCajachicaCantidad(); } $first_row->setCajachicaBalance($newbalance); $first_row->save(); $caja = \CajachicaQuery::create()->joinConceptocajachica()->withColumn('conceptocajachica_nombre')->findOneByIdcajachica($id); $caja_array = $caja->toArray(\BasePeer::TYPE_FIELDNAME); $caja_array['new_balance'] = $newbalance; $caja_array['caja_fecha'] = $caja_fecha->format('d-m-Y'); $caja_array['caja_fecha_js'] = $caja_fecha->format('m/d/Y'); $caja_array['cajatransaccion_nombre'] = $caja->getConceptocajachica()->getConceptocajachicaNombre(); return $this->getResponse()->setContent(\Zend\Json\Json::encode(array('response' => true, 'caja' => $caja_array))); } if ($this->params()->fromQuery('id')) { $id = $this->params()->fromQuery('id'); $caja = \CajachicaQuery::create()->joinConceptocajachica()->withColumn('conceptocajachica_nombre')->findOneByIdcajachica($id)->toArray(\BasePeer::TYPE_FIELDNAME); $dateJS = new \DateTime($caja['cajachica_fecha']); $caja['cajachica_fecha'] = $dateJS->format('d-m-Y'); //echo '<pre>';var_dump($caja); echo '<pre>';exit(); $viewModel = new ViewModel(); $viewModel->setTerminal(true); $viewModel->setVariable('caja', $caja); return $viewModel; } }