diff --git a/Web.Tests/Utility/CustomExtensionsTests.cs b/Web.Tests/Utility/CustomExtensionsTests.cs index 61919ae..c76fa47 100644 --- a/Web.Tests/Utility/CustomExtensionsTests.cs +++ b/Web.Tests/Utility/CustomExtensionsTests.cs @@ -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(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)); + } } } diff --git a/Web.Tests/ViewModels/Log/LogQueryViewModelTests.cs b/Web.Tests/ViewModels/Log/LogQueryViewModelTests.cs new file mode 100644 index 0000000..7eb1034 --- /dev/null +++ b/Web.Tests/ViewModels/Log/LogQueryViewModelTests.cs @@ -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")); + } + } +} diff --git a/Web.Tests/Web.Tests.csproj b/Web.Tests/Web.Tests.csproj index 87ed44e..56614f6 100644 --- a/Web.Tests/Web.Tests.csproj +++ b/Web.Tests/Web.Tests.csproj @@ -44,6 +44,10 @@ True ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll + + False + ..\packages\JonSkeet.MiscUtil.0.1\lib\net35-Client\MiscUtil.dll + False ..\packages\NUnit.2.6.3\lib\nunit.framework.dll @@ -98,6 +102,7 @@ + diff --git a/Web/Controllers/LogController.cs b/Web/Controllers/LogController.cs index a541579..51272dd 100644 --- a/Web/Controllers/LogController.cs +++ b/Web/Controllers/LogController.cs @@ -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.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); diff --git a/Web/DAL/DataService.cs b/Web/DAL/DataService.cs index 2584129..9d246af 100644 --- a/Web/DAL/DataService.cs +++ b/Web/DAL/DataService.cs @@ -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 GetValidLogYears() + public IList 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 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 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 GetLogIndexViewModels(IQueryable logs) { @@ -240,19 +247,36 @@ namespace MileageTraker.Web.DAL public static IQueryable FilterLogs(IQueryable 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; } diff --git a/Web/Scripts/Shared/Site.js b/Web/Scripts/Shared/Site.js index 1f44e3b..67d4577 100644 --- a/Web/Scripts/Shared/Site.js +++ b/Web/Scripts/Shared/Site.js @@ -12,13 +12,13 @@ $(function () { }); $("form select#Year").change(function () { - $.getJSON('/Log/GetValidLogMonths', { year: $(this).val() }, function (months) { - var options = ''; - for (var i = 0; i < months.length; i++) { - options += ''; - } - $("form select#Month").html(options); - }); + var year = $(this).val(); + var months = availableLogYearMonths[year]; + var options = ''; + for (var i = 0; i < months.length; i++) { + options += ''; + } + $("form select#Month").html(options); }); $("input#ModelYear,input#Price,input#VehicleId,input#EndOdometer,input#GasPurchased").numeric(); diff --git a/Web/Utility/CustomExtensions.cs b/Web/Utility/CustomExtensions.cs index 3fac838..74eead0 100644 --- a/Web/Utility/CustomExtensions.cs +++ b/Web/Utility/CustomExtensions.cs @@ -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(this Enum enumeration) where T : Attribute @@ -44,23 +47,23 @@ namespace MileageTraker.Web.Utility { var displayAttribute = GetAttribute(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 GetSelectListItems(this Enum enumeration) { var type = enumeration.GetType(); return Enum.GetValues(type) - .OfType().Select(e => - new SelectListItem - { - Text = e.GetDisplayName(), - Value = e.ToString(), - Selected = e.Equals(enumeration) - }); + .OfType().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 f = s => string.Equals(s, item, StringComparison.CurrentCultureIgnoreCase); return Enum.GetValues(enumType) - .OfType().Any(e => e.GetAllNameVariants().Any(f)); + .OfType().Any(e => e.GetAllNameVariants().Any(f)); } public static IEnumerable GetAllNameVariants(this Enum enumeration) @@ -109,27 +112,29 @@ namespace MileageTraker.Web.Utility var items = (from item in Enum.GetValues(enumType).OfType() 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 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 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++; } - + /// /// Users with activity date greater than this value are online /// @@ -231,5 +236,68 @@ namespace MileageTraker.Web.Utility Convert.ToDouble( System.Web.Security.Membership.UserIsOnlineTimeWindow))); } + + public static Dictionary> YearMonthList(IEnumerable 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 ToSelectList( + // this IEnumerable enumerable, + // Func text, + // Func 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 ToSelectList( + // this IEnumerable enumerable, + // string selectedValue = null, + // string defaultOption = null) + //{ + // return enumerable.ToSelectList(t => t.ToString(), t => t.ToString()); + //} } } \ No newline at end of file diff --git a/Web/Utility/ExcelWriter.cs b/Web/Utility/ExcelWriter.cs index 4f012e1..4bb9eef 100644 --- a/Web/Utility/ExcelWriter.cs +++ b/Web/Utility/ExcelWriter.cs @@ -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)) diff --git a/Web/ViewModels/Log/LogQueryViewModel.cs b/Web/ViewModels/Log/LogQueryViewModel.cs index 19013ec..8324e9d 100644 --- a/Web/ViewModels/Log/LogQueryViewModel.cs +++ b/Web/ViewModels/Log/LogQueryViewModel.cs @@ -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.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); + } } } \ No newline at end of file diff --git a/Web/ViewModels/Log/LogResultsViewModel.cs b/Web/ViewModels/Log/LogResultsViewModel.cs index d2cd54d..5b59817 100644 --- a/Web/ViewModels/Log/LogResultsViewModel.cs +++ b/Web/ViewModels/Log/LogResultsViewModel.cs @@ -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 Years { get; set; } - public IEnumerable Months { get; set; } public IEnumerable Logs { get; set; } - public int SelectedYear { get; set; } - public int SelectedMonth { get; set; } - public string SelectedLogType { get; set; } + public Dictionary> AvailableYearMonths { get; set; } + public IEnumerable SelectedYearMonths{get + { + if (!string.IsNullOrEmpty(Year)) + return AvailableYearMonths[Year]; + return new List(); + }} + + // 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 logs, LogQueryViewModel query, Dictionary> 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); + } + } } } \ No newline at end of file diff --git a/Web/Views/Log/Index.cshtml b/Web/Views/Log/Index.cshtml index 3286697..614c3ab 100644 --- a/Web/Views/Log/Index.cshtml +++ b/Web/Views/Log/Index.cshtml @@ -8,22 +8,33 @@ @section Styles { } +@section Scripts { + +} @Html.Partial("_StatusMessage") +
+ @using (Html.BeginForm("Index", "Log", FormMethod.Get, new { id = "filter", @class = "form" })) + { +
+ @Html.EditorForModel() +
+ } +
+

@ViewBag.Title

-
- @using (Html.BeginForm("Index", "Log", FormMethod.Get, new { id = "filter", @class = "form-inline" })) - { -
- @Html.EditorForModel() - -
- } - +
@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 @@ Report
@@ -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: @
@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" }) diff --git a/Web/Views/Shared/EditorTemplates/LogResultsViewModel.cshtml b/Web/Views/Shared/EditorTemplates/LogResultsViewModel.cshtml index 08506a6..f3ee738 100644 --- a/Web/Views/Shared/EditorTemplates/LogResultsViewModel.cshtml +++ b/Web/Views/Shared/EditorTemplates/LogResultsViewModel.cshtml @@ -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" }) \ No newline at end of file +
+
+ @Html.Label("Year", "Year") + @Html.DropDownList("Year", new SelectList(Model.AvailableYearMonths.Keys, Model.Year), "Select Year", new { @class = "input-small" }) +
+
+ @Html.Label("Month", "Month") + @Html.DropDownList("Month", new SelectList(Model.SelectedYearMonths, Model.Month), "Select Month", new { @class = "input-mini" }) +
+
+ @Html.Label("MonthRange", "Range") + @Html.DropDownList("MonthRange", new SelectList(Enumerable.Range(1,12), Model.MonthRange), new { @class = "input-mini" }) +
+
+ +
+
+
+
+ @Html.Label("LogType", "Log Type") + @Html.DropDownList("LogType", typeof(MileageLogType).ToSelectList(Model.LogType, "Log Type"), new { @class = "input-medium" }) +
+
+ @Html.Label("VehicleId", "Vehicle") + @Html.TextBoxFor(m => m.VehicleId, new {@class="search-query input-mini", placeholder="Vehicle"}) +
+
+ @Html.Label("EmployeeName", "User") + @Html.TextBoxFor(m => m.EmployeeName, new {@class="search-query input-small", placeholder="User"}) +
+
diff --git a/Web/Web.csproj b/Web/Web.csproj index aba48a3..71b391f 100644 --- a/Web/Web.csproj +++ b/Web/Web.csproj @@ -69,6 +69,9 @@ True ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll + + ..\packages\JonSkeet.MiscUtil.0.1\lib\net35-Client\MiscUtil.dll + False ..\packages\MvcCheckBoxList.1.4.4.5\lib\net40\MvcCheckBoxList.dll diff --git a/Web/packages.config b/Web/packages.config index 05bd546..d73b197 100644 --- a/Web/packages.config +++ b/Web/packages.config @@ -4,6 +4,7 @@ +