/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Listamateriales(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Listamateriales'])) { $model->attributes = $_POST['Listamateriales']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function actionCreafavorito($id) { //$modfav=new Documentosfavoritos(); $modelocabeza = Solpe::model()->findbypk($id); if (is_null($modelocabeza)) { throw new CHttpException(500, 'No existe esta solicitud con este ID'); } $modfav = new Listamateriales(); //$model->valorespordefecto(); // Uncomment the following line if AJAX validation is needed //$this->performAjaxValidation1($model); if (isset($_POST['Listamateriales'])) { $modfav->attributes = $_POST['Listamateriales']; //$modfav->codocu='340'; //$modfav->hidocu=$modelocabeza->id; $modfav->iduser = Yii::app()->user->id; //$modfav->hidocu=$modeloreferancia->id; if ($modfav->save()) { //agregabdo los detalles $hijos = $modelocabeza->solpe_desolpe; $modfav->refresh(); foreach ($hijos as $fila) { $regi = new Dlistamaeriales(); $regi->setAttributes(array('hidlista' => $modfav->id, 'codigo' => $fila->codart), false); $regi->save(); } if (!empty($_GET['asDialog'])) { //Close the dialog, reset the iframe and update the grid echo CHtml::script("window.parent.\$('#cru-dialogfavorito').dialog('close');\n\t\t\t\t\t\t\t\t\t\t\t\t\t window.parent.\$('#cru-detallefav').attr('src','');\n\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t"); Yii::app()->user->setFlash('success', " Se Agrego la lista '" . $modfav->nombrelista . "' a Sus Favoritos "); $this->render('update', array('model' => $modelocabeza, 'idcabeza' => $modelocabeza->id)); Yii::app()->end(); } } } // if (!empty($_GET['asDialog'])) $this->layout = '//layouts/iframe'; $this->render('_form_favorito', array('model' => $modfav, 'idcabeza' => $idcabeza)); }