<?php

use common\helpers\Price;
use yii\grid\GridView;

$userModule = $this->getUserModule();

$this->setTitle('Cagnotte');

?>

<div class="row">
    <div class="col-md-6">
        <div class="info-box">
            <span class="info-box-icon <?= $sumUserProducerCredits >= 0 ? 'bg-green' : 'bg-red' ?>"><i
                        class="fa fa-euro"></i></span>
            <div class="info-box-content">
                <span class="info-box-text">Somme totale en cagnotte</span>
                <span class="info-box-number"><?= Price::format($sumUserProducerCredits); ?></span>
            </div>
        </div>
    </div>
    <div class="col-md-6">
        <div class="info-box">
            <span class="info-box-icon bg-orange"><i class="fa fa-download"></i></span>
            <div class="info-box-content">
                <span class="info-box-text">Exports<br />
                    <a class="btn btn-default btn-sm" href="<?= Yii::$app->urlManager->createUrl(['credit/export-users', 'type' => 'negative']); ?>">Clients en négatif (CSV)</a>
                    <a class="btn btn-default btn-sm" href="<?= Yii::$app->urlManager->createUrl(['credit/export-users', 'type' => 'positive']); ?>">Clients en positif (CSV)</a>
                </span>
            </div>
        </div>
    </div>
</div>

<h3>Clients avec une cagnotte en négatif</h3>

<?=

GridView::widget([
    'dataProvider' => $dataProviderUsersWithNegativeCredit,
    'summary' => '',
    'columns' => [
        [
            'label' => 'Client',
            'value' => function ($user) use ($userModule) {
                return $userModule->getUsernameFromArray($user, true);
            }
        ],
        [
            'label' => 'Email',
            'format' => 'raw',
            'headerOptions' => ['class' => 'column-hide-on-mobile'],
            'filterOptions' => ['class' => 'column-hide-on-mobile'],
            'contentOptions' => ['class' => 'column-hide-on-mobile'],
            'value' => function ($user) {
                return $user['email'];
            }
        ],
        [
            'label' => 'Téléphone',
            'format' => 'raw',
            'headerOptions' => ['class' => 'column-hide-on-mobile'],
            'filterOptions' => ['class' => 'column-hide-on-mobile'],
            'contentOptions' => ['class' => 'column-hide-on-mobile'],
            'value' => function ($user) {
                return $user['phone'];
            }
        ],
        [
            'label' => 'Cagnotte',
            'format' => 'raw',
            'value' => function ($user) {
                return Price::format($user['credit']);
            }
        ]
    ]
]);
?>
