email documenti
This commit is contained in:
@@ -87,10 +87,17 @@
|
||||
<div class="form-group">
|
||||
<label>Allegati</label>
|
||||
<div class="border rounded p-3 bg-light">
|
||||
<label class="btn btn-sm btn-success mb-0">
|
||||
<i class="fas fa-upload mr-1"></i> Carica file
|
||||
<input type="file" name="allegati[]" multiple class="d-none">
|
||||
</label>
|
||||
<div class="mb-3">
|
||||
<button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#documentiModal">
|
||||
<i class="fas fa-folder-open mr-1"></i> Seleziona da Documenti
|
||||
</button>
|
||||
<label class="btn btn-sm btn-success mb-0">
|
||||
<i class="fas fa-upload mr-1"></i> Carica file
|
||||
<input type="file" name="allegati[]" id="allegati" multiple class="d-none" onchange="handleFileUpload(this)">
|
||||
</label>
|
||||
</div>
|
||||
<div id="allegati-list"></div>
|
||||
<input type="hidden" name="documenti_selezionati" id="documenti_selezionati" value="">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -110,10 +117,62 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="documentiModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="fas fa-folder-open mr-2"></i>Seleziona Documenti</h5>
|
||||
<button type="button" class="close" data-dismiss="modal">
|
||||
<span>×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
@if($documenti->count() > 0)
|
||||
<div class="table-responsive">
|
||||
<table class="table table-bordered table-hover table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width: 40px;"></th>
|
||||
<th>Nome File</th>
|
||||
<th>Tipologia</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach($documenti as $doc)
|
||||
<tr>
|
||||
<td>
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input doc-checkbox" id="doc-{{ $doc->id }}" value="{{ $doc->id }}" data-nome="{{ $doc->nome_file }}">
|
||||
<label class="custom-control-label" for="doc-{{ $doc->id }}"></label>
|
||||
</div>
|
||||
</td>
|
||||
<td>{{ $doc->nome_file }}</td>
|
||||
<td><span class="badge badge-info">{{ $doc->tipologia ?: $doc->tipo }}</span></td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@else
|
||||
<p class="text-muted">Nessun documento disponibile.</p>
|
||||
@endif
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Annulla</button>
|
||||
<button type="button" class="btn btn-primary" onclick="aggiungiDocumenti()">
|
||||
<i class="fas fa-plus mr-1"></i> Aggiungi
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@section('scripts')
|
||||
<script>
|
||||
let allegatiSelezionati = [];
|
||||
|
||||
function toggleDestinatari() {
|
||||
const tipo = document.getElementById('destinatario_tipo').value;
|
||||
|
||||
@@ -160,6 +219,53 @@ function loadGruppiContatti() {
|
||||
});
|
||||
}
|
||||
|
||||
function aggiungiDocumenti() {
|
||||
const checkboxes = document.querySelectorAll('.doc-checkbox:checked');
|
||||
checkboxes.forEach(function(cb) {
|
||||
const id = parseInt(cb.value);
|
||||
const nome = cb.dataset.nome;
|
||||
|
||||
if (!allegatiSelezionati.includes(id)) {
|
||||
allegatiSelezionati.push(id);
|
||||
|
||||
const container = document.getElementById('allegati-list');
|
||||
const div = document.createElement('div');
|
||||
div.className = 'd-flex align-items-center justify-content-between bg-white p-2 mb-2 rounded';
|
||||
div.id = 'allegato-' + id;
|
||||
div.innerHTML = '<span><i class="fas fa-file mr-2"></i>' + nome + '</span>' +
|
||||
'<button type="button" class="btn btn-xs btn-danger" onclick="removeAllegato(' + id + ')">' +
|
||||
'<i class="fas fa-times"></i></button>';
|
||||
container.appendChild(div);
|
||||
}
|
||||
|
||||
cb.checked = false;
|
||||
});
|
||||
|
||||
document.getElementById('documenti_selezionati').value = allegatiSelezionati.join(',');
|
||||
$('#documentiModal').modal('hide');
|
||||
}
|
||||
|
||||
function removeAllegato(id) {
|
||||
allegatiSelezionati = allegatiSelezionati.filter(function(a) { return a !== id; });
|
||||
const el = document.getElementById('allegato-' + id);
|
||||
if (el) el.remove();
|
||||
document.getElementById('documenti_selezionati').value = allegatiSelezionati.join(',');
|
||||
}
|
||||
|
||||
function handleFileUpload(input) {
|
||||
if (!input.files) return;
|
||||
const container = document.getElementById('allegati-list');
|
||||
for (const file of input.files) {
|
||||
const div = document.createElement('div');
|
||||
div.className = 'd-flex align-items-center justify-content-between bg-white p-2 mb-2 rounded';
|
||||
div.innerHTML = '<span><i class="fas fa-file mr-2"></i>' + file.name + ' (' + (file.size / 1024).toFixed(1) + ' KB)</span>' +
|
||||
'<button type="button" class="btn btn-xs btn-danger" onclick="this.parentElement.remove()">' +
|
||||
'<i class="fas fa-times"></i></button>';
|
||||
container.appendChild(div);
|
||||
}
|
||||
input.value = '';
|
||||
}
|
||||
|
||||
function saveDraft() {
|
||||
const form = document.getElementById('emailForm');
|
||||
const formData = new FormData(form);
|
||||
|
||||
Reference in New Issue
Block a user