<style>
    .table thead tr >th{
        background-color:#4c0870;
        color:#fff;
        /*width: 16% !important;*/
    }
    .success {background:#4c0870 !important}
</style>
<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('piece_payment_report'); ?></div>
            <div class="clearfix"></div>
        </div>
        <div class="panel-body">
            <div class="row">
                <div class="col-md-3 form-group">
                    <label><?php echo CommonLanguage::getMessage('Date');?></label>
                    <span class="red-star">*</span>
                    <div class="input-group  ">
                        <span class="input-group-addon success ">
                            <i class="fa fa-calendar"></i>
                        </span>
                        <input id="range_date" type="text" class="form-control" readonly="" name="range_date">
                    </div>
                </div>
                <div class="col-md-3 form-group">
                    <label><?php echo CommonLanguage::getMessage('employee');?></label>
                    <span class="red-star">*</span>
                    <input id="employee_id" type="hidden" class="full-width"  name="employee_id">
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="table-responsive">
                        <table class="table table-bordered table-hover demo-table-search" id="tableWithSearch">
                            <thead>
                                <tr>
                                    <th class="text-center"><?php print CommonLanguage::getMessage('Date'); ?></th>
                                    <th class="text-center"><?php print CommonLanguage::getMessage('employee'); ?></th>
                                    <th class="text-center"><?php print CommonLanguage::getMessage('total_price'); ?></th>
                                    <th class="text-center"><?php print CommonLanguage::getMessage('paid_amount'); ?></th>
                                </tr>
                            </thead>
                            <tbody>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    var is_actual = <?php echo json_encode($is_actual) ?>,
        startDate = '<?php echo date('Y-m-d');?>', 
            endDate = '<?php echo date('Y-m-d');?>';
    $(function(){
        build_select2($("#employee_id"), "xhr/employeeSearch?is_actual=" + is_actual);
        AjaxCall();
        $('#employee_id').on('change',function(){
            AjaxCall();
        });
        $("input[name=range_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");
            AjaxCall();
        });
    });
    function AjaxCall(){
        var data = {employee_id: $('#employee_id').val(),is_actual:is_actual,
                    start_date: startDate,end_date:endDate };
        RebuildDataTable($('.panel-heading .panel-title').html(), [0, 1, 2,3], 'HRMAjax/piecePaymentReport',data);
    }
</script>