Autosave: 20260523-170233

This commit is contained in:
Flatlogic Bot 2026-05-23 17:02:34 +00:00
parent 491b21a0f8
commit 709ff2f0d0
9 changed files with 72 additions and 66 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 234 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 375 KiB

View File

@ -240,7 +240,7 @@ $(document).ready(function() {
"language": { "language": {
"url": "//cdn.datatables.net/plug-ins/1.10.25/i18n/Spanish.json" "url": "//cdn.datatables.net/plug-ins/1.10.25/i18n/Spanish.json"
}, },
"order": [[ <?php echo ($user_role !== 'Asesor') ? 16 : 15; ?>, "desc" ]], "order": [[ 0, "desc" ]],
"paging": false, "paging": false,
"lengthChange": false, "lengthChange": false,
"info": false "info": false

View File

@ -147,7 +147,7 @@ include 'layout_header.php';
</div> </div>
<div class="col-md-6 mb-3"> <div class="col-md-6 mb-3">
<label for="dni_cliente" class="form-label">DNI</label> <label for="dni_cliente" class="form-label">DNI</label>
<input type="text" class="form-control" id="dni_cliente" name="dni" value="<?php echo htmlspecialchars($pedido['dni_cliente'] ?? ''); ?>" required> <input type="text" class="form-control" id="dni_cliente" name="dni" value="<?php echo htmlspecialchars($pedido['dni_cliente'] ?? ''); ?>">
</div> </div>
</div> </div>

View File

@ -345,11 +345,7 @@ $(document).ready(function() {
"language": { "language": {
"url": "//cdn.datatables.net/plug-ins/1.10.25/i18n/Spanish.json" "url": "//cdn.datatables.net/plug-ins/1.10.25/i18n/Spanish.json"
}, },
"order": [[ <?php "order": [[ 0, "desc" ]],
$orderCol = ($user_role !== 'Asesor' ? 16 : 15);
if ($user_role === 'Logistica') $orderCol -= 2;
echo $orderCol;
?>, "desc" ]],
"paging": false, "paging": false,
"lengthChange": false, "lengthChange": false,
"info": false "info": false
@ -375,7 +371,6 @@ document.addEventListener('DOMContentLoaded', function() {
const options = [ const options = [
{val: '', text: 'Seleccionar'}, {val: '', text: 'Seleccionar'},
{val: 'RUTA', text: 'RUTA'}, {val: 'RUTA', text: 'RUTA'},
{val: 'CONTRAENTREGA', text: 'CONTRAENTREGA'},
{val: 'NO CONTESTA, VOLVER A LLAMAR', text: 'NO CONTESTA, VOLVER A LLAMAR'}, {val: 'NO CONTESTA, VOLVER A LLAMAR', text: 'NO CONTESTA, VOLVER A LLAMAR'},
{val: 'PENDIENTE A RETORNO', text: 'PENDIENTE A RETORNO'}, {val: 'PENDIENTE A RETORNO', text: 'PENDIENTE A RETORNO'},
{val: 'COMPLETADO', text: 'COMPLETADO'} {val: 'COMPLETADO', text: 'COMPLETADO'}

View File

@ -1,4 +1,8 @@
<?php <?php
ob_start();
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start(); session_start();
if (!isset($_SESSION['user_id'])) { if (!isset($_SESSION['user_id'])) {
header('Location: login.php'); header('Location: login.php');
@ -12,18 +16,18 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$id = $_POST['id'] ?? null; $id = $_POST['id'] ?? null;
$dni = trim($_POST['dni']); $dni = trim($_POST['dni'] ?? '');
$nombre_completo = trim($_POST['nombre_completo']); $nombre_completo = trim($_POST['nombre_completo'] ?? '');
$celular = trim($_POST['celular']); $celular = trim($_POST['celular'] ?? '');
$agencia = trim($_POST['agencia'] ?? 'CONTRAENTREGA'); $agencia = trim($_POST['agencia'] ?? 'CONTRAENTREGA');
$sede_envio = trim($_POST['sede_envio']); $sede_envio = trim($_POST['sede_envio'] ?? '');
$codigo_rastreo = trim($_POST['codigo_rastreo'] ?? ''); $codigo_rastreo = trim($_POST['codigo_rastreo'] ?? '');
$codigo_tracking = trim($_POST['codigo_tracking'] ?? ''); $codigo_tracking = trim($_POST['codigo_tracking'] ?? '');
$direccion_exacta = trim($_POST['direccion_exacta'] ?? ''); $direccion_exacta = trim($_POST['direccion_exacta'] ?? '');
$referencia_domicilio = trim($_POST['referencia_domicilio'] ?? ''); $referencia_domicilio = trim($_POST['referencia_domicilio'] ?? '');
$coordenadas = trim($_POST['coordenadas'] ?? ''); $coordenadas = trim($_POST['coordenadas'] ?? '');
$seguimiento = trim($_POST['seguimiento'] ?? ''); $seguimiento = trim($_POST['seguimiento'] ?? '');
$fecha_entrega = trim($_POST['fecha_entrega'] ?? null); $fecha_entrega = !empty($_POST['fecha_entrega']) ? trim($_POST['fecha_entrega']) : null;
// --- Manejo de multiples productos --- // --- Manejo de multiples productos ---
$productos_post = $_POST['productos'] ?? []; $productos_post = $_POST['productos'] ?? [];
@ -46,17 +50,20 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$notas_adicionales = "Detalle de productos: " . implode(', ', $productos_detalle); $notas_adicionales = "Detalle de productos: " . implode(', ', $productos_detalle);
// --- Fin del manejo de multiples productos --- // --- Fin del manejo de multiples productos ---
$monto_total = filter_var($_POST['monto_total'], FILTER_VALIDATE_FLOAT); $monto_total = filter_var($_POST['monto_total'] ?? 0, FILTER_VALIDATE_FLOAT);
$monto_adelantado = filter_var($_POST['monto_adelantado'], FILTER_VALIDATE_FLOAT); $monto_adelantado = filter_var($_POST['monto_adelantado'] ?? 0, FILTER_VALIDATE_FLOAT);
$numero_operacion = trim($_POST['numero_operacion']); if ($monto_total === false) $monto_total = 0.0;
if ($monto_adelantado === false) $monto_adelantado = 0.0;
$numero_operacion = trim($_POST['numero_operacion'] ?? '');
$banco = trim($_POST['banco'] ?? ''); $banco = trim($_POST['banco'] ?? '');
$notas = trim($_POST['notas']); $notas = trim($_POST['notas'] ?? '');
if (!empty($productos_detalle)) { if (!empty($productos_detalle)) {
$notas .= "\n\n" . $notas_adicionales; $notas .= "\n\n" . $notas_adicionales;
} }
if (empty($dni) || empty($nombre_completo) || empty($celular) || empty($sede_envio) || empty($producto) || $cantidad === false || $monto_total === false || empty($coordenadas)) { if (empty($nombre_completo) || empty($celular) || empty($sede_envio) || empty($producto) || $cantidad === false || $monto_total === false || empty($coordenadas)) {
$error_message = urlencode('Por favor, complete todos los campos obligatorios, incluyendo las coordenadas.'); $error_message = urlencode('Por favor, complete todos los campos obligatorios, incluyendo las coordenadas.');
$id_param = $id ? '&id=' . $id : ''; $id_param = $id ? '&id=' . $id : '';
header('Location: pedidos_contraentrega.php?error=' . $error_message . $id_param); header('Location: pedidos_contraentrega.php?error=' . $error_message . $id_param);
@ -110,6 +117,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
'fecha_entrega' => $fecha_entrega, 'fecha_entrega' => $fecha_entrega,
]; ];
try {
if ($id) { if ($id) {
// UPDATE: Explicit and safe query // UPDATE: Explicit and safe query
$user_role = $_SESSION['user_role'] ?? ''; $user_role = $_SESSION['user_role'] ?? '';
@ -162,6 +170,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$stmt = $pdo->prepare($sql); $stmt = $pdo->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
} }
} catch (PDOException $e) {
die("Error en la base de datos: " . $e->getMessage());
}
if (isset($_POST['id']) && !empty($_POST['id'])) { if (isset($_POST['id']) && !empty($_POST['id'])) {
// Si se está editando un pedido, redirigir a la página de referencia o a la lista general. // Si se está editando un pedido, redirigir a la página de referencia o a la lista general.