<?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 Onroad'
        . '';
$this->load->add_map($this->load->title);
$count = count($data);
$countall = 0;
?>
<div class="row">
    <div class="col-xs-12">
        <div class="portlet">
            <div class="portlet-title">
                Antrian Test Ride
                <a class="btn btn-primary btn-xs pull-right" href="<?php echo base_url('backoffice/testonroad/viewonroad/'.$cardid) ?>" target="_blank">View Display</a>
            </div>
            <div class="portlet-body">
                <table class="table table-hover table-bordered">
                    <thead>
                        <tr>
                            <?php foreach ($data as $key => $val) : ?>
                                <th>
                                    <?php if (isset($val[0])) : ?>
                                        <a class="btn btn-xs btn-danger" href="<?php echo base_url('backoffice/testonroad/closevehicle/' . $val[0]['vehicleid'] . '/' . $cardid) ?>">
                                            <i class="fa fa-close"></i>
                                        </a>
                                    <?php endif; ?>
                                    <span style="font-family: 'Mercedes-B'; margin-left: 33px;"><?php echo $key ?></span>
                                </th>
                                <?php $countall = ($countall < count($val)) ? count($val) : $countall; ?>
                            <?php endforeach; ?>
                        </tr>
                    </thead>
                    <tbody>
                        <?php for ($i = 0; $i < $countall; $i++) : ?>
                            <tr>
                                <?php $row = null; ?>
                                <?php foreach ($data as $key => $val) : ?>
                                    <?php
                                    if (!isset($val[$i])) {
                                        echo "<td></td>";
                                        continue;
                                    }
                                    ?>
                                    <td>
                                        <a class="btn btn-xs btn-danger" href="<?php echo base_url('backoffice/testonroad/cancel/' . $val[$i]['id'] . '/' . $cardid) ?>">
                                            <i class="fa fa-close"></i>
                                        </a>
                                        <a class="btn btn-xs btn-success" href="<?php echo base_url('backoffice/testonroad/finish/' . $val[$i]['id'] . '/' . $cardid) ?>">
                                            <i class="fa fa-check"></i>
                                        </a>
                                        <span><?php echo $val[$i]['name'] . ' - ' . $val[$i]['company'] ?></span>
                                    </td>
                                <?php endforeach; ?>
                            </tr>
                        <?php endfor; ?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<?php echo form_open('backoffice/testonroad/requeue/' . $cardid) ?>
<div class="row">
    <div class="col-sm-6">
        <!-- BEGIN SAMPLE FORM PORTLET-->
        <div class="portlet">
            <div class="portlet-title">
                Reassign Visitor
            </div>
            <div class="portlet-body form">
                <div class="form-body">
                    <div class="form-group">
                        <label class="control-label">Visitor</label>
                        <?php
                        echo form_dropdown('onroadid', $canceldata, null, array(
                            'class' => 'form-control input-circle-right'
                        ));
                        ?>
                    </div>
                    <div class="form-group">
                        <label class="control-label">Kendaraan</label>
                        <?php
                        echo form_dropdown('vehicleid', $vehicleid, null, array(
                            'class' => 'form-control input-circle-right',
                        ));
                        ?>
                    </div>
                </div>
                <div class="form-actions">
                    <button type="submit" class="btn green">Submit</button>
                </div>

            </div>
        </div>
        <!-- END SAMPLE FORM PORTLET-->
    </div>
</div>
<?php
echo form_close();

$this->load->add_css('assets/plugins/select2/css/select2.min.css');
$this->load->add_css('assets/plugins/select2/css/select2-bootstrap.min.css');
$this->load->add_js('assets/plugins/select2/js/select2.full.min.js');
$this->load->add_js(<<<EOD
            $('[name="vehicleid"]').select2();
        $('[name="onroadid"]').select2();
EOD
        , 'embed');
