@model MileageTraker.Web.ViewModels.DriverMileageViewModel
@{
    ViewBag.Title = "Driver Mileage Report";
}

@{ Html.RenderPartial("BackToLogs"); }

@Html.Partial("_StatusMessage")

<h2><i class="fa fa-road"></i> @ViewBag.Title</h2>

<div class="btn-toolbar clearfix">
	@Html.ActionLink("Export", "ExportDriverMileageReport", Model.Query, new { @class = "btn no-print" })
</div>

@Html.DisplayFor(m => m.Query)

<table class="table">
    <tr>
        <th>
            Driver
        </th>
        <th>
            Vehicle
        </th>
		<th>
			Trips
		</th>
        <th>
            Total Miles
        </th>
        <th>
            Total Gas Purchased
        </th>
    </tr>
    @foreach (var item in Model.Items)
    {
        <tr>
            <td colspan="5"><strong>@Html.DisplayTextFor(i => item.DriverName)</strong></td>
        </tr>
        foreach (var vehicleItem in item.VehicleMileageItems)
        {
            <tr>
                <td style="border-top: 0"></td>
                <td>
                    @Html.DisplayTextFor(i => vehicleItem.VehicleId)
                    (@Html.DisplayTextFor(i => vehicleItem.Prog))
                </td>
                <td>
                    @Html.DisplayTextFor(i => vehicleItem.TripCount)
                </td>
	            <td>
		            @Html.DisplayTextFor(i => vehicleItem.Miles)
		            <small>@Html.ActionLink("Logs", "Index", Model.Query.CloneSet(vehicleItem.VehicleId, item.DriverName), new {@class="no-print"})</small>
	            </td>
                <td>
                    @Html.DisplayTextFor(i => vehicleItem.GasPurchased)
                </td>
            </tr>
        
        }
        <tr>
            <td style="border-top: 0"></td>
            <td style="text-align: right">
                <strong>
                    Total:
                </strong>
            </td>
            <td>
                <strong>
                    @Html.DisplayTextFor(i => item.TripCount)
                </strong>
            </td>
            <td>
                <strong>
                    @Html.DisplayTextFor(i => item.Miles)
                </strong>
            </td>
            <td>
                <strong>
                    @Html.DisplayTextFor(i => item.GasPurchased)
                </strong>
            </td>
        </tr>
    }
    <tfoot>
        <tr>
            <td colspan="2" style="text-align: right"><strong>Grand Total:</strong></td>
            <td><strong>@Html.DisplayTextFor(m => m.TotalTrips)</strong></td>
            <td><strong>@Html.DisplayTextFor(m => m.TotalMiles)</strong></td>
            <td><strong>@Html.DisplayTextFor(m => m.TotalGasPurchased)</strong></td>
        </tr>
    </tfoot>
</table>
