/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Abonnement::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'prijs' => $this->prijs, 'periodeduur' => $this->periodeduur, 'restrictions' => $this->restrictions]); $query->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * Creates a new UserCv model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $userCp = Yii::$app->getModule("user")->model("User"); $userCp = $userCp::findOne(Yii::$app->user->userid); $abonnementType = Abonnement::findOne(['id' => $userCp->abonnement->abonnement_id]); $userCp->abonnement->checkAbonnement($abonnementType, $userCp->company_id); $userCv = new UserCv(); $user = new User(); // contactpersoon user $profile = new Profile(); $contactpersonuser_id = Yii::$app->user->id; $tarievenDag = UserTarievenDag::findOne(['user_id' => $contactpersonuser_id, 'naam' => 'Dagdienst']); $tarievenNacht = UserTarievenNacht::findOne(['user_id' => $contactpersonuser_id, 'naam' => 'Nachtdienst']); $tarievenWeekend = UserTarievenWeekend::findOne(['user_id' => $contactpersonuser_id, 'naam' => 'Weekenddienst']); $reisTarief = UserReistarief::findOne(['user_id' => $contactpersonuser_id]); $uploadMdl = null; //$userCv->branch_discipline = explode(',',$model->branch_discipline); //$userCv->branch_specialisatie = explode(',',$model->branch_specialisatie); if ($userCv->load(Yii::$app->request->post())) { $user->role_id = 5; //werknemer $user->company_id = Company::findOne(['user_id' => Yii::$app->user->id])->id; $contactpersonMdl = User::findOne(['id' => Yii::$app->user->id]); $user->status = 1; $user->email = Yii::$app->security->generateRandomString() . '_' . $contactpersonMdl->email; $user->username = Yii::$app->security->generateRandomString() . '_' . $contactpersonMdl->username; $user->password = $user->randomPassword(); $user->activated_date = time(); $user->create_time = time(); if ($user->save(false)) { if (2 == 1) { if ($userCv->documentfile) { $documentfile = UploadedFile::getInstance($userCv, 'documentfile'); $userCv->document_naam = $documentfile->name; $ext = end(explode(".", $documentfile->name)); $userCv->document_encryp = Yii::$app->security->generateRandomString() . ".{$ext}"; $path = Yii::$app->params['uploadPath'] . $userCv->document_encryp; } } $userCv->user_id = $user->id; // convert array's to string comma seperated $userCv->branch_discipline = implode(',', $userCv->branch_discipline); $userCv->branch_specialisatie = implode(',', $userCv->branch_specialisatie); $userCv->zoek = $userCv->branch_discipline . ',' . $userCv->branch_specialisatie . ',' . $userCv->voornaam . ',' . $userCv->achternaam; if ($userCv->save(false)) { if (isset($userCv->documentfile)) { $documentfile->saveAs($path); } $profile->user_id = $user->id; $profile->full_name = $userCv->volledige_naam; $profile->save(false); $this->saveTarieven(Yii::$app->request->post(), $user->id); $uad = new UserActivedays(); $uad->status = "aktief"; $uad->user_id = $user->id; // zet user_id $uad->activated_date = date("Y-m-d H:i:s"); $uad->paused_date = '0000-00-00 00:00:00'; $uad->create_time = date("Y-m-d H:i:s"); $uad->save(false); } } return $this->redirect('update?id=' . $userCv->id . '#collapseTwo'); } else { return $this->render('create', ['model' => $userCv, 'company' => Company::findOne(['user_id' => Yii::$app->user->id]), 'disciplines' => BranchDisciplines::allOmschrijvingen(), 'specialisaties' => BranchSpecialisaties::allOmschrijvingen(), 'tarievenDag' => $tarievenDag, 'tarievenNacht' => $tarievenNacht, 'tarievenWeekend' => $tarievenWeekend, 'reisTarief' => $reisTarief, 'uploadMdl' => $uploadMdl]); } }
/** * Finds the Abonnement model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Abonnement the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Abonnement::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
echo $form->field($company, 'adress'); ?> <?php echo $form->field($company, 'zip'); ?> <?php echo $form->field($company, 'city'); ?> <?php echo $form->field($company, 'telephone'); ?> <?php if (!$abonnementstypeMdl) { echo $form->field($userabonnement, 'abonnement_id')->dropDownList(ArrayHelper::map(Abonnement::find()->all(), 'id', 'name')); } ?> <div class="form-group"> <div class="col-lg-offset-2 col-lg-10"> <?php echo Html::submitButton(Yii::t('user', 'Register'), ['class' => 'btn btn-primary']); ?> <?php echo Html::a(Yii::t('user', 'Login'), ["/user/login"]); ?> </div> </div>
/** * Display registration page * input parameter $i is bedoeld om onderscheid te maken in abbonementstype aanbieding */ public function actionRegister($i = '') { $user = Yii::$app->getModule("user")->model("User", ["scenario" => "register"]); $profile = Yii::$app->getModule("user")->model("Profile"); $company = Yii::$app->getModule("user")->model("Company"); $userabonnement = Yii::$app->getModule("user")->model("UserAbonnement"); $abonnementstype = $i; //controleer of het abonnementype bestaat if (($abonnementstypeMdl = Abonnement::findOne($abonnementstype)) === null) { $abonnementstypeMdl = null; } // load post data $post = Yii::$app->request->post(); if ($user->load($post)) { // ensure profile data gets loaded $profile->load($post); $company->load($post); $userabonnement->load($post); // validate for ajax request if (Yii::$app->request->isAjax) { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($user, $profile, $company, $userabonnement); } // validate for normal request if ($user->validate() && $profile->validate() && $company->validate() && $userabonnement->validate()) { // perform registration $role = Yii::$app->getModule("user")->model("Role"); //DE rol contactpersoon wordt gezet $user->setRegisterAttributes($role::ROLE_CONTACTPERSON, Yii::$app->request->userIP)->save(false); $profile->setUser($user->id)->save(false); $company->setUser($user->id)->save(false); $user->company_id = $company->id; $userabonnement->user_id = $user->id; $userabonnement->newAbonnement(); $userabonnement->save(false); $user->save(true); //set de standaard tarieven bij registratie UserTarieven::defaultValues($user->id); $userreistarief = new UserReistarief(); $userreistarief->user_id = $user->id; $userreistarief->setDefaultValues(); $userreistarief->save(false); $this->afterRegister($user); // set flash // don't use $this->refresh() because user may automatically be logged in and get 403 forbidden $successText = Yii::t("user", "Successvol geregistreerd [ {displayName} ]", ["displayName" => $user->getDisplayName()]); $guestText = ""; if (Yii::$app->user->isGuest) { $guestText = Yii::t("user", " - Controleer nu uw E-mail om u account te bevestigen"); } Yii::$app->session->setFlash("Register-success", $successText . $guestText); } } // render return $this->render("register", ['user' => $user, 'profile' => $profile, 'company' => $company, 'userabonnement' => $userabonnement, 'abonnementstypeMdl' => $abonnementstypeMdl]); }
public static function abonnementDropdown() { // get and cache data static $dropdown; if ($dropdown === null) { // get all records from database and generate $models = Abonnement::findAll(['active' => 1]); foreach ($models as $model) { $dropdown[$model->id] = $model->name; } } return $dropdown; }
public function isActive() { $user = Yii::$app->getModule("user")->model("User"); $user = $user::findOne(Yii::$app->user->userid); $abonnementType = Abonnement::findOne(['id' => $user->abonnement->abonnement_id]); $today = new \DateTime("now"); $end = new \DateTime($this->end); if ($this->active == 0) { throw new ForbiddenHttpException(' <div class="panel-body"> <div class="panel panel-primary"> <div class="text-center"> <h4> <br>Je abonnement is niet actief omdat je abonnenttype dat nu niet toelaat! <br><br>Je abonnement type is: <br> </h4> <div class="well">' . $abonnementType->name . '<br><br>' . $abonnementType->description . '</div> <a href="http://werkmetspoor.nl/index.php/abonnement-vragen/" class="btn btn-primary" role="button">Klik hier voor al onze abonnementstypen.</a> <a href="http://werkmetspoor.nl/index.php/contact/" class="btn btn-danger" role="button">Neem contact met ons op over je abonnement</a> <br><br> <br><br> </div> </div> </div> '); } if ($end < $today) { throw new ForbiddenHttpException(' <div class="text-center"> <h4> <p class="bg-danger"> <br>Uw abonnement verlopen is op ' . $end->format('d-m-Y') . ' !<br><br> Uiteraard wilen we u graag weer als klant terug. <br><br> <a href="http://werkmetspoor.nl/index.php/abonnement-vragen/" class="btn btn-danger" role="button">Neem u alstublieft contact met ons op</a> <br><br> </p> </h4> </div> '); } }