@model CheckoutConfirmModel
@{
    Layout = "_ColumnsOne";

    //title
    NopHtml.AddTitleParts(T("PageTitle.Checkout").Text);
    //page class
    NopHtml.AppendPageCssClassParts("html-checkout-page");
    NopHtml.AppendPageCssClassParts("html-order-confirm-page");
}
@await Component.InvokeAsync(typeof(CheckoutProgressViewComponent), new { step = CheckoutProgressStep.Confirm })
<div class="page checkout-page">
    <div class="page-title panel-heading">
        <h1>@T("Checkout.ConfirmYourOrder")</h1>
    </div>
    <div class="page-body checkout-data">
        @await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.CheckoutConfirmTop, additionalData = Model })
        <div class="section confirm-order">
            <form asp-route="CheckoutConfirm" method="post" id="confirm-order-form">
                <script asp-location="Footer">
                    $(function() {
                        $('.confirm-order-next-step-button').on('click', function () {
                            //terms of service
                            var termOfServiceOk = true;
                            if ($('#termsofservice').length > 0) {
                                //terms of service element exists
                                if (!$('#termsofservice').is(':checked')) {
                                    $("#terms-of-service-warning-box").dialog();
                                    termOfServiceOk = false;
                                } else {
                                    termOfServiceOk = true;
                                }
                            }
                            if (termOfServiceOk) {
                                //$('#confirm-order-form').submit();
                                //$('.confirm-order-next-step-button').prop('disabled', true);
                                return true;
                            } else {
                                return false;
                            }
                        });
                    });
                </script>
                @if (!string.IsNullOrEmpty(Model.MinOrderTotalWarning))
                {
                    <span class="min-order-warning">@Model.MinOrderTotalWarning</span>
                }
                else
                {
                    if (Model.TermsOfServiceOnOrderConfirmPage)
                    {
                        <div id="terms-of-service-warning-box" title="@T("Checkout.TermsOfService")" style="display:none;">
                            <p>@T("Checkout.TermsOfService.PleaseAccept")</p>
                        </div>
                        <div class="terms-of-service">
                            <input id="termsofservice" type="checkbox" name="termsofservice" />
                            <label for="termsofservice">
                                @T("Checkout.TermsOfService.IAccept")
                                @if (Model.TermsOfServicePopup)
                                {
                                    <a class="read" id="read-terms">@T("Checkout.TermsOfService.Read")</a>
                                    <script asp-location="Footer">
                                    $(function() {
                                        $('#read-terms').on('click', function(e) {
                                            e.preventDefault();
                                            displayPopupContentFromUrl('@Url.RouteUrl("TopicPopup", new {SystemName = "conditionsofuse"})', '@T("Checkout.TermsOfService")');
                                        });
                                    });
                                    </script>
                                }
                                else
                                {
                                    <a class="read" id="read-terms" href="@Url.RouteTopicUrl("conditionsofuse")">@T("Checkout.TermsOfService.Read")</a>
                                }
                            </label>
                        </div>
                    }
                    <div class="primary-buttons">
                        <div class="form-group row">
                            <div class="col-md-12">
                                <button type="submit" name="nextstep" class="btn btn-primary confirm-order-next-step-button">@T("Checkout.ConfirmButton")</button>
                            </div>
                        </div>
                    </div>
                    <script asp-location="Footer">
                        $('#confirm-order-form').on('submit',
                            function () {
                                var button = $(this).find('button[type="submit"][name="nextstep"]');
                                setTimeout(function () {
                                    button.prop('disabled', true);
                                },
                                0);
                            });
                    </script>
                    if (Model.DisplayCaptcha)
                    {
                        <nop-captcha />
                    }
                }
                @if (Model.Warnings.Count > 0)
                {
                    <div class="message-error">
                        <ul>
                            @foreach (var warning in Model.Warnings)
                            {
                                <li>@warning</li>
                            }
                        </ul>
                    </div>
                }
            </form>
        </div>
        @await Component.InvokeAsync(typeof(WidgetViewComponent), new { widgetZone = PublicWidgetZones.CheckoutConfirmBottom, additionalData = Model })
        <div class="order-summary-body">
            @await Component.InvokeAsync(typeof(OrderSummaryViewComponent), new { prepareAndDisplayOrderReviewData = true })
        </div>
    </div>
</div>
