<?php

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

/* @var $this yii\web\View */
/* @var $model common\models\Product */
/* @var $accounts common\models\Account[] */
/* @var $form yii\widgets\ActiveForm */
?>
<?php 
$account_options = ArrayHelper::map($accounts, 'id_account', 'name');
$product_category_options = ArrayHelper::map($categories, 'id_product_category', 'name');

$inventory_groups = InventoryGroup::find()->andWhere(['status' => InventoryGroup::STATUS_ACTIVE])->all();
$inventory_groups = ['' => '']  + ArrayHelper::map($inventory_groups, "id_inventory_group", "name");

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

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>

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

    <?= $form->field($model, 'product_number')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'barcode')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'purchase_price')->input('number') ?>

    <?= $form->field($model, 'sale_price')->input('number')?>

    <?= $form->field($model, 'profit_margins')->textInput() ?>

    <?= $form->field($model, 'status')->checkbox( ['value' => 10, 'label' =>    Yii::t('common/product', "Active") 	])  ?>

    <?= $form->field($model, 'description')->textarea(['maxlength' => true])->hint( Yii::t( 'common/product', "Max 255 character")) ?>

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

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

</div>
