Example #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Material::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' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Example #2
0
 /**
  * Finds the Material model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Material the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Material::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #3
0
File: index.php Project: apuc/admin
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'image', 'format' => 'raw', 'value' => function ($model) {
    return "<a href='#' class='openModalSup' data-sup-id='{$model->id}' data-toggle='modal' data-target='#myModal'><img class='supImg' id='supImg_{$model->id}' src='{$model->images}' width='100px'></a>";
}], ['attribute' => 'code', 'class' => DataColumn::className(), 'format' => 'raw', 'value' => function ($model) {
    return Html::textInput('code_' . $model->id, $model->code, ['id' => 'code_' . $model->id, 'class' => 'codeInput', 'style' => 'width:90px;']);
    //return "<input type='text' value='$model->code' name='code'>";
}], ['attribute' => 'type_mat', 'format' => 'raw', 'filter' => function () {
    return '1223';
}, 'value' => function ($model) {
    $mat = \backend\modules\material\models\Material::find()->all();
    foreach ($mat as $m) {
        $arr[$m->id] = $m->name;
    }
    return Html::dropDownList('mat_' . $model->id, $model->type_mat, $arr, ['id' => 'mat_' . $model->id, 'class' => 'matSelect']);
    //$material = \common\models\Material::find()->where(['id' => $model->type_mat])->one();
    //return $material->name;
}, 'filter' => Html::activeDropDownList(new \backend\modules\supplies\models\SuppliesSearch(), 'type_mat', \yii\helpers\ArrayHelper::map(\backend\modules\material\models\Material::find()->asArray()->all(), 'id', 'name'), ['class' => 'form-control', 'prompt' => 'Выберите тип материала', 'options' => [$_GET['SuppliesSearch']['type_mat'] => ['selected ' => 'selected']]])], ['attribute' => 'type_blind', 'format' => 'raw', 'value' => function ($model) {
    /*if($model->type_blind == '1'){
          return 'Горизантальные';
      }
      if($model->type_blind == '2'){
          return 'рулонные';
      }
      if($model->type_blind == '3'){
          return 'вертикальные';
      }*/
    $arr = ['0' => 'Выберите элемент', '1' => 'Горизантальные', '2' => 'рулонные', '3' => 'вертикальные'];
    return Html::dropDownList('blind_' . $model->id, $model->type_blind, $arr, ['id' => 'blind_' . $model->id, 'class' => 'blindSelect']);
}, 'filter' => Html::dropDownList('SuppliesSearch[type_blind]', $_GET['SuppliesSearch']['type_blind'], ['' => 'Выберите', '1' => 'Горизантальные', '2' => 'рулонные', '3' => 'вертикальные'], ['id' => 'suppliessearch-type_blind', 'class' => 'form-control'])], ['attribute' => 'type_width', 'format' => 'raw', 'value' => function ($model) {
    return Html::textInput('width_' . $model->id, $model->type_width, ['id' => 'width_' . $model->id, 'class' => 'widthInput', 'style' => 'width:60px;']);
    //return "<input type='text' value='$model->code' name='code'>";
}], ['attribute' => 'color', 'format' => 'raw', 'value' => function ($model) {