ildar-shaymukhametov_grandnode-refactorings/Grand.Web/Areas/Admin/Views/Payment/MethodRestrictions.TabCountry.cshtml
@model PaymentMethodRestrictionModel
<div class="form-horizontal">
    <div class="form-body">
        <div class="form-group">
            <div class="col-md-12 col-sm-12">
                <div class="note note-info">
                    @T("Admin.Configuration.Payment.MethodRestrictions.DescriptionCountry")
                </div>
                @if (Model.AvailablePaymentMethods.Count == 0)
                {
                    <text>No payment methods installed</text>
                }
                else if (Model.AvailableCountries.Count == 0)
                {
                    <text>No countries available</text>
                }
                else
                {
                    <script>
                            $(document).ready(function () {
                                @foreach (var pm in Model.AvailablePaymentMethods)
                            {
                                var systemNameWithoutDot = pm.SystemName.Replace(".", "");
                                <text>
                                $('#selectall-@(systemNameWithoutDot)').click(function () {
                                    $('.restrict_@(systemNameWithoutDot)').prop('checked', $(this).is(':checked')).change();
                                });

                                </text>
                            }
                            });
                    </script>
                    <table class="table table-bordered table-striped table-hover table-hover">
                        <tbody>
                            <tr>
                                <th scope="col">
                                    <strong>@T("Admin.Configuration.Payment.MethodRestrictions.Country")</strong>
                                </th>
                                @foreach (var pm in Model.AvailablePaymentMethods)
                                {
                                    var systemNameWithoutDot = pm.SystemName.Replace(".", "");
                                    <th scope="col">
                                        <strong>@pm.FriendlyName</strong>
                                        <label class='mt-checkbox mt-checkbox-outline control control-checkbox'><input type="checkbox" id="selectall-@(systemNameWithoutDot)" /> <div class="control__indicator"></div></label>
                                    </th>
                                }
                            </tr>
                            @{
                                bool altRow = true;
                            }
                            @foreach (var c in Model.AvailableCountries)
                            {
                                altRow = !altRow;
                                <tr class="@(altRow ? "altrowstyle" : "rowstyle")">
                                    <td>
                                        <span>@c.Name</span>
                                    </td>
                                    @foreach (var pm in Model.AvailablePaymentMethods)
                                    {
                                        var resticted = Model.Resticted.ContainsKey(pm.SystemName) && Model.Resticted[pm.SystemName][c.Id];

                                        var systemNameWithoutDot = pm.SystemName.Replace(".", "");
                                        <td style="text-align:center">
                                            <label class='mt-checkbox mt-checkbox-outline control control-checkbox'><input class="restrict_@(systemNameWithoutDot)" type="checkbox" value="@(c.Id)" name="restrict_@(pm.SystemName)" @(resticted ? " checked=checked" : null) /> <div class="control__indicator"></div></label>
                                        </td>
                                    }
                                </tr>
                            }
                        </tbody>
                    </table>
                }
            </div>
        </div>
    </div>
</div>