

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

        <ol class="breadcrumb">
            <li><a href="#">المطاعم</a></li>
            <li><a href="restaurantprinters.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 id="myform" class="nameToBeChecked form-horizontal" role="form" action="restaurantprinters.php?do=update" method="post">

                    <div class="form-group">
                        <label for="printerName" class="col-lg-2 control-label">اسم الطابعة</label>
                        <div class="col-lg-4">
                            <span id="sprytextfield1">
                                <input type="text" name="printerName" id="printerName"     placeholder="اسم الطابعة" class="form-control" value="{$data->name}" /><!-- onkeyup="checkNameWithId(event, 'unit', 'printerName', 'unitId')" -->
                                <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 type="hidden" name="cats[]" id="cats"/>
                        </div>
                    </div>
                    <!-- =================================================   -->
                    <input name="id" id="id" type="hidden" value="{$data->id}" />
                    <input name="oldname" id="oldname" type="hidden" value="{$data->name}" />
                    <!-- =================================================   -->


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


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




    </div>
</div>
<input type='hidden' id='cats_hidden' name='cats_hidden' value='{$cats_hidden}'/>

{literal}
<script type="text/javascript">
    var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
    $(function () {
        $("#cats").select2({
            multiple: true,
            ajax: {
                url: "productControllerAjax.php?do=gellastlevelcats",
                dataType: 'json',
                data: function (term, page) {
                    return {
                        term: term, //search term
                        page_limit: 10 // page size
                    };
                },
                results: function (data) {
                    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);
            }
        });
        var cats_hidden = $('#cats_hidden').val();
        cats_hidden = JSON.parse(cats_hidden);
//        $('#cats').select2('data', [{id: 103, text: 'ENABLED_FROM_JS'}, {id: 104, text: 'ENABLED'}]);
        $('#cats').select2('data', cats_hidden);
    });
</script>
{/literal}
