/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate($idobservacion) { $model = new Observacionesdetalle(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Observacionesdetalle'])) { $model->attributes = $_POST['Observacionesdetalle']; $model->hidobservaciones = $idobservacion; $model->usuario = Yii::app()->user->name; $model->fecha = date("d-m-Y H:i:s"); if ($model->save()) { $modeloinventario = Observaciones::model()->findByPk($idobservacion); } if (!$this->enviamail($modeloinventario, $model->comentario)) { echo "fallo"; yii::app()->end(); } $model->refresh(); if (!empty($_GET['asDialog'])) { //Close the dialog, reset the iframe and update the grid echo CHtml::script("window.parent.\$('#cru-dialog1').dialog('close');\n\t\t\t\t\t\t\t\t\t\t\t\t\t window.parent.\$('#cru-frame1').attr('src','');\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\twindow.parent.\$.fn.yiiGridView.update('{$_GET['gridId']}');\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"); Yii::app()->end(); } $this->render('Confirma', array('id' => $model->id)); Yii::app()->end(); //$this->redirect(array('view','id'=>$model->id)); } $this->layout = '//layouts/iframe'; $this->render('create', array('model' => $model, 'idobservacion' => $idobservacion)); }
/** * 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 the ID of the model to be loaded */ public function loadModel($id) { $model = Observaciones::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'El enlace o direccion solicitado no existe'); } return $model; }