
<div class="row">
    <div class="container">

        <ol class="breadcrumb">
            <li><a href="#"> المطاعم</a></li>
            <li><a href="restaurantplaystation.php?do=show">البلاي ستيشن</a></li>
            <li class="active">اضافة  </li>
        </ol>


        <div class="panel panel-default panel-m">
            <div class="panel-heading">
                <h3 class="panel-title">اضافة البلاي ستيشن </h3>
            </div>
            <div class="panel-body">

                <form class="form-horizontal" role="form" action="restaurantplaystation.php?do=add" method="post" id="spform">


                    <div class="form-group">
                        <label class="col-lg-2 control-label"> اسم الجهاز</label>

                        <div class="col-lg-4">

                            <span id="sprytextfield1">
                                <input type="text" name="name" id="name" class="form-control"/>
                                <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">
                            <span id="sprytextfield2">
                                <input type="text" name="hourPrice" id="hourPrice" class="form-control positivefloat"/>
                                <span class="textfieldRequiredMsg">*</span></span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-2 control-label">سعر الساعة زوجى</label>
                        <div class="col-lg-4">
                            <span id="sprytextfield22">
                                <input type="text" name="hourPriceMulti" id="hourPriceMulti" class="form-control positivefloat"/>
                                <span class="textfieldRequiredMsg">*</span></span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-2 control-label">له طاولة</label>
                        <div class="col-lg-4">
                            <input value="1" name="hasTable" id="hasTable" type="checkbox">
                        </div>
                    </div>

                    <div class="form-group" id="hallDiv" style="display: none">
                        <label class="col-lg-2 control-label">الصالة</label>
                        <div class="col-lg-4">
                            <span id="spryselect">
                                <select name="hallid" id="hallid" class="select2 wdt100">
                                    <option value='-1'>-- اختر صالة --</option>
                                    {foreach $restaurantHalls as $data}
                                    <option value="{$data->id}">{$data->name}</option>
                                    {/foreach}
                                </select>
                                <span class="selectInvalidMsg">*</span><span class="selectRequiredMsg">*</span></span>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-lg-2 control-label">تعريف الجهاز</label>
                        <div class="col-lg-4">
                            <input type="text" name="deviceIdentification" id="deviceIdentification" class="form-control"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-2 control-label">التعريف الفرعى </label>
                        <div class="col-lg-4">
                            <input type="text" name="subDeviceIdentification" id="subDeviceIdentification" class="form-control"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-2 control-label">استخدام التعريف الفرعى</label>
                        <div class="col-lg-4">
                            <div class="radio-inline">
                                <label>
                                    <input type="radio" name="useSubIdentification" value="0" checked="">
                                    لا </label>
                            </div>
                            <div class="radio-inline">
                                <label>
                                    <input type="radio" name="useSubIdentification" value="1">
                                    نعم </label>
                            </div>
                        </div>
                    </div>
                    <!-- =================================================   -->

                    <div class="form-group">
                        <div class="col-lg-offset-2 col-lg-4">
                            <button type="button" class="btn btn-primary pull-left" id="spbutton">حفظ الامر</button>
                        </div>
                    </div>




                </form>
            </div>
        </div>




    </div>
</div>


<div class="clear"></div>
<!-- ======= .grid_12 - block end ======= -->

</section>
<!-- End of #container -->

</section>
<!-- End of #layout -->
<div class="clear"></div>
{literal}

<script type="text/javascript">
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
    var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
    var sprytextfield22 = new Spry.Widget.ValidationTextField("sprytextfield22");
    var spryselect = '';//new Spry.Widget.ValidationSelect("spryselect", {invalidValue: "-1"});
    $('#hasTable').live('change', function (e) {
        if ($(this).prop("checked")) {
            $('#hallDiv').show();
            spryselect = new Spry.Widget.ValidationSelect("spryselect", {invalidValue: "-1"});
        } else {
            $('#hallDiv').hide();
            spryselect.destroy();
        }
    });
</script>

{/literal}


{literal}
<script type="text/javascript">
    $('#spbutton').live('click', function (e) {
        //ckeck name
        var tableName = 'restaurantplaystation';
        var inputName = 'name';
        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}
