Example #1
0
        <div class="box-body">

            <!-- Global Search -->
            <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>
            <p><?php 
echo Html::a("Refresh", ['product/index'], ['class' => 'btn btn-md btn-default']);
?>
</p>

            <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'tableOptions' => ['class' => 'table table-striped table-bordered'], 'columns' => [['attribute' => 'title', 'contentOptions' => ['style' => 'width: 20%;']], ['attribute' => 'description', 'value' => function ($model) {
    return BaseStringHelper::truncateWords($model->description, 15);
}], ['label' => 'Image', 'format' => 'raw', 'value' => function ($model) {
    return \common\components\Product::getSmallProductImage($model);
}], ['attribute' => 'category_id', 'value' => function ($model) {
    return empty($model->category_id) ? '-' : $model->category->title;
}], 'price', ['header' => 'Actions', 'class' => 'yii\\grid\\ActionColumn', 'template' => '{view} {update} {images} {delete}', 'buttons' => ['images' => function ($url, $model, $key) {
    return Html::a('<span class="glyphicon glyphicon glyphicon-picture" aria-label="Image"></span>', Url::to(['image/index', 'id' => $model->id]));
}], 'contentOptions' => ['style' => 'width: 10%;']]]]);
?>

        </div>
        <!-- /.box-body -->
        <?php 
Pjax::end();
?>

    </div>
    <!-- /.box -->
Example #2
0
<?php

/** @var common\models\Product $product */
use common\components\Product;
use yii\helpers\Html;
?>

<tr>
    <td>
        <?php 
echo Product::getSmallProductImage($product);
?>
    </td>
    <td>
        <strong>
            <?php 
echo Html::a(Html::encode($product->title), ['catalog/view', 'id' => $product->id]);
?>
        </strong>
    </td>
    <td>
<!--        <input type="number" value="2" class="form-control">-->
        <?php 
echo $quantity = $product->getQuantity();
?>
<!--        --><?php 
//\yii\widgets\Pjax::begin(['enablePushState' => false])
?>

        <?php 
echo Html::a('-', ['cart/update', 'id' => $product->id, 'quantity' => $quantity - 1], ['class' => 'btn btn-danger', 'disabled' => $quantity - 1 < 1]);