From 2f1f6f96317babbf1acdf286d1768c581c85253c Mon Sep 17 00:00:00 2001 From: jaimejimenezortega Date: Sun, 16 Jun 2024 02:10:01 +0200 Subject: [PATCH] terminado --- ci4/app/Controllers/Pedidos/Pedido.php | 50 ++++++++++++++++--- ci4/app/Models/Pedidos/PedidoLineaModel.php | 7 ++- .../vuexy/form/pedidos/_cabeceraItems.php | 27 +++++++--- 3 files changed, 71 insertions(+), 13 deletions(-) diff --git a/ci4/app/Controllers/Pedidos/Pedido.php b/ci4/app/Controllers/Pedidos/Pedido.php index d17b0902..93e41170 100755 --- a/ci4/app/Controllers/Pedidos/Pedido.php +++ b/ci4/app/Controllers/Pedidos/Pedido.php @@ -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)) : ''; } } \ No newline at end of file diff --git a/ci4/app/Models/Pedidos/PedidoLineaModel.php b/ci4/app/Models/Pedidos/PedidoLineaModel.php index de4bb1e9..13308f06 100644 --- a/ci4/app/Models/Pedidos/PedidoLineaModel.php +++ b/ci4/app/Models/Pedidos/PedidoLineaModel.php @@ -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 diff --git a/ci4/app/Views/themes/vuexy/form/pedidos/_cabeceraItems.php b/ci4/app/Views/themes/vuexy/form/pedidos/_cabeceraItems.php index 9dc42d6f..6f269af0 100644 --- a/ci4/app/Views/themes/vuexy/form/pedidos/_cabeceraItems.php +++ b/ci4/app/Views/themes/vuexy/form/pedidos/_cabeceraItems.php @@ -162,6 +162,7 @@ section('additionalInlineJs') ?> $("#fecha_entrega_real").flatpickr({ + defaultDate: 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) { + estado !== 'finalizado' && $pedidoEntity->estado !== 'cancelado'): ?> + updateDate('fecha_entrega_real', dateStr); + } }); $("#fecha_impresion").flatpickr({ + defaultDate: 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); + estado !== 'finalizado' && $pedidoEntity->estado !== 'cancelado'): ?> + updateDate('fecha_impresion', dateStr); + } }); $("#fecha_encuadernado").flatpickr({ + defaultDate: 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); + estado !== 'finalizado' && $pedidoEntity->estado !== 'cancelado'): ?> + updateDate('fecha_encuadernado', dateStr); + } }); $("#fecha_entrega_externo").flatpickr({ + defaultDate: 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); + estado !== 'finalizado' && $pedidoEntity->estado !== 'cancelado'): ?> + updateDate('fecha_entrega_externo', dateStr); + } }); @@ -267,7 +279,10 @@ function updateDate(elementId, dateStr) { data = { : 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 = ''; url = url.replace(':id', id );