<?php if(!empty($travels)) foreach ($travels as $key => $travel): ?>
    <tr class="border-bottom">
        <td>
            <div class="row py-1">
                <div class="col text-right">

                    <?php if($is_in_submission_range): ?>
                        <?php if($screen_mode == 'hod'): ?>

                            <button class="btn btn-success btn-sm" 
                                data-trigger="hover" 
                                data-tooltip="tooltip" title="" 
                                data-original-title="Approved Claim" 
                                data-claim-id="<?php echo $travel->id; ?>" 
                                data-mode="6" 
                                onclick="hodApproval(this)"
                                >
                                <i class="fas fa-thumbs-up" style="transform: scaleX(-1);"></i>    
                            </button>
                            <!-- button reject -->
                            <button class="btn btn-danger btn-sm" 
                                data-trigger="hover" 
                                data-tooltip="tooltip" 
                                title="" 
                                data-original-title="Disaprove Claim" 
                                data-id="<?php echo $travel->id; ?>"
                                data-claim-id="<?php echo $travel->claim_id; ?>" 
                                data-mode="6" 
                                data-toggle="modal" data-target="#rejectModal"
                                onclick="hodReject(this)"
                                >
                                <i class="fas fa-thumbs-down"></i>
                            </button>
                            <!-- button reject -->

                        <?php else: ?>
                            <?php if(empty($screen_mode)): ?>
                            <button 
                                class="btn btn-danger btn-sm" 
                                data-rqtarget="removeTravel" 
                                data-id="<?php echo ($travel->id)?$travel->id:0?>" 
                                onclick="deleteClaim(this)" 
                                data-trigger="hover" 
                                data-tooltip="tooltip" 
                                title="" 
                                data-original-title="Remove Claim" <?php echo ($disabled || !empty($claims->is_submit))?'disabled':''; ?>>
                                <i class="fa fa-trash-alt"></i>
                            </button>
                            <?php endif ?>
                        <?php endif ?>
                    <?php endif; ?>
                    
                    <?php if($screen_mode == 'admin'): ?>
                        <?php if($travel->is_hod_approved == 0 || $travel->is_hod_approved == 2): ?>
                            <div class="text-danger">claim has not been approved or reject by HOD</div>
                        <?php endif; ?>
                            <button 
                                class="btn btn-success btn-sm text-white" 
                                onclick="approveClaim(this)" 
                                data-price="<?php echo $travel->mileage_amount; ?>" 
                                data-mileage="<?php echo number_format($travel->mileage_amount,2); ?>"
                                data-rqtarget="approveTravels" 
                                data-id="<?php echo ($travel->id)?$travel->id:0; ?>" 
                                data-status="<?php echo $travel->status; ?>" 
                                data-allocation="status" 
                                data-balanced="balanced" 
                                data-trigger="hover" 
                                data-tooltip="tooltip" 
                                title="" 
                                data-original-title="Approve Claim">
                                <i class="fas fa-thumbs-up" style="transform: scaleX(-1);"></i>
                            </button>

                            <button 
                                class="btn btn-danger btn-sm text-white" 
                                onclick="rejectClaim(this)" 
                                data-price="<?php echo $travel->amount_claim; ?>" 
                                data-mileage="<?php echo number_format($travel->mileage_amount,2); ?>"
                                data-rqtarget="approveTravels" 
                                data-id="<?php echo ($travel->id)?$travel->id:0; ?>" 
                                data-status="<?php echo $travel->status; ?>" 
                                data-allocation="status" 
                                data-balanced="balanced" 
                                data-trigger="hover" 
                                data-tooltip="tooltip" 
                                title="" 
                                data-original-title="reject Claim">
                                <i class="fas fa-thumbs-up"></i>
                            </button>
                        
                    <?php endif ?>
                    
                </div>
            </div>

            <div class="row py-1">
                <div class="col text-primary">
                    <h4>Mileage</h4>
                    <?php echo date('d-F-Y',strtotime($travel->travelling_date)); ?>
                </div>
            </div>

            <div class="row">
                <div class="col-12 col-md-10">
                
                    <div class="row">
                        <div class="col-12 col-md-6">
                            <div class="row">
                                <div class="col-md-4">
                                    <b>Status (HOD)</b>
                                </div>
                                <div class="col">

                                    <?php if ($travel->is_hod_approved == 0): ?>
                                        <span class="badge badge-secondary">Draft</span>
                                    <?php endif ?>

                                    <?php if ($travel->is_hod_approved == 1): ?>
                                        <span class="badge badge-success">Approved</span>
                                    <?php endif ?>

                                    <?php if ($travel->is_hod_approved == 2): ?>
                                        <span class="badge badge-danger">Rejected</span>
                                    <?php endif ?>

                                </div>
                            </div>
                        </div>
                        <div class="col-12 col-md-6">
                            <div class="row">
                                <div class="col-md-4">
                                    <b>Status (Admin)</b>
                                </div>
                                <div class="col">

                                    <?php if ($travel->status == 0): ?>
                                        <span class="badge badge-secondary">Draft</span>
                                    <?php endif ?>

                                    <?php if ($travel->status == 1): ?>
                                        <span class="badge badge-success">Approved</span>
                                    <?php endif ?>

                                    <?php if ($travel->status == 2): ?>
                                        <span class="badge badge-danger">Rejected</span>
                                    <?php endif ?>

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

                    <?php if($travel->details) foreach ($travel->details as $key => $detail): ?>
                        <div class="row">
                            <div class="col-lg-2">
                                <i class="<?php echo $detail['claim_type_icon']; ?>"></i> <?php echo $detail['claim_type']; ?>
                            </div>
                            <div class="col">RM<?php echo number_format($detail['amount'],2); ?></div>
                        </div>
                        <?php if($key == sizeof($travel->details)-1)
                        {
                            echo '<div class="row py-1 border-bottom"></div>';
                        }
                        ?>
                    <?php endforeach ?>
                    
                    <div class="row">
                        <div class="col-12">
                            <b>Routes</b>
                        </div>
                        <!-- <ol class="col-12" style="width:100%;"> -->
                            
                                <?php if($travel->routes) foreach($travel->routes as $key => $route): ?>
                                <!-- <li> -->
                                    <!-- <div class="row"> -->
                                    <div class="col-lg-4">
                                        <?php echo $key+1; ?>.
                                        <i class="fas fa-map-marker-alt text-danger"></i>
                                        <a href="https://www.google.com/maps/search/?api=1&parameters=<?php echo $route->from; ?>" target="_blank">
                                            [<?php echo substr($route->from,0,25); ?>
                                            <span class="dot" data-trigger="hover" data-tooltip="tooltip" title="" data-original-title="<?php echo $route->from; ?>" ><i class="fas fa-ellipsis-h"></i></span>]
                                        </a>
                                    </div>
                                    <div class="col">
                                        <i class="fas fa-arrow-right text-success"></i>
                                    </div>
                                    <div class="col-lg-4">                                                            
                                        <i class="fas fa-map-marker-alt text-danger"></i>
                                        <a href="https://www.google.com/maps/search/?api=1&parameters=<?php echo $route->to;?>" target="_blank">
                                            [<?php echo substr($route->to,0,25); ?> 
                                            <span class="dot" data-trigger="hover" data-tooltip="tooltip" title="" data-original-title="<?php echo $route->to; ?>"><i class="fas fa-ellipsis-h"></i></span>]
                                        </a>
                                    </div>
                                    <div class="col">
                                        (<?php echo number_format($route->distance,2); ?> <b>KM</b>)
                                    </div>
                                    <!-- </div> -->
                                <!-- </li> -->
                                <?php endforeach?>
                        <!-- </ol> -->
                    </div>

                    <div class="row">
                        <div class="col-lg-2"><b>Attachment(s)</b></div>
                        <?php if($travel->attachments) foreach($travel->attachments as $key => $attachment): ?>

                            <div class="col">
                                <ol>
                                    <li>
                                        <a href="<?php echo base_url('/hr/claim/openAttachment/'.$attachment->unique_id.'/MILEAGE'); ?>" target="_blank">
                                            <?php echo $attachment->attachment_name; ?></a>
                                            <br>
                                            <small><?php echo $attachment->description; ?></small>
                                        </li>
                                </ol>
                            </div>
                        <?php endforeach ?>
                    </div>
                    
                    <div class="row">
                        <div class="col-lg-2">
                            <b>Remarks</b>
                        </div>
                        <div class="col" style="min-height:100px;">

                            <?php if($travel->is_hod_approved == 2): ?>
                                <?php if(!empty($travel->hod_remarks)): ?>
                                    <b>[HOD] : </b> <?php echo $travel->hod_remarks; ?>
                                <?php endif; ?>
                            <?php endif; ?>

                            <?php if($travel->status == 2): ?>
                                <?php if(!empty($travel->admin_remarks)): ?>
                                    <b>[ADMIN] : </b> <?php echo $travel->admin_remarks; ?>
                                <?php endif; ?>
                            <?php endif; ?>
                        </div>
                    </div>

                </div>
                <div class="col-12 col-md-2">

                    <div class="row py-1 border-bottom" style="background-color:bisque;">
                        <div class="col">
                            <b>Claimed (RM)</b>
                            <h1>
                                <?php 
                                    echo number_format($travel->mileage_amount,2); 
                                ?>
                            </h1>
                        </div>
                    </div>

                    <div class="row py-1" style="background-color:bisque;">
                        <div class="col">
                            <b>Approved (RM)</b>
                            <h1>
                                <?php echo number_format($travel->amount_approve,2); ?>
                            </h1>
                        </div>
                    </div>


                </div>
            </div>
        </td>
    </tr>
<?php endforeach ?>