/**
  * @return mixed
  */
 public function handleRegister()
 {
     $rules = ['first_name' => 'required|min:3', 'last_name' => 'required|min:3', 'email' => 'unique:User:email|required|email', 'confirm-email' => 'required|email|equalTo:email', 'agree' => 'required', 'password' => 'required|min:3', 'confirm-password' => 'required|equalTo:password', 'join_list' => 'required'];
     $errors = $this->validate($rules);
     if (sizeof($errors) > 0) {
         $html = $this->blade->with('session', $this->session)->withTemplate('register')->render();
         $new_html = $this->repopulateForm($html, $errors, $this->request->getParameters());
         return $this->response->setContent($new_html);
     } else {
         $user = new User();
         $user->email = $this->request->getParameter('email');
         $user->password = password_hash($this->request->getParameter('password'), PASSWORD_DEFAULT);
         $user->save();
         $user_id = $user->id;
         $registration = new Registration();
         $registration->user_id = $user_id;
         $registration->first_name = $this->request->getParameter('first_name');
         $registration->last_name = $this->request->getParameter('last_name');
         $registration->colour = $this->request->getParameter('colour');
         $registration->comments = $this->request->getParameter('comments');
         $registration->join_list = $this->request->getParameter('join_list');
         $registration->save();
         return $this->response->setContent($this->blade->with('session', $this->session)->render("generic-page", ['content' => 'Thanks for joining our site!', 'title' => 'Thanks!']));
     }
 }
 public function actionRegistration()
 {
     $model = new Registration();
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         /*password*/
         /*$password = substr(md5($username),0,8);*/
         /*email for link*/
         $email_link = md5($username . time());
         /*generate activation link*/
         $link = Yii::$app->urlManager->createAbsoluteUrl(['site/activate', 'code' => $email_link]);
         if ($user = $model->registrations($email_link, $password)) {
             $data = Yii::$app->request->post('Registration');
             $data['operation'] = 'registration';
             $data['url'] = Url::to('');
             $data['text'] = 'Сайт, страница регистрации';
             $data['message'] = 'Зарегестрировался пользователь под именем -> ' . $data['name'] . ', почтовый ящик -> ' . $data['username'];
             $logs = Logs::loger($data);
             /*sending email*/
             $send = User::send_email($model->username, $link);
             return $this->redirect('index.php?r=site/confirmate');
         }
     } else {
         // либо страница отображается первый раз, либо есть ошибка в данных
         return $this->render('registration', ['model' => $model]);
     }
 }
Пример #3
0
 /**
  * Sends an e-mail to request confirmation for
  * @param  \App\Models\Registration $registration
  * @return void
  */
 public static function confirmationEmail(\App\Models\Registration $registration)
 {
     Mail::send(['mails/confirmRegistration/html', 'mails/confirmRegistration/text'], ['registration' => $registration], function ($message) use($registration) {
         $message->to($registration->email, $registration->name);
         $message->subject("Bevestigen aanmelding maaltijd " . $registration->longDate());
     });
 }
Пример #4
0
 /**
  * @param $id
  * @return \yii\web\Response
  * @throws NotFoundHttpException
  * @throws \yii\db\Exception
  */
 public function actionPreregister($id)
 {
     $model = $this->findModel($id);
     $user = User::find()->where("id=" . Yii::$app->user->id)->one();
     $user_id = $user->id;
     $student = Student::find()->where("user_id=" . $user_id)->one();
     $student_id = $student->id;
     $vacancy = ProjectVacancy::find()->where("project_id=" . $id)->one();
     $vacancyValue = $vacancy->vacancy;
     if ($existe = StudentProfile::find()->where(['project_id' => $id, 'degree_id' => $student->degree_id])->one()) {
         if (Registration::find()->where(['student_id' => $student_id])->one()) {
             Yii::$app->getSession()->setFlash('danger', 'Ya te has pre-registrado a un proyecto');
             return $this->redirect(['view', 'id' => $model->id]);
         } else {
             if ($vacancyValue > 0) {
                 $newRegistration = new Registration();
                 $newRegistration->project_id = $id;
                 $newRegistration->student_id = $student_id;
                 $newRegistration->student_status = "preregistered";
                 $newRegistration->save();
                 Yii::$app->db->createCommand()->update('project_vacancy', ['vacancy' => $vacancy->vacancy - 1], 'project_id=' . $id)->execute();
                 Yii::$app->getSession()->setFlash('success', 'Te has pre-registrado al proyecto');
                 return $this->redirect(['view', 'id' => $model->id]);
             } else {
                 Yii::$app->getSession()->setFlash('danger', 'No hay cupo para este proyecto. Escoge otro.');
                 return $this->redirect(['view', 'id' => $model->id]);
             }
         }
     } else {
         Yii::$app->getSession()->setFlash('danger', 'No cuentas con el perfil solicitado');
         return $this->redirect(['view', 'id' => $model->id]);
     }
 }
Пример #5
0
 /**
  * Удаление информации о регистрации по реферальной ссылке
  *
  * REQUEST:
  * - id - int - идентификатор cap_registration.id
  *
  * @return string
  */
 public function actionReferal_delete()
 {
     $id = self::getParam('id');
     $item = Registration::find($id);
     if (is_null($item)) {
         return self::jsonError('Нет такой записи');
     }
     $item->delete();
     return self::jsonSuccess();
 }
 /**
  * @return string|\yii\web\Response
  */
 public function actionSelectProject()
 {
     $model = new Task();
     $project = $_POST['list'];
     if (Registration::find()->where("projectId=" . $project)->all()) {
         return $this->render('create', ['model' => $model, 'projectId' => $project]);
     } else {
         Yii::$app->getSession()->setFlash('danger', 'No hay estudiantes en el proyecto seleccionado ');
         return $this->redirect(['index']);
     }
 }
Пример #7
0
 /**
  * Return the position (#1, #2, etc) of this user in the top-eaters list for this year
  * @return integer or null when not in the list
  */
 public function topEatersPositionThisYear()
 {
     $entries = Registration::top_ytd();
     $rank = 0;
     foreach ($entries as $entry) {
         $rank++;
         if ($entry->id === $this->id) {
             return $rank;
         }
     }
     return null;
 }
 /**
  * AJAX
  * Активирует запрос
  */
 public function actionActivate_ajax()
 {
     $request = Request::find(self::getParam('id'));
     if (is_null($request)) {
         return self::jsonError('Нет такого запроса');
     }
     $r = Registration::find(['user_id' => $request->getField('user_id')]);
     if (!is_null($r)) {
         $r->update(['is_paid' => 1]);
     }
     $request->activate();
     return self::jsonSuccess();
 }
Пример #9
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Registration::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'registration_type_id' => $this->registration_type_id, 'zip' => $this->zip]);
     $query->andFilterWhere(['like', 'organization_name', $this->organization_name])->andFilterWhere(['like', 'first_name', $this->first_name])->andFilterWhere(['like', 'last_name', $this->last_name])->andFilterWhere(['like', 'display_name', $this->display_name])->andFilterWhere(['like', 'degree', $this->degree])->andFilterWhere(['like', 'business_phone', $this->business_phone])->andFilterWhere(['like', 'fax', $this->fax])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'email2', $this->email2])->andFilterWhere(['like', 'address1', $this->address1])->andFilterWhere(['like', 'address2', $this->address2])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'state', $this->state])->andFilterWhere(['like', 'province', $this->province])->andFilterWhere(['like', 'country', $this->country])->andFilterWhere(['like', 'student_id', $this->student_id])->andFilterWhere(['like', 'payment_receipt', $this->payment_receipt])->andFilterWhere(['like', 'emergency_name', $this->emergency_name])->andFilterWhere(['like', 'emergency_phone', $this->emergency_phone])->andFilterWhere(['like', 'token', $this->token]);
     return $dataProvider;
 }
Пример #10
0
 public function confirm($id, $salt)
 {
     $registration = Registration::find((int) $id);
     if (!$registration) {
         return response('Registratie niet gevonden', 404);
     }
     // Salt must match
     if ($registration->salt !== $salt) {
         return response('Beveiligingscode is incorrect', 409);
     }
     // Deadline must not have passed
     if (!$registration->meal->open_for_registrations()) {
         return response('Aanmelddeadline is al verstreken', 410);
     }
     // Confirm registration
     $registration->confirmed = true;
     $registration->save();
     Log::debug("Registration {$registration->id} bevestigd");
     // Show confirmation page
     return $this->setPageContent(view('confirm/confirm', ['registration' => $registration]));
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     //
     Schema::create('registrations', function (Blueprint $table) {
         $table->increments('id');
         $table->string('conference');
         $table->string('attendance');
         $table->string('email');
         $table->string('phone')->nullable();
         $table->string('first_name')->nullable();
         $table->string('last_name')->nullable();
         $table->string('title')->nullable();
         $table->string('company')->nullable();
         $table->string('street')->nullable();
         $table->string('city')->nullable();
         $table->string('state')->nullable();
         $table->string('postal')->nullable();
         $table->string('referrals')->nullable();
         $table->timestamps();
         $table->timestamp('accepted')->nullable();
         $table->softDeletes();
     });
     Registration::create(['conference' => 'austin', 'attendance' => 'attendee', 'email' => '*****@*****.**', 'phone' => '9715061908', 'first_name' => 'Jeff', 'last_name' => 'Martin', 'title' => 'Grand Poo-bah', 'company' => 'SpartanMartin.com', 'street' => '18415 SW Ewen Drive APT H', 'city' => 'Beaverton', 'state' => 'OR', 'postal' => '97003', 'referrals' => null]);
 }
Пример #12
0
                }
            })
        }
    });
    \$('.dateTooltip').tooltip();
JS
);
?>

<h1 class="page-header"><?php 
echo Html::encode($this->title);
?>
</h1>

<?php 
echo \yii\grid\GridView::widget(['dataProvider' => new \yii\data\ActiveDataProvider(['query' => \app\models\Registration::query()->select(['cap_registration.*', 'cap_users.avatar       as cap_users_avatar', 'cap_users.name_first   as cap_users_name_first', 'cap_users.name_last    as cap_users_name_last', 'cap_users.name_org     as cap_users_name_org', 'cap_users.email        as cap_users_email'])->innerJoin('cap_users', 'cap_registration.referal_code = cap_users.referal_code')->orderBy(['cap_registration.datetime' => SORT_DESC]), 'pagination' => ['pageSize' => 20]]), 'tableOptions' => ['class' => 'table table-striped table-hover'], 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['header' => 'Время регистрации', 'content' => function ($model, $key, $index, $column) {
    return Html::tag('abbr', \cs\services\DatePeriod::back($model['datetime']), ['title' => Yii::$app->formatter->asDatetime($model['datetime'], 'php:d.m.Y в H:i (P)'), 'class' => 'dateTooltip']);
}], ['header' => 'Чья ссылка?', 'content' => function ($model, $key, $index, $column) {
    $arr = [];
    if ($model['cap_users_avatar']) {
        $arr[] = Html::img($model['cap_users_avatar'], ['width' => 40, 'style' => 'padding-right: 5px;']);
    }
    $arr[] = $model['cap_users_name_first'] . ' ' . $model['cap_users_name_last'] . ' (' . $model['cap_users_email'] . ')';
    return join('', $arr);
}], ['header' => 'Кто зарегистрировался?', 'content' => function ($model, $key, $index, $column) {
    return $model['user_id'];
}], ['header' => 'Оплатил?', 'content' => function ($model, $key, $index, $column) {
    if ($model['is_paid']) {
        return Html::tag('span', 'Да', ['class' => 'label label-success']);
    } else {
        return Html::tag('span', 'Нет', ['class' => 'label label-default']);
Пример #13
0
 /**
  * @throws BadRequestHttpException
  */
 public function actionSetBeginningAndEndingDates()
 {
     $beginningDate = new \DateTime(Yii::$app->request->post('Registration')['beginning_date']);
     $endingDate = new \DateTime(Yii::$app->request->post('Registration')['ending_date']);
     $interval = $beginningDate->diff($endingDate);
     $daysBetweenDates = $interval->format('%a');
     if ($daysBetweenDates > 180) {
         try {
             $student = Student::findOne(['user_id' => Yii::$app->user->id]);
             $registration = Registration::findOne(['student_id' => $student->id]);
             $registration->beginning_date = Yii::$app->request->post('Registration')['beginning_date'];
             $registration->ending_date = Yii::$app->request->post('Registration')['ending_date'];
             $registration->save(false);
             $this->actionPrintProjectAssignmentPDF();
         } catch (InvalidConfigException $e) {
             throw new BadRequestHttpException('No se tiene asignado ningún proyecto');
         }
     } else {
         throw new BadRequestHttpException('Las fechas ingresadas no son válidas,
         deben tener una diferencia de al menos 6 meses');
     }
 }
Пример #14
0
            <div class="pull-right">
                <?php 
echo Html::a('Cancelar', ['index'], ['class' => 'btn btn-danger']);
?>

                <?php 
if (Yii::$app->user->can('student')) {
    $vacancy = ProjectVacancy::find()->where("project_id=" . $model->id)->one();
    //$vacancyValue=ArrayHelper::getColumn($vacancy, 'vacancy')[0];
    $vacancyValue = $vacancy->vacancy;
    if ($vacancyValue > 0) {
        $user = User::find()->where("id=" . Yii::$app->user->id)->one();
        $user_id = $user->id;
        $student = Student::find()->where("user_id=" . $user_id)->one();
        $student_id = $student->id;
        if (Registration::find()->where(['student_id' => $student_id])->one()) {
            echo Html::a('Pre-registrarse al proyecto', ['preregister', 'id' => $model->id], ['class' => 'btn btn-success', 'disabled' => 'disabled']);
        } else {
            echo Html::a('Pre-registrarse al proyecto', ['preregister', 'id' => $model->id], ['class' => 'btn btn-success']);
        }
    } else {
        echo Html::a('Pre-registrarse al proyecto', ['preregister', 'id' => $model->id], ['class' => 'btn btn-success', 'disabled' => 'disabled']);
    }
}
?>

            </div>


        </div>
    </div>
Пример #15
0
 public function actionRegistration_referal($code)
 {
     $model = new \app\models\Form\Registration();
     $model->setScenario('insert');
     if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) {
         $model->setScenario('ajax');
         Yii::$app->response->format = Response::FORMAT_JSON;
         return ActiveForm::validate($model);
     }
     if ($model->load(Yii::$app->request->post()) && ($user = $model->register())) {
         Yii::$app->session->setFlash('contactFormSubmitted');
         Yii::$app->session->setFlash('user_id', $user->getId());
         \app\models\Registration::insert(['referal_code' => $code, 'user_id' => $user->getId()]);
         $user->activate();
         Yii::$app->user->login($user);
         return $this->refresh();
     } else {
         return $this->render(['model' => $model]);
     }
 }
 /**
  * @return mixed|\yii\web\Response
  */
 public function actionPrintEvidenceReport()
 {
     $student = Student::findOne(['user_id' => Yii::$app->user->id]);
     date_default_timezone_set("America/Mexico_City");
     try {
         $searchModel = new StudentEvidenceSearch();
         $dataProviderAccepted = $searchModel->search(Yii::$app->request->queryParams, StudentEvidence::$ACCEPTED);
         $registration = Registration::findOne(['student_id' => $student->id]);
         $person = Person::findOne(User::findOne(Yii::$app->user->id)->person_id);
         $project = Project::findOne($registration->project_id);
         $projectM = ProjectManager::findOne($project->manager_id);
         // get your HTML raw content without any layouts or scripts
         $content = $this->render('studentEvidencePDF', ['registration' => $registration, 'student' => $student, 'person' => $person, 'project' => $project, 'projectM' => $projectM, 'searchModel' => $searchModel, 'dataProviderAccepted' => $dataProviderAccepted]);
         $formatter = \Yii::$app->formatter;
         // setup kartik\mpdf\Pdf component
         $pdf = new Pdf(['mode' => Pdf::MODE_UTF8, 'format' => Pdf::FORMAT_LETTER, 'orientation' => Pdf::ORIENT_PORTRAIT, 'destination' => Pdf::DEST_BROWSER, 'content' => $content, 'cssFile' => '@vendor/kartik-v/yii2-mpdf/assets/kv-mpdf-bootstrap.min.css', 'cssInline' => '.kv-heading-1{font-size:18px}', 'options' => ['title' => 'Reporte de avances'], 'methods' => ['SetFooter' => ['Fecha de expedición: ' . $formatter->asDate(date('d-F-Y'))]]]);
         // return the pdf output as per the destination setting
         return $pdf->render();
     } catch (InvalidConfigException $e) {
         Yii::$app->getSession()->setFlash('danger', 'No tienes proyectos asignados');
         return $this->redirect(Url::home());
     }
 }
Пример #17
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRegistration()
 {
     return $this->hasOne(Registration::className(), ['id' => 'registration_id']);
 }
 /**
  * Finds the Registration model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Registration the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Registration::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Пример #19
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getRegistrations()
 {
     return $this->hasMany(Registration::className(), ['registration_type_id' => 'id']);
 }
Пример #20
0
 /**
  * Subscribe a user to a single meal
  * @return json
  */
 public function aanmeldenBolker()
 {
     // Find the meal
     $meal = Meal::find((int) Request::input('meal_id'));
     if (!$meal) {
         return response()->json(['error' => 'meal_not_found', 'error_details' => 'De maaltijd waarvoor je je probeert aan te melden bestaat niet'], 404);
     }
     // Check if the meal is still open
     if (!$meal->open_for_registrations()) {
         return response()->json(['error' => 'meal_deadline_expired', 'error_details' => 'De aanmeldingsdeadline is verstreken'], 400);
     }
     $user = OAuth::user();
     // Check if the user is blocked from registering
     if ($user->blocked) {
         return response()->json(['error' => 'user_blocked', 'error_details' => 'Je bent geblokkeerd op bolknoms. Je kunt je niet aanmelden voor maaltijden.'], 403);
     }
     // Check if the user is already registered
     if ($user->registeredFor($meal)) {
         return response()->json(['error' => 'double_registration', 'error_details' => 'Je bent al aangemeld voor deze maaltijd'], 400);
     }
     // Create registration
     $registration = new Registration(['name' => $user->name, 'handicap' => $user->handicap]);
     $registration->user_id = $user->id;
     $registration->meal_id = $meal->id;
     $registration->username = $user->username;
     $registration->email = $user->email;
     $registration->confirmed = true;
     if ($registration->save()) {
         \Log::info("Aangemeld: {$registration->id}|{$registration->name}");
         return response(null, 200);
     } else {
         \Log::error("Aanmelding mislukt, onbekend");
         return response()->json(['error' => 'unknown', 'error_details' => 'unknown_internal_server_error'], 500);
     }
 }
Пример #21
0
<?php

use app\models\Project;
use app\models\Registration;
use app\models\student;
use app\models\StudentEvidenceSearch;
/* @var $this yii\web\View */
/* @var $searchModel app\models\StudentSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Página principal';
Yii::$app->formatter->locale = 'es_ES';
$student = Student::findOne(['user_id' => Yii::$app->user->id]);
if ($registration = Registration::findOne(['student_id' => $student->id])) {
    $project = Project::findOne($registration->project_id);
    $textProject = 'Avances de proyecto: ' . $project->name;
    $searchModel = new StudentEvidenceSearch();
    $dataProviderNews = $searchModel->search(Yii::$app->request->queryParams, \app\models\StudentEvidence::$NEW);
    $dataProviderPending = $searchModel->search(Yii::$app->request->queryParams, \app\models\StudentEvidence::$PENDING);
    $countNews = $dataProviderNews->getTotalCount();
    $countPending = $dataProviderPending->getTotalCount();
    if ($countNews == 1) {
        $textDetails = 'Tienes ' . $countNews . ' avance nuevo.';
    } else {
        $textDetails = 'Tienes ' . $countNews . ' avances nuevos.';
    }
    if ($countPending == 1) {
        $textDetails .= '<br>Tienes ' . $countPending . ' avance pendiente.';
    } else {
        $textDetails .= '<br>Tienes ' . $countPending . ' avances pendientes.';
    }
    $textFooter = "<div class = 'panel-footer'><h4>Da click en el menú <i>Avances</i> para ver los detalles.</h4></div>";
Пример #22
0
 /**
  * Show a list of all eaters
  */
 public function index()
 {
     return $this->setPageContent(view('top/index', ['statistics_ytd' => Registration::top_ytd(), 'statistics_alltime' => Registration::top_alltime()]));
 }
Пример #23
0
 /**
  * Removes a registration from a meal
  * @param int $id the id of the registration to remove
  * @return string "success" if succesfull
  */
 public function afmelden($id)
 {
     // Find registration
     $registration = Registration::find((int) $id);
     if (!$registration) {
         return response()->json(['error' => 'registration_not_existent', 'error_details' => 'Deze registratie bestaat niet'], 500);
     }
     // Store data for later usage
     $id = $registration->id;
     $name = $registration->name;
     $meal = $registration->meal;
     if ($registration->delete()) {
         Log::info("Afgemeld: administratie|{$id}|{$name}|{$meal}");
         return response(null, 200);
     } else {
         return response()->json(['error' => 'destroy_registration_admin_unknown_error', 'error_details' => 'Deze registratie kon niet verwijderd worden, reden onbekend.'], 500);
     }
 }
 /**
  * @param $id
  * @throws NotFoundHttpException
  */
 public function actionCancelPreregistration($project_id, $student_id)
 {
     if ($model = ($model = Registration::find()->where(['project_id' => $project_id, 'student_id' => $student_id])->one()) !== null) {
         $model->student_status = Registration::PREREGISTRATION_CANCELLED;
         $model->save();
         //Se envia el correo al estudiante
         Yii::$app->mailer->compose()->setFrom('*****@*****.**')->setTo($model->student->user->email)->setSubject('Asignación de alumno al proyecto' . ' ' . $model->project->name)->setTextBody('Su registro al proyecto ha sido rechazado.')->setHtmlBody('<b>Asignación exitosa</b>')->send();
         Yii::$app->getSession()->setFlash('success', 'Alumno eliminado.');
         $this->redirect('view-preregistered-students');
     } else {
         throw new NotFoundHttpException('El estudiante no ha sido encontrado.');
     }
 }