Skip to content

Commit 73d03a2

Browse files
committed
Configuracion fechas pedidos
1 parent 177960c commit 73d03a2

2 files changed

Lines changed: 15 additions & 3 deletions

File tree

Frontend/app/Http/Controllers/Pedidos/PedidosController.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ public function store(Request $request)
7575
'ID_EMPLEADO' => 'required|integer|min:1',
7676
'ID_ESTADO_PEDIDO' => 'required|integer|min:1',
7777
'TOTAL_PRODUCTO' => 'required|numeric|min:0',
78-
'productos' => 'required_without:carrito|array',
78+
'productos' => 'required_without:carrito|array',
79+
'FECHA_ENTREGA' => 'nullable|date|after_or_equal:today',
7980
]);
8081

8182
$detallesApi = [];
@@ -204,6 +205,7 @@ public function update(Request $request, $id)
204205
'TOTAL_PRODUCTO' => 'required|numeric',
205206
'productos' => 'required|array|min:1',
206207
'cantidades' => 'required|array',
208+
'FECHA_ENTREGA' => 'nullable|date|after_or_equal:today',
207209
]);
208210

209211
try {

Frontend/resources/views/pedidosviews/PedidosClientes/index-admin.blade.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,8 @@
222222
</div>
223223

224224
<div class="col-md-6">
225-
<label class="form-label fw-bold">Fecha y Hora de Entrega</label>
226-
<input type="datetime-local" class="form-control" id="modal_FECHA_ENTREGA" name="FECHA_ENTREGA">
225+
<label class="form-label fw-bold">Fecha y Hora de Entrega</label>
226+
<input type="datetime-local" class="form-control" id="modal_FECHA_ENTREGA" name="FECHA_ENTREGA" min="">
227227
</div>
228228

229229
<div class="col-md-6">
@@ -291,6 +291,16 @@
291291
}
292292
293293
document.addEventListener('DOMContentLoaded', function() {
294+
295+
// Bloquear fechas pasadas en el input de entrega
296+
function setFechaMinima() {
297+
const ahora = new Date();
298+
// Ajuste para evitar desfase de zona horaria
299+
ahora.setMinutes(ahora.getMinutes() - ahora.getTimezoneOffset());
300+
const fechaMin = ahora.toISOString().slice(0, 16);
301+
document.getElementById('modal_FECHA_ENTREGA').setAttribute('min', fechaMin);
302+
}
303+
setFechaMinima();
294304
cargarProductosDesdeJava();
295305
296306
const modal = new bootstrap.Modal(document.getElementById('pedidoModal'));

0 commit comments

Comments
 (0)