205 lines
7.3 KiB
Plaintext
205 lines
7.3 KiB
Plaintext
@using CORE.Data.DbModels
|
|
@using UI.Data
|
|
|
|
@inject IJSRuntime JSRuntime
|
|
@inject GpwDataService GDataServ
|
|
@inject MessageService AppMServ
|
|
|
|
|
|
@if (CalcOreProj == null)
|
|
{
|
|
<LoadingDataSmall></LoadingDataSmall>
|
|
}
|
|
else
|
|
{
|
|
<div class="card border border-info">
|
|
<div class="card-header bg-info text-light py-1">
|
|
<div class="d-flex justify-content-between border border-top-0 border-left-0 border-right-0">
|
|
<div class="px-0">
|
|
<b>@CalcOreProj.Gruppo</b>
|
|
</div>
|
|
<div class="px-0">
|
|
<span>@CalcOreProj.RagSociale</span>
|
|
</div>
|
|
</div>
|
|
<div class="d-flex justify-content-between">
|
|
<div class="px-0">
|
|
<span>@CalcOreProj.NomeProj</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="card-body py-1">
|
|
<div class="d-flex justify-content-between">
|
|
<div class="px-0">
|
|
Budget: <b>@CalcOreProj.budgetTime.ToString("N2")</b>
|
|
</div>
|
|
<div class="px-0 @cssCheckOre">
|
|
consumate: <b>@CalcOreProj.percUsed.ToString("P1")</b>
|
|
</div>
|
|
</div>
|
|
<div class="d-flex justify-content-between">
|
|
<div class="px-0">
|
|
Caricate: <b>@CalcOreProj.totOre.ToString("N2")</b>
|
|
</div>
|
|
<div class="px-0 @cssCheckOre">
|
|
rimanenti: <b>@CalcOreProj.timeRem.ToString("N0")</b>
|
|
</div>
|
|
</div>
|
|
@if (@CalcOreProj.timeRem < 0)
|
|
{
|
|
<div class="alert alert-danger">
|
|
<b>Attenzione!</b>: impossibile caricare altre ore nel progetto, verificare sia attivo o le ore a budget con amministrazione prima di procedere!
|
|
</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
<div class="card border border-info mt-1">
|
|
<div class="card-header bg-info text-light py-1">
|
|
@if (currFase != null)
|
|
{
|
|
<div class="d-flex justify-content-between">
|
|
<div class="px-0">
|
|
<b>@ancestFase.NomeFase</b>
|
|
</div>
|
|
<div class="px-0">
|
|
<span>@currFase.NomeFase</span>
|
|
</div>
|
|
</div>
|
|
}
|
|
</div>
|
|
<div class="card-body">
|
|
<div class="row">
|
|
<div class="col-6" title="Chiusura/prolungamento attività precedente all'avvio della nuova attività">
|
|
<label class="small">Consecutiva</label>
|
|
<div class="custom-control custom-switch">
|
|
<input type="checkbox" class="custom-control-input" id="switchClosePrec" @bind-value="@doClose" checked="@doClose">
|
|
<label class="custom-control-label" for="switchClosePrec">Chiudi</label>
|
|
</div>
|
|
</div>
|
|
<div class="col-6 text-right" title="Durata prevista attività (minuti)">
|
|
<label class="small">Durata Prevista</label>
|
|
<div class="input-group mb-2">
|
|
<div class="input-group-prepend">
|
|
<span class="input-group-text">Min</span>
|
|
</div>
|
|
<input type="number" class="form-control text-right" placeholder="minuti" @bind-value="@minDur">
|
|
</div>
|
|
</div>
|
|
<div class="col-12" title="Descrizione di dettaglio attività">
|
|
<label class="small">Descrizione Attività</label>
|
|
<div class="input-group mb-2">
|
|
<div class="input-group-prepend">
|
|
<span class="input-group-text"><i class="far fa-comment-alt"></i></span>
|
|
</div>
|
|
<input type="text" class="form-control text-right" placeholder="Inserire descrizione attività" @bind-value="@descrizione">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-6">
|
|
@if (CalcOreProj != null && CalcOreProj.timeRem > 0)
|
|
{
|
|
<button class="btn btn-lg btn-block btn-success" @onclick="() => StartRecord()"><i class="fas fa-play"></i> Start</button>
|
|
}
|
|
</div>
|
|
<div class="col-6">
|
|
<button class="btn btn-lg btn-block btn-warning" @onclick="() => ClosePage()"><i class="fas fa-ban"></i> Cancel</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
}
|
|
|
|
@code {
|
|
private int _idxFase = 0;
|
|
private int idxProj = 0;
|
|
private int minDur = 30;
|
|
private bool doClose = true;
|
|
|
|
private string descrizione = "";
|
|
|
|
private string cssCheckOre = "";
|
|
|
|
private CalcOreProgettiModel? CalcOreProj { get; set; } = null;
|
|
private AnagFasiModel? currFase { get; set; } = null;
|
|
private AnagFasiModel? ancestFase { get; set; } = null;
|
|
|
|
[Parameter]
|
|
public int idxFase
|
|
{
|
|
get
|
|
{
|
|
return _idxFase;
|
|
}
|
|
set
|
|
{
|
|
_idxFase = value;
|
|
var pUpd = Task.Run(async () => await ReloadData());
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> RecStarted { get; set; }
|
|
|
|
private async Task StartRecord()
|
|
{
|
|
// calcolo dataora chiusura...
|
|
DateTime newInizio = CORE.Data.Utils.DateRounded(DateTime.Now, 5, true);
|
|
|
|
// chiudo attività precedente (se c'è) odierna
|
|
if (doClose)
|
|
{
|
|
var lastRA = await GDataServ.RegAttLastByDip(AppMServ.IdxDipendente);
|
|
if (lastRA != null && lastRA.Inizio.Date == DateTime.Today)
|
|
{
|
|
lastRA.Fine = newInizio;
|
|
await GDataServ.RegAttUpdate(lastRA);
|
|
}
|
|
}
|
|
// registro nuova attività
|
|
RegAttivitaModel newItem = new RegAttivitaModel()
|
|
{
|
|
IdxDipendente = AppMServ.IdxDipendente,
|
|
Inizio = newInizio,
|
|
Fine = newInizio.AddMinutes(minDur),
|
|
IdxFase = idxFase,
|
|
Descrizione = descrizione
|
|
};
|
|
await GDataServ.RegAttUpdate(newItem);
|
|
// segnalo fatto
|
|
await RecStarted.InvokeAsync(false);
|
|
}
|
|
|
|
private async Task ClosePage()
|
|
{
|
|
await RecStarted.InvokeAsync(false);
|
|
}
|
|
|
|
protected async Task ReloadData()
|
|
{
|
|
// recupero dati fase completi...
|
|
currFase = await GDataServ.AnagFasiSearch(idxFase);
|
|
ancestFase = await GDataServ.AnagFasiSearch(currFase.IdxFaseAncest);
|
|
if (currFase != null)
|
|
{
|
|
if (currFase.IdxProgetto != null)
|
|
{
|
|
int idxProj = (int)currFase.IdxProgetto;
|
|
CalcOreProj = await GDataServ.CalcOreProj(idxProj);
|
|
cssCheckOre = "text-success";
|
|
if (CalcOreProj.percUsed > 1)
|
|
{
|
|
cssCheckOre = "text-danger";
|
|
}
|
|
else if (CalcOreProj.percUsed * 100 > 80)
|
|
{
|
|
cssCheckOre = "text-warning";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|