Autosave: 20260217-033956
This commit is contained in:
parent
1bf602b5b0
commit
11c42a7000
BIN
assets/uploads/info_images/info_6993de122e596.webp
Normal file
BIN
assets/uploads/info_images/info_6993de122e596.webp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 274 KiB |
12
kanban.php
12
kanban.php
@ -47,21 +47,13 @@ if ($items) {
|
||||
}
|
||||
}
|
||||
|
||||
$pageTitle = "Kanban de Productos";
|
||||
$pageDescription = "Tablero Kanban para visualizar la información de los productos.";
|
||||
$pageTitle = "PANEL DE PRODUCTOS";
|
||||
$pageDescription = "Panel para visualizar la información de los productos.";
|
||||
|
||||
include 'layout_header.php';
|
||||
?>
|
||||
|
||||
<div class="container-fluid mt-4">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<h1><?php echo $pageTitle; ?></h1>
|
||||
</div>
|
||||
<p><?php echo $pageDescription; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
|
||||
@ -23,7 +23,7 @@ $navItems = [
|
||||
'kanban' => [
|
||||
'url' => 'kanban.php',
|
||||
'icon' => 'fa-columns',
|
||||
'text' => 'Kanban',
|
||||
'text' => 'Panel',
|
||||
'roles' => ['Administrador', 'admin', 'Asesor', 'Control Logistico']
|
||||
],
|
||||
'cobertura' => [
|
||||
|
||||
@ -156,6 +156,7 @@ include 'layout_header.php';
|
||||
<th>Celular</th>
|
||||
<th>Producto</th>
|
||||
<th>Sede de Envío</th>
|
||||
<th>Cantidad</th>
|
||||
<th>Monto Total</th>
|
||||
<th>Monto Debe</th>
|
||||
<th>Nro. Operación</th>
|
||||
@ -182,6 +183,7 @@ include 'layout_header.php';
|
||||
<td><?php echo htmlspecialchars($pedido['celular']); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['producto']); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['sede_envio'] ?? 'N/A'); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['cantidad'] ?: 1); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['monto_total']); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['monto_debe']); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['numero_operacion'] ?? 'N/A'); ?></td>
|
||||
|
||||
@ -152,6 +152,7 @@ include 'layout_header.php';
|
||||
<th>Celular</th>
|
||||
<th>Producto</th>
|
||||
<th>Sede de Envío</th>
|
||||
<th>Cantidad</th>
|
||||
<th>Monto Total</th>
|
||||
<th>Monto Debe</th>
|
||||
<th>Nº De Orden</th>
|
||||
@ -173,6 +174,7 @@ include 'layout_header.php';
|
||||
<td><?php echo htmlspecialchars($pedido['celular']); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['producto']); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['sede_envio'] ?? 'N/A'); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['cantidad'] ?: 1); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['monto_total']); ?></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>
|
||||
|
||||
326
test_pedidos.php
Normal file
326
test_pedidos.php
Normal file
@ -0,0 +1,326 @@
|
||||
<?php
|
||||
session_start();
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once 'db/config.php';
|
||||
|
||||
function getStatusStyle($status) {
|
||||
$style = 'color: white;'; // Default text color
|
||||
$bgColor = '#0dcaf0'; // Default info blue
|
||||
|
||||
switch (strtoupper(trim($status))) {
|
||||
case 'ROTULADO':
|
||||
$bgColor = '#ffc107'; // yellow
|
||||
$style = 'color: black;';
|
||||
break;
|
||||
case 'EN TRANSITO':
|
||||
$bgColor = '#90EE90'; // light green
|
||||
$style = 'color: black;';
|
||||
break;
|
||||
case 'EN DESTINO':
|
||||
$bgColor = '#800080'; // purple
|
||||
break;
|
||||
case 'COMPLETADO':
|
||||
case 'COMPLETADO ✅':
|
||||
$bgColor = '#198754'; // dark green
|
||||
break;
|
||||
case 'GESTION':
|
||||
$bgColor = '#6c757d'; // secondary grey
|
||||
break;
|
||||
}
|
||||
return "background-color: {$bgColor} !important; {$style}";
|
||||
}
|
||||
|
||||
$pdo = db();
|
||||
|
||||
$user_id = $_SESSION['user_id'];
|
||||
$user_role = $_SESSION['user_role'] ?? 'Asesor';
|
||||
|
||||
// Fetch years for the filter
|
||||
$years_query = "SELECT DISTINCT YEAR(created_at) as year FROM pedidos";
|
||||
if ($user_role === 'Asesor') {
|
||||
$years_query .= " WHERE asesor_id = ?";
|
||||
$years_stmt = $pdo->prepare($years_query);
|
||||
$years_stmt->execute([$user_id]);
|
||||
} else {
|
||||
$years_stmt = $pdo->query($years_query);
|
||||
}
|
||||
$years = $years_stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||
|
||||
|
||||
// Filter logic
|
||||
$selected_month = $_GET['mes'] ?? '';
|
||||
$selected_year = $_GET['año'] ?? '';
|
||||
$search_query = $_GET['q'] ?? '';
|
||||
|
||||
$sql = "SELECT p.*, u.nombre_asesor as asesor_nombre FROM pedidos p LEFT JOIN users u ON p.asesor_id = u.id WHERE p.estado = 'EN TRANSITO 🚛'";
|
||||
$params = [];
|
||||
|
||||
if ($user_role === 'Asesor') {
|
||||
$sql .= " AND p.asesor_id = ?";
|
||||
$params[] = $user_id;
|
||||
}
|
||||
|
||||
if (!empty($search_query)) {
|
||||
$sql .= " AND (p.nombre_completo LIKE ? OR p.dni_cliente LIKE ? OR p.celular LIKE ?)";
|
||||
$params[] = "%$search_query%";
|
||||
$params[] = "%$search_query%";
|
||||
$params[] = "%$search_query%";
|
||||
}
|
||||
|
||||
if (!empty($selected_month)) {
|
||||
$sql .= " AND MONTH(p.created_at) = ?";
|
||||
$params[] = $selected_month;
|
||||
}
|
||||
if (!empty($selected_year)) {
|
||||
$sql .= " AND YEAR(p.created_at) = ?";
|
||||
$params[] = $selected_year;
|
||||
}
|
||||
|
||||
$sql .= " ORDER BY p.created_at DESC";
|
||||
$stmt = $pdo->prepare($sql);
|
||||
$stmt->execute($params);
|
||||
$pedidos = $stmt->fetchAll();
|
||||
|
||||
$months = [
|
||||
1 => 'Enero', 2 => 'Febrero', 3 => 'Marzo', 4 => 'Abril', 5 => 'Mayo', 6 => 'Junio',
|
||||
7 => 'Julio', 8 => 'Agosto', 9 => 'Septiembre', 10 => 'Octubre', 11 => 'Noviembre', 12 => 'Diciembre'
|
||||
];
|
||||
|
||||
?>
|
||||
<?php
|
||||
$pageTitle = "Pedidos en Tránsito (Prueba)";
|
||||
include 'layout_header.php';
|
||||
?>
|
||||
|
||||
<!-- Modal for tracking status -->
|
||||
<div class="modal fade" id="trackingModal" tabindex="-1" aria-labelledby="trackingModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="trackingModalLabel">Estado del Pedido</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p><strong>Número de Orden:</strong> <span id="modal-order-number"></span></p>
|
||||
<hr>
|
||||
<p>Aquí se mostrará el estado del envío consultado desde la API de Shalom.</p>
|
||||
<p><em>(Esta es una funcionalidad de prueba)</em></p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cerrar</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<?php if (isset($_SESSION['flash_message'])):
|
||||
$flash = $_SESSION['flash_message'];
|
||||
unset($_SESSION['flash_message']);
|
||||
?>
|
||||
<div class="alert alert-<?php echo htmlspecialchars($flash['type']); ?> alert-dismissible fade show" role="alert">
|
||||
<?php echo htmlspecialchars($flash['message']); ?>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<form method="GET" action="test_pedidos.php" class="row g-3 align-items-center">
|
||||
<div class="col-auto">
|
||||
<label for="q" class="form-label">Buscar</label>
|
||||
<input type="text" name="q" id="q" class="form-control" value="<?php echo htmlspecialchars($search_query); ?>" placeholder="Nombre, DNI o Celular">
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<label for="mes" class="form-label">Mes</label>
|
||||
<select name="mes" id="mes" class="form-select">
|
||||
<option value="">Todos</option>
|
||||
<?php foreach ($months as $num => $name): ?>
|
||||
<option value="<?php echo $num; ?>" <?php echo $selected_month == $num ? 'selected' : ''; ?>><?php echo $name; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<label for="año" class="form-label">Año</label>
|
||||
<select name="año" id="año" class="form-select">
|
||||
<option value="">Todos</option>
|
||||
<?php foreach ($years as $year): ?>
|
||||
<option value="<?php echo $year; ?>" <?php echo $selected_year == $year ? 'selected' : ''; ?>><?php echo $year; ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-auto mt-4">
|
||||
<button type="submit" class="btn btn-info">Filtrar</button>
|
||||
<a href="test_pedidos.php" class="btn btn-secondary">Limpiar</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table id="pedidos-table" class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Cliente</th>
|
||||
<th>DNI</th>
|
||||
<th>Celular</th>
|
||||
<th>Producto</th>
|
||||
<th>Sede de Envío</th>
|
||||
<th>Cantidad</th>
|
||||
<th>Monto Total</th>
|
||||
<th>Monto Debe</th>
|
||||
<th>Nº De Orden</th>
|
||||
<th>Codigo De Orden</th>
|
||||
<th>CLAVE</th>
|
||||
<th>Estado</th>
|
||||
<?php if ($user_role !== 'Asesor'): ?><th>Asesor</th><?php endif; ?>
|
||||
<th>Fecha Creación</th>
|
||||
<th>Voucher Restante</th>
|
||||
<th>Acciones</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($pedidos as $pedido): ?>
|
||||
<tr>
|
||||
<td><?php echo htmlspecialchars($pedido['id']); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['nombre_completo']); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['dni_cliente'] ?? 'N/A'); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['celular']); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['producto']); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['sede_envio'] ?? 'N/A'); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['cantidad'] ?: 1); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['monto_total']); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['monto_debe']); ?></td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-link tracking-btn" data-bs-toggle="modal" data-bs-target="#trackingModal" data-order-number="<?php echo htmlspecialchars($pedido['codigo_rastreo'] ?? 'N/A'); ?>">
|
||||
<?php echo htmlspecialchars($pedido['codigo_rastreo'] ?? 'N/A'); ?>
|
||||
</button>
|
||||
</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>
|
||||
<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; ?>
|
||||
<td><?php echo htmlspecialchars($pedido['created_at']); ?></td>
|
||||
<td>
|
||||
<?php if (!empty($pedido['voucher_restante_path'])): ?>
|
||||
<a href="<?php echo htmlspecialchars($pedido['voucher_restante_path']); ?>" target="_blank">Ver</a>
|
||||
<?php else: ?>
|
||||
N/A
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td>
|
||||
<a href="pedido_form.php?id=<?php echo $pedido['id']; ?>" class="btn btn-sm btn-warning">Editar</a>
|
||||
<?php if ($user_role === 'Administrador'): ?>
|
||||
<a href="delete_pedido.php?id=<?php echo $pedido['id']; ?>" class="btn btn-sm btn-danger" onclick="return confirm('¿Estás seguro de que quieres eliminar este pedido?');">Eliminar</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if (empty($pedidos)): ?>
|
||||
<p class="text-center">No hay pedidos que coincidan con el filtro.</p>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<?php include 'layout_footer.php'; ?>
|
||||
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$('#pedidos-table').DataTable({
|
||||
"language": {
|
||||
"url": "//cdn.datatables.net/plug-ins/1.10.25/i18n/Spanish.json"
|
||||
},
|
||||
"order": [[ <?php echo ($user_role !== 'Asesor' ? 13 : 12); ?>, "desc" ]],
|
||||
"paging": false,
|
||||
"lengthChange": false,
|
||||
"info": false
|
||||
});
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const table = document.querySelector('.table');
|
||||
|
||||
// Logic for editable cells
|
||||
table.addEventListener('click', function(e) {
|
||||
if (e.target && e.target.classList.contains('editable')) {
|
||||
const cell = e.target;
|
||||
if (cell.querySelector('input')) {
|
||||
return; // Already in edit mode
|
||||
}
|
||||
|
||||
const originalContent = cell.textContent.trim();
|
||||
const input = document.createElement('input');
|
||||
input.type = 'text';
|
||||
input.className = 'form-control form-control-sm';
|
||||
input.value = originalContent === 'N/A' ? '' : originalContent;
|
||||
|
||||
cell.innerHTML = '';
|
||||
cell.appendChild(input);
|
||||
input.focus();
|
||||
|
||||
const saveChanges = function() {
|
||||
const newValue = input.value.trim();
|
||||
const pedidoId = cell.dataset.id;
|
||||
const field = cell.dataset.field;
|
||||
|
||||
let endpoint = 'update_tracking.php'; // Default endpoint
|
||||
if (field === 'clave') {
|
||||
endpoint = 'update_clave.php';
|
||||
}
|
||||
|
||||
cell.textContent = newValue === '' ? 'N/A' : newValue;
|
||||
|
||||
fetch(endpoint, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({ id: pedidoId, field: field, value: newValue })
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.error) {
|
||||
console.error('Error:', data.error);
|
||||
cell.textContent = originalContent;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Fetch Error:', error);
|
||||
cell.textContent = originalContent;
|
||||
});
|
||||
};
|
||||
|
||||
input.addEventListener('blur', saveChanges);
|
||||
input.addEventListener('keydown', function(e) {
|
||||
if (e.key === 'Enter') {
|
||||
input.blur();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Logic for tracking modal
|
||||
var trackingModal = document.getElementById('trackingModal');
|
||||
trackingModal.addEventListener('show.bs.modal', function (event) {
|
||||
var button = event.relatedTarget;
|
||||
var orderNumber = button.getAttribute('data-order-number');
|
||||
var modalOrderNumberSpan = trackingModal.querySelector('#modal-order-number');
|
||||
modalOrderNumberSpan.textContent = orderNumber;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Loading…
x
Reference in New Issue
Block a user