/** * 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 Tallas(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Tallas'])) { $model->attributes = $_POST['Tallas']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function postNewTalla() { $inp = Input::all(); $rules = array('name_talla' => 'required', 'desc_talla' => 'required'); $msg = array('required' => 'El campo es obligatorio'); $validator = Validator::make($inp, $rules, $msg); if ($validator->fails()) { return Redirect::back()->withErrors($validator)->withInput(); } $talla = new Tallas(); $talla->talla_nomb = $inp['name_talla']; $talla->talla_desc = $inp['desc_talla']; if ($talla->save()) { Session::flash('success', 'Talla creada satisfactoriamente'); return Redirect::to('administrador/inicio'); } else { Session::flash('danger', 'Error al crear la talla'); return Redirect::back(); } }