|
@@ -75,10 +75,70 @@
|
|
|
{% endif %}
|
|
{% endif %}
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+
|
|
|
|
|
+ <div class="card mb-4">
|
|
|
|
|
+ <div class="card-header bg-success text-white d-flex justify-content-between align-items-center">
|
|
|
|
|
+ <span>Gestión de Paneles Solares</span>
|
|
|
|
|
+ <button type="button" class="btn btn-light btn-sm" data-bs-toggle="modal" data-bs-target="#panelModal" onclick="setupPanelModal('new')">
|
|
|
|
|
+ + Nuevo Panel
|
|
|
|
|
+ </button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="card-body">
|
|
|
|
|
+ <h5 class="card-title">Catálogo de Paneles</h5>
|
|
|
|
|
+ {% if paneles %}
|
|
|
|
|
+ <div class="table-responsive mb-4">
|
|
|
|
|
+ <table class="table table-hover">
|
|
|
|
|
+ <thead>
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <th>Marca</th>
|
|
|
|
|
+ <th>Modelo</th>
|
|
|
|
|
+ <th>Eficiencia</th>
|
|
|
|
|
+ <th>Área (m²)</th>
|
|
|
|
|
+ <th>Precio ($)</th>
|
|
|
|
|
+ <th>Acciones</th>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ </thead>
|
|
|
|
|
+ <tbody>
|
|
|
|
|
+ {% for panel in paneles %}
|
|
|
|
|
+ <tr>
|
|
|
|
|
+ <td>{{ panel.marca }}</td>
|
|
|
|
|
+ <td>{{ panel.modelo }}</td>
|
|
|
|
|
+ <td>{{ panel.eficiencia_r }}</td>
|
|
|
|
|
+ <td>{{ panel.area_m2 }}</td>
|
|
|
|
|
+ <td>{{ panel.precio_unitario }}</td>
|
|
|
|
|
+ <td>
|
|
|
|
|
+ <div class="btn-group" role="group">
|
|
|
|
|
+ <button type="button" class="btn btn-sm btn-warning"
|
|
|
|
|
+ data-bs-toggle="modal"
|
|
|
|
|
+ data-bs-target="#panelModal"
|
|
|
|
|
+ onclick="setupPanelModal('edit', {
|
|
|
|
|
+ marca: '{{ panel.marca }}',
|
|
|
|
|
+ modelo: '{{ panel.modelo }}',
|
|
|
|
|
+ eficiencia_r: '{{ panel.eficiencia_r }}',
|
|
|
|
|
+ area_m2: '{{ panel.area_m2 }}',
|
|
|
|
|
+ precio_unitario: '{{ panel.precio_unitario }}'
|
|
|
|
|
+ }, '{{ url_for('main.editar_panel', id_panel=panel.id_panel) }}')">
|
|
|
|
|
+ Editar
|
|
|
|
|
+ </button>
|
|
|
|
|
+ <form action="{{ url_for('main.eliminar_panel', id_panel=panel.id_panel) }}" method="POST" onsubmit="return confirm('¿Estás seguro de eliminar este panel?');" style="display: inline;">
|
|
|
|
|
+ <button type="submit" class="btn btn-sm btn-danger">Eliminar</button>
|
|
|
|
|
+ </form>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </td>
|
|
|
|
|
+ </tr>
|
|
|
|
|
+ {% endfor %}
|
|
|
|
|
+ </tbody>
|
|
|
|
|
+ </table>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ {% else %}
|
|
|
|
|
+ <div class="alert alert-info mb-4">No hay paneles registrados.</div>
|
|
|
|
|
+ {% endif %}
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
-<!-- Modal -->
|
|
|
|
|
|
|
+<!-- Modal Casa -->
|
|
|
<div class="modal fade" id="casaModal" tabindex="-1" aria-labelledby="casaModalLabel" aria-hidden="true">
|
|
<div class="modal fade" id="casaModal" tabindex="-1" aria-labelledby="casaModalLabel" aria-hidden="true">
|
|
|
<div class="modal-dialog">
|
|
<div class="modal-dialog">
|
|
|
<div class="modal-content">
|
|
<div class="modal-content">
|
|
@@ -131,6 +191,45 @@
|
|
|
</div>
|
|
</div>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
+<!-- Modal Panel -->
|
|
|
|
|
+<div class="modal fade" id="panelModal" tabindex="-1" aria-labelledby="panelModalLabel" aria-hidden="true">
|
|
|
|
|
+ <div class="modal-dialog">
|
|
|
|
|
+ <div class="modal-content">
|
|
|
|
|
+ <div class="modal-header">
|
|
|
|
|
+ <h5 class="modal-title" id="panelModalLabel">Gestión de Panel Solar</h5>
|
|
|
|
|
+ <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="modal-body">
|
|
|
|
|
+ <form id="panelForm" method="POST" action="{{ url_for('main.nuevo_panel') }}">
|
|
|
|
|
+ <div class="mb-3">
|
|
|
|
|
+ <label for="marca" class="form-label">Marca</label>
|
|
|
|
|
+ <input type="text" name="marca" id="marca" class="form-control" required>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="mb-3">
|
|
|
|
|
+ <label for="modelo" class="form-label">Modelo</label>
|
|
|
|
|
+ <input type="text" name="modelo" id="modelo" class="form-control" required>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="mb-3">
|
|
|
|
|
+ <label for="eficiencia_r" class="form-label">Eficiencia (0.0 - 1.0)</label>
|
|
|
|
|
+ <input type="number" step="0.01" name="eficiencia_r" id="eficiencia_r" class="form-control" required>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="mb-3">
|
|
|
|
|
+ <label for="area_m2" class="form-label">Área (m²)</label>
|
|
|
|
|
+ <input type="number" step="0.01" name="area_m2" id="area_m2" class="form-control" required>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="mb-3">
|
|
|
|
|
+ <label for="precio_unitario" class="form-label">Precio Unitario ($)</label>
|
|
|
|
|
+ <input type="number" step="0.01" name="precio_unitario" id="precio_unitario" class="form-control" required>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="d-grid">
|
|
|
|
|
+ <button type="submit" class="btn btn-primary" id="panelModalSubmitBtn">Guardar Panel</button>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </form>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+</div>
|
|
|
|
|
+
|
|
|
<script>
|
|
<script>
|
|
|
function setupModal(mode, data, actionUrl) {
|
|
function setupModal(mode, data, actionUrl) {
|
|
|
const form = document.getElementById('casaForm');
|
|
const form = document.getElementById('casaForm');
|
|
@@ -155,5 +254,28 @@ function setupModal(mode, data, actionUrl) {
|
|
|
document.getElementById('inclinacion').value = data.inclinacion;
|
|
document.getElementById('inclinacion').value = data.inclinacion;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+function setupPanelModal(mode, data, actionUrl) {
|
|
|
|
|
+ const form = document.getElementById('panelForm');
|
|
|
|
|
+ const title = document.getElementById('panelModalLabel');
|
|
|
|
|
+ const btn = document.getElementById('panelModalSubmitBtn');
|
|
|
|
|
+
|
|
|
|
|
+ if (mode === 'new') {
|
|
|
|
|
+ title.textContent = 'Agregar Nuevo Panel';
|
|
|
|
|
+ btn.textContent = 'Guardar Panel';
|
|
|
|
|
+ form.action = "{{ url_for('main.nuevo_panel') }}";
|
|
|
|
|
+ form.reset();
|
|
|
|
|
+ } else if (mode === 'edit') {
|
|
|
|
|
+ title.textContent = 'Editar Panel';
|
|
|
|
|
+ btn.textContent = 'Actualizar Panel';
|
|
|
|
|
+ form.action = actionUrl;
|
|
|
|
|
+
|
|
|
|
|
+ document.getElementById('marca').value = data.marca;
|
|
|
|
|
+ document.getElementById('modelo').value = data.modelo;
|
|
|
|
|
+ document.getElementById('eficiencia_r').value = data.eficiencia_r;
|
|
|
|
|
+ document.getElementById('area_m2').value = data.area_m2;
|
|
|
|
|
+ document.getElementById('precio_unitario').value = data.precio_unitario;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
</script>
|
|
</script>
|
|
|
{% endblock %}
|
|
{% endblock %}
|