-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadmin.html
More file actions
509 lines (484 loc) · 34.6 KB
/
admin.html
File metadata and controls
509 lines (484 loc) · 34.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
<!DOCTYPE html>
<html lang="it">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Office Dashboard - Antimo Attività</title>
<!-- Riusiamo lo stesso CSS base ma aggiungiamo stili specifici per desktop -->
<link rel="stylesheet" href="style.css">
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;700&display=swap" rel="stylesheet">
<style>
body {
background-color: #f4f7f6;
margin: 0;
padding: 0;
overflow-x: hidden;
display: block; /* Overrides mobile app centering */
}
.admin-header {
background: linear-gradient(135deg, #22c55e 0%, #15803d 100%);
color: white;
padding: 1rem 2rem;
display: flex;
justify-content: space-between;
align-items: center;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.admin-container {
max-width: 1400px;
margin: 2rem auto;
padding: 0 1rem;
}
.controls-card {
background: white;
border-radius: 12px;
padding: 1.5rem;
margin-bottom: 2rem;
box-shadow: 0 4px 15px rgba(0,0,0,0.05);
display: flex;
flex-wrap: wrap;
gap: 1.5rem;
align-items: flex-end;
}
.control-group {
display: flex;
flex-direction: column;
gap: 0.5rem;
}
.control-group label {
font-size: 0.85rem;
font-weight: 600;
color: var(--blue-dark);
text-transform: uppercase;
}
.control-group input, .control-group select {
padding: 0.75rem;
border: 1px solid #ddd;
border-radius: 8px;
font-family: inherit;
}
/* Tabella Desktop */
.table-container {
background: white;
border-radius: 12px;
box-shadow: 0 4px 15px rgba(0,0,0,0.05);
overflow-x: auto;
}
table {
width: 100%;
border-collapse: collapse;
text-align: left;
}
th, td {
padding: 1rem;
border-bottom: 1px solid #eee;
}
th {
background-color: #f8fafc;
color: var(--blue-dark);
font-weight: 600;
font-size: 0.9rem;
position: sticky;
top: 0;
}
tbody tr:hover {
background-color: #f1f5f9;
}
.badge {
padding: 4px 8px;
border-radius: 12px;
font-size: 0.75rem;
font-weight: 600;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef08a; color: #854d0e; }
.attachment-link {
color: var(--blue-primary);
text-decoration: none;
font-weight: 600;
display: inline-flex;
align-items: center;
gap: 5px;
}
.attachment-link:hover { text-decoration: underline; }
.btn-sm {
padding: 0.5rem 1rem;
font-size: 0.9rem;
}
.loading-spinner {
text-align: center;
padding: 3rem;
color: var(--blue-primary);
font-weight: 600;
}
</style>
</head>
<body>
<header class="admin-header">
<div style="display: flex; flex-direction: column; gap: 8px; align-items: flex-start;">
<div style="background: white; padding: 6px 16px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<h1 style="margin: 0; font-size: 1.5rem; color: var(--blue-primary);">Antimo - Dashboard Ufficio</h1>
</div>
<div style="background: white; padding: 4px 12px; border-radius: 6px; box-shadow: 0 2px 4px rgba(0,0,0,0.1);">
<p style="margin: 0; font-size: 0.85rem; color: var(--blue-primary); font-weight: 700;">Gestione Remota Interventi</p>
</div>
<div style="display: flex; gap: 10px; align-items: center;">
<div id="adminAuthContainer" style="color: white; font-size: 0.9rem; font-weight: bold; margin-right: 15px; display: flex; gap: 10px;">
<button class="btn btn-primary" id="btnLoginAdmin" style="margin: 0; background-color: var(--blue-dark); color: white; border: none; padding: 0.5rem 1rem; border-radius: 8px; cursor: pointer;">=d Login Admin</button>
<button class="btn btn-primary hidden" id="btnOpenAiSettings" style="margin: 0; background-color: #6366f1; color: white; border: none; padding: 0.5rem 1rem; border-radius: 8px; cursor: pointer;">> Cfg & Log AI</button>
<button class="btn btn-primary hidden" id="btnViewStats" style="margin: 0; background-color: #8b5cf6; color: white; border: none; padding: 0.5rem 1rem; border-radius: 8px; cursor: pointer;">=� Statistiche</button>
<button class="btn btn-primary hidden" id="btnViewDashboard" style="margin: 0; background-color: var(--blue-primary); color: white; border: none; padding: 0.5rem 1rem; border-radius: 8px; cursor: pointer;">�x9 Tabella Dati</button>
</div>
<button class="btn btn-primary hidden" id="btnManualSync" style="margin: 0; background-color: var(--orange); border-color: var(--orange);">= Sincronizza Dati</button>
<a href="index.html" class="btn" style="margin: 0; background-color: white; color: var(--blue-dark); text-decoration: none; border: 2px solid var(--blue-dark); display: flex; align-items: center; padding: 0.5rem 1rem; border-radius: 8px; font-weight: bold;">= Torna al Menu</a>
<button class="btn btn-primary" id="btnExportExcel" style="margin: 0;">�! Esporta Excel (CSV)</button>
<button class="btn btn-primary" id="btnOpenValuation" style="background-color: #22c55e; border-color: #16a34a; height: 100%; display: flex; align-items: center; justify-content: center; text-align: center; line-height: 1.2; margin-left: 10px;">
<span class="btn-icon">💰</span> VALORIZZAZIONE<br>ATTIVITÀ
</button>
</div>
</header>
<main class="admin-container">
<div id="filtersWrapper" class="hidden">
<div class="controls-card" style="align-items: flex-start; flex-direction: column;">
<div style="width: 100%; display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 15px; border-bottom: 1px solid #eee; padding-bottom: 10px;">
<span style="font-size: 0.85rem; font-weight: bold; color: #555; align-self: center;">Filtri Rapidi:</span>
<button class="btn btn-secondary btn-sm filter-quick" data-range="week" style="padding: 5px 10px; font-size: 0.8rem;">Ultima Settimana</button>
<button class="btn btn-secondary btn-sm filter-quick" id="btnFilterMonth" data-range="month" style="padding: 5px 10px; font-size: 0.8rem;">Mese in Corso</button>
<button class="btn btn-secondary btn-sm filter-quick" data-range="last_month" style="padding: 5px 10px; font-size: 0.8rem;">Mese Prec.</button>
<button class="btn btn-secondary btn-sm filter-quick" data-range="trim" style="padding: 5px 10px; font-size: 0.8rem;">Trimestre</button>
<button class="btn btn-secondary btn-sm filter-quick" data-range="year" style="padding: 5px 10px; font-size: 0.8rem;">Anno</button>
</div>
<div style="width: 100%; display: flex; flex-wrap: wrap; gap: 1.5rem; align-items: flex-end;">
<div class="control-group">
<label for="filterDateStart">Da Data</label>
<input type="date" id="filterDateStart">
</div>
<div class="control-group">
<label for="filterDateEnd">A Data</label>
<input type="date" id="filterDateEnd">
</div>
<div class="control-group">
<label for="filterSearch">Cerca (Paziente/Città)</label>
<input type="text" id="filterSearch" placeholder="Es. Mario Rossi...">
</div>
<div class="control-group" style="flex-grow: 1; text-align: right;">
<button class="btn btn-primary btn-orange btn-sm" id="btnApplyFilters">Conferma Cerca</button>
<button class="btn btn-danger btn-sm" id="btnResetFilters" style="margin-left: 10px;">Reset</button>
</div>
</div>
</div>
</div>
<div class="table-container" id="activitiesSection" style="margin-bottom: 2rem;">
<h2 id="toggleNonEseguitiHeader" style="padding: 1.5rem; margin: 0; background: linear-gradient(to right, #fef08a, #fde047); color: #b45309; border-bottom: 2px solid #eab308; display: flex; justify-content: space-between; align-items: center; cursor: pointer; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); transition: transform 0.2s;">
<div style="display: flex; align-items: center; flex-wrap: wrap; gap: 10px;">
<span style="font-size: 1.3rem;">⚠️ Interventi Non Eseguiti (Da Chiudere)</span>
<span id="badgeNonEseguitiHeader" style="background:#ef4444; color:white; padding: 4px 10px; border-radius: 12px; font-size: 0.9rem; font-weight: bold;">0</span>
<button id="btnMassDeleteNonEseguiti" class="btn btn-danger btn-sm hidden" style="margin: 0; padding: 6px 12px; font-weight: bold; font-size: 0.8rem; box-shadow: 0 4px 6px rgba(239, 68, 68, 0.4);">🗑️ Elimina (<span id="countNonEseguiti">0</span>)</button>
</div>
<span id="nonEseguitiToggleIcon" class="toggle-icon-bar" style="font-size: 1.2rem; font-weight: bold;" style="font-size: 0.9rem;">Apri ⬇️</span>
</h2>
<div id="nonEseguitiWrapper" class="hidden">
<table id="nonEseguitiTable">
<thead>
<tr>
<th style="width: 40px; text-align: center;"><input type="checkbox" id="selectAllNonEseguiti" style="transform: scale(1.3); cursor: pointer;"></th>
<th>Data Prevista</th>
<th>Paziente</th>
<th>Località</th>
<th>Indirizzo (Tel)</th>
<th>Tipo Intervento / Disp.</th>
<th>Motivazione Mancata Esecuzione</th>
<th>Azioni</th>
</tr>
</thead>
<tbody id="nonEseguitiTableBody">
<tr><td colspan="6" class="loading-spinner">Caricamento dati da Firebase... ⏳</td></tr>
</tbody>
</table>
</div>
<h2 id="toggleStoricoHeader" style="padding: 1.5rem; margin: 0; margin-top: 15px; background: linear-gradient(to right, #e0f2fe, #bae6fd); color: var(--blue-dark); border-bottom: 2px solid #7dd3fc; display: flex; justify-content: space-between; align-items: center; cursor: pointer; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.05); flex-wrap: wrap; gap: 10px; transition: transform 0.2s;">
<div style="display: flex; align-items: center; gap: 15px;">
<span> Storico Interventi (Eseguiti)</span>
<button id="btnMassDeleteStorico" class="btn btn-danger btn-sm hidden" style="margin: 0; padding: 6px 12px; font-weight: bold; font-size: 0.8rem; box-shadow: 0 4px 6px rgba(239, 68, 68, 0.4);">=�� Elimina Selezionati (<span id="countStorico">0</span>)</button>
</div>
<div>
<div style="position: relative; display: inline-block; margin-right: 15px;">
<button id="btnTechFilterToggle" style="padding: 5px 10px; border-radius: 6px; border: 1px solid #0284c7; font-size: 0.85rem; background: #0ea5e9; color: white; font-weight: bold; cursor: pointer;" onclick="event.stopPropagation(); document.getElementById('techFilterDropdown').classList.toggle('hidden')">👨🔧 Filtra Tecnici ▾</button>
<div id="techFilterDropdown" class="hidden" style="position: absolute; top: 100%; right: 0; width: max-content; min-width: 250px; background: white; border: 1px solid #ccc; border-radius: 6px; box-shadow: 0 4px 10px rgba(0,0,0,0.2); z-index: 1000; padding: 10px; display: flex; flex-direction: column; gap: 5px; color: black; font-size: 0.9rem; text-align: left;" onclick="event.stopPropagation();">
<!-- Generato da JS -->
</div>
</div>
<span style="font-size: 0.85rem; font-weight: bold; margin-right: 5px; color: var(--blue-dark);">Raggruppa per:</span>
<select id="groupBySelector" style="padding: 5px; border-radius: 6px; border: 1px solid #ccc; font-size: 0.85rem; margin-right: 15px; background: white; color: var(--blue-dark); font-weight: bold;" onclick="event.stopPropagation();">
<option value="">Nessuno</option>
<option value="giorno">Giorno</option>
<option value="mese">Mese</option>
<option value="trimestre">Trimestre</option>
<option value="anno">Anno</option>
<option value="tecnico">Tecnico Assegnatario</option>
<option value="paziente">Paziente</option>
<option value="localita">Località</option>
<option value="tipo">Tipo Intervento</option>
<option value="dispositivi">Dispositivi</option>
</select>
<button id="btnExpandAllGrouped" class="btn btn-secondary btn-sm hidden" style="margin:0; font-size:0.85rem; padding: 5px 10px; margin-right: 15px; background: #64748b; color: white; border: none;" onclick="event.stopPropagation();">Espandi Tutto 🔽</button>
<input type="text" id="quickSearchStorico" placeholder="Cerca al volo..." style="padding: 5px 10px; border-radius: 6px; border: 1px solid #ccc; font-size: 0.85rem; margin-right: 10px;" onclick="event.stopPropagation();">
<button id="btnToggleFilters" class="btn btn-primary btn-sm" style="margin:0; font-size:0.85rem; padding: 5px 10px; background: #b45309; border: none; margin-right: 5px;">�� Filtri Avanzati</button>
<span id="storicoToggleIcon" class="toggle-icon-bar" style="font-size: 1.2rem; font-weight: bold;">Apri ⬇️</span>
</div>
</h2>
<div id="storicoWrapper" class="hidden">
<table id="interventiTable">
<thead>
<tr>
<th style="width: 40px; text-align: center;"><input type="checkbox" id="selectAllStorico" style="transform: scale(1.3); cursor: pointer;"></th>
<th>Data Esecuzione</th>
<th>Orario (Inizio - Fine)</th>
<th>Paziente</th>
<th>Località</th>
<th>Indirizzo (Tel)</th>
<th>Tipo Intervento</th>
<th>Dispositivi / Matricola</th>
<th>Tecnico</th>
<th>Km</th>
<th>Allegato</th>
</tr>
</thead>
<tbody id="tableBody">
<tr><td colspan="9" class="loading-spinner">Caricamento dati da Firebase... ⏳</td></tr>
</tbody>
</table>
</div>
<!-- SEZIONE STATISTICHE E GRAFICI -->
<div id="adminStatsSection" class="hidden" style="margin-bottom: 2rem; background: white; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); padding: 20px;">
<h2 style="color: var(--blue-dark); margin-top: 0; padding-bottom: 10px; border-bottom: 2px solid #f1f5f9; display: flex; align-items: center; justify-content: space-between;">
<span>=� Analisi Operativa e Statistiche</span>
<span style="font-size: 0.8rem; font-weight: normal; color: #64748b;">(I grafici rispettano i filtri di data e riceca applicati in alto)</span>
</h2>
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 20px; margin-top: 20px;">
<!-- Chart 1 -->
<div style="background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 15px;">
<h3 style="font-size: 1rem; color: #475569; margin-top: 0; text-align: center;">Stato Interventi (Completamento vs Programmazione)</h3>
<div style="position: relative; height: 230px; width: 100%;">
<canvas id="chartStatoInterventi"></canvas>
</div>
</div>
<!-- Chart 2 -->
<div style="background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 15px;">
<h3 style="font-size: 1rem; color: #475569; margin-top: 0; text-align: center;">Performance Tecnici (Volume Interventi Completati)</h3>
<div style="position: relative; height: 230px; width: 100%;">
<canvas id="chartInterventiTecnici"></canvas>
</div>
</div>
<!-- Chart 3 -->
<div style="background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 15px; grid-column: 1 / -1;">
<h3 style="font-size: 1rem; color: #475569; margin-top: 0; text-align: center;">Trend Lineare (Volume temporale interventi eseguiti)</h3>
<div style="position: relative; height: 280px; width: 100%;">
<canvas id="chartTrendTemporale"></canvas>
</div>
</div>
<!-- Chart 4 -->
<div style="background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; padding: 15px; grid-column: 1 / -1;">
<h3 style="font-size: 1rem; color: #475569; margin-top: 0; text-align: center;">Valutazione Pazienti DPAD/D3 (Esito Medio per Operatore Sanitario)</h3>
<div style="position: relative; height: 230px; width: 100%;">
<canvas id="chartValutazioniD3"></canvas>
</div>
</div>
</div>
</div>
<!-- MODAL MODIFICA ATTIVITA (Admin) -->
<div id="editInterventionModal" class="hidden" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 1000; overflow-y: auto; display: flex; align-items: flex-start; justify-content: center;">
<div style="background: white; padding: 20px; border-radius: 12px; width: 90%; max-width: 500px; margin: 40px auto; box-shadow: 0 10px 25px rgba(0,0,0,0.2);">
<h3 style="color: var(--blue-dark); margin-bottom: 15px; display:flex; justify-content: space-between; align-items:center;">
<span><span class="btn-icon">�S�️</span> Modifica Attività (Admin)</span>
<button id="btnCancelEdit" style="background:none; border:none; font-size:1.5rem; cursor:pointer;">×</button>
</h3>
<form id="editInterventionForm">
<input type="hidden" id="editFbId">
<input type="hidden" id="editIsProgrammato">
<div class="form-group">
<label>Paziente / Ente</label>
<input type="text" id="editPaziente" required>
</div>
<div class="form-group">
<label>Località</label>
<input type="text" id="editLocalita" required>
</div>
<div class="form-group">
<label>Indirizzo</label>
<input type="text" id="editIndirizzo">
</div>
<div class="form-group">
<label>Telefono</label>
<input type="tel" id="editTelefono">
</div>
<div class="form-group">
<label>Tipo Intervento</label>
<input type="text" id="editTipo">
</div>
<div class="form-group">
<label>Dispositivi</label>
<input type="text" id="editDispositivi">
</div>
<div class="form-group" id="containerKm">
<label>Km Percorsi</label>
<input type="number" id="editKm">
</div>
<!-- CAMPI VALUTAZIONE DPAD / D3 -->
<div style="border-top: 1px dashed #ccc; padding-top: 10px; display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 15px;">
<div class="form-group" style="flex: 1; min-width: 120px; margin-bottom: 0;">
<label style="color: #0284c7; font-weight: bold; font-size: 0.8rem;">Operatore Sanitario (Opzionale)</label>
<select id="editOperatoreValutazione" style="width: 100%; padding: 6px; border-radius: 4px; border: 1px solid #bae6fd; background: #f0f9ff;"></select>
</div>
<div class="form-group" style="flex: 1; min-width: 120px; margin-bottom: 0;">
<label style="color: #0284c7; font-weight: bold; font-size: 0.8rem;">Esito / Punteggio</label>
<input type="text" id="editEsito" style="width: 100%; padding: 6px; border-radius: 4px; border: 1px solid #bae6fd; background: #f0f9ff;">
</div>
<div class="form-group" style="flex: 1; min-width: 120px; margin-bottom: 0;">
<label style="color: #0284c7; font-weight: bold; font-size: 0.8rem;">Stato Valutazione</label>
<select id="editStatoValutazione" style="width: 100%; padding: 6px; border-radius: 4px; border: 1px solid #bae6fd; background: #f0f9ff;">
<option value="">Nessuno</option>
<option value="Svolta - A buon fine"> A buon fine</option>
<option value="Svolta - Da ripetere">= Da ripetere</option>
</select>
</div>
</div>
<div class="form-group">
<label>Note</label>
<textarea id="editNote" rows="2"></textarea>
</div>
<button type="button" id="btnSaveEdit" class="btn btn-primary btn-large" style="width: 100%; margin-top: 10px;">SALVA MODIFICHE</button>
</form>
</div>
</div>
</main>
<!-- MODAL CFG E LOG AI (AMMINISTRATORE) -->
<div id="aiAdminModal" class="hidden" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 2000; display: flex; align-items: flex-start; justify-content: center; overflow-y: auto;">
<div style="background: white; padding: 20px; border-radius: 12px; width: 95%; max-width: 900px; margin: 40px auto; box-shadow: 0 10px 25px rgba(0,0,0,0.2);">
<h3 style="color: #4f46e5; margin-bottom: 15px; display:flex; justify-content: space-between; align-items:center; border-bottom: 2px solid #e0e7ff; padding-bottom: 10px;">
<span><span class="btn-icon">></span> Configurazione e Log AI (Gemini)</span>
<button id="btnCloseAiAdmin" style="background:none; border:none; font-size:1.5rem; cursor:pointer;">×</button>
</h3>
<div style="background: #f8fafc; padding: 15px; border-radius: 8px; border: 1px solid #cbd5e1; margin-bottom: 20px;">
<h4 style="margin-top: 0; font-size: 1rem; color: #334155;">Chiave API Google Gemini (Firestore Segreto)</h4>
<p style="font-size: 0.85rem; color: #64748b; margin-bottom: 15px;">Inserisci qui la tua chiave API. Verrà salvata su Firestore e utilizzata dalle app dei tecnici per effettuare le interrogazioni. Non sarà mai visibile pubblicamente nel codice frontend.</p>
<div style="display: flex; gap: 10px; align-items: center;">
<input type="password" id="adminAiKeyInput" placeholder="Incolla qui la chiave API (AIzaSy...)" style="flex: 1; padding: 10px; border: 1px solid #ccc; border-radius: 6px;">
<button id="btnSaveAiKey" class="btn btn-primary" style="background-color: #4f46e5; border: none; margin: 0; padding: 10px 15px;">=� SALVA CHIAVE</button>
<button id="btnTestAiKey" class="btn btn-secondary" style="margin: 0; padding: 10px 15px;">= TEST</button>
</div>
</div>
<h4 style="margin-top: 20px; font-size: 1.1rem; color: #334155;">Log Interrogazioni AI</h4>
<div style="display: flex; justify-content: space-between; margin-bottom: 10px; align-items: center;">
<span id="aiLogsSummary" style="font-weight: bold; color: #b45309; background: #fef3c7; padding: 5px 10px; border-radius: 6px;">Costo Totale Stimato: $0.0000</span>
<button id="btnRefreshAiLogs" class="btn btn-secondary btn-sm" style="margin: 0;">= Aggiorna Log</button>
</div>
<div style="overflow-x: auto; max-height: 400px; border-bottom: 2px solid #e2e8f0; margin-bottom: 20px;">
<table style="width: 100%; border-collapse: collapse; text-align: left; font-size: 0.85rem;">
<thead>
<tr style="background: #f1f5f9; position: sticky; top: 0;">
<th style="padding: 10px;">Data/Ora</th>
<th style="padding: 10px;">Utente</th>
<th style="padding: 10px;">Domanda (Prompt snippet)</th>
<th style="padding: 10px;">Token (I/O)</th>
<th style="padding: 10px;">Tempo (s)</th>
<th style="padding: 10px;">Costo ($)</th>
</tr>
</thead>
<tbody id="aiLogsTableBody">
<tr><td colspan="6" style="text-align: center; padding: 20px; color: #64748b;">Nessun log presente o caricamento in corso...</td></tr>
</tbody>
</table>
</div>
</div>
</div>
<!-- MODAL VALORIZZAZIONE ATTIVITÀ -->
<div id="valorizzazioneModal" class="hidden" style="position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 2300; overflow-y: auto; display: flex; align-items: flex-start; justify-content: center;">
<div style="background: white; padding: 20px; border-radius: 12px; width: 95%; max-width: 900px; margin: 20px auto; box-shadow: 0 10px 25px rgba(0,0,0,0.2); display: flex; flex-direction: column;">
<h3 style="color: #15803d; margin-bottom: 15px; display:flex; justify-content: space-between; align-items:center; border-bottom: 2px solid #bbf7d0; padding-bottom: 10px;">
<span><span class="btn-icon">💰</span> Valorizzazione Attività</span>
<button id="btnCloseValuation" style="background:none; border:none; font-size:1.5rem; cursor:pointer;">×</button>
</h3>
<div style="display: flex; flex-wrap: wrap; gap: 15px; margin-bottom: 20px; background: #f0fdf4; padding: 15px; border-radius: 8px; border: 1px solid #bbf7d0;">
<div style="flex: 1; min-width: 150px;">
<label style="font-size: 0.8rem; font-weight: bold; color: #166534;">Periodo / Modus</label>
<select id="valPeriod" style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 6px;">
<option value="oggi">Oggi</option>
<option value="ieri">Ieri</option>
<option value="mese_corrente" selected>Questo Mese</option>
<option value="mese_scorso">Mese Scorso</option>
<option value="trimestre">Questo Trimestre</option>
<option value="anno">Quest'Anno</option>
<option value="custom">Date Personalizzate...</option>
</select>
</div>
<div id="valCustomDates" class="hidden" style="flex: 2; display: flex; gap: 10px; min-width: 250px;">
<div style="flex: 1;">
<label style="font-size: 0.8rem; font-weight: bold; color: #166534;">Dal</label>
<input type="date" id="valDateFrom" style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 6px;">
</div>
<div style="flex: 1;">
<label style="font-size: 0.8rem; font-weight: bold; color: #166534;">Al</label>
<input type="date" id="valDateTo" style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 6px;">
</div>
</div>
<div style="flex: 1; min-width: 150px;">
<label style="font-size: 0.8rem; font-weight: bold; color: #166534;">Ruolo</label>
<select id="valRole" style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 6px;">
<option value="">Tutti i Ruoli</option>
<!-- Popolato dinamicamente -->
</select>
</div>
<div style="flex: 1; min-width: 150px;">
<label style="font-size: 0.8rem; font-weight: bold; color: #166534;">Operatore/Tecnico</label>
<select id="valOperator" style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 6px;">
<option value="">Tutti gli Operatori</option>
<!-- Popolato dinamicamente -->
</select>
</div>
<div style="display: flex; align-items: flex-end;">
<button id="btnCalculateValuation" class="btn btn-primary" style="margin: 0; padding: 8px 15px; background: #22c55e; border-color: #16a34a;"><span class="btn-icon">🧮</span> CALCOLA</button>
</div>
</div>
<div style="display: flex; gap: 15px; margin-bottom: 20px;">
<div style="flex: 1; background: #f8fafc; padding: 15px; border-radius: 8px; text-align: center; border: 1px solid #e2e8f0;">
<div style="font-size: 0.85rem; color: #64748b; font-weight: bold; text-transform: uppercase;">Totale Interventi Validi</div>
<div id="valTotalCount" style="font-size: 1.8rem; font-weight: bold; color: #0f172a;">0</div>
</div>
<div style="flex: 1; background: #ecfdf5; padding: 15px; border-radius: 8px; text-align: center; border: 1px solid #6ee7b7;">
<div style="font-size: 0.85rem; color: #047857; font-weight: bold; text-transform: uppercase;">Valore Economico Totale</div>
<div id="valTotalAmount" style="font-size: 1.8rem; font-weight: bold; color: #059669;">€ 0.00</div>
</div>
</div>
<h4 style="color: #334155; margin-bottom: 10px; font-size: 1rem;">Dettaglio Attività Valutate</h4>
<div style="overflow-x: auto; max-height: 400px; border: 1px solid #e2e8f0; border-radius: 8px;">
<table id="valDetailsTable" style="width: 100%; border-collapse: collapse; font-size: 0.85rem; text-align: left;">
<thead style="background: #f1f5f9; position: sticky; top: 0; box-shadow: 0 2px 4px rgba(0,0,0,0.05);">
<tr>
<th style="padding: 10px; border-bottom: 2px solid #cbd5e1; color: #334155;">Data</th>
<th style="padding: 10px; border-bottom: 2px solid #cbd5e1; color: #334155;">Operatore</th>
<th style="padding: 10px; border-bottom: 2px solid #cbd5e1; color: #334155;">Ruolo / Paziente</th>
<th style="padding: 10px; border-bottom: 2px solid #cbd5e1; color: #334155;">Tipo Intervento</th>
<th style="padding: 10px; border-bottom: 2px solid #cbd5e1; color: #334155; text-align: right;">Valore Unit.</th>
<th style="padding: 10px; border-bottom: 2px solid #cbd5e1; color: #334155; text-align: right;">Valore Tot.</th>
<th style="padding: 10px; border-bottom: 2px solid #cbd5e1; color: #334155; text-align: center; width: 40px;"></th>
</tr>
</thead>
<tbody id="valDetailsTableBody">
<tr><td colspan="7" style="padding: 20px; text-align: center; color: #94a3b8;">Imposta i filtri e clicca su Calcola per visualizzare la valorizzazione economica.</td></tr>
</tbody>
</table>
</div>
<div style="margin-top: 20px; display: flex; justify-content: flex-end;">
<button id="valExportBtn" class="btn btn-secondary" style="font-size: 0.85rem; padding: 6px 12px; display: none;">📥 ESPORTA CSV</button>
</div>
</div>
</div>
<!-- Libs -->
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.25/jspdf.plugin.autotable.min.js"></script>
<script type="module" src="admin.js?v=68"></script>
<script type="module" src="global_notifications.js?v=64"></script>
</body>
</html>