<?php

use yii\helpers\Html;
use common\widgets\GridView;
use yii\helpers\ArrayHelper;
use backend\models\Dynamiccss;

/**
 * @var yii\web\View $this
 * @var PortalPeople\shippingcosts\models\SysShippingSettingSearch $searchModel
 * @var yii\data\ActiveDataProvider $dataProvider
 */
$stores = Dynamiccss::getStores();

$this->title = 'Shipping General Settings';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="sys-shipping-setting-index">

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'id' => 'shipset',
        'filterSelector' => '#shipsetpagesize',
        'columns' => [
            [
                'class'     => 'common\widgets\ActionColumn',
                'header'    => 'Action',
            ],
            ['class' => 'yii\grid\SerialColumn'],
            [
                'label' => 'Store',
                'attribute' => 'centerid',
                'value' => function ($model) {
                    return $model->storename;
                },
                'filter' => Html::activeDropDownList($searchModel, 'centerid', ArrayHelper::map($stores, 'id', 'storeid'), ['class' => 'form-control','prompt' => 'All']),
                'options' => ['width' => '8%'],

            ],
            'title',
            'max_shipping_cost',
            'shipping_promotion',
            [
                'label' => "Enabled",
                'attribute' => 'enabled',
                'value' => function ($model) {
                    return $model->enabled == "1" ? "Yes" : ( $model->enabled == "2" ? "No" : "");
                },
            ],
            [
                'attribute' => 'totaling_algo',
                'value' => function ($model) {
                    return $model->algoname;
                },
            ],
                        [
                            'class' => common\widgets\TraceabilityColumn::class,
                            'attribute' => 'traceability',
                            'format' => 'raw',
                        ],

        ],
    ]); ?>
</div>
