Fuel Log Import basic functionality

This commit is contained in:
2015-09-18 13:02:15 -04:00
parent 4987215f0b
commit e3590b29e5
18 changed files with 438 additions and 59 deletions
+9
View File
@@ -0,0 +1,9 @@
@{
ViewBag.Title = "No Fuel Logs";
}
<h2 class="center-content">@ViewBag.Title</h2>
<div class="center-content well">
No Fuel logs have been added yet. @Html.ActionLink("Import", "ImportUpload", null, new { @class = "btn" })
</div>
+36 -30
View File
@@ -1,4 +1,5 @@
@model IList<MileageTraker.Web.Models.FuelLog>
@using MileageTraker.Web.ViewModels.FuelLog
@model IList<ImportFuelLogViewModel>
@{
ViewBag.Title = "Import Fuel Logs";
@@ -8,58 +9,63 @@
<link href="@Url.Content("~/Content/font-awesome.min.css")" rel="stylesheet" type="text/css" />
}
@{ Html.RenderPartial("BackToLogs"); }
@Html.Partial("_StatusMessage")
<h2>@ViewBag.Title</h2>
<p>Driver: <strong>@ViewData["UserFullName"]</strong></p>
<h5>Matching Mileage Logs based on Date, Vehicle, and Gas Purchased</h5>
<p id="page-import-status"></p>
<p id="page-match-status"></p>
<table id="logs" class="table table-striped table-bordered table-hover table-condensed">
<table id="fuellogs" class="table table-striped table-bordered table-hover table-condensed">
<thead>
<tr>
<th>Import Status</th>
<th style="width:20%"></th>
<th>Vehicle ID</th>
<th>End Odometer</th>
<th>Type</th>
<th>Destination City</th>
<th>Purpose</th>
<th>Notes</th>
<th>Gas Purchased</th>
<th>Match Status</th>
<th style="width:15%"></th>
<th>Date</th>
<th>Driver</th>
<th>Tag Number</th>
<th>Odometer</th>
<th>MPG</th>
<th>Gas Purchased</th>
<th>Total Price</th>
</tr>
</thead>
@for (var i = 0; i < Model.Count; i++)
{
var viewModel = Model[i];
<tr id="log-@i">
@using (Html.BeginForm("ImportCreate", "Log", FormMethod.Post))
<tr id="fuellog-@i" @if (viewModel.PreviouslyAdded && viewModel.LogId != null) { <text>class="complete"</text>}>
@using (Html.BeginForm("Match", "FuelLog", FormMethod.Post))
{
@Html.EditorFor(x => viewModel)
<input type="hidden" name="fuelLogId" value="@viewModel.FuelLogId"/>
}
<td class="import-status"></td>
<td class="import-message"></td>
<td>@Html.ValueFor(x => viewModel.VehicleId)</td>
<td>@Html.ValueFor(x => viewModel.EndOdometer)</td>
<td>@Html.ValueFor(x => viewModel.LogType)</td>
<td>@Html.ValueFor(x => viewModel.CityName)</td>
<td>@Html.ValueFor(x => viewModel.Purpose)</td>
<td>@Html.ValueFor(x => viewModel.Notes)</td>
<td>@Html.ValueFor(x => viewModel.GasPurchased)</td>
<td>@Html.ValueFor(x => viewModel.Date)</td>
<td class="match-status">
@if (viewModel.PreviouslyAdded)
{
<span class="label label-info">Previously Imported</span>
}
@if (viewModel.LogId != null)
{
@Html.Partial("ImportMatchedLog", new ImportMatchedLogViewModel { LogId = viewModel.LogId.Value })
}
</td>
<td class="match-message"></td>
<td>@Html.ValueFor(x => viewModel.Date, "{0:d}")</td>
<td>@Html.ValueFor(x => viewModel.DriverFullName)</td>
<td>@Html.ValueFor(x => viewModel.TagNumber)</td>
<td>@Html.ValueFor(x => viewModel.Odometer)</td>
<td>@Html.ValueFor(x => viewModel.MPG)</td>
<td>@Html.ValueFor(x => viewModel.GasPurchased, "{0:0.000}")</td>
<td>@Html.ValueFor(x => viewModel.TotalPrice, "{0:C}")</td>
</tr>
}
</table>
@section Scripts
{
<script src="@Url.Content("~/Scripts/Shared/ImportCreate.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/Shared/FuelLogImport.js")" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
importLogs("@ViewData["UserFullName"]");
importFuelLogs();
});
</script>
}
@@ -0,0 +1,5 @@
@model MileageTraker.Web.ViewModels.FuelLog.ImportMatchedLogViewModel
@{
Layout = null;
}
@Html.ActionLink("View Log", "Details", "Log", new{id=Model.LogId}, new{@class="btn btn-mini", target="_blank"})
+1 -1
View File
@@ -1,4 +1,4 @@
@model MileageTraker.Web.ViewModels.FuelLog.FuelLogImportUploadViewModel
@model MileageTraker.Web.ViewModels.FuelLog.ImportUploadViewModel
@{
ViewBag.Title = "Import Fuel Logs";
}
+67
View File
@@ -0,0 +1,67 @@
@using MileageTraker.Web.Utility
@model MileageTraker.Web.ViewModels.FuelLog.ResultsViewModel
@{
ViewBag.Title = "Fuel Logs";
var grid = new WebGrid(Model.Logs, rowsPerPage: 45);
var parameters = new {Model.Year, Model.Month};
}
@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 clearfix">
@Html.ActionLink("Import", "ImportUpload", null, new { @class = "btn" })
@Html.ActionLink("Export", "Export", parameters, new { @class = "btn" })
</div>
<div>
@grid.GetHtml(columns:
grid.Columns(
grid.Column("Date", format: item => item.Date.ToString("d")),
grid.Column("DriverFullName", "Driver Name"),
grid.Column("TagNumber"),
grid.Column("Odometer"),
grid.Column("MPG"),
grid.Column("GasPurchased", "Gas Purchased", @<text>@String.Format("{0:0.000}", item.GasPurchased)</text>),
grid.Column("TotalPrice", "Total Price", @<text>@String.Format("{0:C}", item.TotalPrice)</text>),
grid.Column("Log", "Matched Log", @<text>
@(item.Log != null
? Html.ActionLink("View Log", "Details", "Log", new {id = item.Log.LogId}, new {@class = "btn btn-mini", target="_blank"})
: Html.ActionLink("Match", "Match", new {id = item.FuelLogId}, new {@class = "btn btn-warning btn-mini", target="_blank"}))
</text>),
grid.Column("Total Results: " + Model.Logs.Count(), canSort:false, format:
@<div class='btn-group'> @Html.ActionLink("Details", "Details", new { id = item.FuelLogId }, new { @class = "btn btn-mini" }) </div>)),
htmlAttributes: new { @class = "table table-striped table-bordered table-hover table-condensed"},
numericLinksCount: 20
)
</div>
@if (!Model.Logs.Any())
{
<div>
No results.
</div>
}