<?php

use yii\helpers\Html;
use yii\widgets\DetailView;

/* @var $this yii\web\View */
/* @var $model frontend\models\Vehicle */

$this->title = $model->reg;
$this->params['breadcrumbs'][] = ['label' => 'Vehicles', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="vehicle-view">

	<p>
		<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
		<?= Html::a('Create Reminder', ['/vehiclereminders/create', 'vehicle' => $model->id], ['class' => 'btn btn-primary']) ?>
		<?= Html::a('Delete', ['delete', 'id' => $model->id], [
			'class' => 'btn btn-danger',
			'data' => [
				'confirm' => 'Are you sure you want to delete this item?',
				'method' => 'post',
			],
		]) ?>
	</p>


<div class="vehicle-form">
	<div class="card card-default">
		<div class="card-header">Details</div>	
		<div class="card-body">
			<div class="row">	
				<div class="col-sm-2 data-label">Make</div>
				<div class="col-sm-4"><?= $model->make ?></div>
				<div class="col-sm-2 data-label">Model</div>
				<div class="col-sm-4"><?= $model->model ?></div>
			</div>
			<div class="row">	
				<div class="col-sm-2 data-label">Name</div>
				<div class="col-sm-4"><?= $model->name ?></div>
				<div class="col-sm-2 data-label">Reg</div>
				<div class="col-sm-4"><?= $model->reg ?></div>
			</div>
			<div class="row">	
				<div class="col-sm-2 data-label">Description</div>
				<div class="col-sm-10"><?= $model->description ?></div>
			</div>
			<div class="row">	
				<div class="col-sm-2 data-label">Date of First Drive</div>
				<div class="col-sm-4"><?= $model->firstd ?></div>
				<div class="col-sm-2 data-label">Current Mileage</div>
				<div class="col-sm-4"><?= isset($model->travel) ? $model->travel->finishmileage : 'N/A' ?></div>
			</div>
			<div class="row">	
				<div class="col-sm-2 data-label">Category</div>
				<div class="col-sm-4"><?= $model->category ?></div>
			</div>
			<div class="row">	
				<div class="col-sm-2 data-label">Vehicle Unloaded Weight</div>
				<div class="col-sm-4"><?= $model->weight ?></div>
				<div class="col-sm-2 data-label">Vehicle Loaded Weight</div>
				<div class="col-sm-4"><?= $model->loadedweight ?></div>
			</div>
			<div class="row">
				<div class="col-sm-2 data-label">Fuel Tank Size (L)</div>
				<div class="col-sm-4"><?= $model->fueltanksize ?></div>
			</div>
			<div class="row">
				<div class="col-sm-2 data-label">Status</div>
				<div class="col-sm-4"><?= $model->status ?></div>
			</div>
		</div>
	</div>
		<div class="card card-default">
		<div class="card-header">Tyre Pressures</div>
	  	<div class="card-body">
			<div class="row">
				<div class="col-sm-offset-2 col-sm-4 data-label text-center">Loaded</div>
				<div class="col-sm-4 data-label text-center">Unloaded</div>
			</div>
			<div class="row">
				<div class="col-sm-2 data-label">Nearside Front</div>
				<div class="col-sm-4"><?= $model->nearsidefl ?></div>
				<div class="col-sm-4"><?= $model->nearsidefu ?></div>
			</div>
			<div class="row">
				<div class="col-sm-2 data-label">Nearside Rear</div>
				<div class="col-sm-4"><?= $model->nearsiderl ?></div>
				<div class="col-sm-4"><?= $model->nearsideru ?></div>
			</div>
			<div class="row">
				<div class="col-sm-2 data-label">Offside Front</div>
				<div class="col-sm-4"><?= $model->offsidefl ?></div>
				<div class="col-sm-4"><?= $model->offsidefu ?></div>
			</div>
			<div class="row">
				<div class="col-sm-2 data-label">Offside Rear</div>
				<div class="col-sm-4"><?= $model->offsiderl ?></div>
				<div class="col-sm-4"><?= $model->offsidefu ?></div>
			</div>
			<div class="row">
				<div class="col-sm-2 data-label">Spare</div>
				<div class="col-sm-4"><?= $model->spare ?></div>
			</div>
		</div>
	</div>

	<?php if ($model->fueldata) { ?>
	<div class="card card-default">
		<div class="card-header">Lifetime Statistics</div>
		<div class="card-body">
			<div class="row">
				<div class="col-sm-2 data-label">Mileage</div>
				<div class="col-sm-2"><?= $model->fueldata[0]['lifetime']['miles'] ?></div>
				
				<div class="col-sm-2 data-label">Litres</div>
				<div class="col-sm-2"><?= $model->fueldata[0]['lifetime']['litres'] ?></div>
				
				<div class="col-sm-2 data-label">MPG</div>
				<div class="col-sm-2"><?= $model->fueldata[0]['lifetime']['mpg'] ?></div>
			</div>
		</div>
	</div>
	<?php } ?>
	<?php if ($model->servicehistory) { ?>
	<div class="card card-default">
		<div class="card-header">Service History</div>
		<div class="card-body">
			<?php foreach ($model->servicehistory as $a => $sh) { ?>
				
			<div class="row ">
				<div class="col-sm-1 data-label">Date:</div>
				<div class="col-sm-1"><?= $sh->date ?></div>
				
				<div class="col-sm-1 data-label">Type:</div>
				<div class="col-sm-1"><?= $sh->type ?></div>
				<div class="col-sm-1 data-label">Mileage:</div>
				<div class="col-sm-1"><?= $sh->mileage ?></div>
				
				<div class="col-sm-1 data-label">Description:</div>
				<div class="col-sm-3"><?= $sh->description ?></div>
				
				<div class="col-sm-2"><?= HTML::A('<i class="fa fa-eye"></i>', ['/vehicleservicehistory/view', 'id' => $sh->id], ['title' => 'View Service' ]); ?></div>
			</div>
			<?php } ?>
		</div>
	</div>
	<?php } ?>
	<?php if ($model->defects) { ?>
	<div class="card card-default">
		<div class="card-header">Defect Sheets</div>
		<div class="card-body">
			<?php foreach ($model->defects as $a => $sh) { ?>
				
			<div class="row ">
				<div class="col-sm-1 data-label">Date:</div>
				<div class="col-sm-1"><?= $sh->date ?></div>
				
				
				<div class="col-sm-2"><?= HTML::A('<i class="fa fa-eye"></i>', ['/dt134/view', 'id' => $sh->id], ['title' => 'View Defect' ]); ?></div>
			</div>
			<?php } ?>
		</div>
	</div>
	<?php } ?>
	
	<?php if ($model->keys) { ?>
	<div class="card card-default">
		<div class="card-header">Keys</div>
		<div class="card-body">
			<?php foreach ($model->keys as $a => $sh) { ?>
				
			<div class="row ">
				<div class="col-sm-1 data-label">Type:</div>
				<div class="col-sm-1"><?= $sh->type ?></div>
				<div class="col-sm-1 data-label">Employee:</div>
				<div class="col-sm-2"><?= isset($sh->employeel) ? $sh->employeel->fullname : null ?></div>
				<div class="col-sm-1 data-label">Location:</div>
				<div class="col-sm-2"><?= $sh->location ?></div>
				<div class="col-sm-1 data-label">Peg:</div>
				<div class="col-sm-1"><?= $sh->peg ?></div>
				
				<div class="col-sm-2"><?= HTML::A('<i class="fa fa-eye"></i>', ['/vehiclekeys/view', 'id' => $sh->id], ['title' => 'View Service' ]); ?></div>
			</div>
			<?php } ?>
		</div>
	</div>
	<?php } ?>
	<?php if ($model->reminders) { ?>
	<div class="card card-default">
		<div class="card-header">Policies</div>
		<div class="card-body">
			<?php foreach ($model->reminders as $a => $sh) { ?>
				
			<div class="row ">
				<div class="col-sm-1 data-label">Type:</div>
				<div class="col-sm-2"><?= $sh->type ?></div>
				<div class="col-sm-1 data-label">Description:</div>
				<div class="col-sm-2"><?= $sh->description ?></div>
				<div class="col-sm-1 data-label">Employee:</div>
				<div class="col-sm-2"><?= isset($sh->employeel) ? $sh->employeel->fullname : null ?></div>
				<div class="col-sm-1 data-label">Status:</div>
				<div class="col-sm-1"><?= $sh->status ?></div>
				
				<div class="col-sm-1"><?= HTML::A('<i class="fa fa-eye"></i>', ['/vehiclereminders/view', 'id' => $sh->id], ['title' => 'View Service' ]); ?></div>
			</div>
			<?php } ?>
		</div>
	</div>
	<?php } ?>
	
	
	
	<?= $this->render('/uploads/files', ['files' => $model->files]); ?> 
   
</div>

