File "buscarActivo.php.bak"
Full Path: C:/wamp64/www/sistemas/activosFijos/buscarActivo.php.bak
File size: 15.94 KB
MIME-type: text/x-php
Charset: utf-8
<?php
include("../connection.php");
$con = connection();
// Verificar si se ha enviado el formulario de búsqueda
$filtro_numero_acta = isset($_GET['numero_acta']) ? $_GET['numero_acta'] : '';
$filtro_tipo = isset($_GET['tipo']) ? $_GET['tipo'] : '';
$filtro_equipo = isset($_GET['equipo']) ? $_GET['equipo'] : '';
$filtro_fecha_inicio = isset($_GET['fecha_inicio']) ? $_GET['fecha_inicio'] : '';
$filtro_fecha_fin = isset($_GET['fecha_fin']) ? $_GET['fecha_fin'] : '';
// Construir la consulta SQL con los filtros
$sql = "SELECT * FROM bajaActivos WHERE 1=1";
if (!empty($filtro_numero_acta)) {
$sql .= " AND numero_acta LIKE '%$filtro_numero_acta%'";
}
if (!empty($filtro_tipo)) {
$sql .= " AND tipo LIKE '%$filtro_tipo%'";
}
if (!empty($filtro_equipo)) {
$sql .= " AND equipo LIKE '%$filtro_equipo%'";
}
if (!empty($filtro_fecha_inicio) && !empty($filtro_fecha_fin)) {
$sql .= " AND fecha BETWEEN '$filtro_fecha_inicio' AND '$filtro_fecha_fin'";
}
$query = mysqli_query($con, $sql);
// Verificar si la consulta tuvo éxito
if (!$query) {
die('Error en la consulta SQL: ' . mysqli_error($con));
}
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Generar Reporte de Activos Fijos</title>
<link rel="icon" type="image/png" href="../img/icono1.png">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background-color: #f5f5f5;
}
.container {
max-width: 1200px;
margin: 0 auto;
background-color: white;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
/* Contenedor de filtros */
.filters-container {
background-color: #f8f9fa;
padding: 20px;
border-radius: 5px;
margin-bottom: 20px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
border: 1px solid #e0e0e0;
}
.filters-container h3 {
margin-top: 0;
margin-bottom: 15px;
color: #333;
border-bottom: 1px solid #ddd;
padding-bottom: 10px;
}
.filter-row {
display: flex;
flex-wrap: wrap;
gap: 15px;
align-items: flex-end;
}
.filter-group {
flex: 1;
min-width: 150px;
}
.filter-group label {
display: block;
margin-bottom: 5px;
font-weight: bold;
font-size: 14px;
color: #555;
}
.filter-group input[type="text"],
.filter-group input[type="date"] {
width: 100%;
padding: 8px 12px;
border: 1px solid #ddd;
border-radius: 4px;
box-sizing: border-box;
font-size: 14px;
background-color: white;
}
.date-range {
min-width: 250px;
}
.date-inputs {
display: flex;
align-items: center;
gap: 10px;
}
.date-inputs span {
font-size: 14px;
color: #666;
}
.submit-btn input[type="submit"] {
background-color: coral;
color: white;
border: none;
padding: 8px 20px;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
height: 36px;
white-space: nowrap;
transition: background-color 0.3s;
}
.submit-btn input[type="submit"]:hover {
background-color: #ff7f50;
}
/* Botones */
.button-container {
margin-bottom: 20px;
display: flex;
gap: 10px;
flex-wrap: wrap;
}
.button-container input[type="button"],
.button-container button {
padding: 8px 15px;
cursor: pointer;
background-color: coral;
color: white;
border: none;
border-radius: 4px;
transition: background-color 0.3s;
font-size: 14px;
}
.button-container input[type="button"]:hover,
.button-container button:hover {
background-color: #ff7f50;
}
.btn-pdf {
background-color: #d9534f !important;
}
.btn-pdf:hover {
background-color: #c9302c !important;
}
@media (max-width: 768px) {
.filter-row {
flex-direction: column;
}
.filter-group {
width: 100%;
}
}
/* Mensajes */
.no-results {
padding: 20px;
background-color: #f8d7da;
color: #721c24;
border-radius: 5px;
margin-top: 20px;
border: 1px solid #f5c6cb;
}
.info-message {
padding: 20px;
background-color: #d1ecf1;
color: #0c5460;
border-radius: 5px;
margin-top: 20px;
border: 1px solid #bee5eb;
}
/* Tabla */
.users-table {
width: 100%;
overflow-x: auto;
margin-top: 20px;
}
table.display {
width: 100%;
border-collapse: collapse;
margin-top: 15px;
}
table.display th, table.display td {
padding: 10px 12px;
text-align: left;
border: 1px solid #ddd;
}
table.display th {
background-color: #f2f2f2;
font-weight: bold;
}
table.display tr:nth-child(even) {
background-color: #f9f9f9;
}
table.display tr:hover {
background-color: #f1f1f1;
}
/* Imágenes */
table.display td img {
max-width: 100px;
max-height: 100px;
display: block;
cursor: pointer;
border: 1px solid #ddd;
border-radius: 4px;
}
/* Modal */
.modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.9);
}
.modal-content {
display: block;
margin: auto;
max-width: 90%;
max-height: 90%;
position: relative;
top: 50%;
transform: translateY(-50%);
}
.close {
position: absolute;
top: 15px;
right: 35px;
color: #f1f1f1;
font-size: 40px;
font-weight: bold;
cursor: pointer;
}
/* Footer */
.copyright {
text-align: center;
margin-top: 30px;
color: #666;
font-size: 14px;
padding-top: 20px;
border-top: 1px solid #eee;
}
/* Toast */
.toast {
position: fixed;
bottom: 20px;
right: 20px;
background-color: #4CAF50;
color: white;
padding: 12px 24px;
border-radius: 5px;
z-index: 1000;
display: none;
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
</style>
</head>
<body>
<div class="container">
<div class="button-container">
<input type="button" style ="background-color: #f94e40;" onclick="window.location.href='../index.php';" value="Menú Principal">
</div>
<div class="button-container">
<input type="button" value="Volver" onclick="window.location.href='../disponibles/subMenu.php';">
<input type="button" onclick="window.location.href='generarExcel.php';" value="Generar Excel">
<!-- Botón para generar PDF -->
<form method="post" action="pdf.php" style="display: inline;">
<input type="hidden" name="numero_acta" value="<?= htmlspecialchars($filtro_numero_acta) ?>">
<input type="hidden" name="tipo" value="<?= htmlspecialchars($filtro_tipo) ?>">
<input type="hidden" name="equipo" value="<?= htmlspecialchars($filtro_equipo) ?>">
<input type="hidden" name="fecha_inicio" value="<?= htmlspecialchars($filtro_fecha_inicio) ?>">
<input type="hidden" name="fecha_fin" value="<?= htmlspecialchars($filtro_fecha_fin) ?>">
<button type="submit" name="generar_pdf" class="btn-pdf">
<i class="fas fa-file-pdf"></i> Generar PDF
</button>
</form>
</div>
<div class="filters-container">
<h3>Filtrar Reporte</h3>
<form method="GET" action="">
<div class="filter-row">
<div class="filter-group">
<label for="numero_acta">numero_acta:</label>
<input type="text" name="numero_acta" id="numero_acta" value="<?= htmlspecialchars($filtro_numero_acta) ?>">
</div>
<div class="filter-group">
<label for="tipo">Tipo Equipo:</label>
<input type="text" name="tipo" id="tipo" value="<?= htmlspecialchars($filtro_tipo) ?>">
</div>
<div class="filter-group">
<label for="equipo">Equipo:</label>
<input type="text" name="equipo" id="equipo" value="<?= htmlspecialchars($filtro_equipo) ?>">
</div>
<div class="filter-group date-range">
<label>Rango de Fechas:</label>
<div class="date-inputs">
<input type="date" name="fecha_inicio" value="<?= htmlspecialchars($filtro_fecha_inicio) ?>">
<span>a</span>
<input type="date" name="fecha_fin" value="<?= htmlspecialchars($filtro_fecha_fin) ?>">
</div>
</div>
<div class="filter-group submit-btn">
<input type="submit" value="Filtrar" style="margin-left: 70px">
</div>
</div>
</form>
</div>
<?php if (isset($_GET['numero_acta']) || isset($_GET['tipo']) || isset($_GET['equipo']) || isset($_GET['fecha_inicio'])): ?>
<div class="users-table">
<?php if (mysqli_num_rows($query) > 0): ?>
<table class="display">
<thead>
<tr>
<th>Nombre</th>
<th>Cargo</th>
<th>Tipo Equipo</th>
<th>Motivo</th>
<th>Equipo</th>
<th>Referencia</th>
<th>numero_acta</th>
<th>Serial</th>
<th>Fecha Registro</th>
<th>Evidencia</th>
</tr>
</thead>
<tbody>
<?php
// Reiniciar el puntero del resultado para volver a recorrerlo
mysqli_data_seek($query, 0);
while ($row = mysqli_fetch_array($query)): ?>
<tr>
<td><?= htmlspecialchars($row['nombre']) ?></td>
<td><?= htmlspecialchars($row['cargo']) ?></td>
<td><?= htmlspecialchars($row['tipo']) ?></td>
<td><?= htmlspecialchars($row['motivo']) ?></td>
<td><?= htmlspecialchars($row['equipo']) ?></td>
<td><?= htmlspecialchars($row['referencia']) ?></td>
<td><?= htmlspecialchars($row['numero_acta']) ?></td>
<td><?= htmlspecialchars($row['serial']) ?></td>
<td><?= htmlspecialchars($row['fecha']) ?></td>
<td>
<?php if (!empty($row['evidencia'])): ?>
<img src="data:image/jpeg;base64,<?= base64_encode($row['evidencia']) ?>" width="100" height="100" style="cursor: pointer;" onclick="mostrarImagenGrande(this)">
<?php else: ?>
Sin evidencia
<?php endif; ?>
</td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
<?php else: ?>
<div class="no-results">
No se encontraron resultados con los filtros aplicados.
</div>
<?php endif; ?>
</div>
<?php else: ?>
<div class="info-message">
Utilice los filtros para generar un reporte específico.
</div>
<?php endif; ?>
<div class="copyright">
© Avicampo <?= date('Y') ?>
</div>
</div>
<!-- Toast notification -->
<div class="toast" id="toast"></div>
<!-- Modal para imágenes -->
<div id="imagenModal" class="modal">
<span class="close" onclick="document.getElementById('imagenModal').style.display='none'">×</span>
<img class="modal-content" id="imagenAmpliada">
</div>
<script>
function mostrarImagenGrande(elemento) {
var modal = document.getElementById('imagenModal');
var modalImg = document.getElementById("imagenAmpliada");
modal.style.display = "block";
modalImg.src = elemento.src;
}
// Cerrar modal al hacer clic fuera de la imagen
window.onclick = function(event) {
var modal = document.getElementById('imagenModal');
if (event.target == modal) {
modal.style.display = "none";
}
}
// Función para copiar texto al portapapeles
function copiarAlPortapapeles(texto) {
navigator.clipboard.writeText(texto).then(function() {
mostrarToast('Copiado al portapapeles');
}, function() {
mostrarToast('Error al copiar');
});
}
// Función para mostrar notificación toast
function mostrarToast(mensaje) {
var toast = document.getElementById('toast');
toast.textContent = mensaje;
toast.style.display = 'block';
setTimeout(function() {
toast.style.display = 'none';
}, 3000);
}
</script>
</body>
</html>