Files
MileageTraker/Web/Views/Log/Index.cshtml
T

71 lines
3.5 KiB
Plaintext

@using MileageTraker.Web.Utility
@model MileageTraker.Web.ViewModels.Log.LogResultsViewModel
@{
ViewBag.Title = "Logs";
var grid = new WebGrid(Model.Logs, rowsPerPage: 45);
}
@section Styles {
<link href="@Url.Content("~/Content/VehicleColors.css")" rel="stylesheet" type="text/css" />
}
@Html.Partial("_StatusMessage")
<h2 id="log-title">@ViewBag.Title</h2>
<div class="btn-toolbar">
@using (Html.BeginForm("Index", "Log", FormMethod.Get, new { id = "filter", @class = "form-inline" }))
{
<div class="input-append pull-right">
@Html.EditorForModel()
<input type="submit" value="Filter" class="btn" />
</div>
}
@Html.ActionLink("Add New Log", "Create", null, new { @class = "btn" })
@Html.ActionLink("Export", "Export", new { Year = Model.SelectedYear, Month = Model.SelectedMonth, LogType = Model.SelectedLogType }, new { @class = "btn" })
<div class="btn-group">
<a class="btn dropdown-toggle" data-toggle="dropdown" href="#">Report <span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
@Html.ActionLink("Vehicle Mileage", "MonthlyVehicleMileage", new { Year = Model.SelectedYear, Month = Model.SelectedMonth, LogType = Model.SelectedLogType })
</li>
<li>
@Html.ActionLink("Employee Mileage", "MonthlyEmployeeMileage", new { Year = Model.SelectedYear, Month = Model.SelectedMonth, LogType = Model.SelectedLogType })
</li>
</ul>
</div>
</div>
<div>
@grid.GetHtml(columns:
grid.Columns(
grid.Column("VehicleId", "Vehicle ID", item => Html.ActionLink((string)item.VehicleId, "DetailsPartial", "Vehicle", new { id = item.VehicleId }, new { @class = "qtip-modal" })),
grid.Column("EndOdometer", "End ODO"),
grid.Column("Miles", canSort: false, format: item =>
{
if (item.PreviousLogId != null)
{
string miles = (item.EndOdometer - item.PreviousLogEndOdometer).ToString();
return Html.ActionLink(miles, "DetailsPartial", new { id = item.PreviousLogId }, new { @class = "qtip-modal" });
}
return Html.Raw("<span class='miles-unknown'>?</span>");
}),
grid.Column("LogType", "Type", item => ((Enum)item.LogType).GetDisplayShortName()),
grid.Column("GasPurchased", "Gas", item => item.GasPurchased > 0 ? String.Format("{0:0.000}", item.GasPurchased) : string.Empty),
grid.Column("Date", format: item => item.Date.ToString("d")),
grid.Column("CityName", "City Name"),
grid.Column("Driver Name", format: item => item.User != null ? item.User.FullName : ""),
grid.Column(format:
@<div class='btn-group'>
@Html.ActionLink("Edit", "Edit", new { id = item.LogId }, new { @class = "btn btn-mini" })
@Html.ActionLink("Details", "Details", new { id = item.LogId }, new { @class = "btn btn-mini" })
@Html.ActionLink("Delete", "Delete", new { id = item.LogId }, new { @class = "btn btn-mini" })
</div>)
),
htmlAttributes: new { @class = "table table-striped table-bordered table-hover table-condensed"},
numericLinksCount: 20
)
</div>