/** * Lists all Incentive models. * @return mixed */ public function actionIndex() { $username = Yii::$app->user->identity->username; $users = User::find()->all(); $scholars = Scholar::find()->all(); $model = new Incentive(); foreach ($users as $user) { foreach ($scholars as $scholar) { if ($user->username == $username && $user->id == $scholar->scholar_user_id) { $model->scholar_scholar_id = $scholar->scholar_id; $searchModel = new IncentiveSearch($model); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); } } } }
public function actionIndex2() { $searchModel = new IncentiveSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); if (Yii::$app->request->post('hasEditable')) { $incentiveId = Yii::$app->request->post('editableKey'); $incentive = Incentive::findOne($incentiveId); $out = Json::encode(['output' => '', 'message' => '']); $post = []; $posted = current($_POST['Incentive']); $post['Incentive'] = $posted; if ($incentive->load($post)) { $incentive->save(); } echo $out; return; } return $this->render('index2', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }
?> <div class="scholar-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <?php $exportedValues = [['class' => 'kartik\\grid\\ExpandRowColumn', 'value' => function ($model, $key, $index, $column) { return GridView::ROW_COLLAPSED; }, 'detail' => function ($model, $key, $index, $column) { $searchModel = new IncentiveSearch(); $searchModel->scholar_scholar_id = $model->scholar_id; $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return Yii::$app->controller->renderPartial('_dropdown', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }], 'scholar_id', ['attribute' => 'scholar_first_name'], ['attribute' => 'scholar_middle_name'], ['attribute' => 'scholar_last_name'], ['attribute' => 'school_school_id', 'value' => 'schoolSchool.school_name']]; $export = ExportMenu::widget(['dataProvider' => $dataProvider, 'columns' => $exportedValues, 'noExportColumns' => [18], 'columnSelectorOptions' => ['label' => 'Columns', 'class' => 'btn btn-danger'], 'target' => '_blank', 'fontAwesome' => true, 'dropdownOptions' => ['label' => 'Export', 'class' => 'btn btn-success']]); echo Html::a('Group By Scholar', ['index'], ['class' => 'btn btn-success']); echo Html::a('Show Only Incentive Records', ['index2'], ['class' => 'btn btn-success']); ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'pjax' => true, 'pjaxSettings' => ['neverTimeout' => true], 'rowOptions' => function ($model) { if (strcasecmp($model->allowance_allowance_area, 'NCR') != 0) { return ['class' => 'provincial-row']; } else { if (strcasecmp($model->allowance_allowance_area, 'NCR') == 0) { return ['class' => 'ncr-row'];