Autosave: 20260422-225218

This commit is contained in:
Flatlogic Bot 2026-04-22 22:52:20 +00:00
parent 7eb4c17bef
commit f8fadfdc8a
63 changed files with 344 additions and 115 deletions

View File

@ -232,6 +232,10 @@ h1, .h1 {
font-weight: 500; font-weight: 500;
} }
.td-pago-verificado {
background-color: #d4edda !important;
}
/* Style for the select element inside the badge */ /* Style for the select element inside the badge */
.form-select-pago { .form-select-pago {
background-color: transparent; background-color: transparent;

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 442 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 317 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 522 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 418 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 544 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 477 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 440 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 686 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 605 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 435 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 478 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 480 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 494 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 485 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 273 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

View File

@ -168,15 +168,19 @@ include 'layout_header.php';
<td><?php echo htmlspecialchars($pedido['producto']); ?></td> <td><?php echo htmlspecialchars($pedido['producto']); ?></td>
<td><?php echo htmlspecialchars($pedido['monto_total']); ?></td> <td><?php echo htmlspecialchars($pedido['monto_total']); ?></td>
<td><?php echo htmlspecialchars($pedido['monto_debe']); ?></td> <td><?php echo htmlspecialchars($pedido['monto_debe']); ?></td>
<td><?php echo htmlspecialchars($pedido['numero_operacion'] ?? 'N/A'); ?></td> <td class="editable" data-id="<?php echo $pedido['id']; ?>" data-field="numero_operacion">
<?php echo htmlspecialchars($pedido['numero_operacion'] ?? 'N/A'); ?>
</td>
<?php <?php
$canSeeClave = ($user_role !== 'Asesor' || !empty($pedido['numero_operacion'])); $canSeeClave = ($user_role !== 'Asesor' || (!empty($pedido['numero_operacion']) && !empty($pedido['banco'])));
$isEditableClave = ($user_role !== 'Asesor') ? 'editable' : ''; $isEditableClave = ($user_role !== 'Asesor') ? 'editable' : '';
?> ?>
<td class="<?php echo $isEditableClave; ?>" data-id="<?php echo $pedido['id']; ?>" data-field="clave"> <td class="<?php echo $isEditableClave; ?> clave-cell" data-id="<?php echo $pedido['id']; ?>" data-field="clave" id="clave-<?php echo $pedido['id']; ?>">
<?php echo $canSeeClave ? htmlspecialchars($pedido['clave'] ?? 'N/A') : '<i class="fas fa-eye-slash text-muted" title="Suba el número de operación para ver la clave"></i> <span class="text-muted" style="font-size: 0.8rem;">Oculto</span>'; ?> <?php echo $canSeeClave ? htmlspecialchars($pedido['clave'] ?? 'N/A') : '<i class="fas fa-eye-slash text-muted" title="Suba el número de operación y seleccione el banco para ver la clave"></i> <span class="text-muted" style="font-size: 0.8rem;">Oculto</span>'; ?>
</td>
<td class="editable-select" data-id="<?php echo $pedido['id']; ?>" data-field="banco">
<?php echo !empty($pedido['banco']) ? htmlspecialchars($pedido['banco']) : 'N/A'; ?>
</td> </td>
<td><?php echo htmlspecialchars($pedido['banco'] ?? 'N/A'); ?></td>
<td <?php if (in_array($user_role, ['Administrador', 'personal', 'Verificador de Pagos', 'Control Logistico', 'Logistica']) || strpos($user_role, 'Asesor') !== false) { echo 'class="editable-recojo" data-id="'.$pedido['id'].'" title="Doble clic para editar"'; } ?>> <td <?php if (in_array($user_role, ['Administrador', 'personal', 'Verificador de Pagos', 'Control Logistico', 'Logistica']) || strpos($user_role, 'Asesor') !== false) { echo 'class="editable-recojo" data-id="'.$pedido['id'].'" title="Doble clic para editar"'; } ?>>
<?php echo !empty($pedido['fecha_recojo']) ? htmlspecialchars($pedido['fecha_recojo']) : 'N/A'; ?> <?php echo !empty($pedido['fecha_recojo']) ? htmlspecialchars($pedido['fecha_recojo']) : 'N/A'; ?>
</td> </td>
@ -205,7 +209,7 @@ include 'layout_header.php';
N/A N/A
<?php endif; ?> <?php endif; ?>
</td> </td>
<td> <td class="<?php echo (isset($pedido['estado_pago']) && $pedido['estado_pago'] == 'Verificado') ? 'td-pago-verificado' : ''; ?>">
<?php <?php
$estado_pago_class = ''; $estado_pago_class = '';
if (isset($pedido['estado_pago'])) { if (isset($pedido['estado_pago'])) {
@ -243,12 +247,50 @@ include 'layout_header.php';
</div> </div>
<script> <script>
function updatePedidoField(pedidoId, field, value) {
fetch('update_pedido_field.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ id: pedidoId, field: field, value: value })
})
.then(response => response.json())
.then(data => {
if (data.success) {
console.log(`${field} actualizado con éxito.`);
// Si el usuario es Asesor, verificar si ahora puede ver la clave
const userRole = "<?php echo $user_role; ?>";
if (userRole === 'Asesor') {
const pedido = data.pedido;
const claveCell = document.getElementById(`clave-${pedidoId}`);
if (pedido.numero_operacion && pedido.banco) {
claveCell.innerHTML = pedido.clave || 'N/A';
} else {
claveCell.innerHTML = '<i class="fas fa-eye-slash text-muted" title="Suba el número de operación y seleccione el banco para ver la clave"></i> <span class="text-muted" style="font-size: 0.8rem;">Oculto</span>';
}
}
} else if (data.error) {
alert('Error: ' + data.error);
}
})
.catch(error => {
console.error('Error:', error);
alert('Hubo un error de conexión.');
});
}
function updateEstadoPago(pedidoId, selectElement) { function updateEstadoPago(pedidoId, selectElement) {
const estado = selectElement.value; const estado = selectElement.value;
const badge = selectElement.closest('.badge'); const badge = selectElement.closest('.badge');
const td = selectElement.closest('td');
// Guardar el estado original en caso de error // Guardar el estado original en caso de error
const originalState = Array.from(selectElement.options).find(opt => opt.defaultSelected).value; const originalOption = Array.from(selectElement.options).find(opt => opt.defaultSelected);
const originalState = originalOption ? originalOption.value : selectElement.value;
console.log(`Actualizando pedido ${pedidoId} a estado: ${estado}`);
const formData = new URLSearchParams(); const formData = new URLSearchParams();
formData.append('pedido_id', pedidoId); formData.append('pedido_id', pedidoId);
@ -261,31 +303,41 @@ function updateEstadoPago(pedidoId, selectElement) {
}, },
body: formData body: formData
}) })
.then(response => response.json()) .then(response => {
if (!response.ok) {
throw new Error('Respuesta de red no OK');
}
return response.json();
})
.then(data => { .then(data => {
if (data.success) { if (data.success) {
console.log('Estado de pago actualizado con éxito.'); console.log('Estado de pago actualizado con éxito en el servidor.');
// Actualizar color del badge dinámicamente
// Limpiar clases previas
badge.classList.remove('estado-pago-pendiente', 'estado-pago-verificado'); badge.classList.remove('estado-pago-pendiente', 'estado-pago-verificado');
td.classList.remove('td-pago-verificado');
// Aplicar nuevas clases según el estado
if (estado === 'Pendiente a verificación') { if (estado === 'Pendiente a verificación') {
badge.classList.add('estado-pago-pendiente'); badge.classList.add('estado-pago-pendiente');
} else if (estado === 'Verificado') { } else if (estado === 'Verificado') {
badge.classList.add('estado-pago-verificado'); badge.classList.add('estado-pago-verificado');
td.classList.add('td-pago-verificado');
} }
// Actualizar el estado 'selected' del <select>
// Actualizar el estado 'defaultSelected' para futuras reversiones
Array.from(selectElement.options).forEach(opt => { Array.from(selectElement.options).forEach(opt => {
opt.defaultSelected = (opt.value === estado); opt.defaultSelected = (opt.value === estado);
}); });
} else { } else {
console.error('Error del servidor:', data.message);
alert('Error: ' + (data.message || 'No se pudo actualizar el estado.')); alert('Error: ' + (data.message || 'No se pudo actualizar el estado.'));
// Revertir el <select> al estado original
selectElement.value = originalState; selectElement.value = originalState;
} }
}) })
.catch(error => { .catch(error => {
console.error('Error:', error); console.error('Error de conexión:', error);
alert('Hubo un error de conexión al intentar actualizar el estado.'); alert('Hubo un error de conexión al intentar actualizar el estado.');
// Revertir el <select> al estado original
selectElement.value = originalState; selectElement.value = originalState;
}); });
} }
@ -297,92 +349,140 @@ document.addEventListener('DOMContentLoaded', function() {
if (authorizedRoles.includes(userRole) || userRole.includes('Asesor')) { if (authorizedRoles.includes(userRole) || userRole.includes('Asesor')) {
const table = document.querySelector('.table'); const table = document.querySelector('.table');
table.addEventListener('dblclick', function(e) { table.addEventListener('dblclick', function(e) {
const cell = e.target.closest('.editable-recojo, .editable'); const cell = e.target.closest('.editable-recojo, .editable, .editable-select');
if (!cell) return; if (!cell) return;
// Evitar doble edición si ya hay un input // Evitar doble edición si ya hay un input o select
if (cell.querySelector('input')) { if (cell.querySelector('input, select')) {
return; return;
} }
const originalText = cell.textContent.trim() === 'N/A' ? '' : cell.textContent.trim(); const originalText = cell.textContent.trim() === 'N/A' || cell.textContent.trim() === 'Seleccionar' ? '' : cell.textContent.trim();
const pedidoId = cell.dataset.id; const pedidoId = cell.dataset.id;
const field = cell.dataset.field; const field = cell.dataset.field;
cell.innerHTML = `<input type="text" class="form-control form-control-sm" value="${originalText}">`; if (cell.classList.contains('editable-select')) {
const input = cell.querySelector('input'); const bancos = ['YAPE', 'PLIN', 'BCP', 'INTERBANK', 'BANCO DE LA NACION', 'BBVA'];
let options = '<option value="">Seleccionar</option>';
bancos.forEach(b => {
options += `<option value="${b}" ${originalText === b ? 'selected' : ''}>${b}</option>`;
});
cell.innerHTML = `<select class="form-select form-select-sm">${options}</select>`;
const select = cell.querySelector('select');
select.focus();
input.focus(); const saveSelectChanges = function() {
const newValue = select.value;
cell.innerHTML = newValue === '' ? 'N/A' : newValue;
if (newValue === originalText) return;
updatePedidoField(pedidoId, field, newValue);
};
const saveChanges = function() { select.addEventListener('blur', saveSelectChanges);
const newValue = input.value.trim(); select.addEventListener('change', function() {
select.blur();
});
// Reemplazar el input con el texto select.addEventListener('keydown', function(e) {
cell.innerHTML = newValue === '' ? 'N/A' : newValue; if (e.key === 'Escape') {
select.removeEventListener('blur', saveSelectChanges);
// Si el valor no ha cambiado, no hacer nada
if (newValue === originalText) {
return;
}
if (cell.classList.contains('editable-recojo')) {
const formData = new URLSearchParams();
formData.append('id', pedidoId);
formData.append('fecha_recojo', newValue);
fetch('update_recojo.php', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: formData
})
.then(response => response.json())
.then(data => {
if (!data.success) {
console.error('Error al guardar:', data.message);
cell.innerHTML = originalText === '' ? 'N/A' : originalText; // Revertir en caso de error
alert('No se pudo guardar el cambio. Por favor, inténtalo de nuevo.');
}
})
.catch(error => {
console.error('Error de red:', error);
cell.innerHTML = originalText === '' ? 'N/A' : originalText; // Revertir en caso de error
alert('Error de conexión. No se pudo guardar el cambio.');
});
} else if (field === 'clave') {
fetch('update_clave.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ id: pedidoId, value: newValue })
})
.then(response => response.json())
.then(data => {
if (data.error) {
console.error('Error al guardar:', data.error);
cell.innerHTML = originalText === '' ? 'N/A' : originalText;
alert('Error: ' + data.error);
}
})
.catch(error => {
console.error('Error de red:', error);
cell.innerHTML = originalText === '' ? 'N/A' : originalText; cell.innerHTML = originalText === '' ? 'N/A' : originalText;
alert('Error de conexión.'); }
}); });
} } else {
}; cell.innerHTML = `<input type="text" class="form-control form-control-sm" value="${originalText}">`;
const input = cell.querySelector('input');
input.addEventListener('blur', saveChanges); input.focus();
input.addEventListener('keydown', function(e) {
if (e.key === 'Enter') { const saveChanges = function() {
input.blur(); // Dispara el evento blur para guardar const newValue = input.value.trim();
} else if (e.key === 'Escape') {
input.removeEventListener('blur', saveChanges); // Evitar que se guarde // Reemplazar el input con el texto
cell.innerHTML = originalText === '' ? 'N/A' : originalText; cell.innerHTML = newValue === '' ? 'N/A' : newValue;
}
}); // Si el valor no ha cambiado, no hacer nada
if (newValue === originalText) {
return;
}
if (cell.classList.contains('editable-recojo')) {
const formData = new URLSearchParams();
formData.append('id', pedidoId);
formData.append('fecha_recojo', newValue);
fetch('update_recojo.php', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: formData
})
.then(response => response.json())
.then(data => {
if (!data.success) {
console.error('Error al guardar:', data.message);
cell.innerHTML = originalText === '' ? 'N/A' : originalText; // Revertir en caso de error
alert('No se pudo guardar el cambio. Por favor, inténtalo de nuevo.');
}
})
.catch(error => {
console.error('Error de red:', error);
cell.innerHTML = originalText === '' ? 'N/A' : originalText; // Revertir en caso de error
alert('Error de conexión. No se pudo guardar el cambio.');
});
} // Cierre de if (cell.classList.contains('editable-recojo'))
if (field === 'clave' || field === 'numero_operacion') {
if (field === 'numero_operacion' && newValue !== '' && newValue.length < 6) {
alert('El número de operación debe tener al menos 6 dígitos.');
cell.innerHTML = originalText === '' ? 'N/A' : originalText;
return;
}
fetch('update_pedido_field.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ id: pedidoId, field: field, value: newValue })
})
.then(response => response.json())
.then(data => {
if (data.success) {
// Si es numero_operacion y es Asesor, verificar visibilidad de clave
if (field === 'numero_operacion' && userRole === 'Asesor') {
const pedido = data.pedido;
const claveCell = document.getElementById(`clave-${pedidoId}`);
if (pedido.numero_operacion && pedido.banco) {
claveCell.innerHTML = pedido.clave || 'N/A';
} else {
claveCell.innerHTML = '<i class="fas fa-eye-slash text-muted" title="Suba el número de operación y seleccione el banco para ver la clave"></i> <span class="text-muted" style="font-size: 0.8rem;">Oculto</span>';
}
}
} else if (data.error) {
console.error('Error al guardar:', data.error);
cell.innerHTML = originalText === '' ? 'N/A' : originalText;
alert('Error: ' + data.error);
}
})
.catch(error => {
console.error('Error de red:', error);
cell.innerHTML = originalText === '' ? 'N/A' : originalText;
alert('Error de conexión.');
});
}
};
input.addEventListener('blur', saveChanges);
input.addEventListener('keydown', function(e) {
if (e.key === 'Enter') {
input.blur(); // Dispara el evento blur para guardar
} else if (e.key === 'Escape') {
input.removeEventListener('blur', saveChanges); // Evitar que se guarde
cell.innerHTML = originalText === '' ? 'N/A' : originalText;
}
});
}
}); });
} }
}); });

View File

@ -0,0 +1,2 @@
-- Migration: Add asesor to operaciones_provincia
ALTER TABLE operaciones_provincia ADD COLUMN asesor VARCHAR(255) AFTER fecha_completado;

View File

@ -185,11 +185,11 @@ include 'layout_header.php';
<td class="editable" data-id="<?php echo $pedido['id']; ?>" data-field="codigo_rastreo"><?php echo htmlspecialchars($pedido['codigo_rastreo'] ?? 'N/A'); ?></td> <td class="editable" data-id="<?php echo $pedido['id']; ?>" data-field="codigo_rastreo"><?php echo htmlspecialchars($pedido['codigo_rastreo'] ?? 'N/A'); ?></td>
<td class="editable" data-id="<?php echo $pedido['id']; ?>" data-field="codigo_tracking"><?php echo htmlspecialchars($pedido['codigo_tracking'] ?? 'N/A'); ?></td> <td class="editable" data-id="<?php echo $pedido['id']; ?>" data-field="codigo_tracking"><?php echo htmlspecialchars($pedido['codigo_tracking'] ?? 'N/A'); ?></td>
<?php <?php
$canSeeClave = ($user_role !== 'Asesor' || !empty($pedido['numero_operacion'])); $canSeeClave = ($user_role !== 'Asesor' || (!empty($pedido['numero_operacion']) && !empty($pedido['banco'])));
$isEditableClave = ($user_role !== 'Asesor') ? 'editable' : ''; $isEditableClave = ($user_role !== 'Asesor') ? 'editable' : '';
?> ?>
<td class="<?php echo $isEditableClave; ?>" data-id="<?php echo $pedido['id']; ?>" data-field="clave"> <td class="<?php echo $isEditableClave; ?>" data-id="<?php echo $pedido['id']; ?>" data-field="clave">
<?php echo $canSeeClave ? htmlspecialchars($pedido['clave'] ?? 'N/A') : '<i class="fas fa-eye-slash text-muted" title="Suba el número de operación para ver la clave"></i> <span class="text-muted" style="font-size: 0.8rem;">Oculto</span>'; ?> <?php echo $canSeeClave ? htmlspecialchars($pedido['clave'] ?? 'N/A') : '<i class="fas fa-eye-slash text-muted" title="Suba el número de operación y seleccione el banco para ver la clave"></i> <span class="text-muted" style="font-size: 0.8rem;">Oculto</span>'; ?>
</td> </td>
<td class="editable-pendientes" data-id="<?php echo $pedido['id']; ?>" data-value="<?php echo htmlspecialchars($pedido['pendientes'] ?? ''); ?>" style="cursor: pointer;"> <td class="editable-pendientes" data-id="<?php echo $pedido['id']; ?>" data-value="<?php echo htmlspecialchars($pedido['pendientes'] ?? ''); ?>" style="cursor: pointer;">
<span class="badge" style="<?php echo getPendientesStyle($pedido['pendientes'] ?? ''); ?>"> <span class="badge" style="<?php echo getPendientesStyle($pedido['pendientes'] ?? ''); ?>">

View File

@ -188,11 +188,12 @@ include 'layout_header.php';
<td><?php echo htmlspecialchars($pedido['monto_debe']); ?></td> <td><?php echo htmlspecialchars($pedido['monto_debe']); ?></td>
<td><?php echo htmlspecialchars($pedido['numero_operacion'] ?? 'N/A'); ?></td> <td><?php echo htmlspecialchars($pedido['numero_operacion'] ?? 'N/A'); ?></td>
<?php <?php
$canSeeClave = ($user_role !== 'Asesor' || !empty($pedido['numero_operacion'])); $canSeeClave = ($user_role !== 'Asesor' || (!empty($pedido['numero_operacion']) && !empty($pedido['banco'])));
?> $isEditableClave = ($user_role !== 'Asesor') ? 'editable' : '';
<td> ?>
<?php echo $canSeeClave ? htmlspecialchars($pedido['clave'] ?? 'N/A') : '<i class="fas fa-eye-slash text-muted" title="Suba el número de operación para ver la clave"></i> <span class="text-muted" style="font-size: 0.8rem;">Oculto</span>'; ?> <td class="<?php echo $isEditableClave; ?>" data-id="<?php echo $pedido['id']; ?>" data-field="clave">
</td> <?php echo $canSeeClave ? htmlspecialchars($pedido['clave'] ?? 'N/A') : '<i class="fas fa-eye-slash text-muted" title="Suba el número de operación y seleccione el banco para ver la clave"></i> <span class="text-muted" style="font-size: 0.8rem;">Oculto</span>'; ?>
</td>
<td class="editable-recojo" data-id="<?php echo $pedido['id']; ?>" style="background-color: #d4edda; font-weight: bold;"> <td class="editable-recojo" data-id="<?php echo $pedido['id']; ?>" style="background-color: #d4edda; font-weight: bold;">
<span class="text" title="Doble clic para editar"><?php echo !empty($pedido['fecha_recojo']) ? htmlspecialchars($pedido['fecha_recojo']) : 'N/A'; ?></span> <span class="text" title="Doble clic para editar"><?php echo !empty($pedido['fecha_recojo']) ? htmlspecialchars($pedido['fecha_recojo']) : 'N/A'; ?></span>
<input type="text" class="form-control edit-input" style="display: none;" value="<?php echo htmlspecialchars($pedido['fecha_recojo'] ?? ''); ?>"> <input type="text" class="form-control edit-input" style="display: none;" value="<?php echo htmlspecialchars($pedido['fecha_recojo'] ?? ''); ?>">

View File

@ -106,13 +106,14 @@ try {
<th>Nro. Operación</th> <th>Nro. Operación</th>
<th>Banco</th> <th>Banco</th>
<th>Fecha Completado</th> <th>Fecha Completado</th>
<th>Asesor</th>
<th>Acciones</th> <th>Acciones</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php if (empty($operaciones)): ?> <?php if (empty($operaciones)): ?>
<tr class="no-data"> <tr class="no-data">
<td colspan="10" class="text-center py-4 text-muted">No hay operaciones registradas para esta fecha.</td> <td colspan="11" class="text-center py-4 text-muted">No hay operaciones registradas para esta fecha.</td>
</tr> </tr>
<?php else: ?> <?php else: ?>
<?php foreach ($operaciones as $op): ?> <?php foreach ($operaciones as $op): ?>
@ -135,6 +136,7 @@ try {
} }
} }
?></td> ?></td>
<td contenteditable="true" data-column="asesor"><?php echo htmlspecialchars($op['asesor'] ?? ''); ?></td>
<td class="text-center"> <td class="text-center">
<button class="btn btn-outline-danger btn-sm delete-row"> <button class="btn btn-outline-danger btn-sm delete-row">
<i class="fas fa-trash"></i> <i class="fas fa-trash"></i>
@ -200,6 +202,7 @@ document.addEventListener('DOMContentLoaded', function() {
<td contenteditable="true" data-column="nro_operacion"></td> <td contenteditable="true" data-column="nro_operacion"></td>
<td contenteditable="true" data-column="banco"></td> <td contenteditable="true" data-column="banco"></td>
<td contenteditable="true" data-column="fecha_completado">${currentDateTime}</td> <td contenteditable="true" data-column="fecha_completado">${currentDateTime}</td>
<td contenteditable="true" data-column="asesor"></td>
<td class="text-center"> <td class="text-center">
<button class="btn btn-outline-danger btn-sm delete-row"> <button class="btn btn-outline-danger btn-sm delete-row">
<i class="fas fa-trash"></i> <i class="fas fa-trash"></i>
@ -270,7 +273,7 @@ document.addEventListener('DOMContentLoaded', function() {
row.remove(); row.remove();
updateSummary(); updateSummary();
if (tbody.children.length === 0) { if (tbody.children.length === 0) {
tbody.innerHTML = '<tr class="no-data"><td colspan="10" class="text-center py-4 text-muted">No hay operaciones registradas para esta fecha.</td></tr>'; tbody.innerHTML = '<tr class="no-data"><td colspan="11" class="text-center py-4 text-muted">No hay operaciones registradas para esta fecha.</td></tr>';
} }
} else { } else {
alert('Error al eliminar: ' + data.message); alert('Error al eliminar: ' + data.message);

View File

@ -154,7 +154,7 @@ include 'layout_header.php';
<i class="bi bi-eye"></i> 👁️ <i class="bi bi-eye"></i> 👁️
</button> </button>
</div> </div>
<small class="text-muted">Ingresa un número de operación válido para ver la clave.</small> <small class="text-muted">Ingresa un número de operación válido y selecciona el banco para ver la clave.</small>
</div> </div>
<div class="col-md-6 mb-3"> <div class="col-md-6 mb-3">
<label for="pendientes" class="form-label">Pendientes</label> <label for="pendientes" class="form-label">Pendientes</label>
@ -209,7 +209,7 @@ include 'layout_header.php';
<?php endif; ?> <?php endif; ?>
<div class="col-md-3 mb-3"> <div class="col-md-3 mb-3">
<label for="numero_operacion" class="form-label">Número de Operación</label> <label for="numero_operacion" class="form-label">Número de Operación</label>
<input type="text" class="form-control" id="numero_operacion" name="numero_operacion" value="<?php echo htmlspecialchars($pedido['numero_operacion'] ?? ''); ?>"> <input type="text" class="form-control" id="numero_operacion" name="numero_operacion" value="<?php echo htmlspecialchars($pedido['numero_operacion'] ?? ''); ?>" minlength="6">
<div id="operacion-feedback" class="form-text"></div> <div id="operacion-feedback" class="form-text"></div>
</div> </div>
<div class="col-md-3 mb-3"> <div class="col-md-3 mb-3">
@ -276,6 +276,7 @@ include 'layout_header.php';
<script> <script>
document.addEventListener('DOMContentLoaded', function() { document.addEventListener('DOMContentLoaded', function() {
const numeroOperacionInput = document.getElementById('numero_operacion'); const numeroOperacionInput = document.getElementById('numero_operacion');
const bancoInput = document.getElementById('banco');
const operacionFeedback = document.getElementById('operacion-feedback'); const operacionFeedback = document.getElementById('operacion-feedback');
const claveInput = document.getElementById('clave'); const claveInput = document.getElementById('clave');
const toggleClaveBtn = document.getElementById('toggleClave'); const toggleClaveBtn = document.getElementById('toggleClave');
@ -284,6 +285,7 @@ document.addEventListener('DOMContentLoaded', function() {
function validateOperacion() { function validateOperacion() {
const value = numeroOperacionInput.value.trim(); const value = numeroOperacionInput.value.trim();
const bancoValue = bancoInput.value;
if (value === '') { if (value === '') {
operacionFeedback.innerHTML = ''; operacionFeedback.innerHTML = '';
@ -293,6 +295,16 @@ document.addEventListener('DOMContentLoaded', function() {
return; return;
} }
if (value.length < 6) {
operacionFeedback.innerHTML = '<span class="text-danger">⚠️ El número debe tener al menos 6 dígitos</span>';
numeroOperacionInput.classList.add('is-invalid');
numeroOperacionInput.classList.remove('is-valid');
toggleClaveBtn.disabled = true;
claveInput.type = 'password';
submitBtn.disabled = true;
return;
}
fetch(`check_duplicate_operation.php?numero_operacion=${encodeURIComponent(value)}&pedido_id=${pedidoId}`) fetch(`check_duplicate_operation.php?numero_operacion=${encodeURIComponent(value)}&pedido_id=${pedidoId}`)
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
@ -307,7 +319,14 @@ document.addEventListener('DOMContentLoaded', function() {
operacionFeedback.innerHTML = '<span class="text-success">✅ Número disponible</span>'; operacionFeedback.innerHTML = '<span class="text-success">✅ Número disponible</span>';
numeroOperacionInput.classList.remove('is-invalid'); numeroOperacionInput.classList.remove('is-invalid');
numeroOperacionInput.classList.add('is-valid'); numeroOperacionInput.classList.add('is-valid');
toggleClaveBtn.disabled = false;
// Solo habilitar si también hay banco seleccionado
if (bancoValue !== '') {
toggleClaveBtn.disabled = false;
} else {
toggleClaveBtn.disabled = true;
claveInput.type = 'password';
}
submitBtn.disabled = false; submitBtn.disabled = false;
} }
}) })
@ -317,6 +336,7 @@ document.addEventListener('DOMContentLoaded', function() {
} }
numeroOperacionInput.addEventListener('input', validateOperacion); numeroOperacionInput.addEventListener('input', validateOperacion);
bancoInput.addEventListener('change', validateOperacion);
// Run validation on load if there's a value // Run validation on load if there's a value
if (numeroOperacionInput.value.trim() !== '') { if (numeroOperacionInput.value.trim() !== '') {

View File

@ -187,11 +187,11 @@ include 'layout_header.php';
<td class="editable" data-id="<?php echo $pedido['id']; ?>" data-field="codigo_rastreo"><?php echo htmlspecialchars($pedido['codigo_rastreo'] ?? 'N/A'); ?></td> <td class="editable" data-id="<?php echo $pedido['id']; ?>" data-field="codigo_rastreo"><?php echo htmlspecialchars($pedido['codigo_rastreo'] ?? 'N/A'); ?></td>
<td class="editable" data-id="<?php echo $pedido['id']; ?>" data-field="codigo_tracking"><?php echo htmlspecialchars($pedido['codigo_tracking'] ?? 'N/A'); ?></td> <td class="editable" data-id="<?php echo $pedido['id']; ?>" data-field="codigo_tracking"><?php echo htmlspecialchars($pedido['codigo_tracking'] ?? 'N/A'); ?></td>
<?php <?php
$canSeeClave = ($user_role !== 'Asesor' || !empty($pedido['numero_operacion'])); $canSeeClave = ($user_role !== 'Asesor' || (!empty($pedido['numero_operacion']) && !empty($pedido['banco'])));
$isEditableClave = ($user_role !== 'Asesor') ? 'editable' : ''; $isEditableClave = ($user_role !== 'Asesor') ? 'editable' : '';
?> ?>
<td class="<?php echo $isEditableClave; ?>" data-id="<?php echo $pedido['id']; ?>" data-field="clave"> <td class="<?php echo $isEditableClave; ?>" data-id="<?php echo $pedido['id']; ?>" data-field="clave">
<?php echo $canSeeClave ? htmlspecialchars($pedido['clave'] ?? 'N/A') : '<i class="fas fa-eye-slash text-muted" title="Suba el número de operación para ver la clave"></i> <span class="text-muted" style="font-size: 0.8rem;">Oculto</span>'; ?> <?php echo $canSeeClave ? htmlspecialchars($pedido['clave'] ?? 'N/A') : '<i class="fas fa-eye-slash text-muted" title="Suba el número de operación y seleccione el banco para ver la clave"></i> <span class="text-muted" style="font-size: 0.8rem;">Oculto</span>'; ?>
</td> </td>
<td><span class="badge" style="<?php echo getStatusStyle($pedido['estado']); ?>"><?php echo ($pedido['estado'] == 'Gestion') ? 'GESTIONES ⚙️' : htmlspecialchars($pedido['estado']); ?></span></td> <td><span class="badge" style="<?php echo getStatusStyle($pedido['estado']); ?>"><?php echo ($pedido['estado'] == 'Gestion') ? 'GESTIONES ⚙️' : htmlspecialchars($pedido['estado']); ?></span></td>
<?php if ($user_role !== 'Asesor'): ?><td><?php echo htmlspecialchars($pedido['asesor_nombre'] ?? 'N/A'); ?></td><?php endif; ?> <?php if ($user_role !== 'Asesor'): ?><td><?php echo htmlspecialchars($pedido['asesor_nombre'] ?? 'N/A'); ?></td><?php endif; ?>

View File

@ -203,7 +203,7 @@ include 'layout_header.php';
<?php endif; ?> <?php endif; ?>
<div class="col-md-3 mb-3"> <div class="col-md-3 mb-3">
<label for="numero_operacion" class="form-label">Número de Operación</label> <label for="numero_operacion" class="form-label">Número de Operación</label>
<input type="text" class="form-control" id="numero_operacion" name="numero_operacion" value="<?php echo htmlspecialchars($pedido['numero_operacion'] ?? ''); ?>"> <input type="text" class="form-control" id="numero_operacion" name="numero_operacion" value="<?php echo htmlspecialchars($pedido['numero_operacion'] ?? ''); ?>" minlength="6">
<div id="operacion-feedback" class="form-text"></div> <div id="operacion-feedback" class="form-text"></div>
</div> </div>
<div class="col-md-3 mb-3"> <div class="col-md-3 mb-3">
@ -262,6 +262,14 @@ document.addEventListener('DOMContentLoaded', function() {
return; return;
} }
if (value.length < 6) {
operacionFeedback.innerHTML = '<span class="text-danger">⚠️ El número debe tener al menos 6 dígitos</span>';
numeroOperacionInput.classList.add('is-invalid');
numeroOperacionInput.classList.remove('is-valid');
submitBtn.disabled = true;
return;
}
fetch(`check_duplicate_operation.php?numero_operacion=${encodeURIComponent(value)}&pedido_id=${pedidoId}`) fetch(`check_duplicate_operation.php?numero_operacion=${encodeURIComponent(value)}&pedido_id=${pedidoId}`)
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {

View File

@ -274,11 +274,11 @@ include 'layout_header.php';
<td><?php echo htmlspecialchars($pedido['codigo_rastreo'] ?? 'N/A'); ?></td> <td><?php echo htmlspecialchars($pedido['codigo_rastreo'] ?? 'N/A'); ?></td>
<td class="editable" data-id="<?php echo $pedido['id']; ?>" data-field="codigo_tracking"><?php echo htmlspecialchars($pedido['codigo_tracking'] ?? 'N/A'); ?></td> <td class="editable" data-id="<?php echo $pedido['id']; ?>" data-field="codigo_tracking"><?php echo htmlspecialchars($pedido['codigo_tracking'] ?? 'N/A'); ?></td>
<?php <?php
$canSeeClave = ($user_role !== 'Asesor' || !empty($pedido['numero_operacion'])); $canSeeClave = ($user_role !== 'Asesor' || (!empty($pedido['numero_operacion']) && !empty($pedido['banco'])));
$isEditableClave = ($user_role !== 'Asesor') ? 'editable' : ''; $isEditableClave = ($user_role !== 'Asesor') ? 'editable' : '';
?> ?>
<td class="<?php echo $isEditableClave; ?>" data-id="<?php echo $pedido['id']; ?>" data-field="clave"> <td class="<?php echo $isEditableClave; ?>" data-id="<?php echo $pedido['id']; ?>" data-field="clave">
<?php echo $canSeeClave ? htmlspecialchars($pedido['clave'] ?? 'N/A') : '<i class="fas fa-eye-slash text-muted" title="Suba el número de operación para ver la clave"></i> <span class="text-muted" style="font-size: 0.8rem;">Oculto</span>'; ?> <?php echo $canSeeClave ? htmlspecialchars($pedido['clave'] ?? 'N/A') : '<i class="fas fa-eye-slash text-muted" title="Suba el número de operación y seleccione el banco para ver la clave"></i> <span class="text-muted" style="font-size: 0.8rem;">Oculto</span>'; ?>
</td> </td>
<td><span class="badge" style="<?php echo getStatusStyle($pedido['estado']); ?>"><?php echo ($pedido['estado'] == 'Gestion') ? 'GESTIONES ⚙️' : htmlspecialchars($pedido['estado']); ?></span></td> <td><span class="badge" style="<?php echo getStatusStyle($pedido['estado']); ?>"><?php echo ($pedido['estado'] == 'Gestion') ? 'GESTIONES ⚙️' : htmlspecialchars($pedido['estado']); ?></span></td>
<td id="live-status-<?php echo $pedido['id']; ?>"><span class="badge bg-light text-dark">Pendiente</span></td> <td id="live-status-<?php echo $pedido['id']; ?>"><span class="badge bg-light text-dark">Pendiente</span></td>

View File

@ -38,7 +38,7 @@ try {
$allowed_columns = [ $allowed_columns = [
'cliente', 'celular', 'producto', 'monto_total', 'cliente', 'celular', 'producto', 'monto_total',
'monto_debe', 'nro_operacion', 'banco', 'fecha_completado' 'monto_debe', 'nro_operacion', 'banco', 'fecha_completado', 'asesor'
]; ];
if (!in_array($column, $allowed_columns)) { if (!in_array($column, $allowed_columns)) {

View File

@ -96,6 +96,17 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
exit; exit;
} }
// Check for minimum length of operation number
if (!empty($numero_operacion) && strlen($numero_operacion) < 6) {
$error_message = urlencode("El número de operación debe tener al menos 6 dígitos.");
$redirect_url = 'pedido_form.php?error=' . $error_message;
if ($id) {
$redirect_url .= '&id=' . $id;
}
header('Location: ' . $redirect_url);
exit;
}
// Check for duplicate operation number // Check for duplicate operation number
if (!empty($numero_operacion)) { if (!empty($numero_operacion)) {
$check_sql = "SELECT id FROM pedidos WHERE numero_operacion = ? AND id != ?"; $check_sql = "SELECT id FROM pedidos WHERE numero_operacion = ? AND id != ?";
@ -180,12 +191,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$sql_parts[] = "fecha_completado = NOW()"; $sql_parts[] = "fecha_completado = NOW()";
// --- NEW: Insert into operaciones_provincia --- // --- NEW: Insert into operaciones_provincia ---
$stmt_p = $pdo->prepare("SELECT * FROM pedidos WHERE id = ?"); $stmt_p = $pdo->prepare("SELECT p.*, u.nombre_asesor FROM pedidos p LEFT JOIN users u ON p.asesor_id = u.id WHERE p.id = ?");
$stmt_p->execute([$id]); $stmt_p->execute([$id]);
$p_data = $stmt_p->fetch(PDO::FETCH_ASSOC); $p_data = $stmt_p->fetch(PDO::FETCH_ASSOC);
if ($p_data) { if ($p_data) {
$stmt_op = $pdo->prepare("INSERT INTO operaciones_provincia (pedido_id, cliente, celular, producto, monto_total, monto_debe, nro_operacion, banco, fecha_completado) VALUES (?, ?, ?, ?, ?, ?, ?, ?, NOW())"); $stmt_op = $pdo->prepare("INSERT INTO operaciones_provincia (pedido_id, cliente, celular, producto, monto_total, monto_debe, nro_operacion, banco, fecha_completado, asesor) VALUES (?, ?, ?, ?, ?, ?, ?, ?, NOW(), ?)");
$stmt_op->execute([ $stmt_op->execute([
$id, $id,
$p_data['nombre_completo'], $p_data['nombre_completo'],
@ -194,7 +205,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$p_data['monto_total'], $p_data['monto_total'],
$p_data['monto_debe'], $p_data['monto_debe'],
$numero_operacion, $numero_operacion,
$banco $banco,
$p_data['nombre_asesor']
]); ]);
} }
// --- End of NEW --- // --- End of NEW ---
@ -233,7 +245,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// --- NEW: Insert into operaciones_provincia if completed --- // --- NEW: Insert into operaciones_provincia if completed ---
if (in_array($estado, $completed_states)) { if (in_array($estado, $completed_states)) {
$stmt_op = $pdo->prepare("INSERT INTO operaciones_provincia (pedido_id, cliente, celular, producto, monto_total, monto_debe, nro_operacion, banco, fecha_completado) VALUES (?, ?, ?, ?, ?, ?, ?, ?, NOW())"); $stmt_u = $pdo->prepare("SELECT nombre_asesor FROM users WHERE id = ?");
$stmt_u->execute([$_SESSION['user_id']]);
$nombre_asesor = $stmt_u->fetchColumn();
$stmt_op = $pdo->prepare("INSERT INTO operaciones_provincia (pedido_id, cliente, celular, producto, monto_total, monto_debe, nro_operacion, banco, fecha_completado, asesor) VALUES (?, ?, ?, ?, ?, ?, ?, ?, NOW(), ?)");
$stmt_op->execute([ $stmt_op->execute([
$new_id, $new_id,
$nombre_completo, $nombre_completo,
@ -242,7 +258,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$monto_total, $monto_total,
$monto_debe, $monto_debe,
$numero_operacion, $numero_operacion,
$banco $banco,
$nombre_asesor
]); ]);
} }
// --- End of NEW --- // --- End of NEW ---

View File

@ -62,6 +62,14 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
exit; exit;
} }
// Check for minimum length of operation number
if (!empty($numero_operacion) && strlen($numero_operacion) < 6) {
$error_message = urlencode("El número de operación debe tener al menos 6 dígitos.");
$id_param = $id ? '&id=' . $id : '';
header('Location: pedidos_contraentrega.php?error=' . $error_message . $id_param);
exit;
}
// Check for duplicate operation number // Check for duplicate operation number
if (!empty($numero_operacion)) { if (!empty($numero_operacion)) {
$check_sql = "SELECT id FROM pedidos WHERE numero_operacion = ? AND id != ?"; $check_sql = "SELECT id FROM pedidos WHERE numero_operacion = ? AND id != ?";

View File

@ -16,17 +16,17 @@ if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
// Get input data // Get input data
$pedido_id = $_POST['pedido_id'] ?? null; $pedido_id = $_POST['pedido_id'] ?? null;
$estado_pago = $_POST['estado_pago'] ?? null; $estado_pago = isset($_POST['estado_pago']) ? trim($_POST['estado_pago']) : null;
// Validate input // Validate input
if (empty($pedido_id) || empty($estado_pago)) { if (empty($pedido_id) || empty($estado_pago)) {
echo json_encode(['success' => false, 'message' => 'Datos incompletos.']); echo json_encode(['success' => false, 'message' => 'Datos incompletos. ID: ' . $pedido_id . ', Estado: ' . $estado_pago]);
exit; exit;
} }
$allowed_statuses = ['Pendiente a verificación', 'Verificado']; $allowed_statuses = ['Pendiente a verificación', 'Verificado'];
if (!in_array($estado_pago, $allowed_statuses)) { if (!in_array($estado_pago, $allowed_statuses)) {
echo json_encode(['success' => false, 'message' => 'Estado no válido.']); echo json_encode(['success' => false, 'message' => 'Estado no válido: ' . $estado_pago]);
exit; exit;
} }
@ -36,9 +36,9 @@ try {
$pdo = db(); $pdo = db();
$sql = "UPDATE pedidos SET estado_pago = ? WHERE id = ?"; $sql = "UPDATE pedidos SET estado_pago = ? WHERE id = ?";
$stmt = $pdo->prepare($sql); $stmt = $pdo->prepare($sql);
$success = $stmt->execute([$estado_pago, $pedido_id]); $stmt->execute([$estado_pago, $pedido_id]);
if ($success) { if ($stmt->rowCount() >= 0) { // rowCount can be 0 if the value didn't change
echo json_encode(['success' => true, 'message' => 'Estado de pago actualizado.']); echo json_encode(['success' => true, 'message' => 'Estado de pago actualizado.']);
} else { } else {
echo json_encode(['success' => false, 'message' => 'No se pudo actualizar la base de datos.']); echo json_encode(['success' => false, 'message' => 'No se pudo actualizar la base de datos.']);

66
update_pedido_field.php Normal file
View File

@ -0,0 +1,66 @@
<?php
session_start();
require_once 'db/config.php';
if (!isset($_SESSION['user_id'])) {
http_response_code(403);
echo json_encode(['error' => 'Acceso no autorizado.']);
exit;
}
$data = json_decode(file_get_contents('php://input'), true);
if (!$data || !isset($data['id']) || !isset($data['field']) || !isset($data['value'])) {
http_response_code(400);
echo json_encode(['error' => 'Datos incompletos.']);
exit;
}
$pedido_id = $data['id'];
$field = $data['field'];
$value = $data['value'];
// Whitelist allowed fields for security
$allowed_fields = ['numero_operacion', 'banco', 'clave', 'fecha_recojo'];
if (!in_array($field, $allowed_fields)) {
http_response_code(400);
echo json_encode(['error' => 'Campo no permitido.']);
exit;
}
try {
$pdo = db();
// If updating numero_operacion, check for duplicates (optional but good)
if ($field === 'numero_operacion' && !empty($value)) {
if (strlen($value) < 6) {
echo json_encode(['error' => 'El número de operación debe tener al menos 6 dígitos.']);
exit;
}
$stmt_check = $pdo->prepare("SELECT id FROM pedidos WHERE numero_operacion = ? AND id != ?");
$stmt_check->execute([$value, $pedido_id]);
if ($stmt_check->fetch()) {
echo json_encode(['error' => 'El número de operación ya existe en otro pedido.']);
exit;
}
}
$sql = "UPDATE pedidos SET $field = ? WHERE id = ?";
$stmt = $pdo->prepare($sql);
$stmt->execute([$value, $pedido_id]);
// Fetch the updated pedido to return relevant info (like the clave if it's now visible)
$stmt_fetch = $pdo->prepare("SELECT clave, numero_operacion, banco FROM pedidos WHERE id = ?");
$stmt_fetch->execute([$pedido_id]);
$updated_pedido = $stmt_fetch->fetch(PDO::FETCH_ASSOC);
echo json_encode([
'success' => true,
'message' => 'Campo actualizado correctamente.',
'pedido' => $updated_pedido
]);
} catch (PDOException $e) {
http_response_code(500);
echo json_encode(['error' => 'Error al actualizar la base de datos: ' . $e->getMessage()]);
}
?>