diff --git a/Controllers/TimbratureController.cs b/Controllers/TimbratureController.cs index fb8585f..830ea1d 100644 --- a/Controllers/TimbratureController.cs +++ b/Controllers/TimbratureController.cs @@ -29,7 +29,7 @@ namespace VirtualTask.Controllers #region INDEX - public IActionResult Index(int id, int? page = 1) + public IActionResult Index(DateTime dataTimb, string commessa, string tecnico, int? page = 1) { SessionHelper helper = new SessionHelper(this); token = helper.GetStringValue("tok"); @@ -57,15 +57,30 @@ namespace VirtualTask.Controllers string data = response.Content.ReadAsStringAsync().Result; modelList = JsonConvert.DeserializeObject>(data); - if (id != 0) + if (dataTimb.Date != DateTime.MinValue) { - modelList = modelList.Where(s => s.id == id).ToList(); - ViewData["CurrentFilter"] = id; + modelList = modelList.Where(x => x.data_timbratura.GetValueOrDefault().Date == dataTimb).ToList(); } - else + + if (!string.IsNullOrEmpty(commessa)) { - ViewData["CurrentFilter"] = null; + modelList = modelList.Where(s => s.commessa.ToLower().Contains(commessa.ToLower())).ToList(); } + + if (!string.IsNullOrEmpty(tecnico)) + { + modelList = modelList.Where(s => s.tecnico.ToLower().Contains(tecnico.ToLower())).ToList(); + + } + //if (id != 0) + //{ + // modelList = modelList.Where(s => s.id == id).ToList(); + // ViewData["CurrentFilter"] = id; + //} + //else + //{ + // ViewData["CurrentFilter"] = null; + //} if (page != null && page < 1) { page = 1; @@ -133,7 +148,7 @@ namespace VirtualTask.Controllers #region metodi interni - public IActionResult ExportExcel(int id) + public IActionResult ExportExcel(DateTime dataTimb, string commessa, string tecnico) { SessionHelper helper = new SessionHelper(this); token = helper.GetStringValue("tok"); @@ -161,6 +176,22 @@ namespace VirtualTask.Controllers modelList = JsonConvert.DeserializeObject>(data); + if (dataTimb.Date != DateTime.MinValue) + { + modelList = modelList.Where(x => x.data_timbratura.GetValueOrDefault().Date == dataTimb).ToList(); + } + + if (!string.IsNullOrEmpty(commessa)) + { + modelList = modelList.Where(s => s.commessa.Contains(commessa)).ToList(); + } + + if (!string.IsNullOrEmpty(tecnico)) + { + modelList = modelList.Where(s => s.tecnico.Contains(tecnico)).ToList(); + + } + var workbook = new XLWorkbook(); workbook.AddWorksheet("sheetName"); var ws = workbook.Worksheet("sheetName"); diff --git a/Views/Home/Listino.cshtml b/Views/Home/Listino.cshtml index 7d7f652..3d7c574 100644 --- a/Views/Home/Listino.cshtml +++ b/Views/Home/Listino.cshtml @@ -4,8 +4,8 @@ ViewData["Title"] = "Listino Virtual Task 2024"; }
- Virtual Task App - Virtual Task App + Virtual Task App + Virtual Task App
diff --git a/Views/Timbrature/Index.cshtml b/Views/Timbrature/Index.cshtml index a54ee06..67e127e 100644 --- a/Views/Timbrature/Index.cshtml +++ b/Views/Timbrature/Index.cshtml @@ -14,7 +14,49 @@
- @using (Html.BeginForm()) + @using (Html.BeginForm("Index", "Timbrature")) + { +
+
+ Data timbratura: + @* @Html.TextBox("dataTimb", ViewBag.Timbrature, null, new { @class = "agy-form-field require" }) *@ + @Html.TextBox("dataTimb", null, new { type = "date", @class = "agy-form-field require" }) + + @*
*@ + Commessa: + @Html.TextBox("commessa", ViewBag.Timbrature, null, new { @class = "agy-form-field require" }) + @*
*@ + + @*
*@ + Tecnico: + @Html.TextBox("tecnico", ViewBag.Timbrature, null, new { @class = "agy-form-field require" }) + @*
*@ + +
+
+ +
 
+
 
+
 
+ +
+ } + +
+
+
+ + @using (Html.BeginForm("ExportExcel", "Timbrature")) + { + @Html.Hidden("dataTimb", ViewBag.Timbrature, null) + @Html.Hidden("commessa", ViewBag.Timbrature, null) + @Html.Hidden("tecnico", ViewBag.Timbrature, null) + +
+ +
+ } + @* @using (Html.BeginForm()) {
@@ -23,7 +65,7 @@
-
 
+
 
@@ -34,15 +76,16 @@

-
+
*@ - @using (Html.BeginForm("ExportExcel", "Timbrature")) + @* @using (Html.BeginForm("ExportExcel", "Timbrature")) { -
- + @Html.Hidden("id", ViewBag.Timbrature, null) +
+ *@ @*
*@ -
- } + @*
+ } *@