{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);
                    $("#productId").select2('data', {id: response.id, text: response.text});
                }
            });
            // }
        }
    }


//
//
//			$(document).ready( function () {
//    $('#example').dataTable( {
//		 "bPaginate": false,
//		 "bStateSave": true,
//        "sDom": 'TCR<"clear">lfrtip',
//        "oTableTools": {
//            "aButtons": [
//                "copy",
//                "print",
//                {
//                    "sExtends":    "collection",
//                    "sButtonText": "حفظ",
//                    "aButtons":    [ "csv", "xls"]
//                }
//            ]
//        }
//    } ).columnFilter();
//} );
</script>
{/literal}

<style>
    .myresult {
        -webkit-print-color-adjust: exact;
    }
</style>

<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">
            <!-- Default panel contents -->
            <div class="panel-heading">تقرير حركة المخازن
                <a href="{$youtubes[112]->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-inline hidden-print" action="storereportController.php?do=show" method="post">
                    <input type="hidden" name="searchvalue" id="searchvalue" value="{$Programsettingdata->searchvalue}"/>
                   
                    {if $searchinonestore neq 0}
                    <div class="form-group">
                        <div class="col-md-2">
                            <label class="sr-only"> المخزن</label>
                        </div>
                         <input type="hidden" name="storeId" id="storeId"  value="{$storeid}"  >
                        {$storedef->storeName}
                    </div>
                    {else}
                    <div class="form-group">
                        <div class="col-md-2">
                            <label class="sr-only"> المخزن</label>
                        </div>
                        <select class="select2 wdt300"  name="storeId" id="storeId">
                            <option value="-1">اختر مخزن</option>
                            {foreach $stores as $store}
                            <option value="{$store->storeId}">{$store->storeName}</option>
                            {/foreach}
                        </select>
                    </div>
                    {/if}



                    <div class="form-group">
                        <div class="col-md-2">
                            <label class="sr-only"> المنتج</label>
                        </div>
                        <input type="hidden" class="select2product wdt300"  name="productId" id="productId" data-placeholder="اختر منتج"  />
                    </div>
                    <div class="form-group">
                        <div class="col-md-2">
                            <label class="sr-only">الباركود</label>
                        </div>
                        <input type="text" name="parcode" id="parcode" class="form-control" onkeypress="getproductbyParcode(event, this.value);" placeholder="need to press enter">
                    </div>
                    <br />

                    <div class="form-group">
                        <div class="col-md-2">
                            <label class="sr-only"> الترتيب</label>
                        </div>
                        <select class="select2 wdt300"  name="order" id="order" >
                            <option value="asc">تصاعدى</option>
                            <option value="desc">تنازلى</option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label class="sr-only">رصيد صافي</label>
                        <input name="bure" type="checkbox" id="bure" checked="checked" value="1" />
                        <label for="bure"></label>
                    </div>
                    <br/>
                    <div class="form-group">
                        <label class="sr-only">من التاريخ</label>
                        <input type="text" class="form-control awdatepicker" autocomplete="off"   data-date-format="yyyy-mm-dd" name="from" >
                    </div>
                    <div class="form-group">
                        <label class="sr-only">إلى التاريخ</label>
                        <input type="text" class="form-control awdatepicker" autocomplete="off"   data-date-format="yyyy-mm-dd" name="to" >
                    </div>
                    <button type="submit" class="btn btn-primary">بحث</button>
                </form>
            </div>
            {if {count($storereportData)} > 0}
            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">{$message}</div>
                <div class="panel-body">
                    <hr/>
                    <div class="hidden-print col-lg-offset-8 col-lg-4 {if $Usergroupdata->hideBillPrices == 1}hidden{/if}">
                        <div class="well well-sm">
                            <h4 class="text-center">اجمالى سعر المنتجات {$sumValue} {$currency}</h4>
                        </div>
                    </div>
                    <table class="table table-black dataTableClass" id="example">
                        <thead>
                            <tr>
                                <th>الرقم</th>
                                <th>المنتج</th>
                                <th>المخزن</th>
                                <th>الكمية قبل</th>
                                <th>الكمية المتغيرة</th>
                                <th>الكمية بعد</th>
                                <th>تاريخ العملية</th>
                                <th>وصف العملية</th>
                                {if $Usergroupdata->hideBillPrices != 1}<th>السعر </th>{/if}
                                <th>المستخدم </th>
                                {if $Usergroupdata->hideBillPrices != 1}<th class="noprint">تفاصيل العملية</th>{/if}
                            </tr>
                        </thead>
                        <tbody>
                            {assign var=x value=1}
                            {foreach $storereportData as $storereport}

                            {if {$storereport->storereportid} > 0}
                            {if {$storereport->storereporttype} eq 1}
                            <tr class="danger"> {elseif {$storereport->storereporttype} eq 0}

                            <tr> {/if}
                                <td>{$x}</td>
                                <td>{$storereport->productName}</td>
                                <td>{$storereport->storeName}</td>
                                <td>{$storereport->productbefore}</td>
                                <td>{$storereport->productquantity}</td>
                                <td>{$storereport->productafter}</td>
                                <td>{$storereport->storereportdate}</td>
                                <td>{$storereport->processname}{if $storereport->otherName != ""} - {$storereport->otherName}{/if}</td>
                                {if $Usergroupdata->hideBillPrices != 1}<td>{$storereport->pricebuy}</td>{/if}
                                <td>{$storereport->employeename}</td>
                                {if $Usergroupdata->hideBillPrices != 1}<td class="noprint"> {if {$storereport->storereportmodelid} <> -1}


                                    {if {$storereport->tablename} eq "buyBillController.php" || {$storereport->tablename} eq "returnBuyBillController.php"  || {$storereport->tablename} eq "buyAndReturnBillController.php"}
                                    <a href="{$storereport->tablename}?do=details&id={$storereport->storereportmodelid}" target="_blank" type="button" class="btn btn-default btn-lg editicon"></a>


                                    {elseif {$storereport->tablename} eq "sellbillController.php" || {$storereport->tablename} eq "sellbillandruternController.php"}

                                    <a href="{$storereport->tablename}?do=showDetail&sellbillid={$storereport->storereportmodelid}" target="_blank" type="button" class="btn btn-default btn-lg editicon"></a>


                                    {elseif {$storereport->tablename} eq "returnsellbillController.php"}

                                    <a href="{$storereport->tablename}?do=showDetail&returnsellbillid={$storereport->storereportmodelid}" target="_blank" type="button" class="btn btn-default btn-lg editicon"></a>
                                    {elseif {$storereport->tablename} eq "bills.php" || {$storereport->tablename} eq "billsreturn.php"}

                                    <a href="{$storereport->tablename}?do=details&id={$storereport->storereportmodelid}" target="_blank" type="button" class="btn btn-default btn-lg editicon"></a>
                                    {else}
                                    <a href="{$storereport->tablename}?do=editprint&id={$storereport->storereportmodelid}" target="_blank" type="button" class="btn btn-default btn-lg editicon"></a>
                                    {/if}
                                    {elseif {$storereport->storereportmodelid} eq -1}

                                    {/if} </td>{/if}
                            </tr>
                            {/if}
                            {capture assign=x}{$x+1}{/capture}

                            {/foreach}

                        </tbody>

                    </table>
                    <div class="col-lg-offset-8 col-lg-4 {if $Usergroupdata->hideBillPrices == 1}hidden{/if}">
                        <div class="well well-sm">
                            <h4 class="text-center">اجمالى سعر المنتجات {$sumValue} {$currency}</h4>
                        </div>
                    </div>
                    {/if}
                    <div class="clearfix"></div>
                    <hr />
                    {if {count($storereportData)} > 0}
                    <div  class="noprint">
                        <div class="col-lg-12">
                            <div class="form-group">
                                <div class="col-lg-4">
                                    <button type="button" onclick="print_Custom('mycustomheader');" class="btn btn-success pull-right hidden-print">طباعة</button>
                                </div>
                            </div>
                        </div>
                        <div class="clearfix"></div>
                    </div>
                    {/if}
                    <div class="clearfix"></div>
                </div>
            </div>
        </div>
