@model ShippingMethodRestrictionModel

<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">
                    @Loc["Admin.Configuration.Shipping.Restrictions.DescriptionGroup"]
                </div>
                <br />
                @if (Model.AvailableCountries.Count == 0)
                {
                    <text>No countries defined</text>
                }
                else if (Model.AvailableCustomerGroups.Count == 0)
                {
                    <text>No custome group available</text>
                }
                else
                {
                    <script>
                        $(document).ready(function () {
                            @foreach (var sm in Model.AvailableShippingMethods)
                            {
                            <text>
                            $('#selectgroupall-@(sm.Id)').click(function () {
                                $('.restrictgroup_@(sm.Id)').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>@Loc["Admin.Configuration.Shipping.Restrictions.Group"]</strong>
                                </th>
                                @foreach (var sm in Model.AvailableShippingMethods)
                                {
                                    <th scope="col">
                                        <strong>@sm.Name</strong>
                                        <label class='mt-checkbox mt-checkbox-outline control control-checkbox'><input type="checkbox" id="selectgroupall-@(sm.Id)" /> <div class="control__indicator"></div></label>
                                    </th>
                                }
                            </tr>
                            @{
                                bool altRow = true;
                            }
                            @foreach (var c in Model.AvailableCustomerGroups)
                            {
                                altRow = !altRow;
                                <tr class="@(altRow ? "altrowstyle" : "rowstyle")">
                                    <td>
                                        <span>@c.Name</span>
                                    </td>
                                    @foreach (var sm in Model.AvailableShippingMethods)
                                    {
                                        var restricted = Model.RestictedGroup.ContainsKey(c.Id) && Model.RestictedGroup[c.Id][sm.Id];
                                        <td style="text-align:center">
                                            <label class='mt-checkbox mt-checkbox-outline control control-checkbox'><input id="restrictgroup_@(sm.Id)" class="restrictgroup_@(sm.Id)" type="checkbox" value="@(c.Id)" name="restrictgroup_@(sm.Id)" @(restricted ? " checked=checked" : null) /> <div class="control__indicator"></div></label>
                                        </td>
                                    }
                                </tr>
                            }
                        </tbody>
                    </table>
                }
            </div>
        </div>
    </div>
</div>