Files
glastree/storage/framework/views/770f7793fb2506075291f5825b49a758.php
T

371 lines
16 KiB
PHP
Executable File

<?php $__env->startSection('title', 'Email - ' . ucfirst($folder)); ?>
<?php $__env->startSection('page_title', 'Email'); ?>
<?php
$currentFolder = $folders->firstWhere('type', $folder);
?>
<?php $__env->startSection('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">
<?php $__currentLoopData = $folders; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $f): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<a href="<?php echo e(route('email.index', $f->type)); ?>"
class="btn btn-xs <?php echo e($folder === $f->type ? 'btn-primary' : 'btn-default'); ?>">
<i class="fas <?php echo e($f->icon); ?>"></i>
<?php echo e($f->name); ?>
<?php if($f->type === 'inbox' && $messages->where('is_read', false)->count() > 0): ?>
<span class="badge badge-light"><?php echo e($messages->where('is_read', false)->count()); ?></span>
<?php endif; ?>
</a>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</div>
<a href="<?php echo e(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>
<?php 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>
<?php else: ?>
<option value="empty_trash">Svuota cestino</option>
<?php 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'); ?>
<?php if($folder === 'sent' || $folder === 'inviate'): ?>
<a href="<?php echo e(request()->fullUrlWithQuery(['sort' => 'to_email', 'direction' => $sort === 'to_email' && $dir === 'asc' ? 'desc' : 'asc'])); ?>" class="text-dark text-decoration-none">
Destinatario <?php echo $sort === 'to_email' ? ($dir === 'asc' ? '▲' : '▼') : ''; ?>
</a>
<?php else: ?>
<a href="<?php echo e(request()->fullUrlWithQuery(['sort' => 'from_email', 'direction' => $sort === 'from_email' && $dir === 'asc' ? 'desc' : 'asc'])); ?>" class="text-dark text-decoration-none">
Mittente <?php echo $sort === 'from_email' ? ($dir === 'asc' ? '▲' : '▼') : ''; ?>
</a>
<?php endif; ?>
</th>
<th>
<a href="<?php echo e(request()->fullUrlWithQuery(['sort' => 'subject', 'direction' => $sort === 'subject' && $dir === 'asc' ? 'desc' : 'asc'])); ?>" class="text-dark text-decoration-none">
Oggetto <?php echo $sort === 'subject' ? ($dir === 'asc' ? '▲' : '▼') : ''; ?>
</a>
</th>
<th style="width: 120px;">
<a href="<?php echo e(request()->fullUrlWithQuery(['sort' => 'received_at', 'direction' => $sort === 'received_at' && $dir === 'asc' ? 'desc' : 'asc'])); ?>" class="text-dark text-decoration-none">
Data <?php echo $sort === 'received_at' ? ($dir === 'asc' ? '▲' : '▼') : ''; ?>
</a>
</th>
</tr>
</thead>
<tbody>
<?php $__empty_1 = true; $__currentLoopData = $messages; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $message): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
<tr class="<?php echo e($message->is_read ? '' : 'font-weight-bold'); ?>">
<td style="width: 30px;" onclick="event.stopPropagation()">
<input type="checkbox" class="email-checkbox" value="<?php echo e($message->id); ?>" onchange="updateCount()">
</td>
<td style="width: 30px;" onclick="event.stopPropagation(); window.location='<?php echo e(route('email.show', [$folder, $message->id])); ?>'">
<?php if($message->is_starred): ?>
<i class="fas fa-star text-warning"></i>
<?php endif; ?>
</td>
<td onclick="window.location='<?php echo e(route('email.show', [$folder, $message->id])); ?>'">
<?php echo e($message->is_sent ? 'A: ' . $message->to_email : ($message->from_name ?: $message->from_email)); ?>
</td>
<td onclick="window.location='<?php echo e(route('email.show', [$folder, $message->id])); ?>'">
<?php echo e($message->subject ?? '(senza oggetto)'); ?>
</td>
<td>
<?php if($message->received_at): ?>
<?php echo e($message->received_at->format('d/m/Y')); ?>
<?php elseif($message->sent_at): ?>
<?php echo e($message->sent_at->format('d/m/Y')); ?>
<?php endif; ?>
</td>
</tr>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
<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>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
<div class="card-footer d-flex justify-content-between align-items-center">
<div>
<form method="GET" class="form-inline" id="perPageForm">
<label class="mr-2 small">Righe per pagina:</label>
<select name="perPage" class="form-control form-control-sm" onchange="this.form.submit()" style="width: auto;">
<?php $__currentLoopData = [10, 20, 25, 50, 100]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $p): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<option value="<?php echo e($p); ?>" <?php echo e((int) request('perPage', 20) === $p ? 'selected' : ''); ?>><?php echo e($p); ?></option>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</select>
<?php $__currentLoopData = request()->except(['perPage', 'page']); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key => $value): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<?php if(is_array($value)): ?>
<?php $__currentLoopData = $value; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
<input type="hidden" name="<?php echo e($key); ?>[]" value="<?php echo e($v); ?>">
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
<?php else: ?>
<input type="hidden" name="<?php echo e($key); ?>" value="<?php echo e($value); ?>">
<?php endif; ?>
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</form>
</div>
<div>
<?php echo e($messages->links('vendor.pagination.simple-bootstrap-4')); ?>
</div>
</div>
</div>
<?php $__env->stopSection(); ?>
<?php $__env->startPush('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>
<?php $__env->stopPush(); ?>
<?php if($syncInterval > 0 && $folder === 'inbox'): ?>
<?php $__env->startPush('scripts'); ?>
<script>
let syncInterval = <?php echo e($syncInterval * 60 * 1000); ?>;
let syncTimeout;
function autoSync() {
fetch('<?php echo e(url('email/sync/quick')); ?>', {
method: 'POST',
headers: {
'X-CSRF-TOKEN': '<?php echo e(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>
<?php $__env->stopPush(); ?>
<?php endif; ?>
<?php $__env->startSection('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('<?php echo e(route('email.bulk')); ?>', {
method: 'POST',
headers: {
'X-CSRF-TOKEN': '<?php echo e(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('<?php echo e(url('email/sync/quick')); ?>', {
method: 'POST',
headers: {
'X-CSRF-TOKEN': '<?php echo e(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>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.adminlte', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /var/www/html/glastree/resources/views/email/index.blade.php ENDPATH**/ ?>