From 9e177436d5b41fb4bbb006c290030ca8646f7359 Mon Sep 17 00:00:00 2001 From: michele Date: Mon, 20 May 2024 11:00:02 +0200 Subject: [PATCH] Michele: view timbrature, model, controller --- Controllers/PortaleController.cs | 5 + Controllers/TimbratureController.cs | 234 ++++++++++++++++++ Models/Timbratura.cs | 64 +++++ Views/Home/Listino.cshtml | 161 +++++++----- Views/Portale/VT_Page3.cshtml | 3 +- Views/Portale/VT_Page4.cshtml | 31 +++ Views/Shared/_LayoutAreaRiservata.cshtml | 1 + Views/Shared/_LayoutPortale.cshtml | 44 +++- Views/Timbrature/Details.cshtml | 157 ++++++++++++ Views/Timbrature/Index.cshtml | 212 ++++++++++++++++ wwwroot/assets/images/immagine1Trasp.png | Bin 0 -> 5451 bytes wwwroot/assets/images/virtualTaskTS.png | Bin 0 -> 391098 bytes .../images/virtualTaskTS_removebgpreview.png | Bin 0 -> 31610 bytes 13 files changed, 838 insertions(+), 74 deletions(-) create mode 100644 Controllers/TimbratureController.cs create mode 100644 Models/Timbratura.cs create mode 100644 Views/Portale/VT_Page4.cshtml create mode 100644 Views/Timbrature/Details.cshtml create mode 100644 Views/Timbrature/Index.cshtml create mode 100644 wwwroot/assets/images/immagine1Trasp.png create mode 100644 wwwroot/assets/images/virtualTaskTS.png create mode 100644 wwwroot/assets/images/virtualTaskTS_removebgpreview.png diff --git a/Controllers/PortaleController.cs b/Controllers/PortaleController.cs index 2a56c1a..84511ed 100644 --- a/Controllers/PortaleController.cs +++ b/Controllers/PortaleController.cs @@ -23,5 +23,10 @@ namespace VirtualTask.Controllers { return View(); } + + public IActionResult VT_Page4() + { + return View(); + } } } diff --git a/Controllers/TimbratureController.cs b/Controllers/TimbratureController.cs new file mode 100644 index 0000000..fb8585f --- /dev/null +++ b/Controllers/TimbratureController.cs @@ -0,0 +1,234 @@ +using ClosedXML.Excel; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using VirtualTask.Models; +using X.PagedList; + +namespace VirtualTask.Controllers +{ + public class TimbratureController : Controller + { + string apiUrl = string.Empty; + string urlBase = string.Empty; + string token = string.Empty; + string tenant = string.Empty; + string errMes = string.Empty; + string admin = string.Empty; + + HttpClient client; + + private readonly IConfiguration _configuration; + + public TimbratureController(IConfiguration configuration) + { + client = new HttpClient(); + _configuration = configuration; + var key = _configuration["ApplicationInsights:rootUrlApi"]; + apiUrl = key; + } + + #region INDEX + + public IActionResult Index(int id, int? page = 1) + { + SessionHelper helper = new SessionHelper(this); + token = helper.GetStringValue("tok"); + + if (string.IsNullOrEmpty(token)) + { + return RedirectToAction("Login2", "Login"); + } + + apiUrl = helper.GetStringValue("apiUrl"); + admin = helper.GetStringValue("admin"); + ViewBag.Admin = admin; + urlBase = apiUrl + "timbratureList"; + urlBase = urlBase + "?token=" + token; + 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 data = response.Content.ReadAsStringAsync().Result; + modelList = JsonConvert.DeserializeObject>(data); + + 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; + } + + var pageSize = 10; + + var shortLinks = modelList + .OrderByDescending(s => s.id) + .ToPagedList(page ?? 1, pageSize); + + return View(shortLinks); + } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } + } + + #endregion INDEX + + #region DETAILS + + public IActionResult Details(int id) + { + SessionHelper helper = new SessionHelper(this); + + + token = helper.GetStringValue("tok"); + + apiUrl = helper.GetStringValue("apiUrl"); + admin = helper.GetStringValue("admin"); + ViewBag.Admin = admin; + urlBase = apiUrl + "timbratureList"; + urlBase = urlBase + "?token=" + token; + Uri baseAddress = new Uri(urlBase); + client = new HttpClient(); + client.BaseAddress = baseAddress; + + Timbratura rapp = new Timbratura(); + + List modelList = new List(); + + HttpResponseMessage response = client.GetAsync(baseAddress).Result; + + if (response.IsSuccessStatusCode) + { + string data = response.Content.ReadAsStringAsync().Result; + modelList = JsonConvert.DeserializeObject>(data); + rapp = modelList.Where(x => x.id.Equals(id)).First(); + } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } + + return View(rapp); + } + + #endregion DETAILS + + #region metodi interni + + public IActionResult ExportExcel(int id) + { + SessionHelper helper = new SessionHelper(this); + token = helper.GetStringValue("tok"); + if (string.IsNullOrEmpty(token)) + { + return RedirectToAction("Login2", "Login"); + } + + apiUrl = helper.GetStringValue("apiUrl"); + admin = helper.GetStringValue("admin"); + ViewBag.Admin = admin; + urlBase = apiUrl + "timbratureList"; + urlBase = urlBase + "?token=" + token; + 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 data = response.Content.ReadAsStringAsync().Result; + + modelList = JsonConvert.DeserializeObject>(data); + + var workbook = new XLWorkbook(); + workbook.AddWorksheet("sheetName"); + var ws = workbook.Worksheet("sheetName"); + + int col = 1; + + //Scrivo intestazioni colonne + foreach (var item in modelList[0].GetType().GetProperties()) + { + ws.Cell(1, col).Style = ws.Cell(1, col).Style.Font.SetBold(); + ws.Cell(1, col).Value = item.Name.ToString().Replace("_", " ").ToUpper(); + + col++; + } + + var row = 0; + + foreach (var item in modelList) + { + var colonna = 1; + //righe per ogni item nel modelList + foreach (var prop in item.GetType().GetProperties()) + { + //controllo se item null assegno stringa vuota + //perchè se null da errore quando scrive l'excel + if (prop.GetValue(item) != null) + { + ws.Cell(row + 2, colonna).Value = prop.GetValue(item).ToString(); + } + else + { + ws.Cell(row + 2, colonna).Value = string.Empty; + } + colonna++; + } + + row++; + } + + //Salvo il file Excel + var anno = DateTime.Now.Year.ToString(); + var mese = DateTime.Now.Month.ToString(); + var giorno = DateTime.Now.Day.ToString(); + var ore = DateTime.Now.Hour.ToString(); + var minuti = DateTime.Now.Minute.ToString(); + var secondi = DateTime.Now.Second.ToString(); + + var dateFile = anno + mese + giorno + ore + minuti + secondi; + + //workbook.SaveAs($"C:\\Users\\utente\\Desktop\\ExcelVT\\buoni_{dateFile}.xlsx"); + string contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; + //string fileName = "authors.xlsx"; + string fileName = $"Timbrature_{dateFile}.xlsx"; + using (var stream = new MemoryStream()) + { + workbook.SaveAs(stream); + var content = stream.ToArray(); + return File(content, contentType, fileName); + } + } + else + { + errMes = response.Content.ReadAsStringAsync().Result; + helper.SetStringValue("errMsg", errMes); + return RedirectToAction("Error"); + } + } + + #endregion metodi interni + } +} diff --git a/Models/Timbratura.cs b/Models/Timbratura.cs new file mode 100644 index 0000000..4102339 --- /dev/null +++ b/Models/Timbratura.cs @@ -0,0 +1,64 @@ +using System.ComponentModel.DataAnnotations; + +namespace VirtualTask.Models +{ + public class Timbratura + { + [Display(Name = "Id")] + /// chiave primaria + public int id { get; set; } + + [Display(Name = "Data timbratura")] + /// data + public DateTime? data_timbratura { get; set; } + + [Display(Name = "Ora inzio")] + /// ora inizio + public int ora_ini { get; set; } + + [Display(Name = "Minuti inizio")] + /// minuto inizio + public int min_ini { get; set; } + + [Display(Name = "Ora fine")] + /// ora fine + public int ora_fin { get; set; } + + [Display(Name = "Minuti fine")] + /// minuto fine + public int min_fin { get; set; } + + [Display(Name = "Commessa")] + /// commessa + public string? commessa { get; set; } + + [Display(Name = "Ore viaggio")] + /// ore viaggio + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? ore_viaggio { get; set; } + + [Display(Name = "Totale ore")] + /// totale ore + [System.ComponentModel.DataAnnotations.Schema.Column(TypeName = "decimal(7, 2)")] + public decimal? tot_ore { get; set; } + + [Display(Name = "Giorno sett.")] + /// giorno settimana + public int? giorno { get; set; } + + [Display(Name = "Azienda")] + /// azienda + public string? azienda { get; set; } + + [Display(Name = "Tecnico")] + /// tecnico + public string? tecnico { get; set; } + + /// cpccchk + public string? cpccchk { get; set; } + + [Display(Name = "Note")] + /// note + public string? note { get; set; } + } +} diff --git a/Views/Home/Listino.cshtml b/Views/Home/Listino.cshtml index 3cd94ec..7d7f652 100644 --- a/Views/Home/Listino.cshtml +++ b/Views/Home/Listino.cshtml @@ -3,77 +3,116 @@ Layout = "~/Views/Shared/_LayoutAreaRiservata.cshtml"; ViewData["Title"] = "Listino Virtual Task 2024"; } -
- @* Virtual Task App *@ - Virtual Task App +
+ Virtual Task App + Virtual Task App
-
-

-

Abbonamento Virtual Task FREE

-

- 2 Utenti e numero massimo anagrafiche clienti gestibili 50. -
-
-
-

-

Abbonamento Virtual Task BASIC

-

- 2 Utenti e numero massimo anagrafiche clienti gestibili 200. € 30,00 mese -
-
-
-

-

Abbonamento Virtual Task MEDIUM

-

- 2 Utenti e numero massimo anagrafiche clienti gestibili 500. € 40,00 mese -
-
-
-

-

Abbonamento Virtual Task ADVANCED

-

- 2 Utenti e numero massimo anagrafiche clienti gestibili 1000. € 50,00 mese -
-
-
-

-

Abbonamento Virtual Task PREMIUM

-

- 2 Utenti e numero massimo anagrafiche clienti gestibili illimitate. € 100,00 mese -
-
-
-

- Utenti/dispositivi aggiuntivi € 3,00 mese -
- pacchetto di 5 Utenti/dispositivi aggiuntivi € 10,00 mese* -

-
-

*max 30 utenti aggiungibili. Oltre contattare Polo Informatico s.r.l.

-
-
-

- Convenzione per iscritti a Confartigianato Terni. Sconto 50% su tutti i prezzi applicati a Virtual Task. -

-
-
-
-

- Per info e ordini inviare una email a info@virtualtask.it -

+
+
+
+
+

+

Abbonamento Virtual Task FREE

+

+ 2 Utenti e numero massimo anagrafiche clienti gestibili 50. +
+
+
+

+

Abbonamento Virtual Task BASIC

+

+ 2 Utenti e numero massimo anagrafiche clienti gestibili 200. € 30,00 mese +
+
+
+

+

Abbonamento Virtual Task MEDIUM

+

+ 2 Utenti e numero massimo anagrafiche clienti gestibili 500. € 40,00 mese +
+
+
+

+

Abbonamento Virtual Task ADVANCED

+

+ 2 Utenti e numero massimo anagrafiche clienti gestibili 1000. € 50,00 mese +
+
+
+

+

Abbonamento Virtual Task PREMIUM

+

+ 2 Utenti e numero massimo anagrafiche clienti gestibili illimitate. € 100,00 mese*9 +
+
+
+

+ Nuova funzionalità Time Sheet in Virtual Task +

+ Per ogni utente/dispositivo € 2,00 mese. + Non attivabile nella versione free. +
+
+ +
+

+ Utenti/dispositivi aggiuntivi € 3,00 mese +
+ pacchetto di 5 Utenti/dispositivi aggiuntivi € 10,00 mese* +

+
+

*max 30 utenti aggiungibili. Oltre contattare Polo Informatico s.r.l.

+
+
+

+ Convenzione per iscritti a Confartigianato Terni. Sconto 50% su tutti i prezzi + applicati a Virtual Task. +

+
+
+
+

+ Per info e ordini inviare una email a info@virtualtask.it +

+
+
+ +
+
+
+
+

+

Abbonamento Virtual Task Time Sheet

+

+ € 3,00 mese Utente/dispositivo +
+
+
+

+ Pacchetto sino a 5 utenti/dispositivi € 10,00 mese +

+

+ Oltre contattare Polo Informatico s.r.l e richiedere un offerta. +

+

+ I canoni sono anticipati e annuali. +

+
+
+
- \ No newline at end of file + *@ \ No newline at end of file diff --git a/Views/Portale/VT_Page3.cshtml b/Views/Portale/VT_Page3.cshtml index c40cefe..58de40f 100644 --- a/Views/Portale/VT_Page3.cshtml +++ b/Views/Portale/VT_Page3.cshtml @@ -1,5 +1,4 @@ -ah -@{ +@{ Layout = "~/Views/Shared/_LayoutAreaRiservata.cshtml"; ViewData["Title"] = "Task Manager"; } diff --git a/Views/Portale/VT_Page4.cshtml b/Views/Portale/VT_Page4.cshtml new file mode 100644 index 0000000..d62637e --- /dev/null +++ b/Views/Portale/VT_Page4.cshtml @@ -0,0 +1,31 @@ +@{ + Layout = "~/Views/Shared/_LayoutAreaRiservata.cshtml"; + ViewData["Title"] = "Virtual Task Time Sheet"; +} + + + +
+
+
+

+ Virtual Task Time Sheet è un' App che permette di consuntivare i tempi di lavoro su commessa ed esportarli poi su foglio di excel tramite la soluzione web. + Dall'applicativo web è possibile sapere, in tempo reale, su che commessa il tecnico ha timbrato e l'orario di entrata e/o uscita dall'attività che sta consuntivando. +

+

+ L'applicativo offre la possibilita di quantificare il tempo impiegato per una commessa, verranno quindi calcolate le ore di lavoro sulla base degli orari delle timbrarure di ingresso + ed uscita. +

+

+ E' possibile imputare eventuali ore di viaggio per raggiungere il luogo di lavoro e di annotare appunti relativi alla consuntivazione temporale fatta. +

+

+ Ogni utente può di timbrare un solo ingresso e una sola uscita alla volta. +

+

+ Infine l'applicativo permette di esportare le timbrature ai fini dell'import all'interno di software di rilevazione presenze del mondo Zucchetti. +

+ +
+
+
\ No newline at end of file diff --git a/Views/Shared/_LayoutAreaRiservata.cshtml b/Views/Shared/_LayoutAreaRiservata.cshtml index ba88e23..7c0745e 100644 --- a/Views/Shared/_LayoutAreaRiservata.cshtml +++ b/Views/Shared/_LayoutAreaRiservata.cshtml @@ -177,6 +177,7 @@ Purchase:
  • Dati Azienda
  • Commesse
  • Esporta buoni
  • +
  • Timbrature
  • Logout
  • @{ diff --git a/Views/Shared/_LayoutPortale.cshtml b/Views/Shared/_LayoutPortale.cshtml index 3551deb..831f1b9 100644 --- a/Views/Shared/_LayoutPortale.cshtml +++ b/Views/Shared/_LayoutPortale.cshtml @@ -347,7 +347,31 @@ Purchase:

    Consectetur adipiscing elit, sed do eiusmod tempor incididunt usdet labore esdt dolore magna aliqua. Quis ipsum suspendisse ultrices gravida.

    *@
    -
    +
    +
    +
      +
    • +
    • +
    • +
    • +
    • +
    • +
    +
    + Virtual Task +
    +
    +

    La soluzione standalone per la rendicontazione delle attività svolte fuori sede.
    Ideale per piccoli Manutentori e Impiantisti

    + + Leggi Altro + + + + +
    +
    +
    +
    • @@ -359,23 +383,22 @@ Purchase:
    @* *@ - Virtual Task + Virtual Task
    @*

    Virtual Task

    *@ -

    La soluzione standalone per la rendicontazione delle attività svolte fuori sede.
    Ideale per piccoli Manutentori e Impiantisti

    - +

    Virtual Task Time Sheet è un' App che permette di consuntivare i tempi di lavoro su commessa ed esportarli poi su foglio di excel tramite la soluzione web.

    +
    Leggi Altro -
    -
    -
    +
    +
    • @@ -400,8 +423,8 @@ Purchase:
    -
    -
    +
    +
    • @@ -416,7 +439,7 @@ Purchase:
    @*

    Task Manager

    *@ -

    Il modulo integrato con Adhoc Revolution Zucchetti , sia Web che Client Server , che permette la completa gestione delle aziende di manutenzione ed impiantistiche.

    +

    Il modulo integrato con Adhoc Revolution Zucchetti, Web e Client Server, che permette la completa gestione delle aziende di manutenzione ed impiantistiche.

    Leggi Altro @@ -426,7 +449,6 @@ Purchase:
    - @*