Autosave: 20260206-051613
This commit is contained in:
parent
7ccbc77b67
commit
8430b2c637
@ -59,7 +59,7 @@ if ($user_role === 'Asesor') {
|
||||
}
|
||||
|
||||
// Define los estados de los pedidos
|
||||
$estados = ['ROTULADO 📦', 'EN TRANSITO 🚛', 'EN DESTINO 🏬', 'COMPLETADO ✅', 'Ruta Contraentrega'];
|
||||
$estados = ['RUTA_CONTRAENTREGA', 'RETORNADO', 'ENTREGA EXITOSA', 'ROTULADO 📦', 'EN TRANSITO 🚛', 'EN DESTINO 🏬', 'COMPLETADO ✅'];
|
||||
$asesor_data = [];
|
||||
$chart_data = [];
|
||||
|
||||
@ -560,8 +560,11 @@ $selected_month] . ' ' . $selected_year; ?>)</h6>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Asesora</th>
|
||||
<?php foreach ($estados as $estado):
|
||||
echo "<th>" . htmlspecialchars($estado) . "</th>";
|
||||
<?php
|
||||
$estado_display_map = ['RUTA_CONTRAENTREGA' => 'Ruta Contraentrega', 'RETORNADO' => 'Retornado', 'ENTREGA EXITOSA' => 'Entrega Exitosa'];
|
||||
foreach ($estados as $estado):
|
||||
$display_name = $estado_display_map[$estado] ?? $estado;
|
||||
echo "<th>" . htmlspecialchars($display_name) . "</th>";
|
||||
endforeach; ?>
|
||||
<th>Total</th>
|
||||
</tr>
|
||||
|
||||
10
db/migrations/060_add_contraentrega_statuses.sql
Normal file
10
db/migrations/060_add_contraentrega_statuses.sql
Normal file
@ -0,0 +1,10 @@
|
||||
ALTER TABLE pedidos MODIFY COLUMN estado ENUM(
|
||||
'ROTULADO 📦',
|
||||
'EN TRANSITO 🚛',
|
||||
'EN DESTINO 🏬',
|
||||
'COMPLETADO ✅',
|
||||
'Gestion',
|
||||
'RUTA_CONTRAENTREGA',
|
||||
'ENTREGA EXITOSA',
|
||||
'RETORNADO'
|
||||
) DEFAULT 'ROTULADO 📦';
|
||||
@ -18,7 +18,7 @@ $navItems = [
|
||||
'url' => 'dashboard.php',
|
||||
'icon' => 'fa-tachometer-alt',
|
||||
'text' => 'Dashboard',
|
||||
'roles' => ['Administrador', 'admin', 'Asesor', 'Control Logistico']
|
||||
'roles' => ['Administrador', 'admin', 'Asesor', 'Control Logistico', 'Soporte Logistico']
|
||||
],
|
||||
'kanban' => [
|
||||
'url' => 'kanban.php',
|
||||
@ -42,13 +42,13 @@ $navItems = [
|
||||
'url' => 'buscador_general.php',
|
||||
'icon' => 'fa-search',
|
||||
'text' => 'Buscador General',
|
||||
'roles' => ['Administrador', 'admin', 'Asesor', 'Control Logistico']
|
||||
'roles' => ['Administrador', 'admin', 'Asesor', 'Control Logistico', 'Soporte Logistico']
|
||||
],
|
||||
'completados' => [
|
||||
'url' => 'completados.php',
|
||||
'icon' => 'fa-check-circle',
|
||||
'text' => 'Pedidos Completados',
|
||||
'roles' => ['Administrador', 'admin', 'Asesor', 'Control Logistico']
|
||||
'roles' => ['Administrador', 'admin', 'Asesor', 'Control Logistico', 'Soporte Logistico']
|
||||
],
|
||||
'listos_para_recojo' => [
|
||||
'url' => 'listos_para_recojo.php',
|
||||
@ -78,13 +78,13 @@ $navItems = [
|
||||
'url' => 'pedidos_contraentrega.php',
|
||||
'icon' => 'fa-hand-holding-usd',
|
||||
'text' => 'Agregar Pedidos Contraentrega',
|
||||
'roles' => ['Administrador', 'admin', 'Asesor', 'Control Logistico']
|
||||
'roles' => ['Administrador', 'admin', 'Asesor', 'Control Logistico', 'Soporte Logistico']
|
||||
],
|
||||
'ruta_contraentrega' => [
|
||||
'url' => 'ruta_contraentrega.php',
|
||||
'icon' => 'fa-route',
|
||||
'text' => 'Ruta Contraentrega',
|
||||
'roles' => ['Administrador', 'admin', 'Asesor', 'Control Logistico']
|
||||
'roles' => ['Administrador', 'admin', 'Asesor', 'Control Logistico', 'Soporte Logistico']
|
||||
],
|
||||
'inventario_group' => [
|
||||
'icon' => 'fa-warehouse',
|
||||
|
||||
@ -153,6 +153,7 @@ include 'layout_header.php';
|
||||
<option value="Administrador">Administrador</option>
|
||||
<option value="Asesor">Asesor</option>
|
||||
<option value="Control Logistico">Control Logístico</option>
|
||||
<option value="Soporte Logistico">Soporte Logístico</option>
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" name="create_user" class="btn btn-primary w-100">Crear Usuario</button>
|
||||
@ -235,6 +236,7 @@ include 'layout_header.php';
|
||||
<option value="Administrador">Administrador</option>
|
||||
<option value="Asesor">Asesor</option>
|
||||
<option value="Control Logistico">Control Logístico</option>
|
||||
<option value="Soporte Logistico">Soporte Logístico</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -133,14 +133,14 @@ include 'layout_header.php';
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="direccion_exacta" class="form-label">Direccion exacta</label>
|
||||
<input type="text" class="form-control" id="direccion_exacta" name="direccion_exacta" value="" required>
|
||||
<input type="text" class="form-control" id="direccion_exacta" name="direccion_exacta" value="<?php echo htmlspecialchars($pedido['direccion_exacta'] ?? ''); ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="referencia_domicilio" class="form-label">Referencia de domicilio</label>
|
||||
<input type="text" class="form-control" id="referencia_domicilio" name="referencia_domicilio" value="">
|
||||
<input type="text" class="form-control" id="referencia_domicilio" name="referencia_domicilio" value="<?php echo htmlspecialchars($pedido['referencia_domicilio'] ?? ''); ?>">
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label for="coordenadas" class="form-label">Coordenadas</label>
|
||||
@ -201,6 +201,22 @@ include 'layout_header.php';
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4 mb-3">
|
||||
<label for="estado" class="form-label">Estado del Pedido</label>
|
||||
<select class="form-select" id="estado" name="estado" required>
|
||||
<?php
|
||||
$current_status = $pedido['estado'] ?? 'RUTA_CONTRAENTREGA';
|
||||
$statuses = ['RUTA_CONTRAENTREGA', 'ENTREGA EXITOSA', 'RETORNADO'];
|
||||
foreach ($statuses as $status) {
|
||||
$selected = ($current_status == $status) ? 'selected' : '';
|
||||
echo "<option value='{$status}' {$selected}>" . htmlspecialchars($status) . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="notas" class="form-label">Notas</label>
|
||||
<textarea class="form-control" id="notas" name="notas" rows="3"><?php echo htmlspecialchars($pedido['notas']); ?></textarea>
|
||||
|
||||
@ -33,6 +33,12 @@ function getStatusStyle($status) {
|
||||
case 'RUTA_CONTRAENTREGA':
|
||||
$bgColor = '#007bff'; // primary blue
|
||||
break;
|
||||
case 'ENTREGA EXITOSA':
|
||||
$bgColor = '#198754'; // dark green
|
||||
break;
|
||||
case 'RETORNADO':
|
||||
$bgColor = '#dc3545'; // red
|
||||
break;
|
||||
}
|
||||
return "background-color: {$bgColor} !important; {$style}";
|
||||
}
|
||||
@ -70,7 +76,7 @@ $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 = 'RUTA_CONTRAENTREGA'";
|
||||
$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 IN ('RUTA_CONTRAENTREGA', 'ENTREGA EXITOSA', 'RETORNADO')";
|
||||
$params = [];
|
||||
|
||||
if ($user_role === 'Asesor') {
|
||||
@ -180,6 +186,7 @@ include 'layout_header.php';
|
||||
<th>Provincia/Distrito</th>
|
||||
<th>Coordenadas</th>
|
||||
<th>Producto</th>
|
||||
<th>Cantidad</th>
|
||||
<th>Monto Total</th>
|
||||
<th>Monto Debe</th>
|
||||
<th>Estado</th>
|
||||
@ -237,6 +244,7 @@ include 'layout_header.php';
|
||||
<td><?php echo htmlspecialchars($pedido['codigo_rastreo'] ?? 'N/A'); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['coordenadas'] ?? 'N/A'); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['producto']); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['cantidad']); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['monto_total']); ?></td>
|
||||
<td><?php echo htmlspecialchars($pedido['monto_debe']); ?></td>
|
||||
<td><span class="badge" style="<?php echo getStatusStyle($pedido['estado']); ?>"><?php echo htmlspecialchars($pedido['estado']); ?></span></td>
|
||||
|
||||
@ -107,7 +107,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
"notas = :notas",
|
||||
"seguimiento = :seguimiento",
|
||||
"fecha_entrega = :fecha_entrega",
|
||||
"estado = :estado",
|
||||
];
|
||||
$params['estado'] = $_POST['estado'] ?? 'RUTA_CONTRAENTREGA';
|
||||
|
||||
// Conditionally add asesor_id
|
||||
if ($user_role === 'Administrador' && !empty($_POST['asesor_id'])) {
|
||||
@ -123,7 +125,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
} else {
|
||||
// INSERT: The advisor is the user creating the order.
|
||||
$params['asesor_id'] = $_SESSION['user_id'];
|
||||
$params['estado'] = 'RUTA_CONTRAENTREGA';
|
||||
$params['estado'] = $_POST['estado'] ?? 'RUTA_CONTRAENTREGA';
|
||||
|
||||
$columns_sql = "dni_cliente, nombre_completo, celular, sede_envio, direccion_exacta, referencia_domicilio, coordenadas, codigo_rastreo, codigo_tracking, producto, cantidad, monto_total, monto_adelantado, numero_operacion, monto_debe, asesor_id, notas, estado, seguimiento, fecha_entrega";
|
||||
$values_sql = ":dni_cliente, :nombre_completo, :celular, :sede_envio, :direccion_exacta, :referencia_domicilio, :coordenadas, :codigo_rastreo, :codigo_tracking, :producto, :cantidad, :monto_total, :monto_adelantado, :numero_operacion, :monto_debe, :asesor_id, :notas, :estado, :seguimiento, :fecha_entrega";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user