コード例 #1
0
 public function editarmovmientoAction()
 {
     $request = $this->request;
     if ($request->isPost()) {
         $post_data = $request->getPost();
         $id = $post_data['idbanco'];
         $banco = \BancoQuery::create()->findOneByIdbanco($id);
         $banco_old = $banco->toArray(\BasePeer::TYPE_FIELDNAME);
         $banco_fecha = \DateTime::createFromFormat('d-m-Y', $post_data['banco_fecha']);
         $banco->setIdconceptobanco($post_data['idconcepto'])->setBancoFecha($banco_fecha->format('Y-m-d'))->setBancoTipomovimiento($post_data["banco_tipomoviento"])->setBancoCantidad($post_data['banco_cantidad'])->setBancoComprobante($post_data['banco_comprobante'])->setBancoNota($post_data['banco_nota']);
         $banco->save();
         //Actualizamos nustro balance
         $first_row = \BancoQuery::create()->orderByIdbanco('asc')->findOne();
         $current_balance = $first_row->getBancoBalance();
         if ($banco_old['banco_tipomovimiento'] == 'cargo') {
             $reset_balance = $current_balance - $banco_old['banco_cantidad'];
             $newbalance = $reset_balance + $banco->getBancoCantidad();
         } else {
             $reset_balance = $current_balance + $banco_old['banco_cantidad'];
             $newbalance = $reset_balance - $banco->getBancoCantidad();
         }
         $first_row->setBancoBalance($newbalance);
         $first_row->save();
         $banco = \BancoQuery::create()->joinConceptobanco()->withColumn('bancotransaccion_nombre')->findOneByIdbanco($id);
         $banco_array = $banco->toArray(\BasePeer::TYPE_FIELDNAME);
         $banco_array['new_balance'] = $newbalance;
         $banco_array['banco_fecha'] = $banco_fecha->format('d-m-Y');
         $banco_array['banco_fecha_js'] = $banco_fecha->format('m/d/Y');
         $banco_array['bancotransaccion_nombre'] = $banco->getConceptobanco()->getBancotransaccionNombre();
         return $this->getResponse()->setContent(\Zend\Json\Json::encode(array('response' => true, 'banco' => $banco_array)));
     }
     if ($this->params()->fromQuery('id')) {
         $id = $this->params()->fromQuery('id');
         $banco = \BancoQuery::create()->joinConceptobanco()->withColumn('bancotransaccion_nombre')->findOneByIdbanco($id)->toArray(\BasePeer::TYPE_FIELDNAME);
         $dateJS = new \DateTime($banco['banco_fecha']);
         $banco['banco_fecha'] = $dateJS->format('d-m-Y');
         //echo '<pre>';var_dump($banco); echo '<pre>';exit();
         $viewModel = new ViewModel();
         $viewModel->setTerminal(true);
         $viewModel->setVariable('banco', $banco);
         return $viewModel;
     }
 }
コード例 #2
0
ファイル: BaseConceptobanco.php プロジェクト: jalvarez14/hva
 /**
  * Returns the number of related Banco objects.
  *
  * @param Criteria $criteria
  * @param boolean $distinct
  * @param PropelPDO $con
  * @return int             Count of related Banco objects.
  * @throws PropelException
  */
 public function countBancos(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     $partial = $this->collBancosPartial && !$this->isNew();
     if (null === $this->collBancos || null !== $criteria || $partial) {
         if ($this->isNew() && null === $this->collBancos) {
             return 0;
         }
         if ($partial && !$criteria) {
             return count($this->getBancos());
         }
         $query = BancoQuery::create(null, $criteria);
         if ($distinct) {
             $query->distinct();
         }
         return $query->filterByConceptobanco($this)->count($con);
     }
     return count($this->collBancos);
 }
コード例 #3
0
 /**
  * Get the associated Banco object
  *
  * @param PropelPDO $con Optional Connection object.
  * @param $doQuery Executes a query to get the object if required
  * @return Banco The associated Banco object.
  * @throws PropelException
  */
 public function getBanco(PropelPDO $con = null, $doQuery = true)
 {
     if ($this->aBanco === null && $this->idbanco !== null && $doQuery) {
         $this->aBanco = BancoQuery::create()->findPk($this->idbanco, $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->aBanco->addBancotransaccions($this);
            */
     }
     return $this->aBanco;
 }
コード例 #4
0
ファイル: BaseBanco.php プロジェクト: jalvarez14/hva
 /**
  * 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(BancoPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     $con->beginTransaction();
     try {
         $deleteQuery = BancoQuery::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;
     }
 }
コード例 #5
0
ファイル: BaseBancoQuery.php プロジェクト: jalvarez14/hva
 /**
  * Returns a new BancoQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param   BancoQuery|Criteria $criteria Optional Criteria to build the query from
  *
  * @return BancoQuery
  */
 public static function create($modelAlias = null, $criteria = null)
 {
     if ($criteria instanceof BancoQuery) {
         return $criteria;
     }
     $query = new BancoQuery(null, null, $modelAlias);
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }