/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Subject::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->joinWith('grades'); $query->joinWith('scholarScholar'); $query->andFilterWhere(['subject_id' => $this->subject_id, 'scholar_scholar_id' => $this->scholar_scholar_id, 'scholar_school_school_id' => $this->scholar_school_school_id, 'subject_term' => $this->subject_term, 'subject_units' => $this->subject_units]); $query->andFilterWhere(['like', 'subject_name', $this->subject_name])->andFilterWhere(['like', 'subject_taken_status', $this->subject_taken_status])->andFilterWhere(['like', 'subject_approval_status', $this->subject_approval_status])->andFilterWhere(['like', 'subject_approved_by', $this->subject_approved_by])->andFilterWhere(['like', 'grades.grade_raw_grade', $this->rawGrade])->andFilterWhere(['like', 'scholar.scholar_first_name', $this->firstName])->andFilterWhere(['like', 'scholar.scholar_middle_name', $this->middleName])->andFilterWhere(['like', 'scholar.scholar_last_name', $this->lastName]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Subject::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!isset($this->dob)) { if (isset($this->dob_yyyy) && isset($this->dob_mm) && isset($this->dob_dd)) { $this->dob = sprintf('%s-%s-%s', $this->dob_yyyy, $this->dob_mm, $this->dob_dd); } } 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; } print_r($this->dob); // grid filtering conditions $query->andFilterWhere(['id' => $this->id, 'dob' => $this->dob, 'screening_form_id' => $this->screening_form_id, 'project_id' => $this->project_id, 'gp_opt_id' => $this->gp_opt_id, 'email_opt_id' => $this->email_opt_id, 'sex_id' => $this->sex_id, 'sort_order' => $this->sort_order, 'status_id' => $this->status_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'created_by' => $this->created_by, 'updated_by' => $this->updated_by]); $query->Where(['=', 'first_name', $this->first_name])->andWhere(['=', 'last_name', $this->last_name])->andWhere(['=', 'dob', $this->dob]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = parent::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!isset($params['dob'])) { if (isset($this->dob_yyyy) && isset($this->dob_mm) && isset($this->dob_dd)) { $this->dob = sprintf('%s-%s-%s', $this->dob_yyyy, $this->dob_mm, $this->dob_dd); } } 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; } if (isset($params['hash'])) { $query->Where(['=', 'hash', $params['hash']])->andWhere(['=', 'status_id', Types::$status['active']['id']]); } else { $query->Where(['=', 'first_name', $this->first_name])->andWhere(['=', 'last_name', $this->last_name])->andWhere(['=', 'dob', $this->dob])->andWhere(['=', 'status_id', Types::$status['active']['id']]); } return $dataProvider; }
<?php use yii\helpers\Html; use kartik\grid\GridView; use kartik\export\ExportMenu; use yii\helpers\ArrayHelper; use common\models\Scholar; use common\models\School; use common\models\Subject; $exportedValues = [['class' => 'kartik\\grid\\SerialColumn'], ['attribute' => 'subject_scholar_scholar_id'], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'subject_subject_id', 'editableOptions' => ['inputType' => '\\kartik\\select2\\Select2', 'options' => ['data' => ArrayHelper::map(Subject::find()->all(), 'subject_id', 'subject_name')]], 'value' => 'subjectSubject.subject_name'], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'takenStatus', 'editableOptions' => ['inputType' => 'dropDownList', 'pluginOptions' => ['allowClear' => true], 'data' => ["Not Taken" => "Not Taken", "Taken" => "Taken", "Failed" => "Failed"], 'widgetClass' => 'kartik\\select2\\Select2'], 'value' => 'subjectSubject.subject_taken_status'], ['attribute' => 'firstName', 'value' => 'scholarScholar.scholar_first_name'], ['attribute' => 'middleName', 'value' => 'scholarScholar.scholar_middle_name'], ['attribute' => 'lastName', 'value' => 'scholarScholar.scholar_last_name'], ['attribute' => 'subject_scholar_school_school_id', 'value' => 'schoolSchool.school_name'], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'grade_school_year_start'], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'grade_school_year_end'], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'grade_raw_grade'], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'grade_approval_status', 'editableOptions' => ['inputType' => 'dropDownList', 'pluginOptions' => ['allowClear' => true], 'data' => ["Not Approved" => "Not Approved", "Approved" => "Approved"], 'widgetClass' => 'kartik\\select2\\Select2']], ['attribute' => 'grade_approved_by'], ['class' => 'kartik\\grid\\ActionColumn']]; $export = ExportMenu::widget(['dataProvider' => $dataProvider, 'columns' => $exportedValues, 'exportConfig' => ['Excel5' => false, 'Excel2007' => false], 'noExportColumns' => [13], 'target' => '_blank', 'columnSelectorOptions' => ['label' => 'Columns', 'class' => 'btn btn-danger'], 'fontAwesome' => true, 'dropdownOptions' => ['label' => 'Export All', 'class' => 'btn btn-success']]); /* @var $this yii\web\View */ /* @var $searchModel common\models\SchoolSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Grades'; $this->params['breadcrumbs'][] = $this->title; ?> <h1><?php echo Html::encode($this->title); ?> </h1> <?php echo Html::a('Group By School', ['index'], ['class' => 'btn btn-success']); echo Html::a('Show Only Grade Records', ['index2'], ['class' => 'btn btn-success']); ?> <div class="school-index"> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'pjax' => true, 'pjaxSettings' => ['neverTimeout' => true], 'columns' => $exportedValues, 'toolbar' => [['content' => Html::a('Create Grade', ['groupcreate'], ['class' => 'btn btn-success'])], '{toggleData}', $export], 'export' => ['fontAwesome' => true, 'label' => 'Export All', 'target' => '_blank'], 'panel' => ['type' => GridView::TYPE_PRIMARY, 'heading' => 'Grade List']]); ?> </div> <br>
<button type="button" class="remove-item btn btn-danger btn-xs"><i class="glyphicon glyphicon-minus"></i></button> </div> <div class="clearfix"></div> </div> <div class="panel-body"> <?php // necessary for update action. if (!$modelAddress->isNewRecord) { echo Html::activeHiddenInput($modelAddress, "[{$i}]grade_id"); } ?> <div class="row"> <div class="col-sm-6"> <?php echo $form->field($modelAddress, "[{$i}]subject_subject_id")->dropDownList(ArrayHelper::map(Subject::find()->where(['scholar_scholar_id' => $modelCustomer->subject_scholar_scholar_id])->all(), 'subject_id', 'subject_name', 'subject_term', 'scholar_scholar_id')); ?> </div> <div class="col-sm-4"> <?php echo $form->field($modelAddress, "[{$i}]grade_raw_grade")->textInput(['maxlength' => true]); ?> </div> </div><!-- .row --> </div> </div> <?php } ?>
<button type="button" class="remove-item btn btn-danger btn-xs"><i class="glyphicon glyphicon-minus"></i></button> </div> <div class="clearfix"></div> </div> <div class="panel-body"> <?php // necessary for update action. if (!$modelAddress->isNewRecord) { echo Html::activeHiddenInput($modelAddress, "[{$i}]id"); } ?> <div class="row"> <div class="col-sm-6"> <?php echo $form->field($modelAddress, "[{$i}]subject_subject_id")->dropDownList(ArrayHelper::map(Subject::find()->all(), 'subject_id', 'subject_name', 'scholar_scholar_id')); ?> </div> <div class="col-sm-4"> <?php echo $form->field($modelAddress, "[{$i}]grade_raw_grade")->textInput(['maxlength' => true]); ?> </div> </div><!-- .row --> </div> </div> <?php } ?>
public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Subject::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }
use common\models\Subject; use yii\helpers\ArrayHelper; use common\models\Scholar; /* @var $this yii\web\View */ /* @var $model common\models\Grade */ /* @var $form yii\widgets\ActiveForm */ ?> <div class="grade-form"> <?php $form = ActiveForm::begin(); ?> <?php echo $form->field($model, 'subject_subject_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Subject::find()->all(), 'subject_id', 'subject_name'), 'language' => 'en', 'options' => ['placeholder' => 'Select Scholar ID'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php echo $form->field($model, 'subject_scholar_scholar_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Scholar::find()->all(), 'scholar_id', 'scholar_last_name', 'scholar_id'), 'language' => 'en', 'options' => ['placeholder' => 'Select Scholar ID'], 'pluginOptions' => ['allowClear' => true]]); ?> <?php echo $form->field($model, 'grade_school_year_start')->textInput(); ?> <?php echo $form->field($model, 'grade_school_year_end')->textInput(); ?> <?php
public function actionFaq() { return $this->render('faq', ['list' => Faq::find()->where(['active' => 1])->orderBy('id asc')->all(), 'subjects' => Subject::find()->all()]); }