<style>
    /* #map {height: 300px;} */
    tr:hover
    {
        cursor: pointer;
    }
    .dot{
        border:.5px solid #dedede;
        border-radius:25px;
        padding:5px;
        padding-top:1px;
        padding-bottom:1px;
        color:#000 !important;
        box-shadow: 0 1px 4px 0 rgba(0, 0, 0, 0.2), 0 3px 10px 0 rgba(0, 0, 0, 0.19);
    }
</style>
<?php
    $bg     = 'bg-dark';
    $mode   = 'My Claim List';
    if(!empty($screen_mode))
    {
        if($screen_mode == 'admin')
        {
            $bg     = 'bg-secondary';
            $mode   = 'Admin Approval';
        }elseif($screen_mode == 'hod')
        {
            $bg     = 'bg-secondary';
            $mode   = 'HOD Claim review';
        }
    }
?>
<section class="" style="padding-bottom: 2rem;" id="content_section">
	<div class="card bg-light-transparent">  

        <div class="card-header <?php echo $bg; ?> text-white">
            
            
            <div class="text-right">
                <?php $this->load->view('hr/claim/page/claimdetail/button'); ?>
                <h5>
                    <?php echo $mode; ?>
                </h5>
            </div>

            <div class="row">
                <div class="col-lg-6">
                    <div class="row">
                        <div class="col-lg-4">
                            Name : 
                        </div>
                        <div class="col">
                            <input type="text" class="form-control" value="<?php echo (!empty($claims_user))?$claims_user['name']:''; ?>" disabled/>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6">
                    <div class="row">
                        <div class="col-lg-4">
                            Department : 
                        </div>
                        <div class="col">
                            <input type="text" class="form-control" value="<?php echo (!empty($claims_user))?$claims_user['department_name']:''; ?>" disabled/>
                        </div>
                    </div>
                </div>
            </div>

            <br/>
            <div class="row">
                <div class="col-lg-6">
                    <div class="row">
                        <div class="col-lg-4">
                          Submission Month :   
                        </div>
                        <div class="col">
                            <input type="text" class="form-control" value="<?php echo date('F',strtotime('01-'.$month.'-'.$year))?>" disabled/>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6">
                    <div class="row">
                        <div class="col-lg-4">
                            Submission Year : 
                        </div>
                        <div class="col">
                            <input type="text" class="form-control" value="<?php echo date('Y',strtotime('01-'.$month.'-'.$year))?>" disabled/>
                        </div>
                    </div>
                </div>
            </div>
            <hr/>
            <div class="row">
                <div class="col">
                    <h4>Prorate for submission (<?php echo date('F-Y',strtotime('01-'.$month.'-'.date('Y'))); ?>)</h4>
                </div>
            </div>
            
            <div class="row">
                <div class="col p-3 mx-1" style="border:0.5px solid #ccc;border-radius:5px;">
                    <h4>Dental / Optical</h4>
                    <p>
                        <div class="row">
                            <div class="col">
                                <span class="text-success"><?php echo date('F Y',strtotime('01-'.$second_month.'-'.$second_year)); ?></span> <br/>
                                RM <?php echo (!empty($second_prorate_dental))?number_format($second_prorate_dental,2):0.00; ?>
                                <br>
                                <small>Balance : RM<?php echo (!empty($second_dental_balance))?number_format($second_dental_balance):0.00; ?> </small>
                            </div>
                            <div class="col">
                                <span class="text-success"><?php echo date('F Y',strtotime('01-'.$first_month.'-'.$first_year)); ?></span> <br>
                                RM <?php echo (!empty($first_prorate_dental))?number_format($first_prorate_dental,2):0.00; ?>
                                <br>
                                <small>Balance : RM<?php echo (!empty($first_dental_balance))?number_format($first_dental_balance,2):0.00; ?></small>
                            </div>
                        </div>
                    </p>
                </div>
                <div class="col p-3 mx-1" style="border:0.5px solid #ccc;border-radius:5px;">
                    <h4>Hospitalization</h4>
                    <p>
                      <div class="row">

                        <?php if($second_year != $first_year): ?>
                        <div class="col">
                            <span class="text-success"><?php echo $second_year; ?></span> <br>
                            RM <?php echo (!empty($second_hospitalization_prorate))?$second_hospitalization_prorate:0.00; ?>
                            <br>
                            <small>Balance : RM <?php echo $second_hospitalization_balance; ?></small>
                        </div>
                        <?php endif; ?>

                        <div class="col">
                            <span class="text-success"><?php echo $first_year; ?></span> <br>
                            RM <?php echo (!empty($first_hospitalization_prorate))?$first_hospitalization_prorate:0.00; ?>
                            <br>
                            <small>Balance : RM <?php echo $first_hospitalization_balance; ?></small>
                        </div>
                      </div>
                    </p>
                </div>
                <div class="col p-3 mx-1" style="border:0.5px solid #ccc;border-radius:5px;">
                    <h4>Outpatient</h4>
                    <p>
                        <div class="row">
                            <div class="col">
                                <span class="text-success"><?php echo date('F Y',strtotime('01-'.$second_month.'-'.$second_year)); ?></span> <br>
                                RM <?php echo (!empty($second_prorate_outpatient))?number_format($second_prorate_outpatient,2):0.00; ?>
                                <br>
                                <small>Balance : RM <?php echo (!empty($second_outpatient_balance))?number_format($second_outpatient_balance,2):0.00; ?></small>
                            </div>
                            <div class="col">
                                <span class="text-success"><?php echo date('F Y',strtotime('01-'.$first_month.'-'.$first_year)); ?></span> <br>
                                RM <?php echo (!empty($first_prorate_outpatient))?number_format($first_prorate_outpatient,2):0.00; ?>
                                <br>
                                <small>Balance : RM <?php echo (!empty($first_outpatient_balance))?number_format($first_outpatient_balance,2):0.00; ?></small>
                            </div>
                        </div>
                    </p>
                </div>
            </div>

            <div class="row">
                <div class="col text-right">
                    <?php $this->load->view('hr/claim/page/claimdetail/button2'); ?>            
                </div>
            </div>

        </div>

        <?php if(!empty($screen_mode) && $screen_mode == 'hod'):?>
        <div class="card-body">
            <div class="card no-shadow">
                <div class="card-body">
                    
                    <div class="row">
                        <div class="col text-right pr-4">
                            <form action="<?php echo base_url('/hr/claim/hodApprove/'); ?>" method="post" id="hodApprove">
                                <button class="btn btn-success" type="submit" data-trigger="hover" data-tooltip="tooltip" title="" data-original-title="Approve all">
                                    <i class="fas fa-thumbs-up" style="transform: scaleX(-1);"></i>
                                </button>
                                <button class="btn btn-danger" type="button" data-trigger="hover" data-tooltip="tooltip" title="" data-original-title="Reject all">
                                    <i class="fas fa-thumbs-down"></i>
                                </button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <?php endif ?>
        

        <!-- claim summary -->
        <div class="card-footer bg-white">
            <h5>Summary Claim for <?php echo date('F Y',strtotime('01-'.$month.'-'.$year)) ?></h5>
            <div class="table-responsive">
                <table class="table table-hover table-bordered p-0 m-0" width="100%">
                    <thead>
                        <tr>
                            <th class="text-center">#</th>
                            <th class="text-center">Type</th>
                            <th class="text-center">Total Claim (RM)</th>
                            <th class="text-center">Total Approved (RM)</th>
                        </tr>
                    </thead>
                    <tbody>

                        <tr>
                            <td>1</td> 
                            <td>Mileage</td> 
                            <?php
                                $mileage_claim = 0;
                                $mileage_approved = 0;
                                        
                                if(!empty($travels)) foreach($travels as $key => $value)
                                {
                                    $mileage_claim += $value->mileage_amount;
                                    $mileage_approved += $value->mileage_amount_approved;
                                }
                            ?>
                            <td class="text-right"><?php echo number_format($mileage_claim,2); ?></td>
                            <td class="text-right"><?php echo number_format($mileage_approved,2); ?></td>
                        </tr>

                        <tr>
                            <td>2</td>
                            <td>Accomodation</td>

                            <?php
                                $accomodation_claim = 0;
                                $accomodation_approved = 0;

                                if(!empty($accomodation)) foreach($accomodation as $key => $value)
                                {
                                    $accomodation_claim += $value->amount;
                                    $accomodation_approved += $value->amount_approved;
                                }
                            ?>
                            <td class="text-right">
                                <?php echo number_format($accomodation_claim,2); ?>
                            </td>
                            <td class="text-right">
                                <?php echo number_format($accomodation_approved,2); ?>
                            </td>
                        </tr>
                        
                        <?php
                            $meal_allowance = 0;
                            $meal_approved = 0;
                            
                            $outstation_allowance = 0;
                            $outstation_approved = 0;
                            
                            $travel_allowance = 0;
                            $travel_approved = 0;

                            if(!empty($subsistence)) foreach($subsistence as $key => $value)
                            {
                                if($value->allowance == 'OUTSTATION')
                                {
                                    $outstation_allowance += $value->amount;
                                    $outstation_approved += $value->amount_approved;
                                }

                                if($value->allowance == 'MEALS')
                                {
                                    $meal_allowance += $value->amount;
                                    $meal_approved += $value->amount_approved;
                                }

                                if($value->allowance == 'TRAVEL')
                                {
                                    $travel_allowance += $value->amount;
                                    $travel_approved += $value->amount_approved;
                                }
                            }
                        ?>


                        <tr>
                            <td>3</td>
                            <td>Subsistence Allowance - Meal</td>
                            <td class="text-right"><?php echo number_format($meal_allowance,2); ?></td>
                            <td class="text-right"><?php echo number_format($meal_approved,2); ?></td>
                        </tr>
                        
                        <tr>
                            <td>4</td>
                            <td>Subsistence Allowance - Outstation </td>
                            <td class="text-right"><?php echo number_format($outstation_allowance,2); ?></td>
                            <td class="text-right"><?php echo number_format($outstation_approved,2); ?></td>
                        </tr>
                        
                        
                        <tr>
                            <td>5</td>
                            <td>Subsistence Allowance - Travel </td>
                            <td class="text-right"><?php echo number_format($travel_allowance,2); ?></td>
                            <td class="text-right"><?php echo number_format($travel_approved,2); ?></td>
                        </tr>

                        <tr>
                            <td>6</td>
                            <td>Transportation</td>
                            <?php
                                $transportation_claim = 0;
                                $transportation_approved = 0;
                                foreach($transportation as $key => $value)
                                {
                                    $transportation_claim += $value->amount;
                                    $transportation_approved += $value->amount_approved;
                                }
                            ?>
                            <td class="text-right"><?php echo number_format($transportation_claim,2); ?></td>
                            <td class="text-right"><?php echo number_format($transportation_approved,2); ?></td>
                        </tr>

                        <tr>
                            <td>7</td>
                            <td>Parking</td>
                            <?php
                                $parking_claim = 0;
                                $parking_approved = 0;
                                if(!empty($parking)) foreach($parking as $key => $value)
                                {
                                    $parking_claim += $value->amount;
                                    $parking_approved += $value->amount_approved;
                                }
                            ?>
                            <td class="text-right"><?php echo number_format($parking_claim,2); ?></td>
                            <td class="text-right"><?php echo number_format($parking_approved,2); ?></td>
                        </tr>
                        
                        <tr>
                            <td>8</td>
                            <td>Toll</td>
                            <?php
                                $toll_claim = 0;
                                $toll_approved = 0;
                                if(!empty($toll)) foreach($toll as $key => $value)
                                {
                                    $toll_claim += $value->amount;
                                    $toll_approved += $value->amount_approved;
                                }
                            ?>
                            <td class="text-right"><?php echo number_format($toll_claim,2); ?></td>
                            <td class="text-right"><?php echo number_format($toll_approved,2); ?></td>
                        </tr>
                        

                        <tr>
                            <td>9</td> 
                            <td>Outpatient</td>
                            <?php 
                                $outpatient_claim   = 0;
                                $outpatient_approve = 0;
                                $medical_claim   = 0;
                                $medical_approve = 0;

                                if(!empty($outpatients)) foreach ($outpatients as $key => $outpatient) {
                                    
                                    if ($outpatient->is_medical == 0) 
                                    {
                                        $outpatient_claim   += $outpatient->amount_claim;
                                    }else
                                    {
                                        $medical_claim += $outpatient->amount_claim;
                                    }

                                    if ($outpatient->is_approve == 1 && $outpatient->is_medical == 0)
                                    {
                                        $outpatient_approve += $outpatient->amount_approved;
                                    }else
                                    {
                                        $medical_approve += $outpatient->amount_approved;
                                    }
                                    
                                }
                            ?>
                            <td class="text-right"><?php echo number_format($outpatient_claim,2); ?></td> 
                            <td class="text-right"><?php echo number_format($outpatient_approve,2);?></td>
                        </tr>
                        <tr>
                            <td>10</td> 
                            <td>Hospitalzation</td>
                            <?php 
                                $hospitalization_claim   = 0;
                                $hospitalization_approve = 0;
                                if(!empty($hospitalizations)) foreach ($hospitalizations as $key => $hospitalization) 
                                {
                                    $hospitalization_claim   += $hospitalization->amount_claim;
                                    if ($hospitalization->is_approve == 1) {
                                        $hospitalization_approve += $hospitalization->amount_approved;
                                    }
                                }
                             ?>
                            <td class="text-right"><?php echo number_format($hospitalization_claim,2); ?></td> 
                            <td class="text-right"><?php echo number_format($hospitalization_approve,2); ?></td>
                        </tr>
                        <tr>
                            <td>11</td> 
                            <td>Dental / Optical</td>
                            <?php 
                                $dental_claim   = 0;
                                $dental_approve = 0;
                                if($dentals) foreach ($dentals as $key => $dental) 
                                {
                                    $dental_claim   += $dental->amount_claim;
                                    if ($dental->is_approve == 1) {
                                        $dental_approve += $dental->amount_approved; 
                                    }
                                }
                             ?>
                            <td class="text-right"><?php echo number_format($dental_claim,2); ?></td> 
                            <td class="text-right"><?php echo number_format($dental_approve,2); ?></td>
                        </tr>
                        
                        <tr>
                            <td>12</td>
                            <td>Trainer / Facilitator</td>
                            <?php
                                $trainer_claim     = 0;
                                $trainer_approve   = 0;
                                if(!empty($trainers)) foreach($trainers as $key => $trainer)
                                {
                                    $trainer_claim += $trainer->amount;
                                    if($trainer->is_admin_approve == 1){
                                        $trainer_approve += $trainer->amount_approved;
                                    }
                                }
                            ?>
                            <td class="text-right">
                                <?php echo number_format($trainer_claim,2); ?>
                            </td>
                            <td class="text-right">
                                <?php echo number_format($trainer_approve,2); ?>
                            </td>
                        </tr>

                        <tr>
                            <td>13</td> 
                            <td>Others</td>
                            <?php 
                                $other_claim   = 0;
                                $other_approve = 0;
                                if($others) foreach ($others as $key => $other) {
                                    $other_claim   += $other->amount_claim;
                                    if ($other->is_approve == 1) {
                                        $other_approve += $other->amount_approved; 
                                    }
                                }
                             ?>
                            <td class="text-right"><?php echo number_format($other_claim,2); ?></td> 
                            <td class="text-right"><?php echo number_format($other_approve,2); ?></td>
                        </tr>
                        
                        
                    </tbody>
                    <tfoot>
                        <tr>
                            <th class="text-center">#</th>
                            <th class="text-center">Total</th>
                            <th class="text-right">
                                <?php 
                                    $total_claim = $outpatient_claim 
                                                    + $hospitalization_claim 
                                                    + $dental_claim 
                                                    + $mileage_claim 
                                                    + $other_claim 
                                                    + $accomodation_claim 
                                                    + $transportation_claim
                                                    + $parking_claim
                                                    + $toll_claim
                                                    + $outstation_allowance
                                                    + $meal_allowance
                                                    + $travel_allowance
                                                    + $trainer_claim;
                                    echo number_format($total_claim,2); 
                                ?>
                            </th>
                            <th class="text-right">
                                <?php 
                                    $total_approved = $outpatient_approve 
                                                        + $hospitalization_approve 
                                                        + $dental_approve 
                                                        + $other_approve 
                                                        + $mileage_approved
                                                        + $accomodation_approved 
                                                        + $transportation_approved 
                                                        + $parking_approved
                                                        + $toll_approved
                                                        + $outstation_approved
                                                        + $meal_approved
                                                        + $travel_approved
                                                        + $trainer_approve;
                                    echo number_format($total_approved,2); 
                                ?>
                            </th>
                        </tr>
                    </tfoot>
                </table>
            </div>

        </div>
        <!-- claim summary -->

    </div>
</section> 


<?php if(empty($screen_mode)): ?>
    <!-- Modal claim type -->
    <div class="modal fade" id="modal_claim_type" role="dialog" aria-hidden="true">
        <div class="modal-dialog modal-lg">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLongTitle">Select claim type</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <div class="row form-group">
                        <div class="col-lg-3">
                            <label for="claim_type">Claim type</label>
                        </div>
                        <div class="col">
                            <select class="form-control select" name="claim_type" id="claim_type">
                                <option value="-1" selected disabled>Select claim type</option>
                                <?php if(!empty($claimType)) foreach($claimType as $key => $row): ?>
                                <option value="<?php echo $row['ID'] ?>" data-link="<?php echo base_url($row['form_location']); ?>"><?php echo $row['code'] ?></option>
                                <?php endforeach ?>                                      
                            </select>
                        </div>
                        <div class="col-lg-1">
                            <div class="btn-group float-right">
                                <a onclick="openClaimForm()" class="btn btn-info"><div class="text-white">Next</div></a>
                            </div>
                        </div>
                    </div>  
                </div>
            </div>
        </div>
    </div>
    <!-- Modal claim type -->
<?php endif ?>

<?php if(!empty($screen_mode)): ?>
    <?php if($screen_mode == 'admin'): ?>
        <!-- modal approve -->
        <div class="modal fade" id="mdl_approve" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">Approves</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>

                    <form class="form" id="approveForm">
                        <div class="modal-body container"> 
                            <div class="row form-group">
                                <div class="col">
                                    <label><b>Amount Claim</b></label>
                                    <div class="input-group mb-3">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text bg-light">RM</span>
                                    </div>
                                    <input type="number" name="amount_claim" id="approveAmountClaim" class="form-control bg-light" placeholder="0.00" disabled>
                                        <div class="input-group-prepend">
                                            <button type="button" id="btn-toRight" class="btn btn-success">
                                                <i class="fas fa-arrow-right"></i>
                                            </button>
                                    </div>
                                    </div>

                                </div>
                                <div class="col">
                                    <label><b>Amount Approved</b></label>
                                    <div class="input-group mb-3">
                                    <div class="input-group-prepend">
                                        <span class="input-group-text bg-light">RM</span>
                                    </div>
                                    <input type="number" name="amount_approve" id="approveAmountApprove" class="form-control" placeholder="0.00" min="0" onchange="checkProrate()" onkeyup="checkProrate()" >
                                    </div>
                                </div>
                            </div>
                            
                            <div class="row form-group">
                                <div class="col-lg-6">
                                    <label><b>Status</b></label>
                                    <select class="form-control" name="status" id="approveStatus">
                                        <option value="0">Draft </option>
                                        <option value="1">Approve</option>
                                        <option value="2">Rejected</option>
                                    </select>
                                </div>
                                <div class="col">
                                    <input type="hidden" name="approve_id" class="form-control" id="approveId">
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <div class="btn-group">
                                <a href="#" class="btn btn-info" data-placement="top" title="Edit OT" data-dismiss="modal"><i class="fas fa-ban"></i> Cancel</a>
                                <button type="submit" id="btn-saveApprove" data-rqtarget="" class="btn btn-success" data-toggle="tooltip" data-placement="top" title="Approve Claim">
                                    <i class="fas fa-save"></i> Save
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <!-- modal approve -->

        <!-- modal approve -->
        <div class="modal fade" id="mdl_paid" role="dialog" aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title">Approve</h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>

                    <form class="form" id="" action="<?php echo base_url('/hr/claim/claimPaid/'); ?>" method="post">
                        <div class="modal-body container"> 
                            <div class="row form-group">
                                <div class="col">
                                    <label><b>Amount Approved</b></label>
                                    <div class="input-group mb-3">
                                        <div class="input-group-prepend">
                                            <span class="input-group-text bg-light">RM</span>
                                        </div>
                                        <?php 
                                            $approved_outpatient        = (!empty($outpatient_approve))?$outpatient_approve:0 ;
                                            $approved_hospitalization   = (!empty($hospitalization_approve))?$hospitalization_approve:0;
                                            $approved_dental            = (!empty($dental_approve))?$dental_approve:0;
                                            $approved_medical           = (!empty($medical_approve))?$medical_approve:0;
                                            $approved_mileage           = (!empty($mileage_approve))?$mileage_approve:0;
                                            $approved_travel            = (!empty($travel_approve))?$travel_approve:0;
                                            $approved_meal              = (!empty($meal_approve))?$meal_approve:0;
                                            $approved_other             = (!empty($other_approve))?$other_approve:0;

                                            $approve_amount             =  number_format($approved_outpatient+$approved_hospitalization+$approved_dental+$approved_medical+$approved_mileage+$approved_travel+$approved_meal+$approved_other,2); 
                                        
                                        ?>
                                        <input type="number" name="amount_claim" id="mdlPaid_amount_approve" class="form-control bg-light" placeholder="0.00" value="<?php echo $approve_amount; ?>" disabled>
                                        <div class="input-group-prepend">
                                            <button type="button" id="mdlPaid_transfer" class="btn btn-success">
                                                <i class="fas fa-arrow-right"></i>
                                            </button>
                                        </div>
                                    </div>
                                </div>

                                <div class="col">
                                    <label><b>Amount Paid</b></label>
                                    <div class="input-group mb-3">
                                        <div class="input-group-prepend">
                                            <span class="input-group-text bg-light">RM</span>
                                        </div>
                                        <input type="number" name="amount_paid" id="mdlPaid_amount_paid" class="form-control" placeholder="0.00" value="<?php echo $approve_amount; ?>">
                                    </div>
                                </div>
                            </div>
                            <div class="row d-none">
                                <label><b>Claim Id </b></label>
                                <div class="input-group mb-3">
                                   <input type="text" name="claim_id" class="form-control" value="<?php echo $claim_id;?>">
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <div class="btn-group">
                                <a href="#" class="btn btn-info" data-placement="top" title="Edit OT" data-dismiss="modal"><i class="fas fa-ban"></i> Cancel</a>
                                <button type="submit" data-rqtarget="" class="btn btn-success" data-toggle="tooltip" data-placement="top" title="Approve Claim">
                                    <i class="fas fa-save"></i> Save
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
        <!-- modal approve -->
    <?php endif ?>

    <?php if($screen_mode == 'hod'):?>
        <!-- modal reject -->
        <div class="modal" id="rejectModal">
            <div class="modal-dialog">
                <div class="modal-content">
                <form action="<?php echo base_url('hr/claim/hodReject'); ?>" method="post">

                    <!-- Modal Header -->
                    <div class="modal-header">
                        <h4 class="modal-title">Reject Claim</h4>
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                    </div>

                    <!-- Modal body -->
                    <div class="modal-body">
                        <div class="row">
                            <div class="col">
                                <!-- id -->
                                <input type="hidden" name="id" class="form-control" placeholder="id" id="hdR_id">
                                <!-- claim id -->
                                <input type="hidden" name="claim_id" class="form-control" placeholder="claim id" id="hdR_claim_id"/>
                                <!-- mode -->
                                <input type="hidden" name="mode" class="form-control" placeholder="mode" id="hdR_mode">
                                <label><b>Reason</b></label><br>
                                <textarea name="reason" id="hdR_reason" rows="10" class="form-control" placeholder="Please Specify Reason for Claim Rejection" style="resize:none;"></textarea>
                            </div>
                        </div>
                    </div>

                    <!-- Modal footer -->
                    <div class="modal-footer btn-group">
                        <button type="submit" class="btn btn-success">Submit</button>                    
                        <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                    </div>

                </form>
                </div>
            </div>
        </div>
        <!-- modal reject -->
    <?php endif ?>
<?php endif ?>

<script>
    var isContainer = true;

    $(document).ready(function()
    {
        <?php if(!empty($screen_mode)): ?>
            <?php if($screen_mode == 'hod' ): ?>
                $('#hodApprove').submit(function(event)
                {
                    event.preventDefault();
                    toastConfirm('Click yes to approve all claim for this submission',function(){
                        let data = 
                        {
                            year : <?php echo $this->uri->segment(4); ?>,
                            month: <?php echo $this->uri->segment(5); ?>,
                            user_id: <?php echo $this->uri->segment(6); ?>,
                            claim_id: <?php echo $this->uri->segment(7); ?>,
                            status: '1',
                        }
                        ajxRequest('<?php echo base_url('/hr/claim/hodApprove/'); ?>', 'POST', data, '<?php echo current_url(); ?>');
                    });
                });
            <?php endif ?>

            <?php if($screen_mode == 'admin' ): ?>
                
                $('#btn-saveApprove').click(function(event)
                {
                    event.preventDefault();
                    var serialize = formIdToInputObject('#approveForm');
                    serialize.token = '<?php echo $_SESSION['token']; ?>';
                                
                    var locate = $(this).data('rqtarget');
                    var redirect    = '<?php echo current_url(); ?>';
                    ajxRequest(locate,'POST',serialize,redirect);
                });


                $('#btn-toRight').click(function()
                {
                    var amount_claim = $('#approveAmountClaim').val();
                    $('#approveAmountApprove').val(amount_claim);
                });

                $('#mdlPaid_transfer').click(function()
                {
                    let amount_approve = $('#mdlPaid_amount_approve').val();
                    $('#mdlPaid_amount_paid').val(amount_approve);
                });

                $('#paidClaim').submit(function(event)
                {
                    event.preventDefault();
                    toastConfirm('Are you sure you want to set this to complete',function()
                    {
                        $('#mdl_paid').modal();
                    });
                });
            <?php endif ?>
        <?php endif ?>
    });


    <?php if($screen_mode == 'admin' ): ?>
        //admin approval claim button
        //fill up modal form
        function approveClaim(elem)
        {
            toastConfirm('You are going to approve this claim and will require to enter approved amount',function(){
                $('#approveForm').trigger("reset");
                $('#mdl_approve').modal('toggle');

                var amount_claim = $(elem).data('price');
                var mileage_claim= $(elem).data('mileage');

                //only for travelling situation 
                if(!mileage_claim)
                {
                    mileage_claim = 0;
                }

                var amount_claim = parseFloat(amount_claim) + parseFloat(mileage_claim);

                var url          = '<?php echo base_url('hr/api/claim/');?>'+$(elem).data('rqtarget');
                var status       = $(elem).data('status');
                var id           = $(elem).data('id');

                var allocation   = $(elem).data('allocation');
                var balanced     = $(elem).data('balanced'); 

                $('#btn-saveApprove').attr('data-rqtarget',url);
                $('#approveId').val(id);
                $('#approveAmountClaim').val(amount_claim);
                $('#approveStatus').val(status);
                
                $('#mdl-allocation').html('RM'+allocation);
                $('#mdl-prorateBalanced').html('RM'+balanced);
            });
        }

        
    <?php else: ?>
        <?php if($screen_mode == 'hod'):?>
        //hod approval
        function hodApproval(elem)
        {
            let claim_id    = $(elem).data('claim-id');
            let mode        = $(elem).data('mode');

            let url     = '<?php echo base_url('hr/claim/hodApprove/'); ?>'+mode;
            let type    = 'POST';
            let data    = 
            {
                claim_id: claim_id,
                mode: mode
            };
            let redirect = '<?php echo current_url(); ?>';
            ajxRequest(url, type, data, redirect);        
        }


        function hodReject(elem)
        {
            let id          = $(elem).data('id');
            let claim_id    = $(elem).data('claim-id');
            let mode        = $(elem).data('mode');

            $('#hdR_id').val(id);
            $('#hdR_claim_id').val(claim_id);
            $('#hdR_mode').val(mode);
        }
        
        <?php else:?>
            //own claim
            function closeModal()
            {
                $('#modal_claim_travelling').modal('hide');
            }

            function openClaimForm()
            {
                var link = $('#claim_type').find(':selected').data('link');
                if(link != '<?php echo base_url(); ?>'){
                    window.location.href = link+'/'+'<?php echo $this->uri->segment(4); ?>'+'/'+'<?php echo $this->uri->segment(5); ?>'+'/'+'<?php echo $this->uri->segment(6); ?>'+'/'+'<?php echo $this->uri->segment(7); ?>';
                }
            }

            function deleteClaim(elem)
            {
                toastConfirm('Are you sure you want to remove this claim for your claim list',function(){
                    var id          = $(elem).data('id');
                    var locate      = '<?php echo base_url('/hr/api/claim/'); ?>'+$(elem).data('rqtarget');
                    var redirect    = '<?php echo current_url(); ?>';
                    var data        = {
                        token       : '<?php echo $_SESSION['token']; ?>',
                        id          : id,
                    }
                    ajxRequest(locate,'POST',data, redirect);
                })
            }
        <?php endif?>
    <?php endif ?>
    
</script>