<div class="container-fluid container-fixed-lg bg-white">
    <div class="panel panel-transparent">
        <div class="panel-heading">
            <div class="panel-title"><?php print CommonLanguage::getMessage('cash_drawer_log'); ?></div>
        </div>
        <div class="panel-body">
            <div class="row form-group">
                <div class="col-md-3">
                    <label><?php echo CommonLanguage::getMessage('Date') ?></label>
                    <div class="input-group">
                        <span class="input-group-addon bg-primary"><i class="fa fa-calendar"></i></span>
                        <input id="From_To_Date" type="text" class="form-control" name="From_To_Date" >
                    </div>
                </div> 
                <div class="col-md-3">
                    <label><?php echo CommonLanguage::getMessage('cash_drawer'); ?></label>
                    <input id="cash_drawer_id" type="hidden" class="full-width" name="cash_drawer_id" >
                </div> 
                <div class="col-md-3">
                    <label><?php echo CommonLanguage::getMessage('user_name') ?></label>
                    <input id="user_id" type="hidden" class="full-width" name="user_id" >
                </div> 
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="table-responsive">
                        <table class="table table-bordered inventory" id="tableWithSearch">
                            <thead>
                                <tr>
                                    <th class="text-center"><?php print CommonLanguage::getMessage('login_system_amount'); ?></th>
                                    <th class="text-center"><?php print CommonLanguage::getMessage('real_amount'); ?></th>
                                    <th class="text-center"><?php print CommonLanguage::getMessage('diff'); ?></th>
                                    <th class="text-center"><?php print CommonLanguage::getMessage('login_date_time'); ?></th>
                                    <th class="text-center"><?php print CommonLanguage::getMessage('cash_drawer'); ?></th>
                                    <th class="text-center"><?php print CommonLanguage::getMessage('user_name'); ?></th>
                                    <th class="text-center"><?php print CommonLanguage::getMessage('logout_system_amount'); ?></th>
                                    <th class="text-center"><?php print CommonLanguage::getMessage('withdrawal_amount'); ?></th>
                                    <th class="text-center"><?php print CommonLanguage::getMessage('remaining_amount'); ?></th>
                                    <th class="text-center"><?php print CommonLanguage::getMessage('diff'); ?></th>
                                    <th class="text-center"><?php print CommonLanguage::getMessage('logout_date_time'); ?></th>
                                </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    var today = <?php echo json_encode($today) ?>;
    $(function(){
        ajaxTable();
        $("input[name=From_To_Date]").daterangepicker({
            ranges: {
                'Today': [moment(), moment()],
                'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
                'Last 7 Days': [moment().subtract(6, 'days'), moment()],
                'Last 30 Days': [moment().subtract(29, 'days'), moment()],
                'This Month': [moment().startOf('month'), moment().endOf('month')],
                'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
            }
        }, function (start, end, label) {
            window.startDate = start.format("YYYY-MM-DD"),
                window.endDate = end.format("YYYY-MM-DD")
            ajaxTable()
        });
        $("#user_id,#cash_drawer_id").on('change',function(){
            ajaxTable();
        });
        build_select2($("#user_id"), "xhr/employeeSearch");
        build_select2($("#cash_drawer_id"), "xhr/commonSearch?col_id=cash_drawer_id&col_name=cash_drawer_title&table=tbl_cash_drawer_accounts");
    });
    function ajaxTable(){
         var Data = {
            user_id: $('#user_id').val(),
            cash_drawer_id: $('#cash_drawer_id').val(),
            Date_From: window.startDate ? window.startDate : today,
            Date_To: window.endDate ? window.endDate : today};
         RebuildDataTable($('.panel-heading .panel-title').html(), [0], 'InventoryAjax/CashDrawerLog',Data);
    }
</script>