<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">مجموعات المستخدمين</li>
        </ol>
        <div class="panel panel-default">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <h3 class="panel-title">إضافة مجموعة</h3>
            </div>
            <div class="panel-body"> {literal}
                <form class="nameToBeChecked form-horizontal" action="usergroupController.php?do=add" method="post" id="spform">
                    <!--validate the form before checking name-->
                    {/literal}
                    <!-- Nav tabs -->
                    <ul class="nav nav-tabs">
                        <li class="active"><a href="#info" data-toggle="tab">بيانات المجموعه</a></li>
                        <li><a href="#props" data-toggle="tab">خصائص الصفحات</a></li>
                        <li><a href="#genpro" data-toggle="tab">خصائص عامه</a></li>
                    </ul>

                    <!-- Tab panes -->
                    <div class="tab-content">
                        <div class="tab-pane active" id="info"><!-- start the 1st tab -->
                            <div class="form-group">
                                <label class="col-lg-2 control-label">اسم المجموعة</label>
                                <div class="col-lg-4">
                                    <span id="namesx">
                                        <input type="text" required="required" name="usergroupname" id="usergroupname" class="form-control" placeholder="اسم المجموعة" />
                                        <span class="textfieldRequiredMsg">*</span></span>

                                    <div id="nameError" class="alert alert-block alert-danger fade in" style="display:none">
                                        <button type="button" class="close pull-left" data-dismiss="alert" aria-hidden="true">&times;</button>
                                        <h4>رسالة خطأ</h4>
                                        <p>هذا الإسم مستخدم من قبل</p>
                                        <div class="clearfix"></div>
                                    </div>
                                </div>
                            </div>

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

                            <div class="form-group">
                                <label class="col-lg-2 control-label">وصف المجموعة</label>
                                <div class="col-lg-4">
                                    <textarea name="usergroupdescription" class="form-control" cols="45" rows="5" ></textarea>
                                </div>
                            </div>

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



                            <div class="form-group">
                                <label class="col-lg-2 control-label">صفحة الدخول</label>
                                <div class="col-lg-4">
                                    <span id="spryselect1">
                                        <select name="startpage" required  data-placeholder="اختر صفحة الدخول"  class="select2 wdt100">
                                            <option value=""></option>
                                            <option value="index.php"> الادارة</option>
                                            <option value="billreceiptController.php?do=show"> ادارة الاستلام</option>
                                            <option value="checkReportController.php?do=all"> ادارة الفحص</option>
                                            <option value="externalMaintenanceGoReport.php?do=all"> ادارة الصيانة الخارجية</option>
                                            <option value="stagepropertyController.php?do=show"> خواص المراحل</option>
                                            <option value="receiptController.php?do=show"> ايصال استلام</option>
                                            <option value="deleveryReportController.php?do=all"> ادارة التسليم</option>
                                            <option value="maintennanceArchiveController.php?do=all"> الارشيف</option>
                                        </select>
                                        <span class="selectRequiredMsg">*</span></span>
                                </div>
                            </div>

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

                            <div class="form-group">
                                <label class="col-lg-2 control-label">النوع</label>
                                <div class="col-lg-4">
                                    <span id="spryselect2">
                                        <select name="level" required id="level" data-placeholder="اختر النوع"   class="select2 wdt100">
                                            <option value=""></option>
                                            <option value="1">مدير</option>
                                            <option value="2">محاسب</option>
                                            <option value="3">بائع</option>
                                        </select>
                                        <span class="selectRequiredMsg">*</span></span>
                                </div>
                            </div>

                        </div><!-- end the 1st tab -->
                        <div class="tab-pane" 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}">
                                    <label  class="col-lg-3 control-label">{$properity->propertyname}</label>
                                    <div class="radio-inline">
                                        <label>
                                            <input value="0" class="radioR" {if {$properity->
                                            propertydefault} eq 0} checked {/if} name="propertydefault{$i}" type="radio"   />

                                            نعم </label>
                                    </div>
                                    <div class="radio-inline">
                                        <label>
                                            <input  class="noradioR" value="1"  {if {$properity->
                                            propertydefault} eq 1} checked {/if} name="propertydefault{$i}" type="radio" />
                                            لا </label>
                                    </div>
                                    <input type="hidden"  name="propertyid{$i}" value="{$properity->propertyid}"/>
                                </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 class="tab-pane" id="genpro"><!-- start the 3rd tab -->

                            <div class="form-group propbd">
                                <label class="col-lg-3 control-label">خاصيه البحث بالتاريخ فى تقرير يوميه الخزنه</label>
                                <div class="col-lg-4">
                                    <div class="radio-inline">
                                        <label>
                                            <input value="1"  class="radioR" name="savedailydate" type="radio" />

                                            نعم </label>
                                    </div>
                                    <div class="radio-inline">
                                        <label>
                                            <input value="0"  class="noradioR" checked="checked" name="savedailydate"  type="radio" />
                                            لا </label>
                                    </div>

                                </div>
                            </div>

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

                            <div class="form-group propbd">
                                <label class="col-lg-3 control-label">اظهار القوائم</label>
                                <div class="col-lg-4">
                                    <div class="radio-inline">
                                        <label>
                                            <input value="1"  class="radioR" name="hidemenu" type="radio" />

                                            نعم </label>
                                    </div>
                                    <div class="radio-inline">
                                        <label>
                                            <input value="0"  class="noradioR" checked="checked" name="hidemenu"  type="radio" />
                                            لا </label>
                                    </div>

                                </div>
                            </div>

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


                            <div class="form-group propbd">
                                <label class="col-lg-3 control-label">اظهار تصنيفات المنتجات</label>
                                <div class="col-lg-4">
                                    <div class="radio-inline">
                                        <label>
                                            <input value="1"  class="radioR" name="hidecat" type="radio" />

                                            نعم </label>
                                    </div>
                                    <div class="radio-inline">
                                        <label>
                                            <input value="0"  class="noradioR" checked="checked" name="hidecat"  type="radio" />
                                            لا </label>
                                    </div>

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


                            <div class="form-group propbd">
                                <label class="col-lg-3 control-label">ادخال مديونيه عميل بالسالب</label>
                                <div class="col-lg-4">
                                    <div class="radio-inline">
                                        <label>
                                            <input value="1"  class="radioR" name="clientnegative" checked="checked"   type="radio" />

                                            نعم </label>
                                    </div>
                                    <div class="radio-inline">
                                        <label>
                                            <input value="0"  class="noradioR" name="clientnegative"    type="radio" />
                                            لا </label>
                                    </div>

                                </div>
                            </div>


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


                            <div class="form-group propbd">
                                <label class="col-lg-3 control-label">ادخال مديونيه مورد بالسالب</label>
                                <div class="col-lg-4">
                                    <div class="radio-inline">
                                        <label>
                                            <input value="1"  class="radioR" name="suplliernegative"  checked="checked"   type="radio" />

                                            نعم </label>
                                    </div>
                                    <div class="radio-inline">
                                        <label>
                                            <input value="0"  class="noradioR" name="suplliernegative"    type="radio" />
                                            لا </label>
                                    </div>

                                </div>
                            </div>


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



                            <div class="form-group propbd">
                                <label class="col-lg-3 control-label">ادخال ارصده للمخازن بالسالب</label>
                                <div class="col-lg-4">
                                    <div class="radio-inline">
                                        <label>
                                            <input value="1"  class="radioR" name="storenegative"  checked="checked"   type="radio" />

                                            نعم </label>
                                    </div>
                                    <div class="radio-inline">
                                        <label>
                                            <input value="0"  class="noradioR" name="storenegative"   type="radio" />
                                            لا </label>
                                    </div>

                                </div>
                            </div>



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



                            <div class="form-group propbd">
                                <label class="col-lg-3 control-label">تعديل الاسعار</label>
                                <div class="col-lg-4">
                                    <div class="radio-inline">
                                        <label>
                                            <input value="1"  class="radioR" name="priceupdate"  checked="checked"   type="radio" />

                                            نعم </label>
                                    </div>
                                    <div class="radio-inline">
                                        <label>
                                            <input value="0"  class="noradioR" name="priceupdate"   type="radio" />
                                            لا </label>
                                    </div>

                                </div>
                            </div>


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

                            <div class="form-group propbd">
                                <label class="col-lg-3 control-label">الخصم المباشر</label>
                                <div class="col-lg-4">
                                    <div class="radio-inline">

                                        <input  value="0" type="text" class="form-control" name="directDiscount" />



                                    </div>


                                </div>

                            </div>
                            <!--==============================-->
                            <div class="form-group propbd">

                                <label class="col-lg-3 control-label">الخصم نسبه</label>
                                <div class="col-lg-4">
                                    <div class="radio-inline">

                                        <input  value="0" type="text" class="form-control" name="percentageDiscount" />



                                    </div>


                                </div>
                            </div>
                        </div><!-- end the 3rd tab -->
                    </div><!-- end of tabs -->












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


                    <!--==============================-->
                    <div class="form-group">
                        <div class="col-lg-offset-8 col-lg-4">
                            <button type="button" class="btn btn-primary pull-left" id="spbutton">حفظ</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{literal}
<script type="text/javascript">
    var namesx = new Spry.Widget.ValidationTextField("namesx");
    var spryselect1 = new Spry.Widget.ValidationSelect("spryselect1", {invalidValue: "-1"});
    var spryselect2 = new Spry.Widget.ValidationSelect("spryselect2", {invalidValue: "-1"});
</script>
{/literal}

{literal}
<script type="text/javascript">
    $('#spbutton').live('click', function (e) {
        //ckeck name
        var tableName = 'usergroup';
        var inputName = 'usergroupname';
        var name = $("#" + inputName).val();
        $.ajax({
            url: 'checkRedundantNames.php?name=' + name + '&tablename=' + tableName,
            success: function (data) {
                //alert(data);
                if (data == '0')
                {
                    $("#nameError").css("display", "none");
                    var myForm = document.getElementById("spform");
                    var SS = Spry.Widget.Form.validate(myForm);
                    if (SS == true) {
                        if (!$('#spbutton').hasClass("processing"))
                        {
                            $('#spbutton').addClass("processing");
                            myForm.submit();
                            //$('#spbutton').unbind('click');
                        }
                    }

                }
                else if (data == '1')
                {
                    $("#" + inputName).val("");
                    $("#" + inputName).focus();
                    $("#nameError").css("display", "block");
                    return false;
                }
            }});

    });
</script>
{/literal}