Exemple #1
0
 /**
  * Deletes an existing UserCv model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $model = $this->findModel($id);
     $user = User::findOne(['id' => $model->user_id]);
     $profile = Profile::findOne(['user_id' => $model->user_id]);
     $userabonnement = UserAbonnement::findOne(['user_id' => $model->user_id]);
     UserActivedays::deleteAll(['user_id' => $model->user_id]);
     $profile->delete();
     $usertarieven = UserTarieven::deleteAll(['user_id' => $model->user_id]);
     UserReistarief::deleteAll(['user_id' => $model->user_id]);
     if ($userabonnement) {
         $userabonnement->delete();
     }
     $model->delete();
     $user->delete();
     return $this->redirect(['index']);
 }
 /**
  * start de dialog om een contract aan te bieden
  **/
 public function actionDialogContr()
 {
     $id = ArrayHelper::getValue($_POST, 'id');
     $calenderevent = CalendarEvents::findOne(['id' => $id]);
     $start = substr($calenderevent->start, 0, 10);
     //Zie of er op die dag all contracten die zijn geaccepteerd.
     //
     $query = new Query();
     $query->from('calendar_events');
     $query->where(['start' => substr($calenderevent->start, 0, 10), 'user_id' => $calenderevent->user_id]);
     $query->andWhere(['like', 'code_title', 'Accep']);
     if ($query->count() > 0) {
         return $this->renderAjax('_dialogContrbezet', ['calenderevent' => $calenderevent]);
     }
     $usercv = UserCv::findOne(['user_id' => $calenderevent->user_id]);
     $user = User::findOne(['id' => $calenderevent->user_id]);
     $contractdeal = new ContractDeals();
     $company = Company::findOne(['id' => $user->company_id]);
     $usercontactperson = Gebruikers::findOne(['id' => $calenderevent->user_id]);
     return $this->renderAjax('_dialogContr', ['calenderevent' => $calenderevent, 'company' => $company, 'usercv' => $usercv, 'contractdeal' => $contractdeal, 'user' => $user]);
 }
 /**
  * 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]);
     }
 }