<div class="container-fluid" style="padding-bottom: 2rem;">
    <div class="card bg-light-transparent">
        <div class="card-header bg-white">
            <div class="float-left">
                <h4>Report Summary</h4>
            </div>
            <div class="float-right">
                <a href="<?php echo base_url('hr/Serviceform_report/summary_print')?>" target="_blank" class="btn btn-outline-dark btn-sm" title="Print"><i class="fa fa-print"></i>Print</a>

                <a id="btnShowFilters" type="button" class="btn btn-outline-dark btn-sm collapsed" data-trigger="hover" title="Show Filters Box" data-toggle="collapse" data-target="#collapseFilter" aria-expanded="false"><i class="fas fa-filter"></i>Show Filters</a>
            </div>
        </div>
        <div class="collapse show active" id="collapseFilter">
            <div class="card-header">
                <div class="row">
                    <div class="col">
                        <div class="card no-shadow">
                            <form class="form" action="<?php echo base_url('/hr/serviceform_report/sv_summary_report'); ?>" method="POST" onsubmit="change_btn_class()">
                                <div class="card-body">
                                    <div class="form-group row">
                                        <label for="sv_summary_filter_form" class="col-lg-2">
                                            Booking Form
                                        </label>                           
                                        <div class="col-lg-5" >
                                            <select class="form-control select" name="sv_summary_filter_form" id="sv_summary_filter_form">
                                                <option value="all" selected>[ALL]</option>
                                                <?php if($getBookingName) foreach($getBookingName as $key => $value){ ?>
                                                    <option value="<?php echo $value['id']; ?>" <?php echo (isset($_SESSION['sv_summary_filter_title']) && $_SESSION['sv_summary_filter_title'] != 'all' && $_SESSION['sv_summary_filter_title'] == $value['id'])?'selected':''; ?>><?php echo $value['title'].' - ['.$value['category'].']'; ?></option>
                                                <?php } ?>
                                            </select>
                                        </div>
                                    </div>

                                    <div class="form-group row">
                                        <label for="sv_summary_filter_year" class="col-lg-2">
                                            Year
                                        </label>                           
                                        <div class="col-lg-5" >
                                            <input type="text" name="sv_summary_filter_year" id="sv_summary_filter_year" class="form-control datepicker-yyyy" value="<?php echo (isset($_SESSION['sv_summary_filter_year']))?$_SESSION['sv_summary_filter_year']:date('Y'); ?>">
                                        </div>
                                    </div>
                                    <div class="form-group row">
                                        <label for="sv_summary_filter_month" class="col-lg-2">
                                            Month
                                        </label>                           
                                        <div class="col-lg-5" >
                                            <input type="text" name="sv_summary_filter_month" id="sv_summary_filter_month" class="form-control datepicker-mm" value="<?php echo (isset($_SESSION['sv_summary_filter_month']))?$_SESSION['sv_summary_filter_month']:''; ?>">
                                        </div>
                                    </div>
                                    <div class="row float-right" style="margin-bottom: 1rem;">
                                        <div class="col d-print-none spinner-border">
                                            <button type="submit" class="btn btn-info" id="searchBtn">Search</button>
                                        </div>
                                    </div>
                                </div>
                            </form>    
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="tab-content">
            <div class="tab-pane fade <?php echo (!empty($booking_form))?'active show':''; ?>" id="tableView" role="tabpanel" aria-labelledby="nav-table-tab">
                <div class="card-body">
                    <div class="card no-shadow">
                        <div class="card-body">
                            <div class="row">
                                <div class="col-4 mx-auto py-5 text-center">
                                    <img src="<?php echo base_url('assets/images/logo/salihin-logo.png'); ?>" class="img img-fluid">
                                    <h5 class="text-uppercase mt-3"><b>Service Form Summary <?php echo (!empty($title_month)?date('M',strtotime('01-'.$title_month.'-'.$title_year)):'').' '.$title_year; ?></b></h5>
                                </div>
                            </div>
                            <div class="table-responsive">
                                <table id="filter_table_sv_summary" class="table table-bordered p-0 m-0" width="100%">
                                    <thead>
                                        <th class="text-center">#</th>
                                        <th class="text-center">Service Form</th>
                                        <th class="text-center">Department</th>
                                        <th class="text-center">Total</th>
                                    </thead>

                                    <tbody>
                                        <?php 
                                        $total_pax = 0; 
                                        $total_pending = 0;
                                        $total_in_progress = 0;
                                        $total_approved = 0;
                                        $total_verified = 0;
                                        $total_cancel = 0;
                                        $total_rejected = 0;

                                        if($booking_form) foreach($booking_form as $key => $row){ ?>
                                            <tr>
                                                <td class="text-center"><?php echo $key+1; ?></td>
                                                <td><?php echo $row['title']; ?></td>
                                                <td><?php echo $row['department_name']; ?></td>
                                                <td class="text-center">
                                                    <?php 
                                                        $total_pax += $row['total']; 
                                                        echo $row['total'];
                                                    ?>
                                                </td>
                                            </tr>
                                        <?php } ?>
                                        <tr>
                                            <td style="border-right: none;"></td>
                                            <td style="border-left: none; border-right: none;"></td>
                                            <td style="padding-left: 0px; border-left: none; border-right: none;"><strong>TOTAL</strong></td>
                                            <td class="text-center"><strong><?php echo $total_pax; ?></strong></td>
                                        </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(document).ready(function()
    {
        $('#filter_table_sv_summary').DataTable().destroy();
    });

    function change_btn_class()
    {
        $('#searchBtn').addClass("spinner-border");
        $('#searchBtn').prop('disabled', true);
    }
</script>