public function search($params) { $query = Price::find()->orderBy('sort DESC'); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'product_id' => $this->product_id, 'available' => $this->available]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
echo ExportMenu::widget(['dataProvider' => $dataProvider, 'columns' => $gridColumns]); ?> </div> </div> <?php if ($amount = $dataProvider->query->sum('amount')) { ?> <div class="summary"> Всего товаров: <?php echo $amount; ?> на сумму <?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\" />"; }