Ejemplo n.º 1
0
 public function getUseractivestatus()
 {
     $today = new \DateTime("now");
     $activatedate = new \DateTime($this->user->activated_date);
     $deactivatedate = new \DateTime($this->user->deactivated_date);
     $pausedate = new \DateTime($this->user->paused_date);
     $useractiveday = UserActivedays::find()->where(['user_id' => $this->user_id])->orderBy(['activated_date' => SORT_DESC])->one();
     if (isset($useractiveday)) {
         return $useractiveday->status;
     } else {
         return 'aktief';
     }
 }
Ejemplo n.º 2
0
 /**
  * Confirm email
  */
 public function actionConfirm($key)
 {
     /** @var \amnah\yii2\user\models\UserKey $userKey */
     /** @var \amnah\yii2\user\models\User $user */
     // search for userKey
     $success = false;
     $userKey = Yii::$app->getModule("user")->model("UserKey");
     $userKey = $userKey::findActiveByKey($key, [$userKey::TYPE_EMAIL_ACTIVATE, $userKey::TYPE_EMAIL_CHANGE]);
     if ($userKey) {
         // confirm user
         $user = Yii::$app->getModule("user")->model("User");
         $user = $user::findOne($userKey->user_id);
         $user->confirm();
         // add contact information to zoho invoices
         $resp = $this->addZoHoContact($user);
         $obj = json_decode($resp);
         // als er geen invoice kan worden aangemaakt verzend dan email.
         if (!isset($obj)) {
             $user->sendEmailWhenError($userKey, 'Er kan voor deze nieuwe aanmelder geen Invoice worden aangemaakt. Zie zoho');
             //throw new NotFoundHttpException('Er kan geen inv. aangemaakt worden foutcode(zhinv)');
         } else {
             $invoice = new UserInvoice();
             $invoice->user_id = $user->id;
             $invoice->zoho_contact_id = $obj->contact->contact_id;
             $invoice->save(false);
             $activedays = new UserActivedays();
             $activedays->user_id = $user->id;
             $activedays->save(false);
         }
         // consume userKey and set success
         $userKey->consume();
         $success = $user->email;
     }
     // render
     return $this->render("confirm", ["userKey" => $userKey, "success" => $success]);
 }
Ejemplo n.º 3
0
 public function actionPauseren($id)
 {
     $today = date("Y-m-d H:i:s");
     $useractiveday = UserActivedays::find()->where(['user_id' => $id])->orderBy(['activated_date' => SORT_DESC])->one();
     $p = new \DateTime($useractiveday->paused_date);
     // zet de oude gepauseerde datum
     $p = date_format($p, 'Y-m-d-');
     $a = new \DateTime($useractiveday->activated_date);
     $a = date_format($a, 'Y-m-d-');
     $t = new \DateTime($today);
     $t = date_format($t, 'Y-m-d-');
     if (isset($useractiveday)) {
         // indien aktieve  datum vandaag is en status is aktief
         if ($useractiveday->status == 'aktief' && $a == $t) {
             $tc = new \DateTime($today);
             $ac = new \DateTime($useractiveday->activated_date);
             $useractiveday->status = 'aktief';
             $useractiveday->paused_date = $t;
             $useractiveday->days = $ac->diff($tc)->days;
             $useractiveday->save(false);
             //insert new record as pause
             $uad = new UserActivedays();
             $uad->status = "pauze";
             $uad->user_id = $id;
             // zet user_id
             $uad->activated_date = $today;
             //zet activated day
             $uad->paused_date = '0000-00-00 00:00:00';
             $uad->create_time = $today;
             $uad->save();
         } elseif ($useractiveday->status == 'pauze' && $a == $t) {
             $lastactiveday = UserActivedays::find()->where(['user_id' => $id, 'status' => 'aktief'])->orderBy(['activated_date' => SORT_DESC])->one();
             $lastactiveday->paused_date = '0000-00-00 00:00:00';
             $lastactiveday->save(false);
             //delete pause date as it on the same date
             $useractiveday->delete();
         } elseif ($useractiveday->status == 'aktief' && $a != $t) {
             $t = new \DateTime($today);
             $a = new \DateTime($useractiveday->activated_date);
             $useractiveday->days = $a->diff($t)->days;
             $useractiveday->paused_date = $today;
             $useractiveday->save(false);
             $uad = new UserActivedays();
             $uad->status = "pauze";
             $uad->user_id = $id;
             // zet user_id
             $uad->activated_date = $today;
             //zet activated day
             $uad->paused_date = '0000-00-00 00:00:00';
             $uad->create_time = $today;
             $uad->save(false);
         } elseif ($useractiveday->status == 'pauze' && $a != $t) {
             $useractiveday->paused_date = $today;
             $useractiveday->save(false);
             $uad = new UserActivedays();
             $uad->status = "aktief";
             $uad->user_id = $id;
             // zet user_id
             $uad->activated_date = $today;
             //zet activated day
             $uad->paused_date = '0000-00-00 00:00:00';
             $uad->create_time = $today;
             $uad->save(false);
         }
     }
     return $this->redirect(['index']);
 }
Ejemplo n.º 4
0
 /**
  * Finds the UserActivedays model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return UserActivedays the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = UserActivedays::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }