Add vehicle filtering for fuellog and vehicle service
This commit is contained in:
@@ -663,6 +663,10 @@ namespace MileageTraker.Web.DAL
|
|||||||
{
|
{
|
||||||
fuelLogs = fuelLogs.Where(l => l.Log == null);
|
fuelLogs = fuelLogs.Where(l => l.Log == null);
|
||||||
}
|
}
|
||||||
|
if (!string.IsNullOrEmpty(query.TagNumber))
|
||||||
|
{
|
||||||
|
fuelLogs = fuelLogs.Where(l => l.TagNumber == query.TagNumber);
|
||||||
|
}
|
||||||
return fuelLogs;
|
return fuelLogs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -842,8 +846,10 @@ namespace MileageTraker.Web.DAL
|
|||||||
var start = new DateTime(query.Year.Value, query.Month.Value, 1);
|
var start = new DateTime(query.Year.Value, query.Month.Value, 1);
|
||||||
var monthRange = query.MonthRange.HasValue ? query.MonthRange.Value : 1;
|
var monthRange = query.MonthRange.HasValue ? query.MonthRange.Value : 1;
|
||||||
var end = start.AddMonths(monthRange);
|
var end = start.AddMonths(monthRange);
|
||||||
vehicleServices = vehicleServices.Where(l => l.InvoiceDate >= start && l.InvoiceDate < end);
|
vehicleServices = vehicleServices.Where(vs => vs.InvoiceDate >= start && vs.InvoiceDate < end);
|
||||||
}
|
}
|
||||||
|
if (!string.IsNullOrEmpty(query.VehicleId))
|
||||||
|
vehicleServices = vehicleServices.Where(vs => vs.Vehicle.VehicleId == query.VehicleId);
|
||||||
return vehicleServices;
|
return vehicleServices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -151,6 +151,8 @@ var matchCountFunc = function() {
|
|||||||
} else {
|
} else {
|
||||||
$link.append(" <span class='badge'>0</span>");
|
$link.append(" <span class='badge'>0</span>");
|
||||||
}
|
}
|
||||||
|
$link
|
||||||
|
.append(' <sup><i class="fa fa-clone"></i></sup>');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -233,8 +235,15 @@ function addButtonIcons () {
|
|||||||
.prepend('<i class="icon-user icon-white" /> ');
|
.prepend('<i class="icon-user icon-white" /> ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function addTargetBlankIcon() {
|
||||||
|
$("a[target='_blank']:not(:has(i:last-child))")
|
||||||
|
.append(' <sup><i class="fa fa-clone"></i></sup>');
|
||||||
|
}
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
addButtonIcons();
|
addButtonIcons();
|
||||||
|
addTargetBlankIcon();
|
||||||
});
|
});
|
||||||
|
|
||||||
// Convert MVC3 WebGrid paging to Bootstrap
|
// Convert MVC3 WebGrid paging to Bootstrap
|
||||||
|
|||||||
@@ -3,5 +3,19 @@ namespace MileageTraker.Web.ViewModels.FuelLog
|
|||||||
public class FuelLogQueryViewModel : DateQueryViewModel
|
public class FuelLogQueryViewModel : DateQueryViewModel
|
||||||
{
|
{
|
||||||
public bool Unmatched { get; set; }
|
public bool Unmatched { get; set; }
|
||||||
|
|
||||||
|
public string TagNumber { get; set; }
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(TagNumber))
|
||||||
|
return base.ToString();
|
||||||
|
return base.ToString() + "_" + TagNumber.Replace(' ', '-');
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool HasParameters()
|
||||||
|
{
|
||||||
|
return base.HasParameters() || !string.IsNullOrEmpty(TagNumber);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,6 +22,7 @@ namespace MileageTraker.Web.ViewModels.FuelLog
|
|||||||
public string Month { get; set; }
|
public string Month { get; set; }
|
||||||
public string MonthRange { get; set; }
|
public string MonthRange { get; set; }
|
||||||
public bool Unmatched { get; set; }
|
public bool Unmatched { get; set; }
|
||||||
|
public string TagNumber { get; set; }
|
||||||
|
|
||||||
public FuelLogResultsViewModel(
|
public FuelLogResultsViewModel(
|
||||||
IEnumerable<FuelLogIndexViewModel> fuelLogs,
|
IEnumerable<FuelLogIndexViewModel> fuelLogs,
|
||||||
@@ -34,6 +35,7 @@ namespace MileageTraker.Web.ViewModels.FuelLog
|
|||||||
Month = query.Month.HasValue ? query.Month.Value.ToString(CultureInfo.InvariantCulture) : string.Empty;
|
Month = query.Month.HasValue ? query.Month.Value.ToString(CultureInfo.InvariantCulture) : string.Empty;
|
||||||
MonthRange = query.MonthRange.HasValue ? query.MonthRange.Value.ToString(CultureInfo.InvariantCulture) : string.Empty;
|
MonthRange = query.MonthRange.HasValue ? query.MonthRange.Value.ToString(CultureInfo.InvariantCulture) : string.Empty;
|
||||||
Unmatched = query.Unmatched;
|
Unmatched = query.Unmatched;
|
||||||
|
TagNumber = query.TagNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,5 +2,18 @@ namespace MileageTraker.Web.ViewModels.VehicleService
|
|||||||
{
|
{
|
||||||
public class VehicleServiceQueryViewModel : DateQueryViewModel
|
public class VehicleServiceQueryViewModel : DateQueryViewModel
|
||||||
{
|
{
|
||||||
|
public string VehicleId { get; set; }
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(VehicleId))
|
||||||
|
return base.ToString();
|
||||||
|
return base.ToString() + "_" + VehicleId.Replace(' ', '-');
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool HasParameters()
|
||||||
|
{
|
||||||
|
return base.HasParameters() || !string.IsNullOrEmpty(VehicleId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,6 +23,7 @@ namespace MileageTraker.Web.ViewModels.VehicleService
|
|||||||
public string Year { get; set; }
|
public string Year { get; set; }
|
||||||
public string Month { get; set; }
|
public string Month { get; set; }
|
||||||
public string MonthRange { get; set; }
|
public string MonthRange { get; set; }
|
||||||
|
public string VehicleId { get; set; }
|
||||||
|
|
||||||
public VehicleServiceResultsViewModel(
|
public VehicleServiceResultsViewModel(
|
||||||
IEnumerable<VehicleServiceViewModel> serviceItems,
|
IEnumerable<VehicleServiceViewModel> serviceItems,
|
||||||
@@ -36,6 +37,7 @@ namespace MileageTraker.Web.ViewModels.VehicleService
|
|||||||
Year = query.Year.HasValue ? query.Year.Value.ToString(CultureInfo.InvariantCulture) : string.Empty;
|
Year = query.Year.HasValue ? query.Year.Value.ToString(CultureInfo.InvariantCulture) : string.Empty;
|
||||||
Month = query.Month.HasValue ? query.Month.Value.ToString(CultureInfo.InvariantCulture) : string.Empty;
|
Month = query.Month.HasValue ? query.Month.Value.ToString(CultureInfo.InvariantCulture) : string.Empty;
|
||||||
MonthRange = query.MonthRange.HasValue ? query.MonthRange.Value.ToString(CultureInfo.InvariantCulture) : string.Empty;
|
MonthRange = query.MonthRange.HasValue ? query.MonthRange.Value.ToString(CultureInfo.InvariantCulture) : string.Empty;
|
||||||
|
VehicleId = query.VehicleId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
@{
|
@{
|
||||||
ViewBag.Title = "Fuel Logs";
|
ViewBag.Title = "Fuel Logs";
|
||||||
var grid = new WebGrid(Model.FuelLogs, rowsPerPage: 45);
|
var grid = new WebGrid(Model.FuelLogs, rowsPerPage: 45);
|
||||||
var queryParams = new {FiscalYear = Model.Year, Model.Month, Model.Unmatched};
|
var queryParams = new {FiscalYear = Model.Year, Model.Month, Model.Unmatched, Model.TagNumber};
|
||||||
}
|
}
|
||||||
|
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
@Html.Partial("_StatusMessage")
|
@Html.Partial("_StatusMessage")
|
||||||
|
|
||||||
<div class="btn-toolbar pull-right" style="width:400px">
|
<div class="btn-toolbar pull-right" style="width:600px">
|
||||||
@using (Html.BeginForm("Index", "FuelLog", FormMethod.Get, new { id = "filter", @class = "form" }))
|
@using (Html.BeginForm("Index", "FuelLog", FormMethod.Get, new { id = "filter", @class = "form" }))
|
||||||
{
|
{
|
||||||
@Html.EditorForModel()
|
@Html.EditorForModel()
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
@model MileageTraker.Web.ViewModels.FuelLog.FuelLogResultsViewModel
|
@model MileageTraker.Web.ViewModels.FuelLog.FuelLogResultsViewModel
|
||||||
|
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span3">
|
<div class="span2">
|
||||||
@Html.Label("Year", "Year")
|
@Html.Label("Year", "Year")
|
||||||
@Html.DropDownList("Year", new SelectList(Model.AvailableYearMonths.Keys, Model.Year), "Select Year", new { @class = "input-small" })
|
@Html.DropDownList("Year", new SelectList(Model.AvailableYearMonths.Keys, Model.Year), "Select Year", new { @class = "input-small" })
|
||||||
</div>
|
</div>
|
||||||
@@ -15,7 +15,11 @@
|
|||||||
@Html.Label("MonthRange", "Range")
|
@Html.Label("MonthRange", "Range")
|
||||||
@Html.DropDownList("MonthRange", new SelectList(Enumerable.Range(1,12), Model.MonthRange), new { @class = "input-mini" })
|
@Html.DropDownList("MonthRange", new SelectList(Enumerable.Range(1,12), Model.MonthRange), new { @class = "input-mini" })
|
||||||
</div>
|
</div>
|
||||||
<div class="span3" >
|
<div class="span2">
|
||||||
|
@Html.Label("TagNumber", "Tag Number")
|
||||||
|
@Html.TextBoxFor(m => m.TagNumber, new {@class="search-query input-mini", placeholder="Vehicle"})
|
||||||
|
</div>
|
||||||
|
<div class="span2" >
|
||||||
@Html.Label("Unmatched", "Unmatched Only", new{style = "padding-top:22px"})
|
@Html.Label("Unmatched", "Unmatched Only", new{style = "padding-top:22px"})
|
||||||
<input id="Unmatched" name="Unmatched" type="checkbox" @(Model.Unmatched ? "checked='checked'" : "" ) value="true" />
|
<input id="Unmatched" name="Unmatched" type="checkbox" @(Model.Unmatched ? "checked='checked'" : "" ) value="true" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,11 +3,11 @@
|
|||||||
@model MileageTraker.Web.ViewModels.VehicleService.VehicleServiceResultsViewModel
|
@model MileageTraker.Web.ViewModels.VehicleService.VehicleServiceResultsViewModel
|
||||||
|
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span4">
|
<div class="span2">
|
||||||
@Html.Label("Year", "Year")
|
@Html.Label("Year", "Year")
|
||||||
@Html.DropDownList("Year", new SelectList(Model.AvailableYearMonths.Keys, Model.Year), "Select Year", new { @class = "input-small" })
|
@Html.DropDownList("Year", new SelectList(Model.AvailableYearMonths.Keys, Model.Year), "Select Year", new { @class = "input-small" })
|
||||||
</div>
|
</div>
|
||||||
<div class="span3">
|
<div class="span2">
|
||||||
@Html.Label("Month", "Month")
|
@Html.Label("Month", "Month")
|
||||||
@Html.DropDownList("Month", new SelectList(Model.SelectedYearMonths, Model.Month), "All Months", new { @class = "input-small" })
|
@Html.DropDownList("Month", new SelectList(Model.SelectedYearMonths, Model.Month), "All Months", new { @class = "input-small" })
|
||||||
</div>
|
</div>
|
||||||
@@ -15,6 +15,10 @@
|
|||||||
@Html.Label("MonthRange", "Range")
|
@Html.Label("MonthRange", "Range")
|
||||||
@Html.DropDownList("MonthRange", new SelectList(Enumerable.Range(1,12), Model.MonthRange), new { @class = "input-mini" })
|
@Html.DropDownList("MonthRange", new SelectList(Enumerable.Range(1,12), Model.MonthRange), new { @class = "input-mini" })
|
||||||
</div>
|
</div>
|
||||||
|
<div class="span3">
|
||||||
|
@Html.Label("VehicleId", "Vehicle Id")
|
||||||
|
@Html.TextBoxFor(m => m.VehicleId, new {@class="search-query input-mini", placeholder="Vehicle"})
|
||||||
|
</div>
|
||||||
<div class="span2">
|
<div class="span2">
|
||||||
<input type="submit" value="Filter" class="btn" style="margin-top:1.75em" />
|
<input type="submit" value="Filter" class="btn" style="margin-top:1.75em" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
@{
|
@{
|
||||||
ViewBag.Title = "Vehicle Service";
|
ViewBag.Title = "Vehicle Service";
|
||||||
var grid = new WebGrid(Model.ServiceItems, rowsPerPage: 45);
|
var grid = new WebGrid(Model.ServiceItems, rowsPerPage: 45);
|
||||||
var queryParams = new { Model.Year, Model.Month, Model.MonthRange };
|
var queryParams = new { Model.Year, Model.Month, Model.MonthRange, Model.VehicleId };
|
||||||
}
|
}
|
||||||
|
|
||||||
@section Scripts {
|
@section Scripts {
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
@Html.Partial("_StatusMessage")
|
@Html.Partial("_StatusMessage")
|
||||||
|
|
||||||
<div class="btn-toolbar pull-right" style="width:400px">
|
<div class="btn-toolbar pull-right" style="width:600px">
|
||||||
@using (Html.BeginForm("Index", "VehicleService", FormMethod.Get, new { id = "filter", @class = "form" }))
|
@using (Html.BeginForm("Index", "VehicleService", FormMethod.Get, new { id = "filter", @class = "form" }))
|
||||||
{
|
{
|
||||||
@Html.EditorForModel()
|
@Html.EditorForModel()
|
||||||
|
|||||||
Reference in New Issue
Block a user