From 461d23d67d5531c024710f03e64f2095904aec1e Mon Sep 17 00:00:00 2001 From: Marco Audiffredi Date: Wed, 23 Oct 2024 15:39:23 +0200 Subject: [PATCH] nuova procedura abbinamento --- Controllers/DestinazioniController.cs | 99 +++++- Controllers/GiriDaValidareController.cs | 6 +- Views/Destinazioni/Index.cshtml | 2 +- Views/Destinazioni/IndexValidate.cshtml | 400 ++++++++++++++++++++++++ Views/Giri/Index.cshtml | 2 +- appsettings.json | 1 + 6 files changed, 504 insertions(+), 6 deletions(-) create mode 100644 Views/Destinazioni/IndexValidate.cshtml diff --git a/Controllers/DestinazioniController.cs b/Controllers/DestinazioniController.cs index c9d6f8e..b7f143c 100644 --- a/Controllers/DestinazioniController.cs +++ b/Controllers/DestinazioniController.cs @@ -91,7 +91,7 @@ namespace SoftwayWeb.Controllers ViewBag.dataGiro = dataG; } - urlBase = apiUrl + "Giri/listaDestinazioniByAutistaDataMezzo"; + urlBase = apiUrl + "Giri/listaDestinazioniByAutistaDataMezzoNonValidate"; urlBase = urlBase + "?autista=" + codAutista + "&dataGiro=" + dataGi + "&mezzo=" + codMezzo; Uri baseAddress = new Uri(urlBase); client = new HttpClient(); @@ -124,6 +124,103 @@ namespace SoftwayWeb.Controllers return RedirectToAction("Error"); } + } + public IActionResult IndexValidate(string id, string? codAutista, string? nomeAutista, DateTime dataGiro, string? codMezzo, string? desMezzo, int? page = 1) + { + helper = new SessionHelper(this); + + token = helper.GetStringValue("tok"); + + if (string.IsNullOrEmpty(token)) + { + return RedirectToAction("Login", "Login"); + } + + string autista = string.Empty; + string dataGi = string.Empty; + string mezzo = string.Empty; + string dataGiro2 = string.Empty; + + ViewBag.CodAutista = codAutista; + ViewBag.Autista = nomeAutista; + ViewBag.CodMezzo = codMezzo; + ViewBag.Automezzo = desMezzo; + ViewBag.dataGiro = dataGiro.ToString("dd/MM/yyyy"); + + if (!string.IsNullOrEmpty(codAutista)) + { + helper.SetStringValue("codAutista", codAutista.TrimEnd()); + helper.SetStringValue("nomeAutista", nomeAutista.TrimEnd()); + } + else + { + string codAut = helper.GetStringValue("codAutista"); + codAutista = codAut.TrimEnd(); + ViewBag.CodAutista = codAutista; + string nomeAut = helper.GetStringValue("nomeAutista"); + ViewBag.Autista = nomeAut; + } + + if (!string.IsNullOrEmpty(codMezzo)) + { + helper.SetStringValue("codMezzo", codMezzo.TrimEnd()); + helper.SetStringValue("desMezzo", desMezzo.TrimEnd()); + } + else + { + string mez = helper.GetStringValue("codMezzo").TrimEnd(); + codMezzo = mez; + ViewBag.CodMezzo = codMezzo; + string nomeMezzo = helper.GetStringValue("desMezzo"); + ViewBag.Automezzo = nomeMezzo; + } + + if (dataGiro.Date != DateTime.MinValue) + { + helper.SetStringValue("dataGiro", dataGiro.ToString("yyyy-MM-dd'T'HH:mm:ss.fff'Z'")); + dataGi = dataGiro.ToString("yyyy-MM-dd'T'HH:mm:ss.fff'Z'"); + helper.SetStringValue("dataGiro2", dataGiro.ToString("dd/MM/yyyy")); + } + else + { + dataGi = helper.GetStringValue("dataGiro"); + string dataG = helper.GetStringValue("dataGiro2"); + ViewBag.dataGiro = dataG; + } + + urlBase = apiUrl + "Giri/listaDestinazioniByAutistaDataMezzo"; + urlBase = urlBase + "?autista=" + codAutista + "&dataGiro=" + dataGi + "&mezzo=" + codMezzo; + Uri baseAddress = new Uri(urlBase); + client = new HttpClient(); + client.BaseAddress = baseAddress; + + List modelList = new List(); + HttpResponseMessage response = client.GetAsync(baseAddress).Result; + + if (response.IsSuccessStatusCode) + { + string dato = response.Content.ReadAsStringAsync().Result; + modelList = JsonConvert.DeserializeObject>(dato); + modelList = modelList.Where(x => x.serialeGiro == id).OrderBy(x => x.Seq).ThenBy(x => x.Committente).ToList(); + + if (page != null && page < 1) + { + page = 1; + } + + var pageSize = 10; + + var shortList = modelList.ToPagedList(page ?? 1, pageSize); + + return View(shortList); + } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } + } public IActionResult EliminaDestinazione(string serial) diff --git a/Controllers/GiriDaValidareController.cs b/Controllers/GiriDaValidareController.cs index cabe568..139e559 100644 --- a/Controllers/GiriDaValidareController.cs +++ b/Controllers/GiriDaValidareController.cs @@ -57,19 +57,19 @@ namespace SoftwayWeb.Controllers string _filtro= helper.GetStringValue("filterData"); - if (data == DateTime.MinValue && string.IsNullOrEmpty(_filtro)) + if (data == DateTime.MinValue && string.IsNullOrEmpty(_filtro) && modelList.Count()>0) { var last = modelList.OrderByDescending(t => t.DataGiro).Take(1).First(); modelList = modelList.Where(x => x.DataGiro == last.DataGiro).ToList(); } - if (data == DateTime.MinValue && !string.IsNullOrEmpty(_filtro)) + if (data == DateTime.MinValue && !string.IsNullOrEmpty(_filtro) && modelList.Count() > 0) { DateTime dataFiltro=Convert.ToDateTime(_filtro); ViewBag.Filtro = Convert.ToString(_filtro); modelList = modelList.Where(x => x.DataGiro == dataFiltro).ToList(); } - if (data != DateTime.MinValue ) + if (data != DateTime.MinValue && modelList.Count() > 0) { helper.SetStringValue("filterData", Convert.ToString( data)); ViewBag.Filtro = data.ToString("dd/MM/yyyy"); diff --git a/Views/Destinazioni/Index.cshtml b/Views/Destinazioni/Index.cshtml index 45b901e..ecefe8c 100644 --- a/Views/Destinazioni/Index.cshtml +++ b/Views/Destinazioni/Index.cshtml @@ -19,7 +19,7 @@
Automezzo: @ViewBag.CodMezzo - @ViewBag.Automezzo

-Torna alla lista +Torna alla lista

diff --git a/Views/Destinazioni/IndexValidate.cshtml b/Views/Destinazioni/IndexValidate.cshtml new file mode 100644 index 0000000..2993bcb --- /dev/null +++ b/Views/Destinazioni/IndexValidate.cshtml @@ -0,0 +1,400 @@ +@* @model IEnumerable *@ +@* @model SoftwayWeb.Models.Destinazioni_Out *@ +@model IPagedList +@using X.PagedList; +@using X.PagedList.Mvc.Core; +@using X.PagedList; + +@{ + ViewData["Title"] = "Lista Destinazioni"; + Layout = "~/Views/Shared/_LayoutAreaRis.cshtml"; +} + +

Lista destinazioni

+ +

+ Data giro: @ViewBag.dataGiro +
+ Autista: @ViewBag.CodAutista - @ViewBag.Autista +
+ Automezzo: @ViewBag.CodMezzo - @ViewBag.Automezzo +

+Torna alla lista +
+
+ + +
+
Lista destinazioni
+
+ + + + @**@ + + + + + + + + + + + + + + + + + + @foreach (var item in Model) { + int diffBancali = 0; + string cl = string.Empty; + @if (item.ConsFatta != null) + { + @Html.HiddenFor(modelItem => item.ConsFatta.consFattaFlagCons) + + @if (item.ConsFatta.consFattaFlagCons != null && item.ConsFatta.consFattaFlagCons.Contains("S")) + { + @*cons*@ + cl = "table-success"; + } + else + { + cl = "table-danger"; + @*nocons*@ + } + } + else + { +@* *@ + } + + + + +@* @if (item.ConsFatta != null) + { + + } + else + { + + }*@ + + + + + + + @if (item.Casse != null && item.Casse > 0) + { + int icasse = 0; + icasse = Convert.ToInt32(item.Casse); + + } + else + { + + } + @if (item.Trasf != null && item.Trasf > 0) + { + + } + else + { + + } + @if (item.Colli != null && item.Colli > 0) + { + int icolli = 0; + icolli = Convert.ToInt32(item.Colli); + + } + else + { + + } + @if (item.num_cons != null && item.num_cons > 0) + { + + } + else + { + + } + @if (item.Uova != null && item.Uova > 0) + { + + } + else + { + + } + @if (item.Cist != null && item.Cist > 0) + { + + } + else + { + + } + + + + @if (item.ConsFatta != null && item.ConsFatta.consFattaBanCar != null && item.ConsFatta.consFattaBanSca!=null) + { + diffBancali = item.ConsFatta.consFattaBanCar.Value - item.ConsFatta.consFattaBanSca.Value; + + + } + else + { + + } + @if (item.ConsFatta == null) + { + + + } + else + { + + + } + + + } + +
 S.CommittenteSedeIndirizzo sedeCa.Tr.Co.Nr.Co.UoCi.NoteBc - Bs  
+ notyet +
+ @Html.HiddenFor(modelItem => item.ConsFatta.consFattaFlagCons) + + @if (item.ConsFatta.consFattaFlagCons!=null && item.ConsFatta.consFattaFlagCons.Contains("S")) + { + cons + } + else + { + nocons + } + + notyet + @Html.DisplayFor(modelItem => item.Seq)@Html.DisplayFor(modelItem => item.Committente)@*@Html.DisplayFor(modelItem => item.CodSede) - *@@Html.DisplayFor(modelItem => item.Sede)@Html.DisplayFor(modelItem => item.IndirizzoSede) + @icasse +   + @Html.DisplayFor(modelItem => item.Trasf) +   + @icolli +   + @Html.DisplayFor(modelItem => item.num_cons) +   + @Html.DisplayFor(modelItem => item.Uova) +   + @Html.DisplayFor(modelItem => item.Cist) +   + @Html.DisplayFor(modelItem => item.Note) + + @diffBancali +   + @if (!string.IsNullOrEmpty(item.Prog)) + { + nocons + } + + nocons + + nocons +   
+
+
+
+ + Consegna non effettuata + + Consegna completata + + Consegna da effettuare + + nocons + + Destinazione modificata + + + +@* + + + + + + + + + + + + + + + + + + + + +@foreach (var item in Model) { + + @if (item.ConsFatta != null) + { + + } + else + { + + } + + + + + @if (item.Casse != null && item.Casse>0) + { + + } + else + { + + } + @if (item.Trasf != null && item.Trasf > 0) + { + + } + else + { + + } + @if (item.Colli != null && item.Colli > 0) + { + + } + else + { + + } + @if (item.num_cons != null && item.num_cons > 0) + { + + } + else + { + + } + @if (item.Uova != null && item.Uova > 0) + { + + } + else + { + + } + @if (item.Cist != null && item.Cist > 0) + { + + } + else + { + + } + + + + @if (item.ConsFatta == null) + { + + + } + else + { + + + } + +} + +
 SeqCommittenteSedeIndirizzo sedeCasseTrasf.ColliNr.Cons.UovaCistNote  
+ @Html.HiddenFor(modelItem => item.ConsFatta.consFattaFlagCons) + + @if (item.ConsFatta.consFattaFlagCons.Contains("S")) + { + cons + } + else + { + nocons + } + + notyet + + @Html.DisplayFor(modelItem => item.Seq) + + @Html.DisplayFor(modelItem => item.CodCommittente) - @Html.DisplayFor(modelItem => item.Committente) + + @Html.DisplayFor(modelItem => item.CodSede) - @Html.DisplayFor(modelItem => item.Sede) + + @Html.DisplayFor(modelItem => item.IndirizzoSede) + + @Html.DisplayFor(modelItem => item.Casse) +   + @Html.DisplayFor(modelItem => item.Trasf) +   + @Html.DisplayFor(modelItem => item.Colli) +   + @Html.DisplayFor(modelItem => item.num_cons) +   + @Html.DisplayFor(modelItem => item.Uova) +   + @Html.DisplayFor(modelItem => item.Cist) +   + @Html.DisplayFor(modelItem => item.Note) + + @if (!string.IsNullOrEmpty(item.Prog)) + { + nocons + } + + nocons + + nocons +   
*@ +
+ \ No newline at end of file diff --git a/Views/Giri/Index.cshtml b/Views/Giri/Index.cshtml index 034e86d..48abdea 100644 --- a/Views/Giri/Index.cshtml +++ b/Views/Giri/Index.cshtml @@ -111,7 +111,7 @@ } -