<div class="row">
    <div class="col-sm-12 col-md-12">
        <div class="panel panel-bd lobidrag">
            <div class="panel-heading">
                <div class="panel-title">
                    <h4><?php echo(!empty($title) ? $title : null) ?></h4>
                </div>
            </div>
            <?php

            if ($this->session->userdata('isAdmin') == 1) { ?>
                <div class="panel-body">
                    <table width="100%" class="datatable table table-striped table-bordered table-hover">
                        <thead>
                        <tr>
                            <th><?php echo 'Name' ?></th>
                            <th><?php echo 'Start Date' ?></th>
                            <th><?php echo 'Start Time' ?></th>
                            <th><?php echo 'End Date' ?></th>
                            <th><?php echo 'End Time' ?></th>
                            <th><?php echo 'Reason' ?></th>
                            <th><?php echo 'Total Time (HH:MM)' ?></th>
                            <th><?php echo 'Approve By Supervisor' ?></th>
                            <th><?php echo 'Action' ?></th>

                        </tr>
                        </thead>
                        <tbody>
                        <?php if (!empty($admin_ovt_requests)) { ?>
                            <?php $sl = 1; ?>
                            <?php foreach ($admin_ovt_requests as $row) {
                                if ($row->approve_by_sup == 1) {
                                    $approval = 'Approved';
                                } else if ($row->approve_by_sup == 2) {
                                    $approval = 'Rejected';
                                } else {
                                    $approval = 'Pending';
                                }

                                $total_time = $row->total_time;
                                $hour = floor($total_time);
                                $minute = round(($total_time - $hour) * 60);
                                ?>
                                <tr class="<?php echo ($sl & 1) ? "odd gradeX" : "even gradeC" ?>">
                                    <td class="center">
                                        <p><?php echo $row->first_name . " " . $row->last_name ?></p>
                                    </td>
                                    <td class="center">
                                        <p><?php echo $row->ovt_start_date ?></p>
                                    </td>
                                    <td class="center">
                                        <p><?php echo $row->ovt_start_time ?></p>
                                    </td>
                                    <td class="center">
                                        <p><?php echo $row->ovt_end_date ?></p>
                                    </td>
                                    <td class="center">
                                        <p><?php echo $row->ovt_end_time ?></p>
                                    </td>
                                    <td class="center">
                                        <p><?php echo $row->ovt_reason ?></p>
                                    </td>
                                    <td class="center">
                                        <p><?php echo $hour . ":" . $minute ?></p>
                                    </td>
                                    <td class="center">
                                        <p><?php echo $approval ?></p>
                                    </td>
                                    <td class="center">
                                        <?php
                                        if ($row->approve_by_sup == '') { ?>
                                            <p>
                                                <a href="<?php base_url() ?>overtime_approval?approve_by_sup=1&ovt_id=<?php echo $row->ovt_id ?>&emp_id=<?php echo $row->employee_id ?>"
                                                   class="btn btn-sm btn-success"
                                                   onclick="return confirm('<?php echo "Are you sure to submit. You cannot edit after submission." ?>') "><i
                                                            class="fa fa-check-circle"></i></a>
                                                <a href="<?php base_url() ?>overtime_approval?approve_by_sup=2&ovt_id=<?php echo $row->ovt_id ?>&emp_id=<?php echo $row->employee_id ?>"
                                                   class="btn btn-sm btn-danger"
                                                   onclick="return confirm('<?php echo "Are you sure to submit. You cannot edit after submission." ?>') ">x</a>
                                            </p>
                                        <?php } else { ?>
                                            <button disabled class="btn btn-sm btn-success"><i
                                                        class="fa fa-check-circle"></i></button>
                                            <button disabled class="btn btn-sm btn-danger">x</button>
                                        <?php }
                                        ?>

                                    </td>

                                </tr>
                                <?php $sl++; ?>
                            <?php } ?>
                        <?php } ?>
                        </tbody>
                    </table>  <!-- /.table-responsive -->
                </div>
            <?php } else { ?>
                <div class="panel-body">
                    <table width="100%" class="datatable table table-striped table-bordered table-hover">
                        <thead>
                        <tr>
                            <th><?php echo 'First Name' ?></th>
                            <th><?php echo 'Last Name' ?></th>
                            <th><?php echo 'Start Date' ?></th>
                            <th><?php echo 'Start Time' ?></th>
                            <th><?php echo 'End Date' ?></th>
                            <th><?php echo 'End Time' ?></th>
                            <th><?php echo 'Reason' ?></th>
                            <th><?php echo 'Total Time (HH:MM)' ?></th>
                            <th><?php echo 'Approve By Supervisor' ?></th>
                            <th><?php echo 'Action' ?></th>

                        </tr>
                        </thead>
                        <tbody>
                        <?php if (!empty($ovt_requests)) { ?>
                            <?php $sl = 1; ?>
                            <?php foreach ($ovt_requests as $row) {
                                if ($row->approve_by_sup == 1) {
                                    $approval = 'Approved';
                                } else if ($row->approve_by_sup == 2) {
                                    $approval = 'Rejected';
                                } else {
                                    $approval = 'Pending';
                                }

                                $total_time = $row->total_time;
                                $hour = floor($total_time);
                                $minute = round(($total_time - $hour) * 60);
                                ?>
                                <tr class="<?php echo ($sl & 1) ? "odd gradeX" : "even gradeC" ?>">
                                    <td class="center">
                                        <p><?php echo $row->first_name ?></p>
                                    </td>
                                    <td class="center">
                                        <p><?php echo $row->last_name ?></p>
                                    </td>
                                    <td class="center">
                                        <p><?php echo $row->ovt_start_date ?></p>
                                    </td>
                                    <td class="center">
                                        <p><?php echo $row->ovt_start_time ?></p>
                                    </td>
                                    <td class="center">
                                        <p><?php echo $row->ovt_end_date ?></p>
                                    </td>
                                    <td class="center">
                                        <p><?php echo $row->ovt_end_time ?></p>
                                    </td>
                                    <td class="center">
                                        <p><?php echo $row->ovt_reason ?></p>
                                    </td>
                                    <td class="center">
                                        <p><?php echo $hour . ":" . $minute ?></p>
                                    </td>
                                    <td class="center">
                                        <p><?php echo $approval ?></p>
                                    </td>
                                    <td class="center">
                                        <?php
                                        if ($row->approve_by_sup == '') { ?>
                                            <p>
                                                <a href="<?php base_url() ?>overtime_approval?approve_by_sup=1&ovt_id=<?php echo $row->ovt_id ?>&emp_id=<?php echo $row->employee_id ?>"
                                                   class="btn btn-sm btn-success"
                                                   onclick="return confirm('<?php echo "Are you sure to submit. You cannot edit after submission." ?>') "><i
                                                            class="fa fa-check-circle"></i></a>
                                                <a href="<?php base_url() ?>overtime_approval?approve_by_sup=2&ovt_id=<?php echo $row->ovt_id ?>&emp_id=<?php echo $row->employee_id ?>"
                                                   class="btn btn-sm btn-danger"
                                                   onclick="return confirm('<?php echo "Are you sure to submit. You cannot edit after submission." ?>') ">x</a>
                                            </p>
                                        <?php } else { ?>
                                            <button disabled class="btn btn-sm btn-success"><i
                                                        class="fa fa-check-circle"></i></button>
                                            <button disabled class="btn btn-sm btn-danger">x</button>
                                        <?php }
                                        ?>

                                    </td>

                                </tr>
                                <?php $sl++; ?>
                            <?php } ?>
                        <?php } ?>
                        </tbody>
                    </table>  <!-- /.table-responsive -->
                </div>
            <?php }
            ?>

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