/** * 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 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]); } }
/** * Lists all Participant models. * @return mixed */ public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Participant::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }
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; }
use yii\helpers\Html; use yii\widgets\ActiveForm; /* @var $this yii\web\View */ /* @var $model app\models\Work */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="work-form"> <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> <?php if (Yii::$app->user->can('editWork')) { ?> <?php echo $form->field($model, 'user_id')->dropDownList(ArrayHelper::map(\app\models\Participant::find()->asArray()->all(), 'user_id', 'name')); ?> <?php } ?> <?php echo $form->field($model, 'category_id')->dropDownList(ArrayHelper::map(\app\models\WorkCategory::find()->asArray()->all(), 'id', 'title'), ['onchange' => ' $.post( "' . Yii::$app->urlManager->createUrl('work/get-file-info?id=') . '"+$(this).val(), function( data ) { $( "#fileInfoHint" ).html( data ); }); ']); ?> <?php echo $form->field($model, 'file')->fileInput()->hint($this->context->actionGetFileInfo($model->category_id), ['id' => 'fileInfoHint']);
/** * Affiche le formulaire pour éditer un participant. * * @param int $id l'id du participant à éditer * @return Response */ public function edit($id) { try { $participant = Participant::findOrFail($id); $regions = Region::all(); $sports = Sport::all(); $participantSports = Participant::find($id)->sports; // Si de vieilles entrées n'ont pas de date de naissance, on utilise les valeurs par défaut $anneeDefaut = date('Y') - 20; $moisDefaut = 0; $jourDefaut = 0; if ($participant->naissance) { // Déterminer les valeurs des trois comboboxes $stringsDate = explode('-', $participant->naissance); $anneeDefaut = $stringsDate[0] + 1; $moisDefaut = $stringsDate[1] + 1; $jourDefaut = $stringsDate[2] + 1; } // Générer les listes des comboboxes $listeAnnees = ParticipantsController::generer_liste(date('Y') - 100, 101); $listeMois = ParticipantsController::generer_liste(1, 12); $listeJours = ParticipantsController::generer_liste(1, 31); return View::make('participants.edit', compact('participant', 'regions', 'sports', 'participantSports', 'listeAnnees', 'anneeDefaut', 'listeMois', 'listeJours', 'anneeDefaut', 'moisDefaut', 'jourDefaut')); } catch (Exception $e) { App: abort(404); } }