コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $way = null)
 {
     if ($way == null) {
         $query = Exercise::find();
     } else {
         $query = $way;
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $query->joinWith('subject');
     $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' => $this->id, 'teacher_id' => $this->teacher_id]);
     $query->andFilterWhere(['like', 'exercise.text', $this->text])->andFilterWhere(['like', 'exercise.name', $this->name])->andFilterWhere(['like', 'exercise_subject.name', $this->subject_id]);
     return $dataProvider;
 }
コード例 #2
0
 public function actionExersicelistbytype($id)
 {
     $arr = GivenTask::listToArray($id);
     $exersices = Exercise::find()->where(['subject_id' => $arr])->all();
     return $this->renderAjax('_exersicelistbytype', ['exersices' => $exersices]);
 }
コード例 #3
0
ファイル: _update_form.php プロジェクト: mrhat24/site-for-pm
                $.post( "' . Url::to(['//exercise/exersicelistbytype', 'id' => '']) . '"+arr, function( data ) {
                  $( "#exersices" ).html( data );
                });
            '], 'pluginOptions' => ['tags' => true]]);
?>
    
    <?php 
echo Html::tag('br');
?>
    
    <?php 
echo Html::label('Упражнения');
?>
    
    <?php 
echo Select2::widget(['name' => 'exersices', 'id' => 'exersices', 'value' => ArrayHelper::getColumn($model->exercises, 'exercise.id'), 'data' => ArrayHelper::map(Exercise::find()->where(['subject_id' => ArrayHelper::getColumn(ExerciseSubject::find()->where(['teacher_id' => Yii::$app->user->identity->teacher->id])->all(), 'id')])->all(), 'id', 'name'), 'options' => ['placeholder' => 'Select a color ...', 'multiple' => true, 'onchange' => '
                var arr = []; 
                $("#exersices :selected").each(function(i, selected){ 
                  arr[i] = $(selected).val(); 
                });               
                $.post( "' . Url::to(['//task/exersicespreview', 'list' => '']) . '"+arr, function( data ) {
                  $( "#exersicespreview" ).html( data );
                });
            '], 'pluginOptions' => ['tags' => true]]);
?>
    
    
    <?php 
echo Html::tag('br');
?>