Example #1
0
 public function actionCreaservicio($idcabeza, $cest)
 {
     //VERIFICADO PRIMERO SI ES POSIBLE AGREGAR MAS ITEMS
     $modelocabeza = Solpe::model()->findbypk($idcabeza);
     if (is_null($modelocabeza)) {
         throw new CHttpException(500, 'No existe esta solicitud con este ID');
     }
     if ($modelocabeza->estado == ESTADO_CREADO or $modelocabeza->estado == ESTADO_PREVIO) {
         $model = new Desolpe();
         $model->setScenario('servicios');
         $model->valorespordefecto();
         // Uncomment the following line if AJAX validation is needed
         $this->performAjaxValidation($model);
         if (isset($_POST['Desolpe'])) {
             $model->attributes = $_POST['Desolpe'];
             $model->codocu = '350';
             ///detalle guia
             $model->tipsolpe = 'S';
             //SERVICIO
             $model->codart = CODIGO_MATERIAL_SERVICIO;
             /*var_dump($model->codart);
             		yii::app()->end();*/
             if ($model->save()) {
                 if (!empty($_GET['asDialog'])) {
                     //Close the dialog, reset the iframe and update the grid
                     echo CHtml::script("window.parent.\$('#cru-dialogdetalle').dialog('close');\n\t\t\t\t\t\t\t\t\t\t\t\t\t                    window.parent.\$('#cru-detalle').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('detalle-grid');\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t");
                     Yii::app()->end();
                 }
             }
         }
         // if (!empty($_GET['asDialog']))
         $this->layout = '//layouts/iframe';
         $this->render('_form_servicio', array('model' => $model, 'idcabeza' => $idcabeza));
     } else {
         //si ya cambio el estado impisble agregar mas items
         if (!empty($_GET['asDialog'])) {
             $this->layout = '//layouts/iframe';
         }
         $this->render('vw_imposible', array());
     }
 }