<?php if(!empty($outpatients)) foreach ($outpatients as $key => $outpatient): ?>
    <?php 
        $bool_display = true; 
        if(!empty($outpatients_journal) && $screen_mode != 'admin') foreach ($outpatients_journal as $key => $journal) 
        {
           if( $journal->id == $outpatient->journal_id)
           {
            $bool_display = false;
           }
        }
    ?>
    <?php if($bool_display): ?>
    <tr class="border-bottom" style="background-color:bisque;">
        <td style="vertical-align:middle;">

            <div class="row py-1">
                <div class="col text-right">
                    <?php if ($screen_mode == 'admin'): ?>
                        <?php if($outpatient->is_hod_approved == 0 || $outpatient->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 $outpatient->amount_claim; ?>" 
                                data-rqtarget="approveOutpatient" 
                                data-id="<?php echo ($outpatient->id)?$outpatient->id:0; ?>" 
                                data-status="<?php echo $outpatient->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($outpatient->amount_claim,2); ?>" 
                                data-rqtarget="approveOutpatient" 
                                data-id="<?php echo ($outpatient->id)?$outpatient->id:0; ?>" 
                                data-status="<?php echo $outpatient->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><?php echo (empty($outpatient->is_medical))? 'Outpatients':'Medical Screening'; ?></h4>
                    <small><?php echo date('d-F-Y',strtotime($outpatient->date)); ?></small>
                </div>
            </div>
            
            <div class="row py-1">
                <div class="col">
                    <b>Submission : </b> <?php echo date('F Y',strtotime('01-'.$outpatient->month.'-'.$outpatient->year)); ?>
                </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 ($outpatient->is_hod_approved == 0): ?>
                                        <span class="badge badge-secondary">Draft</span>
                                    <?php endif ?>

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

                                    <?php if ($outpatient->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 py-1">
                                <div class="col-md-4">
                                <b>Status (Admin)</b>
                                </div>
                                <div class="col">
                                    
                                    <?php if ($outpatient->is_approve == 0): ?>
                                        <div class="input-group">
                                            <div class="input-group-prepend w-100">
                                                <span class="badge badge-secondary">Draft</span>
                                                <!-- <button class="btn btn-default btn-block btn-sm bg-dark text-white" type="button" disabled>
                                                    Draft
                                                </button> -->
                                            </div>
                                        </div>
                                    <?php endif ?>

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

                                                <!-- <button class="btn btn-success btn-block btn-sm" type="button" disabled>
                                                    Approved
                                                </button> -->
                                            </div>
                                        </div>
                                    <?php endif ?>

                                    <?php if ($outpatient->is_approve == 2): ?>
                                        <div class="input-group">
                                            <div class="input-group-prepend w-100">
                                                <span class="badge badge-danger">Rejected</span>
                                                <!-- <button class="btn btn-danger btn-sm btn-block text-white" type="button" disabled>
                                                    Rejected
                                                </button> -->
                                            </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 $outpatient->invoice_chit; ?></div>
                    </div>

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

                    <div class="row">
                        <div class="col-lg-2">
                            <b>Patient Name </b>
                        </div>
                        <div class="col">
                            <?php if ($outpatient->patient_name): ?>
                                <?php echo $outpatient->patient_name; ?>
                            <?php else: ?>
                                N/A
                            <?php endif ?>
                        </div>
                    </div>

                    <div class="row">
                        <div class="col-lg-2">
                            <b>Relation </b>
                        </div>
                        <div class="col">

                            <?php if ($outpatient->relation == 0): ?>
                                Self    
                            <?php endif ?>

                            <?php if ($outpatient->relation == 1): ?>
                                Self
                            <?php endif ?>

                            <?php if ($outpatient->relation == 2): ?>
                                Child
                            <?php endif ?>

                            <?php if ($outpatient->relation == 3): ?>
                                Spouse
                            <?php endif ?>
                        </div>
                    </div>

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

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

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

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

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


                        </div>
                    </div>

                </div>
                <div class="col-12 col-md-2" >
                    <div class="row py-1 border-bottom">
                        <div class="col">
                            <b>Claimed (RM)</b>
                            <h1><?php echo number_format($outpatient->amount_claim,2); ?></h1>
                        </div>
                    </div>

                    <div class="row py-1 border-bottom">
                        <div class="col">
                            <b>Approved (RM)</b>
                            <h1><?php echo number_format($outpatient->amount_approved,2); ?></h1>
                        </div>
                    </div>
                </div>
            </div>

        </td>
    </tr>
    <?php endif; ?>
<?php endforeach ?>