<?php
use common\models\Orders;
use yii\helpers\Url;
use yii\widgets\ActiveForm;

?>
<table border="0" cellspacing="1" cellpadding="2" align="center" style="cursor:default; width: 100%;">
    <tbody>
    <tr>
        <td>

            <table border="0" cellspacing="0" cellpadding="5" id="tbl_cart" class="tbl_cart">

                <tbody><tr class="buttonsPanel topButtonsBox">
                    <td class="returnBtnCell" style="width: 220px;">
                        <div style="float: left;">

                            <button name="submit_button" type="submit" class="btn btn-large" id="submit_button" data-toggle="modal" data-target="#myForm" onclick="return false;">Оформить заказ</button>
                        </div>
                    </td>
                    <td class="confirmBtnCell">

                        <div style="float: left;">
                            <button name="" type="button" class="btn btn-large return" id="" onclick="return location.href='javascript:history.back();';">
                                Вернуться к покупкам
                            </button>                                 </div>
                    </td>

                </tr>

                </tbody></table>





            <?php


            foreach($models as $model) {
                $item = $basket->getItem($model->product_variant_id);
                ?>
                <div class="order_item item_container"  data-id="<?php echo $model->product_variant_id; ?>" >
                    <table border="0" cellspacing="0" cellpadding="5" id="tbl_cart" class="tbl_cart">

                        <tbody><tr valign="top" id="ord_row_539" class="itemRow">

                            <td rowspan="2" class="order_img">
                                <a target="_blank" href="<?= Url::to([
                                    'catalog/product',
                                    'product' => $model->product->alias
                                ]) ?>">
                                    <div class="imgBorder">
                                        <?php
                                        echo \common\components\artboximage\ArtboxImageHelper::getImage($model->getImageUrl(), 'list');
                                        ?>
                                    </div>
                                </a>
                            </td>
                            <td class="iTitle" style="width: 450px;">
                                <a target="_blank" href="<?= Url::to([
                                    'catalog/product',
                                    'product' => $model->product->alias
                                ]) ?>">
                                    <?= $model->getFullname() ?>
                                </a>

                            </td>

                            <td style=" vertical-align: top;">

                                <table class="order_details">
                                    <tbody>
                                    <tr>
                                        <td colspan="2">
                                            <a class="del_order cart_remove" lang="539" title="Удалить товар">удалить товар <span>x</span></a>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Цена&nbsp;
                                        </td>
                                        <td>
                                            <div class="iPriceOne">
                                                <label class="price"><span><?= $item['price']?></span> грн.</label>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr >
                                        <td>
                                            Количество&nbsp;
                                        </td>
                                        <td>
                                            <div class="count_choise">
                                                <span class="minus"></span>
                                                <input type="text" value="<?=  $item['count']?>" class="small qtyInput prod_count" >
                                                <span class="plus"></span>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Cумма&nbsp;
                                        </td>
                                        <td>
                                            <div class="iPrice">
                                                <label id="cost" class="total_prod cost"><span><?= $item['count'] * $item['price']; ?></span> грн.</label> <!-- 00 коп.-->
                                            </div>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>

                            </td>


                        </tr>

                        </tbody></table>

                </div>

                <?php
            }
            ?>



            <table border="0" cellspacing="0" cellpadding="5" id="tbl_cart" class="tbl_cart">
                <tbody>

                <tr valign="bottom" class="totalPrice" style="text-align: right;">
                    <td colspan="2" align="right"> </td>
                    <td>
                        <span class="total_summ_name">Сумма заказа:</span>
                        <label id="total" class="cart_total"><span><?php echo $basket->getSum(); ?></span> грн.</label>
                    </td>
                </tr>



                <tr>
                    <td colspan="6">


                    </td>
                </tr>



                </tbody>
            </table>

        </td>
    </tr>
    </tbody>
</table>

<div class="modal fade" id="myForm" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog buy-product" role="document">
        <div class="modal-content">

            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>

            </div>

            <div class="modal-body">

                <?php $form = ActiveForm::begin(['action'=>['/order/save'],'id'=>'orderForm']); ?>

                    <?= $form->field(new Orders(), 'name')->textInput() ?>

                    <?= $form->field(new Orders(), 'phone')->textInput() ?>

                    <?= $form->field(new Orders(), 'email') ?>

                    <?= $form->field(new Orders(), 'comment')->textarea() ?>

                    <button type="submit" class="pull-right btn btn-large btn-default">Оформить</button>
                <?php ActiveForm::end(); ?>
                <div class="clearfix"></div>
                <p><span style="color: red;">*</span> - обязательные поля для ввода</p>
            </div>
        </div>
    </div>
</div>

