示例#1
0
 /**
  * Creates a new Contact model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Contact();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'company_id' => $model->company_id, 'user_id' => $model->user_id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
示例#2
0
 /**
  * Creates a new Contact model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Contact();
     $model->loadDefaultValues();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } elseif (!Yii::$app->request->isPost) {
         $model->load(Yii::$app->request->get());
     }
     if (Yii::$app->request->isAjax) {
         return $this->renderAjax('_form', ['model' => $model]);
     }
     return $this->render('create', ['model' => $model]);
 }
示例#3
0
 /**
  * Creates a new Company model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Company();
     if ($model->load(Yii::$app->request->post())) {
         $model->save();
         $company_id = $model->id;
         $user_id = Yii::$app->user->id;
         $contact = new Contact();
         $contact->company_id = $company_id;
         $contact->user_id = $user_id;
         $contact->roles_code = Roles::ROLE_EMP;
         if (!$contact->save()) {
             throw new NotFoundHttpException('Save contact error');
         }
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
示例#4
0
 /**
  * Creates a new Contact model.
  * If no group or category exist will redirect to related creation page.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Contact();
     $errorCode = 0;
     $categorie = Contact_category::getContact_category();
     if ($categorie == null) {
         $errorCode = 1;
     }
     $gruppi = Contact_group::getGruppi();
     if ($gruppi == null) {
         $errorCode = $errorCode + 2;
     }
     if ($errorCode > 0) {
         return $this->redirect(['create-group-or-category', 'errorCode' => $errorCode]);
     }
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         /* passage of parameter $categorie to 'create' view, and then to '_form' partial */
         return $this->render('create', ['model' => $model, 'categorie' => $categorie]);
     }
 }