<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use kartik\widgets\DatePicker;

/* @var $this yii\web\View */
/* @var $model backend\models\ProcurementSearch */
/* @var $form yii\widgets\ActiveForm */
?>

<?php 

function mkOptions($options){
// 	$o = $options;
	
	$all = ['' => Yii::t('common/product','All' ) ];
	
	$o =  $all + $options;
	
	return $o;
}

$products =  mkOptions(  ArrayHelper::map( $products ,'id_product','name') );
$users =  mkOptions(  ArrayHelper::map( $users ,'id','username') );
$warehouses =  mkOptions(  ArrayHelper::map( $warehouses ,'id_warehouse','name') );

?>


<div class="procurement-search">

    <?php $form = ActiveForm::begin([
        'action' => ['index'],
        'method' => 'get',
    ]); ?>

	<div class="row">
		<div class="col-md-4">
		    <?= $form->field($model, 'id_warehouse')->dropDownList($warehouses) ?>
		</div>
		<div class="col-md-4">
		    <?= $form->field($model, 'id_user')->dropDownList($users) ?>
		</div>
		<div class="col-md-4">
		    <?= $form->field($model, 'id_product')->dropDownList($products) ?>
		</div>
	</div>
	<div class="row">
		<div class="col-md-4">
		    <?= $form->field($model, 'date_start')->widget(DatePicker::classname(), [
    			 'pluginOptions' => [
				        'autoclose'=>true,
				        'format' => 'yyyy.mm.dd'
				    ]
				])->label("Időintervallum kezdete")  ?>
		</div>
		<div class="col-md-4">
		    <?= $form->field($model, 'date_end') ->widget(DatePicker::classname(), [
    			 'pluginOptions' => [
				        'autoclose'=>true,
				        'format' => 'yyyy.mm.dd'
				    ]
				])->label("Időintervallum vége")   ?>
		</div>
	</div>


    <div class="form-group">
        <?= Html::submitButton(Yii::t('common/procurement', 'Search'), ['class' => 'btn btn-primary']) ?>
    </div>

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

</div>
