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

        <ol class="breadcrumb">
            <li><a href="#"> صيانه</a></li>
            <li><a href="typeSupplierController.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="typeSupplierController.php?do=add" method="post" id="spform">

                    {/literal}



                    <div class="form-group">
                        <label for="typename" class="col-lg-2 control-label"> توع المورد </label>

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

                            <span id="sprytextfield1">
                                <input type="text" name="typename" id="typename" class="form-control" required/>
                                <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="comments" class="col-lg-2 control-label">التصنيفات</label>-->
                        <!--<div class="col-lg-4">-->

                        <!--<select class="js-example-basic-multiple"  name="category_id[]" multiple="multiple">-->
                            <!--{foreach $allParents as $category}-->
                            <!--<option value="{$category->productCatId}">{$category->productCatName}</option>-->
                            <!--{/foreach}-->
                            <!--</select>-->
                        <!--</div>-->
                    <!--</div>-->


                    <div class="form-group">
                        <label for="comments" class="col-lg-2 control-label">التعليق</label>
                        <div class="col-lg-4">

                            <textarea class="form-control" rows="3" name="comments" id="comments"></textarea>

                        </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 = 'typeclient';
        var inputName = 'typename';
        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;
                }
            }});

    });

    // $(document).ready(function() {
    //     $('.js-example-basic-multiple').select2({
    //         placeholder: "اختر التصنيف",
    //         containerCssClass: function(e) {
    //             return $(e).attr('required') ? 'required' : '';
    //         }
    //     });
    // });


</script>
{/literal}
