<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\TicketType;
use yii\helpers\ArrayHelper;

/* @var $this yii\web\View */
/* @var $model common\models\TicketType */
/* @var $form yii\widgets\ActiveForm */
?>
<?php 
	function mkTitle($name){
		$s = "";
		$tag = "h4";
		$s .= "<hr>";
		$s .= Html::beginTag($tag);
		$s .= $name;
		$s .= Html::endTag($tag);
		$s .= "<hr>";
		return $s;
	}
	$account_options = ArrayHelper::map($accounts, 'id_account', 'name');
?>
<div class="ticket-type-form">

    <?php $form = ActiveForm::begin(); ?>
	
	<?= mkTitle("Általános")?>
    <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'type')->dropDownList(TicketType::ticketTypes() )  ?>

	<?= mkTitle("Alkalmak")?>
    <?= $form->field($model, 'max_usage_count')->textInput() ?>

	<?= mkTitle("Érvényességi idő belállítások")?>
	<div class="row">
		<div class="col-md-4">
		    <?= $form->field($model, 'time_unit_count')->textInput() ?>
		</div>
		<div class="col-md-4">
			<?= $form->field($model, 'time_unit_type')->dropDownList(TicketType::timeUnitTypes())  ?>
		</div>
	</div>


	<?= mkTitle("Ár és kassza")?>
    <?= $form->field($model, 'price_brutto')->textInput() ?>


	<?= $form->field($model, 'id_account')->dropDownList($account_options)  ?>

	<?= mkTitle("További beállítások")?>
	
    <?= $form->field($model, 'status')->checkbox( ['value' => 10, 'label' =>    Yii::t('common/ticket_type', "Active") 	])  ?>

    <?= $form->field($model, 'flag_student')->checkbox( ['value' => 1, 'label' =>    Yii::t('common/ticket_type', "Student") 	])  ?>
    
    <?= mkTitle("Csoportos beszedés")?>
    <?= $form->field($model, 'installment_enabled')->checkbox( ['value' => 1, 'label' =>    Yii::t('common/ticket_type', "Csoportos beszedéses a bruttó áron felül") 	])  ?>
	<p>A részletek havonta kerülnek beszedésre</p>
	 <?= $form->field($model, 'installment_money')->textInput() ?>
	 <?= $form->field($model, 'installment_count')->textInput() ?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? Yii::t('common/ticket_type', 'Create') : Yii::t('common/ticket_type', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

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

</div>
