<?php 
\yii\widgets\Pjax::begin();
?>
<div class="box">
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $filterModel, 'layout' => "<div class='box-body table-responsive no-padding'>{items}</div><div class='box-footer'><div class='row'><div class='col-sm-6'>{summary}</div><div class='col-sm-6 text-right'>{pager}</div></div></div>", 'tableOptions' => ['class' => 'table table-hover'], 'columns' => [['attribute' => 'id', 'options' => ['width' => '50'], 'headerOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'], 'value' => function ($data) {
    return $data->id;
}], ['class' => CheckboxColumn::className(), 'options' => ['width' => '50'], 'headerOptions' => ['class' => 'checkbox-column text-center'], 'contentOptions' => ['class' => 'checkbox-column text-center']], ['attribute' => 'title', 'filterInputOptions' => ['class' => 'form-control input-sm'], 'format' => 'raw', 'value' => function ($data) {
    return Html::a($data->title, Url::toRoute(['/catalog/update-product', 'id' => $data->id]), ['data-pjax' => 0]);
}], ['header' => 'Категории', 'format' => 'raw', 'value' => function ($data) {
    $tmp = '';
    foreach ($data->categories as $cItem) {
        $tmp .= '<div>' . Html::a($cItem->title, Url::toRoute(['/catalog/products', 'Product[parents]' => $cItem->id])) . '</div>';
    }
    return $tmp;
}, 'filter' => Html::activeDropDownList($filterModel, 'parents', Category::getAllToList(), ['class' => 'form-control input-sm filtered', 'prompt' => '-'])], ['attribute' => 'price', 'format' => 'raw', 'value' => function ($data) {
    return Yii::$app->formatter->asCurrency($data->price, 'RUR');
}], ['attribute' => 'quantity', 'headerOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'], 'format' => 'raw', 'value' => function ($data) {
    return Yii::$app->formatter->asInteger($data->quantity);
}], ['attribute' => 'is_active', 'headerOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center'], 'format' => 'html', 'value' => function ($data) {
    return $data->is_active ? '<span class="label label-success">Активный</span>' : '<span class="label label-danger">Не активный</span>';
}, 'filter' => Html::activeDropDownList($filterModel, 'is_active', [true => 'Активный', false => 'Не активный'], ['class' => 'form-control input-sm filtered', 'prompt' => '-'])], ['attribute' => 'created_at', 'format' => 'raw', 'options' => ['width' => '200'], 'value' => function ($data) {
    return Yii::$app->formatter->asDateTime($data->created_at, Yii::$app->formatter->dateFormat) . ' <small style="color:gray;">' . Yii::$app->formatter->asDateTime($data->created_at, Yii::$app->formatter->timeFormat) . '</small>';
}, 'filter' => DateTimePicker::widget(['name' => 'Product[created_at]', 'value' => $filterModel->created_at != '' ? Yii::$app->formatter->asDateTime($filterModel->created_at, Yii::$app->formatter->dateFormat) : null, 'options' => ['placeholder' => 'Введите дату ...', 'class' => 'form-control input-sm filtered'], 'size' => 'sm', 'pickerButton' => null, 'convertFormat' => true, 'type' => DateTimePicker::TYPE_COMPONENT_APPEND, 'pluginOptions' => ['format' => 'dd.MM.yyyy', 'autoclose' => true, 'todayBtn' => true, 'startView' => 2, 'minView' => 3]])], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update-product} {delete-product}', 'options' => ['width' => '100'], 'buttons' => ['update-product' => function ($url, $model) {
    return Html::a('<span class="icon fa fa-edit"></span>', $url, ['class' => 'btn btn-xs btn-primary', 'data-pjax' => 0]);
}, 'delete-product' => function ($url, $model) {
    return Html::a('<span class="icon fa fa-trash"></span>', $url, ['class' => 'btn btn-xs btn-danger isDel', 'data-pjax' => 0]);
}]]]]);
?>
</div>
<?php 
$form = ActiveForm::begin(['id' => 'form-category-update', 'options' => ['enctype' => 'multipart/form-data']]);
?>
<div class="box">
    <div class="box-body">
        <div class="row">
            <div class="col-xs-6">
                <?php 
echo $form->field($model, 'title');
?>
            </div>

            <div class="col-xs-6">
                <?php 
echo $form->field($model, 'parent')->widget(Chosen::className(), ['placeholder' => 'Выберите родителя', 'items' => Category::getAllToList(), 'multiple' => false]);
?>
            </div>
        </div>

        <?php 
echo $form->field($model, 'description')->widget(imperaviWidget::className());
?>
    </div>
    <div class="box-footer text-right">
        <?php 
echo Html::submitButton('Сохранить', ['class' => 'btn btn-primary', 'name' => 'save-button']);
?>
    </div>
</div>
<?php