terminado

This commit is contained in:
jaimejimenezortega
2024-06-16 02:10:01 +02:00
parent 3171c32283
commit 2f1f6f9631
3 changed files with 71 additions and 13 deletions

View File

@ -50,17 +50,47 @@ class Pedido extends \App\Controllers\BaseResourceController
public function activos()
{
echo 'Pedidos Activos';
$viewData = [
'currentModule' => static::$controllerSlug,
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Pedidos.pedido')]),
'presupuestoEntity' => new PedidoEntity(),
'usingServerSideDataTable' => true,
'pageTitle' => lang('Pedidos.Pedidos'),
'estadoPedidos' => 'activo',
['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true]
];
return view(static::$viewPath . 'viewPedidosList', $viewData);
}
public function finalizados()
{
echo 'Pedidos Finalizados';
$viewData = [
'currentModule' => static::$controllerSlug,
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Pedidos.pedido')]),
'presupuestoEntity' => new PedidoEntity(),
'usingServerSideDataTable' => true,
'pageTitle' => lang('Pedidos.Pedidos'),
'estadoPedidos' => 'finalizado',
['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true]
];
return view(static::$viewPath . 'viewPedidosList', $viewData);
}
public function cancelados()
{
echo 'Pedidos Cancelados';
$viewData = [
'currentModule' => static::$controllerSlug,
'pageSubTitle' => lang('Basic.global.ManageAllRecords', [lang('Pedidos.pedido')]),
'presupuestoEntity' => new PedidoEntity(),
'usingServerSideDataTable' => true,
'pageTitle' => lang('Pedidos.Pedidos'),
'estadoPedidos' => 'cancelado',
['title' => lang("App.menu_pedidos"), 'route' => site_url('pedidos/todos'), 'active' => true]
];
return view(static::$viewPath . 'viewPedidosList', $viewData);
}
public function todos()
@ -189,6 +219,7 @@ class Pedido extends \App\Controllers\BaseResourceController
$this->obtenerDatosFormulario($pedidoEntity);
$this->viewData['pedidoEntity'] = $pedidoEntity;
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Pedidos.moduleTitle') . ' ' . lang('Basic.global.edit3');
@ -211,14 +242,16 @@ class Pedido extends \App\Controllers\BaseResourceController
$requestedOrder = $reqData['order']['0']['column'] ?? 0;
$order = PedidoModel::SORTABLE_TODOS[$requestedOrder >= 0 ? $requestedOrder : 0];
$dir = $reqData['order']['0']['dir'] ?? 'asc';
$estado = $reqData['estado'] ?? 'todos';
if($estado == 'todos') $estado = '';
$model_linea = model('\App\Models\Pedidos\PedidoLineaModel');
$resourceData = $model_linea->getResource($search)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
$resourceData = $model_linea->getResource($search, $estado)->orderBy($order, $dir)->limit($length, $start)->get()->getResultObject();
return $this->respond(Collection::datatable(
$resourceData,
$model_linea->getResource()->countAllResults(),
$model_linea->getResource($search)->countAllResults()
$model_linea->getResource("", $estado)->countAllResults(),
$model_linea->getResource($search, $estado)->countAllResults()
));
} else {
return $this->failUnauthorized('Invalid request', 403);
@ -259,6 +292,11 @@ class Pedido extends \App\Controllers\BaseResourceController
$pedidoEntity->cliente_id = $datos[0]->cliente_id;
$pedidoEntity->comercial = $datos[0]->comercial;
}
$pedidoEntity->fecha_entrega_real_text = $pedidoEntity->fecha_entrega_real ? date('d/m/Y', strtotime($pedidoEntity->fecha_entrega_real)) : '';
$pedidoEntity->fecha_impresion_text = $pedidoEntity->fecha_impresion ? date('d/m/Y', strtotime($pedidoEntity->fecha_impresion)) : '';
$pedidoEntity->fecha_encuadernado_text = $pedidoEntity->fecha_encuadernado ? date('d/m/Y', strtotime($pedidoEntity->fecha_encuadernado)) : '';
$pedidoEntity->fecha_entrega_externo_text = $pedidoEntity->fecha_entrega_externo ? date('d/m/Y', strtotime($pedidoEntity->fecha_entrega_externo)) : '';
}
}

View File

@ -59,7 +59,12 @@ class PedidoLineaModel extends \App\Models\BaseModel
$builder->join("ubicaciones t6", "t6.id = t1.ubicacion_id", "left");
if($estado != "") {
$builder->where("t1.estado", $estado);
if($estado == "activo") {
$sql = "t2.estado = 'validacion' OR t2.estado = 'produccion'";
$builder->where($sql);
} else {
$builder->where("t2.estado", $estado);
}
}
// Falta implementar la busqueda por grupos

View File

@ -162,6 +162,7 @@
<?=$this->section('additionalInlineJs') ?>
$("#fecha_entrega_real").flatpickr({
defaultDate: <?= $pedidoEntity->fecha_entrega_real_text ? "'".$pedidoEntity->fecha_entrega_real_text."'" : 'null' ?>,
dateFormat: "d/m/Y",
locale: {
firstDayOfWeek: 1,
@ -174,12 +175,15 @@ $("#fecha_entrega_real").flatpickr({
longhand: ['Enero', 'Febreo', 'Мarzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
},
},
onChange: function(selectedDates, instance) {
updateDate('fecha_entrega_real', selectedDates);
onChange: function(selectedDates, dateStr, instance) {
<?php if ($pedidoEntity->estado !== 'finalizado' && $pedidoEntity->estado !== 'cancelado'): ?>
updateDate('fecha_entrega_real', dateStr);
<?php endif; ?>
}
});
$("#fecha_impresion").flatpickr({
defaultDate: <?= $pedidoEntity->fecha_impresion_text ? "'".$pedidoEntity->fecha_impresion_text."'" : 'null' ?>,
dateFormat: "d/m/Y",
locale: {
firstDayOfWeek: 1,
@ -193,11 +197,14 @@ $("#fecha_impresion").flatpickr({
},
},
onChange: function(selectedDates, dateStr, instance) {
updateDate('fecha_impresion', dateStr);
<?php if ($pedidoEntity->estado !== 'finalizado' && $pedidoEntity->estado !== 'cancelado'): ?>
updateDate('fecha_impresion', dateStr);
<?php endif; ?>
}
});
$("#fecha_encuadernado").flatpickr({
defaultDate: <?= $pedidoEntity->fecha_encuadernado_text ? "'".$pedidoEntity->fecha_encuadernado_text."'" : 'null' ?>,
dateFormat: "d/m/Y",
locale: {
firstDayOfWeek: 1,
@ -211,11 +218,14 @@ $("#fecha_encuadernado").flatpickr({
},
},
onChange: function(selectedDates, dateStr, instance) {
updateDate('fecha_encuadernado', dateStr);
<?php if ($pedidoEntity->estado !== 'finalizado' && $pedidoEntity->estado !== 'cancelado'): ?>
updateDate('fecha_encuadernado', dateStr);
<?php endif; ?>
}
});
$("#fecha_entrega_externo").flatpickr({
defaultDate: <?= $pedidoEntity->fecha_entrega_externo_text ? "'".$pedidoEntity->fecha_entrega_externo_text."'" : 'null' ?>,
dateFormat: "d/m/Y",
locale: {
firstDayOfWeek: 1,
@ -229,7 +239,9 @@ $("#fecha_entrega_externo").flatpickr({
},
},
onChange: function(selectedDates, dateStr, instance) {
updateDate('fecha_entrega_externo', dateStr);
<?php if ($pedidoEntity->estado !== 'finalizado' && $pedidoEntity->estado !== 'cancelado'): ?>
updateDate('fecha_entrega_externo', dateStr);
<?php endif; ?>
}
});
@ -267,7 +279,10 @@ function updateDate(elementId, dateStr) {
data = {
<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v,
};
data[elementId] = dateStr;
var parts = dateStr.split('/');
var newFormat = parts[2] + '-' + parts[1] + '-' + parts[0]; // Asume dateStr en formato d/m/Y.
data[elementId] = newFormat;
var url = '<?= route_to('actualizarPedido', ':id') ?>';
url = url.replace(':id', id );