<?php

use yii\helpers\Html;
use common\widgets\GridView;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\Shippingcostssearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Shippingcosts';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="shippingcosts-index">

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            [
                'label' => 'Haulier', 
                'attribute' => 'haulierid', 
                'value' => 'haulier.name', 
                'filter' => backend\models\Accounts::intids('haulier'),
            ],
            [
                'format' => 'html',
                'attribute' => 'postcodes',
                //'value' => 'postcodes',
                'value' => function($model){
                    $ex = explode(',',$model->postcodes);
                    $x = 1;
                    $out = '';
                    foreach ($ex as $key => $pc) {
                        $out .= $pc.', ';
                    }
                  
                    return $out;
                },
                'contentOptions'=> ['style' => 'max-width:50vw; white-space: break-spaces; word-break: break-all;']
            ],
            [
                'format' => 'raw',
                'attribute' => 'type',
                'value' => 'type',
                //'contentOptions'=> ['style' => 'max-width:200px; white-space: break-spaces;'],
                'filter' => backend\models\Attributesvalues::formArray('shipping_types'),
            ],
            [
                'attribute' => 'notes',
                'value' => 'notes',
                'contentOptions'=> ['style' => 'max-width:200px; white-space: break-spaces;  word-break: break-all;'],
                //'filter' => backend\models\Attributesvalues::formArray('shipping_types'),
            ],
            // 'notes:ntext',
            // 'haulierid',
            // 'id',
            // 'language',
            // 'created_by',
            // 'updated_by',
            // 'deleted_by',
            // 'relatedid',
            // 'centerid',
            // 'created_at',
            // 'updated_at',
            // 'deleted_at',
            // 'status',
            // 'createdby_name',
            // 'updatedby_name',
            // 'deletedby_name',
            // 'prices',
            // 'postcodes:ntext',

            [
                'class' => common\widgets\ActionColumn::class,
                'template' => '{view} {clone} {update} {delete}',
                'buttons' => [
                    'clone' => function ($url, $model, $key) {
                        return  Html::a('<span class="fa fa-copy"></span>', ['clone', 'id' => $model->id, 'return' => 'back']);
                    },
                ],
            ],
        ],
    ]); ?>
</div>
