function postCapnhat(Request $request, $id) { $model = Student::find($id); $model->first_name = $request->txtfirst_name; $model->middle_name = $request->txtmiddle_name; $model->last_name = $request->txtlast_name; $model->address = $request->txtaddress; $model->identity = $request->txtidentity; $model->phone = $request->txtphone; $model->birthday = $request->txtbirthday; $model->save(); $img_current = $request->img_current; $file = $request->file('txtimage'); if (!empty($file)) { $file_name = $model['id'] . "-" . time() . "-" . $file->getClientOriginalName(); $model->image = $file_name; $file->move('../resources/upload/hocsinh/', $file_name); if (File::exists($img_current)) { File::delete($img_current); } $model->save(); } else { echo "khong co file"; } return redirect()->route('student'); }
/** * @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]); } }
public function actionView($id = null) { if (!$id) { return $this->render('/site/error', ['name' => 'Bad request', 'message' => 'id is not defined']); } $dataProvider = Student::find()->where(['id' => (int) $id]); return $this->render('view', ['dataProvider' => $dataProvider]); }
public function deleteStudent() { $stud_id = Input::get('stud_id'); $User = Student::find($stud_id); if (!$User->delete()) { return 0; } else { return 1; } }
public function deleteStudent($id) { return Student::find($id)->delete(); // if($s){ // $s->delete(); // return true; // }else{ // return false; // } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (Session::has('student_id') === false) { return Redirect::route('oauth.auth'); } $student = Student::find(Session::get('student_id')); if ($student) { View::share('student', $student); } return $next($request); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Student::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, 'user_id' => $this->user_id, 'faculty_id' => $this->faculty_id, 'current_semester' => $this->current_semester]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = StudentModel::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, 'name' => $this->name]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Student::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, 'dob' => $this->dob]); $query->andFilterWhere(['like', 'studentNum', $this->studentNum])->andFilterWhere(['like', 'firstName', $this->firstName])->andFilterWhere(['like', 'surname', $this->surname])->andFilterWhere(['like', 'email', $this->email]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Student::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(['st_id' => $this->st_id, 'st_active' => $this->st_active]); $query->andFilterWhere(['like', 'st_fname', $this->st_fname])->andFilterWhere(['like', 'st_lname', $this->st_lname])->andFilterWhere(['like', 'st_address', $this->st_address])->andFilterWhere(['like', 'st_postcode', $this->st_postcode])->andFilterWhere(['like', 'st_mobile', $this->st_mobile])->andFilterWhere(['like', 'st_phone', $this->st_phone])->andFilterWhere(['like', 'st_email', $this->st_email])->andFilterWhere(['like', 'st_disp_id', $this->st_disp_id]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Student::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, 'classid' => $this->classid, 'created_dt' => $this->created_dt]); $query->andFilterWhere(['like', 'course_id', $this->course_id])->andFilterWhere(['like', 'stucode', $this->stucode])->andFilterWhere(['like', 'fname', $this->fname])->andFilterWhere(['like', 'lname', $this->lname])->andFilterWhere(['like', 'faculity', $this->faculity])->andFilterWhere(['like', 'major', $this->major])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'score', $this->score])->andFilterWhere(['like', 'past', $this->past])->andFilterWhere(['like', 'status', $this->status]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Student::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 100], 'sort' => ['defaultOrder' => ['name' => SORT_ASC]]]); $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, 'birth_dt' => $this->birth_dt]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'level', $this->level]); return $dataProvider; }
public function search($params) { $query = Student::find()->joinWith('affiliations.handAnchor.day')->joinWith('affiliations.handAnchor.frequency')->joinWith('affiliations.school')->joinWith('phones')->joinWith('division')->joinWith('promotions.rank')->groupBy('student.id')->where(['affiliation.school_id' => user()->schoolId]); $dataProvider = new ActiveDataProvider(['query' => $query]); // load the search form data and validate if (!($this->load($params) && $this->validate())) { return $dataProvider; } // we only get here if there are filter params in the GET //dump($params); //dump('active=', $this->active); // adjust the query by adding the filters $query->andFilterWhere(['dob' => $this->dob, 'spar_auth' => $this->spar_auth, 'grapple_auth' => $this->grapple_auth, 'belt_size' => $this->belt_size, 'gi_size' => $this->gi_size]); $query->andFilterWhere(['student.active' => $this->active])->andFilterWhere(['like', 'prefix', $this->prefix])->andFilterWhere(['like', 'gender', $this->gender])->andFilterWhere(['like', 'fname', $this->fname])->andFilterWhere(['like', 'mname', $this->mname])->andFilterWhere(['like', 'lname', $this->lname])->andFilterWhere(['like', 'kai_number', $this->kai_number])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'notes', $this->notes])->andFilterWhere(['like', 'day.name', $this['handAnchor.name']])->andFilterWhere(['like', 'student_phone.number', $this->bestPhoneNumber])->andFilterWhere(['like', 'division.name', $this->division_id]); return $dataProvider; }
public function updateProfil(Request $request) { $input = $request->all(); $validator = $this->profile_validator($input); if ($validator->fails()) { $this->throwValidationException($request, $validator); } $student = Student::find($input['Noreg']); $student->Noreg = $input['Noreg']; $student->Nama_Mhs = $input['Nama_Mhs']; $student->Prodi_id = $input['Prodi_id']; $student->Alamat = $input['Alamat']; $student->Telepon = $input['Telepon']; $student->Semester = $input['Semester']; $student->Mac = $input['Mac']; $student->save(); return $this->profil(); }
/** * Гененирует тестовый данные в БД. Единственная точка входа */ public function actionIndex() { try { echo "Начинаю генерировать " . $this->getConfig('students_num') . " студентов" . "\n"; $this->minStudentId = Student::find()->max('id') + 1; $this->generateStudents(); $this->maxStudentId = Student::find()->max('id'); echo 'Студенты успешно сгенерированы' . "\n"; echo "Начинаю генерировать " . $this->getConfig('teachers_num') . " учителей" . "\n"; $this->minTeacherId = Teacher::find()->max('id') + 1; $this->generateTeachers(); $this->maxTeacherId = Teacher::find()->max('id'); echo 'Учителя успешно сгенерированы' . "\n"; echo "Начинаю генерировать привязки студентов к учителям." . "\n"; $this->generateLinks(); echo 'Привязки успешно сгенерированы' . "\n"; } catch (Exception $e) { echo 'Ошибка. Не удалось сгенерировать тестовые данные. Причина: ' . $e->getMessage(); } }
public function actionList($q = null, $id = null) { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; $out = ['results' => ['id' => '', 'text' => '']]; if (!is_null($q)) { $data = Student::find()->select('id, name AS text')->where('name LIKE "%' . $q . '%"')->limit(20)->asArray()->all(); $out['results'] = array_values($data); } elseif ($id > 0) { $out['results'] = ['id' => $id, 'text' => Student::find($id)->name]; } return $out; }
public function actionCheckName($term) { $lname = Html::encode($term); $models = Student::find()->where(['like', 'lname', "{$lname}%", false])->all(); return $this->renderAjax('name-conflict', ['models' => $models, 'lname' => $lname]); }
public function getStudInfo() { $studId = Input::get('studId'); return Student::find($studId); }
</div> <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>
/** * Creates a printable table of all active students in a given school, * ordered by division. */ public function actionAttendance() { if (!Yii::$app->user->can('printAttendance')) { throw new ForbiddenHttpException(Yii::t('app', 'You are not authorized to perform this action.')); } $school = Yii::$app->user->school; $utsMonth = strtotime(Yii::$app->user->reportMonth); $minimumBlanks = 4; $rowsPerPage = 38; $rowHeight = 4.8; // define the columns to show in the table $columns = [['attribute' => 'name', 'header' => 'Name', 'head-font-style' => 'B', 'body-font-size' => 9, 'width' => 40], ['attribute' => 'bestPhoneNumber', 'header' => 'Phone', 'head-font-style' => 'B', 'body-font-size' => 9, 'width' => 24], ['attribute' => 'handAnchor.name', 'header' => 'Anc.', 'head-font-style' => 'B', 'body-font-size' => 8, 'width' => 10], ['attribute' => 'dobAndAge', 'header0' => 'DoB/', 'header' => 'Age', 'head-font-style' => 'B', 'body-font-size' => 8, 'width' => 14]]; // add the days of the month to the column list $abbr = ['M', 'T', 'W', 'H', 'F', 'A', 'S']; $daysInMonth = date('t', $utsMonth); for ($i = 0; $i < $daysInMonth; $i++) { // get the date of day $i+1 in the month $date = strtotime(date('Y-m-', $utsMonth) . ($i + 1)); // get the abbreviation of the day name $day = $abbr[intval(date('N', $date)) - 1]; $columns[] = ['head-font-size' => 8, 'isDay' => true, 'width' => 5, 'header0' => $day, 'header' => '' . ($i + 1), 'border' => 1, 'x' => null]; } // add the notes column $columns[] = ['head-font-size' => 9, 'head-font-style' => 'B', 'width' => 22, 'header0' => 'Notes/', 'header' => 'Excusals', 'x' => null]; $pdf = new mPDF('c', 'Letter-L', 0, '', 6.25, 6.25, 10, 6.25, 6.25, 6.25, 'L'); $header = array('odd' => array('L' => array('content' => 'Attendance List: ' . date('F Y', $utsMonth), 'font-size' => 10, 'font-style' => 'B', 'font-family' => 'sans serif', 'color' => '#000000'), 'C' => array('content' => $school->name, 'font-size' => 14, 'font-style' => 'B', 'font-family' => 'serif', 'color' => '#000000'), 'R' => array('content' => '', 'font-size' => 9, 'font-style' => 'B', 'font-family' => 'serif', 'color' => '#000000'), 'line' => 0), 'even' => array()); $pdf->SetHeader($header); $newPage = function ($division) use(&$pdf, &$utsMonth, &$rowsPerPage, &$columns, $rowHeight) { $lMargin = $pdf->lMargin; $pdf->AddPage('L'); // write the division header $pdf->SetFont('sans serif', 'BU', 12); $pdf->WriteCell(0, 6, 'Division ' . $division, 0, 0, 'C'); $pdf->Ln(); // write first line of column headers foreach ($columns as $c) { $text = isset_get($c, 'header0', ''); $width = isset_get($c, 'width', 0); // print the day headers smaller if (isset($c['isDay'])) { $fontSize = 8; $fontStyle = ''; } else { $fontSize = isset_get($c, 'head-font-size', 10); $fontStyle = isset_get($c, 'head-font-style', ''); } $pdf->SetFont('', $fontStyle, $fontSize); // append text to a blank string to convert nulls $pdf->WriteCell($width, 2, $text, 0, 0, 'C'); } $pdf->Ln(); // write second line of column headers foreach ($columns as $i => $c) { $text = isset_get($c, 'header', ''); $width = isset_get($c, 'width', 0); // print the day headers smaller if (isset($c['isDay'])) { $fontSize = 8; $fontStyle = ''; } else { $fontSize = isset_get($c, 'head-font-size', 10); $fontStyle = isset_get($c, 'head-font-style', ''); } $pdf->SetFont('', $fontStyle, $fontSize); // record this column's x position $columns[$i]['x'] = $pdf->x; $pdf->WriteCell($width, $rowHeight, $text, 0, 0, 'C'); } $pdf->Ln(); // underline headers $pdf->Line($lMargin, $pdf->y, $lMargin + $pdf->pgwidth, $pdf->y); // fill every other row $pdf->SetFillColor(128, 255, 255); for ($i = 0; $i < $rowsPerPage; ++$i) { $rowY = $pdf->y + $i * $rowHeight; if (0 !== $i % 2) { $pdf->RoundedRect($lMargin, $rowY, $pdf->pgwidth, $rowHeight, 0, 'F'); } // underline all rows $pdf->Line($lMargin, $rowY + $rowHeight, $lMargin + $pdf->pgwidth, $rowY + $rowHeight); } // fill every other day column $pdf->SetFillColor(192, 192, 192); $allRowsHeight = $rowsPerPage * $rowHeight; foreach ($columns as $i => $c) { $x = $c['x']; $y = $pdf->y; $width = $c['width']; if (0 === $i % 2 && isset($c['isDay'])) { // fill $pdf->RoundedRect($x, $y, $width, $allRowsHeight, 0, 'F'); } } // underline all rows for ($i = 0; $i < $rowsPerPage; ++$i) { $rowB = $pdf->y + $i * $rowHeight + $rowHeight; $pdf->Line($lMargin, $rowB, $lMargin + $pdf->pgwidth, $rowB); } // Set the font for the rest of the table $pdf->SetFont('sans serif', '', 9); }; $fillPageWithBlanks = function () use(&$pdf, &$columns, &$printedRows, &$rowsPerPage, &$minimumBlanks, &$printBlanks, &$lastDivision, &$newPage) { $remainder = $printedRows % $rowsPerPage; $availableRows = $remainder > 0 ? $rowsPerPage - $remainder : 0; $printBlanks($availableRows); if ($availableRows < $minimumBlanks) { $newPage($lastDivision); $printBlanks($rowsPerPage); } }; $printBlanks = function ($rowCount) use(&$printModel) { while ($rowCount-- > 0) { $printModel(null); } }; $printModel = function ($model) use(&$pdf, &$columns, &$printedRows, $rowHeight) { foreach ($columns as $c) { $attr = $c['attribute']; $text = null; if (isset($model) && isset($attr)) { $text = ArrayHelper::getValue($model, $attr); } $border = isset($c['border']) ? $c['border'] : 0; $fontSize = isset_get($c, 'body-font-size', 9); $fontStyle = isset_get($c, 'body-font-style', ''); $pdf->SetFont('', $fontStyle, $fontSize); $pdf->WriteCell($c['width'], $rowHeight, '' . $text, $border); } $pdf->Ln(); ++$printedRows; }; // query for all active students in this school (excluding instructors) $q = Student::find(); $q->joinWith('affiliation.handAnchor.day'); $q->joinWith('affiliation.handAnchor.frequency'); $q->joinWith('affiliation.role'); $q->joinWith('promotions.rank'); $q->joinWith('division'); $q->andWhere(['student.active' => 1]); $q->andWhere(['affiliation.school_id' => $school->id]); $q->andWhere(['between', 'role.ord', 0, 7000]); $q->orderBy(['division.ord' => SORT_ASC, '-`class_frequency`.`ord`' => SORT_DESC, '-`day`.`ord`' => SORT_DESC, '-`class`.`start_time`' => SORT_DESC, 'rank.ord' => SORT_DESC]); $lastDivision = ''; $printedRows = 0; $models = $q->all(); foreach ($models as $model) { $division = $model->division->name; if ($division !== $lastDivision) { if ($printedRows > 0) { $fillPageWithBlanks(); } $newPage($division); } elseif (0 === $printedRows % $rowsPerPage && $printedRows > 0) { // if we ran out of space on the page, start a new one $newPage($lastDivision); } $printModel($model); // will increment printedRows $lastDivision = $division; } $fillPageWithBlanks(); //ensure blanks after last division return $pdf->Output(); }
public function actionIndex($params = []) { $student = new Student(); $this->render('index.php', ['students' => $student->find()]); }
<?php // $form->field($model, 'usr_id')->textInput(['readonly' => !$model->isNewRecord]) ?> <?php if ($model->isNewRecord) { ?> <?php //} ?> <?php echo $form->field($model, 'usr_type_id')->dropDownList(ArrayHelper::map(Student::find()->asArray()->all(), 'st_id', 'st_fname'), ['prompt' => '-Choose a Student-', 'onchange' => ' $.post( "index.php?r=student/list&id=' . '"+$(this).val(), function( data ) { $( "#userstudent-usr_id").val(data); });']); ?> <?php } ?> <?php echo $form->field($model, 'usr_id')->textInput(['readonly' => true]); ?> <?php echo $form->field($model, 'usr_name')->textInput(['maxlength' => true]); ?>
/** * Handle the authorization_code to request an access_token. * * @return Response */ public function callback() { // The user should not have been redirected here without the // "authorization_code" variable in the url. If it's not the // case, do not go further. if (!Request::has('authorization_code')) { App::abort(401); } $client = new \GuzzleHttp\Client(['base_uri' => Config::get('services.etuutt.baseuri.api'), 'auth' => [Config::get('services.etuutt.client.id'), Config::get('services.etuutt.client.secret')]]); $params = ['grant_type' => 'authorization_code', 'authorization_code' => Request::input('authorization_code')]; try { $response = $client->post('/api/oauth/token', ['form_params' => $params]); } catch (\GuzzleHttp\Exception\GuzzleException $e) { // An error 400 from the server is usual when the authorization_code // has expired. Redirect the user to the OAuth gateway to be sure // to regenerate a new authorization_code for him :-) if ($e->hasResponse() && $e->getResponse()->getStatusCode() === 400) { return $this->auth(); } App::abort(500); } $json = json_decode($response->getBody()->getContents(), true); $access_token = $json['access_token']; $refresh_token = $json['refresh_token']; try { $response = $client->get('/api/private/user/account?access_token=' . $json['access_token']); } catch (\GuzzleHttp\Exception\GuzzleException $e) { App::abort(500); } $json = json_decode($response->getBody()->getContents(), true)['data']; // If the user is new, import some values from the API response. $student = Student::find($json['studentId']); if ($student === null) { $student = new Student(['student_id' => $json['studentId'], 'first_name' => $json['firstName'], 'last_name' => $json['lastName'], 'surname' => $json['surname'], 'email' => $json['email'], 'facebook' => $json['facebook'], 'phone' => $json['phonePrivacy'] == 'public' ? $json['phone'] : null, 'branch' => $json['branch'], 'level' => $json['level']]); $student->etuutt_access_token = $access_token; $student->etuutt_refresh_token = $refresh_token; // Error here a ignored, we just keep user without a picture if we cannot download it $picture = @file_get_contents('http://local-sig.utt.fr/Pub/trombi/individu/' . $student->student_id . '.jpg'); @file_put_contents(public_path() . '/uploads/students-trombi/' . $student->student_id . '.jpg', $picture); if ($json['sex'] == 'male') { $student->sex = Student::SEX_MALE; } elseif ($json['sex'] == 'female') { $student->sex = Student::SEX_FEMALE; } $student->last_login = new \DateTime(); $student->save(); } elseif (empty($student->etuutt_refresh_token)) { $student->last_login = new \DateTime(); $student->etuutt_access_token = $access_token; $student->etuutt_refresh_token = $refresh_token; $student->phone = $json['phonePrivacy'] == 'public' ? $json['phone'] : null; if ($json['sex'] == 'male') { $student->sex = Student::SEX_MALE; } elseif ($json['sex'] == 'female') { $student->sex = Student::SEX_FEMALE; } $student->save(); } else { $student->last_login = new \DateTime(); $student->etuutt_access_token = $access_token; $student->etuutt_refresh_token = $refresh_token; $student->save(); } // Remember the user accross the whole website. Session::set('student_id', $json['studentId']); Session::forget('newcomer_id'); return Redirect::route('menu'); }
public static function get($id) { return App\models\Student::find($id); }
/** * When search form from add is submited * * @return Response */ public function addSubmit($login) { // If the user is new, import some values from the API response. $json = EtuUTT::call('/api/public/users/' . $login)['data']; $student = Student::find($json['studentId']); if ($student === null) { $student = new Student(['student_id' => $json['studentId'], 'first_name' => $json['firstName'], 'last_name' => $json['lastName'], 'surname' => $json['surname'], 'email' => $json['email'], 'facebook' => $json['facebook'], 'branch' => $json['branch'], 'level' => $json['level'], 'ce' => 1, 'team_id' => EtuUTT::student()->team_id]); $student->save(); // Error here a ignored, we just keep user without a picture if we cannot download it $picture = @file_get_contents('http://local-sig.utt.fr/Pub/trombi/individu/' . $json['studentId'] . '.jpg'); @file_put_contents(public_path() . '/uploads/students-trombi/' . $json['studentId'] . '.jpg', $picture); } elseif ($student->team) { return $this->error('Cet étudiant fait déjà partie d\'une équipe. Il faut qu\'il la quitte avant de pouvoir être ajouté à une nouvelle équipe.'); } else { $student->team_id = EtuUTT::student()->team_id; $student->ce = 1; $student->save(); } $team = EtuUTT::student()->team; $team->validated = false; $team->save(); return redirect(route('dashboard.ce.myteam'))->withSuccess($json['fullName'] . ' a bien été ajouté à votre équipe. Il faut maintenant qu\'il se connecte au site d\'intégration pour valider sa participation.'); }
/** * Search a student on EtuUTT by first_name, last_name, student_id * * @return array */ public function searchStudent() { // If we've already retrieved the user for the current request we can just // return it back immediately. We do not want to fetch the user data on // every call to this method because that would be tremendously slow. if (!is_null($this->student)) { return $this->student; } $id = Session::get('student_id'); // First we will try to load the user using the identifier in the session if // one exists. Otherwise we will check for a "remember me" cookie in this // request, and if one exists, attempt to retrieve the user using that. $student = null; if (!is_null($id)) { $student = Student::find(Session::get('student_id')); } if ($student === null && $id !== null) { Session::forget('student_id'); abort(500); } return $student; }
?> <?php echo $form->field($model, 'name')->textInput(['maxlength' => true]); ?> <?php echo $form->field($model, 'gender')->dropDownList(Teacher::getGendersList()); ?> <?php echo $form->field($model, 'phone'); ?> <?php $studentsList = Student::find()->select(['id', 'name as text'])->where(['id' => $model->students_list])->orderBy('text')->asArray()->all(); $data = []; $studentsListIdsByName = []; foreach ($studentsList as $student) { $data[$student['id']] = $student; $studentsListIdsByName[] = $student['id']; } $model->students_list = $studentsListIdsByName; $data = Json::encode($data); echo $form->field($model, 'students_list')->widget(MultipleInput::className(), ['allowEmptyList' => true, 'columns' => [['name' => 'students_list', 'type' => Select2::className(), 'options' => ['pluginOptions' => ['minimumInputLength' => 3, 'ajax' => ['url' => Url::to(['student/list']), 'dataType' => 'json', 'data' => new JsExpression('function(params) { return {q:params.term}; }'), 'results' => new JsExpression(' function (data) { return { results: $.map(data, function (item) { return { text: item.name, id: item.id
use app\models\Student; use app\models\Module; /* @var $this yii\web\View */ /* @var $model app\models\StudentModule */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="student-module-form"> <?php $form = ActiveForm::begin(); ?> <!-- THIS WORKS - NO VALIDATION FOR DUPLICATES YET --> <?php echo $form->field($model, 'Student_id')->dropDownList(ArrayHelper::map(Student::find()->all(), 'id', 'studentNum'), ['prompt' => 'Select Student']); ?> <?php echo $form->field($model, 'Module_id')->dropDownList(ArrayHelper::map(Module::find()->all(), 'id', 'moduleName'), ['prompt' => 'Select Module']); ?> <!-- END --> <!-- ?= $form->field($model, 'Student_id')->textInput() -- ?> <! -- ?= $form->field($model, 'Module_id')->textInput() ? --> <div class="form-group"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
public function student_info() { $student = Student::find(1); $student['academicinfo'] = $student->academicInfo()->first(); return view("student.partials._studentinfo")->with('student', $student); }
public function actionLoginstudent() { $email = $_POST['email']; $pass = $_POST['pass']; $status = array(); //echo $email . " " . $pass; $model = Student::find()->where(['email' => $email, 'password' => $pass])->one(); if ($model == null) { $status["status"] = "faild"; } else { $status["status"] = "ok"; $status["name"] = $model->name; $status["email"] = $model->email; $status["id"] = $model->id; } return json_encode($status); }