Add save button above payments table in luz_camara
This commit is contained in:
@@ -103,6 +103,13 @@ endif; ?>
|
|||||||
<!-- Tabla de Pagos -->
|
<!-- Tabla de Pagos -->
|
||||||
<div class="card shadow-sm">
|
<div class="card shadow-sm">
|
||||||
<div class="card-body p-0">
|
<div class="card-body p-0">
|
||||||
|
<?php if (Auth::isCapturist()): ?>
|
||||||
|
<div class="p-3 pb-0 no-print">
|
||||||
|
<button onclick="saveChanges()" id="btnSaveTable" class="btn btn-warning" disabled>
|
||||||
|
<i class="bi bi-save"></i> Guardar Cambios
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<table class="table table-bordered table-hover mb-0" id="electricityTable">
|
<table class="table table-bordered table-hover mb-0" id="electricityTable">
|
||||||
<thead class="table-dark text-center sticky-top">
|
<thead class="table-dark text-center sticky-top">
|
||||||
@@ -428,6 +435,7 @@ endforeach; ?>
|
|||||||
function updateSaveButton() {
|
function updateSaveButton() {
|
||||||
const count = Object.keys(pendingChanges).length;
|
const count = Object.keys(pendingChanges).length;
|
||||||
const btnTop = document.getElementById('btnSaveTop');
|
const btnTop = document.getElementById('btnSaveTop');
|
||||||
|
const btnTable = document.getElementById('btnSaveTable');
|
||||||
const btnBottom = document.getElementById('btnSaveBottom');
|
const btnBottom = document.getElementById('btnSaveBottom');
|
||||||
const badge = document.getElementById('changesBadge');
|
const badge = document.getElementById('changesBadge');
|
||||||
|
|
||||||
@@ -443,6 +451,11 @@ endforeach; ?>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (btnTable) {
|
||||||
|
btnTable.disabled = count === 0;
|
||||||
|
btnTable.innerHTML = `<i class="bi bi-save"></i> Guardar ${count > 0 ? count + ' ' : ''}Cambios`;
|
||||||
|
}
|
||||||
|
|
||||||
if (btnBottom) {
|
if (btnBottom) {
|
||||||
btnBottom.disabled = count === 0;
|
btnBottom.disabled = count === 0;
|
||||||
btnBottom.innerHTML = `<i class="bi bi-save"></i> Guardar ${count} Cambios`;
|
btnBottom.innerHTML = `<i class="bi bi-save"></i> Guardar ${count} Cambios`;
|
||||||
@@ -461,15 +474,21 @@ endforeach; ?>
|
|||||||
|
|
||||||
const changes = Object.values(pendingChanges);
|
const changes = Object.values(pendingChanges);
|
||||||
const btnTop = document.getElementById('btnSaveTop');
|
const btnTop = document.getElementById('btnSaveTop');
|
||||||
|
const btnTable = document.getElementById('btnSaveTable');
|
||||||
const btnBottom = document.getElementById('btnSaveBottom');
|
const btnBottom = document.getElementById('btnSaveBottom');
|
||||||
|
|
||||||
const originalTextTop = btnTop ? btnTop.innerHTML : '';
|
const originalTextTop = btnTop ? btnTop.innerHTML : '';
|
||||||
|
const originalTextTable = btnTable ? btnTable.innerHTML : '';
|
||||||
const originalTextBottom = btnBottom ? btnBottom.innerHTML : '';
|
const originalTextBottom = btnBottom ? btnBottom.innerHTML : '';
|
||||||
|
|
||||||
if (btnTop) {
|
if (btnTop) {
|
||||||
btnTop.disabled = true;
|
btnTop.disabled = true;
|
||||||
btnTop.innerHTML = '<span class="spinner-border spinner-border-sm"></span> Guardando...';
|
btnTop.innerHTML = '<span class="spinner-border spinner-border-sm"></span> Guardando...';
|
||||||
}
|
}
|
||||||
|
if (btnTable) {
|
||||||
|
btnTable.disabled = true;
|
||||||
|
btnTable.innerHTML = '<span class="spinner-border spinner-border-sm"></span> Guardando...';
|
||||||
|
}
|
||||||
if (btnBottom) {
|
if (btnBottom) {
|
||||||
btnBottom.disabled = true;
|
btnBottom.disabled = true;
|
||||||
btnBottom.innerHTML = '<span class="spinner-border spinner-border-sm"></span> Guardando...';
|
btnBottom.innerHTML = '<span class="spinner-border spinner-border-sm"></span> Guardando...';
|
||||||
@@ -494,6 +513,10 @@ endforeach; ?>
|
|||||||
btnTop.disabled = false;
|
btnTop.disabled = false;
|
||||||
btnTop.innerHTML = originalTextTop;
|
btnTop.innerHTML = originalTextTop;
|
||||||
}
|
}
|
||||||
|
if (btnTable) {
|
||||||
|
btnTable.disabled = false;
|
||||||
|
btnTable.innerHTML = originalTextTable;
|
||||||
|
}
|
||||||
if (btnBottom) {
|
if (btnBottom) {
|
||||||
btnBottom.disabled = false;
|
btnBottom.disabled = false;
|
||||||
btnBottom.innerHTML = originalTextBottom;
|
btnBottom.innerHTML = originalTextBottom;
|
||||||
|
|||||||
Reference in New Issue
Block a user