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

        <ol class="breadcrumb">
            <li><a href="#"> صيانه</a></li>
            <li><a href="branchesController.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">


                {literal}
                <form class="form-horizontal" enctype="multipart/form-data" role="form" action="branchesController.php?do=update" method="post" id="spform">

                    {/literal}

                    <input type="hidden" name="branchid" id="branchid" class="form-control" value="{$alldata->branchId}"/>

                    <div class="form-group">
                        <label for="branchname" class="col-lg-2 control-label"> اسم الفرع</label>

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

                            <span id="sprytextfield1">
                                <input type="text" name="branchname" id="branchname" class="form-control" value="{$alldata->branchName}"/>
                                <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 for="nameEn" class="col-lg-2 control-label">اسم الفرع بالانجليزية</label>
                        <div class="col-lg-4">
                            <input type="text" name="nameEn" id="nameEn" class="form-control" value="{$alldata->nameEn}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="phone" class="col-lg-2 control-label"> رقم الفرع</label>

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

                            <span id="sprytextfield2">
                                <input type="text" name="branchNo" id="branchNo" value="{$alldata->branchNo}" class="form-control positiveNo"/>
                                <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">ادخل رقم صحيح </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="branchTaxNo" id="branchTaxNo" class="form-control" value="{$alldata->branchTaxNo}"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="phone" class="col-lg-2 control-label"> عنوان الفرع</label>

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

                            <span id="sprytextfield2">
                                <textarea class="form-control" name="branchAddress" id="branchAddress">{$alldata->branchAddress}</textarea>
                                <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">ادخل رقم صحيح </span></span>

                        </div>
                    </div>
                    <div class="form-group">
                        <label for="phone" class="col-lg-2 control-label"> عنوان الفرع بالانجليزية</label>

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

                            <span id="sprytextfield2">
                                <textarea class="form-control" name="addressEn" id="addressEn">{$alldata->addressEn}</textarea>
                                <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">ادخل رقم صحيح </span></span>

                        </div>
                    </div>

                    <div class="form-group">
                        <label for="phone" class="col-lg-2 control-label">رقم الهاتف</label>

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

                            <span id="sprytextfield2">
                                <input type="text" name="phone" id="phone" class="form-control positiveNo" value="{$alldata->phone}"/>
                                <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">ادخل رقم صحيح </span></span>

                        </div>
                    </div>
                    <div class="form-group">
                        <label for="mobile" class="col-lg-2 control-label"> رقم المويايل</label>

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

                            <span id="sprytextfield3">
                                <input type="text" name="mobile" id="mobile" class="form-control positiveNo" value="{$alldata->mobile}"/>
                                <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">ادخل رقم صحيح </span></span>

                        </div>
                    </div>
                    <div class="form-group">
                        <label for="email" class="col-lg-2 control-label"> البريد الالكتروني</label>

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

                            <span id="sprytextfield3">
                                <input type="email" name="email" id="email" class="form-control" value="{$alldata->email}"/>
                                <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">ادخل رقم صحيح </span></span>

                        </div>
                    </div>
                    <div class="form-group">
                        <label for="phone" class="col-lg-2 control-label">رسالة التنبيه </label>

                        <div class="col-lg-4">
                            <textarea class="form-control" name="message" id="message">{$alldata->message}</textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="phone" class="col-lg-2 control-label">اللوجو </label>
                        <div class="col-lg-4">
                            <input type="hidden" name="oldlogo" id="oldlogo"  value="{$alldata->logo}" />
                            <input type="file" name="logo" id="logo" placeholder="اللوجو" accept="image/*"/>
                            {if $alldata->logo !=""}<a href="../views/default/images/branch_image/{$alldata->logo}" style="color: blue;" target="_blank"><u>عرض الصورة</u></a>{/if}
                        </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", "integer", {allowNegative: false});
    var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "integer", {allowNegative: false});
</script>

{/literal}

{literal}
<script type="text/javascript">
    $('#spbutton').live('click', function (e) {
        //ckeck name
        var tableName = 'branch';
        var inputName = 'branchname';
        var name = $("#" + inputName).val();
        var id = $("#branchid").val();
        $.ajax({
            url: 'checkRedundantNames.php?do=checkNameWithId&name=' + name + '&id=' + id + '&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}