{literal}
<script type="text/javascript" charset="utf-8">
    $("[id^='parcode']").live('keypress', function () {
        if (event.which == '10' || event.which == '13') {
            event.preventDefault();
        }
    });
    function getproductbyParcode(e, value) {
        //\s means "one space", and \s+ means "one or more spaces".
        value = value.replace(/\s+/g, '');//\s is the regex for "whitespace", and g is the "global" flag, meaning match ALL \s (whitespaces).
        var code = (e.keyCode ? e.keyCode : e.which);
        //to stop the submit of the form
        if (e.which == 13 && value != "") {
            var billnameid = 3;
            value = value.replace("ه", "i");//this replacement is for parcode reader
            value = value.replace("÷", "i");//this replacement is for parcode reader
            value = value.replace("/", "i");//this replacement is for parcode reader
            value = value.replace("I", "i");//this replacement is for parcode reader
            //alert(value.charAt(0));
            $.ajax({
                url: 'sellbillAjaxController.php?do=getproductNamebyOnlyParcode&parcode=' + value + '&billnameid=' + billnameid + '',
                success: function (data) {
                    var response = $.parseJSON(data);
                    $("#product").select2('data', {id: response.id, text: response.text});
                }
            });
            // }
        }
    }
</script>
{/literal}

<div class="row">
    <div class="container">
        <ol class="breadcrumb">
            <li><a href="#">المنتجات</a></li>
            <li class="active">إعادة جرد</li>
        </ol>
        <div class="panel panel-default panel-m">
            <div class="panel-heading">
                <h3 class="panel-title">إعادة جرد</h3>
                <a href="{$youtubes[58]->url}" target="_blank" class="hidden-print"><img
                        src="../views/default/assets/img/youtube.png" class="pull-left" alt="Youtube"
                        style="width: 2%;"></a>

            </div>
            <div class="panel-body">
                <form class="form-horizontal" role="form" action="inventoryController.php?do=add" method="post">
                    <div class="form-group">
                        <label for="storesData" class="col-lg-2 control-label">المخزن</label>
                        <div class="col-lg-4">
                            <select class="select2 wdt100" name="storeId" id="storeId">
                                <option value="-1">اختر مخزن</option>




                                {foreach $storesData as $store}




                                <option value="{$store->storeId}">{$store->storeName}</option>




                                {/foreach}




                            </select>
                        </div>
                    </div>

                    <!-- ================================================= -->
                    <div class="form-group">
                        <label for="catId" class="col-lg-2 control-label">التصنيف الرئيسى</label>
                        <div class="col-lg-4">
                            <select class="select2 wdt100 productCat" data-level="0" name="productCatId0"
                                    id="productCatId0">
                                <option value="-1">اختر تصنيف</option>
                                {foreach $catData as $data}
                                <option value="{$data->productCatId}">{$data->productCatName}</option>
                                {/foreach}
                            </select>
                        </div>
                        <input type="hidden" id="level" name="level" value="0">
                    </div>

                    <div id="manyParents">

                    </div>

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

                    <div class="form-group">
                        <label for="parent" class="col-lg-2 control-label">المنتج</label>
                        <div class="col-lg-4">
                            <input type="hidden" id="product" name="product" data-placeholder="اختر"
                                   class="select2product wdt100" />
                        </div>
                    </div>

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

                    <div class="form-group">
                        <label for="parent" class="col-lg-2 control-label">الباركود</label>
                        <div class="col-lg-4">
                            <input type="text" name="parcode" id="parcode" class="form-control"
                                   onkeypress="getproductbyParcode(event, this.value);" placeholder="need to press enter">
                        </div>
                        <div class="col-lg-2">
                            {if $manyParcodes != 1}
                            <button type="button" class="btn btn-success pull-left ft-nor addManyParcodes"
                                    id="addManyParcodes" data-type="sell" style="margin-left:3px;">إضافة بالباركود المجمع
                            </button>
                            <span
                                class="col-lg-4 pull-left {if $billsettingsData[99]->billsettingsvalue != 1} hidden {/if} ">
                                <select class="select2 wdt100" id="billTemplatesId"
                                        data-placeholder="الفواتير المحفوظة">
                                    <option value=""></option>
                                    {foreach $allBillTemplates as $item}
                                    <option value="{$item->id}">{$item->name}</option>
                                    {/foreach}
                                </select>
                                {/if}
                            </span>
                        </div>
                        <div class="col-lg-1"><button type="button" class="btn btn-primary pull-left"
                                                      id="searchnow">بحث</button></div>
                    </div>


                    <div class="form-group">
                        <label for="parent" class="col-lg-2 control-label">تاريخ آخر إعادة جرد</label>

                        <div class="col-lg-4">
                            <input type="text" class="form-control awdatepicker " autocomplete="off"
                                   data-date-format="yyyy-mm-dd" id="lastInventoryDate" value="">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="parent" class="col-lg-2 control-label">.</label>

                        <div class="col-lg-4">
                            <label> <input value="1" class="beforeAfter" name="beforeAfter" type="radio">
                                تم جردها بعد هذا التاريخ </label>
                            <label>
                                <input value="2" class="beforeAfter" name="beforeAfter" type="radio">
                                تم جردها قبل هذا التاريخ</label>
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="parent" class="col-lg-2 control-label">اظهار المنتجات الصفريه</label>

                        <div class="col-lg-4">
                            <input class="form-control" name="zeros" id="zeros" type="checkbox" checked="" value="1">

                        </div>
                    </div>
                    <div class="form-group">
                        <label for="parent" class="col-lg-2 control-label">نتائج البحث</label>

                        <div class="col-lg-4">
                            <label> <input value="1" class="showMoreSetting" name="showMoreSetting" type="radio">
                                كل النتائج </label>
                            <label>
                                <input value="0" class="showMoreSetting" name="showMoreSetting" type="radio" checked>
                                مجموعه و عرض المزيد</label>
                        </div>
                    </div>

                    <!-- ================================================= -->
                    <div id="productsDiv">

                    </div>
                    <input name="storenegative" type="hidden" value="{$storenegative}" id="storenegative" />
                    <!--  <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>
                <input type="hidden" name="searchvalue" id="searchvalue" value="{$programsettingsdata->searchvalue}" />
            </div>
        </div>
    </div>
</div>


<!-- Modal -->
<div class="modal fade" id="myModalManyParcodes" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
     aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content bg-modal">
            <div class="modal-header">
                <button type="button" class="close pull-left savemodel2" data-dismiss="modal"
                        aria-hidden="true">&times;</button>
                <h4 class="modal-title">اضافة منتجات بالباركود المجمع</h4>
            </div>
            <div class="modal-body">
                <form id="manyParcodesForm" action="inventoryControllerAjax.php?do=addManyParcodes" method="post"
                      class="form-horizontal">
                    <div class="form-group">
                        <label for="debtLimit" class="col-lg-3 control-label">الباركودات مجمعة</label>
                        <div class="col-lg-9">
                            <textarea name="manyParcodes" class="form-control" style="background: url(http://i.imgur.com/2cOaJ.png);
                                      background-attachment: local;
                                      background-repeat: no-repeat;
                                      padding-left: 35px;
                                      padding-top: 10px;
                                      text-align: left !important;
                                      border-color:#ccc;
                                      direction: ltr;" id="manyParcodes" rows="5"></textarea>

                        </div>
                        <div id='hazemc'>1</div>
                    </div>
                    <input type="hidden" name="manyParcodesstoreid" id="manyParcodesstoreid" value="" />
                    <input type="hidden" name="manyParcodesproductCatId" id="manyParcodesproductCatId" value="" />
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default savemodel2" data-dismiss="modal">الغاء</button>
                <button type="button" class="btn btn-primary" id="doAddManyParcodes">تم</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
<!-- /.modal -->

{literal}
<script type="text/javascript">
    $(document).on('click', "#addManyParcodes", function () {
        if ($('#storeId').val() == "-1" || $('#storeidto').val() == "-1") {
            alert('اختر المخزن اولا');
        } else {
            $('#myModalManyParcodes').modal('show');
            setTimeout(function () {
                $('#manyParcodes').focus();
            }, 800);
        }
    });


</script>
{/literal}