public static function insertaprimerdetallecaja($id, $saldo) { $modelopadre = Cajachica::model()->findByPk($id); $modelodet = new Dcajachica(); $modelodet->hidcaja = $id; $modelodet->codtra = $modelopadre->codtra; }
public function checkfecha($attribute, $params) { $fechainicio = Cajachica::model()->findByPk($this->hidcaja)->fechaini; $fechafin = Cajachica::model()->findByPk($this->hidcaja)->fechafin; if (!yii::app()->periodo->estadentrodefechas($fechainicio, $this->fecha, $fechafin)) { $this->adderror('Fecha', 'Esta fecha no esta dentro del perido de la cabecera '); } }
/** * 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; }
public function checksepuedeabrir($attribute, $params) { $devolver = false; $valorultimo = Yii::app()->db->createCommand()->select('max(a.id)')->from('{{cajachica}} a')->where(' a.serie=:vserie and codestado <>:vanulado and codestado ', array(":vserie" => $this->serie, ":vanulado" => ESTADO_CAJA_ANULADO))->queryScalar(); if ($valorultimo != false) { ///anualizamo esta caja $cajaanterior = Cajachica::model()->findBypK((int) $valorultimo); if ($cajaanterior->hijospendientes == 0) { $devolver = false; } } else { $devolver = true; //se puede abrir no hay registro anteriores } if (!$devolver) { $this->adderror('serie', " Aun existe una caja en esta serie pendiente de liquidar "); } }
/** * 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 Cajachica the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Cajachica::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * 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'); } }
/** * @param Cajachica $cajachica The cajachica object to add. */ protected function doAddCajachica($cajachica) { $this->collCajachicas[] = $cajachica; $cajachica->setConceptocajachica($this); }
/** * 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; }
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))); } } }
/** * Filter the query by a related Cajachica object * * @param Cajachica|PropelObjectCollection $cajachica the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ConceptocajachicaQuery 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(ConceptocajachicaPeer::IDCONCEPTOCAJACHICA, $cajachica->getIdconceptocajachica(), $comparison); } elseif ($cajachica instanceof PropelObjectCollection) { return $this->useCajachicaQuery()->filterByPrimaryKeys($cajachica->getPrimaryKeys())->endUse(); } else { throw new PropelException('filterByCajachica() only accepts arguments of type Cajachica or PropelCollection'); } }
/** * 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; } }