<div class="card bg-light-transparent">  
    <div class="card-header bg-white">
        <button id="btnShowFilters" 
            type="button" 
            class="btn btn-outline-dark btn-sm collapsed float-right" 
            data-trigger="hover" title="Show Filters Box" 
            data-toggle="collapse" 
            data-target="#collapseFilter" 
            aria-expanded="false">
            <span class="d-none d-sm-block"><i class="fas fa-filter"></i> Show Filters</span>
            <span class="d-block d-sm-none"><i class="fas fa-filter"></i></span>
        </button>

        <button 
            class="btn btn-outline-dark btn-sm" 
            title="Add New Claim Allocation" 
            data-toggle="modal" 
            data-target="#modal_claim_new" >
            <span class="d-none d-sm-block"><i class="fa fa-plus"></i> Add New Claim Submission</span>
            <span class="d-block d-sm-none"><i class="fa fa-plus"></i></span>
        </button>     
    </div>
    <div class="collapse" id="collapseFilter">
        <div class="card-header">
            <div class="row">
                <div class="col">
                    <div class="card no-shadow">
                        <div class="card-body">
                            <div class="form-group row">
                                <label class="col-lg-3">
                                    Year
                                </label>                           
                                <div class="col-lg-4" >
                                    <select class="custom-select" id="filter_year">
                                        <?php if(!empty($filter_years)) foreach($filter_years as $filter): ?>
                                        <option value="<?php echo $filter->year; ?>" <?php echo ($filtered_year == $filter->year)?'selected':''; ?>><?php echo $filter->year; ?></option>
                                        <?php endforeach; ?>
                                        <!-- <option value="">All</option> -->
                                    </select>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col d-print-none">
                                    <button class="btn btn-info" id="searchBtn">Search</button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div> 
    <div class="card-body">
        <div class="card no-shadow">

            <div class="card-body d-none d-sm-block">
                <div class="table-responsive">
                    <table class="table table-hover table-bordered" id="example" width="100%">
                        <thead>
                            <tr>
                                <th>No</th>
                                <th class="text-center">Year</th>
                                <th class="text-center">Submission Month</th>
                                <th class="text-center">Total Claim</th>
                                <th class="text-center">Total Approve</th>
                                <th class="text-center">Status</th>
                                <th class="text-center">Action</th>
                            </tr>
                        </thead>
                        <tbody>
                        
                                <?php if(!empty($claims)) foreach($claims as $key => $claim): ?>
                                    <tr>
                                        <td>
                                                <?php echo ++$key; ?>
                                        </td>
                                        <td>
                                                <?php echo $claim->year; ?>
                                        </td>
                                        <td>
                                            <?php echo date('F',mktime(0,0,0,$claim->month,1)); ?>
                                        </td>
                                        <td>
                                            <?php
                                                $total_claim = $claim->dental_claim
                                                            +$claim->hospitalization_claim
                                                            +$claim->meals_claim
                                                            +$claim->medical_screening_claim
                                                            +$claim->mileage_claim
                                                            +$claim->others_claim
                                                            +$claim->outpatient_claim
                                                            +$claim->travelling_mileage_claim
                                                            +$claim->travelling_mileage_claim_item
                                                            +$claim->accomodation_claim
                                                            +$claim->subsistence_claim
                                                            +$claim->transportation_claim
                                                            +$claim->parking_claim
                                                            +$claim->toll_claim
                                                            +$claim->trainer_claim
                                                            +$claim->panel_claim                //todo: panel claim removed as requested from zaidah
                                                            +$claim->petrol_claim
                                                            +$claim->entertainment_claim_amount
                                                            +$claim->dressing_claim
                                                            +$claim->gadget_claim;
                                                echo 'RM '.number_format($total_claim,2);
                                            ?>
                                        </td>
                                        <td>
                                        <?php
                                                $total_claim = $claim->dental_approved
                                                            +$claim->hospitalization_approved
                                                            +$claim->meals_approved
                                                            +$claim->medical_screening_approved
                                                            +$claim->mileage_approved
                                                            +$claim->others_approved
                                                            +$claim->outpatient_approved
                                                            +$claim->travelling_mileage_approved
                                                            +$claim->travelling_item_approved
                                                            +$claim->accomodation_claim_approved
                                                            +$claim->subsistence_claim_approved
                                                            +$claim->transportation_claim_approved
                                                            +$claim->parking_claim_approved
                                                            +$claim->toll_claim_approved
                                                            +$claim->trainer_claim_approved
                                                            +$claim->panel_claim                //todo: panel claim removed as requested from zaidah
                                                            +$claim->petrol_claim_approved
                                                            +$claim->entertainment_claim_amount_approved
                                                            +$claim->dressing_approved
                                                            +$claim->gadget_approved;
                                                echo 'RM '.number_format($total_claim,2);
                                            ?> 
                                        </td>
                                        <td>
                                            <?php if($claim->is_submit == 1): ?>
                                                <span class="badge badge-primary" data-trigger="hover" data-tooltip="tooltip" title="" data-placement="bottom" data-original-title="Required HOD approval, Waiting for admin processed" >Submitted</span>
                                            <?php else: ?>
                                                
                                                <?php if ($claim->status == 0): ?>
                                                    <span class="badge badge-secondary" data-trigger="hover" data-tooltip="tooltip" title="" data-placement="bottom" data-original-title="Unsubmitted Claim">Draft</span>
                                                <?php endif ?>

                                                <?php if ($claim->status == 2): ?>
                                                    <span class="badge badge-danger" data-trigger="hover" data-tooltip="tooltip" title="" data-placement="bottom" data-original-title="Unsubmitted Claim, overdue submission date">Not submitted</span>
                                                <?php endif ?>

                                            <?php endif; ?>

                                        </td>
                                        <td class="text-center">
                                            <div class="btn-group">
                                                <a href="<?php echo base_url().'hr/claim_v2/myClaimDetail/'.$claim->year.'/'.$claim->month.'/'.$_SESSION['user']['id'].'/'.$claim->id; ?>" class="btn btn-primary btn-sm" data-trigger="hover" data-tooltip="tooltip" title="" data-original-title="View claim" target="_blank" >
                                                    <i class="fas fa-sign-in-alt"></i>
                                                </a>
                                            </div>
                                        </td>
                                    </tr>
                                <?php endforeach?>
                        
                        </tbody>
                    </table>
                </div>
            </div>
            
            <div class="card-body d-block d-sm-none">
                

            <?php if(!empty($claims)) foreach($claims as $key => $claim): ?>
                <div class="row">
                    <div class="col-12 mb-3">
                        <strong class="text-uppercase">Year</strong><br>
                        <?php echo $claim->year; ?>
                    </div>
                </div>

                <div class="row">
                    <div class="col-12 mb-3">
                        <strong class="text-uppercase">Submission month</strong><br>
                        <?php echo date('F',mktime(0,0,0,$claim->month,1)); ?>
                    </div>
                </div>

                <div class="row">
                    <div class="col-12 mb-3">
                        <strong class="text-uppercase">Total claim</strong><br>
                        <?php
                        $total_claim = $claim->dental_claim
                                    +$claim->hospitalization_claim
                                    +$claim->meals_claim
                                    +$claim->medical_screening_claim
                                    +$claim->mileage_claim
                                    +$claim->others_claim
                                    +$claim->outpatient_claim
                                    +$claim->travelling_mileage_claim
                                    +$claim->travelling_mileage_claim_item
                                    +$claim->accomodation_claim
                                    +$claim->subsistence_claim
                                    +$claim->transportation_claim
                                    +$claim->parking_claim
                                    +$claim->toll_claim
                                    +$claim->trainer_claim
                                    +$claim->panel_claim                                    //todo: panel claim removed as requested from zaidah
                                    +$claim->petrol_claim
                                    +$claim->entertainment_claim_amount
                                    +$claim->dressing_amount
                                    +$claim->gadget_amount;
                        echo 'RM '.number_format($total_claim,2); ?>
                    </div>
                </div>
                
                <div class="row">
                    <div class="col-12 mb-3">
                        <strong class="text-uppercase">Total approve</strong><br>
                        <?php
                            $total_claim = $claim->dental_approved
                                        +$claim->hospitalization_approved
                                        +$claim->meals_approved
                                        +$claim->medical_screening_approved
                                        +$claim->mileage_approved
                                        +$claim->others_approved
                                        +$claim->outpatient_approved
                                        +$claim->travelling_mileage_approved
                                        +$claim->travelling_item_approved
                                        +$claim->accomodation_claim_approved
                                        +$claim->subsistence_claim_approved
                                        +$claim->transportation_claim_approved
                                        +$claim->parking_claim_approved
                                        +$claim->toll_claim_approved
                                        +$claim->trainer_claim_approved
                                        +$claim->panel_claim                //todo: panel claim removed as requested from zaidah
                                        +$claim->petrol_claim_approved
                                        +$claim->entertainment_claim_amount_approved
                                        +$claim->dressing_approved
                                        +$claim->gadget_approved;
                            echo 'RM '.number_format($total_claim,2);
                        ?> 
                    </div>
                </div>

                <div class="row">
                    <div class="col-12 mb-3">
                        <strong class="text-uppercase">Action</strong><br>
                        <a href="<?php echo base_url().'hr/claim_v2/myClaimDetail/'.$claim->year.'/'.$claim->month.'/'.$_SESSION['user']['id'].'/'.$claim->id; ?>" class="btn btn-primary btn-sm" data-trigger="hover" data-tooltip="tooltip" title="" data-original-title="View claim" target="_blank" >
                                                    <i class="fas fa-sign-in-alt"></i>
                                                </a>
                    </div>
                </div>
                <hr>
                <?php endforeach; ?>

            </div>

        </div>
    </div>  
</div>

<script>
    $(document).ready(function(){
        $('#searchBtn').click(function(){
            let year = $('#filter_year').val();
            let url  = '<?php echo base_url('hr/claim_v2/myClaimList/'); ?>'+year;
            location.href= url;
        });
    });
</script>