<?php

use yii\helpers\Html;
use yii\grid\GridView;

/* @var $this yii\web\View */
/* @var $searchModel app\models\BranchesSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$actCol;
$count = $dataProvider->getTotalCount();
$count < 2 ? $actCol = ['class' => 'yii\grid\ActionColumn', 'template' => '{view} {update}'] :
$actCol = ['class' => 'yii\grid\ActionColumn', 'template' => '{view} {update} {delete}'];
$this->title = Yii::t('app', 'Branches');

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

    <h1><?= Html::encode($this->title) ?></h1>

    <p>
        <?= Html::a(Yii::t('app', 'Create Branches'), ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
    <div class="table-responsive">
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        
        'columns' => [
            'arabic_name',
            'english_name',
            [
                'attribute' => 'arabic_address',
                'headerOptions' => ['style' => 'width:25%'],
                'contentOptions' => ['style' => 'word-break:break-word;']
            ],
            [
                'attribute' => 'english_address',
                'headerOptions' => ['style' => 'width:25%'],
                'contentOptions' => ['style' => 'word-break:break-word;']
            ],
            [
                'attribute' => 'location',
                'format' => 'raw',
                'headerOptions' => ['style' => 'width:25%'],
                'contentOptions' => ['style' => 'word-break:break-word;'],
                'value' => function($model) {
                    return Html::a($model->location, $model->location, ['target' => '_blank']);
                }
            ],
            'phone_num',

            $actCol,
        ],
    ]); ?>

</div>
</div>
