/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $a = new Empleados(); $b = new Tallas(); // 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 = 2; $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('create', array('a' => $a, 'b' => $b)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Empleados(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Empleados'])) { $model->attributes = $_POST['Empleados']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }