public function updateData($data, $tables) { $db = new yii\db\Connection(['dsn' => "mysql:host=196.202.202.131;dbname=shinda2", 'username' => 'root', 'password' => 'FAQU', 'charset' => 'utf8']); $table = "tbl_" . $tables; $columns = $db->getTableSchema($table)->columnNames; $sqls = ""; foreach ($data as $value) { $sql = "UPDATE {$table} SET "; for ($index = 1; $index < count($columns); $index++) { $model = Participant::findOne($columns[0]); $col = $columns[$index]; $hold = $value[$columns[$index]]; if (empty($hold)) { $val = "NULL"; } else { $val = "'{$hold}'"; } $sql .= "{$col} = {$val}, "; } $sql = substr($sql, 0, -2); $id = $value[$columns[0]]; $sql .= " WHERE id_p ={$id};"; $sqls .= $sql; } $db->createCommand($sqls)->execute(); $db->createCommand()->update('tbl_participant', ['altered' => NULL])->execute(); }
/** * Updates an existing Questionnaire model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if (\Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) { \Yii::$app->response->format = 'json'; return \kartik\widgets\ActiveForm::validate($model); } $persondetails = \app\models\Participant::findOne(['pk_person' => $model->fk_person]); if ($model->load(Yii::$app->request->post())) { $model->creation_name = Yii::$app->user->identity->username; $model->altered = 1; $persondetails->filtered = $persondetails->filtered + 1; $model->hbp_med_list = $_POST['Questionnaire']['enalapril'] . "," . $_POST['Questionnaire']['atenolol'] . ", " . $_POST['Questionnaire']['propranolol'] . "," . $_POST['Questionnaire']['hydrochlorthiazide'] . "," . $_POST['Questionnaire']['frusemide'] . "," . $_POST['Questionnaire']['aldactone'] . "," . $_POST['Questionnaire']['methyldopa'] . "," . $_POST['Questionnaire']['nifedipine'] . "," . $_POST['Questionnaire']['hydralazine']; if ($_POST['Questionnaire']['own_none'] == 1) { $model->household_own = "0,0,0,0,0,0,1"; } else { $model->household_own = $_POST['Questionnaire']['car'] . "," . $_POST['Questionnaire']['refridgerator'] . ", " . $_POST['Questionnaire']['bicycle'] . "," . $_POST['Questionnaire']['radio'] . "," . $_POST['Questionnaire']['television'] . "," . $_POST['Questionnaire']['own_none']; } $persondetails->filtered = 1; if ($model->save(FALSE) && $persondetails->save(FALSE)) { Yii::$app->session->setFlash('success', 'The questionnaire saved successfully'); return $this->redirect(['participant/apptmnts']); } } else { return $this->render('update', ['model' => $model, 'persondetails' => $persondetails]); } }
/** * Crée les entrées de la table Participants correspondant aux équipes */ public function creerEquipes() { $entrees = [["Grizzlis effarouchés", 1, 1, 1, [1, 2, 3]], ["Opossums déchaînés", 2, 1, 2, [4, 5, 6]], ["Antilopes frustrées", 3, 1, 3, [7, 8, 9]], ["Nasiques offensés", 4, 2, 1, []], ["Renards désinhibés", 5, 2, 1, [13, 14, 15]], ["Escargots enragés", 6, 2, 3, [16, 18, 19]], ["Méduses surexcitées", 7, 3, 2, [20, 21, 22]], ["Gousses d'aïl en furie", 8, 3, 1, [24, 25, 26]], ["Levures passives-agressives", 9, 5, 3, [1, 2, 3]], ["Streptocoques désagréables", 10, 4, 3, [4, 5, 6]]]; $sports = Sport::all(); $regions = Region::all(); $participants = Participant::all(); Equipe::where('equipe', '=', 1)->delete(); foreach ($entrees as $entree) { $equipe = new Equipe(); $equipe->nom = $entree[0]; $equipe->numero = $entree[1]; $equipe->region_id = $regions[$entree[2]]->id; $equipe->prenom = ""; $equipe->equipe = true; $equipe->sexe = $entree[1] % 2; $equipe->naissance = new DateTime(); $equipe->save(); $equipe->sports()->attach([$sports[$entree[3]]->id]); $index_membres = array(); for ($x = 0; $x < count($entree[4]); $x++) { array_push($index_membres, $participants[$entree[4][$x] - 1]->id); } $equipe->membres()->sync($index_membres); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params, $date = '', $filter = '') { $query = Participant::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_p' => $this->id_p, 'sex' => $this->sex, 'dob' => $this->dob, 'study_no' => $this->study_no, 'pk_res' => $this->pk_res, 'latt' => $this->latt, 'longd' => $this->longd, 'shinda2' => $this->shinda2, 'shinda3' => $this->shinda3]); if (!empty($date)) { $query->andWhere(['appoint_date' => $date])->andWhere('appoint_level < 3 OR appoint_level IS NULL')->andWhere('consent IS NULL'); } else { if ($filter == 1) { $query->andWhere('filtered IS NULL'); } else { if (empty($filter)) { $query->andWhere('filtered IS NOT NULL')->andWhere('filtered != 5'); } else { if ($filter == 3) { $username = Yii::$app->user->identity->username; $query->andWhere('altered = 1')->andWhere("updated_name = '{$username}'"); } } } } $query->andFilterWhere(['like', 'names', $this->names])->andFilterWhere(['like', 'agecat', $this->agecat])->andFilterWhere(['like', 'ez_hm', $this->ez_hm])->andFilterWhere(['like', 'locn', $this->locn])->andFilterWhere(['like', 'consent', $this->consent])->andFilterWhere(['like', 'updated_name', $this->updated_name])->andFilterWhere(['like', 'pk_person', $this->pk_person])->andFilterWhere(['like', 'sublocn', $this->sublocn]); return $dataProvider; }
public static function boot() { parent::boot(); Participant::created(self::raiseEvent()); // When adding participants, the model used is the original Cmgmyr\Messenger and the created event doesn't triggered for ours so listen for it here. CmgmyrParticipant::created(self::raiseEvent()); }
public function postUpdateParticipant(Request $request) { if ($request->ajax()) { $input = $request->only(['user_id', 'state']); $input['course_id'] = Auth::user()->course->id; Participant::where('course_id', '=', $input['course_id'])->where('user_id', '=', $input['user_id'])->update($input); return response()->json(['id' => $input['user_id'], 'value' => $input['state'] == Participant::REJECTED ? 'Odmietnutý' : 'Prihlásený']); } }
/** * Creates a new Participant model. * If creation is successful, the browser will be redirected to the 'view' page. * * @param integer $type * * @return mixed * @throws NotFoundHttpException */ public function actionRegister($type = null) { if (!\Yii::$app->user->isGuest && !\Yii::$app->user->can('manageUsers')) { return $this->redirect(['site/index']); } $model = new Participant(); if (Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) { Yii::$app->response->format = Response::FORMAT_JSON; return ActiveForm::validate($model); } if ($model->load(Yii::$app->request->post()) && $model->save()) { Yii::$app->user->login($model->user, 3600 * 24 * 30); return $this->redirect(['site/verify']); } else { $model->setUserType($type); $model->scenario = 'register' . $model->getUserType(); return $this->render('create', ['model' => $model]); } }
/** * Crée les entrées de la table Participants correspondant aux équipes */ public function run() { //TODO: à refaire car ca plante si on seed 2 fois car les id de région et de sports sont hardcodés $entrees = [["Arthur", "Archambault", 1, 1, 1, 0], ["Beowulf", "Beaulieu", 2, 1, 2, 0], ["Circé", "Charron", 3, 1, 3, 1], ["Donatello", "DeGrandPré", 4, 2, 1, 0], ["Elsa", "Eiffel", 5, 2, 2, 1], ["Francesco", "Funiculaire", 6, 2, 3, 0], ["Ginette", "Gargantua", 7, 3, 1, 1], ["Henri", "Hippocampe", 8, 3, 2, 0], ["Ivan", "Impitoyable", 9, 3, 3, 0], ["Josephte", "Jamboni", 10, 4, 1, 1], ["Kitty", "KitKat", 11, 4, 2, 1], ["Lola", "Lilalou", 12, 4, 3, 1], ["Manon", "Moriarty", 13, 5, 1, 1], ["Norbert", "Nucléaire", 14, 5, 2, 0], ["Osiris", "Orangeraie", 15, 5, 3, 0], ["Patricia", "Pédoncule", 16, 6, 1, 1], ["Quetzal", "Quelconque", 17, 6, 2, 0], ["Rosa", "Rubéole", 18, 6, 3, 1], ["Stephen", "Satan", 19, 1, 1, 0], ["Tarantula", "Tantrique", 20, 2, 2, 1], ["Ursulin", "Ultime Ninja", 21, 3, 3, 0], ["Vanessa", "Velociraptor", 22, 4, 1, 1], ["Waldorf", "Wolfenstein", 23, 5, 2, 0], ["Xanetia", "Xylophage", 24, 6, 3, 1], ["Yannick", "Ytterbium", 25, 1, 4, 0], ["Zaza", "Zébulon", 26, 2, 4, 1]]; $sports = Sport::all(); $regions = Region::all(); Participant::where('equipe', '=', 0)->delete(); foreach ($entrees as $entree) { $participant = new Participant(); $participant->prenom = $entree[0]; $participant->nom = $entree[1]; $participant->numero = $entree[2]; $participant->region_id = $regions[$entree[3]]->id; $participant->sexe = $entree[5]; $participant->naissance = new DateTime(); $participant->equipe = false; $participant->save(); $participant->sports()->attach([$sports[$entree[4]]->id]); } }
public static function notification($template, $recipient, $variables) { $variables['recipient'] = $recipient; if ($recipient instanceof User) { $recipient = array($recipient); } foreach ($recipient as $user) { $messageParts = View::make('messenger.templates.' . $template, $variables)->renderSections(); $thread = Thread::create(['subject' => $messageParts['subject']]); // Message Message::create(['thread_id' => $thread->id, 'user_id' => $user->id, 'body' => $messageParts['body'] . $messageParts['footer'], 'type' => 'notification']); // Sender Participant::create(['thread_id' => $thread->id, 'user_id' => $user->id]); // Recipients $thread->addParticipants(array($user->id)); } }
public function actionUpdateresults($id) { if (Yii::$app->user->can('clinic_results') || Yii::$app->user->can('system_admin')) { $model = $this->findModel($id); $part = \app\models\Participant::findOne(['pk_person' => $model->fk_person]); if ($model->load(Yii::$app->request->post())) { $model->aliquots = $_POST['Urine']['aliquot1'] . "," . $_POST['Urine']['aliquot2']; $model->save(FALSE); Yii::$app->session->setFlash('success', 'The record has been updated successfully'); return $this->redirect(['urine/index']); } else { return $this->render('updateresult', ['model' => $model, 'persondetails' => $part]); } } else { throw new \yii\web\ForbiddenHttpException('Currently you do not have permissions to view this section'); } }
public function getNewNotifications() { $threadsWithNewMessages = []; $participants = Participant::where('user_id', $this->id)->lists('last_read', 'thread_id'); /** * @todo: see if we can fix this more in the future. * Illuminate\Foundation is not available through composer, only in laravel/framework which * I don't want to include as a dependency for this package...it's overkill. So let's * exclude this check in the testing environment. */ if (getenv('APP_ENV') == 'testing' || !str_contains(\Illuminate\Foundation\Application::VERSION, '5.0')) { $participants = $participants->all(); } if ($participants) { $threads = Thread::whereIn('id', array_keys($participants))->get(); foreach ($threads as $thread) { if ($thread->updated_at > $participants[$thread->id] && $thread->getLatestMessageAttribute()->type == 'notification') { $threadsWithNewMessages[] = $thread->id; } } } return $threadsWithNewMessages; }
/** * Adds a new message to a current thread * * @param $id * @return mixed */ public function update($id) { try { $thread = Thread::findOrFail($id); } catch (ModelNotFoundException $e) { Session::flash('error_message', 'The thread with ID: ' . $id . ' was not found.'); return Redirect::to('messages'); } $thread->activateAllParticipants(); // Message Message::create(['thread_id' => $thread->id, 'user_id' => Auth::id(), 'body' => strip_tags(Input::get('message'))]); // Add replier as a participant $participant = Participant::firstOrCreate(['thread_id' => $thread->id, 'user_id' => Auth::user()->id]); $participant->last_read = new Carbon(); $participant->save(); // Recipients if (Input::has('recipients')) { $thread->addParticipants(Input::get('recipients')); } return Redirect::to('messages'); }
/** * Finds the Participant model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Participant the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Participant::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
/** * @return \yii\db\ActiveQuery */ public function getParticipants() { return $this->hasMany(Participant::className(), ['konkurs_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getParticipants() { return $this->hasMany(Participant::className(), ['id' => 'Participant_id'])->viaTable('Survey_has_Participant', ['Survey_id' => 'id']); }
/** * Retourne le résultat pour un événement en format JSON * * Doit être appelé par un call AJAX. * * @param[in] post int evenementId l'id de l'événement pour lequel on veut montrer le résultat * @return la sous-view pour afficher un résultat. * */ public function resultatPourEvenement() { if (1 == 1 || Request::ajax()) { $evenementId = Input::get('evenementId'); //$evenementId = $this->checkEvenementId($evenements, $evenementId); try { $evenement = Evenement::findOrFail($evenementId); $resultats = $evenement->resultats; $resultat = Resultat::findOrFail($evenementId); $participant1 = Participant::findOrFail($resultat->participant1_id); $participant2 = Participant::findOrFail($resultat->participant2_id); } catch (ModelNotFoundException $e) { //App::abort(404); return View::make('resultats.resultat')->with('resultat', $resultats); } return View::make('resultats.resultat')->with('resultat', $resultats)->with('participant1', $participant1)->with('participant2', $participant2); } else { return App::abort(404); } }
/** * @return \yii\db\ActiveQuery */ public function getParticipant() { return $this->hasOne(Participant::className(), ['id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getFkPerson() { return $this->hasOne(Participant::className(), ['pk_person' => 'fk_person']); }
/** * Find a user by barcode * * @param $barcode * @return array */ public function findByBarcode($barcode) { $participant = Participant::where('barcode', $barcode)->first(); return ['id' => $participant->id, 'name' => $participant->name, 'image' => $participant->image, 'crew' => $participant->crew]; }
public function actionUpdatebp($id) { $model = $this->findModel($id); if (\Yii::$app->request->isAjax && $model->load(Yii::$app->request->post())) { \Yii::$app->response->format = 'json'; return \kartik\widgets\ActiveForm::validate($model); } if ($model->load(Yii::$app->request->post()) && $model->validate()) { $model->updated_date = new \yii\db\Expression('NOW()'); $model->update_name = \Yii::$app->user->identity->username; if ($model->save()) { Yii::$app->session->setFlash('success', 'The record has been updated successfully'); return $this->redirect(['participant/index']); } } else { $fkperson = \app\models\Participant::findOne(['pk_person' => $model->fk_person]); return $this->render('updatebp', ['model' => $model, 'persondetails' => $fkperson]); } }
function actionCalendar() { $model = new Participant(); $year = $_POST['year']; $month = $_POST['id']; $data = $model->build_calendar($month, $year); return $data; }
<?php use yii\helpers\Html; use yii\widgets\DetailView; /* @var $this yii\web\View */ /* @var $model app\models\Urine */ $this->title = \app\models\Participant::findOne(['pk_person' => $model->fk_person])->names; ?> <div class="panel panel-primary"> <div class="panel-heading"> <h3 class="panel-title"><?php echo Html::encode($this->title); ?> </h3> </div> <div class="panel-body"> <div class="urine-view"> <?php echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'fk_person', 'fk_study_no', 'date_visit', 'time_visit', 'spot_urine_collected', 'reason_not_collected', 'spot_urine_time', 'date_collect_urine', 'date_received_urine', 'time_received_urine', 'date_result_spot_urine', 'time_result_spot_urine', 'spot_na_urine', 'spot_k_urine', 'spot_cr_urine', 'spot_alb_urine', 'year', 'clinician', 'result_complete', 'aliquots', 'sample_labelled', 'frozen', 'tech_initials_r', 'tech_date_r', 'tech_time_r', 'tech_initials_p', 'tech_date_p', 'tech_time_p']]); ?> </div> </div> </div>
/** * The participant index. * * @return \Library\View */ public function index() { return $this->view->make('participant/index', array('participants' => Participant::all())); }
/** * Run the database seeds. * * @return void */ public function run() { \App\Models\Participant::create(['barcode' => "1", 'name' => 'Ssoele', 'image' => 'ssoele']); }
public function findOne($id) { if (($participant = Participant::findOne($id)) !== null) { $this->id = $participant->id; $this->makeNameFromParticipant($participant->name); $this->setUserType($participant->type); $this->smi_name = $participant->smi_name; $this->smi_type = $participant->smi_type; $this->smi_url = $participant->smi_url; $this->smi_editor = $participant->smi_editor; $this->smi_periodity = $participant->smi_periodity; $this->smi_field = $participant->smi_field; $this->smi_area = $participant->smi_area; $this->smi_status = $participant->smi_status; $this->smi_head = $participant->smi_head; $this->smi_jur_address = $participant->smi_jur_address; $this->occupation = $participant->occupation; $this->post_address = $participant->post_address; $this->city_phone = $participant->city_phone; $this->mobile_phone = $participant->mobile_phone; return $this; } return null; }
/** * @return \yii\db\ActiveQuery */ public function getParticipants() { return $this->hasMany(Participant::className(), ['id' => 'Participant_id'])->viaTable('participant_has_coupon', ['coupon_id' => 'id']); }
public function actionRegisterBPMeasurements($fkperson, $fkstudyno) { echo "I am here"; exit; $modelcheck = Bp24h::findone(['fk_person' => $fkperson]); if (!$modelcheck) { $bpmodel = new Bp24h(); $bpmodel->fk_person = $fkperson; $bpmodel->fk_study_no = $fkstudyno; if ($bpmodel->save(false)) { $modelcheck = Bp24h::findone(['fk_person' => $fkperson]); } } $id = $modelcheck->idbp24; $model = $this->findModel($id); $bp24 = new Bp24h(); $_24hdata = $bp24->pull24hoursdata($id); $pid = $model->fk_person; $patmodel = \app\models\Participant::find([]); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->idbp24]); } else { return $this->render('update', ['model' => $model, 'dataProvider' => $_24hdata]); } }
/** * @return \yii\db\ActiveQuery */ public function getParticipant() { return $this->hasOne(Participant::className(), ['user_id' => 'id'])->inverseOf('user'); }
function countRecords($date) { $data = Participant::find()->where(['appoint_date' => $date])->andWhere('filtered IS NULL')->andWhere('appoint_level < 3 OR appoint_level IS NULL')->andWhere('consent IS NULL')->count(); return $data; }
/** * Modifie les joueurs faisant partie de l'équipe * * @param int $id * @return \Illuminate\Http\Response */ public function update($id) { try { $equipe = Equipe::findOrFail($id); // L'équipe doit être une équipe if (!$equipe->equipe) { App::abort(404); } $equipe->equipe = true; $equipe->nom = Input::get('nom'); $equipe->numero = Input::get('numero'); $membres = Input::get('joueur'); if ($membres) { if (is_array($membres)) { // Les joueurs sélectionnés doivent exister $participants = Participant::whereIn('id', $membres); if ($participants->count() != count($membres)) { App::abort(404); } // Les joueurs sélectionnés ne doivent pas être des équipes if ($participants->where('equipe', '<>', '0')->count() > 0) { App::abort(404); } } elseif (Participant::findOrFail($membres)->equipe) { App::abort(404); } } if ($equipe->save()) { // Associer les membres à l'équipe if ($membres) { if (is_array($membres)) { $equipe->membres()->sync($membres); } else { $equipe->membres()->sync([$membres]); } } else { $equipe->membres()->detach(); } // Redirection dans la page de visualisation de l'équipe return Redirect::action('EquipesController@show', $equipe->id); } else { return Redirect::back()->withInput()->withErrors($equipe->validationMessages()); } } catch (Exception $e) { App: abort(404); } }