
<div class="container-fluid container-fixed-lg bg-white">
    <div class="panel panel-transparent">
        <div class="panel-heading">
            <div class="panel-title"> <?php echo $title?></div>
            <div class="row form-group">
                <div class="col-md-3">
                    <label><?php echo CommonLanguage::getMessage('From') ?></label>
                    <input id="from_date" type="text" class="form-control" name="from_date" autocomplete="off" >
                </div> 
                <div class="col-md-3">
                    <label><?php echo CommonLanguage::getMessage('To') ?></label>
                    <input id="to_date" type="text" class="form-control" name="to_date" autocomplete="off" >
                </div> 
                <div class="col-md-2">
                    <div><label><?php print CommonLanguage::getMessage('Category'); ?></label></div>
                    <input class=" full-width " id="category_main_filter"  type="hidden" />
                </div>
                <div class="col-md-2">
                    <div><label><?php print CommonLanguage::getMessage('product'); ?></label></div>
                    <input class=" full-width " value="<?php echo isset($get_paramters['product_id']) ? $get_paramters['product_id'] : ''; ?>" data-select-name="<?php echo isset($get_paramters['product_name']) ? $get_paramters['product_name'] : ''; ?>" id="product_filter"  type="hidden" />
                </div>
                <div class="col-md-2">
                    <label><?php echo CommonLanguage::getMessage('Depot') ?></label>

                    <input id="depot_id" type="hidden" class="full-width" name="depot_id" >
                </div>
            </div>
            <div class="clearfix"></div>
        </div>
        <div class="panel-body" >
            <table class="table table-bordered stock" id="tableWithSearch" >
                <thead>
                    <tr>
                        <th class="text-center"><?php print CommonLanguage::getMessage('Code'); ?></th>
                        <th class="text-center"  ><?php print CommonLanguage::getMessage('Name'); ?></th>
                        <th class="text-center"  ><?php print CommonLanguage::getMessage('quantity'); ?></th>
                    </tr>
                </thead>
                <tbody>
                </tbody>
            </table>
        </div>
    </div>
</div>
<script>
    var title = <?php echo json_encode(CommonLanguage::getMessage('backdated_stock')); ?>;
    $(function () {
        build_select2($("#category_main_filter"), "xhr/catSearch")
        build_select2($("#product_filter"), "xhr/ProductSearch");
         build_select2($("#depot_id"), "xhr/depotSearch")
        change_table()
        $("#from_date,#to_date").datepicker({autoclose: true}).on("changeDate", function () {
            change_table()

        })
        $("#category_main_filter,#product_filter,#depot_id").on("change", function () {
            change_table()
        })
    })
    function change_table() {
        var Data = {
            cat_id: $("#category_main_filter").val(),
            product_id: $("#product_filter").val(),
            depot_id: $("#depot_id").val(),
            from_date: $("#from_date").val(),
            to_date: $("#to_date").val(),
        };
        RebuildDataTable(title, [0, 1, 2], 'StockAjax/backdated_stock_ajax', Data);

    }
</script>