189 lines
5.8 KiB
Plaintext
189 lines
5.8 KiB
Plaintext
@page "/FastRec"
|
|
|
|
@using GPW.CORE.UI
|
|
@using GPW.CORE.UI.Components
|
|
@using CORE.Data.DbModels
|
|
@using CORE.Data.DTO
|
|
@using UI.Data
|
|
|
|
@inject IJSRuntime JSRuntime
|
|
@inject GpwDataService GDataServ
|
|
@inject MessageService AppMServ
|
|
|
|
<div class="card">
|
|
<div class="card-header table-primary">
|
|
<div class="d-flex justify-content-between">
|
|
<div class="px-2">
|
|
<h3>Fast Recording</h3>
|
|
</div>
|
|
<div class="px-2">
|
|
<div class="input-group input-group-lg" title="Modalità ricerca Progetti / Fasi">
|
|
<div class="input-group-prepend">
|
|
<span class="input-group-text">
|
|
<i class="fas fa-search"></i>
|
|
</span>
|
|
</div>
|
|
<select @bind="@TipoSearch" class="form-control form-control-sm">
|
|
<option value="0">Pareto attività</option>
|
|
<option value="1">Ricerca Libera</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-8">
|
|
@if (@TipoSearch == 0)
|
|
{
|
|
<ParetoRA ItemSelected="SelFase" idxFase="@idxFaseSel"></ParetoRA>
|
|
}
|
|
else if (@TipoSearch == 1)
|
|
{
|
|
<FasiSearch ItemSelected="SelFase"></FasiSearch>
|
|
}
|
|
</div>
|
|
<div class="col-4">
|
|
@if (idxFaseSel > 0)
|
|
{
|
|
<RecFaseStart RecStarted="RecDone" idxFase="@idxFaseSel"></RecFaseStart>
|
|
}
|
|
else
|
|
{
|
|
<div class="alert alert-info">
|
|
<h3>Attesa selezione</h3>
|
|
Selezionare una Fase per attivare la registrazione attività
|
|
</div>
|
|
}
|
|
</div>
|
|
<div class="col-12">
|
|
<DayHoriz IsTitle="true" StartHour="@startHour" EndHour="@endHour" ListFasi="@ListFasi" IdxDipSel="@idxDipendente"></DayHoriz>
|
|
@foreach (var currItem in ListRecords)
|
|
{
|
|
<DayHoriz DayDTO="@currItem" StartHour="@startHour" EndHour="@endHour" ListFasi="@ListFasi" IdxDipSel="@idxDipendente"></DayHoriz>
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
@code {
|
|
|
|
private List<AnagFasiModel> ListFasi = new List<AnagFasiModel>();
|
|
private List<DailyDataDTO> ListRecords = new List<DailyDataDTO>();
|
|
private int _tipoSearch = 0;
|
|
|
|
public int TipoSearch
|
|
{
|
|
get
|
|
{
|
|
return _tipoSearch;
|
|
}
|
|
set
|
|
{
|
|
if (!_tipoSearch.Equals(value))
|
|
{
|
|
_tipoSearch = value;
|
|
idxFaseSel = 0;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected int startHour = 7;
|
|
protected int endHour = 21;
|
|
protected bool isLoading = false;
|
|
private int idxFaseSel = 0;
|
|
|
|
private int idxDipendente
|
|
{
|
|
get => AppMServ.IdxDipendente;
|
|
}
|
|
|
|
private void SelFase(int idxFase)
|
|
{
|
|
idxFaseSel = idxFase;
|
|
}
|
|
|
|
private void RecDone(bool fatto)
|
|
{
|
|
idxFaseSel = 0;
|
|
}
|
|
|
|
private async Task ReloadData()
|
|
{
|
|
isLoading = true;
|
|
DateTime oggi = DateTime.Today;
|
|
var rawData=await GDataServ.DailyDetails(idxDipendente, oggi, oggi.AddDays(1));
|
|
ListRecords = rawData.Where(x=> x.DtRif==oggi).ToList();
|
|
await Task.Delay(100);
|
|
checkHourRange();
|
|
await Task.Delay(100);
|
|
isLoading = false;
|
|
}
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await ReloadData();
|
|
}
|
|
|
|
private void checkHourRange()
|
|
{
|
|
int minHour = 9;
|
|
int maxHour = 18;
|
|
if (ListRecords != null)
|
|
{
|
|
int roundMin = 15;
|
|
// per ogni giornata
|
|
foreach (var giornata in ListRecords)
|
|
{
|
|
var minRecTimb = giornata.ListTimbr
|
|
.Where(x => x.Entrata == true)
|
|
.OrderBy(x => x.DataOra)
|
|
.FirstOrDefault();
|
|
if (minRecTimb != null)
|
|
{
|
|
if (minHour > minRecTimb.DataOra.AddMinutes(-roundMin).Hour)
|
|
{
|
|
minHour = minRecTimb.DataOra.AddMinutes(-roundMin).Hour;
|
|
}
|
|
}
|
|
var minRecRa = giornata.ListRA
|
|
.OrderBy(x => x.Inizio)
|
|
.FirstOrDefault();
|
|
if (minRecRa != null)
|
|
{
|
|
if (minHour > minRecRa.Inizio.AddMinutes(-roundMin).Hour)
|
|
{
|
|
minHour = minRecRa.Inizio.AddMinutes(-roundMin).Hour;
|
|
}
|
|
}
|
|
var maxRecTimb = giornata.ListTimbr
|
|
.Where(x => x.Entrata == false)
|
|
.OrderByDescending(x => x.DataOra)
|
|
.FirstOrDefault();
|
|
if (maxRecTimb != null)
|
|
{
|
|
if (maxHour < maxRecTimb.DataOra.AddMinutes(roundMin).Hour + 1)
|
|
{
|
|
maxHour = maxRecTimb.DataOra.AddMinutes(roundMin).Hour + 1;
|
|
}
|
|
}
|
|
var maxRecRa = giornata.ListRA
|
|
.OrderByDescending(x => x.Fine)
|
|
.FirstOrDefault();
|
|
if (maxRecRa != null)
|
|
{
|
|
if (maxHour < maxRecRa.Fine.AddMinutes(roundMin).Hour + 1)
|
|
{
|
|
maxHour = maxRecRa.Fine.AddMinutes(roundMin).Hour + 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
startHour = minHour;
|
|
endHour = maxHour;
|
|
}
|
|
}
|