Ejemplo n.º 1
0
 public function search($params)
 {
     $query = Producer::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => new \yii\data\Sort(['attributes' => ['name', 'id']])]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'text', $this->text]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
            <?php 
echo $form->field($model, 'sort')->textInput();
?>
        </div>
    </div>



    <div class="row">
        <div class="col-lg-6 col-xs-6">
            <?php 
echo $form->field($model, 'category_id')->widget(Select2::classname(), ['data' => Category::buildTextTree(), 'language' => 'ru', 'options' => ['placeholder' => 'Выберите категорию ...'], 'pluginOptions' => ['allowClear' => true]]);
?>

            <?php 
echo $form->field($model, 'producer_id')->widget(Select2::classname(), ['data' => ArrayHelper::map(Producer::find()->all(), 'id', 'name'), 'language' => 'ru', 'options' => ['placeholder' => 'Выберите бренд ...'], 'pluginOptions' => ['allowClear' => true]]);
?>
        </div>
        <div class="col-lg-6 col-xs-6">
            <?php 
echo $form->field($model, 'category_ids')->label('Прочие категории')->widget(Select2::classname(), ['data' => Category::buildTextTree(), 'language' => 'ru', 'options' => ['multiple' => true, 'placeholder' => 'Доп. категории ...'], 'pluginOptions' => ['allowClear' => true]]);
?>
        </div>
    </div>

    <?php 
echo $form->field($model, 'text')->widget(\app\widgets\Editor::className());
?>

    <?php 
echo $form->field($model, 'short_text')->textInput(['maxlength' => true]);
Ejemplo n.º 3
0
if ($amount = $dataProvider->query->sum('amount')) {
    ?>
    <div class="summary">
            Всего остатков: Всего товаров:
            <?php 
    echo $amount;
    ?>
        </div>
        на сумму
        <?php 
    echo Price::find()->joinWith('product')->sum("shop_price.price*shop_product.amount");
    ?>
        руб.
    </div>
    <?php 
}
?>

    <br style="clear: both;"></div>
    <?php 
echo \kartik\grid\GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'id', 'filter' => false, 'options' => ['style' => 'width: 55px;']], 'name', 'code', ['label' => 'Остаток', 'content' => function ($model) {
    return "<p>{$model->amount} (" . $model->amount * $model->price . ")</p>";
}], ['attribute' => 'images', 'format' => 'images', 'filter' => false, 'content' => function ($image) {
    if ($image = $image->getImage()->getUrl('50x50')) {
        return "<img src=\"{$image}\" class=\"thumb\" />";
    }
}], ['label' => 'Цена', 'value' => 'price'], ['attribute' => 'category_id', 'filter' => Html::activeDropDownList($searchModel, 'category_id', Category::buildTextTree(), ['class' => 'form-control', 'prompt' => 'Категория']), 'value' => 'category.name'], ['attribute' => 'producer_id', 'filter' => Html::activeDropDownList($searchModel, 'producer_id', ArrayHelper::map(Producer::find()->all(), 'id', 'name'), ['class' => 'form-control', 'prompt' => 'Производитель']), 'value' => 'producer.name'], ['class' => 'app\\modules\\admin\\components\\grid\\ActionColumn', 'translatable' => true]]]);
?>

</div>