<?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');
$this->load->title = 'Test Ride';
$this->load->add_map($this->load->title);
$count = count($data);
$countall = 0;
?>

<div class="container">
    <div class="row">
        <div class="col-xs-12">
            <div class="col-xs-6">
                <img src="<?php echo base_url('assets/img/logotable.png') ?>" class="img img-responsive">
            </div>
            <div class="col-xs-6">
                <img src="<?php echo base_url('assets/img/logo.png') ?>" class="img img-responsive imagekanan" >
            </div>
            <span class="headertext">Onroad Test Ride</span>
        </div>
    </div>
</div>
<div class="container">
    <div class="row">
        <div class="col-xs-12">
            <div class="tableantrian">
                <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>
            </div>
        </div>
    </div>
</div>
<?php
$refreshurl = base_url('backoffice/testonroad/viewonroad/' . $card['id']);
$this->load->add_js(<<<EOD
           var refreshurl = '{$refreshurl}'; 
EOD
        , 'embed');
$this->load->add_js('assets/backoffice/pages/viewonroad.js');