<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\Product;
use common\models\ProductCategory;
use yii\helpers\ArrayHelper;
use common\models\Account;

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

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

$statusOptions = ['' => "Mind"] +  ( Product::statuses() );

$productCategories =  ['' => "Mind"] +    ArrayHelper::map( ProductCategory::read(null) ,'id_product_category','name') ;

$accounts =  ['' => "Mind"] +  ( ArrayHelper::map( Account::read(null) ,'id_account','name'));

?>
<div class="product-search">

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

	<div class="row">
	<div class="col-md-4">
    <?= $form->field($model, 'id_product_category')->dropDownList($productCategories) ?>
	</div>
	<div class="col-md-4">
    <?= $form->field($model, 'id_account')->dropDownList($accounts) ?>
	</div>
	<div class="col-md-4">
    <?php  echo $form->field($model, 'status')->dropDownList($statusOptions) ?>
	</div>
	<div class="col-md-4">
		<?= $form->field($model, 'name') ?>
	</div>
	<div class="col-md-4">
    <?= $form->field($model, 'barcode') ?>
	</div>
	<div class="col-md-4">
    <?= $form->field($model, 'product_number') ?>
	</div>
	</div>


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

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

</div>
