Autosave: 20260421-184252

This commit is contained in:
Flatlogic Bot 2026-04-21 18:42:52 +00:00
parent 0a1f6ad1d2
commit 5de02535d2
7 changed files with 83 additions and 30 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 404 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 KiB

View File

@ -136,6 +136,7 @@ include 'layout_header.php';
<thead> <thead>
<tr> <tr>
<th>ID</th> <th>ID</th>
<th>Clave</th>
<th>Cliente</th> <th>Cliente</th>
<th>Celular</th> <th>Celular</th>
<th>Producto</th> <th>Producto</th>
@ -156,12 +157,19 @@ include 'layout_header.php';
<tbody> <tbody>
<?php if (empty($pedidos)): ?> <?php if (empty($pedidos)): ?>
<tr> <tr>
<td colspan="15" class="text-center">No hay pedidos completados que coincidan con el filtro.</td> <td colspan="17" class="text-center">No hay pedidos completados que coincidan con el filtro.</td>
</tr> </tr>
<?php else: ?> <?php else: ?>
<?php foreach ($pedidos as $pedido): ?> <?php foreach ($pedidos as $pedido): ?>
<tr> <tr>
<td><?php echo htmlspecialchars($pedido['id']); ?></td> <td><?php echo htmlspecialchars($pedido['id']); ?></td>
<?php
$canSeeClave = ($user_role !== 'Asesor' || !empty($pedido['numero_operacion']));
$isEditableClave = ($user_role !== 'Asesor') ? 'editable' : '';
?>
<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>'; ?>
</td>
<td><?php echo htmlspecialchars($pedido['nombre_completo']); ?></td> <td><?php echo htmlspecialchars($pedido['nombre_completo']); ?></td>
<td><?php echo htmlspecialchars($pedido['celular']); ?></td> <td><?php echo htmlspecialchars($pedido['celular']); ?></td>
<td><?php echo htmlspecialchars($pedido['producto']); ?></td> <td><?php echo htmlspecialchars($pedido['producto']); ?></td>
@ -289,7 +297,7 @@ 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'); const cell = e.target.closest('.editable-recojo, .editable');
if (!cell) return; if (!cell) return;
// Evitar doble edición si ya hay un input // Evitar doble edición si ya hay un input
@ -299,6 +307,7 @@ document.addEventListener('DOMContentLoaded', function() {
const originalText = cell.textContent.trim() === 'N/A' ? '' : cell.textContent.trim(); const originalText = cell.textContent.trim() === 'N/A' ? '' : cell.textContent.trim();
const pedidoId = cell.dataset.id; const pedidoId = cell.dataset.id;
const field = cell.dataset.field;
cell.innerHTML = `<input type="text" class="form-control form-control-sm" value="${originalText}">`; cell.innerHTML = `<input type="text" class="form-control form-control-sm" value="${originalText}">`;
const input = cell.querySelector('input'); const input = cell.querySelector('input');
@ -316,30 +325,53 @@ document.addEventListener('DOMContentLoaded', function() {
return; return;
} }
const formData = new URLSearchParams(); if (cell.classList.contains('editable-recojo')) {
formData.append('id', pedidoId); const formData = new URLSearchParams();
formData.append('fecha_recojo', newValue); formData.append('id', pedidoId);
formData.append('fecha_recojo', newValue);
fetch('update_recojo.php', { fetch('update_recojo.php', {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/x-www-form-urlencoded', 'Content-Type': 'application/x-www-form-urlencoded',
}, },
body: formData body: formData
}) })
.then(response => response.json()) .then(response => response.json())
.then(data => { .then(data => {
if (!data.success) { if (!data.success) {
console.error('Error al guardar:', data.message); 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 cell.innerHTML = originalText === '' ? 'N/A' : originalText; // Revertir en caso de error
alert('No se pudo guardar el cambio. Por favor, inténtalo de nuevo.'); alert('Error de conexión. No se pudo guardar el cambio.');
} });
}) } else if (field === 'clave') {
.catch(error => { fetch('update_clave.php', {
console.error('Error de red:', error); method: 'POST',
cell.innerHTML = originalText === '' ? 'N/A' : originalText; // Revertir en caso de error headers: {
alert('Error de conexión. No se pudo guardar el cambio.'); '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;
alert('Error de conexión.');
});
}
}; };
input.addEventListener('blur', saveChanges); input.addEventListener('blur', saveChanges);

View File

@ -184,7 +184,13 @@ include 'layout_header.php';
<td><?php echo htmlspecialchars($pedido['monto_debe']); ?></td> <td><?php echo htmlspecialchars($pedido['monto_debe']); ?></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_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>
<td class="editable" data-id="<?php echo $pedido['id']; ?>" data-field="clave"><?php echo htmlspecialchars($pedido['clave'] ?? 'N/A'); ?></td> <?php
$canSeeClave = ($user_role !== 'Asesor' || !empty($pedido['numero_operacion']));
$isEditableClave = ($user_role !== 'Asesor') ? 'editable' : '';
?>
<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>'; ?>
</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'] ?? ''); ?>">
<?php echo htmlspecialchars(!empty($pedido['pendientes']) ? $pedido['pendientes'] : 'Seleccionar'); ?> <?php echo htmlspecialchars(!empty($pedido['pendientes']) ? $pedido['pendientes'] : 'Seleccionar'); ?>

View File

@ -187,7 +187,12 @@ include 'layout_header.php';
<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><?php echo htmlspecialchars($pedido['numero_operacion'] ?? 'N/A'); ?></td>
<td><?php echo htmlspecialchars($pedido['clave'] ?? 'N/A'); ?></td> <?php
$canSeeClave = ($user_role !== 'Asesor' || !empty($pedido['numero_operacion']));
?>
<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>
<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

@ -162,7 +162,6 @@ include 'layout_header.php';
<?php endif; ?> <?php endif; ?>
<th> De Orden</th> <th> De Orden</th>
<th>Codigo De Orden</th> <th>Codigo De Orden</th>
<th>Banco</th>
<th>CLAVE</th> <th>CLAVE</th>
<th>Estado</th> <th>Estado</th>
<?php if ($user_role !== 'Asesor'): ?><th>Asesor</th><?php endif; ?> <?php if ($user_role !== 'Asesor'): ?><th>Asesor</th><?php endif; ?>
@ -187,8 +186,13 @@ include 'layout_header.php';
<?php endif; ?> <?php endif; ?>
<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>
<td><?php echo htmlspecialchars($pedido['banco'] ?? 'N/A'); ?></td> <?php
<td class="editable" data-id="<?php echo $pedido['id']; ?>" data-field="clave"><?php echo htmlspecialchars($pedido['clave'] ?? 'N/A'); ?></td> $canSeeClave = ($user_role !== 'Asesor' || !empty($pedido['numero_operacion']));
$isEditableClave = ($user_role !== 'Asesor') ? 'editable' : '';
?>
<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>'; ?>
</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; ?>
<td><?php echo htmlspecialchars($pedido['created_at']); ?></td> <td><?php echo htmlspecialchars($pedido['created_at']); ?></td>

View File

@ -273,7 +273,13 @@ 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['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>
<td class="editable" data-id="<?php echo $pedido['id']; ?>" data-field="clave"><?php echo htmlspecialchars($pedido['clave'] ?? 'N/A'); ?></td> <?php
$canSeeClave = ($user_role !== 'Asesor' || !empty($pedido['numero_operacion']));
$isEditableClave = ($user_role !== 'Asesor') ? 'editable' : '';
?>
<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>'; ?>
</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>
<?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; ?>