Merge pull request #727 from hargata/Hargata/716
Added functionality to display multi year trends.
This commit is contained in:
@@ -558,6 +558,55 @@ namespace CarCareTracker.Controllers
|
||||
}).ToList();
|
||||
return PartialView("_GasCostByMonthReport", groupedRecord);
|
||||
}
|
||||
[TypeFilter(typeof(CollaboratorFilter))]
|
||||
[HttpPost]
|
||||
public IActionResult GetCostByMonthAndYearByVehicle(int vehicleId, List<ImportMode> selectedMetrics, int year = 0)
|
||||
{
|
||||
List<CostForVehicleByMonth> allCosts = StaticHelper.GetBaseLineCosts();
|
||||
if (selectedMetrics.Contains(ImportMode.ServiceRecord))
|
||||
{
|
||||
var serviceRecords = _serviceRecordDataAccess.GetServiceRecordsByVehicleId(vehicleId);
|
||||
allCosts.AddRange(_reportHelper.GetServiceRecordSum(serviceRecords, year, true));
|
||||
}
|
||||
if (selectedMetrics.Contains(ImportMode.RepairRecord))
|
||||
{
|
||||
var repairRecords = _collisionRecordDataAccess.GetCollisionRecordsByVehicleId(vehicleId);
|
||||
allCosts.AddRange(_reportHelper.GetRepairRecordSum(repairRecords, year, true));
|
||||
}
|
||||
if (selectedMetrics.Contains(ImportMode.UpgradeRecord))
|
||||
{
|
||||
var upgradeRecords = _upgradeRecordDataAccess.GetUpgradeRecordsByVehicleId(vehicleId);
|
||||
allCosts.AddRange(_reportHelper.GetUpgradeRecordSum(upgradeRecords, year, true));
|
||||
}
|
||||
if (selectedMetrics.Contains(ImportMode.GasRecord))
|
||||
{
|
||||
var gasRecords = _gasRecordDataAccess.GetGasRecordsByVehicleId(vehicleId);
|
||||
allCosts.AddRange(_reportHelper.GetGasRecordSum(gasRecords, year, true));
|
||||
}
|
||||
if (selectedMetrics.Contains(ImportMode.TaxRecord))
|
||||
{
|
||||
var taxRecords = _taxRecordDataAccess.GetTaxRecordsByVehicleId(vehicleId);
|
||||
allCosts.AddRange(_reportHelper.GetTaxRecordSum(taxRecords, year, true));
|
||||
}
|
||||
if (selectedMetrics.Contains(ImportMode.OdometerRecord))
|
||||
{
|
||||
var odometerRecords = _odometerRecordDataAccess.GetOdometerRecordsByVehicleId(vehicleId);
|
||||
allCosts.AddRange(_reportHelper.GetOdometerRecordSum(odometerRecords, year, true));
|
||||
}
|
||||
var groupedRecord = allCosts.GroupBy(x => new { x.MonthName, x.MonthId, x.Year }).OrderByDescending(x=>x.Key.Year).Select(x => new CostForVehicleByMonth
|
||||
{
|
||||
Year = x.Key.Year,
|
||||
MonthName = x.Key.MonthName,
|
||||
Cost = x.Sum(y => y.Cost),
|
||||
DistanceTraveled = x.Max(y => y.DistanceTraveled),
|
||||
MonthId = x.Key.MonthId
|
||||
}).ToList();
|
||||
var vehicleData = _dataAccess.GetVehicleById(vehicleId);
|
||||
var userConfig = _config.GetUserConfig(User);
|
||||
var viewModel = new CostDistanceTableForVehicle { CostData = groupedRecord };
|
||||
viewModel.DistanceUnit = vehicleData.UseHours ? "h" : userConfig.UseMPG ? "mi." : "km";
|
||||
return PartialView("_CostDistanceTableReport", viewModel);
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult GetAdditionalWidgets()
|
||||
{
|
||||
|
||||
@@ -5,35 +5,59 @@ namespace CarCareTracker.Helper
|
||||
{
|
||||
public interface IReportHelper
|
||||
{
|
||||
IEnumerable<CostForVehicleByMonth> GetOdometerRecordSum(List<OdometerRecord> odometerRecords, int year = 0);
|
||||
IEnumerable<CostForVehicleByMonth> GetServiceRecordSum(List<ServiceRecord> serviceRecords, int year = 0);
|
||||
IEnumerable<CostForVehicleByMonth> GetRepairRecordSum(List<CollisionRecord> repairRecords, int year = 0);
|
||||
IEnumerable<CostForVehicleByMonth> GetUpgradeRecordSum(List<UpgradeRecord> upgradeRecords, int year = 0);
|
||||
IEnumerable<CostForVehicleByMonth> GetGasRecordSum(List<GasRecord> gasRecords, int year = 0);
|
||||
IEnumerable<CostForVehicleByMonth> GetTaxRecordSum(List<TaxRecord> taxRecords, int year = 0);
|
||||
IEnumerable<CostForVehicleByMonth> GetOdometerRecordSum(List<OdometerRecord> odometerRecords, int year = 0, bool sortIntoYear = false);
|
||||
IEnumerable<CostForVehicleByMonth> GetServiceRecordSum(List<ServiceRecord> serviceRecords, int year = 0, bool sortIntoYear = false);
|
||||
IEnumerable<CostForVehicleByMonth> GetRepairRecordSum(List<CollisionRecord> repairRecords, int year = 0, bool sortIntoYear = false);
|
||||
IEnumerable<CostForVehicleByMonth> GetUpgradeRecordSum(List<UpgradeRecord> upgradeRecords, int year = 0, bool sortIntoYear = false);
|
||||
IEnumerable<CostForVehicleByMonth> GetGasRecordSum(List<GasRecord> gasRecords, int year = 0, bool sortIntoYear = false);
|
||||
IEnumerable<CostForVehicleByMonth> GetTaxRecordSum(List<TaxRecord> taxRecords, int year = 0, bool sortIntoYear = false);
|
||||
}
|
||||
public class ReportHelper: IReportHelper
|
||||
{
|
||||
public IEnumerable<CostForVehicleByMonth> GetOdometerRecordSum(List<OdometerRecord> odometerRecords, int year = 0)
|
||||
public IEnumerable<CostForVehicleByMonth> GetOdometerRecordSum(List<OdometerRecord> odometerRecords, int year = 0, bool sortIntoYear = false)
|
||||
{
|
||||
if (year != default)
|
||||
{
|
||||
odometerRecords.RemoveAll(x => x.Date.Year != year);
|
||||
}
|
||||
if (sortIntoYear)
|
||||
{
|
||||
return odometerRecords.GroupBy(x => new { x.Date.Month, x.Date.Year }).OrderBy(x => x.Key.Month).Select(x => new CostForVehicleByMonth
|
||||
{
|
||||
MonthId = x.Key.Month,
|
||||
MonthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(x.Key.Month),
|
||||
Year = x.Key.Year,
|
||||
Cost = 0,
|
||||
DistanceTraveled = x.Sum(y => y.DistanceTraveled)
|
||||
});
|
||||
} else
|
||||
{
|
||||
return odometerRecords.GroupBy(x => x.Date.Month).OrderBy(x => x.Key).Select(x => new CostForVehicleByMonth
|
||||
{
|
||||
MonthId = x.Key,
|
||||
MonthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(x.Key),
|
||||
Cost = 0,
|
||||
DistanceTraveled = x.Sum(y=>y.DistanceTraveled)
|
||||
DistanceTraveled = x.Sum(y => y.DistanceTraveled)
|
||||
});
|
||||
}
|
||||
public IEnumerable<CostForVehicleByMonth> GetServiceRecordSum(List<ServiceRecord> serviceRecords, int year = 0)
|
||||
}
|
||||
public IEnumerable<CostForVehicleByMonth> GetServiceRecordSum(List<ServiceRecord> serviceRecords, int year = 0, bool sortIntoYear = false)
|
||||
{
|
||||
if (year != default)
|
||||
{
|
||||
serviceRecords.RemoveAll(x => x.Date.Year != year);
|
||||
}
|
||||
if (sortIntoYear)
|
||||
{
|
||||
return serviceRecords.GroupBy(x => new { x.Date.Month, x.Date.Year }).OrderBy(x => x.Key.Month).Select(x => new CostForVehicleByMonth
|
||||
{
|
||||
MonthId = x.Key.Month,
|
||||
MonthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(x.Key.Month),
|
||||
Year = x.Key.Year,
|
||||
Cost = x.Sum(y => y.Cost)
|
||||
});
|
||||
} else
|
||||
{
|
||||
return serviceRecords.GroupBy(x => x.Date.Month).OrderBy(x => x.Key).Select(x => new CostForVehicleByMonth
|
||||
{
|
||||
MonthId = x.Key,
|
||||
@@ -41,12 +65,24 @@ namespace CarCareTracker.Helper
|
||||
Cost = x.Sum(y => y.Cost)
|
||||
});
|
||||
}
|
||||
public IEnumerable<CostForVehicleByMonth> GetRepairRecordSum(List<CollisionRecord> repairRecords, int year = 0)
|
||||
}
|
||||
public IEnumerable<CostForVehicleByMonth> GetRepairRecordSum(List<CollisionRecord> repairRecords, int year = 0, bool sortIntoYear = false)
|
||||
{
|
||||
if (year != default)
|
||||
{
|
||||
repairRecords.RemoveAll(x => x.Date.Year != year);
|
||||
}
|
||||
if (sortIntoYear)
|
||||
{
|
||||
return repairRecords.GroupBy(x => new { x.Date.Month, x.Date.Year }).OrderBy(x => x.Key.Month).Select(x => new CostForVehicleByMonth
|
||||
{
|
||||
MonthId = x.Key.Month,
|
||||
MonthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(x.Key.Month),
|
||||
Year = x.Key.Year,
|
||||
Cost = x.Sum(y => y.Cost)
|
||||
});
|
||||
} else
|
||||
{
|
||||
return repairRecords.GroupBy(x => x.Date.Month).OrderBy(x => x.Key).Select(x => new CostForVehicleByMonth
|
||||
{
|
||||
MonthId = x.Key,
|
||||
@@ -54,12 +90,24 @@ namespace CarCareTracker.Helper
|
||||
Cost = x.Sum(y => y.Cost)
|
||||
});
|
||||
}
|
||||
public IEnumerable<CostForVehicleByMonth> GetUpgradeRecordSum(List<UpgradeRecord> upgradeRecords, int year = 0)
|
||||
}
|
||||
public IEnumerable<CostForVehicleByMonth> GetUpgradeRecordSum(List<UpgradeRecord> upgradeRecords, int year = 0, bool sortIntoYear = false)
|
||||
{
|
||||
if (year != default)
|
||||
{
|
||||
upgradeRecords.RemoveAll(x => x.Date.Year != year);
|
||||
}
|
||||
if (sortIntoYear)
|
||||
{
|
||||
return upgradeRecords.GroupBy(x => new { x.Date.Month, x.Date.Year }).OrderBy(x => x.Key.Month).Select(x => new CostForVehicleByMonth
|
||||
{
|
||||
MonthId = x.Key.Month,
|
||||
MonthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(x.Key.Month),
|
||||
Year = x.Key.Year,
|
||||
Cost = x.Sum(y => y.Cost)
|
||||
});
|
||||
} else
|
||||
{
|
||||
return upgradeRecords.GroupBy(x => x.Date.Month).OrderBy(x => x.Key).Select(x => new CostForVehicleByMonth
|
||||
{
|
||||
MonthId = x.Key,
|
||||
@@ -67,12 +115,24 @@ namespace CarCareTracker.Helper
|
||||
Cost = x.Sum(y => y.Cost)
|
||||
});
|
||||
}
|
||||
public IEnumerable<CostForVehicleByMonth> GetGasRecordSum(List<GasRecord> gasRecords, int year = 0)
|
||||
}
|
||||
public IEnumerable<CostForVehicleByMonth> GetGasRecordSum(List<GasRecord> gasRecords, int year = 0, bool sortIntoYear = false)
|
||||
{
|
||||
if (year != default)
|
||||
{
|
||||
gasRecords.RemoveAll(x => x.Date.Year != year);
|
||||
}
|
||||
if (sortIntoYear)
|
||||
{
|
||||
return gasRecords.GroupBy(x => new { x.Date.Month, x.Date.Year }).OrderBy(x => x.Key.Month).Select(x => new CostForVehicleByMonth
|
||||
{
|
||||
MonthId = x.Key.Month,
|
||||
MonthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(x.Key.Month),
|
||||
Year = x.Key.Year,
|
||||
Cost = x.Sum(y => y.Cost)
|
||||
});
|
||||
} else
|
||||
{
|
||||
return gasRecords.GroupBy(x => x.Date.Month).OrderBy(x => x.Key).Select(x => new CostForVehicleByMonth
|
||||
{
|
||||
MonthId = x.Key,
|
||||
@@ -80,12 +140,24 @@ namespace CarCareTracker.Helper
|
||||
Cost = x.Sum(y => y.Cost)
|
||||
});
|
||||
}
|
||||
public IEnumerable<CostForVehicleByMonth> GetTaxRecordSum(List<TaxRecord> taxRecords, int year = 0)
|
||||
}
|
||||
public IEnumerable<CostForVehicleByMonth> GetTaxRecordSum(List<TaxRecord> taxRecords, int year = 0, bool sortIntoYear = false)
|
||||
{
|
||||
if (year != default)
|
||||
{
|
||||
taxRecords.RemoveAll(x => x.Date.Year != year);
|
||||
}
|
||||
if (sortIntoYear)
|
||||
{
|
||||
return taxRecords.GroupBy(x => new { x.Date.Month, x.Date.Year }).OrderBy(x => x.Key.Month).Select(x => new CostForVehicleByMonth
|
||||
{
|
||||
MonthId = x.Key.Month,
|
||||
MonthName = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(x.Key.Month),
|
||||
Year = x.Key.Year,
|
||||
Cost = x.Sum(y => y.Cost)
|
||||
});
|
||||
} else
|
||||
{
|
||||
return taxRecords.GroupBy(x => x.Date.Month).OrderBy(x => x.Key).Select(x => new CostForVehicleByMonth
|
||||
{
|
||||
MonthId = x.Key,
|
||||
@@ -94,4 +166,5 @@ namespace CarCareTracker.Helper
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -601,6 +601,27 @@ namespace CarCareTracker.Helper
|
||||
_csv.NextRecord();
|
||||
}
|
||||
}
|
||||
public static string HideZeroCost(string input, bool hideZero, string decorations = "")
|
||||
{
|
||||
if (input == 0M.ToString("C2") && hideZero)
|
||||
{
|
||||
return "---";
|
||||
} else
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(decorations) ? input : $"{input}{decorations}";
|
||||
}
|
||||
}
|
||||
public static string HideZeroCost(decimal input, bool hideZero, string decorations = "")
|
||||
{
|
||||
if (input == default && hideZero)
|
||||
{
|
||||
return "---";
|
||||
}
|
||||
else
|
||||
{
|
||||
return string.IsNullOrWhiteSpace(decorations) ? input.ToString("C2") : $"{input.ToString("C2")}{decorations}";
|
||||
}
|
||||
}
|
||||
public static void WriteGasRecordExportModel(CsvWriter _csv, IEnumerable<GasRecordExportModel> genericRecords)
|
||||
{
|
||||
var extraHeaders = genericRecords.SelectMany(x => x.ExtraFields).Select(y => y.Name).Distinct();
|
||||
|
||||
8
Models/Report/CostDistanceTableForVehicle.cs
Normal file
8
Models/Report/CostDistanceTableForVehicle.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace CarCareTracker.Models
|
||||
{
|
||||
public class CostDistanceTableForVehicle
|
||||
{
|
||||
public string DistanceUnit { get; set; } = "mi.";
|
||||
public List<CostForVehicleByMonth> CostData { get; set; } = new List<CostForVehicleByMonth>();
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,11 @@
|
||||
{
|
||||
public class CostForVehicleByMonth
|
||||
{
|
||||
public int Year { get; set; }
|
||||
public int MonthId { get; set; }
|
||||
public string MonthName { get; set; }
|
||||
public decimal Cost { get; set; }
|
||||
public int DistanceTraveled { get; set; }
|
||||
public decimal CostPerDistanceTraveled { get { if (DistanceTraveled > 0) { return Cost / DistanceTraveled; } else { return 0M; } } }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,12 +145,14 @@
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="d-flex">
|
||||
<td class="col-12 showOnPrint lubelogger-report-banner">
|
||||
@StaticHelper.ReportNote
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
97
Views/Vehicle/_CostDistanceTableReport.cshtml
Normal file
97
Views/Vehicle/_CostDistanceTableReport.cshtml
Normal file
@@ -0,0 +1,97 @@
|
||||
@using CarCareTracker.Helper
|
||||
@inject IConfigHelper config
|
||||
@inject ITranslationHelper translator
|
||||
@model CostDistanceTableForVehicle
|
||||
@{
|
||||
var userConfig = config.GetUserConfig(User);
|
||||
var userLanguage = userConfig.UserLanguage;
|
||||
var hideZero = userConfig.HideZero;
|
||||
var years = Model.CostData.Select(x => x.Year).Distinct();
|
||||
if (years.Count() > 5){
|
||||
years = years.Take(5); //if there is more than 5 years of data then we only take the last 5 years.
|
||||
}
|
||||
var months = Model.CostData.OrderBy(x => x.MonthId).Select(x => x.MonthName).Distinct();
|
||||
}
|
||||
@if (Model.CostData.Any())
|
||||
{
|
||||
<div>
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">@(translator.Translate(userLanguage, "Vehicle Monthly Cost Breakdown"))</h5>
|
||||
<button type="button" class="btn-close" onclick="hideDataTable()" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<table class="table table-hover">
|
||||
<thead class="sticky-top">
|
||||
<tr class="d-flex">
|
||||
<th scope="col" onclick="toggleBarChartTableData()" class="col-1 flex-grow-1 flex-shrink-1 text-truncate">@(translator.Translate(userLanguage, "Year"))</th>
|
||||
@foreach(int year in years){
|
||||
if (year != default){
|
||||
<th scope="col" onclick="toggleBarChartTableData()" class="col-1 flex-grow-1 flex-shrink-1 text-truncate">@year</th>
|
||||
}
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach(string month in months){
|
||||
<tr class="d-flex">
|
||||
<td class="col-1 flex-grow-1 flex-shrink-1 text-truncate">@month</td>
|
||||
@foreach(int year in years){
|
||||
if (year != default){
|
||||
{
|
||||
var dataToDisplay = Model.CostData.Where(x => x.Year == year && x.MonthName == month).FirstOrDefault();
|
||||
if (dataToDisplay != null && dataToDisplay != default)
|
||||
{
|
||||
<td class="col-1 flex-grow-1 flex-shrink-1 text-truncate" report-data="cost">@(StaticHelper.HideZeroCost(dataToDisplay.Cost.ToString("C2"), hideZero))</td>
|
||||
<td class="col-1 flex-grow-1 flex-shrink-1 text-truncate d-none" report-data="distance">@(dataToDisplay.DistanceTraveled != default ? $"{dataToDisplay.DistanceTraveled.ToString("N0")} {Model.DistanceUnit}" : "---")</td>
|
||||
<td class="col-1 flex-grow-1 flex-shrink-1 text-truncate d-none" report-data="costperdistance">@(StaticHelper.HideZeroCost(dataToDisplay.CostPerDistanceTraveled.ToString("C2"), hideZero, $"/{Model.DistanceUnit}"))</td>
|
||||
} else {
|
||||
<td class="col-1 flex-grow-1 flex-shrink-1 text-truncate" report-data="cost">@(StaticHelper.HideZeroCost(0M.ToString("C2"), hideZero))</td>
|
||||
<td class="col-1 flex-grow-1 flex-shrink-1 text-truncate d-none" report-data="distance">@("---")</td>
|
||||
<td class="col-1 flex-grow-1 flex-shrink-1 text-truncate d-none" report-data="costperdistance">@($"{StaticHelper.HideZeroCost(0M.ToString("C2"), hideZero)}")</td>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="d-flex fw-bold">
|
||||
<td class="col-1 flex-grow-1 flex-shrink-1 text-truncate">@(translator.Translate(userLanguage, "Total"))</td>
|
||||
@foreach (int year in years)
|
||||
{
|
||||
if (year != default)
|
||||
{
|
||||
{
|
||||
var yearDataToDisplay = Model.CostData.Where(x => x.Year == year);
|
||||
if (yearDataToDisplay != null && yearDataToDisplay != default)
|
||||
{
|
||||
<td class="col-1 flex-grow-1 flex-shrink-1 text-truncate" report-data="cost">@(StaticHelper.HideZeroCost(yearDataToDisplay.Sum(x => x.Cost).ToString("C2"), hideZero))</td>
|
||||
<td class="col-1 flex-grow-1 flex-shrink-1 text-truncate d-none" report-data="distance">@(yearDataToDisplay.Sum(x => x.DistanceTraveled) != default ? $"{yearDataToDisplay.Sum(x => x.DistanceTraveled).ToString("N0")} {Model.DistanceUnit}" : "---")</td>
|
||||
<td class="col-1 flex-grow-1 flex-shrink-1 text-truncate d-none" report-data="costperdistance">@(StaticHelper.HideZeroCost(yearDataToDisplay.Sum(x => x.CostPerDistanceTraveled).ToString("C2"), hideZero, $"/{Model.DistanceUnit}"))</td>
|
||||
}
|
||||
else
|
||||
{
|
||||
<td class="col-1 flex-grow-1 flex-shrink-1 text-truncate" report-data="cost">@(StaticHelper.HideZeroCost(0M.ToString("C2"), hideZero))</td>
|
||||
<td class="col-1 flex-grow-1 flex-shrink-1 text-truncate d-none" report-data="distance">@("---")</td>
|
||||
<td class="col-1 flex-grow-1 flex-shrink-1 text-truncate d-none" report-data="costperdistance">@($"{StaticHelper.HideZeroCost(0M.ToString("C2"), hideZero)}")</td>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="text-center">
|
||||
<h4>@translator.Translate(userLanguage, "No data found or all records have zero sums, insert records with non-zero sums to see visualizations here.")</h4>
|
||||
</div>
|
||||
}
|
||||
@@ -217,12 +217,14 @@
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="d-flex">
|
||||
<td class="col-12 showOnPrint lubelogger-report-banner">
|
||||
@StaticHelper.ReportNote
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -52,6 +52,9 @@
|
||||
]
|
||||
},
|
||||
options: {
|
||||
onClick: (e) => {
|
||||
showBarChartTable();
|
||||
},
|
||||
plugins: {
|
||||
title: {
|
||||
display: true,
|
||||
|
||||
@@ -55,12 +55,14 @@
|
||||
<td class="col-9 text-truncate" data-record-type="cost">@StaticHelper.TruncateStrings(note.NoteText, 100)</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="d-flex">
|
||||
<td class="col-12 showOnPrint lubelogger-report-banner">
|
||||
@StaticHelper.ReportNote
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -145,12 +145,14 @@
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="d-flex">
|
||||
<td class="col-12 showOnPrint lubelogger-report-banner">
|
||||
@StaticHelper.ReportNote
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -105,12 +105,14 @@
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="d-flex">
|
||||
<td class="col-12 showOnPrint lubelogger-report-banner">
|
||||
@StaticHelper.ReportNote
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -143,12 +143,14 @@
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="d-flex">
|
||||
<td class="col-12 showOnPrint lubelogger-report-banner">
|
||||
@StaticHelper.ReportNote
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -161,12 +161,14 @@
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="d-flex">
|
||||
<td class="col-12 showOnPrint lubelogger-report-banner">
|
||||
@StaticHelper.ReportNote
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -137,12 +137,14 @@
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="d-flex">
|
||||
<td class="col-12 showOnPrint lubelogger-report-banner">
|
||||
@StaticHelper.ReportNote
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -145,12 +145,14 @@
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="d-flex">
|
||||
<td class="col-12 showOnPrint lubelogger-report-banner">
|
||||
@StaticHelper.ReportNote
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -153,12 +153,14 @@
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr class="d-flex">
|
||||
<td class="col-12 showOnPrint lubelogger-report-banner">
|
||||
@StaticHelper.ReportNote
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -176,6 +176,58 @@ function refreshBarChart() {
|
||||
});
|
||||
setSelectedMetrics();
|
||||
}
|
||||
function showBarChartTable() {
|
||||
var selectedMetrics = [];
|
||||
var vehicleId = GetVehicleId().vehicleId;
|
||||
var year = getYear();
|
||||
|
||||
if ($("#serviceExpenseCheck").is(":checked")) {
|
||||
selectedMetrics.push('ServiceRecord');
|
||||
}
|
||||
if ($("#repairExpenseCheck").is(":checked")) {
|
||||
selectedMetrics.push('RepairRecord');
|
||||
}
|
||||
if ($("#upgradeExpenseCheck").is(":checked")) {
|
||||
selectedMetrics.push('UpgradeRecord');
|
||||
}
|
||||
if ($("#gasExpenseCheck").is(":checked")) {
|
||||
selectedMetrics.push('GasRecord');
|
||||
}
|
||||
if ($("#taxExpenseCheck").is(":checked")) {
|
||||
selectedMetrics.push('TaxRecord');
|
||||
}
|
||||
if ($("#odometerExpenseCheck").is(":checked")) {
|
||||
selectedMetrics.push('OdometerRecord');
|
||||
}
|
||||
|
||||
$.post('/Vehicle/GetCostByMonthAndYearByVehicle',
|
||||
{
|
||||
vehicleId: vehicleId,
|
||||
selectedMetrics: selectedMetrics,
|
||||
year: year
|
||||
}, function (data) {
|
||||
$("#vehicleDataTableModalContent").html(data);
|
||||
$("#vehicleDataTableModal").modal('show');
|
||||
});
|
||||
}
|
||||
function toggleBarChartTableData() {
|
||||
//find out which column data type is shown
|
||||
if (!$('[report-data="cost"]').hasClass('d-none')) {
|
||||
//currently cost is shown.
|
||||
$('[report-data="cost"]').addClass('d-none');
|
||||
$('[report-data="distance"]').removeClass('d-none');
|
||||
}
|
||||
else if (!$('[report-data="distance"]').hasClass('d-none')) {
|
||||
//currently distance is shown.
|
||||
$('[report-data="distance"]').addClass('d-none');
|
||||
$('[report-data="costperdistance"]').removeClass('d-none');
|
||||
}
|
||||
else if (!$('[report-data="costperdistance"]').hasClass('d-none')) {
|
||||
//currently cost per distance is shown.
|
||||
$('[report-data="costperdistance"]').addClass('d-none');
|
||||
$('[report-data="cost"]').removeClass('d-none');
|
||||
}
|
||||
}
|
||||
function updateReminderPie() {
|
||||
var vehicleId = GetVehicleId().vehicleId;
|
||||
var daysToAdd = $("#reminderOption").val();
|
||||
|
||||
Reference in New Issue
Block a user