<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">المتجر اونلاين</a></li>
            <li><a href="productCatOnlineController.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="nameToBeChecked form-horizontal" role="form" action="productCatOnlineController.php?do=add"
                      method="post" enctype="multipart/form-data" id="spform">
                    {/literal}

                    <div class="form-group">
                        <label class="col-lg-2 control-label">تصنيف المنتج</label>
                        <div class="col-lg-4">
                            <input type="hidden" data-level="0" name="parent" id="productCatId0">
                        </div>
                        <input type="hidden" id="level" name="level" value="0">
                    </div>
                    <!-- =================================================   -->

                    <div class="form-group">
                        <label for="productCatName" class="col-lg-2 control-label">اسم التصنيف</label>
                        <div class="col-lg-4"> <span id="sprytextfield1">
                                <input type="text" name="title" id="title"
                                       onkeyup="/*checkName(event, 'onlineproductcat', 'title')*/" 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>{$smarty.const.WRONG_MESSAGE}</h4>
                                <p>{$smarty.const.NAME_ALREADY_TAKEN}</p>
                                <div class="clearfix"></div>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="productCatName" class="col-lg-2 control-label">اسم التصنيف الانجليزى</label>
                        <div class="col-lg-4"> <span id="sprytextfield2">
                                <input type="text" name="titleEn" id="titleEn"
                                       onkeyup="/*checkName(event, 'onlineproductcat', 'titleEn')*/" class="form-control" />
                                <span class="textfieldRequiredMsg">*</span></span>
                            <div id="nameErrorEn" 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>{$smarty.const.WRONG_MESSAGE}</h4>
                                <p>{$smarty.const.NAME_ALREADY_TAKEN}</p>
                                <div class="clearfix"></div>
                            </div>
                        </div>
                    </div>
                    <!--==============================-->

                    <div class="form-group">
                        <label for="email" class="col-lg-2 control-label">صورة التصنيف</label>
                        <div class="col-lg-4">
                            <input type="file" name="logo" id="logo" class="form-control" accept="image/*" />
                        </div>
                    </div>

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


                    <div class="form-group">
                        <label for="productCatDescription"
                               class="col-lg-2 control-label">تعليق</label>
                        <div class="col-lg-4">
                            <textarea class="form-control" rows="3" name="description"></textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="productCatDescription"
                               class="col-lg-2 control-label">تعليق انجليزى</label>
                        <div class="col-lg-4">
                            <textarea class="form-control" rows="3" name="descriptionEn"></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>

{literal}
<script type="text/javascript">
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
    var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2");
    $('#spbutton').live('click', function (e) {
        if (!$('#spbutton').hasClass("processing")) {
            $('#spbutton').addClass("processing");
            var myForm = document.getElementById("spform");
            var SS = Spry.Widget.Form.validate(myForm);
            if (SS == true) {
                myForm.submit();
            } else {
                $('#spbutton').removeClass("processing");
            }
        }
    });

    $(function () {
        $('#productCatId0').select2({
            placeholder: "اختر تصنيف ",
            minimumInputLength: 0,
            //  minimumInputLength: 3,
            multiple: false,
            quietMillis: 100,
            ajax: {
                url: "productControllerAjax.php?do=getallonlinecats",
                dataType: 'json',
                data: function (term, page) {
                    //  alert(term);
                    return {
                        term: term, //search term
                        page_limit: 30, // page size
                    };
                },
                results: function (data) {
                    // alert(term);
                    return {results: data};
                }
            },
            formatResult: function (data) {
                return data.text;
            },
            initSelection: function (element, callback) {
                var item = element.val().split(':');
                var data = {id: item[0], text: item[1]};
                callback(data);
            }
        });
    });
</script>
{/literal}