@model MileageTraker.Web.ViewModels.Vehicle.VehicleResultsViewModel

@{
	ViewBag.Title = "Vehicles " + (!Model.Inactive ? "(Active)" : "(Inactive)");
}

@section Styles {
    <link href="@Url.Content("~/Content/VehicleColors.css")" rel="stylesheet" type="text/css" />
}

@Html.Partial("_StatusMessage")

<h2 id="vehicle-title"><i class="fa fa-car"></i> @ViewBag.Title</h2>

<div class="btn-toolbar">
    @Html.ActionLink("Add Vehicle", "Create", null, new{@class="btn"})
    @Html.ActionLink("Export All", "Export", null, new { @class = "btn" })
	@Html.ActionLink(Model.Inactive ? "Show Active" : "Show Inactive", "Index", new {inactive = !Model.Inactive}, new { @class = "btn" })
</div>
<table class="table table-striped table-bordered table-hover table-condensed">
    <tr>
        <th>
            Key
        </th>
        <th>
            Id
        </th>
        <th>
            Year, Make, Model
        </th>
        <th>
            Type
        </th>
        <th>
            Tag Number
        </th>
        <th>
            Prog
        </th>
        <th>
            Assigned
        </th>
	    <th>
		    ODO
	    </th>
	    <th>
		    Next Service
	    </th>
        <th></th>
    </tr>

@foreach (var item in Model.Vehicles) {
    <tr>
        <td>
            @Html.DisplayTextFor(m => item.Key)
        </td>
        <td>
            @Html.DisplayTextFor(m => item.VehicleId)
        </td>
        <td>
            @Html.DisplayTextFor(m => item.ModelYear) @Html.DisplayTextFor(m => item.Make) @Html.DisplayTextFor(m => item.CarModel)
        </td>
        <td>
            <span class="label @item.Color">
                @Html.DisplayTextFor(m => item.Type)
            </span>
        </td>
        <td>
            @Html.DisplayTextFor(m => item.TagNumber)
        </td>
        <td>
            @Html.DisplayTextFor(m => item.Prog)
        </td>
        <td>
            @Html.DisplayTextFor(m => item.Assigned) @if(!string.IsNullOrEmpty(item.Notes)) {
                                                         <small class="muted"><em>@Html.DisplayTextFor(m => item.Notes)</em></small>
                                                         }
        </td>
	    <td>
		    @Html.DisplayTextFor(m => item.CurrentOdometer)
	    </td>
	    <td>
		    @Html.DisplayTextFor(m => item.NextServiceOdometer)
		    @if (item.IsNextServiceOverdue)
		    {
			    <span class="badge badge-warning" title="overdue @(-item.NextServiceDueInMiles) miles">!</span>
		    }
		    @Html.ActionLink("Reminder", "Index", "ServiceReminder", new { vehicleId = item.VehicleId }, new { @class = "btn btn-mini pull-right" })
	    </td>
        <td>
            <div class='btn-group'>
                @Html.ActionLink("Details", "Details", new { id = item.VehicleId }, new { @class = "btn btn-mini" })
            </div>
        </td>
    </tr>
}

</table>
