<?php

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

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Clientes';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="clientes-index">
    <div class="box box-default">
        <div class="box-header with-border">
            <h3 class="box-title"><?= $this->title ?></h3>
            <div class="box-tools pull-right">
                <?= Html::a('Registrar Clientes', ['create'], ['class' => 'btn btn-success']) ?>
            </div>
        </div>
        <div class="box-body">
            <?=
            GridView::widget([
                'dataProvider' => $dataProvider,
                'columns' => [
                    'id',
                    [
                        'label' => 'Cliente',
                        'attribute' => 'clientes.nombre',
                        'value' => function($model) {
                            $cliente = $model->getClientes()->one();
                            return ($cliente->nombre . " " . $cliente->apellidop . " " . $cliente->apellidom);
                        }
                    ],
                    'clientes.telefono',
                    'clientes.dnref',
                    'clientes.email:email',
                    [
                        'attribute' => 'created',
                        'value' => function($model) {
                            return date_create($model->created)->format('d-m-Y H:i:s');
                        }
                    ],
                    'linea.icc',
                    [
                        'attribute' => 'linea.producto_id',
                        'value' => function($model) {
                            $linea = $model->getLinea()->one();
                            
                        }
                    ],
                    // 'created',
                    // 'modified',
                    // 'created_by',
                    // 'modified_by',
                    ['class' => 'yii\grid\ActionColumn'],
                ],
            ]);
            ?>
        </div>
    </div>
</div>