<?php
    use common\components\artboximage\ArtboxImageHelper;
    use common\models\Basket;
    use common\models\Orders;
    use common\modules\product\models\ProductVariant;
    use yii\helpers\Html;
    use yii\helpers\Url;
    use yii\web\View;
    use yii\widgets\ActiveForm;
    
    /**
     * @var View             $this
     * @var ProductVariant[] $models
     * @var Basket           $basket
     * @var Orders           $order
     */
?>
<div class="form-wr">
    <div id="close-form"></div>
    <div class="form-title uppercase"><?php echo \Yii::t('app', 'Запрос на просчет')?></div>
    <?php
        $form = ActiveForm::begin([
            'id'          => 'basket_form',
            'fieldConfig' => [
                'template' => '{label}{input}',
            ],
        ]);
        echo $form->field($order, 'name', [
            'options' => [
                'class' => 'input-wr',
            ],
        ])
                  ->label('имя')
                  ->textInput();
        echo $form->field($order, 'phone', [
            'options' => [
                'class' => 'input-wr',
            ],
        ])
                  ->label('Телефон')
                  ->textInput();
        echo $form->field($order, 'email', [
            'options' => [
                'class' => 'input-wr',
            ],
        ])
                  ->label('E-mail')
                  ->textInput();
        if(!empty( $models )) {
            ?>
            <div class="form-product-wr<?php switch(count($models)) {
                case 0:
                    echo ' product_0';
                    break;
                case 1:
                    echo ' product_1';
                    break;
                case 2:
                    echo ' product_2';
                    break;
            } ?>">
                <div class="style scrollbar_">
                    <table>
                        <?php
                            foreach($models as $model) {
                                ?>
                                <tr>
                                    <td>
                                        <?php
                                            echo Html::a(ArtboxImageHelper::getImage($model->getImageUrl(), 'basket_item'), [
                                                'collection/view',
                                                'collection_id' => $model->product_id,
                                                'variant_id'    => $model->product_variant_id,
                                            ]);
                                        ?>
                                    </td>
                                    <td>
                                        <a href="<?php echo Url::to([
                                            'collection/view',
                                            'collection_id' => $model->product_id,
                                            'variant_id'    => $model->product_variant_id,
                                        ]); ?>">
                                            <span><?php echo $model->lang->name; ?></span>
                                            <br/><?php echo \Yii::t('app', 'Номер по каталогу'); ?>:
                                            <span><?php echo $model->sku; ?></span>
                                        </a>
                                    </td>
                                    <td class="remove_" data-id="<?= $model->product_variant_id; ?>"></td>
                                </tr>
                                <?php
                            }
                        ?>
                    </table>
                </div>
            </div>
            <?php
        }
        echo $form->field($order, 'comment', [ 'options' => [ 'class' => 'input-wr' ] ])
                  ->label(Yii::t('app', 'comment2'))
                  ->textarea();
    ?>
    <div class="input-wr">
        <a class="_more_" href="#"><?php echo \Yii::t('app', 'продолжить выбор'); ?></a>
        <div class="button-wr">
            <?php
                echo Html::submitButton(\Yii::t('app', 'Отправить'));
            ?>
        </div>
    </div>
    <?php
        $form::end();
    ?>
    <?php /*
    <form action="">
        <div class="input-wr">
            <label class="control-label" for="form-1">имя</label>
            <input type="text" id="form-1">
            <div class="help-block"></div>
        </div>
        <div class="input-wr required">
            <label class="control-label" for="form-2">Телефон</label>
            <input type="text" id="form-2">
            <div class="help-block"></div>
        </div>
        <div class="input-wr has-error">
            <label class="control-label" for="form-3">E-mail</label>
            <input type="text" id="form-3">
            <div class="help-block"></div>
        </div>
        <div class="form-product-wr">
            <div class="style scrollbar_">
                <table>
                    <tr>
                        <td><a href="#"><img src="images/img_garbage/img-form-1.jpg" alt=""></a>
                        </td>
                        <td><a href="#"><span>Сосна сахара</span><br/>Номер по каталогу:
                                <span>H1059.59772</span></a></td>
                        <td class="remove_"></td>
                    </tr>
                    <tr>
                        <td><a href="#"><img src="images/img_garbage/img-form-2.jpg" alt=""></a>
                        </td>
                        <td><a href="#"><span>Дуб гаррисон натур</span><br/>Номер по каталогу:
                                <span>H1059.59772</span></a></td>
                        <td class="remove_"></td>
                    </tr>
                    <tr>
                        <td><a href="#"><img src="images/img_garbage/img-form-3.jpg" alt=""></a>
                        </td>
                        <td><a href="#"><span>Каштанбелый жирона</span><br/>Номер по каталогу:
                                <span>H1059.59772</span></a></td>
                        <td class="remove_"></td>
                    </tr>
                    <tr>
                        <td><a href="#"><img src="images/img_garbage/img-form-1.jpg" alt=""></a>
                        </td>
                        <td><a href="#"><span>Сосна сахара</span><br/>Номер по каталогу:
                                <span>H1059.59772</span></a></td>
                        <td class="remove_"></td>
                    </tr>
                    <tr>
                        <td><a href="#"><img src="images/img_garbage/img-form-2.jpg" alt=""></a>
                        </td>
                        <td><a href="#"><span>Дуб гаррисон натур</span><br/>Номер по каталогу:
                                <span>H1059.59772</span></a></td>
                        <td class="remove_"></td>
                    </tr>
                    <tr>
                        <td><a href="#"><img src="images/img_garbage/img-form-3.jpg" alt=""></a>
                        </td>
                        <td><a href="#"><span>Каштанбелый жирона</span><br/>Номер по каталогу:
                                <span>H1059.59772</span></a></td>
                        <td class="remove_"></td>
                    </tr>
                </table>
            </div>
        </div>
        <div class="input-wr">
            <label class="control-label" for="form-4">Комментарий</label>
            <textarea id="form-4"></textarea>
            <div class="help-block"></div>
        </div>
        <div class="input-wr">
            <a class="_more_" href="#">продолжить выбор</a>
            <div class="button-wr">
                <button type="submit">Отправить</button>
            </div>
        </div>
    </form>
    */ ?>
</div>