/**
  * Lists all Optionalwork models.
  * @return mixed
  */
 public function actionIndex()
 {
     $username = Yii::$app->user->identity->username;
     $users = User::find()->all();
     $scholars = Scholar::find()->all();
     $model = new Optionalwork();
     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 OptionalworkSearch($model);
                 $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
                 return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
             }
         }
     }
 }
 public function actionIndex2()
 {
     $searchModel = new OptionalworkSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     if (Yii::$app->request->post('hasEditable')) {
         $optionalWorkId = Yii::$app->request->post('editableKey');
         $optionalWork = Optionalwork::findOne($optionalWorkId);
         $out = Json::encode(['output' => '', 'message' => '']);
         $post = [];
         $posted = current($_POST['Optionalwork']);
         $post['Optionalwork'] = $posted;
         if ($optionalWork->load($post)) {
             $optionalWork->save();
         }
         echo $out;
         return;
     }
     return $this->render('index2', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
示例#3
0
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = 'Optional Work';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="scholar-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
$exportedValues = [['class' => 'kartik\\grid\\ExpandRowColumn', 'value' => function ($model, $key, $index, $column) {
    return GridView::ROW_COLLAPSED;
}, 'detail' => function ($model, $key, $index, $column) {
    $searchModel = new OptionalworkSearch();
    $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'], ['class' => 'kartik\\grid\\ActionColumn']];
/*
$export = ExportMenu::widget([
		'dataProvider' => $dataProvider,
        'columns' => $exportedValues,
		'noExportColumns'=>[18],
        'columnSelectorOptions'=>[
            'label' => 'Columns',
            'class' => 'btn btn-danger'
        ],
		'target' => '_blank',
        'fontAwesome' => true,