<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\ArrayHelper;
use yii\data\ArrayDataProvider;
use yii\helpers\Url;

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

$this->title = Yii::t('common/ticket', 'Statisztika');
$this->params['breadcrumbs'][] = $this->title;



?>

<div class="ticket-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php   echo $this->render('_search_statistics', ['model' => $searchModel]); ?>

    
    
    <div class="panel panel-default">
    	<div class="panel-heading">Bérlet statisztika</div>
	    <div class="panel-body">
	        <p>Bérlet statisztika a kiválasztott időszakra</p>
	        
	        	<?php 

	if ( !isset($searchModel->output) ){
		
		$pdfUrl = Url::current([ Html::getInputName($searchModel, 'output')  => 'pdf']);
		echo Html::a("PDF letöltése", $pdfUrl,['class' => 'btn btn-primary btn-all' ]);
	}


?>
	    <?php 
	    
	    	echo GridView::widget([
				'dataProvider' => new ArrayDataProvider([
					'allModels' => $searchModel->statistics,
	     			'sort' => false,
	     			'pagination' =>  false,
				]),
	    		'showFooter'=>TRUE,
	    		'footerRowOptions'=>['style'=>'font-weight:bold; '],
				'columns' =>[
					[
						'attribute' => 'name',
						'label' => 'Bérlet',
	    				'footer' => 'Összesen'
					],
					[
						'attribute' => 'created',
						'label' => 'Kiadva (Db)',
	    				'footer' => $searchModel->statisticsTotal['created']
					],
					[
						'attribute' => 'created_money',
						'label' => 'Kiadott érték (Ft)',
	    				'footer' => $searchModel->statisticsTotal['created_money']
					],
					[
						'attribute' => 'valid',
						'label' => 'Érvényes (Db)',
						'footer' => $searchModel->statisticsTotal['valid']
	
					],
	    			[
						'attribute' => 'expired',
						'label' => 'Lejár az adott időszakban (Db)',
	    				'footer' => $searchModel->statisticsTotal['expired']
	    			]
		
				]
			]);
	    
	    ?>
	    </div>
	    </div>


</div>
