<?php

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

/* @var $this yii\web\View */
/* @var $searchModel frontend\models\ActivitiesSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Activities';
$this->params['breadcrumbs'][] = $this->title;

?>
<div class="activities-index">
    <?= GridView::widget([
        'search' => $this->render('_search.php', ['model' => $searchModel]),
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            //'id',
            'jobno',
            [
                'attribute' => 'welder',
                'format' => 'raw',
                'value' => function($model){
                    $welders = explode(',', $model->welder);
                    $out = '<ul class="list-unstyled">';
                        foreach($welders as $welder) {
                        $out .= '<li>'.$welder.'</li>';
                        }
                        $out .= '</ul>';
                    return $out;
                }
            ],
            // 'company',
            [
                'attribute' => 'account',
                'value' => 'account.account_name',
                'label' => 'Company'
            ],
            'location',
            //'user.username',
 			//'travelstarttime',
            'starttime:datetime',
          	'finishtime:datetime',
//            'edate',
            // 'travelfinishtime',
            // 'shiftlength',
            // 'assistant',
            // 'contact',
            // 'contactno',
            // 'createdby',
            // 'createdon',
            // 'noofwelds',
            // 'contactemail:email',
            // 'date',
            // 'noofshifts',
            // 'attachments',
            
			'jobstatus',
            'billingstatus',
            [
                'class' => 'common\widgets\TraceabilityColumn',
            ],
            

            [
                'class' => 'common\widgets\ActionColumn',
                'template' => Yii::$app->user->identity->ingroup('Global Admins') == true ? '{view} {update} {delete} {undelete}' : '{view}',
                'buttons' => [
                    'undelete' => function ($url, $model, $key) { return $model->deleted == true ? Html::a('<i class="fa fa-undo"></i>', $url) : '';},
                ],
            ]
        ],
    ]); ?>

</div>