<?php if(!empty($outpatients_journal)) foreach ($outpatients_journal as $key => $outpatient): ?>
    <tr class="border-bottom">
        <td style="vertical-align:middle;">
            <div class="row py-1">
                <div class="col text-right">
                    <?php if($is_in_submission_range): ?>
                        <?php if(empty($screen_mode)): ?>
                            <button class="btn btn-danger btn-sm" 
                                data-rqtarget="removeOutpatientJournal" 
                                data-id="<?php echo ($outpatient->id)?$outpatient->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 if($screen_mode == 'hod'): ?>
                            <button class="btn btn-success btn-sm" 
                                    data-trigger="hover" 
                                    data-tooltip="tooltip" 
                                    title="" 
                                    data-original-title="Approve Claim" 
                                    data-claim-id="<?php echo $outpatient->id; ?>" 
                                    data-mode="1" 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 $outpatient->id; ?>"
                                data-claim-id="<?php echo $outpatient->claim_id; ?>" 
                                data-mode="1" 
                                data-toggle="modal" data-target="#rejectModal"
                                onclick="hodReject(this)"
                                >
                                <i class="fas fa-thumbs-down"></i>
                            </button>
                            <!-- button rejecet -->
                        <?php endif; ?>
                    <?php endif;?>
                </div>
            </div>

            <div class="row py-1">
                <div class="col text-primary">
                    <h4><?php echo (empty($outpatient->is_medical))? 'Outpatient':'Medical Screening'; ?></h4>
                    <small><?php echo date('d-F-Y',strtotime($outpatient->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 ($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>

                    <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 echo $outpatient->relation; ?>
                        </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 => $attachment): ?>
                                    <li>
                                        <a href="<?php echo base_url('hr/claim/openAttachment/'.$attachment->unique_id.'/OUTPATIENT'); ?>" target="_blank"><?php echo $attachment->attachment_name; ?></a> <br>
                                        <small><?php echo $attachment->description; ?></small>    
                                    </li>
                                <?php endforeach; endif; ?>
                            </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)
                                {
                                    echo '[HOD] : '.$outpatient->hod_remarks;
                                }
                                if($outpatient->is_approve == 2)
                                {
                                    echo '[ADMIN] : '.$outpatient->admin_remarks;
                                }
                            ?>


                        </div>
                    </div>

                    <!-- <div class="row">
                        <div class="col-12">
                            <table class="table-striped" width="100%">
                                <thead>
                                    <tr>
                                        <th>Prorated Month</th>
                                        <th>Claim (RM)</th>
                                        <th>Approve (RM)</th>
                                        <th>Status</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                        $total_approved = 0;
                                    ?>
                                    <?php if(!empty($outpatient->payment_month)): foreach($outpatient->payment_month as $key => $payment): ?>
                                        <?php
                                            $total_approved += $payment->amount_approved;
                                        ?>
                                        <tr>
                                            <td><?php echo date('M',strtotime('01-'.$payment->prorate_month.'-'.$outpatient->year)); ?></td>
                                            <td><?php echo number_format($payment->amount_claim,2); ?></td>
                                            <td><?php echo number_format($payment->amount_approved,2); ?></td>
                                            <td>
                                            
                                    
                                                <?php if ($payment->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 ($payment->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 ($payment->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 ?>
                                
                                            
                                            </td>
                                        </tr>
                                    <?php endforeach; endif; ?>
                                </tbody>
                            </table>
                        </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($outpatient->amount_claim,2); ?></h1>
                        </div>
                    </div>

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