/** * @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]); } }
/** * Удаление информации о регистрации по реферальной ссылке * * 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']); } }
/** * 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(); }
/** * 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; }
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])); }
/** * 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); } }
<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>
/** * @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.'); } }