<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model common\models\InventoryItem */

$this->title = Yii::t('common/inventory-item', 'Leltár termék');
$this->params['breadcrumbs'][] = ['label' => Yii::t('common/inventory-item', 'Leltár termék'), 'url' => ['inventory-item/index','id' => $inventory->id_inventory]];
$this->params['breadcrumbs'][] = Yii::t('common/inventory-item', 'Leltár mennyiség');

\backend\assets\InventoryItemUpdateAsset::register($this);

$options = [];
$options['products'] = $products;
$options['url_find_inventory_item'] = \yii\helpers\Url::toRoute(['inventory-item/update-item']);
$options['url_save'] = \yii\helpers\Url::toRoute(['inventory-item/update-item']);
$options['id_product'] = $model->id_product;

$this->registerJs('FitnessAdmin.InventoryItem.Update.init( '. json_encode( $options ) .' );');
?>
<div class="inventory-item-update">

    <h1><?= Html::encode($this->title) ?></h1>

    <h2>Leltár</h2>
    <?= DetailView::widget([
        'model' => $inventory,
        'attributes' => [
            'id_inventory',
            'name',
            ['attribute'=>'id_user',
                'value'=>$inventory->userName
            ],
            ['attribute'=>'id_account',
                'value'=>$inventory->accountName
            ],
            'created_at:datetime',
        ],
    ]) ?>

    <?php echo Html::a("Ugrás a leltárhoz",['inventory-item/index','id'=> $inventory->id_inventory ], ['class' => 'btn btn-primary'])  ?>

    <h2>Termék keresése a leltárban</h2>
    <?php $form = \yii\widgets\ActiveForm::begin(); ?>

        <?php  echo Html::textInput("product_autocomplete","",['class' => 'form-control', 'id' => 'product_autocomplete','autocomplete' => 'off']) ?>
        <?php  echo Html::hiddenInput("product_id","",[  'id' => 'product_id','autocomplete' => 'off']) ?>

    <?php \yii\widgets\ActiveForm::end(); ?>

    <div id="inventory-product">
        <h2>Termék</h2>
        <table class="table table-striped table-bordered detail-view">
            <tbody><tr><th>Név</th><td id="inventory_product_name"> <?php echo Html::getAttributeValue($model, 'name') ?> </td></tr></tbody>
        </table>
        <?= $this->render('_form', [
            'model' => $model,
        ]) ?>
    </div>


</div>
