/**
  * Creates a new Bedrijf model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Bedrijf();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->bedrijfid]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 public function actionIndex()
 {
     $model = new Bedrijf();
     $contactModel = new Contact();
     $debiteurModel = new Debiteur();
     $debiteurContactModel = new DebiteurContact();
     $vorderingModel = new Vordering();
     $documentenModel = new Documenten();
     $fileModel = new UploadFile();
     if ($model->load(Yii::$app->request->post()) && $contactModel->load(Yii::$app->request->post()) && $debiteurModel->load(Yii::$app->request->post()) && $debiteurContactModel->load(Yii::$app->request->post()) && $vorderingModel->load(Yii::$app->request->post()) && $fileModel->load(Yii::$app->request->post())) {
         $isValid = false;
         $isValid = $model->validate();
         $isValid = $contactModel->validate() && $isValid;
         $isValid = $debiteurModel->validate() && $isValid;
         $isValid = $debiteurContactModel->validate() && $isValid;
         $isValid = $vorderingModel->validate() && $isValid;
         $isValid = $fileModel->validate() && $isValid;
         if ($isValid) {
             $model->save(false);
             $contactModel->save(false);
             $debiteurModel->save(false);
             $debiteurContactModel->save(false);
             $vorderingModel->bedrijfid = $model->getPrimaryKey();
             $vorderingModel->contactid = $contactModel->getPrimaryKey();
             $vorderingModel->debiteurid = $debiteurModel->getPrimaryKey();
             $vorderingModel->debiteurcontactid = $debiteurContactModel->getPrimaryKey();
             $vorderingModel->save(false);
             $documentenModel->vorderingid = $vorderingModel->getPrimaryKey();
             $fileModel->vorderingid = $vorderingModel->getPrimaryKey();
             $fileModel->files = UploadedFile::getInstances($fileModel, 'files');
             if ($fileModel->files) {
                 if ($fileModel->upload()) {
                     foreach ($fileModel->uploadedFiles as $file) {
                         $documentenModel->setIsNewRecord(true);
                         $documentenModel->naam = $file['naam'];
                         $documentenModel->map = $file['map'];
                         $documentenModel->save(false);
                         unset($documentenModel->documentid);
                     }
                 } else {
                     Yii::$app->session->setFlash('error', 'Kon bestand niet uploaden.');
                 }
             }
             Yii::$app->session->setFlash('success', 'Dank u voor uw aanmelding.');
         }
         return $this->refresh();
     }
     return $this->render('aanmeldform', ['model' => $model, 'contactModel' => $contactModel, 'debiteurModel' => $debiteurModel, 'debiteurContactModel' => $debiteurContactModel, 'vorderingModel' => $vorderingModel, 'documentenModel' => $documentenModel, 'fileModel' => $fileModel]);
 }
 /**
  * Finds the Bedrijf model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Bedrijf the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Bedrijf::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Exemple #4
0
 public function getBedrijf()
 {
     return $this->hasOne(Bedrijf::className(), ['bedrijfid' => 'bedrijfid']);
 }