<?php
require_once("header.php");
require_once("left_sidebar.php");
if ($permessi_user_logged != "6923e6c01ef0afda823f8a4085890079"){
	echo "NON HAI I PERMESSI NECESSARI";
	exit;
}

?>
<link rel="stylesheet" href="vendors/datatables.net-bs4/dataTables.bootstrap4.css">
<link rel="stylesheet" href="vendors/jquery-toast-plugin/jquery.toast.min.css">

<style>/* Stili di base per la pagina */
.content-wrapper {
    background-color: #000000 !important;
    color: #ffffff !important;
}

/* Stili per la card principale */
.card {
    background: #0c161c !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.card-title {
    color: #00ffff !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 15px !important;
}

/* Stili per la tabella */
.table {
    color: #ffffff !important;
    background: #0c161c !important;
}

.table thead th {
    background: #000000 !important;
    color: #00ffff !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

.table td, .table th {
    border-color: rgba(255, 255, 255, 0.1) !important;
    padding: 12px !important;
}

/* Stili per i badge di stato */
.badge-outline-success {
    color: #00ffaa !important;
    border: 1px solid #00ffaa !important;
}

.badge-outline-warning {
    color: #ffaa00 !important;
    border: 1px solid #ffaa00 !important;
}

.badge-outline-danger {
    color: #ff3366 !important;
    border: 1px solid #ff3366 !important;
}

/* Stili per i modali */
.modal-content {
    background: #0c161c !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.modal-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

.modal-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* Stili per i form */
.form-control {
    background: rgba(255, 255, 255, 0.1) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: #ffffff !important;
}

.form-control:disabled {
    background: rgba(255, 255, 255, 0.05) !important;
    color: rgba(255, 255, 255, 0.5) !important;
}

/* Stili per i bottoni */
.btn-danger, .btn-success, .btn-primary, .btn-warning, .btn-info {
    background: linear-gradient(90deg, #00ffff, #ff00ff) !important;
    background-size: 200% 100% !important;
    border: none !important;
    color: white !important;
    font-weight: bold !important;
    animation: gradientAnimation 3s ease infinite !important;
    transition: all 0.3s ease !important;
}

.btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 0 10px rgba(0, 255, 255, 0.5) !important;
}

/* Stili per DataTables */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_processing,
.dataTables_wrapper .dataTables_paginate {
    color: #ffffff !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: #ffffff !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: linear-gradient(90deg, #00ffff, #ff00ff) !important;
    border: none !important;
    color: white !important;
}

/* Stili per le notifiche toast */
.jq-toast-wrap {
    background: #0c161c !important;
    color: #ffffff !important;
}

/* Animazione gradiente */
@keyframes gradientAnimation {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}
/* Stile per la sidebar sinistra */
.sidebar {
    background: black !important;
    border-right: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* Stile per i link della sidebar */
.sidebar .nav-item .nav-link {
    color: #ffffff !important;
    transition: all 0.3s ease !important;
}

.sidebar .nav-item .nav-link:hover {
    background: rgba(0, 255, 255, 0.1) !important;
    color: #00ffff !important;
}

/* Stile per l'icona e il testo del logo */
.sidebar .navbar-brand {
    background: #0c161c !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* Stile per le divisioni tra i menu */
.sidebar .nav-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.05) !important;
}

/* Stile per le icone nella sidebar */
.sidebar .nav-link i {
    color: #00ffff !important;
}

/* Stile per l'item attivo */
.sidebar .nav-item.active .nav-link {
    background: linear-gradient(90deg, #00ffff20, transparent) !important;
    color: #00ffff !important;
}

/* Stile per il testo del menu */
.nav-link span {
    color: #ffffff !important;
}

/* Hover effect per i link */
.nav-link:hover span {
    color: #00ffff !important;
}

/* Stile per il separatore */
.sidebar-divider {
    border-color: rgba(255, 255, 255, 0.1) !important;
}
.navbar .navbar-brand-wrapper {
    border-right: 0px solid #000000;
}
</style>
<div class="content-wrapper">
<!-------- INIZIO MODAL ELIMINA ------------->			
			<div class="modal fade" id="elimina_log" tabindex="-1" role="dialog" aria-labelledby="ModalLabel" style="display: none;" aria-hidden="true">
                <div class="modal-dialog" role="document">
					<form class="forms-sample " name="elimina_log_f" id="elimina_log_f">
						<div class="modal-content">
							<div class="modal-header bg-info text-white">
								<h5 class="modal-title" id="ModalLabel">Elimina Log</h5>
								<button type="button" id="chiudi_modal_elimina" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
							</div>
							<input type="hidden" name="azione" value="elimina_log">
							<div class="modal-body">
								<p style="text-align:justify">Sei sicuro di voler eliminare i log?</p>
								<div class="modal-footer">
									<button type="submit" class="btn btn-success">Elimina</button>
									<button type="button" class="btn btn-light" data-dismiss="modal">Annulla</button>
								</div>
							</div>
					</form>
						</div>
				</div>
			</div>
<!-------- FINE MODAL ELIMINA ------------->	
    <div class="card">
        <div class="card-body">
			<h4 class="card-title">Log Operazioni</h4>
			<div class="row">
			<button type="button" class="btn btn-danger btn-icon-text col-2" data-toggle="modal" data-target="#elimina_log" data-whatever="elimina_log"><i class="mdi mdi-delete-forever btn-icon-prepend"></i>Elimina Log</button><br><br>
			</div><br>
			<div class="row">
				<div class="col-12">
					<div class="table-responsive">
						<table id="client_list" class="table table-bordered">
							<thead>
								<tr>
									<th style="width:6%">#</th>
									<th style="width:20%">Username</th>
									<th style="width:10%">Indirizzo IP</th>
									<th style="width:10%">Data</th>
									<th style="width:50%">Descrizione</th>
								</tr>
							</thead>
							<tbody>
							</tbody>
						</table>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<script>


$( document ).ready(function() {	
	$( "#elimina_log_f" ).submit(function( e ) {  
		e.preventDefault();
		$.ajax({
			url: "operazioni_aj.php",
			type: "POST",
			data: $("#elimina_log_f").serialize(),
			success: function(data) {
				if (data =="OK") { 
					$("#chiudi_modal_elimina").click()
					NotificaSuccesso("Successo", "Log eliminati correttamente");
					client_list.ajax.reload();
				} else {
					NotificaErrore("Attenzione Errori", data);
				}				
			},
			error: function(data) {
				NotificaScriptNonDisponibile();
			}
		});
	}); 
	
	var client_list =  $('#client_list').DataTable({
			dom: 'lBfrtip',
				buttons: [
					{ extend: 'copy', className: 'btn btn-outline-danger', text: 'Copia' }, 
					{ extend: 'csv', className: 'btn btn-outline-danger', text: 'CSV' }, 
					{ extend: 'excel', className: 'btn btn-outline-danger', text: 'Excel' }, 
					{ extend: 'pdf',  className: 'btn btn-outline-danger', text: 'PDF' }, 
					{ extend: 'print', className: 'btn btn-outline-danger', text: 'Stampa' }, 
				],
			"order":  [ 0, "desc" ] ,
			"lengthMenu": [[15, 30, 50, 100 ], [15, 30, 50,100 ]],
			"pageLength": 15,
			"responsive": true,
			"autoWidth": false,
			"language": {
					"sEmptyTable":     "Nessun dato presente nella tabella",
					"sInfo":           "Vista da _START_ a _END_ di _TOTAL_ elementi",
					"sInfoEmpty":      "Vista da 0 a 0 di 0 elementi",
					"sInfoFiltered":   "(filtrati da _MAX_ elementi totali)",
					"sInfoPostFix":    "",
					"sInfoThousands":  ".",
					"sLengthMenu":     "Visualizza _MENU_ elementi",
					"sLoadingRecords": "Caricamento...",
					"sProcessing":     "Elaborazione...",
					"sSearch":         "Cerca:",
					"sZeroRecords":    "La ricerca non ha portato alcun risultato.",
					"oPaginate": {
						"sFirst":      "Inizio",
						"sPrevious":   "Precedente",
						"sNext":       "Successivo",
						"sLast":       "Fine"
					}, 
					"oAria": {
						"sSortAscending":  ": attiva per ordinare la colonna in ordine crescente",
						"sSortDescending": ": attiva per ordinare la colonna in ordine decrescente"
					}
			},

			"ajax": "lista_log_operazioni_json.php",
			"dataSrc": "data",
			"columns": [
					{ data: 0},
					{ data: 1},
					{ data: 2},
					{ data: 3},
					{ data: 4},

			]
	});
	
});

</script>
  <script src="vendors/jquery-toast-plugin/jquery.toast.min.js"></script>
  <script src="js/notifiche.js"></script>
  <script src="vendors/datatables.net/jquery.dataTables.js"></script>
  <script src="vendors/datatables.net-bs4/dataTables.bootstrap4.js"></script>
<script src="https://cdn.datatables.net/buttons/1.7.0/js/dataTables.buttons.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.3/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.53/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/buttons/1.7.0/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/1.7.0/js/buttons.print.min.js"></script>
<?php

require_once("footer.php");
?>