<?php if(!empty($hospitalizations)) foreach ($hospitalizations as $key => $hospitalize): ?>
    <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 $hospitalize->id; ?>" data-mode="2" onclick="hodApproval(this)">
                            <i class="fas fa-thumbs-up" style="transform: scaleX(-1);"></i>
                        </button>
                        
                        <!-- button rejecet -->
                        <button class="btn btn-danger btn-sm" 
                            data-trigger="hover" 
                            data-tooltip="tooltip" 
                            title="" 
                            data-original-title="Disaprove Claim" 
                            data-id="<?php echo $hospitalize->id; ?>"
                            data-claim-id="<?php echo $hospitalize->claim_id; ?>" 
                            data-mode="2" 
                            data-toggle="modal" data-target="#rejectModal"
                            onclick="hodReject(this)"
                            >
                            <i class="fas fa-thumbs-down"></i>
                        </button>
                        <!-- button rejecet -->
                    <?php else: ?>
                        <?php if(empty($screen_mode)): ?>
                            <button class="btn btn-danger btn-sm" 
                                    data-rqtarget="removeHospitalization" 
                                    data-id="<?php echo ($hospitalize->id)?$hospitalize->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($hospitalize->is_hod_approved == 0 || $hospitalize->is_hod_approved == 2): ?>
                        <div class="text-danger">claim has not been approved or rejected by HOD</div>
                    <?php endif; ?>
                    <button 
                        class="btn btn-success btn-sm text-white" 
                        onclick="approveClaim(this)"  
                        data-price="<?php echo $hospitalize->amount_claim; ?>" 
                        data-rqtarget="approveHospitalization" 
                        data-id="<?php echo ($hospitalize->id)?$hospitalize->id:0; ?>" 
                        data-status="<?php echo $hospitalize->is_approve; ?>" 
                        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 number_format($hospitalize->amount_claim,2); ?>" 
                        data-rqtarget="approveHospitalization" 
                        data-id="<?php echo ($hospitalize->id)?$hospitalize->id:0; ?>" 
                        data-status="<?php echo $hospitalize->is_approve; ?>" 
                        data-allocation="status" 
                        data-balanced="balanced" 
                        data-trigger="hover" 
                        data-tooltip="tooltip" title="" 
                        data-original-title="reject Claim">
                        <i class="fas fa-thumbs-down"></i>                                                            
                    </button>
                <?php endif ?>

                </div>
            </div>

            <div class="row py-1">
                <div class="col text-primary">
                    <h4>Hospitalization</h4>
                    <small><?php echo date('d-F-Y',strtotime($hospitalize->date)); ?></small>
                </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 py-1">
                                <div class="col-md-4">
                                    <b>Status (HOD)</b>
                                </div>
                                <div class="col">
                                    <?php if($hospitalize->is_hod_approved == 0): ?>
                                        <div class="input-group">
                                            <div class="input-group-prepend w-100">
                                                <span class="badge badge-secondary">Draft</span>
                                            </div>
                                        </div>
                                    <?php endif ?>
                                    
                                    <?php if ($hospitalize->is_hod_approved == 1): ?>
                                        <div class="input-group w-100">
                                            <div class="input-group-prepend w-100">
                                                <span class="badge badge-success">Approved</span>
                                            </div>
                                        </div>
                                    <?php endif ?>

                                    <?php if ($hospitalize->is_hod_approved == 2): ?>
                                        <div class="input-group">
                                            <div class="input-group-prepend w-100">
                                                <span class="badge badge-danger">Rejected</span>
                                            </div>
                                        </div>
                                    <?php endif ?>

                                </div>
                            </div>
                        </div>
                        <div class="col-12 col-md-6">
                        <div class="row py-1">
                            <div class="col-md-4"><b>Status (Admin)</b></div>
                                <div class="col">
                                    <?php if ($hospitalize->is_approve == 0): ?>
                                        <div class="input-group">
                                            <div class="input-group-prepend w-100">
                                                <span class="badge badge-secondary">Draft</span>
                                            </div>
                                        </div>
                                    <?php endif ?>

                                    <?php if ($hospitalize->is_approve == 1): ?>
                                        <div class="input-group w-100">
                                        <div class="input-group-prepend w-100">
                                            <span class="badge badge-success">Approved</span>
                                        </div>
                                        </div>
                                    <?php endif ?>

                                    <?php if ($hospitalize->is_approve == 2): ?>
                                        <div class="input-group">
                                        <div class="input-group-prepend w-100">
                                            <span class="badge badge-danger">Rejected</span>
                                        </div>
                                        </div>
                                    <?php endif ?>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-lg-2">
                            <b>Invoice Chit </b>
                        </div>
                        <div class="col"><?php echo $hospitalize->invoice_chit; ?></div>
                    </div>

                    <div class="row">
                        <div class="col-lg-2">
                            <b>Hospital / clinic</b> 
                        </div>
                        <div class="col"><?php echo ($hospitalize->clinic_name)?$hospitalize->clinic_name:''; ?></div>
                    </div>

                    <div class="row">
                        <div class="col-lg-2">
                            <b>Patient Name </b>
                        </div>
                        <div class="col"><?php echo $hospitalize->patient_name; ?></div>
                    </div>

                    <div class="row">
                        <div class="col-lg-2">
                            <b>Relation </b>
                        </div>
                        <div class="col"><?php echo $hospitalize->relations; ?></div>
                    </div>

                    <div class="row">
                        <div class="col-lg-2">
                            <b>Treatment</b> 
                        </div>
                        <div class="col"><?php echo $hospitalize->treatment; ?></div>
                    </div>

                    <div class="row">
                        <div class="col-lg-2">
                            <b>Payment Method</b>
                        </div>
                        <div class="col">
                            <?php if($hospitalize->payment_method == 0): ?>
                                Cash
                            <?php else:?>
                                Premium Insurance
                            <?php endif; ?>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-lg-2">
                            <b>Attachment(s)</b>
                        </div>
                        <div class="col">
                            <ol>
                            <?php if(!empty($hospitalize->attachments)) foreach ($hospitalize->attachments as $key => $attachment): ?>
                                <li>
                                    <a href="<?php echo base_url('hr/claim/openAttachment/'.$attachment->unique_id.'/HOSPITALIZATION'); ?>" target="_blank">
                                        <?php echo $attachment->attachment_name; ?>
                                    </a>
                                    <br>
                                    <small><?php echo $attachment->description; ?></small>
                                </li>
                            <?php endforeach ?>
                            </ol>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-lg-2">
                            <b>Remarks</b>
                        </div>
                        <div class="col" style="min-height:100px;">

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

                            <?php if($hospitalize->is_approve == 2): ?>
                                <?php if(!empty($hospitalize->admin_remarks)): ?>
                                    <b>[ADMIN] : </b> <?php echo $hospitalize->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($hospitalize->amount_claim,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($hospitalize->amount_approved,2); ?></h1>
                        </div>
                    </div>
                </div>
            </div>
        </td>
    </tr>
<?php endforeach ?>