/**
  * Creates a new Documento model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Documento();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Exemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function upload()
 {
     if ($this->validate()) {
         $this->url->saveAs('uploads/' . $this->url->baseName . '.' . $this->url->extension);
         $documento = new Documento();
         $documento->url = $this->url->baseName . '.' . $this->url->extension;
         $documento->nombre = $this->url->baseName;
         $documento->save(false);
         $proyecto = Proyecto::findOne($this->id_proyecto);
         $proyecto->id_Anteproyecto = $documento->id_Documento;
         $proyecto->save(false);
         return true;
     } else {
         return false;
     }
 }
Exemplo n.º 3
0
 /**
  * Creates a new Documento model.
  * For ajax request will return json object
  * and for non-ajax request if creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $request = Yii::$app->request;
     $model = new Documento();
     if ($request->isAjax) {
         /*
          *   Process for ajax request
          */
         Yii::$app->response->format = Response::FORMAT_JSON;
         if ($request->isGet) {
             return ['title' => "Create new Documento", 'content' => $this->renderPartial('create', ['model' => $model]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])];
         } else {
             if ($model->load($request->post()) && $model->save()) {
                 return ['forceReload' => 'true', 'title' => "Create new Documento", 'content' => '<span class="text-success">Create Documento success</span>', 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::a('Create More', ['create'], ['class' => 'btn btn-primary', 'role' => 'modal-remote'])];
             } else {
                 return ['title' => "Create new Documento", 'content' => $this->renderPartial('create', ['model' => $model]), 'footer' => Html::button('Close', ['class' => 'btn btn-default pull-left', 'data-dismiss' => "modal"]) . Html::button('Save', ['class' => 'btn btn-primary', 'type' => "submit"])];
             }
         }
     } else {
         /*
          *   Process for non-ajax request
          */
         if ($model->load($request->post()) && $model->save()) {
             return $this->redirect(['view', 'numeroDocumentoEmisor' => $model->numeroDocumentoEmisor, 'serieNumero' => $model->serieNumero, 'tipoDocumento' => $model->tipoDocumento, 'tipoDocumentoEmisor' => $model->tipoDocumentoEmisor]);
         } else {
             return $this->render('create', ['model' => $model]);
         }
     }
 }