Improved filtering implemented.

This commit is contained in:
2014-05-16 18:23:18 -04:00
parent b2d57a9e5f
commit fe0bc4e9ff
14 changed files with 425 additions and 133 deletions
+11 -3
View File
@@ -2,9 +2,7 @@
using System.Linq;
using MileageTraker.Web.Models;
using MileageTraker.Web.Utility;
using MileageTraker.Web.ViewModels;
using MileageTraker.Web.ViewModels.CreateLog;
using MileageTraker.Web.ViewModels.Log;
using MiscUtil.Collections;
using NUnit.Framework;
using ImportLogViewModel = MileageTraker.Web.ViewModels.Log.ImportLogViewModel;
@@ -108,5 +106,15 @@ namespace Web.Tests.Utility
{
typeof (MileageLogType).ParseWithDisplayNames("None");
}
[Test]
public void YearMonthGroupTest()
{
var range = new Range<DateTime>(new DateTime(2011, 2, 4), new DateTime(2013, 6, 23));
var monthsBetween = range.FromStart(d => d.AddMonths(1));
var yearMonthList = CustomExtensions.YearMonthList(monthsBetween);
Assert.That(yearMonthList, Has.Count.EqualTo(3));
Assert.That(yearMonthList["2013"], Has.Count.EqualTo(6));
}
}
}
@@ -0,0 +1,55 @@
using MileageTraker.Web.Models;
using MileageTraker.Web.ViewModels.Log;
using NUnit.Framework;
namespace Web.Tests.ViewModels.Log
{
[TestFixture]
public class LogQueryViewModelTests
{
[Test]
public void YearMonthStartTest()
{
var model = new LogQueryViewModel {Year = 2011, Month=1};
var ym = model.YearMonthStart;
Assert.That(ym, Is.EqualTo("2011-01"));
}
[Test]
public void YearMonthEndTest()
{
var model = new LogQueryViewModel {Year = 2011, Month=1, MonthRange = 3};
var ym = model.YearMonthEnd;
Assert.That(ym, Is.EqualTo("2011-03"));
}
[Test]
public void YearMonthEnd_YearRoll_Test()
{
var model = new LogQueryViewModel { Year = 2011, Month = 6, MonthRange = 12 };
var ym = model.YearMonthEnd;
Assert.That(ym, Is.EqualTo("2012-05"));
}
[Test]
public void YearMonthEnd_YearRoll_NotQuite_Test()
{
var model = new LogQueryViewModel { Year = 2011, Month = 1, MonthRange = 12 };
var ym = model.YearMonthEnd;
Assert.That(ym, Is.EqualTo("2011-12"));
}
[Test]
public void AllTest()
{
var model = new LogQueryViewModel
{
Year = 2011, Month = 2, MonthRange = 12,
EmployeeName = "My Name",
LogType = MileageLogType.Commuting,
VehicleId = "1023"
};
Assert.That(model.ToString(), Is.EqualTo("2011-02to2012-01_Comm_1023_My-Name"));
}
}
}
+5
View File
@@ -44,6 +44,10 @@
<Private>True</Private>
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="MiscUtil, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d3c42c4bfacf7596, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\JonSkeet.MiscUtil.0.1\lib\net35-Client\MiscUtil.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.6.3.13283, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
@@ -98,6 +102,7 @@
<Compile Include="Utility\CustomExtensionsTests.cs" />
<Compile Include="ViewModels\CreateLog\CreateLogViewModelTests.cs" />
<Compile Include="ViewModels\CreateLog\LogImportViewModelTests.cs" />
<Compile Include="ViewModels\Log\LogQueryViewModelTests.cs" />
<Compile Include="ViewModels\Log\LogViewModelTests.cs" />
<Compile Include="ViewModels\User\CreateUserViewModelTests.cs" />
<Compile Include="ViewModels\User\EditUserViewModelTests.cs" />
+26 -33
View File
@@ -19,33 +19,36 @@ namespace MileageTraker.Web.Controllers
{
public ViewResult Index(LogQueryViewModel query)
{
var logs = DataService.GetLogs();
var validLogYearMonths = DataService.GetValidLogMonths();
var validLogYears = DataService.GetValidLogYears().ToList();
if (!validLogYears.Any())
if (!validLogYearMonths.Any()) // this means no logs in DB
return View("Empty");
if (!query.Year.HasValue)
query.Year = validLogYears.FirstOrDefault();
var validLogMonths = DataService.GetValidLogMonths(query.Year.Value).ToList();
if (!query.Month.HasValue)
query.Month = validLogMonths.FirstOrDefault();
// default parameter processing
if (!query.HasParameters())
{
query.Year = validLogYearMonths.First().Year;
query.Month = validLogYearMonths.First().Month;
query.MonthRange = 1;
}
if (query.Year.HasValue && !query.Month.HasValue)
{
var validLogMonths = validLogYearMonths.Where(dt => dt.Year == query.Year).ToList();
query.Month = validLogMonths.Min(dt => dt.Month);
query.MonthRange = validLogMonths.Max(dt => dt.Month) - query.Month + 1;
}
var filteredLogs =
from log in DataService.GetLogIndexViewModels(DataService.FilterLogs(logs, query))
orderby log.Created descending
select log;
var logs = DataService.GetLogs();
var viewModel =
new LogResultsViewModel
{
Logs = filteredLogs.ToList(),
Years = validLogYears,
Months = validLogMonths,
SelectedYear = query.Year.Value,
SelectedMonth = query.Month.Value,
SelectedLogType = query.LogType.ToString()
};
var filteredLogs =
(from log in DataService.GetLogIndexViewModels(DataService.FilterLogs(logs, query))
orderby log.Created descending
select log).ToList();
if (!filteredLogs.Any())
return View("Empty");
var viewModel = new LogResultsViewModel(filteredLogs, query, CustomExtensions.YearMonthList(validLogYearMonths));
Session.Add("LogPage", Request.Url.PathAndQuery);
@@ -61,11 +64,7 @@ namespace MileageTraker.Web.Controllers
DataService.FilterLogs(logs, query)
).ToList();
var name = string.Format(
"MileageLogs{0}-{1}{2}",
query.Year,
query.Month,
query.LogType.HasValue ? "-" + query.LogType.Value.GetDisplayShortName() : "");
var name = string.Format("MileageLogs_{0}", query);
var export = ExcelWriter<LogIndexViewModel>.WriteXls(filteredLogs, name, name);
return File(export, "application/ms-excel", name + ".xls");
@@ -229,12 +228,6 @@ namespace MileageTraker.Web.Controllers
return RedirectToAction("Index");
}
public JsonResult GetValidLogMonths(int year)
{
var validLogMonths = DataService.GetValidLogMonths(year);
return Json(validLogMonths, JsonRequestBehavior.AllowGet);
}
public PartialViewResult DetailsPartial(int id)
{
var log = DataService.GetLog(id);
+44 -20
View File
@@ -8,6 +8,7 @@ using MileageTraker.Web.Utility;
using MileageTraker.Web.ViewModels;
using MileageTraker.Web.ViewModels.Log;
using MileageTraker.Web.ViewModels.Vehicle;
using MiscUtil.Collections;
namespace MileageTraker.Web.DAL
{
@@ -117,28 +118,34 @@ namespace MileageTraker.Web.DAL
select l).FirstOrDefault();
}
public IEnumerable<int> GetValidLogYears()
public IList<DateTime> GetValidLogMonths()
{
return
from l in GetLogs()
group l by new {year = l.Date.Year}
into y
orderby y.Key descending
select y.Key.year;
var months =
from l in GetLogs()
group l by new {l.Date.Year, l.Date.Month}
into g
//let dt = new DateTime(g.Key.Year, g.Key.Month, 1)
select g.Key;
var ym =
from m in months.ToList()
select new DateTime(m.Year, m.Month, 1);
return ym.OrderByDescending(dt => dt).ToList();
}
public IEnumerable<int> GetValidLogMonths(int year)
{
var start = new DateTime(year, 1, 1);
var end = new DateTime(year + 1, 1, 1);
return
from l in GetLogs()
where l.Date >= start && l.Date < end
group l by new { month = l.Date.Month }
into m
orderby m.Key descending
select m.Key.month;
}
//public IEnumerable<int> GetValidLogMonths(int year)
//{
// var start = new DateTime(year, 1, 1);
// var end = new DateTime(year + 1, 1, 1);
// return
// from l in GetLogs()
// where l.Date >= start && l.Date < end
// group l by new { month = l.Date.Month }
// into m
// orderby m.Key descending
// select m.Key.month;
//}
public IEnumerable<LogIndexViewModel> GetLogIndexViewModels(IQueryable<Log> logs)
{
@@ -240,19 +247,36 @@ namespace MileageTraker.Web.DAL
public static IQueryable<Log> FilterLogs(IQueryable<Log> logs, LogQueryViewModel query)
{
// date filtering
if (query.Year.HasValue & query.Month.HasValue)
{
var start = new DateTime(query.Year.Value, query.Month.Value, 1);
var end = start.AddMonths(1);
var monthRange = query.MonthRange.HasValue ? query.MonthRange.Value : 1;
var end = start.AddMonths(monthRange);
logs = logs.Where(l => l.Date >= start && l.Date < end);
}
// log type
if (query.LogType.HasValue)
{
// WTF The specified value is not an instance of type 'Edm.Int32'
logs = logs.Where(query.LogType.Value.GetEqualsPredicate());
}
// employee name
if (!String.IsNullOrEmpty(query.EmployeeName))
{
logs = logs.Where(l =>
l.User.FullName == query.EmployeeName
|| l.User.Username == query.EmployeeName);
}
// vehicle id
if (!String.IsNullOrEmpty(query.VehicleId))
{
logs = logs.Where(l => l.VehicleId == query.VehicleId);
}
return logs;
}
+7 -7
View File
@@ -12,13 +12,13 @@ $(function () {
});
$("form select#Year").change(function () {
$.getJSON('/Log/GetValidLogMonths', { year: $(this).val() }, function (months) {
var options = '<option>Select Month</option>';
for (var i = 0; i < months.length; i++) {
options += '<option>' + months[i] + '</option>';
}
$("form select#Month").html(options);
});
var year = $(this).val();
var months = availableLogYearMonths[year];
var options = '<option>Select Month</option>';
for (var i = 0; i < months.length; i++) {
options += '<option>' + months[i] + '</option>';
}
$("form select#Month").html(options);
});
$("input#ModelYear,input#Price,input#VehicleId,input#EndOdometer,input#GasPurchased").numeric();
+113 -45
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel.DataAnnotations;
using System.Data.SqlTypes;
using System.Linq;
@@ -7,7 +8,9 @@ using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using System.Web.Mvc;
using System.Web.Routing;
using MileageTraker.Web.Models;
using MiscUtil.Collections;
namespace MileageTraker.Web.Utility
{
@@ -16,9 +19,9 @@ namespace MileageTraker.Web.Utility
public static string Wordify(this string str)
{
return str.Aggregate(
String.Empty,
(current, c) =>
current + (Char.IsUpper(c) ? " " + c : c.ToString()));
String.Empty,
(current, c) =>
current + (Char.IsUpper(c) ? " " + c : c.ToString()));
}
private static T GetAttribute<T>(this Enum enumeration) where T : Attribute
@@ -44,23 +47,23 @@ namespace MileageTraker.Web.Utility
{
var displayAttribute = GetAttribute<DisplayAttribute>(enumeration);
return displayAttribute != null
? (!String.IsNullOrEmpty(displayAttribute.ShortName)
? displayAttribute.ShortName
: displayAttribute.Name)
: enumeration.ToString();
? (!String.IsNullOrEmpty(displayAttribute.ShortName)
? displayAttribute.ShortName
: displayAttribute.Name)
: enumeration.ToString();
}
public static IEnumerable<SelectListItem> GetSelectListItems(this Enum enumeration)
{
var type = enumeration.GetType();
return Enum.GetValues(type)
.OfType<Enum>().Select(e =>
new SelectListItem
{
Text = e.GetDisplayName(),
Value = e.ToString(),
Selected = e.Equals(enumeration)
});
.OfType<Enum>().Select(e =>
new SelectListItem
{
Text = e.GetDisplayName(),
Value = e.ToString(),
Selected = e.Equals(enumeration)
});
}
public static Enum ParseWithDisplayNames(this Type enumType, string item)
@@ -74,7 +77,7 @@ namespace MileageTraker.Web.Utility
{
Func<string, bool> f = s => string.Equals(s, item, StringComparison.CurrentCultureIgnoreCase);
return Enum.GetValues(enumType)
.OfType<Enum>().Any(e => e.GetAllNameVariants().Any(f));
.OfType<Enum>().Any(e => e.GetAllNameVariants().Any(f));
}
public static IEnumerable<string> GetAllNameVariants(this Enum enumeration)
@@ -109,27 +112,29 @@ namespace MileageTraker.Web.Utility
var items = (from item in Enum.GetValues(enumType).OfType<Enum>()
let title = item.GetDisplayName()
select new SelectListItem
{
Value = item.ToString(),
Text = title,
Selected = selectedItem == item.ToString()
}).ToList();
{
Value = item.ToString(),
Text = title,
Selected = selectedItem == item.ToString()
}).ToList();
return new SelectList(new[]{new SelectListItem{Text = noItemSelected}}.Concat(items), "Value", "Text");
return new SelectList(new[] {new SelectListItem {Text = noItemSelected}}.Concat(items), "Value", "Text");
}
public static string GetName(this MemberInfo propertyMember)
{
var displayAttr = propertyMember.GetCustomAttributes(typeof(DisplayAttribute), true).FirstOrDefault() as DisplayAttribute;
var displayAttr =
propertyMember.GetCustomAttributes(typeof (DisplayAttribute), true).FirstOrDefault() as DisplayAttribute;
return displayAttr != null
? displayAttr.Name
: propertyMember.Name;
? displayAttr.Name
: propertyMember.Name;
}
public static object GetValue(this PropertyInfo propertyMember, object obj)
{
var value = propertyMember.GetValue(obj, null);
var displayAttr = propertyMember.GetCustomAttributes(typeof(DisplayFormatAttribute), true).FirstOrDefault() as DisplayFormatAttribute;
var displayAttr =
propertyMember.GetCustomAttributes(typeof (DisplayFormatAttribute), true).FirstOrDefault() as DisplayFormatAttribute;
if (displayAttr != null)
{
@@ -144,7 +149,7 @@ namespace MileageTraker.Web.Utility
public static IEnumerable<string> GetPropertyNames(this Type type)
{
return
return
from property in type.GetProperties()
select property.GetName();
}
@@ -164,34 +169,34 @@ namespace MileageTraker.Web.Utility
var sb = new StringBuilder();
Action<int, string> b = (var, name) =>
{
if (var > 0)
{
if (sb.Length > 0)
sb.Append(", ");
sb.Append(var + " " + name);
if (var > 1)
sb.Append("s");
}
};
if (var > 0)
{
if (sb.Length > 0)
sb.Append(", ");
sb.Append(var + " " + name);
if (var > 1)
sb.Append("s");
}
};
var timeLeft = ts;
var years = timeLeft.Days / 365; //no leap year accounting
var years = timeLeft.Days/365; //no leap year accounting
b(years, "year");
timeLeft -= new TimeSpan(years*365, 0, 0, 0);
var months = timeLeft.Days / 30; //naive guess at month size
b(months, "month");
timeLeft -= new TimeSpan(months * 30, 0, 0, 0);
var weeks = timeLeft.Days / 7;
var months = timeLeft.Days/30; //naive guess at month size
b(months, "month");
timeLeft -= new TimeSpan(months*30, 0, 0, 0);
var weeks = timeLeft.Days/7;
b(weeks, "week");
timeLeft -= new TimeSpan(weeks * 7, 0, 0, 0);
timeLeft -= new TimeSpan(weeks*7, 0, 0, 0);
var days = timeLeft.Days;
b(days, "day");
sb.Append(" ago");
return sb.ToString();
}
@@ -220,7 +225,7 @@ namespace MileageTraker.Web.Utility
var i = 0;
while (true) yield return i++;
}
/// <summary>
/// Users with activity date greater than this value are online
/// </summary>
@@ -231,5 +236,68 @@ namespace MileageTraker.Web.Utility
Convert.ToDouble(
System.Web.Security.Membership.UserIsOnlineTimeWindow)));
}
public static Dictionary<string, List<string>> YearMonthList(IEnumerable<DateTime> dates)
{
return
(from d in dates
orderby d.Year descending
group d by d.Year
into yg
select
new
{
Year = yg.Key.ToString(),
MonthList =
(from o in yg
orderby o.Month descending
group o by o.Month
into mg
select mg.Key.ToString()).ToList()
}).ToDictionary(arg => arg.Year, arg => arg.MonthList);
}
public static RouteValueDictionary ToRouteValueDictionary(this NameValueCollection collection)
{
var routeValueDictionary = new RouteValueDictionary();
foreach (var key in collection.AllKeys)
{
routeValueDictionary.Add(key, collection[key]);
}
return routeValueDictionary;
}
//public static IEnumerable<SelectListItem> ToSelectList<T>(
// this IEnumerable<T> enumerable,
// Func<T, string> text,
// Func<T, string> value,
// string selectedValue = null,
// string defaultOption = null)
//{
// var items = enumerable.Select(f => new SelectListItem
// {
// Text = text(f),
// Value = value(f),
// Selected = value(f) == selectedValue,
// }).ToList();
// if (!string.IsNullOrEmpty(defaultOption))
// {
// items.Insert(0, new SelectListItem
// {
// Text = defaultOption,
// Value = "-1"
// });
// }
// return items;
//}
//public static IEnumerable<SelectListItem> ToSelectList<T>(
// this IEnumerable<T> enumerable,
// string selectedValue = null,
// string defaultOption = null)
//{
// return enumerable.ToSelectList(t => t.ToString(), t => t.ToString());
//}
}
}
+2 -2
View File
@@ -100,9 +100,9 @@ namespace MileageTraker.Web.Utility
formatString = "#,##0.00";
if (value is DateTime && p.Name == "Date")
formatString = @"YYYY\-MM\-DD";
formatString = @"MM/DD/YYYY";
else if (value is DateTime)
formatString = @"YYYY\-MM\-DD hh:mm:ss";
formatString = @"MM/DD/YYYY hh:mm:ss";
int intValue; // write int-looking values as numbers
if (value is string && int.TryParse((string) value, out intValue))
+56
View File
@@ -1,4 +1,7 @@
using System;
using System.Collections.Generic;
using MileageTraker.Web.Models;
using MileageTraker.Web.Utility;
namespace MileageTraker.Web.ViewModels.Log
{
@@ -6,6 +9,59 @@ namespace MileageTraker.Web.ViewModels.Log
{
public int? Year { get; set; }
public int? Month { get; set; }
public int? MonthRange { get; set; }
public MileageLogType? LogType { get; set; }
public string EmployeeName { get; set; }
public string VehicleId { get; set; }
public string YearMonthStart {get
{
return string.Format("{0}-{1:00}", Year, Month);
}}
public string YearMonthEnd
{
get
{
var dateTime = new DateTime(Year.Value, Month.Value, 1);
var time = dateTime.AddMonths(MonthRange.Value - 1);
return string.Format("{0}-{1:00}", time.Year, time.Month);
}
}
public override string ToString()
{
var v = new List<string>();
//string.Format("{0}-{1}{2}", Year, Month, LogType.HasValue ? "-" + LogType.Value.GetDisplayShortName() : "");
if (Year.HasValue && Month.HasValue)
{
var str = YearMonthStart;
if (MonthRange.HasValue && MonthRange > 1)
str += "to" + YearMonthEnd;
v.Add(str);
}
if (LogType.HasValue)
v.Add(LogType.Value.GetDisplayShortName());
if (!string.IsNullOrEmpty(VehicleId))
v.Add(VehicleId);
if (!string.IsNullOrEmpty(EmployeeName))
v.Add(EmployeeName);
return String.Join("_", v).Replace(' ', '-');
}
public bool HasParameters()
{
return Year.HasValue ||
LogType.HasValue ||
!string.IsNullOrEmpty(EmployeeName) ||
!string.IsNullOrEmpty(VehicleId);
}
}
}
+42 -6
View File
@@ -1,14 +1,50 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using MiscUtil.Collections;
namespace MileageTraker.Web.ViewModels.Log
{
public class LogResultsViewModel
{
public IEnumerable<int> Years { get; set; }
public IEnumerable<int> Months { get; set; }
public IEnumerable<LogIndexViewModel> Logs { get; set; }
public int SelectedYear { get; set; }
public int SelectedMonth { get; set; }
public string SelectedLogType { get; set; }
public Dictionary<string, List<string>> AvailableYearMonths { get; set; }
public IEnumerable<string> SelectedYearMonths{get
{
if (!string.IsNullOrEmpty(Year))
return AvailableYearMonths[Year];
return new List<string>();
}}
// filter parameters
public string Year { get; set; }
public string Month { get; set; }
public string MonthRange { get; set; }
public string LogType { get; set; }
public string VehicleId { get; set; }
public string EmployeeName { get; set; }
public LogResultsViewModel(IEnumerable<LogIndexViewModel> logs, LogQueryViewModel query, Dictionary<string, List<string>> availableYearMonths)
{
Logs = logs;
AvailableYearMonths = availableYearMonths;
Year = query.Year.HasValue ? query.Year.Value.ToString() : string.Empty;
Month = query.Month.HasValue ? query.Month.Value.ToString() : string.Empty;
MonthRange = query.MonthRange.HasValue ? query.MonthRange.Value.ToString() : string.Empty;
LogType = query.LogType.ToString();
EmployeeName = query.EmployeeName;
VehicleId = query.VehicleId;
}
public bool SecondRowSet
{
get
{
return !string.IsNullOrEmpty(LogType) ||
!string.IsNullOrEmpty(VehicleId) ||
!string.IsNullOrEmpty(EmployeeName);
}
}
}
}
+24 -13
View File
@@ -8,22 +8,33 @@
@section Styles {
<link href="@Url.Content("~/Content/VehicleColors.css")" rel="stylesheet" type="text/css" />
}
@section Scripts {
<script type="text/javascript">
var availableLogYearMonths = @Html.Raw(Json.Encode(Model.AvailableYearMonths));
@if (Model.Year != null)
{
<text>var selectedYear = "@Model.Year";</text>
<text>var selectedMonth = "@Model.Month";</text>
}
</script>
}
@Html.Partial("_StatusMessage")
<div class="btn-toolbar pull-right">
@using (Html.BeginForm("Index", "Log", FormMethod.Get, new { id = "filter", @class = "form" }))
{
<div class="">
@Html.EditorForModel()
</div>
}
</div>
<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>
}
<div class="btn-toolbar clearfix">
@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" })
@Html.ActionLink("Export", "Export", new { Model.Year, Model.Month, Model.LogType, Model.MonthRange, Model.VehicleId, Model.EmployeeName }, new { @class = "btn" })
@Html.ActionLink("Purposes", "Index", "Purpose", null, new { @class = "btn" })
@Html.ActionLink("Import", "ImportUpload", null, new { @class = "btn"})
@@ -31,10 +42,10 @@
<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 })
@Html.ActionLink("Vehicle Mileage", "MonthlyVehicleMileage", new { Year = Model.Year, Month = Model.Month, LogType = Model.LogType })
</li>
<li>
@Html.ActionLink("Driver Mileage", "MonthlyDriverMileage", new { Year = Model.SelectedYear, Month = Model.SelectedMonth, LogType = Model.SelectedLogType })
@Html.ActionLink("Driver Mileage", "MonthlyDriverMileage", new { Year = Model.Year, Month = Model.Month, LogType = Model.LogType })
</li>
</ul>
</div>
@@ -67,7 +78,7 @@
return item.PurposePurpose;
}),
grid.Column("Driver Name", format: item => item.UserFullName),
grid.Column(format:
grid.Column("Total Results: " + Model.Logs.Count(), canSort:false, 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" })
@@ -1,7 +1,39 @@
@using MileageTraker.Web.Models
@using System.Xml
@using MileageTraker.Web.Models
@using MileageTraker.Web.Utility
@model MileageTraker.Web.ViewModels.Log.LogResultsViewModel
@{
var show = Model.SecondRowSet;
}
@Html.DropDownList("Year", new SelectList(Model.Years, Model.SelectedYear), new { @class = "input-small" })
@Html.DropDownList("Month", new SelectList(Model.Months, Model.SelectedMonth), new { @class = "input-mini" })
@Html.DropDownList("LogType", typeof(MileageLogType).ToSelectList(Model.SelectedLogType, "Log Type"), new { @class = "input-medium" })
<div class="row-fluid">
<div class="span4">
@Html.Label("Year", "Year")
@Html.DropDownList("Year", new SelectList(Model.AvailableYearMonths.Keys, Model.Year), "Select Year", new { @class = "input-small" })
</div>
<div class="span3">
@Html.Label("Month", "Month")
@Html.DropDownList("Month", new SelectList(Model.SelectedYearMonths, Model.Month), "Select Month", new { @class = "input-mini" })
</div>
<div class="span3">
@Html.Label("MonthRange", "Range")
@Html.DropDownList("MonthRange", new SelectList(Enumerable.Range(1,12), Model.MonthRange), new { @class = "input-mini" })
</div>
<div class="span2">
<input type="submit" value="Filter" class="btn" style="margin-top:1.75em" />
</div>
</div>
<div class="row-fluid@{ if (show) {<text> show</text>} }">
<div class="span5">
@Html.Label("LogType", "Log Type")
@Html.DropDownList("LogType", typeof(MileageLogType).ToSelectList(Model.LogType, "Log Type"), new { @class = "input-medium" })
</div>
<div class="span3">
@Html.Label("VehicleId", "Vehicle")
@Html.TextBoxFor(m => m.VehicleId, new {@class="search-query input-mini", placeholder="Vehicle"})
</div>
<div class="span4">
@Html.Label("EmployeeName", "User")
@Html.TextBoxFor(m => m.EmployeeName, new {@class="search-query input-small", placeholder="User"})
</div>
</div>
+3
View File
@@ -69,6 +69,9 @@
<Private>True</Private>
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="MiscUtil">
<HintPath>..\packages\JonSkeet.MiscUtil.0.1\lib\net35-Client\MiscUtil.dll</HintPath>
</Reference>
<Reference Include="MvcCheckBoxList, Version=1.4.4.5, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\MvcCheckBoxList.1.4.4.5\lib\net40\MvcCheckBoxList.dll</HintPath>
+1
View File
@@ -4,6 +4,7 @@
<package id="EntityFramework" version="4.3.1" />
<package id="ExcelLibrary" version="1.2011.7.30" />
<package id="FontAwesome" version="4.0.3.1" targetFramework="net40" />
<package id="JonSkeet.MiscUtil" version="0.1" targetFramework="net40" />
<package id="jQuery" version="2.1.0" targetFramework="net40" />
<package id="jQuery.Migrate" version="1.2.1" targetFramework="net40" />
<package id="jQuery.Validation" version="1.12.0" targetFramework="net40" />