@model Nop.Plugin.Pickup.PickupInStore.Models.StorePickupPointModel

<div asp-validation-summary="All"></div>
<input asp-for="Id" type="hidden" />

@if (ViewBag.RefreshPage == true)
{
    <script>
        try {window.opener.document.forms['@(Context.Request.Query["formId"])'].@(Context.Request.Query["btnId"]).click();}
        catch (e){}
        window.close();
    </script>
}

<div class="cards-group">
    <div class="card card-default card-popup">

        <script>
            $(function() {
                $("#@Html.IdFor(model => model.Address.CountryId)").change(function(){
                    var selectedItem = $(this).val();
                    var ddlStates = $("#@Html.IdFor(model => model.Address.StateProvinceId)");
                    $.ajax({
                        cache: false,
                        type: "GET",
                        url: "@(Url.Action("GetStatesByCountryId", "Country"))",
                        data: {
                            "countryId": selectedItem
                        },
                        success: function (data, textStatus, jqXHR) {
                            ddlStates.html('');
                            $.each(data, function(id, option) {
                                ddlStates.append($('<option></option>').val(option.id).html(option.name));
                            });
                        },
                        error: function (jqXHR, textStatus, errorThrown) {
                            $("#getStatesByCountryIdAlert").trigger("click");
                        }
                    });
                });
            });
        </script>

        <div class="card-body">
            <div class="form-group row">
                <div class="col-sm-3">
                    <nop-label asp-for="Name" />
                </div>
                <div class="col-sm-9">
                    <nop-editor asp-for="Name" />
                    <span asp-validation-for="Name"></span>
                </div>
            </div>
            <div class="form-group row">
                <div class="col-sm-3">
                    <nop-label asp-for="Description" />
                </div>
                <div class="col-sm-9">
                    <nop-textarea asp-for="Description" />
                    <span asp-validation-for="Description"></span>
                </div>
            </div>
            <div class="form-group row">
                <div class="col-sm-3">
                    <nop-label asp-for="Address.CountryId" />
                </div>
                <div class="col-sm-9">
                    <nop-select asp-for="Address.CountryId" asp-items="Model.Address.AvailableCountries" />
                    <span asp-validation-for="Address.CountryId"></span>
                </div>
            </div>
            <div class="form-group row">
                <div class="col-sm-3">
                    <nop-label asp-for="Address.StateProvinceId" />
                </div>
                <div class="col-sm-9">
                    <nop-select asp-for="Address.StateProvinceId" asp-items="Model.Address.AvailableStates" />
                    <span asp-validation-for="Address.StateProvinceId"></span>
                </div>
            </div>
            <div class="form-group row">
                <div class="col-sm-3">
                    <nop-label asp-for="Address.County" />
                </div>
                <div class="col-sm-9">
                    <nop-editor asp-for="Address.County" />
                    <span asp-validation-for="Address.County"></span>
                </div>
            </div>
            <div class="form-group row">
                <div class="col-sm-3">
                    <nop-label asp-for="Address.City" />
                </div>
                <div class="col-sm-9">
                    <nop-editor asp-for="Address.City" />
                    <span asp-validation-for="Address.City"></span>
                </div>
            </div>
            <div class="form-group row">
                <div class="col-sm-3">
                    <nop-label asp-for="Address.Address1" />
                </div>
                <div class="col-sm-9">
                    <nop-editor asp-for="Address.Address1" />
                    <span asp-validation-for="Address.Address1"></span>
                </div>
            </div>
            <div class="form-group row">
                <div class="col-sm-3">
                    <nop-label asp-for="Address.ZipPostalCode" />
                </div>
                <div class="col-sm-9">
                    <nop-editor asp-for="Address.ZipPostalCode" />
                    <span asp-validation-for="Address.ZipPostalCode"></span>
                </div>
            </div>
            <div class="form-group row">
                <div class="col-sm-3">
                    <nop-label asp-for="OpeningHours" />
                </div>
                <div class="col-sm-9">
                    <nop-editor asp-for="OpeningHours" />
                    <span asp-validation-for="OpeningHours"></span>
                </div>
            </div>
            <div class="form-group row">
                <div class="col-sm-3">
                    <nop-label asp-for="PickupFee" />
                </div>
                <div class="col-sm-9">
                    <nop-editor asp-for="PickupFee" />
                    <span asp-validation-for="PickupFee"></span>
                </div>
            </div>
            <div class="form-group row">
                <div class="col-sm-3">
                    <nop-label asp-for="DisplayOrder" />
                </div>
                <div class="col-sm-9">
                    <nop-editor asp-for="DisplayOrder" />
                    <span asp-validation-for="DisplayOrder"></span>
                </div>
            </div>
            <div class="form-group row" @(Model.AvailableStores.SelectionIsNotPossible() ? Html.Raw("style=\"display:none\"") : null)>
                <div class="col-sm-3">
                    <nop-label asp-for="StoreId" />
                </div>
                <div class="col-sm-9">
                    <nop-select asp-for="StoreId" asp-items="Model.AvailableStores" />
                    <span asp-validation-for="StoreId"></span>
                </div>
            </div>
            <div class="form-group row">
                <div class="col-sm-3">
                    <nop-label asp-for="Latitude" />
                </div>
                <div class="col-sm-9">
                    <nop-editor asp-for="Latitude" />
                    <span asp-validation-for="Latitude"></span>
                </div>
            </div>
            <div class="form-group row">
                <div class="col-sm-3">
                    <nop-label asp-for="Longitude" />
                </div>
                <div class="col-sm-9">
                    <nop-editor asp-for="Longitude" />
                    <span asp-validation-for="Longitude"></span>
                </div>
            </div>
            <div class="form-group row">
                <div class="col-sm-3">
                    <nop-label asp-for="TransitDays" />
                </div>
                <div class="col-sm-9">
                    <nop-editor asp-for="TransitDays" />
                    <span asp-validation-for="TransitDays"></span>
                </div>
            </div>
        </div>
    </div>
</div>
<nop-alert asp-alert-id="getStatesByCountryIdAlert" asp-alert-message="@T("Admin.Common.Alert.States.Failed")" />