Exemplo n.º 1
0
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     //userCv
     $user = User::findOne(['id' => $model->user_id]);
     $model->username = $user->username;
     $tarievenDag = UserTarievenDag::findOne(['user_id' => $model->user_id, 'naam' => 'Dagdienst']);
     $tarievenNacht = UserTarievenNacht::findOne(['user_id' => $model->user_id, 'naam' => 'Nachtdienst']);
     $tarievenWeekend = UserTarievenWeekend::findOne(['user_id' => $model->user_id, 'naam' => 'Weekenddienst']);
     $reisTarief = UserReistarief::findOne(['user_id' => $model->user_id]);
     $uploadMdl = new UploadForm();
     $uploadMdl->init($model->user_id);
     // convert  string to array
     $model->branch_discipline = explode(',', $model->branch_discipline);
     $model->branch_specialisatie = explode(',', $model->branch_specialisatie);
     if (!isset($tarievenDag)) {
         $tarievenDag = new UserTarieven();
     }
     if (!isset($tarievenNacht)) {
         $tarievenNacht = new UserTarieven();
     }
     if (!isset($tarievenWeekend)) {
         $tarievenWeekend = new UserTarieven();
     }
     if (!isset($reisTarief)) {
         $reisTarief = new UserReistarief();
     }
     //$userCvDocs = UserCvDocs::find()->where(['user_id' =>$model->user_id])->asArray()->all();
     if ($model->load(Yii::$app->request->post())) {
         //uplaod files to user dir
         $uploadMdl->docFiles = UploadedFile::getInstances($uploadMdl, 'docFiles');
         $uploadMdl->upload($model->user_id);
         // convert array's to string comma seperated
         $model->branch_discipline = implode(',', $model->branch_discipline);
         $model->branch_specialisatie = implode(',', $model->branch_specialisatie);
         $model->save(false);
         $tarievenDag->load(Yii::$app->request->post());
         $tarievenWeekend->user_id = $model->user_id;
         $tarievenDag->naam = 'Dagdienst';
         $tarievenDag->omschrijving = 'Dagdienst';
         $tarievenDag->save(false);
         $tarievenNacht->load(Yii::$app->request->post());
         $tarievenNacht->user_id = $model->user_id;
         $tarievenNacht->naam = 'Nachtdienst';
         $tarievenNacht->omschrijving = 'Nachtdienst';
         $tarievenNacht->save(false);
         $tarievenWeekend->load(Yii::$app->request->post());
         $tarievenWeekend->user_id = $model->user_id;
         $tarievenWeekend->naam = 'Weekenddienst';
         $tarievenWeekend->omschrijving = 'Weekenddienst';
         $tarievenWeekend->save(false);
         $reisTarief->load(Yii::$app->request->post());
         $reisTarief->user_id = $model->user_id;
         $tarievenDag->save(false);
         $uploadMdl = new UploadForm();
         $uploadMdl->init($model->user_id);
     }
     return $this->render('update', ['model' => $model, 'company' => Company::findOne(['user_id' => Yii::$app->user->id]), 'disciplines' => BranchDisciplines::allOmschrijvingen(), 'specialisaties' => BranchSpecialisaties::allOmschrijvingen(), 'user' => $user, 'tarievenDag' => $tarievenDag, 'tarievenNacht' => $tarievenNacht, 'tarievenWeekend' => $tarievenWeekend, 'reisTarief' => $reisTarief, 'uploadMdl' => $uploadMdl]);
 }
Exemplo n.º 2
0
 /**
  * Updates an existing Company model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate()
 {
     $userid = Yii::$app->user->identity;
     //        if(!$userid)  return;
     $user = User::findOne($userid->id);
     $company = Company::findOne(['user_id' => $userid->id]);
     $tarievenDag = UserTarievenDag::findOne(['user_id' => $user->id, 'naam' => 'Dagdienst']);
     $tarievenNacht = UserTarievenNacht::findOne(['user_id' => $user->id, 'naam' => 'Nachtdienst']);
     $tarievenWeekend = UserTarievenWeekend::findOne(['user_id' => $user->id, 'naam' => 'Weekenddienst']);
     $tariefReizen = UserReistarief::findOne(['user_id' => $user->id]);
     $profile = Profile::findOne(['user_id' => $user->id]);
     $abonnement = UserAbonnement::findOne(['user_id' => $userid->id]);
     $userLoaded = $user->load(Yii::$app->request->post());
     if ($userLoaded && $user->validate()) {
         if (Yii::$app->getModule("user")->emailChangeConfirmation && $user->checkAndPrepEmailChange()) {
             $userKey = Yii::$app->getModule("user")->model("UserKey");
             $userKey = $userKey::generate($user->id, $userKey::TYPE_EMAIL_CHANGE);
             if (!($numSent = $user->sendEmailConfirmation($userKey))) {
                 // handle email error
                 Yii::$app->session->setFlash("Email-error", "Failed to send email");
                 return $this->refresh();
             }
         }
     }
     if ($user->load(Yii::$app->request->post()) && $user->save() && $company->load(Yii::$app->request->post()) && $company->save() && $tarievenDag->load(Yii::$app->request->post()) && $tarievenDag->save() && $tarievenNacht->load(Yii::$app->request->post()) && $tarievenNacht->save() && $tarievenWeekend->load(Yii::$app->request->post()) && $tarievenWeekend->save() && $tariefReizen->load(Yii::$app->request->post()) && $tariefReizen->save() && $profile->load(Yii::$app->request->post()) && $profile->save() && $abonnement->load(Yii::$app->request->post()) && $abonnement->save()) {
         $this->updateZoHoContact($user);
         Yii::$app->session->setFlash("Account-success", Yii::t("user", "Account updated"));
         return $this->refresh();
         //return $this->redirect(['update',]);
     } else {
         return $this->render('update', ['company' => $company, 'user' => $user, 'tarievenDag' => $tarievenDag, 'tarievenNacht' => $tarievenNacht, 'tarievenWeekend' => $tarievenWeekend, 'tariefReizen' => $tariefReizen, 'profile' => $profile, 'abonnement' => $abonnement]);
     }
 }
Exemplo n.º 3
0
 public function getUserweekendtarief()
 {
     $formatter = \Yii::$app->formatter;
     $UserTarievenWeekend = UserTarievenWeekend::findOne(['user_id' => $this->user_id, 'omschrijving' => 'Weekenddienst']);
     if (isset($UserTarievenWeekend) && $UserTarievenWeekend->tarief > 0) {
         return $formatter->asCurrency($UserTarievenWeekend->tarief, 'EUR') . '/' . $UserTarievenWeekend->tarief_eenheid . ' vanaf ' . $UserTarievenWeekend->dag_vanaf . ' tot/met ' . $UserTarievenWeekend->dag_totenmet;
     } else {
         return 'n.v.t.';
     }
 }
Exemplo n.º 4
0
 public function updateTarieven($post, $user_id)
 {
     $tarievenDag = UserTarievenDag::findOne(['user_id' => $user_id, 'naam' => 'Dagdienst']);
     $tarievenNacht = UserTarievenNacht::findOne(['user_id' => $user_id, 'naam' => 'Nachtdienst']);
     $tarievenWeekend = UserTarievenWeekend::findOne(['user_id' => $user_id, 'naam' => 'Weekenddienst']);
     // $tariefReizen       = UserReistarief::findOne(['user_id'=>$user_id,]);
     $tarievenDag->load($post);
     $tarievenDag->save(false);
     $tarievenNacht->load($post);
     $tarievenNacht->save(false);
     $tarievenWeekend->load($post);
     $tarievenWeekend->save(false);
     //$tarievenReis->load($post);
     //$tarievenReis->save(false);
     return;
 }
Exemplo n.º 5
0
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     //userCv
     $user = User::findOne(['id' => $model->user_id]);
     $model->username = $user->username;
     $tarievenDag = UserTarievenDag::findOne(['user_id' => $model->user_id, 'naam' => 'Dagdienst']);
     $tarievenNacht = UserTarievenNacht::findOne(['user_id' => $model->user_id, 'naam' => 'Nachtdienst']);
     $tarievenWeekend = UserTarievenWeekend::findOne(['user_id' => $model->user_id, 'naam' => 'Weekenddienst']);
     if (!isset($tarievenDag)) {
         $tarievenDag = new UserTarieven();
     }
     if (!isset($tarievenNacht)) {
         $tarievenNacht = new UserTarieven();
     }
     if (!isset($tarievenWeekend)) {
         $tarievenWeekend = new UserTarieven();
     }
     if ($model->load(Yii::$app->request->post())) {
         if (1 == 1) {
             //$documentfile = UploadedFile::getInstance($model, 'documentfile');
             // store the source file name
             //$model->document_naam = $documentfile->name;
             //if(!$model->document_encryp)
             //{
             //    $ext = end((explode(".", $documentfile->name)));
             //    $model->document_encryp = Yii::$app->security->generateRandomString().".$ext";
             //}
             //$path = Yii::$app->params['uploadPath'] . $model->document_encryp;
             //if( $model->save())
             //{
             //$documentfile->saveAs($path);
             //}
         }
         $model->save();
         $tarievenDag->load(Yii::$app->request->post());
         $tarievenWeekend->user_id = $model->user_id;
         $tarievenDag->naam = 'Dagdienst';
         $tarievenDag->omschrijving = 'Dagdienst';
         $tarievenDag->save(false);
         $tarievenNacht->load(Yii::$app->request->post());
         $tarievenNacht->user_id = $model->user_id;
         $tarievenNacht->naam = 'Nachtdienst';
         $tarievenNacht->omschrijving = 'Nachtdienst';
         $tarievenNacht->save(false);
         $tarievenWeekend->load(Yii::$app->request->post());
         $tarievenWeekend->user_id = $model->user_id;
         $tarievenWeekend->naam = 'Weekenddienst';
         $tarievenWeekend->omschrijving = 'Weekenddienst';
         $tarievenWeekend->save(false);
         return $this->redirect(['index']);
     } else {
         return $this->render('update', ['model' => $model, 'company' => Company::findOne(['user_id' => Yii::$app->user->id]), 'disciplines' => BranchDisciplines::allOmschrijvingen(), 'specialisaties' => BranchSpecialisaties::allOmschrijvingen(), 'user' => $user, 'tarievenDag' => $tarievenDag, 'tarievenNacht' => $tarievenNacht, 'tarievenWeekend' => $tarievenWeekend]);
     }
 }