glastree_on_gitea

This commit is contained in:
2026-05-26 08:14:29 +02:00
commit 0bed099d05
9556 changed files with 1186307 additions and 0 deletions
+165
View File
@@ -0,0 +1,165 @@
@extends('layouts.adminlte')
@section('title', 'Nuova Email')
@section('page_title', 'Composizione Email')
@section('content')
<div class="row">
<div class="col-md-12">
<div class="card card-primary">
<div class="card-header">
<h3 class="card-title"><i class="fas fa-edit mr-2"></i>Nuova Email</h3>
</div>
<div class="card-body">
<form method="POST" action="{{ route('email.send') }}" id="emailForm">
@csrf
<div class="form-group">
<label>Destinatari *</label>
<div class="mb-2">
<select name="destinatario_tipo" id="destinatario_tipo" class="form-control" onchange="toggleDestinatari()">
<option value="manuale">Email Manuale</option>
<option value="individui">Singoli Individui</option>
<option value="gruppo">Membri di un Gruppo</option>
<option value="mailing_list">Mailing List</option>
</select>
</div>
<div id="manual-input" class="destinatari-section">
<input type="text" name="to" id="to_manual" class="form-control"
placeholder="destinatario@email.it" value="{{ $prefill['to'] ?? '' }}">
</div>
<div id="individui-input" class="destinatari-section" style="display: none;">
<select name="individui[]" id="individui-select" class="form-control" multiple size="5">
@foreach($individui as $ind)
<option value="{{ $ind->id }}">{{ $ind->cognito }} {{ $ind->nome }} ({{ $ind->email_primaria ?? 'senza email' }})</option>
@endforeach
</select>
<small class="text-muted">Tieni premuto Ctrl per selezionare più individui</small>
</div>
<div id="gruppo-input" class="destinatari-section" style="display: none;">
<select name="gruppo_id" id="gruppo-select" class="form-control mb-2" onchange="loadGruppiContatti()">
<option value="">Seleziona gruppo...</option>
@foreach($gruppi as $gruppo)
<option value="{{ $gruppo->id }}">{{ $gruppo->nome }}</option>
@endforeach
</select>
<div id="gruppo-contatti" class="border rounded p-2" style="max-height: 150px; overflow-y: auto;">
<em class="text-muted">Seleziona un gruppo per vedere i contatti</em>
</div>
</div>
<div id="mailing-list-input" class="destinatari-section" style="display: none;">
<select name="mailing_list_id" id="mailing-list-select" class="form-control">
<option value="">Seleziona mailing list...</option>
@foreach($mailingLists as $list)
<option value="{{ $list->id }}">{{ $list->nome }} ({{ $list->contatti->count() }} contatti)</option>
@endforeach
</select>
</div>
</div>
<div class="form-group">
<label for="subject">Oggetto *</label>
<input type="text" name="subject" id="subject" class="form-control"
value="{{ $prefill['subject'] ?? '' }}" required>
</div>
<div class="form-group">
<label for="body">Messaggio *</label>
<textarea name="body" id="body" class="form-control" rows="15" required>{{ $prefill['body'] ?? '' }}</textarea>
</div>
<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>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary">
<i class="fas fa-paper-plane mr-1"></i> Invia
</button>
<button type="button" class="btn btn-secondary ml-2" onclick="saveDraft()">
<i class="fas fa-save mr-1"></i> Salva Bozze
</button>
<a href="{{ route('email.index') }}" class="btn btn-default ml-2">
Annulla
</a>
</div>
</form>
</div>
</div>
</div>
</div>
@endsection
@section('scripts')
<script>
function toggleDestinatari() {
const tipo = document.getElementById('destinatario_tipo').value;
document.querySelectorAll('.destinatari-section').forEach(el => el.style.display = 'none');
if (tipo === 'manuale') {
document.getElementById('manual-input').style.display = 'block';
} else if (tipo === 'individui') {
document.getElementById('individui-input').style.display = 'block';
} else if (tipo === 'gruppo') {
document.getElementById('gruppo-input').style.display = 'block';
} else if (tipo === 'mailing_list') {
document.getElementById('mailing-list-input').style.display = 'block';
}
}
function loadGruppiContatti() {
const gruppoId = document.getElementById('gruppo-select').value;
const container = document.getElementById('gruppo-contatti');
if (!gruppoId) {
container.innerHTML = '<em class="text-muted">Seleziona un gruppo per vedere i contatti</em>';
return;
}
fetch('/gruppi/' + gruppoId + '/individui-email')
.then(response => response.json())
.then(data => {
if (data.length === 0) {
container.innerHTML = '<em class="text-muted">Nessun contatto email nel gruppo</em>';
return;
}
let html = '';
data.forEach(ind => {
if (ind.email) {
html += `<div class="form-check">
<input class="form-check-input" type="checkbox" name="gruppo_emails[]" value="${ind.email}" id="email-${ind.id}">
<label class="form-check-label" for="email-${ind.id}">${ind.cogname} ${ind.nome} - ${ind.email}</label>
</div>`;
}
});
container.innerHTML = html || '<em class="text-muted">Nessun contatto email nel gruppo</em>';
});
}
function saveDraft() {
const form = document.getElementById('emailForm');
const formData = new FormData(form);
fetch('{{ route('email.draft') }}', {
method: 'POST',
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
body: formData
})
.then(response => response.json())
.then(data => {
alert('Bozza salvata!');
});
}
</script>
@endsection
+340
View File
@@ -0,0 +1,340 @@
@extends('layouts.adminlte')
@section('title', 'Email - ' . ucfirst($folder))
@section('page_title', 'Email')
@php
$currentFolder = $folders->firstWhere('type', $folder);
@endphp
@section('content')
<div class="card">
<div class="card-header">
<h3 class="card-title"><i class="fas fa-envelope mr-2"></i>Email</h3>
<div class="card-tools">
<div class="btn-group mr-2">
@foreach($folders as $f)
<a href="{{ route('email.index', $f->type) }}"
class="btn btn-xs {{ $folder === $f->type ? 'btn-primary' : 'btn-default' }}">
<i class="fas {{ $f->icon }}"></i>
{{ $f->name }}
@if($f->type === 'inbox' && $messages->where('is_read', false)->count() > 0)
<span class="badge badge-light">{{ $messages->where('is_read', false)->count() }}</span>
@endif
</a>
@endforeach
</div>
<a href="{{ route('email.compose') }}" class="btn btn-success btn-xs">
<i class="fas fa-plus"></i> Nuova Email
</a>
<button class="btn btn-primary btn-xs" onclick="syncEmails()" id="syncBtn">
<i class="fas fa-sync"></i> Ricevi/Invia
</button>
</div>
</div>
<div class="card-body p-0">
<div class="card-header pb-0">
<div class="row align-items-center">
<div class="col-md-6">
<div class="form-inline">
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="selectAll" onchange="toggleAll(this)">
<label class="custom-control-label" for="selectAll">Seleziona tutto</label>
</div>
<span class="ml-3 text-muted" id="selectedCount">0 selezionati</span>
</div>
</div>
<div class="col-md-6">
<div class="input-group input-group-sm float-right" style="width: 220px;">
<select class="form-control" id="bulkAction">
<option value="">Azioni di massa...</option>
@if($folder !== 'trash')
<option value="mark_read">Marca come letto</option>
<option value="mark_unread">Marca come non letto</option>
<option value="star">Aggiungi a preferiti</option>
<option value="unstar">Rimuovi da preferiti</option>
<option value="move_trash">Sposta nel cestino</option>
@else
<option value="empty_trash">Svuota cestino</option>
@endif
</select>
<div class="input-group-append">
<button class="btn btn-secondary" type="button" onclick="executeBulkAction()">Applica</button>
</div>
</div>
</div>
</div>
</div>
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<th style="width: 30px;"></th>
<th style="width: 30px;"></th>
<th style="width: 150px;">
@php $sort = request('sort'); $dir = request('direction'); @endphp
@if($folder === 'sent' || $folder === 'inviate')
<a href="{{ request()->fullUrlWithQuery(['sort' => 'to_email', 'direction' => $sort === 'to_email' && $dir === 'asc' ? 'desc' : 'asc']) }}" class="text-dark text-decoration-none">
Destinatario {!! $sort === 'to_email' ? ($dir === 'asc' ? '▲' : '▼') : '' !!}
</a>
@else
<a href="{{ request()->fullUrlWithQuery(['sort' => 'from_email', 'direction' => $sort === 'from_email' && $dir === 'asc' ? 'desc' : 'asc']) }}" class="text-dark text-decoration-none">
Mittente {!! $sort === 'from_email' ? ($dir === 'asc' ? '▲' : '▼') : '' !!}
</a>
@endif
</th>
<th>
<a href="{{ request()->fullUrlWithQuery(['sort' => 'subject', 'direction' => $sort === 'subject' && $dir === 'asc' ? 'desc' : 'asc']) }}" class="text-dark text-decoration-none">
Oggetto {!! $sort === 'subject' ? ($dir === 'asc' ? '▲' : '▼') : '' !!}
</a>
</th>
<th style="width: 120px;">
<a href="{{ request()->fullUrlWithQuery(['sort' => 'received_at', 'direction' => $sort === 'received_at' && $dir === 'asc' ? 'desc' : 'asc']) }}" class="text-dark text-decoration-none">
Data {!! $sort === 'received_at' ? ($dir === 'asc' ? '▲' : '▼') : '' !!}
</a>
</th>
</tr>
</thead>
<tbody>
@forelse($messages as $message)
<tr class="{{ $message->is_read ? '' : 'font-weight-bold' }}">
<td style="width: 30px;" onclick="event.stopPropagation()">
<input type="checkbox" class="email-checkbox" value="{{ $message->id }}" onchange="updateCount()">
</td>
<td style="width: 30px;" onclick="event.stopPropagation(); window.location='{{ route('email.show', [$folder, $message->id]) }}'">
@if($message->is_starred)
<i class="fas fa-star text-warning"></i>
@endif
</td>
<td onclick="window.location='{{ route('email.show', [$folder, $message->id]) }}'">
{{ $message->is_sent ? 'A: ' . $message->to_email : ($message->from_name ?: $message->from_email) }}
</td>
<td onclick="window.location='{{ route('email.show', [$folder, $message->id]) }}'">
{{ $message->subject ?? '(senza oggetto)' }}
</td>
<td>
@if($message->received_at)
{{ $message->received_at->format('d/m/Y') }}
@elseif($message->sent_at)
{{ $message->sent_at->format('d/m/Y') }}
@endif
</td>
</tr>
@empty
<tr>
<td colspan="5" class="text-center text-muted py-4">
<i class="fas fa-inbox fa-2x mb-2"></i>
<p>Nessuna email</p>
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
<div class="card-footer">
{{ $messages->withQueryString()->links('vendor.pagination.simple-bootstrap-4') }}
</div>
</div>
@endsection
@push('styles')
<style>
/* Bootstrap 4 Pagination override */
.pagination {
display: flex !important;
padding-left: 0;
list-style: none;
border-radius: 0.25rem;
margin: 0;
justify-content: center;
}
.page-item {
display: inline-block;
}
.page-link {
position: relative;
display: block;
padding: 0.5rem 0.75rem;
margin-left: -1px;
line-height: 1.25;
color: #007bff;
background-color: #fff;
border: 1px solid #dee2e6;
text-decoration: none;
font-size: 0.875rem;
}
.page-item.active .page-link {
z-index: 3;
color: #fff;
background-color: #007bff;
border-color: #007bff;
}
.page-item.disabled .page-link {
color: #6c757d;
pointer-events: none;
background-color: #fff;
border-color: #dee2e6;
}
.page-link:hover {
color: #0056b3;
background-color: #e9ecef;
border-color: #dee2e6;
}
/* Icons as text characters */
.pagination .page-link::before,
.pagination .page-link::after {
display: none;
}
</style>
@endpush
@if($syncInterval > 0 && $folder === 'inbox')
@push('scripts')
<script>
let syncInterval = {{ $syncInterval * 60 * 1000 }};
let syncTimeout;
function autoSync() {
fetch('{{ url('email/sync/quick') }}', {
method: 'POST',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Content-Type': 'application/json'
}
}).then(() => {
console.log('Auto sync completed');
}).catch(() => {
console.log('Auto sync failed');
});
}
function startAutoSync() {
if (syncInterval > 0) {
syncTimeout = setInterval(autoSync, syncInterval);
}
}
function stopAutoSync() {
if (syncTimeout) {
clearInterval(syncTimeout);
}
}
document.addEventListener('DOMContentLoaded', function() {
startAutoSync();
document.addEventListener('visibilitychange', function() {
if (document.hidden) {
stopAutoSync();
} else {
startAutoSync();
}
});
});
</script>
@endpush
@endif
@section('scripts')
<script>
function toggleAll(checkbox) {
const checkboxes = document.querySelectorAll('.email-checkbox');
checkboxes.forEach(function(cb) {
cb.checked = checkbox.checked;
});
updateCount();
}
function updateCount() {
const checkboxes = document.querySelectorAll('.email-checkbox:checked');
document.getElementById('selectedCount').textContent = checkboxes.length + ' selezionati';
}
function executeBulkAction() {
const select = document.getElementById('bulkAction');
const action = select.value;
if (!action) {
alert('Seleziona un\'azione');
return;
}
if (action === 'empty_trash') {
if (!confirm('Sei sicuro di voler svuotare il cestino? Questa azione non è reversibile.')) {
return;
}
}
const checkboxes = document.querySelectorAll('.email-checkbox:checked');
if (action !== 'empty_trash' && checkboxes.length === 0) {
alert('Seleziona almeno una email');
return;
}
let ids = [];
if (action !== 'empty_trash') {
ids = Array.from(checkboxes).map(function(cb) {
return cb.value;
});
}
fetch('{{ route('email.bulk') }}', {
method: 'POST',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Content-Type': 'application/json'
},
body: JSON.stringify({ ids: ids, action: action })
}).then(function(response) {
return response.json();
}).then(function(data) {
if (data.success) {
// Reset checkboxes before reload to avoid ghost selection
document.querySelectorAll('.email-checkbox').forEach(function(cb) {
cb.checked = false;
});
document.getElementById('selectAll').checked = false;
updateCount();
window.location.href = window.location.href;
} else {
alert(data.message || 'Errore');
}
}).catch(function() {
alert('Errore');
});
}
function syncEmails() {
const btn = document.getElementById('syncBtn');
btn.disabled = true;
btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Sincronizzazione...';
fetch('{{ url('email/sync/quick') }}', {
method: 'POST',
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}',
'Content-Type': 'application/json'
}
}).then(function(response) {
return response.json();
}).then(function(data) {
if (data.success) {
location.reload();
} else {
alert(data.message || 'Errore durante la sincronizzazione');
btn.disabled = false;
btn.innerHTML = '<i class="fas fa-sync"></i> Ricevi/Invia';
}
}).catch(function(error) {
alert('Errore di connessione');
btn.disabled = false;
btn.innerHTML = '<i class="fas fa-sync"></i> Ricevi/Invia';
});
}
</script>
@endsection
+124
View File
@@ -0,0 +1,124 @@
@extends('layouts.adminlte')
@section('title', $message->subject ?: 'Email')
@section('page_title', 'Visualizza Email')
@section('content')
<div class="row">
<div class="col-md-3">
<div class="card card-primary">
<div class="card-body p-0">
<div class="list-group list-group-flush">
<a href="{{ route('email.compose') }}" class="list-group-item list-group-item-action">
<i class="fas fa-plus"></i> Nuova Email
</a>
@foreach($folders as $f)
<a href="{{ route('email.index', $f->type) }}"
class="list-group-item list-group-item-action {{ $folder === $f->type ? 'active' : '' }}">
<i class="fas {{ $f->icon }}"></i> {{ $f->name }}
</a>
@endforeach
</div>
</div>
</div>
</div>
<div class="col-md-9">
<div class="card card-primary card-outline">
<div class="card-header">
<h3 class="card-title">{{ $message->subject ?: '(senza oggetto)' }}</h3>
<div class="card-tools">
@if($message->is_starred)
<button class="btn btn-xs btn-warning" onclick="toggleStar({{ $message->id }})">
<i class="fas fa-star"></i>
</button>
@else
<button class="btn btn-xs btn-default" onclick="toggleStar({{ $message->id }})">
<i class="far fa-star"></i>
</button>
@endif
<a href="{{ route('email.compose', ['reply_to' => $message->id]) }}" class="btn btn-xs btn-default">
<i class="fas fa-reply"></i> Rispondi
</a>
<a href="{{ route('email.compose', ['forward' => $message->id]) }}" class="btn btn-xs btn-default">
<i class="fas fa-forward"></i> Inoltra
</a>
<form method="POST" action="{{ route('email.destroy', $message->id) }}" class="d-inline">
@csrf @method('DELETE')
<button type="submit" class="btn btn-xs btn-danger" onclick="return confirm('Sposta nel cestino?')">
<i class="fas fa-trash"></i>
</button>
</form>
</div>
</div>
<div class="card-body">
<div class="mailbox-read-info">
<h6>
<strong>Da:</strong> {{ $message->from_name }} &lt;{{ $message->from_email }}&gt;
<span class="mailbox-read-time float-right">
@if($message->received_at)
{{ $message->received_at->format('d/m/Y H:i') }}
@elseif($message->sent_at)
{{ $message->sent_at->format('d/m/Y H:i') }}
@endif
</span>
</h6>
<h6>
<strong>A:</strong> {{ $message->to_email }}
@if($message->cc)
<br><strong>CC:</strong> {{ $message->cc }}
@endif
</h6>
</div>
<hr>
<div class="mailbox-read-message">
{!! $message->body_for_display !!}
</div>
@if($message->attachments->count() > 0)
<hr>
<div class="mailbox-attachments">
<h4>Allegati:</h4>
<ul class="mailbox-attachments-links">
@foreach($message->attachments as $attachment)
<li>
<span class="mailbox-attachment-icon">
<i class="fas {{ $attachment->icon }}"></i>
</span>
<div class="mailbox-attachment-info">
<a href="{{ route('email.attachment.download', $attachment->id) }}" class="mailbox-attachment-name">
<i class="fas fa-paperclip"></i> {{ $attachment->filename }}
</a>
<span class="mailbox-attachment-size">
{{ number_format($attachment->size / 1024, 1) }} KB
</span>
@if(!$attachment->is_saved_to_documenti)
<form method="POST" action="{{ route('email.attachment.save', [$message->id, $attachment->id]) }}" class="d-inline">
@csrf
<button type="submit" class="btn btn-xs btn-success" onclick="return confirm('Salvare allegato nei documenti?')">
<i class="fas fa-save"></i> Salva in Documenti
</button>
</form>
@else
<span class="badge badge-success"><i class="fas fa-check"></i> Salvato</span>
@endif
</div>
</li>
@endforeach
</ul>
</div>
@endif
</div>
</div>
</div>
</div>
@endsection
@section('scripts')
<script>
function toggleStar(id) {
fetch('/email/' + id + '/star', {
method: 'POST',
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' }
}).then(() => location.reload());
}
</script>
@endsection