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 '); } }
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; }