/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate($id) { $a = $this->loadModel($id); $b = Tallas::model()->findByAttributes(array('id' => $a->id_talla)); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Empleados'], $_POST['Tallas'])) { $a->attributes = $_POST['Empleados']; $b->attributes = $_POST['Tallas']; $valid = $a->validate(); $valid = $b->validate() && $valid; if ($valid) { $b->save(false); $a->id_talla = $b->id; $a->save(false); date_default_timezone_set('America/Caracas'); $auditoria = new Auditoria(); $auditoria->id_user = Yii::app()->user->getId(); $auditoria->accion = 3; $auditoria->modelo = $this->modelo; $auditoria->id_registro = $a->id; $auditoria->fecha = date("Y-m-d h:i:s"); $auditoria->save(false); $this->redirect(array('admin')); } /*if($model->save()) $this->redirect(array('view','id'=>$model->id));*/ } $this->render('update', array('a' => $a, 'b' => $b)); }
/** * 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 Tallas the loaded model * @throws CHttpException */ public function loadModel($id) { $model = Tallas::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }