<script type="text/javascript">
    $(document).ready(function() {
        $('.datetimepicker').datetimepicker({
                viewMode: 'months',
                format: 'DD-MM-YYYY'
            });
        $('.datetimepickerMonthly').datetimepicker({
                viewMode: 'months',
                format: 'MM-YYYY'
            });
        $('.thisYearDatepicker').datetimepicker({
                viewMode: 'years',
                format: 'YYYY'
            });
    });
    function printPreview(){
        $('.printHide').fadeOut("fast",function(){
            $('.printShow').fadeIn('fast');
            $('.content-wrapper').css('backgroundColor','#fff');
            $('.box').addClass('noBorder');
        });
    }

    function goNormal(){
        $('.printShow').fadeOut("fast",function(){
            $('.printHide').fadeIn('fast');
            $('.content-wrapper').css('backgroundColor','#ecf0f5');
            $('.box').removeClass('noBorder');
        });
    }

    function downloadExcel(){
        var url = "<?php echo "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'/'.true; ?>";
        window.location.href = url;
    }
</script>
<style>
    @media print {
        .no-print, .no-print *, #scrollUp, .td-print, .td-print* {
            display: none !important;
        }
		.printTbl {
			width: 98% !important;
		}
		.box-body {
			overflow: hidden !important;
		}
        @page{
            margin: 0;
			padding: 0;
        }
        .compLogo{
            width: 150px;
        }
    }
</style>
<div class="col-md-12">
    <div class=" box box-primary">
        <div class="box-header with-border">
            <label class="box-title"><?php echo $this->lang->line('filter') ?></label>
            <div class="col-lg-12">
                <?php if ($this->session->userdata('admin_master_code') == md5("yes")) : ?>
                <select class="col-lg-4 text-right">
                    <option>Demo Demo Demo Sdn Bhd</option>
                    <option>ABC ENT</option>
                    <option>ABU ENT</option>
                    <option>ALI ENT</option>
                    <option>Ahmed ENT</option>
                    <option>Yusuf ENT</option>
                </select>
                <?php endif; ?>
            </div>
        </div>
        <div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
                <li class="<?php echo ($activeTab==1)?'active':''; ?>">
                    <a href="#tab_1-1" data-toggle="tab" aria-expanded="true">
                    <?php echo $this->lang->line('monthly') ?>
                    </a>
                </li>
                <li class=" <?php echo ($activeTab==2)?'active':''; ?>">
                    <a href="#tab_1-2" data-toggle="tab" aria-expanded="true">
                    <?php echo $this->lang->line('thisLastMonth') ?>
                    </a>
                </li>
                <li class=" <?php echo ($activeTab==3)?'active':''; ?>">
                    <a href="#tab_1-3" data-toggle="tab" aria-expanded="true">
                    <?php echo $this->lang->line('thisYearLastMonth') ?>
                    </a>
                </li>
                <li class="<?php echo ($activeTab==6)?'active':''; ?>">
                    <a href="#tab_1-4" data-toggle="tab" aria-expanded="true">
                    <?php echo $this->lang->line('thisYear') ?>
                    </a>
                </li>
                <li class=" <?php echo ($activeTab==4)?'active':''; ?>">
                    <a href="#tab_1-5" data-toggle="tab" aria-expanded="true">
                    <?php echo $this->lang->line('thisYearLastYear') ?>
                    </a>
                </li>
                <li class=" <?php echo ($activeTab==5)?'active':''; ?>">
                    <a href="#tab_1-6" data-toggle="tab" aria-expanded="true">
                    <?php echo $this->lang->line('custom') ?>
                    </a>
                </li>
            </ul>
            <script type="text/javascript">
                $('document').ready(function(){
                    $('body').on('submit','#monthly-form',function(e){
                        window.location = base_url+"glreports/pnl_month_range/1-"+$('#dateFrom').val()+"/1-"+$('#dateTo').val();
                        e.preventDefault();
                    });
                });
				
				function pnl_month_range(){
					window.location = "<?php echo base_url(); ?>glreports/pnl_month_range/1-"+$('#dateFrom').val()+"/1-"+$('#dateTo').val();
				}
				
            </script>
            <div class="tab-content">
                <div class="tab-pane <?php echo ($activeTab==1)?'active':''; ?>" id="tab_1-1">
                    <!--<form id="monthly-form" class="form-horizontal" action="<?php //echo base_url().'glreports/profitNloss/profit_n_loss_monthly/';  ?>" method="post">-->
                        <fieldset class="fsStyle">
                            <legend class="legendStyle">
                                <a href="javascript:void(0);" data-toggle="collapse" data-target="#filter"><?php echo $this->lang->line('pnltab1') ?> :</a>
                            </legend>
                            <div id="filter" class="row collapse in">
                                <div class="form-group col-sm-5">
                                    <label for="dateFrom" class="col-sm-5 control-label"><?php echo $this->lang->line('dateFrom'); ?>: </label>
                                    <div class="col-sm-7">
                                        <input type="text" class="form-control datetimepickerMonthly" name="dateFrom" id="dateFrom" placeholder="<?php echo $this->lang->line('date'); ?>" value="<?php echo (isset($dateFrom))?date('m-Y',strtotime($dateFrom)):date('m-Y'); ?>">
                                    </div>
                                </div>
                                <div class="form-group col-sm-5">
                                    <label for="dateTo" class="col-sm-5 control-label"><?php echo $this->lang->line('dateTo'); ?>: </label>
                                    <div class="col-sm-7">
                                        <input type="text" class="form-control datetimepickerMonthly" name="dateTo" id="dateTo" placeholder="<?php echo $this->lang->line('date'); ?>" value="<?php echo (isset($dateTo))?date('m-Y',strtotime($dateTo)):date('m-Y'); ?>">
                                    </div>
                                </div>
                                <div class="form-group col-sm-2">
                                    <button type="button" onclick="pnl_month_range()" class="btn btn-primary pull-right"><?php echo $this->lang->line('submit'); ?></button>
                                </div>
                            </div>
                        </fieldset>
                    <!--</form>-->
                </div>
                <!-- /.tab-pane -->
                <!-- PNL for this month and last month -->
                <div class="tab-pane <?php echo ($activeTab==2)?'active':''; ?>" id="tab_1-2">
                    <form id="thisMonthLastMonth" class="form-horizontal" action="<?php echo base_url().'glreports/pnlThisLastMonth';  ?>" method="post">
                        <fieldset class="fsStyle">
                            <legend class="legendStyle">
                                <a href="javascript:void(0);" data-toggle="collapse" data-target="#filter"><?php echo $this->lang->line('pnltab2') ?> :</a>
                            </legend>
                            <div id="filter" class="row collapse in">
                                <div class="form-group col-sm-5">
                                    <label for="dateFrom" class="col-sm-5 control-label"><?php echo $this->lang->line('selectMonth'); ?>: </label>
                                    <div class="col-sm-7">
                                        <input type="text" class="form-control datetimepickerMonthly" name="dateFrom" id="dateFrom" placeholder="<?php echo $this->lang->line('date'); ?>" value="<?php echo (isset($selMonth))?date('m-Y',strtotime($selMonth)):date('m-Y'); ?>">
                                    </div>
                                </div>
                                <div class="form-group col-sm-2">
                                    <button type="submit" class="btn btn-primary pull-right"><?php echo $this->lang->line('submit'); ?></button>
                                </div>
                            </div>
                        </fieldset>
                    </form>
                </div>
                <!-- /.tab-pane -->
                <!-- This year and this month -->
                <div class="tab-pane <?php echo ($activeTab==3)?'active':''; ?>" id="tab_1-3">
                    <form id="thisMonthLastMonth" class="form-horizontal" action="<?php echo base_url().'glreports/pnlThisYearThisMonth';  ?>" method="post">
                        <fieldset class="fsStyle">
                            <legend class="legendStyle">
                                <a href="javascript:void(0);" data-toggle="collapse" data-target="#filter"><?php echo $this->lang->line('pnltab3') ?> :</a>
                            </legend>
                            <div id="filter" class="row collapse in">
                                <div class="form-group col-sm-5">
                                    <label for="dateFrom" class="col-sm-5 control-label"><?php echo $this->lang->line('selectMonth'); ?>: </label>
                                    <div class="col-sm-7">
                                        <input type="text" class="form-control datetimepickerMonthly" name="dateFrom" id="dateFrom" placeholder="<?php echo $this->lang->line('date'); ?>" value="<?php echo (isset($selMonth))?date('m-Y',strtotime($selMonth)):date('m-Y'); ?>">
                                    </div>
                                </div>
                                <div class="form-group col-sm-2">
                                    <button type="submit" class="btn btn-primary pull-right"><?php echo $this->lang->line('submit'); ?></button>
                                </div>
                            </div>
                        </fieldset>
                    </form>
                </div>
                <!-- /.tab-pane -->
                <!-- Get profit and loss according to year selected -->
                <div class="tab-pane <?php echo ($activeTab==6)?'active':''; ?>" id="tab_1-4">
                    <form id="custom-form" class="form-horizontal" action="<?php echo base_url().'glreports/profitNlossYearly';  ?>" method="post">
                        <fieldset class="fsStyle">
                            <legend class="legendStyle">
                                <a href="javascript:void(0);" data-toggle="collapse" data-target="#filter"><?php echo $this->lang->line('pnltab6') ?> :</a>
                            </legend>
                            <div id="filter" class="row collapse in">
                                <div class="form-group col-sm-5">
                                    <label for="year" class="col-sm-5 control-label"><?php echo $this->lang->line('selectYear'); ?>:</label>
                                    <div class="col-sm-7">
                                        <input type="text" class="form-control thisYearDatepicker" name="year" id="year" placeholder="<?php echo $this->lang->line('date'); ?>" value="<?php echo (isset($selectedYear))?date('Y',strtotime($selectedYear)):date('Y'); ?>">
                                    </div>
                                </div>
                                <div class="form-group col-sm-2">
                                    <button type="submit" class="btn btn-primary pull-right"><?php echo $this->lang->line('submit'); ?></button>
                                </div>
                            </div>
                        </fieldset>
                    </form>
                </div>
                <!-- /.tab-pane -->
                <!-- This year and last year -->
                <div class="tab-pane <?php echo ($activeTab==4)?'active':''; ?>" id="tab_1-5">
                    <form id="custom-form" class="form-horizontal" action="<?php echo base_url().'glreports/profit_n_loss_last_year/';  ?>" method="post">
                        <fieldset class="fsStyle">
                            <legend class="legendStyle">
                                <a href="javascript:void(0);" data-toggle="collapse" data-target="#filter"><?php echo $this->lang->line('pnltab4') ?> :</a>
                            </legend>
                            <div id="filter" class="row collapse in">
                                <div class="form-group col-sm-5">
                                    <label for="dateFrom" class="col-sm-5 control-label"><?php echo $this->lang->line('selectYear'); ?>:</label>
                                    <div class="col-sm-7">
                                        <input type="text" class="form-control thisYearDatepicker" name="thisYear" id="thisYear" placeholder="<?php echo $this->lang->line('date'); ?>" value="<?php echo (isset($slctYear))?date('Y',strtotime($slctYear)):date('Y'); ?>">
                                    </div>
                                </div>
                                <div class="form-group col-sm-2">
                                    <button type="submit" class="btn btn-primary pull-right"><?php echo $this->lang->line('submit'); ?></button>
                                </div>
                            </div>
                        </fieldset>
                    </form>
                </div>
                <!-- /.tab-pane -->
                <!-- Custom Profit and loss according to selected date -->
                <div class="tab-pane <?php echo ($activeTab==5)?'active':''; ?>" id="tab_1-6">
                    <form id="custom-form" class="form-horizontal" action="<?php echo base_url().'glreports/pnlCustom/';  ?>" method="post">
                        <fieldset class="fsStyle">
                            <legend class="legendStyle">
                                <a href="javascript:void(0);" data-toggle="collapse" data-target="#filter"><?php echo $this->lang->line('pnltab5') ?> :</a>
                            </legend>&nbsp;
                            <div id="filter" class="row collapse in">
                                <div class="form-group col-sm-5">
                                    <label for="dateFrom" class="col-sm-5 control-label"><?php echo $this->lang->line('dateFrom'); ?>: </label>
                                    <div class="col-sm-7">
                                        <input type="text" class="form-control datetimepicker" name="dateFrom" id="dateFrom" placeholder="<?php echo $this->lang->line('date'); ?>" value="<?php echo (isset($dateFrom))?date('d-m-Y',strtotime($dateFrom)):date('01-m-Y'); ?>">
                                    </div>
                                </div>
                                <div class="form-group col-sm-5">
                                    <label for="dateTo" class="col-sm-5 control-label"><?php echo $this->lang->line('dateTo'); ?>: </label>
                                    <div class="col-sm-7">
                                        <input type="text" class="form-control datetimepicker" name="dateTo" id="dateTo" placeholder="<?php echo $this->lang->line('date'); ?>" value="<?php echo (isset($dateTo))?date('d-m-Y',strtotime($dateTo)):date('t-m-Y'); ?>">
                                    </div>
                                </div>
                                <div class="form-group col-sm-2">
                                    <button type="submit" class="btn btn-primary pull-right"><?php echo $this->lang->line('submit'); ?></button>
                                </div>
                            </div>
                        </fieldset>
                    </form>
                </div>
                <!-- /.tab-pane -->
            </div>
        </div>
    </div>
</div>
