first commit
This commit is contained in:
Executable
+912
@@ -0,0 +1,912 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>{% block title %}App{% endblock %} · Autopol</title>
|
||||
<script>
|
||||
(function() {
|
||||
var theme = localStorage.getItem('nexus-theme') || 'light';
|
||||
document.documentElement.setAttribute('data-theme', theme);
|
||||
})();
|
||||
</script>
|
||||
<link rel="icon" type="image/svg+xml" href="{{ url_for('static', filename='car-front.svg') }}">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Space+Grotesk:wght@400;600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/animate.min.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='bootstrap-icons-1.13.1/bootstrap-icons.css') }}">
|
||||
|
||||
<style>
|
||||
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
|
||||
|
||||
/* original */
|
||||
:root {
|
||||
--bg: #0a111f;
|
||||
--surface: #101a2e;
|
||||
--nav-bg: #080e19;
|
||||
--border: #1d2b45;
|
||||
--accent: #3b82f6;
|
||||
--accent2: #06b6d4;
|
||||
--text: #e8f0ff;
|
||||
--muted: #71819c;
|
||||
--pill-bg: #17243a;
|
||||
--success: #22c7e8;
|
||||
--nav-w: 220px;
|
||||
--radius: 12px;
|
||||
}
|
||||
|
||||
[data-theme="light"] {
|
||||
--bg: #f5f6fa;
|
||||
--surface: #ffffff;
|
||||
--nav-bg: #ffffff;
|
||||
--border: #e3e6ef;
|
||||
--accent: #2563eb;
|
||||
--accent2: #4f8df7;
|
||||
--text: #1a1d29;
|
||||
--muted: #8a8fa3;
|
||||
--pill-bg: #eef0f8;
|
||||
--success: #159dcc;
|
||||
}
|
||||
|
||||
/* azul profundo + azul eléctrico + cyan */
|
||||
/* :root {
|
||||
--bg: #0d0f14;
|
||||
--surface: #13161e;
|
||||
--nav-bg: #0a0c10;
|
||||
--border: #1e2230;
|
||||
--accent: #3b82f6;
|
||||
--accent2: #06b6d4;
|
||||
--text: #e2e6f0;
|
||||
--muted: #5a607a;
|
||||
--pill-bg: #1a1f2e;
|
||||
--success: #34b9e8;
|
||||
--nav-w: 220px;
|
||||
--radius: 12px;
|
||||
}
|
||||
|
||||
[data-theme="light"] {
|
||||
--bg: #f4f8fd;
|
||||
--surface: #ffffff;
|
||||
--nav-bg: #ffffff;
|
||||
--border: #dce6f2;
|
||||
--accent: #2563eb;
|
||||
--accent2: #0891b2;
|
||||
--text: #172033;
|
||||
--muted: #718096;
|
||||
--pill-bg: #eaf2fc;
|
||||
--success: #0891b2;
|
||||
} */
|
||||
|
||||
/* Ambar + coral */
|
||||
/* :root {
|
||||
--bg: #12110f;
|
||||
--surface: #1b1916;
|
||||
--nav-bg: #0e0d0b;
|
||||
--border: #302b25;
|
||||
--accent: #f59e0b;
|
||||
--accent2: #f97316;
|
||||
--text: #f3eee6;
|
||||
--muted: #8e877d;
|
||||
--pill-bg: #28231d;
|
||||
--success: #34d399;
|
||||
--nav-w: 220px;
|
||||
--radius: 12px;
|
||||
}
|
||||
|
||||
[data-theme="light"] {
|
||||
--bg: #faf8f4;
|
||||
--surface: #ffffff;
|
||||
--nav-bg: #ffffff;
|
||||
--border: #e8e1d7;
|
||||
--accent: #d97706;
|
||||
--accent2: #ea580c;
|
||||
--text: #29251f;
|
||||
--muted: #8a8278;
|
||||
--pill-bg: #f6eee1;
|
||||
--success: #059669;
|
||||
} */
|
||||
|
||||
|
||||
body {
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 15px;
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
transition: background .2s ease, color .2s ease;
|
||||
}
|
||||
|
||||
.input-disabled-look {
|
||||
background-color: #f5f5f5;
|
||||
color: #6c757d;
|
||||
border: 1px solid #ced4da;
|
||||
cursor: not-allowed;
|
||||
opacity: 0.7;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
nav, .card, .msg-banner, .msg-form input, .nav-links a {
|
||||
transition: background .2s ease, border-color .2s ease, color .2s ease;
|
||||
}
|
||||
|
||||
/* ── NAVBAR ── */
|
||||
nav {
|
||||
width: var(--nav-w);
|
||||
background: var(--nav-bg);
|
||||
border-right: 1px solid var(--border);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
padding: 28px 16px 24px;
|
||||
position: fixed;
|
||||
top: 0; left: 0; bottom: 0;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.nav-logo {
|
||||
font-family: 'Space Grotesk', sans-serif;
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
color: var(--text);
|
||||
letter-spacing: -0.5px;
|
||||
padding: 0 8px 28px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 40px;
|
||||
}
|
||||
|
||||
.nav-logo span.dot {
|
||||
width: 8px; height: 8px;
|
||||
background: var(--accent);
|
||||
border-radius: 50%;
|
||||
display: inline-block;
|
||||
box-shadow: 0 0 8px var(--accent);
|
||||
}
|
||||
|
||||
.nav-section-label {
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 1.2px;
|
||||
text-transform: uppercase;
|
||||
color: var(--muted);
|
||||
padding: 0 8px 10px;
|
||||
}
|
||||
|
||||
.nav-links {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.nav-links a {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 8px;
|
||||
text-decoration: none;
|
||||
color: var(--muted);
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
transition: background 0.15s, color 0.15s;
|
||||
}
|
||||
.nav-links a:hover { background: var(--border); color: var(--text); }
|
||||
.nav-links a.active {
|
||||
background: linear-gradient(135deg, rgba(30, 144, 255, 0.08), rgba(0, 51, 204, 0.25));
|
||||
/* background: linear-gradient(135deg, rgba(92,110,248,.18), rgba(139,92,246,.1)); */
|
||||
/* background: linear-gradient(135deg, rgba(30, 144, 255, 0.25), rgba(0, 51, 204, 0.75)); */
|
||||
|
||||
color: var(--text);
|
||||
border: 1px solid rgba(92,110,248,.25);
|
||||
}
|
||||
.nav-links a .icon {
|
||||
width: 18px; height: 18px;
|
||||
opacity: .6;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.nav-links a.active .icon { opacity: 1; }
|
||||
|
||||
/* indicator bar */
|
||||
.nav-links a.active::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
left: 16px;
|
||||
width: 3px; height: 18px;
|
||||
background: var(--accent);
|
||||
border-radius: 2px;
|
||||
margin-left: -12px;
|
||||
}
|
||||
.nav-links a { position: relative; }
|
||||
|
||||
/* message badge in nav */
|
||||
.msg-badge {
|
||||
margin-left: auto;
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
padding: 2px 7px;
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.nav-footer {
|
||||
padding-top: 16px;
|
||||
border-top: 1px solid var(--border);
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
padding-left: 8px;
|
||||
}
|
||||
|
||||
/* ── THEME SWITCH ── */
|
||||
.theme-switch-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 8px 8px 16px;
|
||||
margin-bottom: 4px;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
.theme-switch-label {
|
||||
font-size: 12px;
|
||||
font-weight: 500;
|
||||
color: var(--muted);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
.theme-toggle {
|
||||
position: relative;
|
||||
width: 42px;
|
||||
height: 23px;
|
||||
background: var(--pill-bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 20px;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.theme-toggle::after {
|
||||
content: '☾';
|
||||
position: absolute;
|
||||
top: 1px; left: 1px;
|
||||
width: 17px; height: 17px;
|
||||
background: var(--accent);
|
||||
border-radius: 50%;
|
||||
transition: transform .25s cubic-bezier(.4,0,.2,1), background .2s;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 10px;
|
||||
line-height: 1;
|
||||
color: #fff;
|
||||
}
|
||||
[data-theme="light"] .theme-toggle::after {
|
||||
content: '☀';
|
||||
transform: translateX(19px);
|
||||
background: #f59e0b;
|
||||
}
|
||||
|
||||
/* ── MAIN CONTENT ── */
|
||||
main {
|
||||
margin-left: var(--nav-w);
|
||||
flex: 1;
|
||||
padding: 40px 48px;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.page-header {
|
||||
margin-bottom: 36px;
|
||||
}
|
||||
.page-eyebrow {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
letter-spacing: 1.4px;
|
||||
text-transform: uppercase;
|
||||
color: var(--accent);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.page-title {
|
||||
font-family: 'Space Grotesk', sans-serif;
|
||||
font-size: 28px;
|
||||
font-weight: 700;
|
||||
color: var(--text);
|
||||
letter-spacing: -0.5px;
|
||||
}
|
||||
.page-subtitle {
|
||||
margin-top: 6px;
|
||||
color: var(--muted);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
/* ── MENSAJES MÚLTIPLES ── */
|
||||
.msg-banner-wrap {
|
||||
background: linear-gradient(135deg, rgba(92,110,248,.1), rgba(139,92,246,.06));
|
||||
border: 1px solid rgba(92,110,248,.25);
|
||||
border-radius: var(--radius);
|
||||
margin-bottom: 24px;
|
||||
overflow: hidden;
|
||||
animation: slideIn .25s ease;
|
||||
}
|
||||
.msg-banner-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 16px;
|
||||
border-bottom: 1px solid rgba(92,110,248,.15);
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
letter-spacing: .7px;
|
||||
text-transform: uppercase;
|
||||
color: var(--accent);
|
||||
}
|
||||
.msg-clear-all {
|
||||
background: none;
|
||||
border: 1px solid rgba(92,110,248,.3);
|
||||
border-radius: 6px;
|
||||
color: var(--muted);
|
||||
font-size: 11px;
|
||||
padding: 3px 10px;
|
||||
cursor: pointer;
|
||||
transition: color .15s, border-color .15s;
|
||||
}
|
||||
.msg-clear-all:hover { color: var(--text); border-color: var(--muted); }
|
||||
.msg-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 10px 16px;
|
||||
border-bottom: 1px solid rgba(92,110,248,.08);
|
||||
gap: 12px;
|
||||
}
|
||||
.msg-item:last-child { border-bottom: none; }
|
||||
.msg-fecha {
|
||||
font-size: 10px;
|
||||
color: var(--muted);
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
.msg-texto { font-size: 13px; color: var(--text); }
|
||||
.msg-del-btn {
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--muted);
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
padding: 4px 8px;
|
||||
border-radius: 6px;
|
||||
flex-shrink: 0;
|
||||
transition: color .15s, background .15s;
|
||||
}
|
||||
.msg-del-btn:hover { color: #f87171; background: rgba(248,113,113,.1); }
|
||||
|
||||
|
||||
/* ── MESSAGE BANNER ── */
|
||||
.msg-banner {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
background: linear-gradient(135deg, rgba(92,110,248,.12), rgba(139,92,246,.08));
|
||||
border: 1px solid rgba(92,110,248,.3);
|
||||
border-radius: var(--radius);
|
||||
padding: 14px 18px;
|
||||
margin-bottom: 28px;
|
||||
animation: slideIn .25s ease;
|
||||
}
|
||||
@keyframes slideIn {
|
||||
from { opacity:0; transform: translateY(-6px); }
|
||||
to { opacity:1; transform: translateY(0); }
|
||||
}
|
||||
.msg-banner .label {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
letter-spacing: .8px;
|
||||
text-transform: uppercase;
|
||||
color: var(--accent);
|
||||
margin-bottom: 3px;
|
||||
}
|
||||
.msg-banner .text { color: var(--text); font-size: 14px; }
|
||||
.msg-banner a.clear-btn {
|
||||
color: var(--muted);
|
||||
font-size: 12px;
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
padding: 5px 10px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
transition: color .15s, border-color .15s;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.msg-banner a.clear-btn:hover { color: var(--text); border-color: var(--muted); }
|
||||
|
||||
/* ── MESSAGE FORM ── */
|
||||
.msg-form {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-top: 28px;
|
||||
max-width: 560px;
|
||||
}
|
||||
.msg-form input {
|
||||
flex: 1;
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
color: var(--text);
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 14px;
|
||||
padding: 10px 14px;
|
||||
outline: none;
|
||||
transition: border-color .15s;
|
||||
}
|
||||
.msg-form input::placeholder { color: var(--muted); }
|
||||
.msg-form input:focus { border-color: var(--accent); }
|
||||
.msg-form button {
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
padding: 10px 20px;
|
||||
cursor: pointer;
|
||||
transition: opacity .15s;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.msg-form button:hover { opacity: .85; }
|
||||
|
||||
/* ── CARDS ── */
|
||||
.card-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
|
||||
gap: 16px;
|
||||
margin-top: 28px;
|
||||
}
|
||||
.card {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 20px;
|
||||
transition: border-color .2s;
|
||||
}
|
||||
.card:hover { border-color: rgba(92,110,248,.35); }
|
||||
.card-icon {
|
||||
font-size: 22px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.card-title {
|
||||
font-family: 'Space Grotesk', sans-serif;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.card-desc { font-size: 13px; color: var(--muted); line-height: 1.5; }
|
||||
|
||||
/* ── SELECT / DROPDOWN ── */
|
||||
.select-wrap {
|
||||
position: relative;
|
||||
}
|
||||
.form-select {
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
cursor: pointer;
|
||||
padding-right: 38px;
|
||||
}
|
||||
.form-select option {
|
||||
background: var(--surface);
|
||||
color: var(--text);
|
||||
}
|
||||
.select-arrow {
|
||||
position: absolute;
|
||||
right: 12px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
color: var(--muted);
|
||||
pointer-events: none;
|
||||
transition: transform .2s;
|
||||
}
|
||||
.select-wrap:focus-within .select-arrow {
|
||||
transform: translateY(-50%) rotate(180deg);
|
||||
color: var(--accent);
|
||||
}
|
||||
.form-select:focus {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
{% block extra_css %}{% endblock %}
|
||||
|
||||
thead th {
|
||||
position: relative;
|
||||
transition: background .15s, color .15s;
|
||||
}
|
||||
thead th:hover {
|
||||
background: var(--border);
|
||||
color: var(--text);
|
||||
}
|
||||
thead th:hover .sort-icon {
|
||||
opacity: .7 !important;
|
||||
}
|
||||
|
||||
|
||||
/* ── CRUD TABLE ── */
|
||||
.crud-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 20px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.search-wrap {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
max-width: 360px;
|
||||
}
|
||||
|
||||
.search-wrap > svg:first-child {
|
||||
/* .search-wrap svg { */
|
||||
position: absolute;
|
||||
left: 12px; top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 16px; height: 16px;
|
||||
color: var(--muted);
|
||||
pointer-events: none;
|
||||
}
|
||||
.search-wrap input {
|
||||
width: 100%;
|
||||
padding: 9px 14px 9px 38px;
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
color: var(--text);
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 13px;
|
||||
outline: none;
|
||||
transition: border-color .15s;
|
||||
}
|
||||
.search-wrap input::placeholder { color: var(--muted); }
|
||||
.search-wrap input:focus { border-color: var(--accent); }
|
||||
|
||||
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 8px; font-family: 'Inter', sans-serif; font-size: 13px; font-weight: 600; cursor: pointer; border: none; text-decoration: none; transition: opacity .15s, background .15s; }
|
||||
.btn-primary { background: var(--accent); color: #fff; }
|
||||
.btn-primary:hover { opacity: .85; }
|
||||
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--border); }
|
||||
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
|
||||
.btn-danger { background: transparent; color: #f87171; border: 1px solid rgba(248,113,113,.35); }
|
||||
.btn-danger:hover { background: rgba(248,113,113,.08); }
|
||||
.btn-sm { padding: 5px 12px; font-size: 12px; }
|
||||
|
||||
.table-wrap {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
overflow: hidden;
|
||||
}
|
||||
table { width: 100%; border-collapse: collapse; }
|
||||
thead tr { background: var(--pill-bg); }
|
||||
th {
|
||||
padding: 12px 16px;
|
||||
text-align: left;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
letter-spacing: .8px;
|
||||
text-transform: uppercase;
|
||||
color: var(--muted);
|
||||
}
|
||||
td {
|
||||
padding: 13px 16px;
|
||||
font-size: 13px;
|
||||
border-top: 1px solid var(--border);
|
||||
color: var(--text);
|
||||
}
|
||||
tbody tr { transition: background .12s; padding-bottom: }
|
||||
tbody tr:hover { background: var(--pill-bg); }
|
||||
.td-id { font-family: monospace; color: var(--muted); font-size: 12px; }
|
||||
.td-actions { display: flex; gap: 8px; align-items: center; }
|
||||
.empty-state {
|
||||
text-align: center;
|
||||
padding: 48px 24px;
|
||||
color: var(--muted);
|
||||
font-size: 14px;
|
||||
}
|
||||
.empty-state svg { width: 40px; height: 40px; margin-bottom: 12px; opacity: .3; }
|
||||
|
||||
/* ── FORM ── */
|
||||
.form-card {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 32px;
|
||||
max-width: 1560px; /* aqui se establece el ancho de los formularios */
|
||||
}
|
||||
|
||||
|
||||
.form-group { margin-bottom: 5px; }
|
||||
.form-label {
|
||||
display: block;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
letter-spacing: .5px;
|
||||
color: var(--muted);
|
||||
margin-bottom: 7px;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
.form-input {
|
||||
width: 100%;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
color: var(--text);
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 14px;
|
||||
padding: 10px 14px;
|
||||
outline: none;
|
||||
transition: border-color .15s;
|
||||
}
|
||||
|
||||
.nav-submenu-toggle {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
padding: 10px 12px;
|
||||
border-radius: 8px;
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--muted);
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
cursor: pointer;
|
||||
transition: background .15s, color .15s;
|
||||
}
|
||||
.nav-submenu-toggle:hover,
|
||||
.nav-submenu-toggle.active { background: var(--border); color: var(--text); }
|
||||
.nav-submenu-items {
|
||||
display: none;
|
||||
flex-direction: column;
|
||||
gap: 2px;
|
||||
padding-left: 16px;
|
||||
margin-top: 2px;
|
||||
}
|
||||
.nav-submenu-items.open { display: flex; }
|
||||
.nav-submenu-items a {
|
||||
font-size: 13px;
|
||||
padding: 8px 12px;
|
||||
}
|
||||
|
||||
|
||||
.form-input::placeholder { color: var(--muted); }
|
||||
.form-input:focus { border-color: var(--accent); }
|
||||
.form-input:disabled { opacity: .5; cursor: not-allowed; }
|
||||
.form-actions { display: flex; gap: 10px; margin-top: 28px; }
|
||||
|
||||
/* ── FLASH ── */
|
||||
.flash { padding: 11px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 20px; animation: slideIn .2s ease; }
|
||||
.flash.ok { background: rgba(52,211,153,.12); border: 1px solid rgba(52,211,153,.3); color: #34d399; }
|
||||
.flash.error { background: rgba(248,113,113,.1); border: 1px solid rgba(248,113,113,.3); color: #f87171; }
|
||||
|
||||
@font-face {
|
||||
font-family: 'terminator';
|
||||
/* Usamos url_for para que Flask genere la ruta correcta en el servidor */
|
||||
src: url("{{ url_for('static', filename='fonts/terminator.ttf') }}") format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.nav-logo {
|
||||
font-family: 'terminator', sans-serif;
|
||||
font-size: 18px;
|
||||
color: rgb(8, 8, 111);
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<!-- class="animate__animated animate__backInLeft" -->
|
||||
|
||||
<nav id="navbar"
|
||||
{% if session.pop("animate_navbar", None) %}
|
||||
class="animate__animated animate__backInUp"
|
||||
{% endif %}>
|
||||
<div style="
|
||||
padding: 10px 5px 5px;
|
||||
margin-bottom: 20px;">
|
||||
<img
|
||||
id="siteLogo"
|
||||
src="{{ url_for('static', filename='img/logo.png') }}"
|
||||
alt="Logo"
|
||||
style="max-width:160px; width:100%; height:auto;">
|
||||
</div>
|
||||
|
||||
<div class="nav-logo" id="autopol">AUTOPOL</div>
|
||||
|
||||
|
||||
<div class="theme-switch-row">
|
||||
<span class="theme-switch-label">Tema</span>
|
||||
<button class="theme-toggle" id="themeToggle" aria-label="Cambiar tema claro/oscuro" type="button"></button>
|
||||
</div>
|
||||
|
||||
<div class="nav-section-label">Navegación</div>
|
||||
|
||||
<div class="nav-links">
|
||||
<a href="{{ url_for('index') }}" class="{% if page == 'inicio' %}active{% endif %}">
|
||||
<i class="bi bi-house" style="font-size: 1rem;"></i>
|
||||
<span style="font-family: 'terminator', sans-serif; font-size: 12px;">INICIO</span>
|
||||
<!-- {% if session.get('mensaje') and page == 'inicio' %}<span class="msg-badge">!</span>{% endif %} -->
|
||||
</a>
|
||||
|
||||
<a href="{{ url_for('vehiculos_list') }}" class="{% if page == 'vehiculos' %}active{% endif %}">
|
||||
<i class="bi bi-car-front" style="font-size: 1rem;"></i>
|
||||
<span style="font-family: 'terminator', sans-serif; font-size: 11px;">VEHÍCULOS</span>
|
||||
</a>
|
||||
|
||||
<a href="{{ url_for('itv_list') }}" class="{% if page == 'itv' %}active{% endif %}">
|
||||
<i class="bi bi-calendar-check" style="font-size: 1rem;"></i>
|
||||
<span style="font-family: 'terminator', sans-serif; font-size: 11px;">ITV</span>
|
||||
</a>
|
||||
|
||||
<a href="{{ url_for('viat_list') }}" class="{% if page == 'viat' %}active{% endif %}">
|
||||
<i class="bi bi-broadcast" style="font-size: 1rem;"></i>
|
||||
<span style="font-family: 'terminator', sans-serif; font-size: 11px;">VIA-T</span>
|
||||
</a>
|
||||
|
||||
<a href="{{ url_for('contacto') }}" class="{% if page == 'contacto' %}active{% endif %}">
|
||||
<i class="bi bi-person-vcard" style="font-size: 1rem;"></i>
|
||||
<span style="font-family: 'terminator', sans-serif; font-size: 11px;">CONTACTO</span>
|
||||
{% if session.get('mensaje') and page == 'contacto' %}<span class="msg-badge">!</span>{% endif %}
|
||||
</a>
|
||||
|
||||
<div class="nav-submenu">
|
||||
<hr style="opacity: 0.5;margin-bottom: 5px;">
|
||||
<button class="nav-submenu-toggle {% if page in ['poblaciones','unidades','tipo'] %}active{% endif %}"
|
||||
onclick="toggleSubmenu(this)">
|
||||
<i class="bi bi-database-check" style="font-size: 1rem;"></i>
|
||||
<span style="font-family: 'terminator', sans-serif; font-size: 10px;">CONFIGURACION</span>
|
||||
<svg class="chevron" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" style="margin-top:10px;margin-left:auto;transition:transform .2s">
|
||||
<polyline points="6 9 12 15 18 9"/>
|
||||
</svg>
|
||||
</button>
|
||||
<div class="nav-submenu-items {% if page in ['poblaciones','unidades','tipo'] %}open{% endif %}">
|
||||
<a href="{{ url_for('unidades_list') }}" class="{% if page == 'unidades' %}active{% endif %}">
|
||||
<i class="bi bi-building"></i>
|
||||
<span style="font-family: 'terminator', sans-serif; font-size: 10px;">UNIDADES</span>
|
||||
</a>
|
||||
<a href="{{ url_for('tipo_list') }}" class="{% if page == 'tipo' %}active{% endif %}">
|
||||
<i class="bi bi-bus-front"></i>
|
||||
<span style="font-family: 'terminator', sans-serif; font-size: 10px;">TIPO VEHÍCULO</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="nav-footer">
|
||||
{% if mensajes %}
|
||||
<a href="{{ url_for('index') }}" style="
|
||||
display:flex;align-items:center;gap:6px;
|
||||
color:var(--accent);text-decoration:none;font-size:12px;
|
||||
padding:6px 8px;border-radius:7px;transition:background .15s;
|
||||
margin-bottom:4px;"
|
||||
onmouseover="this.style.background='var(--border)'"
|
||||
onmouseout="this.style.background=''">
|
||||
💬 {{ mensajes|length }} mensaje{{ 's' if mensajes|length != 1 }} activo{{ 's' if mensajes|length != 1 }}
|
||||
</a>
|
||||
{% else %}
|
||||
<span style="font-size:12px;padding:6px 8px;display:block;">Sin mensajes</span>
|
||||
{% endif %}
|
||||
|
||||
|
||||
<a href="{{ url_for('logout') }}" style="
|
||||
display:flex;align-items:center;gap:8px;margin-top:12px;
|
||||
color:var(--muted);font-size:13px;text-decoration:none;
|
||||
padding:7px 8px;border-radius:7px;transition:background .15s,color .15s;
|
||||
" onmouseover="this.style.background='var(--border)';this.style.color='var(--text)'"
|
||||
onmouseout="this.style.background='';this.style.color='var(--muted)'">
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M9 21H5a2 2 0 01-2-2V5a2 2 0 012-2h4"/>
|
||||
<polyline points="16 17 21 12 16 7"/>
|
||||
<line x1="21" y1="12" x2="9" y2="12"/>
|
||||
</svg>
|
||||
Cerrar sesión
|
||||
</a>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main>
|
||||
|
||||
|
||||
{# Mensajes solo en página de inicio #}
|
||||
{% if page == 'inicio' %}
|
||||
{% if mensajes %}
|
||||
<div class="msg-banner-wrap">
|
||||
<div class="msg-banner-header">
|
||||
<div style="display:flex;align-items:center;gap:8px;">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"/>
|
||||
</svg>
|
||||
<span>{{ mensajes|length }} mensaje{{ 's' if mensajes|length != 1 }}</span>
|
||||
</div>
|
||||
<form method="POST" action="{{ url_for('mensajes_eliminar_todos') }}"
|
||||
onsubmit="return confirm('¿Eliminar todos los mensajes?')">
|
||||
<button type="submit" class="msg-clear-all">✕ Eliminar todos</button>
|
||||
</form>
|
||||
</div>
|
||||
{% for m in mensajes %}
|
||||
<div class="msg-item">
|
||||
<div>
|
||||
<div class="msg-fecha">{{ m['fecha'] | fecha_es_hora }}</div>
|
||||
<div class="msg-texto">{{ m['texto'] }}</div>
|
||||
</div>
|
||||
<form method="POST" action="{{ url_for('mensaje_eliminar', id=m['id']) }}">
|
||||
<button type="submit" class="msg-del-btn" title="Eliminar este mensaje">✕</button>
|
||||
</form>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% for category, message in messages %}
|
||||
<div class="flash {{ category }}">{{ message }}</div>
|
||||
{% endfor %}
|
||||
{% endwith %}
|
||||
|
||||
{% block content %}{% endblock %}
|
||||
|
||||
|
||||
|
||||
</main>
|
||||
|
||||
<script>
|
||||
var toggle = document.getElementById('themeToggle');
|
||||
var html = document.documentElement;
|
||||
var autopol = document.getElementById('autopol');
|
||||
|
||||
function applyTheme(theme) {
|
||||
html.setAttribute('data-theme', theme);
|
||||
localStorage.setItem('nexus-theme', theme);
|
||||
|
||||
var logo = document.getElementById('siteLogo');
|
||||
|
||||
// Verificamos que el elemento 'autopol' exista antes de cambiar su estilo
|
||||
if (autopol) {
|
||||
if (theme === 'dark') {
|
||||
logo.src = "{{ url_for('static', filename='img/logo_blanco.png') }}";
|
||||
autopol.style.color = 'rgb(128, 128, 128)'; // ¡Punto y coma fuera! (Gris)
|
||||
} else {
|
||||
logo.src = "{{ url_for('static', filename='img/logo.png') }}";
|
||||
autopol.style.color = 'rgb(8, 8, 111)'; // ¡Punto y coma fuera! (Azul oscuro)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Sync button state on load
|
||||
applyTheme(localStorage.getItem('nexus-theme') || 'light');
|
||||
|
||||
toggle.addEventListener('click', function() {
|
||||
var current = html.getAttribute('data-theme') === 'light' ? 'light' : 'dark';
|
||||
var next = current === 'light' ? 'dark' : 'light';
|
||||
applyTheme(next);
|
||||
});
|
||||
|
||||
function toggleSubmenu(btn) {
|
||||
var items = btn.nextElementSibling;
|
||||
items.classList.toggle('open');
|
||||
btn.querySelector('.chevron').style.transform =
|
||||
items.classList.contains('open') ? 'rotate(180deg)' : '';
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Executable
+91
@@ -0,0 +1,91 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}{{ 'Editar' if campus else 'Nuevo' }} Campus{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<div class="page-eyebrow">Campus</div>
|
||||
<div class="page-title">{{ 'Editar campus' if campus else 'Nuevo campus' }}</div>
|
||||
<div class="page-subtitle">
|
||||
{{ 'Modifica los datos del campus #' ~ campus['id'] if campus else 'Completa el formulario para registrar un nuevo campus.' }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-card">
|
||||
<form method="POST">
|
||||
|
||||
{% if campus %}
|
||||
<div class="form-group">
|
||||
<label class="form-label">ID</label>
|
||||
<input class="form-input" type="text" value="#{{ campus['id'] }}" disabled>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="nombre">Nombre *</label>
|
||||
<input
|
||||
class="form-input"
|
||||
type="text"
|
||||
id="nombre"
|
||||
name="nombre"
|
||||
placeholder="Ej. Campus Norte"
|
||||
value="{{ campus['nombre'] if campus else request.form.get('nombre','') }}"
|
||||
required
|
||||
autofocus
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="telefono">Teléfono *</label>
|
||||
<input
|
||||
class="form-input"
|
||||
type="tel"
|
||||
id="telefono"
|
||||
name="telefono"
|
||||
placeholder="Ej. +52 55 1234 5678"
|
||||
value="{{ campus['telefono'] if campus else request.form.get('telefono','') }}"
|
||||
required
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="email">Email *</label>
|
||||
<input
|
||||
class="form-input"
|
||||
type="email"
|
||||
id="email"
|
||||
name="email"
|
||||
placeholder="Ej. [email protected]"
|
||||
value="{{ campus['email'] if campus else request.form.get('email','') }}"
|
||||
required
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="categoria_id">Categoría</label>
|
||||
<div class="select-wrap">
|
||||
<select class="form-input form-select" id="categoria_id" name="categoria_id">
|
||||
<option value="">— Sin categoría —</option>
|
||||
{% for cat in categorias %}
|
||||
<option value="{{ cat['id'] }}"
|
||||
{% if campus and campus['categoria_id'] == cat['id'] %}selected
|
||||
{% elif request.form.get('categoria_id') == cat['id']|string %}selected
|
||||
{% endif %}>
|
||||
{{ cat['tipo'] }}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<svg class="select-arrow" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
|
||||
<polyline points="6 9 12 15 18 9"/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
{{ '💾 Guardar cambios' if campus else '✚ Crear campus' }}
|
||||
</button>
|
||||
<a href="{{ url_for('campus_list') }}" class="btn btn-ghost">Cancelar</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Executable
+120
@@ -0,0 +1,120 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Campus{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<div class="page-eyebrow">Base de datos</div>
|
||||
<div class="page-title">Campus</div>
|
||||
<div class="page-subtitle">Gestiona los registros de campus: búsqueda, alta, edición y baja.</div>
|
||||
</div>
|
||||
|
||||
<div class="crud-toolbar">
|
||||
<form method="GET" action="{{ url_for('campus_list') }}" class="search-wrap" id="searchForm">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>
|
||||
</svg>
|
||||
<input
|
||||
type="text"
|
||||
name="q"
|
||||
id="searchInput"
|
||||
placeholder="Buscar por ID, nombre, teléfono o email…"
|
||||
value="{{ q }}"
|
||||
autocomplete="off"
|
||||
>
|
||||
</form>
|
||||
<a href="{{ url_for('campus_nuevo') }}" class="btn btn-primary">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>
|
||||
Nuevo campus
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Nombre</th>
|
||||
<th>Teléfono</th>
|
||||
<th>Email</th>
|
||||
<th>Categoría</th>
|
||||
<th style="text-align:right">Acciones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbody">
|
||||
{% if rows %}
|
||||
{% for r in rows %}
|
||||
<tr data-id="{{ r['id'] }}">
|
||||
<td class="td-id">#{{ r['id'] }}</td>
|
||||
<td><strong>{{ r['nombre'] }}</strong></td>
|
||||
<td>{{ r['telefono'] }}</td>
|
||||
<td>{{ r['email'] }}</td>
|
||||
<td>{% if r['categoria'] %}<span style="background:rgba(92,110,248,.12);color:var(--accent);font-size:11px;font-weight:600;padding:3px 9px;border-radius:20px;border:1px solid rgba(92,110,248,.25)">{{ r['categoria'] }}</span>{% else %}<span style="color:var(--muted);font-size:12px">—</span>{% endif %}</td>
|
||||
|
||||
<!-- <td>{{ r['categoria'] }}</td> -->
|
||||
<td>
|
||||
<div class="td-actions" style="justify-content:flex-end">
|
||||
<a href="{{ url_for('campus_editar', id=r['id']) }}" class="btn btn-ghost btn-sm">Editar</a>
|
||||
<form method="POST" action="{{ url_for('campus_eliminar', id=r['id']) }}"
|
||||
onsubmit="return confirm('¿Eliminar «{{ r['nombre'] }}»? Esta acción no se puede deshacer.')">
|
||||
<button type="submit" class="btn btn-danger btn-sm">Eliminar</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
<div class="empty-state">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
||||
<circle cx="12" cy="12" r="10"/><line x1="8" y1="12" x2="16" y2="12"/>
|
||||
</svg>
|
||||
{% if q %}
|
||||
No se encontraron resultados para <strong>"{{ q }}"</strong>.
|
||||
<br><a href="{{ url_for('campus_list') }}" style="color:var(--accent);text-decoration:none">Ver todos</a>
|
||||
{% else %}
|
||||
No hay campus registrados aún.
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{% if rows %}
|
||||
<p id="counter" style="margin-top:12px;font-size:12px;color:var(--muted)">
|
||||
{{ rows|length }} registro{{ 's' if rows|length != 1 }}
|
||||
{% if q %} — filtrado por «{{ q }}»{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<script>
|
||||
var input = document.getElementById('searchInput');
|
||||
var tbody = document.getElementById('tbody');
|
||||
var counter = document.getElementById('counter');
|
||||
var timer;
|
||||
|
||||
/* Actualiza la tabla sin recargar la página (el foco no se pierde) */
|
||||
input.addEventListener('input', function() {
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(function() { buscar(input.value.trim()); }, 300);
|
||||
});
|
||||
|
||||
function buscar(q) {
|
||||
var url = '{{ url_for("campus_list") }}?q=' + encodeURIComponent(q) + '&solo_filas=1';
|
||||
fetch(url)
|
||||
.then(function(r) { return r.text(); })
|
||||
.then(function(html) {
|
||||
tbody.innerHTML = html;
|
||||
if (counter) {
|
||||
var filas = tbody.querySelectorAll('tr[data-id]').length;
|
||||
counter.textContent = filas + ' registro' + (filas !== 1 ? 's' : '')
|
||||
+ (q ? ' — filtrado por «' + q + '»' : '');
|
||||
counter.style.display = filas ? '' : 'none';
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
Executable
+35
@@ -0,0 +1,35 @@
|
||||
{% if rows %}
|
||||
{% for r in rows %}
|
||||
<tr data-id="{{ r['id'] }}">
|
||||
<td class="td-id">#{{ r['id'] }}</td>
|
||||
<td><strong>{{ r['nombre'] }}</strong></td>
|
||||
<td>{{ r['telefono'] }}</td>
|
||||
<td>{{ r['email'] }}</td>
|
||||
<td>{% if r['categoria'] %}<span style="background:rgba(92,110,248,.12);color:var(--accent);font-size:11px;font-weight:600;padding:3px 9px;border-radius:20px;border:1px solid rgba(92,110,248,.25)">{{ r['categoria'] }}</span>{% else %}<span style="color:var(--muted);font-size:12px">—</span>{% endif %}</td>
|
||||
<td>
|
||||
<div class="td-actions" style="justify-content:flex-end">
|
||||
<a href="/campus/{{ r['id'] }}/editar" class="btn btn-ghost btn-sm">Editar</a>
|
||||
<form method="POST" action="/campus/{{ r['id'] }}/eliminar"
|
||||
onsubmit="return confirm('¿Eliminar «{{ r['nombre'] }}»? Esta acción no se puede deshacer.')">
|
||||
<button type="submit" class="btn btn-danger btn-sm">Eliminar</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
<div class="empty-state">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
||||
<circle cx="12" cy="12" r="10"/><line x1="8" y1="12" x2="16" y2="12"/>
|
||||
</svg>
|
||||
{% if q %}
|
||||
No se encontraron resultados para <strong>"{{ q }}"</strong>.
|
||||
{% else %}
|
||||
No hay campus registrados aún.
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
Executable
+44
@@ -0,0 +1,44 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Contacto{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
||||
<style>
|
||||
.card-row {
|
||||
display: grid;
|
||||
grid-template-columns: 70px 1fr;
|
||||
gap: 10px;
|
||||
margin: 6px 0;
|
||||
}
|
||||
|
||||
.card-row .label {
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<div class="page-header">
|
||||
<div class="page-eyebrow">Comunicación</div>
|
||||
<div class="page-title"><i class="bi bi-person-vcard"></i> Contacto</div>
|
||||
</div>
|
||||
|
||||
<div class="card-grid">
|
||||
<div class="card" style="width:300px;">
|
||||
<div class="card-icon">✉️</div>
|
||||
<div class="card-title">Correo electrónico</div>
|
||||
<div class="card-row card-desc"><span class="label">Oficina</span><span>[email protected]</span></div>
|
||||
<div class="card-row card-desc"><span class="label">Taller</span><span>[email protected]</span></div>
|
||||
<div class="card-row card-desc"><span class="label">Jefatura</span><span>malaga.jefeautomocion.es</span></div>
|
||||
</div>
|
||||
|
||||
<div class="card" style="width:300px; margin-left:50px;">
|
||||
<div class="card-icon">📞</div>
|
||||
<div class="card-title">Teléfono</div>
|
||||
<div class="card-row card-desc"><span class="label">Oficina</span><span>952 046 317</span></div>
|
||||
<div class="card-row card-desc"><span class="label">Taller</span><span>952 046 221</span></div>
|
||||
<div class="card-row card-desc"><span class="label">Jefatura</span><span>952 046 453</span></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
Executable
+38
@@ -0,0 +1,38 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Explorar{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<div class="page-eyebrow">Descubrimiento</div>
|
||||
<div class="page-title">Explorar contenido</div>
|
||||
<div class="page-subtitle">Navega entre secciones: el mensaje persiste en todas ellas.</div>
|
||||
</div>
|
||||
|
||||
<div class="card-grid">
|
||||
<div class="card">
|
||||
<div class="card-icon">🗺️</div>
|
||||
<div class="card-title">Descubre</div>
|
||||
<div class="card-desc">Encuentra recursos, artículos y más dentro de la plataforma.</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-icon">📊</div>
|
||||
<div class="card-title">Estadísticas</div>
|
||||
<div class="card-desc">Visualiza datos y métricas de actividad reciente.</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-icon">🔖</div>
|
||||
<div class="card-title">Guardados</div>
|
||||
<div class="card-desc">Accede al contenido que marcaste como favorito.</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-icon">🧩</div>
|
||||
<div class="card-title">Integraciones</div>
|
||||
<div class="card-desc">Conecta herramientas externas con tu flujo de trabajo.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form class="msg-form" method="POST">
|
||||
<input type="text" name="mensaje" placeholder="Escribe un mensaje…">
|
||||
<button type="submit">Enviar</button>
|
||||
</form>
|
||||
{% endblock %}
|
||||
Executable
+37
@@ -0,0 +1,37 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Inicio{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<div class="page-eyebrow">Panel principal</div>
|
||||
<div class="page-title"><i class="bi bi-house"></i> Bienvenido a PyFleet</div>
|
||||
<div class="page-subtitle">Gestión de flota.</div>
|
||||
</div>
|
||||
|
||||
<div class="card-grid">
|
||||
<div class="card">
|
||||
<div class="card-icon">🏠</div>
|
||||
<div class="card-title">Página de Inicio</div>
|
||||
<div class="card-desc">Desde el menu lateral puedes navegar a las distintas secciones.</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-icon">🔔</div>
|
||||
<div class="card-title">Notificaciones</div>
|
||||
<div class="card-desc">El mensaje informativo que escribas aparecerá en cualquier sección.</div>
|
||||
<div class="card-desc">La app mantiene los mensajes activos hasta que sean eliminados.</div>
|
||||
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-icon">⚡</div>
|
||||
<div class="card-title">Escalable</div>
|
||||
<div class="card-desc">En la seccion CONFIGURACIÓN (Unidades - Tipo vehículo) podrás añadir o eliminar datos.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form class="msg-form" method="POST">
|
||||
<input type="text" name="mensaje" placeholder="Escribe un mensaje…" autofocus>
|
||||
<button type="submit">Enviar</button>
|
||||
</form>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
Executable
+457
@@ -0,0 +1,457 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}ITV{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
.filter-card {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
padding: 24px;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
.filter-row {
|
||||
display: flex;
|
||||
align-items: flex-end;
|
||||
gap: 16px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
.filter-group {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
.filter-group label {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
letter-spacing: .7px;
|
||||
text-transform: uppercase;
|
||||
color: var(--muted);
|
||||
}
|
||||
.filter-group input[type="date"] {
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
color: var(--text);
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 14px;
|
||||
padding: 9px 12px;
|
||||
outline: none;
|
||||
transition: border-color .15s;
|
||||
min-width: 160px;
|
||||
}
|
||||
.filter-group input[type="date"]:focus { border-color: var(--accent); }
|
||||
.itv-vencida td { color: #f87171 !important; }
|
||||
.itv-proxima td { color: #f59e0b !important; }
|
||||
.badge-vencida { background:rgba(248,113,113,.12); color:#f87171; font-size:10px; font-weight:700; padding:2px 8px; border-radius:20px; border:1px solid rgba(248,113,113,.3); white-space:nowrap; }
|
||||
.badge-proxima { background:rgba(245,158,11,.12); color:#f59e0b; font-size:10px; font-weight:700; padding:2px 8px; border-radius:20px; border:1px solid rgba(245,158,11,.3); white-space:nowrap; }
|
||||
.badge-ok { background:rgba(52,211,153,.12); color:#34d399; font-size:10px; font-weight:700; padding:2px 8px; border-radius:20px; border:1px solid rgba(52,211,153,.3); white-space:nowrap; }
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<div class="page-eyebrow">Revisiones</div>
|
||||
<div class="page-title"><i class="bi bi-calendar-check"></i> Control de ITV</div>
|
||||
<div class="page-subtitle">Filtra los vehículos por fecha de vencimiento de la ITV, población, unidad, tipo vehículo.</div>
|
||||
</div>
|
||||
|
||||
<div class="filter-card">
|
||||
<form method="GET" action="{{ url_for('itv_list') }}" id="filterForm">
|
||||
<div class="filter-row">
|
||||
<div class="filter-group">
|
||||
<label for="desde">Fecha desde</label>
|
||||
<input type="date" id="desde" name="desde" value="{{ desde }}">
|
||||
</div>
|
||||
<div class="filter-group">
|
||||
<label for="hasta">Fecha hasta</label>
|
||||
<input type="date" id="hasta" name="hasta" value="{{ hasta }}">
|
||||
</div>
|
||||
|
||||
<!-- <div class="filter-group">
|
||||
<label for="unidad_itv">Unidad asdf</label>
|
||||
<input type="text" id="unidad_itv" name="unidad_itv"
|
||||
value="{{ unidad_itv }}"
|
||||
placeholder="Filtrar por unidad…"
|
||||
style="background:var(--bg);border:1px solid var(--border);border-radius:8px;
|
||||
color:var(--text);font-family:'Inter',sans-serif;font-size:14px;
|
||||
padding:9px 12px;outline:none;transition:border-color .15s;min-width:200px;"
|
||||
onfocus="this.style.borderColor='var(--accent)'"
|
||||
onblur="this.style.borderColor='var(--border)'">
|
||||
</div> -->
|
||||
{# Campo de filtro - sustituye el anterior #}
|
||||
<div class="filter-group" >
|
||||
<label for="q_itv">Población, Unidad, Tipo vehículo</label>
|
||||
<div style="position:relative;">
|
||||
<input type="text" id="q_itv" name="q_itv"
|
||||
value="{{ q_itv }}"
|
||||
placeholder="Buscar, palabras separadas por coma"
|
||||
style="background:var(--bg);border:1px solid var(--border);border-radius:8px;
|
||||
color:var(--text);font-family:'Inter',sans-serif;font-size:14px;
|
||||
padding:9px 12px;outline:none;transition:border-color .15s;min-width:280px;"
|
||||
onfocus="this.style.borderColor='var(--accent)'"
|
||||
onblur="this.style.borderColor='var(--border)'">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>
|
||||
</svg>
|
||||
Buscar
|
||||
</button>
|
||||
|
||||
|
||||
{# Botón limpiar #}
|
||||
{% if desde or hasta or q_itv %}
|
||||
<a href="{{ url_for('itv_list') }}" class="btn btn-ghost">✕ Limpiar</a>
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
{% if buscado and rows %}
|
||||
<div style="margin-left:auto;display:flex;gap:8px;">
|
||||
<a href="{{ url_for('itv_exportar', desde=desde, hasta=hasta, q_itv=q_itv) }}"
|
||||
class="btn btn-ghost" title="Exportar a Excel">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/>
|
||||
<polyline points="14 2 14 8 20 8"/>
|
||||
<line x1="12" y1="18" x2="12" y2="12"/>
|
||||
<line x1="9" y1="15" x2="12" y2="18"/><line x1="15" y1="15" x2="12" y2="18"/>
|
||||
</svg>
|
||||
Excel
|
||||
</a>
|
||||
<button type="button" class="btn btn-ghost" id="btnPDF" title="Imprimir PDF">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<polyline points="6 9 6 2 18 2 18 9"/>
|
||||
<path d="M6 18H4a2 2 0 01-2-2v-5a2 2 0 012-2h16a2 2 0 012 2v5a2 2 0 01-2 2h-2"/>
|
||||
<rect x="6" y="14" width="12" height="8"/>
|
||||
</svg>
|
||||
Imprimir - PDF
|
||||
</button>
|
||||
<button type="button" class="btn btn-ghost" id="btnCopiar" title="Copiar al portapapeles">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<rect x="9" y="9" width="13" height="13" rx="2"/>
|
||||
<path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/>
|
||||
</svg>
|
||||
Copiar
|
||||
</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% if not buscado %}
|
||||
<div class="empty-state" style="padding:60px 24px;">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"
|
||||
style="width:48px;height:48px;margin-bottom:16px;opacity:.3">
|
||||
<rect x="3" y="4" width="18" height="18" rx="2"/>
|
||||
<line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/>
|
||||
<line x1="3" y1="10" x2="21" y2="10"/><path d="M9 16l2 2 4-4"/>
|
||||
</svg>
|
||||
<p style="color:var(--muted);font-size:14px;">Selecciona un rango de fechas y pulsa Buscar.</p>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{% elif rows %}
|
||||
|
||||
<p style="margin-top:12px;margin-bottom:10px;font-size:12px;color:var(--muted)">
|
||||
{{ rows|length }} vehículo{{ 's' if rows|length != 1 }}
|
||||
{% if desde and hasta %} con ITV entre {{ desde | fecha_es}} y {{ hasta | fecha_es }}
|
||||
{% elif desde %} con ITV desde {{ desde | fecha_es}}
|
||||
{% elif hasta %} con ITV hasta {{ hasta | fecha_es}}{% endif %}
|
||||
{% if unidad %} · unidad_itv: <strong>{{ unidad_itv }}</strong>{% endif %}
|
||||
</p>
|
||||
|
||||
<div class="table-wrap">
|
||||
<table id="tablaITV">
|
||||
<thead>
|
||||
<tr>
|
||||
<th hidden>ID</th>
|
||||
<th>M. Oficial</th>
|
||||
<th>M. Reservada</th>
|
||||
<th>Marca</th>
|
||||
<th>Modelo</th>
|
||||
<th>Tipo</th>
|
||||
<th>Poblacion</th>
|
||||
<th>Unidad</th>
|
||||
<th>Fecha ITV</th>
|
||||
<th>Estado</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% set hoy = now %}
|
||||
{% for r in rows %}
|
||||
{% set itv_str = r['itv'][:10] if r['itv'] else '' %}
|
||||
<tr onclick="abrirVehiculo({{ r['id'] }})"
|
||||
style="cursor:pointer;"
|
||||
onmouseover="this.style.background='var(--pill-bg)'"
|
||||
onmouseout="this.style.background=''">
|
||||
<td hidden class="td-id">#{{ r['id'] }}</td>
|
||||
<td>{{ r['m_oficial'] or '—' }}</td>
|
||||
<td>{{ r['m_reservada'] or '—' }}</td>
|
||||
<td><strong>{{ r['marca'] or '—' }}</strong></td>
|
||||
<td>{{ r['modelo'] or '—' }}</td>
|
||||
<td>{{ r['tipo'] or '—' }}</td>
|
||||
<td>{{ r['poblacion'] or '—' }}</td>
|
||||
<td>{{ r['unidad'] or '—' }}</td>
|
||||
<td style="white-space:nowrap;font-family:monospace">{{ itv_str | fecha_es}}</td>
|
||||
<td id="estado-{{ r['id'] }}" data-itv="{{ itv_str }}"></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{% else %}
|
||||
<div class="empty-state" style="padding:48px 24px;">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"
|
||||
style="width:40px;height:40px;margin-bottom:12px;opacity:.3">
|
||||
<circle cx="12" cy="12" r="10"/><line x1="8" y1="12" x2="16" y2="12"/>
|
||||
</svg>
|
||||
<p style="color:var(--muted);font-size:14px;">
|
||||
No se encontraron vehículos con ITV en ese rango de fechas.
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
function abrirVehiculo(id) {
|
||||
var desde = document.getElementById('desde').value;
|
||||
var hasta = document.getElementById('hasta').value;
|
||||
var qItv = document.getElementById('q_itv').value;
|
||||
window.location = '/vehiculos/' + id + '/editar'
|
||||
+ '?desde=' + encodeURIComponent(desde)
|
||||
+ '&hasta=' + encodeURIComponent(hasta)
|
||||
+ '&q_itv=' + encodeURIComponent(qItv);
|
||||
}
|
||||
|
||||
|
||||
/* ── Estado ITV según fecha ── */
|
||||
var hoy = new Date();
|
||||
hoy.setHours(0,0,0,0);
|
||||
var treintaDias = new Date(hoy); treintaDias.setDate(hoy.getDate() + 30);
|
||||
|
||||
|
||||
document.querySelectorAll('[data-itv]').forEach(function(td) {
|
||||
var itv = td.getAttribute('data-itv');
|
||||
if (!itv) return;
|
||||
var fecha = new Date(itv);
|
||||
var tr = td.closest('tr');
|
||||
if (fecha < hoy) {
|
||||
td.innerHTML = '<span class="badge-vencida">Vencida</span>';
|
||||
tr.classList.add('itv-vencida');
|
||||
} else if (fecha <= treintaDias) {
|
||||
td.innerHTML = '<span class="badge-proxima">Próxima</span>';
|
||||
tr.classList.add('itv-proxima');
|
||||
} else {
|
||||
td.innerHTML = '<span class="badge-ok">Al día</span>';
|
||||
}
|
||||
});
|
||||
|
||||
/* ── PDF ── */
|
||||
document.getElementById('btnPDF').addEventListener('click', function() {
|
||||
|
||||
var desde = '{{ desde }}', hasta = '{{ hasta }}';
|
||||
var titulo = 'Control ITV' + (desde ? ' — Desde: ' + desde : '') + (hasta ? ' Hasta: ' + hasta : '');
|
||||
var fecha = new Date().toLocaleDateString('es-ES');
|
||||
var heads = ['M. Oficial','M. Reservada','Marca','Modelo','Tipo','Poblacion',"Unidad",'Fecha ITV','Estado'];
|
||||
var filas = '';
|
||||
|
||||
document.querySelectorAll('#tablaITV tbody tr').forEach(function(tr) {
|
||||
filas += '<tr>';
|
||||
var celdas = tr.querySelectorAll('td');
|
||||
// Empezar desde índice 1 para saltar el ID (índice 0)
|
||||
for (var i = 1; i < celdas.length; i++) {
|
||||
filas += '<td>' + celdas[i].innerText.trim() + '</td>';
|
||||
}
|
||||
filas += '</tr>';
|
||||
});
|
||||
|
||||
var html = `<!DOCTYPE html><html><head><meta charset="UTF-8"><title>${titulo}</title>
|
||||
<style>
|
||||
body{font-family:Arial,sans-serif;font-size:10px;color:#1a1d29;margin:20px}
|
||||
h2{font-size:14px;margin-bottom:4px}.meta{font-size:9px;color:#666;margin-bottom:14px}
|
||||
table{width:100%;border-collapse:collapse}
|
||||
th{background:#5c6ef8;color:#fff;padding:6px 7px;text-align:left;font-size:9px}
|
||||
td{padding:5px 7px;border-bottom:1px solid #e3e6ef;font-size:9px}
|
||||
tr:nth-child(even) td{background:#eef0f8}
|
||||
.v{color:#ef4444;font-weight:700}.p{color:#d97706;font-weight:700}.o{color:#059669;font-weight:700}
|
||||
@media print{body{margin:10px}}
|
||||
</style></head><body>
|
||||
<h2>${titulo}</h2>
|
||||
<div class="meta">Generado el ${fecha} · ${document.querySelectorAll('#tablaITV tbody tr').length} vehículos</div>
|
||||
<table><thead><tr>${heads.map(h=>'<th>'+h+'</th>').join('')}</tr></thead>
|
||||
<tbody>${filas}</tbody></table></body></html>`;
|
||||
var win = window.open('','_blank','width=1000,height=700');
|
||||
win.document.write(html); win.document.close(); win.focus(); win.print(); win.close();
|
||||
});
|
||||
|
||||
// COPIAR
|
||||
document.getElementById('btnCopiar') && document.getElementById('btnCopiar').addEventListener('click', function() {
|
||||
var btn = this;
|
||||
var heads = ['M. Oficial','M. Reservada','Marca','Modelo','Tipo','Poblacion ','Unidad','Fecha ITV','Estado'];
|
||||
var lineas = [heads.join('\t')];
|
||||
|
||||
|
||||
document.querySelectorAll('#tablaITV tbody tr').forEach(function(tr) {
|
||||
var celdas = tr.querySelectorAll('td');
|
||||
var fila = [];
|
||||
// Empezar desde índice 1 para saltar el ID
|
||||
for (var i = 1; i < celdas.length; i++) {
|
||||
fila.push(celdas[i].innerText.trim());
|
||||
}
|
||||
lineas.push(fila.join('\t'));
|
||||
});
|
||||
|
||||
var texto = lineas.join('\n');
|
||||
|
||||
if (!texto.trim() || lineas.length <= 1) {
|
||||
alert('No hay datos para copiar.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(texto)
|
||||
.then(function() { mostrarCopiado(btn); })
|
||||
.catch(function() { copiarFallback(texto, btn); });
|
||||
} else {
|
||||
copiarFallback(texto, btn);
|
||||
}
|
||||
});
|
||||
|
||||
function copiarFallback(texto, btn) {
|
||||
var ta = document.createElement('textarea');
|
||||
ta.value = texto;
|
||||
ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;';
|
||||
document.body.appendChild(ta);
|
||||
ta.focus();
|
||||
ta.select();
|
||||
ta.setSelectionRange(0, 99999);
|
||||
var ok = false;
|
||||
try { ok = document.execCommand('copy'); } catch(e) { ok = false; }
|
||||
document.body.removeChild(ta);
|
||||
if (ok) {
|
||||
mostrarCopiado(btn);
|
||||
} else {
|
||||
alert('No se pudo copiar automáticamente.\nSelecciona el texto manualmente con Ctrl+A y Ctrl+C.');
|
||||
}
|
||||
}
|
||||
|
||||
function mostrarCopiado(btn) {
|
||||
var orig = btn.innerHTML;
|
||||
btn.innerHTML = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polyline points="20 6 9 17 4 12"/></svg> Copiado';
|
||||
btn.style.color = 'var(--success)';
|
||||
btn.style.borderColor = 'var(--success)';
|
||||
setTimeout(function() {
|
||||
btn.innerHTML = orig;
|
||||
btn.style.color = '';
|
||||
btn.style.borderColor = '';
|
||||
}, 2000);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
/* ── ORDENACIÓN POR COLUMNAS ── */
|
||||
(function() {
|
||||
var estado = { col: -1, asc: true };
|
||||
|
||||
document.querySelectorAll('thead th').forEach(function(th, idx) {
|
||||
// No ordenar la última columna (acciones/estado)
|
||||
th.style.cursor = 'pointer';
|
||||
th.style.userSelect = 'none';
|
||||
th.title = 'Pulsa para ordenar';
|
||||
|
||||
// Añadir icono de orden
|
||||
var icon = document.createElement('span');
|
||||
icon.style.cssText = 'margin-left:5px;opacity:.3;font-size:10px;';
|
||||
icon.textContent = '⇅';
|
||||
icon.className = 'sort-icon';
|
||||
th.appendChild(icon);
|
||||
|
||||
th.addEventListener('click', function() {
|
||||
var tbody = document.querySelector('tbody');
|
||||
var filas = Array.from(tbody.querySelectorAll('tr[data-id], tr[onclick]'));
|
||||
|
||||
if (!filas.length) return;
|
||||
|
||||
var mismaCol = estado.col === idx;
|
||||
estado.asc = mismaCol ? !estado.asc : true;
|
||||
estado.col = idx;
|
||||
|
||||
// Actualizar iconos
|
||||
document.querySelectorAll('.sort-icon').forEach(function(ic) {
|
||||
ic.textContent = '⇅';
|
||||
ic.style.opacity = '.3';
|
||||
});
|
||||
icon.textContent = estado.asc ? '↑' : '↓';
|
||||
icon.style.opacity = '1';
|
||||
icon.style.color = 'var(--accent)';
|
||||
|
||||
filas.sort(function(a, b) {
|
||||
var celdaA = a.querySelectorAll('td')[idx];
|
||||
var celdaB = b.querySelectorAll('td')[idx];
|
||||
if (!celdaA || !celdaB) return 0;
|
||||
|
||||
var valA = celdaA.innerText.trim().toLowerCase();
|
||||
var valB = celdaB.innerText.trim().toLowerCase();
|
||||
|
||||
// Detectar si es número
|
||||
var numA = parseFloat(valA.replace(/[^0-9.-]/g, ''));
|
||||
var numB = parseFloat(valB.replace(/[^0-9.-]/g, ''));
|
||||
var esNumero = !isNaN(numA) && !isNaN(numB);
|
||||
|
||||
// Detectar si es fecha (formato YYYY-MM-DD o DD-MM-YYYY)
|
||||
var fechaRegex = /^\d{2}[-\/]\d{2}[-\/]\d{4}$|^\d{4}[-\/]\d{2}[-\/]\d{2}$/;
|
||||
var esFecha = fechaRegex.test(celdaA.innerText.trim());
|
||||
|
||||
var resultado;
|
||||
if (esNumero) {
|
||||
resultado = numA - numB;
|
||||
} else if (esFecha) {
|
||||
// Normalizar DD-MM-YYYY a YYYY-MM-DD para comparar
|
||||
var normA = valA.replace(/(\d{2})-(\d{2})-(\d{4})/, '$3-$2-$1');
|
||||
var normB = valB.replace(/(\d{2})-(\d{2})-(\d{4})/, '$3-$2-$1');
|
||||
resultado = normA.localeCompare(normB);
|
||||
} else {
|
||||
resultado = valA.localeCompare(valB, 'es');
|
||||
}
|
||||
|
||||
return estado.asc ? resultado : -resultado;
|
||||
});
|
||||
|
||||
// Reinsertar filas ordenadas
|
||||
filas.forEach(function(fila) { tbody.appendChild(fila); });
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
<!-- /* ── COPIAR funciona en localhost y https ── */
|
||||
document.getElementById('btnCopiar') && document.getElementById('btnCopiar').addEventListener('click', function() {
|
||||
var btn = this;
|
||||
var heads = ['ID','M. Oficial','M. Civil','Marca','Modelo','Denominación','Tipo','Departamento','Fecha ITV','Estado'];
|
||||
var lineas = [heads.join('\t')];
|
||||
document.querySelectorAll('#tablaITV tbody tr').forEach(function(tr) {
|
||||
var fila = [];
|
||||
tr.querySelectorAll('td').forEach(function(td) { fila.push(td.innerText.trim()); });
|
||||
lineas.push(fila.join('\t'));
|
||||
});
|
||||
navigator.clipboard.writeText(lineas.join('\n')).then(function() {
|
||||
var orig = btn.innerHTML;
|
||||
btn.innerHTML = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polyline points="20 6 9 17 4 12"/></svg> Copiado';
|
||||
btn.style.color = 'var(--success)'; btn.style.borderColor = 'var(--success)';
|
||||
setTimeout(function(){ btn.innerHTML = orig; btn.style.color=''; btn.style.borderColor=''; }, 2000);
|
||||
});
|
||||
});
|
||||
Executable
+326
@@ -0,0 +1,326 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>Acceso · Autopol</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Space+Grotesk:wght@600;700&display=swap" rel="stylesheet">
|
||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/animate.min.css') }}">
|
||||
<script>
|
||||
(function() {
|
||||
var t = localStorage.getItem('nexus-theme') || 'light';
|
||||
document.documentElement.setAttribute('data-theme', t);
|
||||
})();
|
||||
</script>
|
||||
<style>
|
||||
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
|
||||
|
||||
:root {
|
||||
--bg: #f5f6fa;
|
||||
--surface: #ffffff;
|
||||
--border: #e3e6ef;
|
||||
--accent: #2563eb;
|
||||
--text: #1a1d29;
|
||||
--muted: #8a8fa3;
|
||||
--error-bg: rgba(248,113,113,.1);
|
||||
--error-brd: rgba(248,113,113,.35);
|
||||
--error-txt: #ef4444;
|
||||
}
|
||||
[data-theme="dark"] {
|
||||
--bg: #0d0f14;
|
||||
--surface: #13161e;
|
||||
--border: #1e2230;
|
||||
--text: #e2e6f0;
|
||||
--muted: #5a607a;
|
||||
}
|
||||
|
||||
body {
|
||||
background: var(--bg);
|
||||
color: var(--text);
|
||||
font-family: 'Inter', sans-serif;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 24px;
|
||||
transition: background .2s, color .2s;
|
||||
}
|
||||
|
||||
.login-wrap {
|
||||
width: 100%;
|
||||
max-width: 380px;
|
||||
}
|
||||
|
||||
.login-logo {
|
||||
text-align: center;
|
||||
margin-bottom: 36px;
|
||||
}
|
||||
.login-logo .dot-row {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.login-logo .dot {
|
||||
width: 10px; height: 10px;
|
||||
border-radius: 50%;
|
||||
background: var(--accent);
|
||||
}
|
||||
.login-logo .dot:nth-child(2) { opacity: .5; transform: scale(.8); }
|
||||
.login-logo .dot:nth-child(3) { opacity: .25; transform: scale(.6); }
|
||||
.login-logo h1 {
|
||||
font-family: 'Space Grotesk', sans-serif;
|
||||
font-size: 26px;
|
||||
font-weight: 700;
|
||||
letter-spacing: -0.5px;
|
||||
}
|
||||
.login-logo p {
|
||||
margin-top: 6px;
|
||||
font-size: 13px;
|
||||
color: var(--muted);
|
||||
}
|
||||
|
||||
.login-card {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 14px;
|
||||
padding: 32px;
|
||||
}
|
||||
|
||||
.field-label {
|
||||
display: block;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
letter-spacing: .7px;
|
||||
text-transform: uppercase;
|
||||
color: var(--muted);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.pwd-wrap {
|
||||
position: relative;
|
||||
}
|
||||
.pwd-wrap input {
|
||||
width: 100%;
|
||||
padding: 11px 42px 11px 14px;
|
||||
background: var(--bg);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
color: var(--text);
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 15px;
|
||||
outline: none;
|
||||
transition: border-color .15s;
|
||||
letter-spacing: 2px;
|
||||
}
|
||||
.pwd-wrap input::placeholder { letter-spacing: 0; color: var(--muted); }
|
||||
.pwd-wrap input:focus { border-color: var(--accent); }
|
||||
|
||||
.toggle-pwd {
|
||||
position: absolute;
|
||||
right: 12px; top: 50%;
|
||||
transform: translateY(-50%);
|
||||
background: none;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
color: var(--muted);
|
||||
padding: 4px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.toggle-pwd:hover { color: var(--text); }
|
||||
|
||||
.error-msg {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
background: var(--error-bg);
|
||||
border: 1px solid var(--error-brd);
|
||||
color: var(--error-txt);
|
||||
border-radius: 8px;
|
||||
padding: 10px 14px;
|
||||
font-size: 13px;
|
||||
margin-bottom: 18px;
|
||||
animation: shake .3s ease;
|
||||
}
|
||||
@keyframes shake {
|
||||
0%,100% { transform: translateX(0); }
|
||||
25% { transform: translateX(-6px); }
|
||||
75% { transform: translateX(6px); }
|
||||
}
|
||||
|
||||
.btn-login {
|
||||
width: 100%;
|
||||
margin-top: 20px;
|
||||
padding: 12px;
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
transition: opacity .15s;
|
||||
}
|
||||
.btn-login:hover { opacity: .88; }
|
||||
|
||||
.theme-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 6px;
|
||||
margin-top: 20px;
|
||||
background: none;
|
||||
border: none;
|
||||
color: var(--muted);
|
||||
font-family: 'Inter', sans-serif;
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
width: 100%;
|
||||
padding: 6px;
|
||||
border-radius: 6px;
|
||||
transition: color .15s;
|
||||
}
|
||||
.theme-btn:hover { color: var(--text); }
|
||||
|
||||
@font-face {
|
||||
font-family: 'terminator';
|
||||
/* Usamos url_for para que Flask genere la ruta correcta en el servidor */
|
||||
src: url("{{ url_for('static', filename='fonts/terminator.ttf') }}") format('truetype');
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<div class="login-wrap">
|
||||
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% for category, message in messages %}
|
||||
<div style="
|
||||
display:flex;align-items:center;gap:8px;
|
||||
background:rgba({% if category == 'error' %}248,113,113{% else %}52,211,153{% endif %},.12);
|
||||
border:1px solid rgba({% if category == 'error' %}248,113,113{% else %}52,211,153{% endif %},.35);
|
||||
color:{% if category == 'error' %}#f87171{% else %}#34d399{% endif %};
|
||||
border-radius:8px;padding:10px 14px;font-size:13px;margin-bottom:18px;">
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<circle cx="12" cy="12" r="10"/>
|
||||
<line x1="12" y1="8" x2="12" y2="12"/>
|
||||
<line x1="12" y1="16" x2="12.01" y2="16"/>
|
||||
</svg>
|
||||
{{ message }}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endwith %}
|
||||
|
||||
|
||||
<div class="login-logo">
|
||||
<div class="dot-row">
|
||||
<span class="dot"></span>
|
||||
<span class="dot"></span>
|
||||
<span class="dot"></span>
|
||||
</div>
|
||||
|
||||
<h1 id="titulo-autopol" style="font-family: 'terminator', sans-serif; font-size: 24px; color: rgb(8, 8, 111);">AUTOPOL</h1>
|
||||
<!-- <h1 class="animate__animated animate__backInLeft" style="font-family: 'terminator', sans-serif; font-size: 24px; color: rgb(8, 8, 111);">AUTOPOL</h1> -->
|
||||
<p>Fleet Operations Platform</p>
|
||||
<p>Introduce la contraseña para continuar</p>
|
||||
</div>
|
||||
|
||||
<div class="login-card">
|
||||
{% if error %}
|
||||
<div class="error-msg">
|
||||
<svg width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<circle cx="12" cy="12" r="10"/><line x1="12" y1="8" x2="12" y2="12"/><line x1="12" y1="16" x2="12.01" y2="16"/>
|
||||
</svg>
|
||||
{{ error }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<label class="field-label" for="password">Contraseña</label>
|
||||
<form method="POST" action="{{ url_for('login') }}">
|
||||
<div class="pwd-wrap">
|
||||
<input
|
||||
type="password"
|
||||
id="password"
|
||||
name="password"
|
||||
placeholder="••••••••"
|
||||
autofocus
|
||||
autocomplete="current-password"
|
||||
>
|
||||
<button type="button" class="toggle-pwd" id="togglePwd" aria-label="Mostrar contraseña">
|
||||
<svg id="eyeIcon" width="17" height="17" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<button type="submit" class="btn-login">Entrar</button>
|
||||
</form>
|
||||
|
||||
<button class="theme-btn" id="themeBtn" type="button">
|
||||
<svg width="13" height="13" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/>
|
||||
<line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/>
|
||||
<line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/>
|
||||
<line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/>
|
||||
</svg>
|
||||
<span id="themeLabel">Cambiar tema</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
/* Mostrar/ocultar contraseña */
|
||||
var togglePwd = document.getElementById('togglePwd');
|
||||
var pwdInput = document.getElementById('password');
|
||||
var eyeIcon = document.getElementById('eyeIcon');
|
||||
togglePwd.addEventListener('click', function() {
|
||||
var visible = pwdInput.type === 'text';
|
||||
pwdInput.type = visible ? 'password' : 'text';
|
||||
eyeIcon.innerHTML = visible
|
||||
? '<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/>'
|
||||
: '<path d="M17.94 17.94A10.07 10.07 0 0112 20c-7 0-11-8-11-8a18.45 18.45 0 015.06-5.94"/><path d="M9.9 4.24A9.12 9.12 0 0112 4c7 0 11 8 11 8a18.5 18.5 0 01-2.16 3.19"/><line x1="1" y1="1" x2="23" y2="23"/>';
|
||||
});
|
||||
|
||||
/* Tema */
|
||||
var html = document.documentElement;
|
||||
var themeBtn = document.getElementById('themeBtn');
|
||||
var themeLabel = document.getElementById('themeLabel');
|
||||
function updateLabel() {
|
||||
var isDark = html.getAttribute('data-theme') === 'dark';
|
||||
themeLabel.textContent = isDark ? 'Modo claro' : 'Modo oscuro';
|
||||
}
|
||||
updateLabel();
|
||||
themeBtn.addEventListener('click', function() {
|
||||
var next = html.getAttribute('data-theme') === 'dark' ? 'light' : 'dark';
|
||||
html.setAttribute('data-theme', next);
|
||||
localStorage.setItem('nexus-theme', next);
|
||||
updateLabel();
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
const titulo = document.getElementById("titulo-autopol");
|
||||
|
||||
// Comprobamos si el usuario ya vio la animación
|
||||
if (!localStorage.getItem("animacionVista")) {
|
||||
// Si no la ha visto, añadimos las clases de Animate.css para que se ejecute
|
||||
titulo.classList.add("animate__animated", "animate__backInLeft");
|
||||
|
||||
// Guardamos en el localStorage que ya la vio
|
||||
localStorage.setItem("animacionVista", "true");
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Executable
+190
@@ -0,0 +1,190 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Denominación{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.min.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='bootstrap-icons/bootstrap-icons.css') }}">
|
||||
|
||||
<body style="background-color: #f5f6fa;">
|
||||
|
||||
<div class="page-header">
|
||||
<div class="page-eyebrow">Configuración</div>
|
||||
<div class="page-title"><i class="bi bi-bus-front"></i> Tipo vehículo</div>
|
||||
<div class="page-subtitle">Gestiona los tipos de vehículos.</div>
|
||||
</div>
|
||||
|
||||
<div style="display:flex;gap:24px;align-items:flex-start;flex-wrap:wrap;">
|
||||
|
||||
{# Formulario añadir #}
|
||||
<div style="background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px;min-width:300px;">
|
||||
<p class="form-label" style="margin-bottom:14px;">Nuevo tipo vehículo</p>
|
||||
<form method="POST" action="{{ url_for('tipo_nueva') }}">
|
||||
<div class="form-group">
|
||||
<input class="form-input" type="text" name="tipo"
|
||||
placeholder="" required >
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-sm btn-primary" style="width:50%;margin-top:12px; display: block; margin-left: auto; margin-right: auto;">
|
||||
✚ Añadir
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{# Listado #}
|
||||
|
||||
<!-- <div style="flex:1;min-width:320px;"> -->
|
||||
<div style="flex:1;min-width:320px;max-width: 800px;">
|
||||
|
||||
|
||||
{# Buscador #}
|
||||
<div class="search-wrap" style="margin-bottom:16px;max-width:100%">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>
|
||||
</svg>
|
||||
<input type="text" id="searchDenom"
|
||||
placeholder="Buscar por tipo vehículo…"
|
||||
autocomplete="off"
|
||||
autofocus
|
||||
style="padding-right:32px; width: 500px;">
|
||||
<button type="button" id="clearSearch"
|
||||
style="display:none;position:absolute;right:325px;top:50%;
|
||||
transform:translateY(-50%);background:none;border:none;
|
||||
cursor:pointer;color:var(--muted);padding:4px;align-items:center;z-index:2;"
|
||||
onmouseover="this.style.color='var(--text)'"
|
||||
onmouseout="this.style.color='var(--muted)'">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2.5" style="pointer-events:none;display:block;">
|
||||
<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<p id="contador" style="margin-top:8px;font-size:12px;color:var(--muted)">
|
||||
{{ rows|length }} tipos vehículo
|
||||
</p>
|
||||
|
||||
<div class="table-wrap">
|
||||
<table id="tabla">
|
||||
<thead>
|
||||
<tr">
|
||||
<th hidden>ID</th>
|
||||
<th>Tipo</th>
|
||||
<!-- <th>Literal</th> -->
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbodyDenom">
|
||||
{% for r in rows %}
|
||||
{% set nombre_den = r['tipo'] %}
|
||||
<tr class="border-bottom">
|
||||
<td hidden class="td-id">{{ r['id'] }}</td>
|
||||
<td><strong>{{ r['tipo'] }}</strong></td>
|
||||
<!-- <td style="color:var(--muted);font-size:13px">{{ r['literal'] or '—' }}</td> -->
|
||||
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="4">
|
||||
<div class="empty-state">Sin tipo registradas.</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="{{ url_for('static', filename='js/jquery-3.7.1.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/tabledit.min.js') }}"></script>
|
||||
|
||||
<script>
|
||||
var input = document.getElementById('searchDenom');
|
||||
var clearBtn = document.getElementById('clearSearch');
|
||||
var contador = document.getElementById('contador');
|
||||
|
||||
input.addEventListener('input', function() {
|
||||
clearBtn.style.display = this.value ? 'flex' : 'none';
|
||||
filtrar(this.value.trim().toLowerCase());
|
||||
});
|
||||
|
||||
clearBtn.addEventListener('click', function() {
|
||||
input.value = '';
|
||||
this.style.display = 'none';
|
||||
input.focus();
|
||||
filtrar('');
|
||||
});
|
||||
|
||||
function filtrar(q) {
|
||||
var filas = document.querySelectorAll('#tbodyDenom tr');
|
||||
var visibles = 0;
|
||||
filas.forEach(function(tr) {
|
||||
var texto = tr.innerText.toLowerCase();
|
||||
var mostrar = !q || texto.indexOf(q) !== -1;
|
||||
tr.style.display = mostrar ? '' : 'none';
|
||||
if (mostrar) visibles++;
|
||||
});
|
||||
contador.textContent = visibles + ' tipos'
|
||||
+ (q ? ' — filtrado por «' + q + '»' : '');
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
$('#tabla').Tabledit({
|
||||
url:'/editar_tipo',
|
||||
|
||||
editButton:true,
|
||||
deleteButton:true,
|
||||
restoreButton:false,
|
||||
hideIdentifier:false,
|
||||
|
||||
buttons:{
|
||||
edit:{
|
||||
class:'btn btn-sm border rounded me-1',
|
||||
html:'<i class="bi bi-pencil"></i> '
|
||||
},
|
||||
// delete:{
|
||||
// class:'btn btn-sm btn-light text-danger border me-1',
|
||||
// html:'<i class="bi bi-trash"></i>'
|
||||
// },
|
||||
save:{
|
||||
class:'btn btn-sm btn-success',
|
||||
html:'Guardar'
|
||||
},
|
||||
// confirm:{
|
||||
// class:'btn btn-sm btn-warning',
|
||||
// html:'¿Seguro?'
|
||||
// }
|
||||
},
|
||||
|
||||
columns:{
|
||||
identifier:[0,'id'],
|
||||
editable:[
|
||||
[1,'tipo'],
|
||||
// [2,'literal'],
|
||||
]
|
||||
|
||||
},
|
||||
|
||||
onSuccess:function(data){
|
||||
if (data.action == "edit") {
|
||||
location.reload();
|
||||
}
|
||||
|
||||
if (data.action == "delete") {
|
||||
location.reload();
|
||||
}
|
||||
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
|
||||
$('#tabla td:last-child').attr(
|
||||
'style',
|
||||
'white-space: nowrap; width:185px;'
|
||||
);
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
Executable
+205
@@ -0,0 +1,205 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Unidades{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.min.css') }}">
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='bootstrap-icons/bootstrap-icons.css') }}">
|
||||
|
||||
<body style="background-color: #f5f6fa;">
|
||||
|
||||
|
||||
<div class="page-header">
|
||||
<div class="page-eyebrow">Configuración</div>
|
||||
<div class="page-title"><i class="bi bi-building"></i> Unidades</div>
|
||||
<div class="page-subtitle">Gestiona los unidades a las que se asignan los vehículos.</div>
|
||||
</div>
|
||||
|
||||
<div style="display:flex;gap:24px;align-items:flex-start;flex-wrap:wrap;">
|
||||
|
||||
{# Formulario añadir #}
|
||||
<div style="background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);padding:24px;min-width:400px;">
|
||||
<p class="form-label" style="margin-bottom:14px;">Nueva unidad</p>
|
||||
<form method="POST" action="{{ url_for('unidades_nueva') }}">
|
||||
<div class="form-group">
|
||||
<label class="form-label">Población</label>
|
||||
<div class="select-wrap">
|
||||
<select class="form-input form-select" name="poblacion_id" required>
|
||||
<option value="">— Selecciona población —</option>
|
||||
{% for p in poblaciones %}
|
||||
<option value="{{ p['id'] }}">{{ p['poblacion'] }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<svg class="select-arrow" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
|
||||
<polyline points="6 9 12 15 18 9"/>
|
||||
</svg>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="form-label">Unidad</label>
|
||||
<input class="form-input" type="text" name="unidad"
|
||||
placeholder="Nombre de la unidad" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-sm btn-primary" style="width:50%;margin-top:12px; display: block; margin-left: auto; margin-right: auto;">
|
||||
✚ Añadir
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{# Listado #}
|
||||
<div style="flex:1;min-width:320px;max-width: 800px;">
|
||||
<!-- <div style="flex:1;min-width:320px;"> -->
|
||||
|
||||
{# Buscador #}
|
||||
<div class="search-wrap" style="margin-bottom:16px;max-width:100%">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>
|
||||
</svg>
|
||||
<input type="text" id="searchUnidades"
|
||||
placeholder="Buscar por población o unidad…"
|
||||
autocomplete="off"
|
||||
autofocus
|
||||
style="padding-right:32px; width: 500px;">
|
||||
<button type="button" id="clearSearch"
|
||||
style="display:none;position:absolute;right:325px;top:50%;
|
||||
transform:translateY(-50%);background:none;border:none;
|
||||
cursor:pointer;color:var(--muted);padding:4px;align-items:center;z-index:2;"
|
||||
onmouseover="this.style.color='var(--text)'"
|
||||
onmouseout="this.style.color='var(--muted)'">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2.5" style="pointer-events:none;display:block;">
|
||||
<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<p id="contador" style="margin-top:8px;font-size:12px;color:var(--muted)">
|
||||
{{ rows|length }} unidades
|
||||
</p>
|
||||
|
||||
<div class="table-wrap">
|
||||
<table id="tabla">
|
||||
<thead>
|
||||
<tr>
|
||||
<th hidden>ID</th>
|
||||
<th>Población</th>
|
||||
<th>Unidad</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbodyUnidades">
|
||||
{% for r in rows %}
|
||||
{% set nombre_uni = r['unidad'] %}
|
||||
<tr class="border-bottom">
|
||||
<td hidden class="td-id">{{ r['id'] }}</td>
|
||||
<td><strong>{{ r['poblacion'] or '—' }}</strong></td>
|
||||
<td><strong>{{ r['unidad'] }}</strong></td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr id="sinDatos">
|
||||
<td colspan="4"><div class="empty-state">Sin unidades registradas.</div></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="{{ url_for('static', filename='js/jquery-3.7.1.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/tabledit.min.js') }}"></script>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
var input = document.getElementById('searchUnidades');
|
||||
var clearBtn = document.getElementById('clearSearch');
|
||||
var contador = document.getElementById('contador');
|
||||
|
||||
input.addEventListener('input', function() {
|
||||
clearBtn.style.display = this.value ? 'flex' : 'none';
|
||||
filtrar(this.value.trim().toLowerCase());
|
||||
});
|
||||
|
||||
clearBtn.addEventListener('click', function() {
|
||||
input.value = '';
|
||||
this.style.display = 'none';
|
||||
input.focus();
|
||||
filtrar('');
|
||||
});
|
||||
|
||||
function filtrar(q) {
|
||||
var filas = document.querySelectorAll('#tbodyUnidades tr');
|
||||
var visibles = 0;
|
||||
filas.forEach(function(tr) {
|
||||
var texto = tr.innerText.toLowerCase();
|
||||
var mostrar = !q || texto.indexOf(q) !== -1;
|
||||
tr.style.display = mostrar ? '' : 'none';
|
||||
if (mostrar) visibles++;
|
||||
});
|
||||
contador.textContent = visibles + ' unidad' + (visibles !== 1 ? 'es' : '')
|
||||
+ (q ? ' — filtrado por «' + q + '»' : '');
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<script>
|
||||
$('#tabla').Tabledit({
|
||||
url:'/editar_unidades',
|
||||
|
||||
editButton:true,
|
||||
deleteButton:false,
|
||||
restoreButton:false,
|
||||
hideIdentifier:false,
|
||||
|
||||
buttons:{
|
||||
edit:{
|
||||
class:'btn btn-sm border rounded me-1 ',
|
||||
html:'<i class="bi bi-pencil"></i> '
|
||||
},
|
||||
// delete:{
|
||||
// class:'btn btn-sm btn-light text-danger border me-1',
|
||||
// html:'<i class="bi bi-trash"></i>'
|
||||
// // html:'Borrar'
|
||||
// },
|
||||
save:{
|
||||
class:'btn btn-sm btn-success',
|
||||
html:'Guardar'
|
||||
},
|
||||
confirm:{
|
||||
class:'btn btn-sm btn-warning',
|
||||
html:'¿Seguro?'
|
||||
}
|
||||
},
|
||||
|
||||
columns:{
|
||||
identifier:[0,'id'],
|
||||
editable:[
|
||||
[1,'poblacion'],
|
||||
[2,'unidad'],
|
||||
]
|
||||
|
||||
},
|
||||
|
||||
onSuccess:function(data){
|
||||
if (data.action == "edit") {
|
||||
location.reload();
|
||||
}
|
||||
|
||||
if (data.action == "delete") {
|
||||
location.reload();
|
||||
}
|
||||
|
||||
console.log(data);
|
||||
}
|
||||
});
|
||||
|
||||
$('#tabla td:last-child').attr(
|
||||
'style',
|
||||
'white-space: nowrap; width:170px;'
|
||||
);
|
||||
</script>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
Executable
+828
@@ -0,0 +1,828 @@
|
||||
```html
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Unidades{% endblock %}
|
||||
{% block content %}
|
||||
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://unpkg.com/[email protected]/dist/css/tabulator_bootstrap5.min.css"
|
||||
>
|
||||
|
||||
<style>
|
||||
|
||||
/* CONTENEDOR TABULATOR */
|
||||
|
||||
#tabla-unidades {
|
||||
background: var(--surface);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
|
||||
/* CABECERA */
|
||||
|
||||
.unidades-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 12px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
|
||||
.unidades-search {
|
||||
position: relative;
|
||||
width: 500px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
|
||||
.unidades-search svg {
|
||||
position: absolute;
|
||||
left: 12px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
color: var(--muted);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
|
||||
.unidades-search input {
|
||||
width: 100%;
|
||||
padding: 9px 38px 9px 38px;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
background: var(--surface);
|
||||
color: var(--text);
|
||||
outline: none;
|
||||
}
|
||||
|
||||
|
||||
.unidades-search input:focus {
|
||||
border-color: var(--primary);
|
||||
}
|
||||
|
||||
|
||||
.clear-search {
|
||||
position: absolute;
|
||||
right: 8px;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
display: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: var(--muted);
|
||||
cursor: pointer;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
|
||||
.clear-search:hover {
|
||||
background: var(--border);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
|
||||
/* =====================================================
|
||||
TABULATOR
|
||||
===================================================== */
|
||||
|
||||
.tabulator {
|
||||
border: 0 !important;
|
||||
background: var(--surface);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
|
||||
.tabulator .tabulator-header {
|
||||
background: #f8f9fa;
|
||||
border-bottom: 1px solid var(--border);
|
||||
}
|
||||
|
||||
|
||||
.tabulator .tabulator-header .tabulator-col {
|
||||
background: transparent;
|
||||
border-right: 0;
|
||||
}
|
||||
|
||||
|
||||
.tabulator .tabulator-row {
|
||||
background: var(--surface);
|
||||
border-bottom: 1px solid var(--border);
|
||||
min-height: 48px;
|
||||
}
|
||||
|
||||
|
||||
.tabulator .tabulator-row:hover {
|
||||
background: rgba(0,0,0,.025);
|
||||
}
|
||||
|
||||
|
||||
/* .tabulator .tabulator-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-right: 0;
|
||||
} */
|
||||
|
||||
|
||||
/* ESTADO */
|
||||
|
||||
#estadoTabla {
|
||||
font-size: 12px;
|
||||
color: var(--muted);
|
||||
margin-top: 8px;
|
||||
min-height: 18px;
|
||||
}
|
||||
|
||||
|
||||
/* =====================================================
|
||||
RESPONSIVE
|
||||
===================================================== */
|
||||
|
||||
@media (max-width: 700px) {
|
||||
|
||||
.unidades-toolbar {
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.unidades-search {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
|
||||
<!-- =========================================================
|
||||
CABECERA
|
||||
========================================================== -->
|
||||
|
||||
<div class="page-header">
|
||||
|
||||
<div class="page-eyebrow">
|
||||
Configuración
|
||||
</div>
|
||||
|
||||
<div class="page-title">
|
||||
<i class="bi bi-building"></i>
|
||||
Unidades
|
||||
</div>
|
||||
|
||||
<div class="page-subtitle">
|
||||
Gestiona las unidades a las que se asignan los vehículos.
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div style="
|
||||
display:flex;
|
||||
gap:24px;
|
||||
align-items:flex-start;
|
||||
flex-wrap:wrap;
|
||||
">
|
||||
|
||||
|
||||
<!-- =====================================================
|
||||
FORMULARIO NUEVA UNIDAD
|
||||
====================================================== -->
|
||||
|
||||
<div style="
|
||||
background:var(--surface);
|
||||
border:1px solid var(--border);
|
||||
border-radius:var(--radius);
|
||||
padding:24px;
|
||||
min-width:400px;
|
||||
">
|
||||
|
||||
<p
|
||||
class="form-label"
|
||||
style="margin-bottom:14px;"
|
||||
>
|
||||
Nueva unidad
|
||||
</p>
|
||||
|
||||
|
||||
<form
|
||||
method="POST"
|
||||
action="{{ url_for('unidades_nueva') }}"
|
||||
>
|
||||
|
||||
|
||||
<!-- POBLACIÓN -->
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
<label class="form-label">
|
||||
Población
|
||||
</label>
|
||||
|
||||
<div class="select-wrap">
|
||||
|
||||
<select
|
||||
class="form-input form-select"
|
||||
name="poblacion_id"
|
||||
required
|
||||
>
|
||||
|
||||
<option value="">
|
||||
— Selecciona población —
|
||||
</option>
|
||||
|
||||
{% for p in poblaciones %}
|
||||
|
||||
<option value="{{ p['id'] }}">
|
||||
{{ p['poblacion'] }}
|
||||
</option>
|
||||
|
||||
{% endfor %}
|
||||
|
||||
</select>
|
||||
|
||||
<svg
|
||||
class="select-arrow"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2.5"
|
||||
>
|
||||
<polyline points="6 9 12 15 18 9"/>
|
||||
</svg>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- UNIDAD -->
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
<label class="form-label">
|
||||
Unidad
|
||||
</label>
|
||||
|
||||
<input
|
||||
class="form-input"
|
||||
type="text"
|
||||
name="unidad"
|
||||
placeholder="Nombre de la unidad"
|
||||
required
|
||||
>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
class="btn btn-sm btn-primary"
|
||||
style="
|
||||
width:50%;
|
||||
margin-top:12px;
|
||||
display:block;
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
"
|
||||
>
|
||||
|
||||
✚ Añadir
|
||||
|
||||
</button>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- =====================================================
|
||||
LISTADO
|
||||
====================================================== -->
|
||||
|
||||
<div style="
|
||||
flex:1;
|
||||
min-width:320px;
|
||||
max-width:800px;
|
||||
">
|
||||
|
||||
|
||||
<!-- TOOLBAR -->
|
||||
|
||||
<div class="unidades-toolbar">
|
||||
|
||||
|
||||
<!-- BUSCADOR -->
|
||||
|
||||
<div class="unidades-search">
|
||||
|
||||
<svg
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
>
|
||||
<circle
|
||||
cx="11"
|
||||
cy="11"
|
||||
r="8"
|
||||
/>
|
||||
<line
|
||||
x1="21"
|
||||
y1="21"
|
||||
x2="16.65"
|
||||
y2="16.65"
|
||||
/>
|
||||
</svg>
|
||||
|
||||
|
||||
<input
|
||||
type="text"
|
||||
id="searchUnidades"
|
||||
placeholder="Buscar por población o unidad…"
|
||||
autocomplete="off"
|
||||
autofocus
|
||||
>
|
||||
|
||||
|
||||
<button
|
||||
type="button"
|
||||
id="clearSearch"
|
||||
class="clear-search"
|
||||
>
|
||||
|
||||
<svg
|
||||
width="14"
|
||||
height="14"
|
||||
viewBox="0 0 24 24"
|
||||
fill="none"
|
||||
stroke="currentColor"
|
||||
stroke-width="2.5"
|
||||
>
|
||||
<line
|
||||
x1="18"
|
||||
y1="6"
|
||||
x2="6"
|
||||
y2="18"
|
||||
/>
|
||||
|
||||
<line
|
||||
x1="6"
|
||||
y1="6"
|
||||
x2="18"
|
||||
y2="18"
|
||||
/>
|
||||
</svg>
|
||||
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<!-- CONTADOR -->
|
||||
|
||||
<div
|
||||
id="contador"
|
||||
style="
|
||||
margin:8px 0;
|
||||
font-size:12px;
|
||||
color:var(--muted);
|
||||
"
|
||||
>
|
||||
{{ rows|length }}
|
||||
unidad{% if rows|length != 1 %}es{% endif %}
|
||||
</div>
|
||||
|
||||
|
||||
<!-- TABLA -->
|
||||
|
||||
<div id="tabla-unidades"></div>
|
||||
|
||||
|
||||
<!-- ESTADO -->
|
||||
|
||||
<div id="estadoTabla"></div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- DATOS PARA TABULATOR=============================== -->
|
||||
|
||||
<script>
|
||||
|
||||
const unidades = [
|
||||
|
||||
{% for r in rows %}
|
||||
|
||||
{
|
||||
id: {{ r['id'] | tojson }},
|
||||
|
||||
poblacion_id:
|
||||
{{ r['poblacion_id'] | tojson }},
|
||||
|
||||
poblacion:
|
||||
{{ (r['poblacion'] or '') | tojson }},
|
||||
|
||||
unidad:
|
||||
{{ r['unidad'] | tojson }}
|
||||
}
|
||||
|
||||
{% if not loop.last %},{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
];
|
||||
|
||||
|
||||
const poblaciones = [
|
||||
|
||||
{% for p in poblaciones %}
|
||||
|
||||
{
|
||||
id: {{ p['id'] | tojson }},
|
||||
|
||||
nombre:
|
||||
{{ p['poblacion'] | tojson }}
|
||||
}
|
||||
|
||||
{% if not loop.last %},{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
];
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<!-- TABULATOR -->
|
||||
|
||||
<script
|
||||
src="https://unpkg.com/[email protected]/dist/js/tabulator.min.js">
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
|
||||
// =========================================================
|
||||
// ELEMENTOS
|
||||
// =========================================================
|
||||
|
||||
const buscador =
|
||||
document.getElementById(
|
||||
"searchUnidades"
|
||||
);
|
||||
|
||||
const clearSearch =
|
||||
document.getElementById(
|
||||
"clearSearch"
|
||||
);
|
||||
|
||||
const contador =
|
||||
document.getElementById(
|
||||
"contador"
|
||||
);
|
||||
|
||||
const estadoTabla =
|
||||
document.getElementById(
|
||||
"estadoTabla"
|
||||
);
|
||||
|
||||
|
||||
// =========================================================
|
||||
// LISTA DE POBLACIONES PARA EL SELECT
|
||||
// =========================================================
|
||||
|
||||
const opcionesPoblaciones = {};
|
||||
|
||||
poblaciones.forEach(function(p) {
|
||||
|
||||
opcionesPoblaciones[p.id] =
|
||||
p.nombre;
|
||||
|
||||
});
|
||||
|
||||
|
||||
// =========================================================
|
||||
// CONTADOR
|
||||
// =========================================================
|
||||
|
||||
function actualizarContador() {
|
||||
|
||||
const cantidad =
|
||||
tabla.getDataCount("active");
|
||||
|
||||
|
||||
contador.textContent =
|
||||
cantidad +
|
||||
" unidad" +
|
||||
(cantidad !== 1 ? "es" : "");
|
||||
|
||||
}
|
||||
|
||||
|
||||
// =========================================================
|
||||
// MENSAJE
|
||||
// =========================================================
|
||||
|
||||
function mostrarEstado(texto, error = false) {
|
||||
|
||||
estadoTabla.textContent = texto;
|
||||
|
||||
estadoTabla.style.color =
|
||||
error
|
||||
? "#dc3545"
|
||||
: "#198754";
|
||||
|
||||
|
||||
setTimeout(function() {
|
||||
|
||||
estadoTabla.textContent = "";
|
||||
|
||||
}, 3000);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// TABULATOR
|
||||
|
||||
const tabla = new Tabulator(
|
||||
"#tabla-unidades",
|
||||
{
|
||||
|
||||
data: unidades,
|
||||
layout: "fitColumns",
|
||||
height: "500px",
|
||||
placeholder:
|
||||
"Sin unidades registradas.",
|
||||
editTriggerEvent: "click",
|
||||
|
||||
columns: [
|
||||
|
||||
|
||||
{ title: "ID",
|
||||
field: "id",
|
||||
visible: false
|
||||
},
|
||||
|
||||
|
||||
{ title: "Población",
|
||||
field: "poblacion_id",
|
||||
minWidth: 220,
|
||||
editor: "list",
|
||||
editorParams: {
|
||||
values:
|
||||
opcionesPoblaciones,
|
||||
autocomplete: true,
|
||||
listOnEmpty: true
|
||||
},
|
||||
|
||||
formatter: function(cell) {
|
||||
const id =
|
||||
cell.getValue();
|
||||
return opcionesPoblaciones[id]
|
||||
|| "—";
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
title: "Unidad",
|
||||
field: "unidad",
|
||||
editor: "input",
|
||||
validator: "required",
|
||||
minWidth: 250,
|
||||
formatter: function(cell) {
|
||||
const valor =
|
||||
cell.getValue();
|
||||
return valor
|
||||
? `<strong>${escapeHtml(valor)}</strong>`
|
||||
: "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
]
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// ESCAPAR HTML
|
||||
|
||||
function escapeHtml(text) {
|
||||
|
||||
const div =
|
||||
document.createElement("div");
|
||||
|
||||
div.textContent = text;
|
||||
|
||||
return div.innerHTML;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// EDICIÓN DE CELDA
|
||||
|
||||
tabla.on(
|
||||
"cellEdited",
|
||||
async function(cell) {
|
||||
|
||||
const fila =
|
||||
cell.getRow();
|
||||
|
||||
const datos =
|
||||
fila.getData();
|
||||
|
||||
const campo =
|
||||
cell.getField();
|
||||
|
||||
const valor =
|
||||
cell.getValue();
|
||||
|
||||
|
||||
console.log(
|
||||
"Edición:",
|
||||
{
|
||||
id: datos.id,
|
||||
campo: campo,
|
||||
valor: valor
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// Guardar en Flask
|
||||
|
||||
try {
|
||||
|
||||
const respuesta =
|
||||
await fetch(
|
||||
`/api/unidades/${datos.id}`,
|
||||
{
|
||||
|
||||
method: "PATCH",
|
||||
headers: {
|
||||
"Content-Type":
|
||||
"application/json"
|
||||
},
|
||||
body: JSON.stringify({
|
||||
campo: campo,
|
||||
valor: valor
|
||||
})
|
||||
}
|
||||
);
|
||||
|
||||
const resultado =
|
||||
await respuesta.json();
|
||||
|
||||
if (!respuesta.ok) {
|
||||
|
||||
throw new Error(
|
||||
resultado.error ||
|
||||
"No se pudo guardar"
|
||||
);
|
||||
}
|
||||
|
||||
// Actualizar fila con respuesta de Flask
|
||||
|
||||
await fila.update({
|
||||
|
||||
id: resultado.id,
|
||||
poblacion_id: resultado.poblacion_id,
|
||||
poblacion: resultado.poblacion,
|
||||
unidad: resultado.unidad
|
||||
});
|
||||
|
||||
mostrarEstado(
|
||||
"✓ Cambios guardados"
|
||||
);
|
||||
|
||||
}
|
||||
catch (error) {
|
||||
console.error(
|
||||
"Error:",
|
||||
error
|
||||
);
|
||||
|
||||
mostrarEstado(
|
||||
error.message,
|
||||
true
|
||||
);
|
||||
|
||||
// Volvemos a obtener los datos originales
|
||||
// desde el servidor.
|
||||
|
||||
tabla.replaceData(
|
||||
unidades
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// BUSCADOR
|
||||
buscador.addEventListener(
|
||||
"input",
|
||||
function() {
|
||||
|
||||
const texto =
|
||||
this.value
|
||||
.trim()
|
||||
.toLowerCase();
|
||||
|
||||
|
||||
clearSearch.style.display =
|
||||
texto
|
||||
? "flex"
|
||||
: "none";
|
||||
|
||||
|
||||
if (!texto) {
|
||||
|
||||
tabla.clearFilter();
|
||||
|
||||
actualizarContador();
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
tabla.setFilter(
|
||||
function(data) {
|
||||
|
||||
const poblacion =
|
||||
String(
|
||||
data.poblacion || ""
|
||||
).toLowerCase();
|
||||
|
||||
|
||||
const unidad =
|
||||
String(
|
||||
data.unidad || ""
|
||||
).toLowerCase();
|
||||
|
||||
|
||||
return (
|
||||
poblacion.includes(texto) ||
|
||||
unidad.includes(texto)
|
||||
);
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
setTimeout(
|
||||
actualizarContador,
|
||||
0
|
||||
);
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// LIMPIAR BUSCADOR
|
||||
|
||||
clearSearch.addEventListener(
|
||||
"click",
|
||||
function() {
|
||||
|
||||
buscador.value = "";
|
||||
|
||||
clearSearch.style.display =
|
||||
"none";
|
||||
|
||||
tabla.clearFilter();
|
||||
|
||||
buscador.focus();
|
||||
|
||||
actualizarContador();
|
||||
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
// CONTADOR INICIAL
|
||||
|
||||
actualizarContador();
|
||||
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
```
|
||||
Executable
+1084
File diff suppressed because it is too large
Load Diff
Executable
+391
@@ -0,0 +1,391 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Vehículos{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
||||
<div class="page-header">
|
||||
<div class="page-eyebrow">Base de datos</div>
|
||||
<div class="page-title"><i class="bi bi-taxi-front"></i> Vehículos</div>
|
||||
<div class="page-subtitle">Gestión del parque móvil. Búsqueda por m.oficial, m.reservada, VIN, marca, modelo, poblacion, unidad, denominación, tipo, operacion, situacion, lanzadestellos.</div>
|
||||
</div>
|
||||
|
||||
<div class="crud-toolbar">
|
||||
<form method="GET" action="{{ url_for('vehiculos_list') }}" class="search-wrap" id="searchForm">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>
|
||||
</svg>
|
||||
<input
|
||||
type="text"
|
||||
name="q"
|
||||
id="searchInput"
|
||||
placeholder="Buscar… palabras separadas por comas: Ford, Transit"
|
||||
value="{{ q }}"
|
||||
autocomplete="off"
|
||||
autofocus
|
||||
style="width: 400px;"
|
||||
>
|
||||
|
||||
<button type="button" id="clearBtn" title="Limpiar búsqueda"
|
||||
style="display:{{ 'flex' if q else 'none' }};position:absolute;right:-25px;top:50%;
|
||||
transform:translateY(-50%);background:none;border:none;cursor:pointer;
|
||||
color:var(--muted);padding:4px;align-items:center;transition:color .15s;
|
||||
z-index:2;"
|
||||
onmouseover="this.style.color='var(--text)'"
|
||||
onmouseout="this.style.color='var(--muted)'">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"
|
||||
style="pointer-events:none;display:block;">
|
||||
<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
|
||||
</svg>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
{# Casilla incluir bajas #}
|
||||
<label style="display:flex;align-items:center;gap:8px;cursor:pointer;
|
||||
font-size:13px;color:var(--muted);white-space:nowrap;
|
||||
padding:8px 12px;border:1px solid var(--border);border-radius:8px;
|
||||
transition:border-color .15s,color .15s;user-select:none; margin-left: 50px;"
|
||||
onmouseover="this.style.borderColor='var(--accent)';this.style.color='var(--text)'"
|
||||
onmouseout="this.style.borderColor='var(--border)';this.style.color='var(--muted)'">
|
||||
<input type="checkbox" id="inclBajas" name="incl_bajas"
|
||||
style="width:15px;height:15px;accent-color:var(--accent);cursor:pointer;"
|
||||
{% if incl_bajas %}checked{% endif %}>
|
||||
Incluir bajas
|
||||
</label>
|
||||
|
||||
<div style="display:flex;gap:8px;align-items:center;margin-left:auto;">
|
||||
<a href="{{ url_for('vehiculos_exportar', q=q) }}" class="btn btn-ghost" id="btnExcel" title="Exportar a Excel">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/>
|
||||
<polyline points="14 2 14 8 20 8"/>
|
||||
<line x1="12" y1="18" x2="12" y2="12"/>
|
||||
<line x1="9" y1="15" x2="12" y2="18"/><line x1="15" y1="15" x2="12" y2="18"/>
|
||||
</svg>
|
||||
Excel
|
||||
</a>
|
||||
<button type="button" class="btn btn-ghost" id="btnPDF" title="Imprimir / Guardar PDF">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<polyline points="6 9 6 2 18 2 18 9"/>
|
||||
<path d="M6 18H4a2 2 0 01-2-2v-5a2 2 0 012-2h16a2 2 0 012 2v5a2 2 0 01-2 2h-2"/>
|
||||
<rect x="6" y="14" width="12" height="8"/>
|
||||
</svg>
|
||||
Imprimir - PDF
|
||||
</button>
|
||||
<button type="button" class="btn btn-ghost" id="btnCopiar" title="Copiar al portapapeles">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/>
|
||||
</svg>
|
||||
Copiar
|
||||
</button>
|
||||
</div>
|
||||
|
||||
|
||||
<a href="{{ url_for('vehiculos_nuevo') }}" class="btn btn-primary">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5">
|
||||
<line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/>
|
||||
</svg>
|
||||
Nuevo vehículo
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{# Sin {% if rows %} - siempre visible #}
|
||||
<p id="counter" style="margin-bottom:10px;margin-top:1px;font-size:12px;color:var(--muted)">
|
||||
{{ rows|length }} registro{{ 's' if rows|length != 1 }}{% if q %} — filtrado por «{{ q }}»{% endif %}
|
||||
</p>
|
||||
|
||||
|
||||
<div class="table-wrap">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<!-- <th hidden>ID</th> -->
|
||||
<th>M. Oficial</th>
|
||||
<th>M. Reservada</th>
|
||||
<th>Marca</th>
|
||||
<th>Modelo</th>
|
||||
<th>Poblacion</th>
|
||||
<th>Unidad</th>
|
||||
<!-- <th>Grupo</th> -->
|
||||
<th>Tipo vehículo</th>
|
||||
<th>Situación</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbody">
|
||||
{% include 'vehiculos/rows.html' %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
var input = document.getElementById('searchInput');
|
||||
var tbody = document.getElementById('tbody');
|
||||
var counter = document.getElementById('counter');
|
||||
var clearBtn = document.getElementById('clearBtn');
|
||||
var timer;
|
||||
|
||||
// Inicializar contador al cargar la página
|
||||
(function() {
|
||||
var filas = document.querySelectorAll('#tbody tr[data-id]').length;
|
||||
var q = input.value.trim();
|
||||
if (counter) {
|
||||
counter.textContent = filas + ' registro' + (filas !== 1 ? 's' : '')
|
||||
+ (q ? ' — filtrado por «' + q + '»' : '');
|
||||
}
|
||||
})();
|
||||
|
||||
// Búsqueda con debounce
|
||||
input.addEventListener('input', function() {
|
||||
clearBtn.style.display = this.value ? 'flex' : 'none';
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(function() { buscar(input.value.trim()); }, 300);
|
||||
});
|
||||
|
||||
clearBtn.addEventListener('click', function() {
|
||||
input.value = '';
|
||||
clearBtn.style.display = 'none';
|
||||
input.focus();
|
||||
buscar('');
|
||||
});
|
||||
|
||||
var inclBajas = document.getElementById('inclBajas');
|
||||
|
||||
// Al cambiar el checkbox, relanzar búsqueda
|
||||
inclBajas.addEventListener('change', function() {
|
||||
buscar(input.value.trim());
|
||||
});
|
||||
|
||||
function buscar(q) {
|
||||
var bajas = inclBajas.checked ? '1' : '0';
|
||||
var btnExcel = document.getElementById('btnExcel');
|
||||
|
||||
if (btnExcel) {
|
||||
btnExcel.href = '{{ url_for("vehiculos_exportar") }}?q=' + encodeURIComponent(q) + '&incl_bajas=' + bajas;;
|
||||
}
|
||||
|
||||
var url = '{{ url_for("vehiculos_list") }}?q='
|
||||
+ encodeURIComponent(q) + '&solo_filas=1&incl_bajas=' + bajas;
|
||||
|
||||
fetch(url)
|
||||
.then(function(r) {
|
||||
// Si el servidor devuelve 302 o la URL cambió, la sesión expiró
|
||||
if (r.redirected || r.url.includes('/login')) {
|
||||
window.location = '{{ url_for("login") }}';
|
||||
return null;
|
||||
}
|
||||
return r.text();
|
||||
})
|
||||
.then(function(html) {
|
||||
if (!html) return;
|
||||
tbody.innerHTML = html;
|
||||
var filas = document.querySelectorAll('#tbody tr[data-id]').length;
|
||||
if (counter) {
|
||||
counter.textContent = filas + ' registro' + (filas !== 1 ? 's' : '')
|
||||
+ (q ? ' — filtrado por «' + q + '»' : '');
|
||||
counter.style.display = '';
|
||||
}
|
||||
})
|
||||
.catch(function() {
|
||||
window.location = '{{ url_for("login") }}';
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* ── PDF ── */
|
||||
document.getElementById('btnPDF').addEventListener('click', function() {
|
||||
var q = input.value.trim();
|
||||
var titulo = 'Listado de vehículos' + (q ? ' — Filtro: ' + q : '');
|
||||
var fecha = new Date().toLocaleDateString('es-ES', {day:'2-digit', month:'2-digit', year:'numeric'});
|
||||
|
||||
// Construir tabla con los datos visibles
|
||||
var heads = [];
|
||||
document.querySelectorAll('thead th').forEach(function(th, i) {
|
||||
if (i < 9) heads.push(th.innerText.trim());
|
||||
});
|
||||
|
||||
var filas = '';
|
||||
tbody.querySelectorAll('tr[data-id]').forEach(function(tr) {
|
||||
var celdas = tr.querySelectorAll('td');
|
||||
filas += '<tr>';
|
||||
for (var i = 0; i < 10; i++) {
|
||||
filas += '<td>' + (celdas[i] ? celdas[i].innerText.trim() : '') + '</td>';
|
||||
}
|
||||
filas += '</tr>';
|
||||
});
|
||||
|
||||
var html = `<!DOCTYPE html><html><head><meta charset="UTF-8">
|
||||
<title>${titulo}</title>
|
||||
<style>
|
||||
body { font-family: Arial, sans-serif; font-size: 11px; color: #1a1d29; margin: 24px; }
|
||||
h2 { font-size: 15px; margin-bottom: 4px; }
|
||||
.meta { font-size: 10px; color: #666; margin-bottom: 16px; }
|
||||
table { width: 100%; border-collapse: collapse; }
|
||||
th { background: #5c6ef8; color: #fff; padding: 7px 8px; text-align: left; font-size: 10px; letter-spacing: .5px; }
|
||||
td { padding: 6px 8px; border-bottom: 1px solid #e3e6ef; font-size: 10px; }
|
||||
tr:nth-child(even) td { background: #eef0f8; }
|
||||
.badge { background: #eef0f8; color: #5c6ef8; padding: 2px 7px; border-radius: 20px;
|
||||
border: 1px solid rgba(92,110,248,.3); font-size: 9px; font-weight: 700; }
|
||||
@media print { body { margin: 12px; } }
|
||||
</style></head><body>
|
||||
<h2>${titulo}</h2>
|
||||
<div class="meta">Generado el ${fecha} · ${tbody.querySelectorAll('tr[data-id]').length} registros</div>
|
||||
<table>
|
||||
<thead><tr>${heads.map(function(h){ return '<th>'+h+'</th>'; }).join('')}</tr></thead>
|
||||
<tbody>${filas}</tbody>
|
||||
</table>
|
||||
</body></html>`;
|
||||
|
||||
var win = window.open('', '_blank', 'width=900,height=650');
|
||||
win.document.write(html);
|
||||
win.document.close();
|
||||
win.focus();
|
||||
win.print();
|
||||
win.close();
|
||||
});
|
||||
|
||||
/* ── COPIAR ── */
|
||||
document.getElementById('btnCopiar').addEventListener('click', function() {
|
||||
var btn = this;
|
||||
|
||||
// Leer filas EN EL MOMENTO del click, no antes
|
||||
var heads = ['M. Oficial','M. Reservada','Marca','Modelo','Poblacion','Unidad','Grupo','Denominación','Situación'];
|
||||
var lineas = [heads.join('\t')];
|
||||
|
||||
document.querySelectorAll('#tbody tr[data-id]').forEach(function(tr) {
|
||||
var fila = [];
|
||||
tr.querySelectorAll('td').forEach(function(td) {
|
||||
fila.push(td.innerText.trim());
|
||||
});
|
||||
lineas.push(fila.join('\t'));
|
||||
});
|
||||
|
||||
var texto = lineas.join('\n');
|
||||
|
||||
if (!texto.trim() || lineas.length <= 1) {
|
||||
alert('No hay datos para copiar.');
|
||||
return;
|
||||
}
|
||||
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(texto)
|
||||
.then(function() { mostrarCopiado(btn); })
|
||||
.catch(function() { copiarFallback(texto, btn); });
|
||||
} else {
|
||||
copiarFallback(texto, btn);
|
||||
}
|
||||
});
|
||||
|
||||
function copiarFallback(texto, btn) {
|
||||
var ta = document.createElement('textarea');
|
||||
ta.value = texto;
|
||||
ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;';
|
||||
document.body.appendChild(ta);
|
||||
ta.focus();
|
||||
ta.select();
|
||||
ta.setSelectionRange(0, 99999); // Para móviles
|
||||
var ok = false;
|
||||
try {
|
||||
ok = document.execCommand('copy');
|
||||
} catch(e) { ok = false; }
|
||||
document.body.removeChild(ta);
|
||||
if (ok) {
|
||||
mostrarCopiado(btn);
|
||||
} else {
|
||||
alert('No se pudo copiar automáticamente.\nSelecciona el texto manualmente con Ctrl+A y Ctrl+C.');
|
||||
}
|
||||
}
|
||||
|
||||
function mostrarCopiado(btn) {
|
||||
var orig = btn.innerHTML;
|
||||
btn.innerHTML = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polyline points="20 6 9 17 4 12"/></svg> Copiado';
|
||||
btn.style.color = 'var(--success)';
|
||||
btn.style.borderColor = 'var(--success)';
|
||||
setTimeout(function() {
|
||||
btn.innerHTML = orig;
|
||||
btn.style.color = '';
|
||||
btn.style.borderColor = '';
|
||||
}, 2000);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
<script>
|
||||
/* ── ORDENACIÓN POR COLUMNAS ── */
|
||||
(function() {
|
||||
var estado = { col: -1, asc: true };
|
||||
|
||||
document.querySelectorAll('thead th').forEach(function(th, idx) {
|
||||
// No ordenar la última columna (acciones/estado)
|
||||
th.style.cursor = 'pointer';
|
||||
th.style.userSelect = 'none';
|
||||
th.title = 'Pulsa para ordenar';
|
||||
|
||||
// Añadir icono de orden
|
||||
var icon = document.createElement('span');
|
||||
icon.style.cssText = 'margin-left:5px;opacity:.3;font-size:10px;';
|
||||
icon.textContent = '⇅';
|
||||
icon.className = 'sort-icon';
|
||||
th.appendChild(icon);
|
||||
|
||||
th.addEventListener('click', function() {
|
||||
var tbody = document.querySelector('tbody');
|
||||
var filas = Array.from(tbody.querySelectorAll('tr[data-id], tr[onclick]'));
|
||||
|
||||
if (!filas.length) return;
|
||||
|
||||
var mismaCol = estado.col === idx;
|
||||
estado.asc = mismaCol ? !estado.asc : true;
|
||||
estado.col = idx;
|
||||
|
||||
// Actualizar iconos
|
||||
document.querySelectorAll('.sort-icon').forEach(function(ic) {
|
||||
ic.textContent = '⇅';
|
||||
ic.style.opacity = '.3';
|
||||
});
|
||||
icon.textContent = estado.asc ? '↑' : '↓';
|
||||
icon.style.opacity = '1';
|
||||
icon.style.color = 'var(--accent)';
|
||||
|
||||
filas.sort(function(a, b) {
|
||||
var celdaA = a.querySelectorAll('td')[idx];
|
||||
var celdaB = b.querySelectorAll('td')[idx];
|
||||
if (!celdaA || !celdaB) return 0;
|
||||
|
||||
var valA = celdaA.innerText.trim().toLowerCase();
|
||||
var valB = celdaB.innerText.trim().toLowerCase();
|
||||
|
||||
// Detectar si es número
|
||||
var numA = parseFloat(valA.replace(/[^0-9.-]/g, ''));
|
||||
var numB = parseFloat(valB.replace(/[^0-9.-]/g, ''));
|
||||
var esNumero = !isNaN(numA) && !isNaN(numB);
|
||||
|
||||
// Detectar si es fecha (formato YYYY-MM-DD o DD-MM-YYYY)
|
||||
var fechaRegex = /^\d{2}[-\/]\d{2}[-\/]\d{4}$|^\d{4}[-\/]\d{2}[-\/]\d{2}$/;
|
||||
var esFecha = fechaRegex.test(celdaA.innerText.trim());
|
||||
|
||||
var resultado;
|
||||
if (esNumero) {
|
||||
resultado = numA - numB;
|
||||
} else if (esFecha) {
|
||||
// Normalizar DD-MM-YYYY a YYYY-MM-DD para comparar
|
||||
var normA = valA.replace(/(\d{2})-(\d{2})-(\d{4})/, '$3-$2-$1');
|
||||
var normB = valB.replace(/(\d{2})-(\d{2})-(\d{4})/, '$3-$2-$1');
|
||||
resultado = normA.localeCompare(normB);
|
||||
} else {
|
||||
resultado = valA.localeCompare(valB, 'es');
|
||||
}
|
||||
|
||||
return estado.asc ? resultado : -resultado;
|
||||
});
|
||||
|
||||
// Reinsertar filas ordenadas
|
||||
filas.forEach(function(fila) { tbody.appendChild(fila); });
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
Executable
+108
@@ -0,0 +1,108 @@
|
||||
{% if rows %}
|
||||
{% for r in rows %}
|
||||
<tr data-id="{{ r['id'] }}"
|
||||
onclick="window.location='/vehiculos/{{ r['id'] }}/editar?q={{ q|urlencode }}'"
|
||||
style="cursor:pointer;"
|
||||
onmouseover="this.style.background='var(--pill-bg)'"
|
||||
onmouseout="this.style.background=''">
|
||||
<!-- <td hidden class="td-id">#{{ r['id'] }}</td> -->
|
||||
<td>{{ r['m_oficial'] or '—' }}</td>
|
||||
<td>{{ r['m_reservada'] or '—' }}</td>
|
||||
<!-- <td>{{ r['vin'] or '—' }}</td> -->
|
||||
<td><strong>{{ r['marca'] or '—' }}</strong></td>
|
||||
<td>{{ r['modelo'] or '—' }}</td>
|
||||
<td>{{ r['poblacion'] or '—' }}</td>
|
||||
<td>{{ r['unidad'] or '—' }}</td>
|
||||
<!-- <td>{{ r['grupo'] or '—' }}</td> -->
|
||||
<td>{{ r['tipo'] or '—' }}</td>
|
||||
<td>
|
||||
{% if r['situacion'] == 'BAJA' %}
|
||||
<span style="background:rgba(248,113,113,.12);color:#f87171;font-size:11px;font-weight:600;padding:3px 9px;border-radius:20px;border:1px solid rgba(248,113,113,.3)">
|
||||
BAJA
|
||||
</span>
|
||||
{% elif r['situacion'] %}
|
||||
<span style="background:rgba(52,211,153,.12);color:#34d399;font-size:11px;font-weight:600;padding:3px 9px;border-radius:20px;border:1px solid rgba(52,211,153,.3)">
|
||||
{{ r['situacion'] }}
|
||||
</span>
|
||||
{% else %}—{% endif %}
|
||||
{% if r['lanzadestellos'] == 1 %}
|
||||
<i class="bi bi-brightness-alt-high-fill" style="margin-left: 10px; font-size: 1rem; color: cornflowerblue;"></i>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="10" rowspan="7">
|
||||
<div class="empty-state" style="color: rgb(194, 191, 191);">
|
||||
<i class="bi bi-car-front" style="font-size: 2rem;"></i>
|
||||
<br>
|
||||
{% if q %}
|
||||
No se encontraron resultados para <strong>"{{ q }}"</strong>.
|
||||
{% else %}
|
||||
<!-- No hay vehículos registrados aún. -->
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- {% if rows %}
|
||||
{% for r in rows %}
|
||||
<tr data-id="{{ r['id'] }}">
|
||||
<td class="td-id">#{{ r['id'] }}</td>
|
||||
<td>{{ r['m_oficial'] or '—' }}</td>
|
||||
<td>{{ r['m_reservada'] or '—' }}</td>
|
||||
<td><strong>{{ r['marca'] or '—' }}</strong></td>
|
||||
<td>{{ r['modelo'] or '—' }}</td>
|
||||
<td>{{ r['tipo'] or '—' }}</td>
|
||||
<td>
|
||||
{% if r['tipo'] %}
|
||||
<span style="background:rgba(92,110,248,.12);color:var(--accent);font-size:11px;font-weight:600;padding:3px 9px;border-radius:20px;border:1px solid rgba(92,110,248,.25)">
|
||||
{{ r['tipo'] }}
|
||||
</span>
|
||||
{% else %}—{% endif %}
|
||||
</td>
|
||||
|
||||
<td>
|
||||
{% if r['situacion'] == 'BAJA' %}
|
||||
<span style="background:rgba(248,113,113,.12);color:#f87171;font-size:11px;font-weight:600;padding:3px 9px;border-radius:20px;border:1px solid rgba(248,113,113,.3)">
|
||||
BAJA
|
||||
</span>
|
||||
{% elif r['situacion'] %}
|
||||
<span style="background:rgba(52,211,153,.12);color:#34d399;font-size:11px;font-weight:600;padding:3px 9px;border-radius:20px;border:1px solid rgba(52,211,153,.3)">
|
||||
{{ r['situacion'] }}
|
||||
</span>
|
||||
{% else %}—{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<div class="td-actions" style="justify-content:flex-end">
|
||||
<a href="/vehiculos/{{ r['id'] }}/editar?q={{ q|urlencode }}" class="btn btn-ghost btn-sm">Editar</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="8">
|
||||
<div class="empty-state">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
|
||||
<path d="M5 17H3a2 2 0 01-2-2V9a2 2 0 012-2h11l4 4v4a2 2 0 01-2 2h-1"/>
|
||||
<circle cx="7" cy="17" r="2"/><circle cx="17" cy="17" r="2"/>
|
||||
</svg>
|
||||
{% if q %}
|
||||
No se encontraron resultados para <strong>"{{ q }}"</strong>.
|
||||
{% else %}
|
||||
No hay vehículos registrados aún.
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %} -->
|
||||
|
||||
|
||||
Executable
+230
@@ -0,0 +1,230 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Via-T{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-header">
|
||||
<div class="page-eyebrow">Gestión</div>
|
||||
<div class="page-title"><i class="bi bi-broadcast"></i> Via-T</div>
|
||||
<div class="page-subtitle">Listado de vehículos con dispositivo Via-T. Búsqueda por Via-T, m.oficial, m.reservada, marca, modelo, poblacion, unidad, tipo.</div>
|
||||
</div>
|
||||
|
||||
<div class="crud-toolbar">
|
||||
<div class="search-wrap" style="max-width:420px;flex:1;">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<circle cx="11" cy="11" r="8"/><line x1="21" y1="21" x2="16.65" y2="16.65"/>
|
||||
</svg>
|
||||
<input type="text" id="searchInput"
|
||||
placeholder="Buscar… palabras separadas por comas"
|
||||
value="{{ q }}" autocomplete="off" style="padding-right:32px;" autofocus>
|
||||
<button type="button" id="clearBtn"
|
||||
style="display:{{ 'flex' if q else 'none' }};position:absolute;right:10px;top:50%;
|
||||
transform:translateY(-50%);background:none;border:none;cursor:pointer;
|
||||
color:var(--muted);padding:4px;align-items:center;z-index:2;"
|
||||
onmouseover="this.style.color='var(--text)'"
|
||||
onmouseout="this.style.color='var(--muted)'">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor"
|
||||
stroke-width="2.5" style="pointer-events:none;display:block;">
|
||||
<line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div style="display:flex;gap:8px;align-items:center;">
|
||||
<a href="{{ url_for('viat_exportar', q=q) }}" class="btn btn-ghost" id="btnExcel" title="Exportar Excel">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<path d="M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"/>
|
||||
<polyline points="14 2 14 8 20 8"/>
|
||||
<line x1="12" y1="18" x2="12" y2="12"/>
|
||||
<line x1="9" y1="15" x2="12" y2="18"/><line x1="15" y1="15" x2="12" y2="18"/>
|
||||
</svg>
|
||||
Excel
|
||||
</a>
|
||||
<button type="button" class="btn btn-ghost" id="btnPDF" title="Imprimir PDF">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<polyline points="6 9 6 2 18 2 18 9"/>
|
||||
<path d="M6 18H4a2 2 0 01-2-2v-5a2 2 0 012-2h16a2 2 0 012 2v5a2 2 0 01-2 2h-2"/>
|
||||
<rect x="6" y="14" width="12" height="8"/>
|
||||
</svg>
|
||||
Imprimir - PDF
|
||||
</button>
|
||||
<button type="button" class="btn btn-ghost" id="btnCopiar" title="Copiar al portapapeles">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<rect x="9" y="9" width="13" height="13" rx="2"/>
|
||||
<path d="M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"/>
|
||||
</svg>
|
||||
Copiar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p id="counter" style="margin-bottom:10px;font-size:12px;color:var(--muted)">
|
||||
{{ rows|length }} registro{{ 's' if rows|length != 1 }}{% if q %} — filtrado por «{{ q }}»{% endif %}
|
||||
</p>
|
||||
|
||||
<div class="table-wrap">
|
||||
<table id="tablaViat">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Via-T</th>
|
||||
<th>M. Oficial</th>
|
||||
<th>M. Reservada</th>
|
||||
<th>Marca</th>
|
||||
<th>Modelo</th>
|
||||
<th>Población</th>
|
||||
<th>Unidad</th>
|
||||
<th>Tipo</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="tbody">
|
||||
{% include 'viat/rows.html' %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
var input = document.getElementById('searchInput');
|
||||
var tbody = document.getElementById('tbody');
|
||||
var counter = document.getElementById('counter');
|
||||
var clearBtn = document.getElementById('clearBtn');
|
||||
var timer;
|
||||
|
||||
input.addEventListener('input', function() {
|
||||
clearBtn.style.display = this.value ? 'flex' : 'none';
|
||||
clearTimeout(timer);
|
||||
timer = setTimeout(function() { buscar(input.value.trim()); }, 300);
|
||||
});
|
||||
|
||||
clearBtn.addEventListener('click', function() {
|
||||
input.value = '';
|
||||
this.style.display = 'none';
|
||||
input.focus();
|
||||
buscar('');
|
||||
});
|
||||
|
||||
function buscar(q) {
|
||||
var btnExcel = document.getElementById('btnExcel');
|
||||
if (btnExcel) {
|
||||
btnExcel.href = '{{ url_for("viat_exportar") }}?q=' + encodeURIComponent(q);
|
||||
}
|
||||
fetch('{{ url_for("viat_list") }}?q=' + encodeURIComponent(q) + '&solo_filas=1')
|
||||
.then(function(r) {
|
||||
if (r.redirected || r.url.includes('/login')) {
|
||||
window.location = '{{ url_for("login") }}'; return null;
|
||||
}
|
||||
return r.text();
|
||||
})
|
||||
.then(function(html) {
|
||||
if (!html) return;
|
||||
tbody.innerHTML = html;
|
||||
var filas = document.querySelectorAll('#tbody tr[data-id]').length;
|
||||
if (counter) {
|
||||
counter.textContent = filas + ' registro' + (filas !== 1 ? 's' : '')
|
||||
+ (q ? ' — filtrado por «' + q + '»' : '');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* ── PDF ── */
|
||||
document.getElementById('btnPDF').addEventListener('click', function() {
|
||||
var titulo = 'Listado Via-T';
|
||||
var fecha = new Date().toLocaleDateString('es-ES');
|
||||
var heads = ['Via-T','M. Oficial','M. Reservada','Marca','Modelo','Población','Unidad','Tipo'];
|
||||
var filas = '';
|
||||
document.querySelectorAll('#tablaViat tbody tr[data-id]').forEach(function(tr) {
|
||||
filas += '<tr>';
|
||||
tr.querySelectorAll('td').forEach(function(td) {
|
||||
filas += '<td>' + td.innerText.trim() + '</td>';
|
||||
});
|
||||
filas += '</tr>';
|
||||
});
|
||||
var html = `<!DOCTYPE html><html><head><meta charset="UTF-8"><title>${titulo}</title>
|
||||
<style>
|
||||
body{font-family:Arial,sans-serif;font-size:10px;color:#1a1d29;margin:20px}
|
||||
h2{font-size:14px;margin-bottom:4px}.meta{font-size:9px;color:#666;margin-bottom:14px}
|
||||
table{width:100%;border-collapse:collapse}
|
||||
th{background:#5c6ef8;color:#fff;padding:6px 7px;text-align:left;font-size:9px}
|
||||
td{padding:5px 7px;border-bottom:1px solid #e3e6ef;font-size:9px}
|
||||
tr:nth-child(even) td{background:#eef0f8}
|
||||
@media print{body{margin:10px}}
|
||||
</style></head><body>
|
||||
<h2>${titulo}</h2>
|
||||
<div class="meta">Generado el ${fecha} · ${document.querySelectorAll('#tablaViat tbody tr[data-id]').length} registros</div>
|
||||
<table><thead><tr>${heads.map(function(h){return '<th>'+h+'</th>';}).join('')}</tr></thead>
|
||||
<tbody>${filas}</tbody></table></body></html>`;
|
||||
var win = window.open('','_blank','width=1000,height=700');
|
||||
win.document.write(html); win.document.close(); win.focus();
|
||||
setTimeout(function(){ win.print(); }, 400);
|
||||
});
|
||||
|
||||
/* ── COPIAR ── */
|
||||
document.getElementById('btnCopiar').addEventListener('click', function() {
|
||||
var btn = this;
|
||||
var heads = ['Via-T','M. Oficial','M. Reservada','Marca','Modelo','Población','Unidad','Tipo'];
|
||||
var lineas = [heads.join('\t')];
|
||||
document.querySelectorAll('#tablaViat tbody tr[data-id]').forEach(function(tr) {
|
||||
var fila = [];
|
||||
tr.querySelectorAll('td').forEach(function(td) { fila.push(td.innerText.trim()); });
|
||||
lineas.push(fila.join('\t'));
|
||||
});
|
||||
var texto = lineas.join('\n');
|
||||
if (!texto.trim() || lineas.length <= 1) { alert('No hay datos para copiar.'); return; }
|
||||
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||
navigator.clipboard.writeText(texto)
|
||||
.then(function(){ mostrarCopiado(btn); })
|
||||
.catch(function(){ copiarFallback(texto, btn); });
|
||||
} else {
|
||||
copiarFallback(texto, btn);
|
||||
}
|
||||
});
|
||||
|
||||
function copiarFallback(texto, btn) {
|
||||
var ta = document.createElement('textarea');
|
||||
ta.value = texto;
|
||||
ta.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;opacity:0;';
|
||||
document.body.appendChild(ta);
|
||||
ta.focus(); ta.select(); ta.setSelectionRange(0, 99999);
|
||||
var ok = false;
|
||||
try { ok = document.execCommand('copy'); } catch(e) { ok = false; }
|
||||
document.body.removeChild(ta);
|
||||
if (ok) { mostrarCopiado(btn); }
|
||||
else { alert('No se pudo copiar automáticamente.'); }
|
||||
}
|
||||
|
||||
function mostrarCopiado(btn) {
|
||||
var orig = btn.innerHTML;
|
||||
btn.innerHTML = '<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5"><polyline points="20 6 9 17 4 12"/></svg> Copiado';
|
||||
btn.style.color = 'var(--success)'; btn.style.borderColor = 'var(--success)';
|
||||
setTimeout(function(){ btn.innerHTML = orig; btn.style.color=''; btn.style.borderColor=''; }, 2000);
|
||||
}
|
||||
|
||||
/* ── ORDENACIÓN ── */
|
||||
(function() {
|
||||
var estado = { col: -1, asc: true };
|
||||
document.querySelectorAll('#tablaViat thead th').forEach(function(th, idx) {
|
||||
th.style.cursor = 'pointer'; th.style.userSelect = 'none';
|
||||
var icon = document.createElement('span');
|
||||
icon.style.cssText = 'margin-left:5px;opacity:.3;font-size:10px;';
|
||||
icon.textContent = '⇅'; icon.className = 'sort-icon';
|
||||
th.appendChild(icon);
|
||||
th.addEventListener('click', function() {
|
||||
var filas = Array.from(document.querySelectorAll('#tablaViat tbody tr[data-id]'));
|
||||
if (!filas.length) return;
|
||||
var mismaCol = estado.col === idx;
|
||||
estado.asc = mismaCol ? !estado.asc : true; estado.col = idx;
|
||||
document.querySelectorAll('.sort-icon').forEach(function(ic){ ic.textContent='⇅'; ic.style.opacity='.3'; });
|
||||
icon.textContent = estado.asc ? '↑' : '↓'; icon.style.opacity='1'; icon.style.color='var(--accent)';
|
||||
filas.sort(function(a, b) {
|
||||
var valA = (a.querySelectorAll('td')[idx]||{innerText:''}).innerText.trim().toLowerCase();
|
||||
var valB = (b.querySelectorAll('td')[idx]||{innerText:''}).innerText.trim().toLowerCase();
|
||||
var numA = parseFloat(valA.replace(/[^0-9.-]/g,'')), numB = parseFloat(valB.replace(/[^0-9.-]/g,''));
|
||||
var r = (!isNaN(numA)&&!isNaN(numB)) ? numA-numB : valA.localeCompare(valB,'es');
|
||||
return estado.asc ? r : -r;
|
||||
});
|
||||
var tb = document.querySelector('#tablaViat tbody');
|
||||
filas.forEach(function(f){ tb.appendChild(f); });
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
{% endblock %}
|
||||
Executable
+42
@@ -0,0 +1,42 @@
|
||||
{% if rows %}
|
||||
{% for r in rows %}
|
||||
<tr data-id="{{ r['id'] }}"
|
||||
onclick="window.location='/vehiculos/{{ r['id'] }}/editar?origen=viat&q_viat={{ q|urlencode }}'"∫
|
||||
style="cursor:pointer;"
|
||||
onmouseover="this.style.background='var(--pill-bg)'"
|
||||
onmouseout="this.style.background=''">
|
||||
<td><strong>{{ r['viat'] or '—' }}</strong></td>
|
||||
<td>{{ r['m_oficial'] or '—' }}</td>
|
||||
<td>{{ r['m_reservada'] or '—' }}</td>
|
||||
<td>{{ r['marca'] or '—' }}</td>
|
||||
<td>{{ r['modelo'] or '—' }}</td>
|
||||
<td>{{ r['poblacion'] or '—' }}</td>
|
||||
<td>{{ r['unidad'] or '—' }}</td>
|
||||
<td>
|
||||
{% if r['tipo'] %}
|
||||
<span style="background:rgba(92,110,248,.12);color:var(--accent);font-size:11px;
|
||||
font-weight:600;padding:3px 9px;border-radius:20px;
|
||||
border:1px solid rgba(92,110,248,.25)">{{ r['tipo'] }}</span>
|
||||
{% else %}—{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="8">
|
||||
<div class="empty-state">
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"
|
||||
style="width:36px;height:36px;margin-bottom:10px;opacity:.3">
|
||||
<rect x="1" y="3" width="15" height="13" rx="2"/>
|
||||
<path d="M16 8h4l3 3v5h-7V8z"/>
|
||||
<circle cx="5.5" cy="18.5" r="2.5"/><circle cx="18.5" cy="18.5" r="2.5"/>
|
||||
</svg>
|
||||
{% if q %}
|
||||
No se encontraron resultados para <strong>"{{ q }}"</strong>.
|
||||
{% else %}
|
||||
No hay vehículos con Via-T registrado.
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
Reference in New Issue
Block a user