<?php
/*
 * Copyright (c) 2019 Earworks.
 * Codeigniter Project Template Modification
 * Please contact our email for more information :
 *  contact@earworks.co.id
 */
defined('BASEPATH') OR exit('No direct script access allowed');
?>
<table class="table table-hover table-bordered">
    <thead>
        <tr>
            <th>No. </th>
            <th>Nama</th>
            <th>Perusahaan</th>
            <th>Kendaraan</th>
            <th>Status</th>
            <th>Estimasi Berangkat</th>
        </tr>
    </thead>
    <tbody>
        <?php $i = 1; ?>
        <?php foreach ($data as $res) : ?>
            <tr>
                <td> <?php echo $i ?></td>
                <td><?php echo $res['name'] ?></td>
                <td><?php echo $res['company'] ?></td>
                <td><?php echo $res['vehiclename'] ?></td>
                <td>
                    <?php
                    if (array_key_exists($res['vehicleid'], $current)) {
                        if ($current[$res['vehicleid']]['id'] == $res['id']) {
                            echo 'Bersiap';
                        } else {
                            echo 'Menunggu';
                        }
                    }
                    ?>
                </td>
                <td>
                    <?php
                    if (array_key_exists($res['vehicleid'], $current)) {
                        if ($current[$res['vehicleid']]['id'] == $res['id']) {
                            $remaining = strtotime('+10 minutes', $res['modified']);
                            $count = date('i', $remaining) - date('i');
                            if ($count <= 0) {
                                $count = 1;
                            }
                            echo $count . ' Menit';
                        }
                    }
                    ?>
                </td>
            </tr>
            <?php $i++ ?>
        <?php endforeach; ?>
    </tbody>
</table>