<style type="text/css">
    .table td {
        min-height: 35px;
    }
    .btn.btn-circle.btn-sm {
        position: fixed;
        z-index: 1000;
        left: 16.2%;
        top: 24%;
        padding: 12px 13px;
    }
    .widgetsearch .widget-buttons {
        height: 16px;
        line-height: 19px;
    }
    .widgetsearch .widget-buttons>a {
        line-height: 1px;
        color: #fff;
    }
    .widgetsearch .widget-header {
        min-height: 18px;
        text-align: center;
    }
    @media only screen and (max-width: 600px) {
        .btn.btn-circle.btn-sm {
            left: 1%;
            top: 31%;
        }
        #back_accounts {
            top: 26%;
        }
        #downloadstatement {
            top: 26%;
        }
        #downloadstatementexcel {
            top: 26%;
        }
    }
    @media screen and (max-width: 768px) and (min-width: 600px) {
        .btn.btn-circle.btn-sm {
            left: 0%;
            top: 23%;
        }
        #back_accounts {
            top: 26%;
        }
        #downloadstatement {
            top: 26%;
        }
        #downloadstatementexcel {
            top: 26%;
        }
    }
    @media screen and (max-width: 1024px) and (min-width: 769px) {
        .btn.btn-circle.btn-sm {
            left: 21%;
            top: 26%;
        }
        #back_accounts {
            top: 26%;
        }
        #downloadstatement {
            top: 26%;
        }
        #downloadstatementexcel {
            top: 26%;
        }
    }
    #back_accounts {
        top: 26%;
    }
    #downloadstatement {
        top: 34%;
    }
    #downloadstatementexcel {
        top: 42%;
    }
    .select2-selection__choice__remove {
        color: #000 !important;
    }
</style>
<div class="page-content">
    <!-- Page Breadcrumb -->
<!--    <div class="page-breadcrumbs">
        <ul class="breadcrumb">
            <li>
                <i class="fa fa-home"></i>
                <a href="#"><?php echo $this->lang->line("FINANCE"); ?></a>
            </li>
            <li class="active"><?php echo $this->lang->line("PROFITANDLOSSSTATEMENT"); ?></li>
        </ul>
    </div>-->
    <!-- /Page Breadcrumb -->
    <!-- Page Header -->
    <div class="page-header position-relative">
        <div class="header-title">
            <h1>
                <?php echo $this->lang->line("PROFITANDLOSSSTATEMENT"); ?>
            </h1>
        </div>
        <!--Header Buttons-->
        <div class="header-buttons">
            <a class="sidebar-toggler" href="#">
                <i class="fa fa-arrows-h"></i>
            </a>
            <a class="refresh" id="refresh-toggler" href="">
                <i class="glyphicon glyphicon-refresh"></i>
            </a>
            <a class="fullscreen" id="fullscreen-toggler" href="#">
                <i class="glyphicon glyphicon-fullscreen"></i>
            </a>
        </div>
        <!--Header Buttons End-->
    </div>
    <!-- /Page Header -->
    <!-- Page Body -->
    <!-- End Page Body -->
    <div class="page-body">
        <div class="row">
            <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                <div class="row">
                    <div class="col-xs-12 col-md-12">
                        <div class="widget">
                            <div class="widget-body">
                                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 no-padding">
                                    <form name="frmsearch" id="frmsearch" action="<?php echo base_url("finance/plstatement/exportPDFData"); ?>" method="post" target="_blank">
                                        <div class="col-lg-6 col-md-12 col-sm-12 col-xs-12 no-padding-left" style="padding-bottom: 9px;">
                                            <div style="max-height: 120px;overflow: auto;">
                                                <select id="choosehead" name="choosehead[]" style="width:100%;" class="e2" multiple="multiple">
                                                    <option value><?php echo $this->lang->line("SELECTHEAD"); ?></option>
                                                    <?php
                                                    if($headlist) {
                                                        foreach ($headlist as $headrec) {
                                                            $selectvar = '';
                                                            if($choosehead) {
                                                                if(in_array($headrec["ID"], $choosehead)) {
                                                                    $selectvar = 'selected';
                                                                }
                                                            } else {
                                                                $selectvar = 'selected';
                                                            }
                                                            echo "<option value=\"".$headrec["ID"]."\" $selectvar>".$headrec["PAYMENTHEAD"]."</option>";    
                                                        }
                                                    }
                                                    ?>
                                                </select>
                                            </div>
                                        </div>
<!--                                        <div class="col-lg-2 col-md-12 col-sm-12 col-xs-12 no-padding-left" style="padding-bottom: 9px;">
                                            <div class="input-group">
                                                <input class="form-control date-picker" name="filter_begin" id="filter_begin"
                                                       type="text" placeholder="<?php echo $this->lang->line("FROM"); ?>"
                                                       data-date-format="dd-mm-yyyy" readonly value="<?php echo date('d-m-Y', strtotime('-1 week')); ?>" />
                                                <span class="input-group-addon">
                                                    <i class="fa fa-calendar"></i>
                                                </span>
                                            </div>
                                        </div>
                                        <div class="col-lg-2 col-md-12 col-sm-12 col-xs-12 no-padding-left" style="padding-bottom: 9px;">
                                            <div class="input-group">
                                                <input class="form-control date-picker" name="filter_end" id="filter_end"
                                                       type="text" placeholder="<?php echo $this->lang->line("TO"); ?>"
                                                       data-date-format="dd-mm-yyyy" readonly value="<?php echo date('d-m-Y'); ?>" />
                                                <span class="input-group-addon">
                                                    <i class="fa fa-calendar"></i>
                                                </span>
                                            </div>
                                        </div>-->
                                        <div class="col-lg-3 col-md-12 col-sm-12 col-xs-12 no-padding-left" style="padding-bottom: 9px;">
                                            <div class="input-group">
                                                <input class="form-control" name="filter_date"
                                                       id="filter_date" type="text" placeholder=""
                                                       data-date-format="dd-mm-yyyy" readonly value="<?php echo date('d-m-Y')." - ".date('d-m-Y', strtotime('-1 week')); ?>" />
                                                <span class="input-group-addon">
                                                    <i class="fa fa-calendar"></i>
                                                </span>
                                            </div>
                                        </div>
                                        <div class="col-lg-2 col-md-12 col-sm-12 col-xs-12 no-padding" style="padding-bottom: 9px;">
                                            <div class="btn-group" style="width: 100%;">
                                                <input type="button" name="btnsearch" class="btn btn-success shiny"
                                                       id="frmsubmitbutton" value="Search" onclick="LoadData()" />
                                                <a class="btn btn-maroon dropdown-toggle shiny"
                                                   data-toggle="dropdown" href="javascript:void(0);">
                                                     <i class="fa fa-save"></i> &nbsp;Save &nbsp;<i class="fa fa-angle-down"></i>
                                                </a>
                                                <ul class="dropdown-menu">
                                                    <li>
                                                        <a id="downloadstatement" href="javascript:void(0);">
                                                            <i class="fa fa-file-pdf-o"></i> <?php echo $this->lang->line("PDF"); ?>
                                                        </a>
                                                    </li>
                                                    <li>
                                                        <a id="downloadstatementexcel" href="javascript:void(0);">
                                                            <i class="fa fa-file-excel-o"></i> <?php echo $this->lang->line("EXCEL"); ?>
                                                        </a>
                                                    </li>
                                                </ul>
                                            </div>
                                        </div>
                                        <input type="hidden" name="exporttype" id="exporttype" value="" />
                                        <input type="submit" name="submit" id="frmexportbutton" style="display: none;" />
                                    </form>
                                </div>
                                <div class="flip-scroll" id="datadiv">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!--Jquery Select2-->
<script src="<?php echo base_url();?>assets/js/select2/select2.js"></script>
<!--Bootstrap Date Range Picker-->
<script src="<?php echo base_url();?>assets/js/datetime/moment.js"></script>
<script src="<?php echo base_url();?>assets/js/datetime/daterangepicker.js"></script>
<!-- End Page Content    -->
<script>
    $(".e2").select2({
        placeholder: "<?php echo $this->lang->line("SELECTHEAD"); ?>",
        allowClear: true
    });
    //--Bootstrap Date Range Picker--
    $('#filter_date').daterangepicker({
        locale: {
            format: 'DD-MM-YYYY'
        }
    });
    function LoadData() {
        $(".loading-container").removeClass("loading-inactive");
        $(".loading-container").html('<div style="text-align: center;font-size: 18px;color: #fff;padding-top: 120px;position: absolute;width: 100%;"> Please Wait While Generating Report ... </div><div class="loader"></div>');
        var choosehead      =  $("#choosehead").val();
//        var filter_begin    =  $("#filter_begin").val();
//        var filter_end      =  $("#filter_end").val();
        $.ajax({
            method: "POST",
            url: "<?php echo base_url('finance/plstatement/searchpandltransactions'); ?>",
            data: {
                choosehead: choosehead,
                filter_date:$('#filter_date').val()
//                filter_begin: filter_begin,
//                filter_end: filter_end
            }
        }).done(function (msg) {
            $(".loading-container").addClass("loading-inactive");
            $("#datadiv").html(msg);
        });
    }
    
    $(document).ready(function () {
        LoadData();
        $("#downloadstatement").click(function(){
            $("#exporttype").val('PDF');
            $('#frmexportbutton').click();
        });
        $("#downloadstatementexcel").click(function(){
            $("#exporttype").val('EXCEL');
            $('#frmexportbutton').click();
        });
    });
    
    
    
    
</script>