mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
terminado
This commit is contained in:
@ -50,17 +50,47 @@ class Pedido extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
public function activos()
|
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()
|
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()
|
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()
|
public function todos()
|
||||||
@ -190,6 +220,7 @@ class Pedido extends \App\Controllers\BaseResourceController
|
|||||||
|
|
||||||
$this->viewData['pedidoEntity'] = $pedidoEntity;
|
$this->viewData['pedidoEntity'] = $pedidoEntity;
|
||||||
|
|
||||||
|
|
||||||
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Pedidos.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
$this->viewData['boxTitle'] = lang('Basic.global.edit2') . ' ' . lang('Pedidos.moduleTitle') . ' ' . lang('Basic.global.edit3');
|
||||||
|
|
||||||
return $this->displayForm(__METHOD__, $id);
|
return $this->displayForm(__METHOD__, $id);
|
||||||
@ -211,14 +242,16 @@ class Pedido extends \App\Controllers\BaseResourceController
|
|||||||
$requestedOrder = $reqData['order']['0']['column'] ?? 0;
|
$requestedOrder = $reqData['order']['0']['column'] ?? 0;
|
||||||
$order = PedidoModel::SORTABLE_TODOS[$requestedOrder >= 0 ? $requestedOrder : 0];
|
$order = PedidoModel::SORTABLE_TODOS[$requestedOrder >= 0 ? $requestedOrder : 0];
|
||||||
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
$dir = $reqData['order']['0']['dir'] ?? 'asc';
|
||||||
|
$estado = $reqData['estado'] ?? 'todos';
|
||||||
|
if($estado == 'todos') $estado = '';
|
||||||
|
|
||||||
$model_linea = model('\App\Models\Pedidos\PedidoLineaModel');
|
$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(
|
return $this->respond(Collection::datatable(
|
||||||
$resourceData,
|
$resourceData,
|
||||||
$model_linea->getResource()->countAllResults(),
|
$model_linea->getResource("", $estado)->countAllResults(),
|
||||||
$model_linea->getResource($search)->countAllResults()
|
$model_linea->getResource($search, $estado)->countAllResults()
|
||||||
));
|
));
|
||||||
} else {
|
} else {
|
||||||
return $this->failUnauthorized('Invalid request', 403);
|
return $this->failUnauthorized('Invalid request', 403);
|
||||||
@ -259,6 +292,11 @@ class Pedido extends \App\Controllers\BaseResourceController
|
|||||||
$pedidoEntity->cliente_id = $datos[0]->cliente_id;
|
$pedidoEntity->cliente_id = $datos[0]->cliente_id;
|
||||||
$pedidoEntity->comercial = $datos[0]->comercial;
|
$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)) : '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +59,12 @@ class PedidoLineaModel extends \App\Models\BaseModel
|
|||||||
$builder->join("ubicaciones t6", "t6.id = t1.ubicacion_id", "left");
|
$builder->join("ubicaciones t6", "t6.id = t1.ubicacion_id", "left");
|
||||||
|
|
||||||
if($estado != "") {
|
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
|
// Falta implementar la busqueda por grupos
|
||||||
|
|||||||
@ -162,6 +162,7 @@
|
|||||||
<?=$this->section('additionalInlineJs') ?>
|
<?=$this->section('additionalInlineJs') ?>
|
||||||
|
|
||||||
$("#fecha_entrega_real").flatpickr({
|
$("#fecha_entrega_real").flatpickr({
|
||||||
|
defaultDate: <?= $pedidoEntity->fecha_entrega_real_text ? "'".$pedidoEntity->fecha_entrega_real_text."'" : 'null' ?>,
|
||||||
dateFormat: "d/m/Y",
|
dateFormat: "d/m/Y",
|
||||||
locale: {
|
locale: {
|
||||||
firstDayOfWeek: 1,
|
firstDayOfWeek: 1,
|
||||||
@ -174,12 +175,15 @@ $("#fecha_entrega_real").flatpickr({
|
|||||||
longhand: ['Enero', 'Febreo', 'Мarzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
|
longhand: ['Enero', 'Febreo', 'Мarzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
onChange: function(selectedDates, instance) {
|
onChange: function(selectedDates, dateStr, instance) {
|
||||||
updateDate('fecha_entrega_real', selectedDates);
|
<?php if ($pedidoEntity->estado !== 'finalizado' && $pedidoEntity->estado !== 'cancelado'): ?>
|
||||||
|
updateDate('fecha_entrega_real', dateStr);
|
||||||
|
<?php endif; ?>
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#fecha_impresion").flatpickr({
|
$("#fecha_impresion").flatpickr({
|
||||||
|
defaultDate: <?= $pedidoEntity->fecha_impresion_text ? "'".$pedidoEntity->fecha_impresion_text."'" : 'null' ?>,
|
||||||
dateFormat: "d/m/Y",
|
dateFormat: "d/m/Y",
|
||||||
locale: {
|
locale: {
|
||||||
firstDayOfWeek: 1,
|
firstDayOfWeek: 1,
|
||||||
@ -193,11 +197,14 @@ $("#fecha_impresion").flatpickr({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
onChange: function(selectedDates, dateStr, instance) {
|
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({
|
$("#fecha_encuadernado").flatpickr({
|
||||||
|
defaultDate: <?= $pedidoEntity->fecha_encuadernado_text ? "'".$pedidoEntity->fecha_encuadernado_text."'" : 'null' ?>,
|
||||||
dateFormat: "d/m/Y",
|
dateFormat: "d/m/Y",
|
||||||
locale: {
|
locale: {
|
||||||
firstDayOfWeek: 1,
|
firstDayOfWeek: 1,
|
||||||
@ -211,11 +218,14 @@ $("#fecha_encuadernado").flatpickr({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
onChange: function(selectedDates, dateStr, instance) {
|
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({
|
$("#fecha_entrega_externo").flatpickr({
|
||||||
|
defaultDate: <?= $pedidoEntity->fecha_entrega_externo_text ? "'".$pedidoEntity->fecha_entrega_externo_text."'" : 'null' ?>,
|
||||||
dateFormat: "d/m/Y",
|
dateFormat: "d/m/Y",
|
||||||
locale: {
|
locale: {
|
||||||
firstDayOfWeek: 1,
|
firstDayOfWeek: 1,
|
||||||
@ -229,7 +239,9 @@ $("#fecha_entrega_externo").flatpickr({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
onChange: function(selectedDates, dateStr, instance) {
|
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 = {
|
data = {
|
||||||
<?= csrf_token() ?? "token" ?>: <?= csrf_token() ?>v,
|
<?= 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') ?>';
|
var url = '<?= route_to('actualizarPedido', ':id') ?>';
|
||||||
url = url.replace(':id', id );
|
url = url.replace(':id', id );
|
||||||
|
|||||||
Reference in New Issue
Block a user