<script>
    $(document).ready(function (e) {


        $("#challredio").change(function () {
            if ($(this).is(':checked'))
            {

                $(".radioR").prop("checked", true);
            } else
            {
                $(".radioR").prop("checked", false);
                $(".noradioR").prop("checked", true);
                //$(".xxx").attr("checked", "checked");
            }
        }


        )
    });</script>
<div class="row">
    <div class="container">

        <ol class="breadcrumb">
            <li><a href="#">خصائص عامة</a></li>
            <li><a href="#">مجموعات المستخدمين</a></li>
            <li class="active">admin</li>
        </ol>
        <div class="panel panel-default panel-m">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <h3 class="panel-title">admin </h3>
            </div>
            <div class="panel-body">
                {literal}
                <form class="nameToBeChecked form-horizontal" action="usergroupControllerAdmin.php?do=update" method="post" id="form1"><!--validate the form before checking name-->
                    {/literal}

                    <!---------(Spry.Widget.Form.validate(this))-------->
                    <!-- Nav tabs -->
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#props" data-toggle="tab">خصائص الصفحات</a></li>
                    </ul>

                    <!-- Tab panes -->
                    <div class="tab-content">
                        <div class="tab-pane active" id="props"><!-- start the 2nd tab -->
                            <div class="well well-sm modfywall">
                                <div class="form-group">
                                    <label class="col-lg-3 control-label"> اختيار كل الخصائص بنعم</label>
                                    <div class="col-lg-4">
                                        <div class="radio-inline">

                                            <input name="" id="challredio" type="checkbox" value="" /> نعم

                                        </div>

                                    </div>
                                </div>
                            </div>
                            <!--==============================-->


                            <!--==============================-->

                            {assign var=i value=1}
                            {foreach $properityData as $properity}
                            {if {$properity->propertyparent} eq 0}<div class="well well-sm modfywall">{/if}
                                <div class="form-group {if {$properity->propertyparent} neq 0}propbd{/if}">
                                    <div class="col-lg-4" style="display: inline">
                                        <label  class="col-lg-8 control-label">{$properity->propertyname}</label>
                                        <div class="radio-inline">
                                            <label>
                                                <input value="0" class="radioR" {if {$properity->isallowed} eq 0} checked {/if} name="propertydefault{$i}" type="radio" />
                                                نعم </label>
                                        </div>
                                        <div class="radio-inline">
                                            <label>
                                                <input value="1" class="noradioR" {if {$properity->isallowed} eq 1} checked {/if} name="propertydefault{$i}" type="radio" />
                                                لا </label>
                                        </div>
                                        <input type="hidden" name="propertyid{$i}" value="{$properity->propertyid}"/>
                                        <input type="hidden" name="id{$i}" value="{$properity->id}"/>
                                    </div>
                                    <!--                                    <div class="col-lg-3" style="display: inline">
                                                                            <label  class="col-lg-3 control-label">الترتيب</label>
                                                                            <div class="col-lg-6">
                                                                                <input type="text" name="theorder{$i}" value="{$properity->theorder}" class="form-control positiveNo"/>
                                                                            </div>
                                                                        </div>-->
                                </div>
                                {if {$properity->propertyparent} eq 0}</div>{/if}
                            {capture assign=i}{$i+1}{/capture}
                            {/foreach}
                            <input type="hidden" name="itr" value="{$properityNum}"/>



                            <!--==============================-->

                        </div><!-- end the 2nd tab -->

                    </div><!-- end of tabs -->
                    <!--==============================-->

                    <!--==============================-->
                    <div class="form-group">
                        <div class="col-lg-offset-8 col-lg-4">
                            <button type="submit" class="btn btn-primary pull-left" id="spbutton">حفظ</button>
                        </div>
                    </div>






                </form>

            </div>

        </div>

    </div>
</div>
{literal}
<script>
    $('input[type="text"], input[type="radio"], input[type="checkbox"], input[type="password"]').change(function () {
        var thisis = $(this);
        var type = thisis.attr('type');
        switch (type) {
            case "checkbox":
                if (thisis.attr('id') == "challredio") {//mark all properities as changed
                    $('[name^="propertydefault"]').addClass('edited');
                    $('[name^="propertyid"]').addClass('edited');
                    $('[name^="id"]').addClass('edited');
                    $('[name^="theorder"]').addClass('edited');
                    $('[name^="relusergrouppropertiesid"]').addClass('edited');
                } else {
                    //not only the element.there is special case has name=reviewBillsAllowedTables[]  if other checkboxes of that name was not changed but marked value will be wrong
                    $('input[name="' + thisis.attr('name') + '"]').addClass('edited');
                }
                break;
            case "radio":
                if (thisis.attr('name').indexOf("propertydefault") == 0) {
                    var i = $(this).attr('name').substr(15);
                    $('[name="propertydefault' + i + '"]').addClass('edited');
                    $('[name="propertyid' + i + '"]').addClass('edited');
                    $('[name="id' + i + '"]').addClass('edited');
                    $('[name="theorder' + i + '"]').addClass('edited');
                    $('[name="relusergrouppropertiesid' + i + '"]').addClass('edited');
                } else {
                    $(this).addClass('edited');
                }
                break;
            case "text":
                if (thisis.attr('name').indexOf("theorder") == 0) {
                    var i = $(this).attr('name').substr(8);
                    $('[name="propertydefault' + i + '"]').addClass('edited');
                    $('[name="propertyid' + i + '"]').addClass('edited');
                    $('[name="id' + i + '"]').addClass('edited');
                    $('[name="theorder' + i + '"]').addClass('edited');
                    $('[name="relusergrouppropertiesid' + i + '"]').addClass('edited');
                } else {
                    $(this).addClass('edited');
                }
                break;
            default:
                $(this).addClass('edited');
                break;
        }
        $(this).addClass('edited');
    });
    $('#form1').on('submit', function () {
        /* ---------------------------------------------------------------------- */
        //## just before submitting stop sending elements not changed by removing attribute name
        //this step is for input[type="hidden"] of properities not changed to remove it
        $('[name^="propertyid"]').not('.edited').remove();
        $('[name^="relusergrouppropertiesid"]').not('.edited').remove();
        //this step is to remove generally not changed of the selector
        $('select, textarea, input[type="text"], input[type="radio"], input[type="checkbox"], input[type="password"]').not('.edited').removeAttr('name');
        //nullNotAllowedOnChange "checkbox" elements sent with zero instead of null for notchecked case
        $('input.edited[type="checkbox"]:not(:checked)').each(function () {
            $(this).removeClass('edited');
            $(this).after('<input type="hidden" name="' + $(this).attr('name') + '" value=0>');
            $(this).removeAttr('name');
        });
        /* ---------------------------------------------------------------------- */
    });
</script>
{/literal}