
<style>
    #tableWithSearch thead tr >th{
        background-color:#4c0870;
        color:#fff;
    }
    #tableWithSearch thead tr th[class*='sorting_'] {
        color: #fff;
    }
    .bg-master-lighter {
        border:none;
        background-color:#fff;
        border-top:1px solid #ddd;  
    }
    .datepicker thead tr .dow {
        color:#4c0870  !important;
    }
    .datepicker table tr td.day:hover {
        background: #4c0870  !important;
        color:#fff;
    }
    .datepicker table tr td.active {
        background-color: #4c0870  !important;
    }
    .datepicker thead tr .datepicker-switch {
        color: #4c0870   !important;
        font-size: 13px;
    }
    .datepicker table tr td span.active {
        background-color: #4c0870  !important;
    }
    .datepicker table tr td span:hover {
        background-color: #4c0870  !important;
        color:#fff;
    }
    datepicker thead tr .next:before, .datepicker thead tr .prev:before {
        color: #4c0870  !important;
        font-family: 'FontAwesome';
        font-size: 10px;
    }
    .datepicker thead tr .next:before, .datepicker thead tr .prev:before {
        color: #4c0870  !important;
        font-family: 'FontAwesome';
        font-size: 10px;
    }





</style>
<div class="container-fluid container-fixed-lg bg-white">
    <div class="panel panel-transparent">
        <div class="panel-heading">
            <div class="panel-title"> <?php echo CommonLanguage::getMessage('check_due_dates'); ?> </div>
            <div class="row ">
                <div class="col-md-12 form-group ">

                    <div class="  col-md-2" >
                        <label><?php echo CommonLanguage::getMessage('type'); ?> </label>
                        <select id="date_type" class="full-width" data-init-plugin="select2">
                            <option value="1"><?php echo CommonLanguage::getMessage('due_date')?></option>
                            <option value="2"><?php echo CommonLanguage::getMessage('value_date')?></option>
                        </select>
                    </div> 
                    <div class="  col-md-3" >
                        <label><?php echo CommonLanguage::getMessage('Date'); ?> </label>
                        <input id="From_To_Date" type="text" class="form-control" name="From_To_Date" >
                    </div> 
                    <div class="  col-md-3" >
                        <label><?php echo CommonLanguage::getMessage('account'); ?> </label>
                        <input id="account_filter" type="hidden" class="full-width"  >
                    </div> 
                    <div class="  col-md-2" >
                        <label><?php echo CommonLanguage::getMessage('type'); ?> </label>
                        <select id="transaction_type" class="full-width" multiple  data-init-plugin="select2">
                            <option value=""><?php echo CommonLanguage::getMessage('All') ?></option>
                            <option value="inv"><?php echo CommonLanguage::getMessage('invoice') ?></option>
                            <option value="pur"><?php echo CommonLanguage::getMessage('purchase') ?></option>
                            <option value="pay"><?php echo CommonLanguage::getMessage('payment') ?></option>
                            <option value="rec"><?php echo CommonLanguage::getMessage('receipt') ?></option>
                            <option value="rin"><?php echo CommonLanguage::getMessage('return_invoice') ?></option>
                            <option value="rpr"><?php echo CommonLanguage::getMessage('return_purchase') ?></option>

                        </select>
                    </div> 
                    <div class="  col-md-2" >
                        <label><?php echo CommonLanguage::getMessage('Transaction_Type'); ?> </label>
                        <select id="trans_type" class="full-width"   data-init-plugin="select2">
                            <option value=""><?php echo CommonLanguage::getMessage('All') ?></option>
                            <option value="Debit"><?php echo CommonLanguage::getMessage('debit') ?></option>
                            <option value="Credit"><?php echo CommonLanguage::getMessage('credit') ?></option>
                            
                        </select>
                    </div> 


                </div>
            </div>
        </div>
        <div class="panel-body">

            <table class="table table-bordered table-hover demo-table-search" id="tableWithSearch">
                <thead>
                    <tr>
                        <th class="text-center" style="width:10%" > <?php print CommonLanguage::getMessage('account'); ?></th>
                        <th class="text-center" style="width:15%" > <?php print CommonLanguage::getMessage('cheque'); ?></th>
                        <th class="text-center" style="width:10%"> <?php print CommonLanguage::getMessage('due_date'); ?></th>
                        <th class="text-center" style="width:10%"> <?php print CommonLanguage::getMessage('value_date'); ?></th>
                        <th class="text-center" style="width:10%"> <?php print CommonLanguage::getMessage('note'); ?></th>
                        <th class="text-center" style="width:10%"> <?php print CommonLanguage::getMessage('amount'); ?></th>
                        <th class="text-center" style="width:5%" > <?php print CommonLanguage::getMessage('type'); ?></th>
                        <th class="text-center" style="width:10%"> <?php print CommonLanguage::getMessage('number'); ?></th>

                    </tr>
                </thead>
                <tbody>

                </tbody>
            </table>
        </div>

    </div>
</div>

<script>
    var is_actual = <?php echo $is_actual ? "true" : "false" ?>;
    var title = <?php echo json_encode(CommonLanguage::getMessage('check_due_dates')); ?>;
    var today = <?php echo json_encode($today) ?>;
    $(function () {
         build_select2($("#account_filter"), ("xhr/accIDSearch?type=Payment"))
        ChangeTable()
        $("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")
            ChangeTable();

        });
        $("#account_filter,#transaction_type,#trans_type,#date_type").on("change",function(){
            ChangeTable();
        })
    })

    function ChangeTable() {
        var Date = {is_actual: is_actual ? 1 : 0,
            account: $("#account_filter").val(),
            type: $("#transaction_type").val(),
            trans_type: $("#trans_type").val(),
            date_from: window.startDate ? window.startDate : today,
            date_to: window.endDate ? window.endDate : today,
            date_type : $("#date_type").val()

        };
        RebuildDataTable(title, [], "ACCAjax/check_due_dates_report", Date);
    }


</script>
