<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\DetailView;
use yii\base\Widget;
use yii\base\Object;
use yii\data\ArrayDataProvider;
use common\components\AccountStatisticWidget;
use common\components\DataProviderTotal;
use common\components\Helper;
use common\models\Transfer;
use yii\helpers\VarDumper;
use yii\widgets\ActiveForm;
use yii\helpers\Url;

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

$this->title = "Tranzakciók későbbi utalás fizetés típussal";
$this->params['breadcrumbs'][] = $this->title;

?>
<style>
	.table-transfer .money,
	.table-transfer .count,
	.table-transfer .item-price
	{
		text-align: right;	
	}
</style>

<div class="transfer-index">

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

<div style="margin-bottom: 6px;">
<?php 
echo Html::a("PDF",Url::current(['TransferLaterSearch[output]'=>'pdf']), ['class' => 'btn btn-primary' ]);
?>
</div>

<div style="margin-bottom: 6px;">
<?php 
echo Html::a("Összes kiválasztása",null, ['class' => 'btn btn-primary select-all' ,'style' => 'margin-right: 6px;',
		'onclick' => "$('.table-transfer').find(\"input[type='checkbox']\").prop('checked',true);"
]);
echo Html::a("Egyiket sem",null, ['class' => 'btn btn-primary deselect-all',
		'onclick' => "$('.table-transfer').find(\"input[type='checkbox']\").prop('checked',false);"
		
]);

?>
</div>
 <div class="transfer-form">

    <?php $form = ActiveForm::begin(
    			[ 'action' => Url::current() ]
    	); ?>
		<p>
			Összesen: <?php echo $searchModel->total_money;?> Ft
		</p>
	    <?= GridView::widget([
	    	'tableOptions' => ['class' => 'table table-striped table-bordered table-transfer'],	
	        'dataProvider' => $dataProvider,
	    	'showFooter'=>TRUE,
	    		
	        'columns' => [
	        		[
	        		'label' => '',
	        		'value' => function ($model, $key, $index, $column)  use (  &$searchModel){
						
						        		
	        			return   Html::checkbox(Html::getInputName($searchModel, 'selected[]') ,  in_array($model['transfer_id_transfer'], $searchModel->selected) , [   'class' => 'cart-item', 'value'  => $model['transfer_id_transfer']] );
	        		},
	        		'format' => 'raw'
	        				],
				[
				 'attribute' => 'user_username',
				 'label' => 'Felhasználó'
			    ],
	        		[
	        		'attribute' => 'customer_name',
	        		'label' => 'Vendég'
	        				],
	        		[
	        		'attribute' => 'ticket_type_name',
	        		'label' => 'Bérlet típus'
	        				],
	        		[
	        		'attribute' => 'ticket_start',
	        		'label' => 'Érvényes -tól',
	        		'format' => 'date'
	        				],
	        		[
	        		'attribute' => 'ticket_end',
	        		'label' => 'Érvényes -ig',
	        		'format' => 'date'
	        				],
	        		[
	        		'attribute' => 'product_name',
	        		'label' => 'Termék'
	        				],
	        		[
	        		'attribute' => 'transfer_created_at',
	        		'label' => 'Kiadva',
	        		'format' => 'datetime'
	        				],
	        		[
	        		'attribute' => 'transfer_money',
	        		'label' => 'Összeg'
			        ],
	        		[
	        			'attribute' => 'transfer_status',
	        			'label' => 'Státusz',
	        			'value' => function ($model, $key, $index, $column){
	        					return Helper::getArrayValue(Transfer::statuses(), $model['transfer_status'],'');
	    				},
			        ],
	        		[
	        		'attribute' => 'customer_description',
	        		'label' => 'Megjegyzés'
			        ],
			        [
				        'attribute' => 'ticket_comment',
				        'label' => 'Megj'
			        ],
			     ],
	    ]); ?>
	
	
	    <div class="form-group">
	        <?=  Html::submitButton(  'Fizetettnek jelöl',  [ 'class' => 'btn btn-success'  ]  ) ?>
	    </div>

    <?php ActiveForm::end(); ?>

</div>

</div>
