Michele: modifiche per filtri, paginazioni impianti e rapportini

This commit is contained in:
michele 2024-10-04 17:57:41 +02:00
parent fba773ce32
commit ecfc109507
4 changed files with 369 additions and 244 deletions

View File

@ -33,7 +33,7 @@ namespace VirtualTask.Controllers
#region INDEX
public IActionResult Index(string searchString, int? page = 1)
public IActionResult Index(string searchString, string cliente, int? page = 1)
{
SessionHelper helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
@ -71,6 +71,15 @@ namespace VirtualTask.Controllers
else
ViewData["CurrentFilter"] = null;
if (!string.IsNullOrEmpty(cliente))
{
modelList = modelList.Where(x => x.imultcli != null && x.imultcli.Contains(cliente)).ToList();
ViewData["CurrentFilterCli"] = cliente;
ViewBag.Cliente = cliente;
}
else
ViewData["CurrentFilterCli"] = null;
if (page != null && page < 1)
{
page = 1;
@ -82,6 +91,8 @@ namespace VirtualTask.Controllers
.OrderByDescending(s => s.imcodimp)
.ToPagedList(page ?? 1, pageSize);
ViewBag.Clienti = LoadStockitems();
return View(shortLinks);
}
else

View File

@ -31,10 +31,11 @@ namespace VirtualTask.Controllers
#region INDEX
public IActionResult Index(string searchString, int? page = 1)
public IActionResult Index(DateTime dataIni, DateTime dataFin, string Codbuono, string tecnico, int? page = 1)
{
SessionHelper helper = new SessionHelper(this);
token = helper.GetStringValue("tok");
if (string.IsNullOrEmpty(token))
{
return RedirectToAction("Login2", "Login");
@ -59,15 +60,44 @@ namespace VirtualTask.Controllers
string data = response.Content.ReadAsStringAsync().Result;
modelList = JsonConvert.DeserializeObject<List<Rapp_New>>(data);
if (!string.IsNullOrEmpty(searchString))
if (dataIni.Date != DateTime.MinValue)
{
//modelList = modelList.Where(s => s.descrizione_intervento.ToUpper().Contains(searchString.ToUpper())).ToList();
modelList = modelList.Where(s => s.data_rapportino.ToString().Substring(0,10).Contains(searchString.ToUpper())).ToList();
modelList = modelList.Where(x => x.data_rapportino.Date >= dataIni.Date).ToList();
ViewData["CurrentFilter"] = searchString;
ViewData["dataIni"] = dataIni;
//ViewData["dataFin"] = dataFin;
}
else
ViewData["CurrentFilter"] = null;
{
ViewData["dataIni"] = null;
}
if (dataFin.Date != DateTime.MinValue)
{
modelList = modelList.Where(x => x.data_rapportino.Date <= dataFin.Date).ToList();
ViewData["dataFin"] = dataFin;
}
else
{
ViewData["dataFin"] = null;
}
if (!string.IsNullOrEmpty(Codbuono))
{
modelList = modelList.Where(x => x.seriale_rapportino.ToUpper().Contains(Codbuono)).ToList();
ViewData["Codbuono"] = Codbuono;
}
else
ViewData["Codbuono"] = null;
if (!string.IsNullOrEmpty(tecnico))
{
modelList = modelList.Where(x => x.codice_tecnico.ToUpper().Contains(tecnico)).ToList();
ViewData["tecnico"] = tecnico;
}
else
ViewData["tecnico"] = null;
if (page != null && page < 1)
{
@ -80,6 +110,9 @@ namespace VirtualTask.Controllers
.OrderByDescending(s => s.seriale_rapportino)
.ToPagedList(page ?? 1, pageSize);
ViewBag.Tecnici = GetTecnici();
return View(shortLinks);
}
else
@ -346,11 +379,22 @@ namespace VirtualTask.Controllers
{
string data = response.Content.ReadAsStringAsync().Result;
modelList = JsonConvert.DeserializeObject<List<Tecnici>>(data);
//per gestire primo elemento tendina (deve essere vuoto)
SelectListItem listItemFirst = new SelectListItem();
listItemFirst.Value = string.Empty;
listItemFirst.Text = " - Tecnico";
selectItems.Add(listItemFirst);
foreach (var role in modelList)
{
SelectListItem listItem = new SelectListItem();
string s = role.tccodice + " - " + role.tcdescri;
listItem.Value = role.tccodice;
listItem.Text = role.tcdescri;
listItem.Text = s/*role.tcdescri*/;
selectItems.Add(listItem);
}
}

View File

@ -12,21 +12,45 @@
<div class="agy-project-wrapper agy-project-page-wrapper">
<div class="container">
<div class="row">
<p>
<a asp-action="Create" class="info-data"><img src="~/assets/images/icons8-nuovo-50.png" alt="Crea un nuovo elemento" /></a>
</p>
@using (Html.BeginForm())
@using (Html.BeginForm("Index", "Impianti"))
{
<div>
<div style="float:left;width:40%;padding:0 20px;">@Html.TextBox("SearchString", null, new { placeholder = "Cerca per Indirizzo", @class = "agy-form-field require" })</div>
<div style="float:left;width:2%;">&nbsp;</div>
<div style="float:left;width:57%;"><input type="submit" value="Cerca" class="agy-btn submitForm" /></div>
<div class="card">
<h5 class="card-header">Ricerca</h5>
<div class="table-responsive text-nowrap">
<table class="table">
<tbody class="table-border-bottom-0">
<tr>
<td>
<i class="bx bxl-angular bx-sm text-black me-3">Indirizzo:</i>
<span class="fw-medium">@Html.TextBox("searchString", null, new { placeholder = "Cerca per indirizzo impianto", @class = "agy-form-field require" })</span>
</td>
<td>
<i class="bx bxl-angular bx-sm text-black me-3">Cliente:</i>
<span class="fw-medium">@Html.DropDownList("cliente", ViewBag.Clienti, null, new { @class = "agy-form-field require" })</span>
</td>
<td>
<i class="bx bxl-angular bx-sm text-black me-3">&nbsp;</i>
<span class="fw-medium"><input type="submit" value="Cerca" class="agy-btn submitForm" /></span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
}
<table class="table">
<div style="width:100%;height:30px;">
&nbsp;
</div>
<div class="card">
<h5 class="card-header">IMPIANTI</h5>
<div class="table-responsive text-nowrap">
<table class="table table-striped">
<thead>
<tr>
<th style="width:20%;">Impianto</th>
@ -66,9 +90,11 @@
}
</tbody>
</table>
</div>
</div>
<br />
<nav>
@Html.PagedListPager(Model, page => Url.Action("index", new { page = page, searchString=@ViewData["CurrentFilter"] }), new PagedListRenderOptions()
@Html.PagedListPager(Model, page => Url.Action("index", new { page = page, searchString = @ViewData["CurrentFilter"], cliente = ViewData["CurrentFilterCli"]}), new PagedListRenderOptions()
{
ActiveLiElementClass = "active",
PageClasses = new[] { "page-link" },
@ -83,6 +109,7 @@
</nav>
</div>
</div>
</div>
@*

View File

@ -3,17 +3,13 @@
@using X.PagedList.Mvc.Core;
@using X.PagedList.Web.Common;
<link href="~/Content/PagedList.css" rel="stylesheet" type="text/css" />
@{
ViewData["Title"] = "Buoni intervento";
Layout = "~/Views/Shared/_LayoutAreaRiservata.cshtml";
}
<div class="agy-project-wrapper agy-project-page-wrapper">
<div class="container">
<div class="row">
@ -21,24 +17,64 @@
@* <p>
<a asp-action="Create" class="info-data"><img src="~/assets/images/icons8-nuovo-50.png" alt="Crea un nuovo elemento" /></a>
</p> *@
@using (Html.BeginForm())
@using (Html.BeginForm("Index","Rapp_New"))
{
<div class="card">
<h5 class="card-header">Ricerca</h5>
<div class="table-responsive text-nowrap">
<table class="table">
<tbody class="table-border-bottom-0">
<tr>
<td>
<i class="bx bxl-angular bx-sm text-black me-3">Codice buono:</i>
<span class="fw-medium">@Html.TextBox("Codbuono", null, new { placeholder = "Cerca per Buono", @class = "agy-form-field require" })</span>
</td>
<td>
<i class="bx bxl-angular bx-sm text-black me-3">Tecnico:</i>
<span class="fw-medium">@Html.DropDownList("tecnico", ViewBag.Tecnici, null, new { @class = "agy-form-field require" })</span>
</td>
<td>
&nbsp;
</td>
</tr>
<tr>
<td>
<i class="bx bxl-angular bx-sm text-black me-3">Data da:</i>
<span class="fw-medium">@Html.TextBox("dataIni", null, new { type = "date", @class = "agy-form-field require" })</span>
</td>
<td>
<i class="bx bxl-angular bx-sm text-black me-3">Data a:</i>
<span class="fw-medium">@Html.TextBox("dataFin", null, new { type = "date", @class = "agy-form-field require" })</span>
</td>
<td>
<i class="bx bxl-angular bx-sm text-black me-3">&nbsp;</i>
<span class="fw-medium"><input type="submit" value="Cerca" class="agy-btn submitForm" /></span>
</td>
</tr>
<div>
<div style="float:left;width:40%;padding:0 20px;">@Html.TextBox("SearchString", null, new { placeholder = "Cerca per data buono", @class = "agy-form-field require" })</div>
<div style="float:left;width:2%;">&nbsp;</div>
<div style="float:left;width:57%;"><input type="submit" value="Cerca" class="agy-btn submitForm" /></div>
</tbody>
</table>
</div>
</div>
}
<table class="table">
<div style="width:100%;height:30px;">
&nbsp;
</div>
<div class="card">
<h5 class="card-header">BUONI INTERVENTO</h5>
<div class="table-responsive text-nowrap">
<table class="table table-striped">
<thead>
<tr>
@* <th>Seriale rapportino</th> *@
<th>Codice buono</th>
@* <th>Tipo rapportino</th> *@
@* <th>Azienda</th> *@
<th>Data buono</th>
<th>Data</th>
<th>Codice impianto</th>
@* <th hidden>Az. chiamata</th> *@
@* <th hidden>Seriale chiamata</th> *@
@ -102,7 +138,6 @@
@foreach (var item in Model)
{
<tr>
@Html.HiddenFor(modelItem => item.seriale_rapportino)
@Html.HiddenFor(modelItem => item.tipo_rapportino)
@Html.HiddenFor(modelItem => item.azienda_impianto)
@Html.HiddenFor(modelItem => item.azienda_chiamata)
@ -160,6 +195,9 @@
@Html.HiddenFor(modelItem => item.rafoto8)
@Html.HiddenFor(modelItem => item.rafoto9)
@Html.DisplayFor(modelItem => item.rafoto10)
<td>
@Html.DisplayFor(modelItem => item.seriale_rapportino)
</td>
<td>
@Html.DisplayFor(modelItem => item.data_rapportino)
</td>
@ -191,9 +229,14 @@
}
</tbody>
</table>
</div>
</div>
<br />
<nav>
@Html.PagedListPager(Model, page => Url.Action("index", new { page = page, searchString=@ViewData["CurrentFilter"] }), new PagedListRenderOptions()
@Html.PagedListPager(Model, page => Url.Action("index", new { page = page, searchString = @ViewData["CurrentFilter"],
CodBuono = ViewData["Codbuono"], tecnico = @ViewData["tecnico"], dataIni = ViewData["dataIni"], dataFin=@ViewData["dataFin"]}), new PagedListRenderOptions()
{
ActiveLiElementClass = "active",
PageClasses = new[]{ "page-link"},