diff --git a/.gitignore b/.gitignore index 1d34c84e..4bee8902 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ ci4/.env .vscode/ - +launch.json *xdebug*.log* \ No newline at end of file diff --git a/ci4/app/Config/Filters.php b/ci4/app/Config/Filters.php index b626a639..f17d1127 100755 --- a/ci4/app/Config/Filters.php +++ b/ci4/app/Config/Filters.php @@ -80,5 +80,6 @@ class Filters extends BaseConfig /*'jwt' => [ 'before' => ['api', 'api/*'] ],*/ + ]; } diff --git a/ci4/app/Config/LogoImpresion.php b/ci4/app/Config/LogoImpresion.php new file mode 100644 index 00000000..7de95716 --- /dev/null +++ b/ci4/app/Config/LogoImpresion.php @@ -0,0 +1,31 @@ + "icon_bn", + "lp_bnhq" => "icon_bnhq", + "lp_color" => "icon_color", + "lp_colorhq" => "icon_colorhq", + "lp_cubierta" => "icon_cubierta", + "lp_sobrecubierta" => "icon_sobrecubierta", + "lp_rot_bn" => "icon_rotativa_bn", + "lp_rot_color" => "icon_rotativa_color", + "lp_guardas" => "icon_cuardas" + + ]; + + public function __construct() + { + parent::__construct(); + } + public function get_logo_path(string $tipo): string + { + return "themes/vuexy/img/safekat/presupuestos/" . $this->TIPO_IMPRESION_MAPPING[$tipo] . ".png"; + } +} diff --git a/ci4/app/Config/RBAC/permissionMatrix.php b/ci4/app/Config/RBAC/permissionMatrix.php index f720b8cb..8f2be0dc 100644 --- a/ci4/app/Config/RBAC/permissionMatrix.php +++ b/ci4/app/Config/RBAC/permissionMatrix.php @@ -142,10 +142,14 @@ const SK_PERMISSION_MATRIX = [ "presupuesto.edit", "presupuesto.delete", "presupuesto.menu", - "presupuesto-cliente.create", - "presupuesto-cliente.edit", - "presupuesto-cliente.delete", - "presupuesto-cliente.menu", + "pedidos-activos.view", + "pedidos-activos.menu", + "pedidos-finalizados.view", + "pedidos-finalizados.menu", + "pedidos-cancelados.view", + "pedidos-cancelados.menu", + "pedidos-todos.view", + "pedidos-todos.menu", "tarifa-preimpresion.create", "tarifa-preimpresion.edit", "tarifa-preimpresion.delete", diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index fd475aec..e0e82453 100644 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -37,6 +37,34 @@ $routes->group('settings', ['namespace' => 'App\Controllers\Sistema'], function /* Rutas para tarifas */ $routes->group('tarifas', ['namespace' => 'App\Controllers\Tarifas'], function ($routes) { + /* Maquinas */ + $routes->group('maquinas', ['namespace' => 'App\Controllers\Tarifas\Maquinas'], function ($routes) { + + $routes->post('acabado', 'TarifaMaquinas::add_tarifa_acabado_maquina_with_tarea'); + $routes->post('manipulado', 'TarifaMaquinas::add_tarifa_manipulado_maquina_with_tarea'); + $routes->post('preimpresion', 'TarifaMaquinas::add_tarifa_preimpresion_maquina_with_tarea'); + $routes->post('encuadernacion', 'TarifaMaquinas::add_tarifa_encuadernacion_maquina_with_tarea'); + $routes->post('extra', 'TarifaMaquinas::add_tarifa_extra_maquina_with_tarea'); + + $routes->delete('acabado/(:num)', 'TarifaMaquinas::delete_tarifa_acabado_maquina_with_tarea/$1'); + $routes->delete('manipulado/(:num)', 'TarifaMaquinas::delete_tarifa_manipulado_maquina_with_tarea/$1'); + $routes->delete('preimpresion/(:num)', 'TarifaMaquinas::delete_tarifa_preimpresion_maquina_with_tarea/$1'); + $routes->delete('encuadernacion/(:num)', 'TarifaMaquinas::delete_tarifa_encuadernacion_maquina_with_tarea/$1'); + $routes->delete('extra/(:num)', 'TarifaMaquinas::delete_tarifa_extra_maquina_with_tarea/$1'); + + $routes->get('acabado/select', 'TarifaMaquinas::get_select_maquina_acabado'); + $routes->get('manipulado/select', 'TarifaMaquinas::get_select_maquina_manipulado'); + $routes->get('impresion/select', 'TarifaMaquinas::get_select_maquina_impresion'); + $routes->get('tareas/select', 'TarifaMaquinas::get_select_maquina_tareas'); + + + + $routes->get('acabado/datatable/(:num)', 'TarifaMaquinas::get_datatable_tarifa_acabado_maquina/$1'); + $routes->get('manipulado/datatable/(:num)', 'TarifaMaquinas::get_datatable_tarifa_manipulado_maquina/$1'); + $routes->get('preimpresion/datatable/(:num)', 'TarifaMaquinas::get_datatable_tarifa_preimpresion_maquina/$1'); + $routes->get('encuadernacion/datatable/(:num)', 'TarifaMaquinas::get_datatable_tarifa_encuadernacion_maquina/$1'); + $routes->get('extra/datatable/(:num)', 'TarifaMaquinas::get_datatable_tarifa_extra_maquina/$1'); + }); /* Cliente */ $routes->group('acabados', ['namespace' => 'App\Controllers\Tarifas\Acabados'], function ($routes) { @@ -45,7 +73,7 @@ $routes->group('tarifas', ['namespace' => 'App\Controllers\Tarifas'], function ( $routes->match(['get', 'post'], 'edit/(:num)', 'TarifaAcabados::edit/$1', ['as' => 'tarifaAcabadoEdit']); $routes->get('delete/(:num)', 'TarifaAcabados::delete/$1', ['as' => 'tarifaAcabadoDelete']); $routes->post('datatable', 'TarifaAcabados::datatable', ['as' => 'tarifaAcabadoDT']); - + $routes->get('select', 'TarifaAcabados::show_select', ["as" => "showSelectTarifaAcabado"]); $routes->group('lineas', ['namespace' => 'App\Controllers\Tarifas\Acabados'], function ($routes) { $routes->post('datatable', 'TarifaAcabadosLineas::datatable', ['as' => 'tarifaAcabadoLineasDT']); $routes->post('datatable_editor', 'TarifaAcabadosLineas::datatable_editor', ['as' => 'tarifaAcabadoLineasDTE']); @@ -77,7 +105,7 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion'] $routes->post('menuitemsFacturas', 'SeriesFacturas::menuItemsFacturas', ['as' => 'menuItemsOfSeriesFacturas']); }); - + $routes->group("variables", ["namespace" => 'App\Controllers\Configuracion'], function ($routes) { $routes->get('', 'ConfigVariables::index', ['as' => 'variablesIndex']); $routes->get('find/(:num)', 'ConfigVariables::get/$1', ['as' => 'variablesFind']); @@ -92,6 +120,14 @@ $routes->group('configuracion', ['namespace' => 'App\Controllers\Configuracion'] $routes->get('datatable', 'ConfigErrores::datatable', ['as' => 'erroresPresupuestoDatatable']); $routes->post('edit/(:num)', 'ConfigErrores::update_error_presupuesto/$1', ['as' => 'erroresPresupuestoUpdate']); }); + $routes->group("servicios", ["namespace" => 'App\Controllers\Configuracion'], function ($routes) { + $routes->get('', 'ServicioCliente::index', ['as' => 'servicioClienteList']); + $routes->get('(:num)', 'ServicioCliente::show/$1', ['as' => 'servicioClienteShow']); + $routes->post('(:num)', 'ServicioCliente::store/$1', ['as' => 'servicioClienteStore']); + $routes->post('update/(:num)', 'ServicioCliente::update_servicio_cliente/$1', ['as' => 'updateServicioCliente']); + $routes->get('edit/(:num)', 'ServicioCliente::viewForm/$1', ['as' => 'servicioClienteViewForm']); + $routes->get('datatable', 'ServicioCliente::datatable', ['as' => 'servicioClienteDatatable']); + }); }); @@ -160,6 +196,7 @@ $routes->group('tarifasmanipulado', ['namespace' => 'App\Controllers\Tarifas'], $routes->post('datatable', 'Tarifasmanipulado::datatable', ['as' => 'dataTableOfTarifasManipulado']); $routes->post('allmenuitems', 'Tarifasmanipulado::allItemsSelect', ['as' => 'select2ItemsOfTarifasManipulado']); $routes->post('menuitems', 'Tarifasmanipulado::menuItems', ['as' => 'menuItemsOfTarifasManipulado']); + $routes->get('select', 'Tarifasmanipulado::show_select', ["as" => "showSelectTarifaManipulado"]); }); $routes->resource('tarifasmanipulado', ['namespace' => 'App\Controllers\Tarifas', 'controller' => 'Tarifasmanipulado', 'except' => 'show,new,create,update']); @@ -263,6 +300,7 @@ $routes->group('maquinas', ['namespace' => 'App\Controllers\Configuracion'], fun $routes->post('datatable', 'Maquinas::datatable', ['as' => 'dataTableOfMaquinas']); $routes->post('allmenuitems', 'Maquinas::allItemsSelect', ['as' => 'select2ItemsOfMaquinas']); $routes->post('menuitems', 'Maquinas::menuItems', ['as' => 'menuItemsOfMaquinas']); + $routes->get('select', 'Maquinas::select', ['as' => 'selectMaquinas']); }); $routes->resource('maquinas', ['namespace' => 'App\Controllers\Configuracion', 'controller' => 'Maquinas', 'except' => 'show,new,create,update']); @@ -663,6 +701,7 @@ $routes->group('pedidos', ['namespace' => 'App\Controllers\Pedidos'], function ( $routes->post('cambiarestado', 'Pedido::cambiarEstado', ['as' => 'cambiarEstadoPedido']); $routes->post('update/(:any)', 'Pedido::update/$1', ['as' => 'actualizarPedido']); $routes->get('xml/(:num)', 'Pedido::get_xml_pedido/$1', ['as' => 'getXMLPedido']); + $routes->post('produccion/(:num)', 'Pedido::to_produccion/$1', ['as' => 'toProduccion']); }); $routes->resource('pedidos', ['namespace' => 'App\Controllers\Pedidos', 'controller' => 'Pedido', 'except' => 'show,new,create,update']); @@ -794,11 +833,9 @@ $routes->group('messages', ['namespace' => 'App\Controllers\Chat'], function ($r $routes->post('direct', 'ChatController::store_new_direct_message', ['as' => 'storeNewDirectMessage']); $routes->post('direct/client', 'ChatController::store_new_direct_message_client', ['as' => 'storeNewDirectMessageClient']); - - }); $routes->group('chat', ['namespace' => 'App\Controllers\Chat'], function ($routes) { - + $routes->get('direct/(:num)', 'ChatController::get_chat_direct_view/$1', ['as' => 'getChatDirectView']); $routes->get('presupuesto/(:num)', 'ChatController::get_chat_presupuesto_view/$1', ['as' => 'getChatPresupuestoView']); $routes->get('pedido/(:num)', 'ChatController::get_chat_pedido_view/$1', ['as' => 'getChatPedidoView']); @@ -806,7 +843,7 @@ $routes->group('chat', ['namespace' => 'App\Controllers\Chat'], function ($route $routes->get('direct/conversation/(:num)', 'ChatController::get_chat_direct/$1', ['as' => 'getChatDirect']); $routes->get('direct/users/select/(:num)', 'ChatController::get_chat_direct_select_users/$1', ['as' => 'getChatDirectSelectUsers']); - + $routes->get('direct/client/users/select/presupuesto/(:num)', 'ChatController::get_presupuesto_client_users/$1/$2', ['as' => 'getPresupuestoClientUsers']); $routes->get('direct/client/users/select/pedido/(:num)', 'ChatController::get_pedido_client_users/$1/$2', ['as' => 'getPedidoClientUsers']); $routes->get('direct/client/users/select/factura/(:num)', 'ChatController::get_factura_client_users/$1/$2', ['as' => 'getFacturaClientUsers']); @@ -848,6 +885,40 @@ $routes->group('chat', ['namespace' => 'App\Controllers\Chat'], function ($route }); + +$routes->group('produccion', ['namespace' => 'App\Controllers\Produccion'], function ($routes) { + $routes->group('ordentrabajo', ['namespace' => 'App\Controllers\Produccion'], function ($routes) { + $routes->get('', 'Ordentrabajo::index', ['as' => 'viewOrdenTrabajoIndex']); + $routes->get('edit/(:num)', 'Ordentrabajo::edit/$1', ['as' => 'viewOrdenTrabajoEdit']); + $routes->delete('reset/tareas/(:num)', 'Ordentrabajo::reset_tareas/$1'); + $routes->delete('tareas/(:num)', 'Ordentrabajo::delete_tarea/$1'); + $routes->get('summary/(:num)', 'Ordentrabajo::get_orden_trabajo_summary/$1', ['as' => 'getOrdenTrabajoSumary']); + $routes->get('datatable', 'Ordentrabajo::datatable'); + $routes->get('datatable_pendientes', 'Ordentrabajo::datatable_pendientes'); + $routes->get('datatable_ferro_pendiente', 'Ordentrabajo::datatable_ferro_pendiente'); + $routes->get('datatable_ferro_ok', 'Ordentrabajo::datatable_ferro_ok'); + $routes->get('tareas/datatable/(:num)', 'Ordentrabajo::tareas_datatable/$1', ['as' => 'datatableTareasOrdenTrabajo']); + /**====================== + * UPDATES + *========================**/ + $routes->post("update/tarea", 'Ordentrabajo::update_orden_trabajo_tarea'); + $routes->post("update/date", 'Ordentrabajo::update_orden_trabajo_date'); + $routes->post("update/user", 'Ordentrabajo::update_orden_trabajo_user'); + $routes->post("update", 'Ordentrabajo::update_orden_trabajo'); + $routes->post("upload/portada", 'Ordentrabajo::upload_orden_trabajo_portada'); + + /**====================== + * PDF + *========================**/ + $routes->get('pdf/(:num)', 'Ordentrabajo::get_pdf/$1'); + $routes->get('portada/(:num)', 'Ordentrabajo::get_portada_img/$1'); + $routes->group('planning', ['namespace' => 'App\Controllers\Produccion'], function ($routes) { + $routes->get('rotativa', 'Ordentrabajo::index_planning_rotativa'); + $routes->get('papel/datatable', 'Ordentrabajo::papel_gramaje_datatable'); + $routes->get('rotativa/datatable', 'Ordentrabajo::planning_rotativa_datatable'); + }); + }); +}); /* * -------------------------------------------------------------------- * APIs Route Definitions @@ -886,4 +957,4 @@ $routes->resource('translate', ['namespace' => 'App\Controllers', 'controller' = */ if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) { require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php'; -} \ No newline at end of file +} diff --git a/ci4/app/Config/Services.php b/ci4/app/Config/Services.php index a802b838..3f76f76e 100755 --- a/ci4/app/Config/Services.php +++ b/ci4/app/Config/Services.php @@ -4,6 +4,8 @@ namespace Config; use App\Services\FTPService; use CodeIgniter\Config\BaseService; +use App\Services\ProductionService; +use App\Services\TarifaMaquinaService; /** * Services Configuration file. @@ -30,4 +32,10 @@ class Services extends BaseService * return new \CodeIgniter\Example(); * } */ + public static function production(){ + return new ProductionService(); + } + public static function tarifa_maquina(){ + return new TarifaMaquinaService(); + } } diff --git a/ci4/app/Config/Validation.php b/ci4/app/Config/Validation.php index cb05c77a..d07aade1 100755 --- a/ci4/app/Config/Validation.php +++ b/ci4/app/Config/Validation.php @@ -43,5 +43,108 @@ class Validation extends BaseConfig // Rules // -------------------------------------------------------------------- + /**======================================================================== + * TARIFA MAQUINA ACABADO + *========================================================================**/ + public array $tarifa_maquina_acabado = + [ + "tarifa_acabado_id" => [ + "rules" => "required|integer", + "label" => "tarifa acabado", + ], + "maquina_id" => [ + "rules" => "required|integer", + "label" => "maquina", + ], + "maquina_tarea_id" => [ + "rules" => "required|integer", + "label" => "tarea", + ], + ]; + public array $tarifa_maquina_manipulado = + [ + "tarifa_manipulado_id" => [ + "rules" => "required|integer", + "label" => "tarifa acabado", + ], + "maquina_id" => [ + "rules" => "required|integer", + "label" => "maquina", + ], + "maquina_tarea_id" => [ + "rules" => "required|integer", + "label" => "tarea", + ], + ]; + public array $tarifa_maquina_preimpresion = + [ + "tarifa_preimpresion_id" => [ + "rules" => "required|integer", + "label" => "tarifa acabado", + ], + "maquina_id" => [ + "rules" => "required|integer", + "label" => "maquina", + ], + "maquina_tarea_id" => [ + "rules" => "required|integer", + "label" => "tarea", + ], + ]; + public array $tarifa_maquina_encuadernacion = + [ + "tarifa_encuadernacion_id" => [ + "rules" => "required|integer", + "label" => "tarifa acabado", + ], + "maquina_id" => [ + "rules" => "required|integer", + "label" => "maquina", + ], + "maquina_tarea_id" => [ + "rules" => "required|integer", + "label" => "tarea", + ], + ]; + public array $tarifa_maquina_extra = + [ + "tarifa_extra_id" => [ + "rules" => "required|integer", + "label" => "tarifa acabado", + ], + "maquina_id" => [ + "rules" => "required|integer", + "label" => "maquina", + ], + "maquina_tarea_id" => [ + "rules" => "required|integer", + "label" => "tarea", + ], + ]; + public array $orden_trabajo_tarea = [ + + "orden_trabajo_tarea_id" => [ + "rules" => "required|integer", + "label" => "tarea" + ], + // "tiempo_real" => [ + // "rules" => "required|float", + // "label" => "tiempo real" + // ] + ]; + public array $orden_trabajo_date = [ + "orden_trabajo_id" => [ + "rules" => "required|integer", + "label" => "tarea" + ], + + ]; + public array $orden_trabajo = [ + "orden_trabajo_id" => [ + "rules" => "required|integer", + "label" => "Orden trabajo" + ], + + ]; } diff --git a/ci4/app/Controllers/Configuracion/Maquinas.php b/ci4/app/Controllers/Configuracion/Maquinas.php index 8deac302..406f44f8 100755 --- a/ci4/app/Controllers/Configuracion/Maquinas.php +++ b/ci4/app/Controllers/Configuracion/Maquinas.php @@ -356,7 +356,10 @@ class Maquinas extends \App\Controllers\BaseResourceController } } - + public function select(){ + $r = $this->model->getSelectQuery($this->request->getGet("q")); + return $this->response->setJSON($r); + } protected function getMaquinaListItems($selId = null) { $data = ['' => lang('Basic.global.pleaseSelectA', [mb_strtolower(lang('Maquinas.maquina'))])]; diff --git a/ci4/app/Controllers/Configuracion/ServicioCliente.php b/ci4/app/Controllers/Configuracion/ServicioCliente.php new file mode 100644 index 00000000..bc282142 --- /dev/null +++ b/ci4/app/Controllers/Configuracion/ServicioCliente.php @@ -0,0 +1,89 @@ +servicioClienteModel = model(ServicioClienteModel::class); + } + + + public function index() + { + $this->viewData['breadcrumb'] = [ + ['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false], + ['title' => lang("App.menu_servicios_cliente"), 'route' => site_url('configuracion/servicios'), 'active' => true] + ]; + return view(static::$viewPath . $this->indexRoute, $this->viewData); + } + public function viewForm(int $servicio_cliente_id) + { + $servicioCliente = $this->servicioClienteModel->find($servicio_cliente_id); + $this->viewData['breadcrumb'] = [ + ['title' => lang("App.menu_configuration"), 'route' => "javascript:void(0);", 'active' => false], + ['title' => lang("App.menu_servicios_cliente"), 'route' => site_url('configuracion/servicios'), 'active' => false], + ['title' => $servicioCliente->nombre, 'route' => site_url('configuracion/servicios/edit/' . $servicio_cliente_id), 'active' => true] + ]; + $this->viewData["model"] = $servicioCliente; + + return view(static::$viewPath . 'ServicioClienteEdit', $this->viewData); + } + public function show(int $id) + { + $data = $this->servicioClienteModel->find($id)->withAllTarifas(); + return $this->response->setJSON($data); + } + public function update_servicio_cliente(int $id) + { + $data = $this->request->getPost(); + $status = $this->servicioClienteModel->update($id, [ + "nombre" => $data["nombre"], + "code" => $data["code"] + ]); + if (isset($data["tarifa_manipulado_id"])) { + $this->servicioClienteModel->upsertTarifaManipulado($id, $data["tarifa_manipulado_id"]); + }else if(isset($data["tarifa_acabado_id"])) { + + $this->servicioClienteModel->upsertTarifaAcabado($id, $data["tarifa_acabado_id"]); + }else{ + $this->servicioClienteModel->detachTarifas($id); + } + + return $this->response->setJSON(["message" => lang("App.global_success"), "status" => $status]); + } + public function store() + { + // $this->servicioClienteModel->update($id,[$this->request->getPost()]); + return $this->response->setJSON([]); + } + public function datatable() + { + $query = $this->servicioClienteModel->getQueryDatatable()->orderBy("created_at", "DESC"); + return DataTable::of($query) + ->edit('created_at', fn($q) => $q->created_at ? Time::createFromFormat('Y-m-d H:i:s', $q->created_at)->format("d/m/Y H:i") : "") + ->add("action", fn($q) => $q->id) + ->toJson(true); + } +} diff --git a/ci4/app/Controllers/Pedidos/Pedido.php b/ci4/app/Controllers/Pedidos/Pedido.php index 5c499b73..4cfa2a1d 100755 --- a/ci4/app/Controllers/Pedidos/Pedido.php +++ b/ci4/app/Controllers/Pedidos/Pedido.php @@ -6,6 +6,7 @@ use App\Entities\Pedidos\PedidoEntity; use App\Models\Collection; use App\Models\Pedidos\PedidoModel; use App\Services\PedidoXMLService; +use App\Services\ProductionService; class Pedido extends \App\Controllers\BaseResourceController { @@ -388,5 +389,20 @@ class Pedido extends \App\Controllers\BaseResourceController // $xml_service = new PedidoXMLService($this->model); return $this->respond($data); } + + public function to_produccion($pedido_id) + { + $serviceProduction = service('production'); + $pedido = $this->model->find($pedido_id); + $serviceProduction->setPedido($pedido); + if($pedido->orden_trabajo()){ + return $this->response->setJSON(["data"=>$pedido->orden_trabajo(),"message" => "Ya existe una orden de trabajo para este pedido"]); + + }else{ + $r = $serviceProduction->createOrdenTrabajo(); + return $this->response->setJSON(["data"=>$r,"message" => "Orden trabajo creada correctamente"]); + } + } + } \ No newline at end of file diff --git a/ci4/app/Controllers/Produccion/Ordentrabajo.php b/ci4/app/Controllers/Produccion/Ordentrabajo.php index 63fe7ca2..a6fe5e73 100755 --- a/ci4/app/Controllers/Produccion/Ordentrabajo.php +++ b/ci4/app/Controllers/Produccion/Ordentrabajo.php @@ -1,50 +1,268 @@ otModel = model(OrdenTrabajoModel::class); + $this->userModel = model(UserModel::class); + $this->produccionService = new ProductionService(); + $this->otTarea = model(OrdenTrabajoTarea::class); + $this->validation = service("validation"); + helper("time"); + parent::initController($request, $response, $logger); } public function index() { - echo 'Orden trabajo'; + // Breadcrumbs + $this->viewData['breadcrumb'] = [ + ['title' => lang("Produccion.ot"), 'route' => "javascript:void(0);", 'active' => false], + ['title' => lang("Produccion.ots"), 'route' => site_url('produccion/ordentrabajo'), 'active' => true] + ]; + return view(static::$viewPath . $this->indexRoute, $this->viewData); + } + public function index_planning_rotativa() + { + // Breadcrumbs + $this->viewData['breadcrumb'] = [ + ['title' => lang("Produccion.ots"), 'route' => "javascript:void(0);", 'active' => false], + ['title' => lang("Produccion.ots"), 'route' => site_url('produccion/ordentrabajo/planning/rotativa'), 'active' => true] + ]; + return view(static::$viewPath . $this->indexRoutePlanning, $this->viewData); } - public function delete() + + public function get_orden_trabajo_summary($orden_trabajo_id) + { + $summary = $this->produccionService->init($orden_trabajo_id)->getSummary(); + return $this->response->setJSON($summary); + } + public function add() {} + + /**======================================================================== + * UPDATES + *========================================================================**/ + public function update_orden_trabajo() + { + $bodyData = $this->request->getPost(); + // return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "data" => $bodyData]); + $validated = $this->validation->run($bodyData, "orden_trabajo"); + if ($validated) { + $r = $this->produccionService->init($bodyData["orden_trabajo_id"])->updateOrdenTrabajo($bodyData); + return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "data" => $bodyData]); + } else { + return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400); + } + } + public function update_orden_trabajo_tarea() + { + $bodyData = $this->request->getPost(); + // return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "data" => $bodyData]); + $validated = $this->validation->run($bodyData, "orden_trabajo_tarea"); + if ($validated) { + $r = $this->produccionService->updateOrdenTrabajoTarea($bodyData["orden_trabajo_tarea_id"], $bodyData); + return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r, "data" => $bodyData]); + } else { + return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400); + } + } + public function update_orden_trabajo_date() + { + $bodyData = $this->request->getPost(); + // return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "data" => $bodyData]); + $validated = $this->validation->run($bodyData, "orden_trabajo_date"); + if ($validated) { + $r = $this->produccionService->init($bodyData["orden_trabajo_id"])->updateOrdenTrabajoDate($bodyData); + return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => $r["status"], "user" => $r["user"], "data" => $bodyData]); + } else { + return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400); + } + } + + public function edit($orden_trabajo_id) + { + // Breadcrumbs + $this->viewData['breadcrumb'] = [ + ['title' => lang("Produccion.ot"), 'route' => site_url('produccion/ordentrabajo'), 'active' => false], + ['title' => $this->otModel->find($orden_trabajo_id)->pedido()->presupuesto()->titulo, 'route' => site_url('produccion/ordentrabajo/edit/' . $orden_trabajo_id), 'active' => true] + ]; + $this->viewData["modelId"] = $orden_trabajo_id; + $this->produccionService->init($orden_trabajo_id); + $this->viewData["presupuesto"] = $this->produccionService->getPresupuesto(); + $this->viewData["cliente"] = $this->produccionService->getCliente(); + $this->viewData["ot"] = $this->produccionService->getOrdenTrabajo(); + return view(static::$viewPath . $this->editRoute, $this->viewData); + } + + public function datatable() + { + $logo = config(LogoImpresion::class); + + $q = $this->otModel->getDatatableQuery()->where("ordenes_trabajo.estado","F"); + // return $this->response->setJSON($q->get()->getResultArray()); + return DataTable::of($q) + ->add("logo",fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo))) + ->edit( + "fecha_encuadernado_at", + fn($q) => Time::createFromFormat("Y-m-d",$q->fecha_encuadernado_at)->format("d/m/Y") + ) + ->add("action", fn($q) => $q->id) + ->toJson(true); + } + public function datatable_pendientes() + { + $logo = config(LogoImpresion::class); + + $q = $this->otModel->getDatatableQuery()->whereIn("ordenes_trabajo.estado",["I","PM"]); + // return $this->response->setJSON($q->get()->getResultArray()); + return DataTable::of($q) + ->add("logo",fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo))) + ->edit( + "fecha_encuadernado_at", + fn($q) => Time::createFromFormat("Y-m-d",$q->fecha_encuadernado_at)->format("d/m/Y") + ) + ->add("action", fn($q) => $q->id) + ->toJson(true); + } + public function datatable_ferro_pendiente() + { + $logo = config(LogoImpresion::class); + + $q = $this->otModel->getDatatableQuery()->where("ferro_ok_at",null); + // return $this->response->setJSON($q->get()->getResultArray()); + return DataTable::of($q) + ->add("logo",fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo))) + ->edit( + "fecha_encuadernado_at", + fn($q) => Time::createFromFormat("Y-m-d",$q->fecha_encuadernado_at)->format("d/m/Y") + ) + ->add("action", fn($q) => $q->id) + ->toJson(true); + } + public function datatable_ferro_ok() + { + $logo = config(LogoImpresion::class); + + $q = $this->otModel->getDatatableQuery()->where("ferro_ok_at is NOT NULL",NULL,FALSE); + // return $this->response->setJSON($q->get()->getResultArray()); + return DataTable::of($q) + ->add("logo",fn($q) => site_url($logo->get_logo_path($q->presupuesto_linea_tipo))) + ->edit( + "fecha_encuadernado_at", + fn($q) => Time::createFromFormat("Y-m-d",$q->fecha_encuadernado_at)->format("d/m/Y") + ) + ->add("action", fn($q) => $q->id) + ->toJson(true); + } + public function papel_gramaje_datatable() { + $q = $this->produccionService->papelGramajeDatatableQuery(); + return DataTable::of($q) + ->edit("tiempoReal", fn($q) => float_seconds_to_hhmm_string($q->tiempoReal * 3600)) + ->toJson(true); } - - public function add() + public function reset_tareas(int $orden_trabajo_id) { - + $r = $this->produccionService->init($orden_trabajo_id)->resetAllTareas(); + return $this->response->setJSON(["message" => "Tareas reseteadas", "status" => $r]); } - - public function edit() + public function delete_tarea(int $orden_trabajo_tarea_id) { - + $r = $this->otTarea->delete($orden_trabajo_tarea_id); + return $this->response->setJSON(["message" => "Tarea eliminada", "states" => $r]); } - - public function cien() + public function tareas_datatable(int $orden_trabajo_id) { - echo 'Orden trabajo 100%'; + $q = $this->produccionService->init($orden_trabajo_id)->taskDatatableQuery($orden_trabajo_id); + // return $this->response->setJSON($q->get()->getResultArray()); + return DataTable::of($q) + ->add("action", fn($q) => $q) + ->edit("orden", fn($q) => ["id" => $q->id, "orden" => $q->orden]) + ->edit("tiempo_estimado", fn($q) => float_seconds_to_hhmm_string($q->tiempo_estimado)) + ->edit("tiempo_real", fn($q) => float_seconds_to_hhmm_string($q->tiempo_real)) + ->edit("maquina_tarea", fn($q) => ["id" => $q->id, "maquina_id" => $q->maquina_tarea, "maquina_name" => $q->maquina_nombre]) + ->toJson(true); } - - public function finalizado() + public function get_pdf($orden_trabajo_id) { - echo 'Orden trabajo finalizado'; + return $this->produccionService->init($orden_trabajo_id)->getPdf(); } - - public function pendiente() + public function upload_orden_trabajo_portada() { - echo 'Orden trabajo pendiente'; + try { + //code... + $file = $this->request->getFile("portada_file"); + $bodyData = $this->request->getPost(); + $id = $bodyData["orden_trabajo_id"]; + $r = null; + $fullpath = null; + if ($file->isValid() && !$file->hasMoved()) { + $fullpath = $file->store('ordenes_trabajo_portadas'); + $r = $this->otModel->update($id, ["portada_path" => $fullpath]); + } + return $this->response->setJSON(["message" => "Portada subida", "data" => $r]); + } catch (\Throwable $th) { + if ($fullpath) { + delete_files($fullpath); + } + return $this->response->setJSON(["message" => "Portada error", "error" => $th->getMessage()])->setStatusCode($th->getCode()); + } + } + public function get_portada_img($orden_trabajo_id) + { + $ot = $this->otModel->find($orden_trabajo_id); + if ($ot->portada_path) { + $filePath = WRITEPATH . 'uploads/' . $ot->portada_path; + $mimeType = mime_content_type($filePath); + return $this->response + ->setHeader('Content-Type', $mimeType) + ->setHeader('Content-Length', filesize($filePath)) + ->setBody(file_get_contents($filePath)); + } else { + return $this->response->setJSON(["message" => "Portada error", "error" => "No hay portada"])->setStatusCode(400); + } + } + public function planning_rotativa_datatable() + { + $q = $this->produccionService->planningRotativaQueryDatatable(); + return DataTable::of($q) + ->edit("fecha_entrega_real_at", fn($q) => $q->fecha_entrega_real_at ? Time::createFromFormat("Y-m-d", $q->fecha_entrega_real_at)->format("d/m/Y") : "") + ->add("action", fn($q) => $q) + ->toJson(true); } - } - \ No newline at end of file diff --git a/ci4/app/Controllers/Tarifas/Acabados/TarifaAcabados.php b/ci4/app/Controllers/Tarifas/Acabados/TarifaAcabados.php index 85920898..7c4d4c54 100644 --- a/ci4/app/Controllers/Tarifas/Acabados/TarifaAcabados.php +++ b/ci4/app/Controllers/Tarifas/Acabados/TarifaAcabados.php @@ -1,4 +1,6 @@ -viewData['proveedores'] = $this->getProveedores(); + $this->viewData['proveedores'] = $this->getProveedores(); $this->viewData['tarifaacabadoEntity'] = isset($sanitizedData) ? new TarifaAcabadoEntity($sanitizedData) : new TarifaAcabadoEntity(); $this->viewData['formAction'] = route_to('tarifaAcabadoAdd'); @@ -169,7 +171,7 @@ class TarifaAcabados extends BaseResourceController // JJO $sanitizedData['user_updated_id'] = auth()->user()->id; - + if ($this->request->getPost('mostrar_en_presupuesto') == null) { $sanitizedData['mostrar_en_presupuesto'] = false; } @@ -181,7 +183,7 @@ class TarifaAcabados extends BaseResourceController if ($this->request->getPost('acabado_sobrecubierta') == null) { $sanitizedData['acabado_sobrecubierta'] = false; } - + $noException = true; if ($successfulResult = $this->canValidate()) : // if ($successfulResult = $this->validate($this->formValidationRules) ) : @@ -207,7 +209,7 @@ class TarifaAcabados extends BaseResourceController if ($noException && $successfulResult) : $id = $tarifaacabadoEntity->id ?? $id; - $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) .'.'; + $message = lang('Basic.global.updateSuccess', [lang('Basic.global.record')]) . '.'; if ($thenRedirect) : if (!empty($this->indexRoute)) : @@ -312,12 +314,26 @@ class TarifaAcabados extends BaseResourceController } } - private function getProveedores(){ + private function getProveedores() + { $provTipoModel = new ProveedorTipoModel(); $provModel = new ProveedorModel(); $tipoId = $provTipoModel->getTipoId("Acabados"); return $provModel->getProvList($tipoId); } - + public function show_select() + { + $query = $this->model->builder() + ->select( + ["id", "nombre as name", "code as description"] + ) + ->where("deleted_at",null); + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("nombre", $this->request->getGet("q")) + ->groupEnd(); + } + return $this->response->setJSON($query->get()->getResultObject()); + } } diff --git a/ci4/app/Controllers/Tarifas/Maquinas/TarifaMaquinas.php b/ci4/app/Controllers/Tarifas/Maquinas/TarifaMaquinas.php new file mode 100644 index 00000000..7d6cd5c0 --- /dev/null +++ b/ci4/app/Controllers/Tarifas/Maquinas/TarifaMaquinas.php @@ -0,0 +1,205 @@ +maquinaModel = model(MaquinaModel::class); + $this->maquinaTareaModel = model(MaquinaTareaModel::class); + $this->tarifaMaquinaService = service("tarifa_maquina"); + $this->validation = service("validation"); + parent::initController($request, $response, $logger); + } + /**======================================================================== + * CREATE + *========================================================================**/ + + public function add_tarifa_acabado_maquina_with_tarea() + { + $bodyData = $this->request->getPost(); + $validated = $this->validation->run($bodyData, "tarifa_maquina_acabado"); + if ($validated) { + $r = $this->tarifaMaquinaService->attachAcabadoToMaquina(...$bodyData); + return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => true, "data" => $r]); + } else { + return $this->response->setJSON($this->validation->getErrors())->setStatusCode(400); + } + } + public function add_tarifa_manipulado_maquina_with_tarea() + { + $bodyData = $this->request->getPost(); + $validated = $this->validation->run($bodyData, "tarifa_maquina_manipulado"); + if ($validated) { + $r = $this->tarifaMaquinaService->attachManipuladoToMaquina(...$bodyData); + return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => true, "data" => $r]); + } else { + return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400); + } + } + public function add_tarifa_preimpresion_maquina_with_tarea() + { + $bodyData = $this->request->getPost(); + $validated = $this->validation->run($bodyData, "tarifa_maquina_preimpresion"); + if ($validated) { + + $r = $this->tarifaMaquinaService->attachPreimpresionToMaquina(...$bodyData); + return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => true, "data" => $r]); + } else { + return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400); + } + } + public function add_tarifa_encuadernacion_maquina_with_tarea() + { + $bodyData = $this->request->getPost(); + $validated = $this->validation->run($bodyData, "tarifa_maquina_encuadernacion"); + if ($validated) { + + $r = $this->tarifaMaquinaService->attachEncuadernacionToMaquina(...$bodyData); + return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => true, "data" => $r]); + } else { + return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400); + } + } + public function add_tarifa_extra_maquina_with_tarea() + { + $bodyData = $this->request->getPost(); + $validated = $this->validation->run($bodyData, "tarifa_maquina_encuadernacion"); + if ($validated) { + $r = $this->tarifaMaquinaService->attachExtraToMaquina(...$bodyData); + return $this->response->setJSON(["message" => lang("App.global_alert_save_success"), "status" => true, "data" => $r]); + } else { + return $this->response->setJSON(["errors" => $this->validation->getErrors()])->setStatusCode(400); + } + } + /**======================================================================== + * DELETES + *========================================================================**/ + public function delete_tarifa_acabado_maquina_with_tarea($tarifa_acabado_maquina_id) + { + $m = model(TarifaAcabadoMaquinaModel::class); + $r = $m->delete($tarifa_acabado_maquina_id); + return $this->response->setJSON(["message" => lang("App.user_alert_delete"), "status" => true, "data" => $r]); + + } + public function delete_tarifa_manipulado_maquina_with_tarea($tarifa_manipulado_maquina_id) + { + $m = model(TarifaManipuladoMaquinaModel::class); + $r = $m->delete($tarifa_manipulado_maquina_id); + return $this->response->setJSON(["message" => lang("App.user_alert_delete"), "status" => true, "data" => $r]); + + } + public function delete_tarifa_encuadernacion_maquina_with_tarea($tarifa_encuadernacion_maquina_id) + { + $m = model(TarifaEncuadernacionMaquinaModel::class); + $r = $m->delete($tarifa_encuadernacion_maquina_id); + return $this->response->setJSON(["message" => lang("App.user_alert_delete"), "status" => true, "data" => $r]); + + } + public function delete_tarifa_preimpresion_maquina_with_tarea($tarifa_preimpresion_maquina_id) + { + $m = model(TarifaPreimpresionMaquinaModel::class); + $r = $m->delete($tarifa_preimpresion_maquina_id); + return $this->response->setJSON(["message" => lang("App.user_alert_delete"), "status" => true, "data" => $r]); + + } + public function delete_tarifa_extra_maquina_with_tarea($tarifa_extra_maquina_id) + { + $m = model(TarifaExtraMaquinaModel::class); + $r = $m->delete($tarifa_extra_maquina_id); + return $this->response->setJSON(["message" => lang("App.user_alert_delete"), "status" => true, "data" => $r]); + + } + + /**======================================================================== + * SELECTS + *========================================================================**/ + public function get_select_maquina_acabado() + { + $r = $this->maquinaModel->getSelectQuery(q: $this->request->getGet("q"), type: 'acabado'); + return $this->response->setJSON($r); + } + public function get_select_maquina_impresion() + { + $r = $this->maquinaModel->getSelectQuery(q: $this->request->getGet("q"), type: 'impresion'); + return $this->response->setJSON($r); + } + public function get_select_maquina_manipulado() + { + $r = $this->maquinaModel->getSelectQuery(q: $this->request->getGet("q"), type: 'manipulado'); + return $this->response->setJSON($r); + } + public function get_select_maquina_tareas() + { + $r = $this->maquinaTareaModel->getSelectQuery(q: $this->request->getGet("q")); + return $this->response->setJSON($r); + } + /**======================================================================== + * DATATABLES + *========================================================================**/ + public function get_datatable_tarifa_acabado_maquina(int $tarifa_acabado_id) + { + $m = model(TarifaAcabadoMaquinaModel::class); + $q = $m->queryDatatable($tarifa_acabado_id); + return DataTable::of($q) + ->add("action", fn($q) => $q->id) + ->toJson(true); + } + public function get_datatable_tarifa_manipulado_maquina(int $tarifa_manipulado_id) + { + $m = model(TarifaManipuladoMaquinaModel::class); + $q = $m->queryDatatable($tarifa_manipulado_id); + return DataTable::of($q) + ->add("action", fn($q) => $q->id) + ->toJson(true); + } + public function get_datatable_tarifa_preimpresion_maquina(int $tarifa_preimpresion_id) + { + $m = model(TarifaPreimpresionMaquinaModel::class); + $q = $m->queryDatatable($tarifa_preimpresion_id); + return DataTable::of($q) + ->add("action", fn($q) => $q->id) + ->toJson(true); + } + public function get_datatable_tarifa_encuadernacion_maquina(int $tarifa_encuadernacion_id) + { + $m = model(TarifaEncuadernacionMaquinaModel::class); + $q = $m->queryDatatable($tarifa_encuadernacion_id); + return DataTable::of($q) + ->add("action", fn($q) => $q->id) + ->toJson(true); + } + public function get_datatable_tarifa_extra_maquina(int $tarifa_extra_id) + { + $m = model(TarifaExtraMaquinaModel::class); + $q = $m->queryDatatable($tarifa_extra_id); + return DataTable::of($q) + ->add("action", fn($q) => $q->id) + ->toJson(true); + } +} diff --git a/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php b/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php index 29833e50..ce497cd4 100755 --- a/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php +++ b/ci4/app/Controllers/Tarifas/Tarifasmanipulado.php @@ -1,4 +1,6 @@ -viewData['tarifaManipuladoEntity'] = isset($sanitizedData) ? new TarifaManipuladoEntity($sanitizedData) : new TarifaManipuladoEntity(); - $this->viewData['formAction'] = site_url('tarifas/tarifasmanipulado/add');//route_to('createTarifaManipulado'); + $this->viewData['formAction'] = site_url('tarifas/tarifasmanipulado/add'); //route_to('createTarifaManipulado'); $this->viewData['boxTitle'] = lang('Basic.global.addNew') . ' ' . lang('Tarifamanipulado.moduleTitle') . ' ' . lang('Basic.global.addNewSuffix'); @@ -153,7 +155,7 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController $message = lang('Basic.global.notFoundWithIdErr', [mb_strtolower(lang('Tarifamanipulado.tarifamanipulado')), $id]); return $this->redirect2listView('sweet-error', $message); endif; - + if ($this->request->getPost()) : @@ -293,5 +295,19 @@ class Tarifasmanipulado extends \App\Controllers\BaseResourceController return $this->failUnauthorized('Invalid request', 403); } } + public function show_select() + { + $query = $this->model->builder() + ->select( + ["id", "nombre as name", "code as description"] + ) + ->where("deleted_at", null); + if ($this->request->getGet("q")) { + $query->groupStart() + ->orLike("nombre", $this->request->getGet("q")) + ->groupEnd(); + } + return $this->response->setJSON($query->get()->getResultObject()); + } } diff --git a/ci4/app/Database/Migrations/2024-11-30-160000_TareasServicioTable.php b/ci4/app/Database/Migrations/2024-11-30-160000_TareasServicioTable.php new file mode 100644 index 00000000..3efceaa0 --- /dev/null +++ b/ci4/app/Database/Migrations/2024-11-30-160000_TareasServicioTable.php @@ -0,0 +1,68 @@ + [ + "type" => "INT", + "unsigned" => true, + "auto_increment" => true + ], + "servicio_cliente_id" => [ + "type" => "INT", + "unsigned" => true, + "comment" => "Servicio cliente asociado" + ], + "tarifa_acabado_id" => [ + "type" => "INT", + "unsigned" => true, + "null" => true, + "comment" => "Tarifa de acabado asociada a servicio" + ], + "tarifa_manipulado_id" => [ + "type" => "INT", + "unsigned" => true, + "null" => true, + "comment" => "Tarifa de manipulado asociada a servicio", + + ] + ]; + public function up() + { + $this->forge->addField($this->COLUMNS); + $currenttime = new RawSql("CURRENT_TIMESTAMP"); + $this->forge->addField([ + "created_at" => [ + "type" => "TIMESTAMP", + "default" => $currenttime, + + ], + "updated_at" => [ + "type" => "TIMESTAMP", + "null" => true, + + ], + "deleted_at" => [ + "type" => "TIMESTAMP", + "null" => true, + + ], + ]); + $this->forge->addPrimaryKey("id"); + $this->forge->addForeignKey('servicio_cliente_id','servicios_cliente','id'); + $this->forge->addForeignKey('tarifa_acabado_id','lg_tarifa_acabado','id'); + $this->forge->addForeignKey('tarifa_manipulado_id','lg_tarifa_manipulado','id'); + + $this->forge->createTable("servicio_cliente_tareas", true); + } + + public function down() + { + $this->forge->dropTable("servicio_cliente_tareas"); + } +} diff --git a/ci4/app/Database/Migrations/2024-11-30-170000_OrdenTrabajoTable.php b/ci4/app/Database/Migrations/2024-11-30-170000_OrdenTrabajoTable.php new file mode 100644 index 00000000..144d78ec --- /dev/null +++ b/ci4/app/Database/Migrations/2024-11-30-170000_OrdenTrabajoTable.php @@ -0,0 +1,161 @@ + [ + "type" => "INT", + "unsigned" => true, + "auto_increment" => true + ], + "pedido_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 16, + "comment" => "Pedido original asociado", + ], + "user_created_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "comment" => "Usuario que ha pasado el pedido a producción", + ], + + "user_updated_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "comment" => "Usuario que ha actualizado la orden de trabajo", + + ], + "fecha_entrega_warning" => [ + "type" => "BOOLEAN", + "default" => false + ], + "fecha_entrega_warning_revised" => [ + "type" => "BOOLEAN", + "default" => false + ], + "total_tirada" => [ + "type" => "DOUBLE", + "null" => true + ], + "total_precio" => [ + "type" => "DOUBLE", + "null" => true + ], + "tipo_entrada" => [ + "type" => "ENUM", + "constraint" => ["in", "out"], + "default" => "out", + "comment" => "Tipo de entrada" + ], + + "progreso" => [ + "type" => "DOUBLE", + "default" => 0.00, + "comment" => "Progreso de 0 a 100" + ], + + "estado" => [ + "type" => "ENUM", + "constraint" => ["I", "F", "E","PM"], + "default" => "I", + "comment" => "I => INICIADO, F => FINALIZADO, P => PENDIENTE , PM=> PENDIENTE_MATERIAL , E => ERROR" + ], + /**============================================ + * PREIMPRESION + *=============================================**/ + "revisar_formato" => [ + "type" => "BOOLEAN", + "default" => false, + "comment" => "Realizar revision del formato" + ], + "revisar_lomo" => [ + "type" => "BOOLEAN", + "default" => false, + "comment" => "Realizar revision del lomo" + ], + "revisar_solapa" => [ + "type" => "BOOLEAN", + "default" => false, + "comment" => "Realizar revision de la solapa" + + ], + "revisar_isbn" => [ + "type" => "BOOLEAN", + "default" => false, + "comment" => "Realizar revision del ISBN" + + ], + "revisar_codigo_barras" => [ + "type" => "BOOLEAN", + "default" => false, + "comment" => "Realizar revision del codigo de barras" + + ], + "realizar_imposicion" => [ + "type" => "BOOLEAN", + "default" => false, + "comment" => "Realizar revision imposicion" + + ], + "enviar_impresion" => [ + "type" => "BOOLEAN", + "default" => false, + "comment" => "Realizar revision impresion" + + ], + "portada_path" => [ + "type" => "TEXT", + "default" => null, + "null" => true, + "comment" => "Path al archivo de portada" + + ], + "comentarios" => [ + "type" => "TEXT", + "null" => true, + "default" => null, + "comment" => "Comentarios orden de trabajo" + ] + ]; + public function up() + { + $this->forge->addField($this->COLUMNS); + $currenttime = new RawSql("CURRENT_TIMESTAMP"); + $this->forge->addField([ + "created_at" => [ + "type" => "TIMESTAMP", + "default" => $currenttime, + + ], + "updated_at" => [ + "type" => "TIMESTAMP", + "null" => true, + + ], + "deleted_at" => [ + "type" => "TIMESTAMP", + "null" => true, + + ], + ]); + $this->forge->addPrimaryKey("id"); + $this->forge->addForeignKey("pedido_id", "pedidos", "id"); + $this->forge->addForeignKey("user_created_id", "users", "id"); + $this->forge->addForeignKey("user_updated_id", "users", "id"); + + $this->forge->createTable("ordenes_trabajo", true); + } + + public function down() + { + $this->forge->dropTable("ordenes_trabajo"); + } +} diff --git a/ci4/app/Database/Migrations/2024-11-30-170001_OrdenTrabajoTareasTable.php b/ci4/app/Database/Migrations/2024-11-30-170001_OrdenTrabajoTareasTable.php new file mode 100644 index 00000000..36ef2a0a --- /dev/null +++ b/ci4/app/Database/Migrations/2024-11-30-170001_OrdenTrabajoTareasTable.php @@ -0,0 +1,147 @@ + [ + "type" => "INT", + "unsigned" => true, + "auto_increment" => true + ], + "orden_trabajo_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "comment" => "Orden de trabajo a la que pertenece esta tarea", + + ], + "presupuesto_linea_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + "comment" => "Presupuesto linea asociada a esta tarea. Puede ser NULL porque se podría añadir una tarea manual", + ], + "presupuesto_acabado_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + "comment" => "Presupuesto linea asociada a esta tarea. Puede ser NULL porque se podría añadir una tarea manual", + ], + "presupuesto_preimpresion_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + "comment" => "Presupuesto linea asociada a esta tarea. Puede ser NULL porque se podría añadir una tarea manual", + ], + "presupuesto_encuadernado_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + "comment" => "Presupuesto linea asociada a esta tarea. Puede ser NULL porque se podría añadir una tarea manual", + ], + "presupuesto_manipulado_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + "comment" => "Presupuesto linea asociada a esta tarea. Puede ser NULL porque se podría añadir una tarea manual", + ], + "presupuesto_extra_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + "comment" => "Presupuesto linea asociada a esta tarea. Puede ser NULL porque se podría añadir una tarea manual", + ], + "nombre" => [ + "type" => "VARCHAR", + "constraint" => 255, + "comment" => "Nombre de la tarea", + ], + "orden" => [ + "type" => "INT", + "unsigned" => true, + "comment" => "Orden de ejecución del tarea. Por defecto el orden será la de la máquina asociada a la línea de presupuesto." + ], + "maquina_id" => + [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + "comment" => "Máquina asociada a la tarea. Por defecto será la asociada a la linea de presupuesto" + ], + "imposicion_id" => [ + "type" => "INT", + "null" => true, + "constraint" => 11, + "default" => null, + "comment" => "Imposicion aplicada a la tarea. Default null" + + ], + "tiempo_estimado" => [ + "type" => "DOUBLE", + "default" => 0.00, + "null" => true, + "comment" => "Tiempo ejecución estimado de la tarea en minutos", + ], + "tiempo_real" => [ + "type" => "DOUBLE", + "default" => 0.00, + "null" => true, + "comment" => "Tiempo ejecución real de la tarea", + ], + "comment" => [ + "type" => "TEXT", + "null" => true, + "comment" => "Comentario sobre la tarea", + ] + ]; + public function up() + { + $this->forge->addField($this->COLUMNS); + $currenttime = new RawSql("CURRENT_TIMESTAMP"); + $this->forge->addField([ + "created_at" => [ + "type" => "TIMESTAMP", + "default" => $currenttime, + + ], + "updated_at" => [ + "type" => "TIMESTAMP", + "null" => true, + + ], + "deleted_at" => [ + "type" => "TIMESTAMP", + "null" => true, + ], + ]); + $this->forge->addPrimaryKey("id"); + $this->forge->addForeignKey("orden_trabajo_id","ordenes_trabajo","id","CASCADE","CASCADE"); + $this->forge->addForeignKey("presupuesto_linea_id","presupuesto_linea","id"); + $this->forge->addForeignKey("presupuesto_acabado_id","presupuesto_acabados","id"); + $this->forge->addForeignKey("presupuesto_encuadernado_id","presupuesto_encuadernaciones","id"); + $this->forge->addForeignKey("presupuesto_manipulado_id","presupuesto_manipulados","id"); + $this->forge->addForeignKey("presupuesto_preimpresion_id","presupuesto_preimpresiones","id"); + $this->forge->addForeignKey("presupuesto_extra_id","presupuesto_serviciosExtra","id"); + $this->forge->addForeignKey("imposicion_id","lg_imposiciones","id"); + $this->forge->addForeignKey("maquina_id","lg_maquinas","id"); + $this->forge->createTable("orden_trabajo_tareas"); + + } + + public function down() + { + $this->forge->dropTable("orden_trabajo_tareas",true); + } +} diff --git a/ci4/app/Database/Migrations/2024-11-30-170002_OrdenTrabajoDatesTable.php b/ci4/app/Database/Migrations/2024-11-30-170002_OrdenTrabajoDatesTable.php new file mode 100644 index 00000000..5deeb3ac --- /dev/null +++ b/ci4/app/Database/Migrations/2024-11-30-170002_OrdenTrabajoDatesTable.php @@ -0,0 +1,166 @@ + [ + "type" => "INT", + "unsigned" => true, + ], + "fecha_entrada_at" => [ + "type" => "DATE", + "null" => true, + ], + "fecha_entrega_at" => [ + "type" => "DATE", + "null" => true, + ], + "fecha_entrega_change_at" => [ + "type" => "DATE", + "null" => true, + ], + + "fecha_entrega_real_at" => [ + "type" => "DATE", + "null" => true, + ], + + "fecha_impresion_at" => [ + "type" => "DATE", + "null" => true, + ], + "fecha_encuadernado_at" => [ + "type" => "DATE", + "null" => true, + ], + "fecha_entrega_externo" => [ + "type" => "DATE", + "null" => true, + ], + + "pendiente_ferro_at" => [ + "type" => "DATE", + "null" => true, + ], + "ferro_en_cliente_at" => [ + "type" => "DATE", + "null" => true, + ], + "ferro_ok_at" => [ + "type" => "DATE", + "null" => true, + ], + "interior_bn_at" => [ + "type" => "DATE", + "null" => true, + ], + "interior_color_at" => [ + "type" => "DATE", + "null" => true, + ], + "preparacion_interiores_at" => [ + "type" => "DATE", + "null" => true, + ], + "cubierta_at" => [ + "type" => "DATE", + "null" => true, + ], + "plastificado_at" => [ + "type" => "DATE", + "null" => true, + ], + "encuadernacion_at" => [ + "type" => "DATE", + "null" => true, + ], + "corte_at" => [ + "type" => "DATE", + "null" => true, + ], + "embalaje_at" => [ + "type" => "DATE", + "null" => true, + ], + "envio_at" => [ + "type" => "DATE", + "null" => true, + ], + "entrada_manipulado_at" => [ + "type" => "DATE", + "null" => true, + ], + + + "ferro_disponible_hecho_at" => [ + "type" => "DATE", + "null" => true, + ], + + "ferro_disponible_ok_at" => [ + "type" => "DATE", + "null" => true, + ], + + "ferro_entregado_at" => [ + "type" => "DATE", + "null" => true, + ], + "pre_formato_at" => [ + "type" => "DATE", + "null" => true, + ], + + "pre_lomo_at" => [ + "type" => "DATE", + "null" => true, + ], + + "pre_solapa_at" => [ + "type" => "DATE", + "null" => true, + ], + + "pre_codbarras_at" => [ + "type" => "DATE", + "null" => true, + ], + + "pre_imposicion_at" => [ + "type" => "DATE", + "null" => true, + ], + ]; + public function up() + { + $this->forge->addField($this->COLUMNS); + $currenttime = new RawSql("CURRENT_TIMESTAMP"); + $this->forge->addField([ + "created_at" => [ + "type" => "TIMESTAMP", + "default" => $currenttime, + ], + "updated_at" => [ + "type" => "TIMESTAMP", + "null" => true, + ], + "deleted_at" => [ + "type" => "TIMESTAMP", + "null" => true, + ], + ]); + $this->forge->addPrimaryKey('orden_trabajo_id'); + $this->forge->addForeignKey("orden_trabajo_id","ordenes_trabajo","id","CASCADE","CASCADE"); + $this->forge->createTable("orden_trabajo_dates", true); + } + + public function down() + { + $this->forge->dropTable("orden_trabajo_dates"); + } +} diff --git a/ci4/app/Database/Migrations/2024-11-30-170002_OrdenTrabajoUsersTable.php b/ci4/app/Database/Migrations/2024-11-30-170002_OrdenTrabajoUsersTable.php new file mode 100644 index 00000000..807cb6f9 --- /dev/null +++ b/ci4/app/Database/Migrations/2024-11-30-170002_OrdenTrabajoUsersTable.php @@ -0,0 +1,223 @@ + [ + "type" => "INT", + "unsigned" => true, + ], + + "user_created_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "user_update_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "inaplazable_revised_change_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + + + "ferro_disponible_hecho_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + + "ferro_disponible_ok_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "ferro_entregado_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + + "pendiente_ferro_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "ferro_en_cliente_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "ferro_ok_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + + + + "interior_bn_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "interior_color_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "preparacion_interior_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "cubierta_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "plastificado_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "encuadernacion_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "corte_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "embalaje_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "envio_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "entrada_manipulado_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + + + "pre_formato_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + + + "pre_lomo_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + + "pre_solapa_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + + + "pre_codbarras_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + + "pre_imposicion_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "pre_imprimir_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + "pre_imprimir_user_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + "null" => true, + ], + ]; + public function up() + { + $this->forge->addField($this->COLUMNS); + $currenttime = new RawSql("CURRENT_TIMESTAMP"); + $this->forge->addField([ + "created_at" => [ + "type" => "TIMESTAMP", + "default" => $currenttime, + + ], + "updated_at" => [ + "type" => "TIMESTAMP", + "null" => true, + + ], + "deleted_at" => [ + "type" => "TIMESTAMP", + "null" => true, + + ], + ]); + foreach ($this->COLUMNS as $key => $value) { + $this->forge->addForeignKey([$key],"users",["id"]); + } + $this->forge->addPrimaryKey("orden_trabajo_id"); + // $this->forge->addForeignKey(["ordenes_trabajo_id"],"ordenes_trabajo",["id"]); + $this->forge->createTable("orden_trabajo_users", true); + + } + + public function down() + { + $this->forge->dropTable("orden_trabajo_users"); + } +} diff --git a/ci4/app/Database/Migrations/2024-11-30-170006_OrdenTrabajoMaquetacionesTable.php b/ci4/app/Database/Migrations/2024-11-30-170006_OrdenTrabajoMaquetacionesTable.php new file mode 100644 index 00000000..e83bd0bc --- /dev/null +++ b/ci4/app/Database/Migrations/2024-11-30-170006_OrdenTrabajoMaquetacionesTable.php @@ -0,0 +1,77 @@ + [ + "type" => "INT", + "unsigned" => true, + "auto_increment" => true + ], + "pedido_maquetacion_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + ], + "user_created_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + ], + "user_update_id" => [ + "type" => "INT", + "unsigned" => true, + "constraint" => 10, + ], + "entrada_at" => [ + "type" => "DATETIME", + "default" => null + ], + "salida_at" => [ + "type" => "DATETIME", + "default" => null + ], + "progreso" => [ + "type" => "DOUBLE", + "default" => 0 + ], + "finalizado" => [ + "type" => "BOOLEAN", + "default" => 0 + ] + ]; + public function up() + { + $this->forge->addField($this->COLUMNS); + $currenttime = new RawSql("CURRENT_TIMESTAMP"); + $this->forge->addField([ + "created_at" => [ + "type" => "TIMESTAMP", + "default" => $currenttime, + + ], + "updated_at" => [ + "type" => "TIMESTAMP", + "null" => true, + + ], + "deleted_at" => [ + "type" => "TIMESTAMP", + "null" => true, + + ], + ]); + $this->forge->addPrimaryKey("id"); + $this->forge->createTable("orden_trabajo_maquetaciones", true); + } + + public function down() + { + $this->forge->dropTable("orden_trabajo_maquetaciones"); + } +} diff --git a/ci4/app/Database/Migrations/2024-11-30-171007_OrdenTrabajoMaquetacionMovimientosTable.php b/ci4/app/Database/Migrations/2024-11-30-171007_OrdenTrabajoMaquetacionMovimientosTable.php new file mode 100644 index 00000000..b9056cd3 --- /dev/null +++ b/ci4/app/Database/Migrations/2024-11-30-171007_OrdenTrabajoMaquetacionMovimientosTable.php @@ -0,0 +1,63 @@ + [ + "type" => "INT", + "unsigned" => true, + "auto_increment" => true + ], + "orden_trabajo_maquetacion_id" => [ + "type" => "INT", + "unsigned" => true, + "null" => true, + + ], + "orden_trabajo_maquetacion_id" => [ + "type" => "INT", + "unsigned" => true, + "null" => true, + + ], + "file_id" => [ + "type" => "INT", + "unsigned" => true, + "null" => true, + ], + ]; + public function up() + { + $this->forge->addField($this->COLUMNS); + $currenttime = new RawSql("CURRENT_TIMESTAMP"); + $this->forge->addField([ + "created_at" => [ + "type" => "TIMESTAMP", + "default" => $currenttime, + + ], + "updated_at" => [ + "type" => "TIMESTAMP", + "null" => true, + + ], + "deleted_at" => [ + "type" => "TIMESTAMP", + "null" => true, + + ], + ]); + $this->forge->addPrimaryKey("id"); + $this->forge->createTable("orden_trabajo_maquetacion_movimientos", true); + } + + public function down() + { + $this->forge->dropTable("orden_trabajo_maquetacion_movimientos"); + } +} diff --git a/ci4/app/Database/Migrations/2024-12-08-195700_AlterColumnServiciosCliente.php b/ci4/app/Database/Migrations/2024-12-08-195700_AlterColumnServiciosCliente.php new file mode 100644 index 00000000..61a5aabc --- /dev/null +++ b/ci4/app/Database/Migrations/2024-12-08-195700_AlterColumnServiciosCliente.php @@ -0,0 +1,38 @@ + [ + "name" => "deleted_at", + "type" => "datetime", + "default" => null, + "null" => true, + ], + "updated_at" => [ + "name" => "updated_at", + "type" => "datetime", + "default" => null, + "null" => true, + ], + ]; + public function up() + { + $this->forge->modifyColumn("servicios_cliente", $this->ALTER_COLUMNS); + } + + public function down() + { + $this->forge->addField([ + "is_deleted" => [ + "type" => "boolean", + "default" => false, + "null" => false, + ] + ]); + } +} diff --git a/ci4/app/Database/Migrations/2024-12-16-180000_MaquinaTareasTable.php b/ci4/app/Database/Migrations/2024-12-16-180000_MaquinaTareasTable.php new file mode 100644 index 00000000..d7a6f752 --- /dev/null +++ b/ci4/app/Database/Migrations/2024-12-16-180000_MaquinaTareasTable.php @@ -0,0 +1,55 @@ + [ + 'type' => 'INT', + 'unsigned' => true, + 'auto_increment' => true, + ], + 'name' => [ + 'type' => 'VARCHAR', + 'constraint' => 255, + ], + 'description' => [ + 'type' => 'LONGTEXT', + 'default' => null, + 'null' => true + ] + ]; + public function up() + { + $this->forge->addField($this->COLUMNS); + $currenttime = new RawSql('CURRENT_TIMESTAMP'); + $this->forge->addField([ + 'created_at' => [ + 'type' => 'TIMESTAMP', + 'default' => $currenttime, + + ], + 'updated_at' => [ + 'type' => 'TIMESTAMP', + 'null' => true, + + ], + 'deleted_at' => [ + 'type' => 'TIMESTAMP', + 'null' => true, + + ], + ]); + $this->forge->addPrimaryKey('id'); + $this->forge->createTable("maquina_tareas"); + } + + public function down() + { + $this->forge->dropTable("maquina_tareas"); + } +} diff --git a/ci4/app/Database/Migrations/2024-12-16-183531_TarifaAcabadoMaquinaTable.php b/ci4/app/Database/Migrations/2024-12-16-183531_TarifaAcabadoMaquinaTable.php new file mode 100644 index 00000000..d5a7d304 --- /dev/null +++ b/ci4/app/Database/Migrations/2024-12-16-183531_TarifaAcabadoMaquinaTable.php @@ -0,0 +1,64 @@ + [ + 'type' => 'INT', + 'unsigned' => true, + 'auto_increment' => true, + ], + 'tarifa_acabado_id' => [ + 'type' => 'INT', + 'unsigned' => true, + 'constraint' => 10, + ], + 'maquina_id' => [ + 'type' => 'INT', + 'unsigned' => true, + 'constraint' => 10, + ], + 'maquina_tarea_id' => [ + 'type' => 'INT', + 'unsigned' => true, + 'constraint' => 10, + ] + + ]; + public function up() + { + $this->forge->addField($this->COLUMNS); + $currenttime = new RawSql('CURRENT_TIMESTAMP'); + $this->forge->addField([ + 'created_at' => [ + 'type' => 'TIMESTAMP', + 'default' => $currenttime, + + ], + 'updated_at' => [ + 'type' => 'TIMESTAMP', + 'null' => true, + + ], + 'deleted_at' => [ + 'type' => 'TIMESTAMP', + 'null' => true, + + ], + ]); + $this->forge->addPrimaryKey('id'); + $this->forge->addForeignKey('tarifa_acabado_id','lg_tarifa_acabado','id'); + $this->forge->addForeignKey('maquina_tarea_id','maquina_tareas','id'); + $this->forge->createTable("tarifa_acabado_maquinas"); + } + + public function down() + { + $this->forge->dropTable("tarifa_acabado_maquinas"); + } +} diff --git a/ci4/app/Database/Migrations/2024-12-16-183550_TarifaManipuladoMaquinaTable.php b/ci4/app/Database/Migrations/2024-12-16-183550_TarifaManipuladoMaquinaTable.php new file mode 100644 index 00000000..5ad3460a --- /dev/null +++ b/ci4/app/Database/Migrations/2024-12-16-183550_TarifaManipuladoMaquinaTable.php @@ -0,0 +1,64 @@ + [ + 'type' => 'INT', + 'unsigned' => true, + 'auto_increment' => true, + ], + 'tarifa_manipulado_id' => [ + 'type' => 'INT', + 'unsigned' => true, + 'constraint' => 10, + ], + 'maquina_id' => [ + 'type' => 'INT', + 'unsigned' => true, + 'constraint' => 10, + ], + 'maquina_tarea_id' => [ + 'type' => 'INT', + 'unsigned' => true, + 'constraint' => 10, + ] + + ]; + public function up() + { + $this->forge->addField($this->COLUMNS); + $currenttime = new RawSql('CURRENT_TIMESTAMP'); + $this->forge->addField([ + 'created_at' => [ + 'type' => 'TIMESTAMP', + 'default' => $currenttime, + + ], + 'updated_at' => [ + 'type' => 'TIMESTAMP', + 'null' => true, + + ], + 'deleted_at' => [ + 'type' => 'TIMESTAMP', + 'null' => true, + + ], + ]); + $this->forge->addPrimaryKey('id'); + $this->forge->addForeignKey('tarifa_manipulado_id','lg_tarifa_manipulado','id'); + $this->forge->addForeignKey('maquina_tarea_id','maquina_tareas','id'); + $this->forge->createTable("tarifa_manipulado_maquinas"); + } + + public function down() + { + $this->forge->dropTable("tarifa_manipulado_maquinas"); + } +} diff --git a/ci4/app/Database/Migrations/2024-12-16-183607_TarifaPreimpresionMaquinaTable.php b/ci4/app/Database/Migrations/2024-12-16-183607_TarifaPreimpresionMaquinaTable.php new file mode 100644 index 00000000..3dacd0ff --- /dev/null +++ b/ci4/app/Database/Migrations/2024-12-16-183607_TarifaPreimpresionMaquinaTable.php @@ -0,0 +1,65 @@ + [ + 'type' => 'INT', + 'unsigned' => true, + 'auto_increment' => true, + ], + 'tarifa_preimpresion_id' => [ + 'type' => 'INT', + 'unsigned' => true, + 'constraint' => 10, + ], + 'maquina_id' => [ + 'type' => 'INT', + 'unsigned' => true, + 'constraint' => 10, + ], + 'maquina_tarea_id' => [ + 'type' => 'INT', + 'unsigned' => true, + 'constraint' => 10, + ] + + ]; + public function up() + { + $this->forge->addField($this->COLUMNS); + $currenttime = new RawSql('CURRENT_TIMESTAMP'); + $this->forge->addField([ + 'created_at' => [ + 'type' => 'TIMESTAMP', + 'default' => $currenttime, + + ], + 'updated_at' => [ + 'type' => 'TIMESTAMP', + 'null' => true, + + ], + 'deleted_at' => [ + 'type' => 'TIMESTAMP', + 'null' => true, + + ], + ]); + $this->forge->addPrimaryKey('id'); + $this->forge->addForeignKey('tarifa_preimpresion_id','lg_tarifa_preimpresion','id'); + $this->forge->addForeignKey('maquina_tarea_id','maquina_tareas','id'); + $this->forge->createTable("tarifa_preimpresion_maquinas"); + } + + public function down() + { + $this->forge->dropTable("tarifa_preimpresion_maquinas"); + } +} diff --git a/ci4/app/Database/Migrations/2024-12-16-183619_TarifaEncuadernacionMaquinaTable.php b/ci4/app/Database/Migrations/2024-12-16-183619_TarifaEncuadernacionMaquinaTable.php new file mode 100644 index 00000000..000eacca --- /dev/null +++ b/ci4/app/Database/Migrations/2024-12-16-183619_TarifaEncuadernacionMaquinaTable.php @@ -0,0 +1,65 @@ + [ + 'type' => 'INT', + 'unsigned' => true, + 'auto_increment' => true, + ], + 'tarifa_encuadernacion_id' => [ + 'type' => 'INT', + 'unsigned' => true, + 'constraint' => 10, + ], + 'maquina_id' => [ + 'type' => 'INT', + 'unsigned' => true, + 'constraint' => 10, + ], + 'maquina_tarea_id' => [ + 'type' => 'INT', + 'unsigned' => true, + 'constraint' => 10, + ] + + ]; + public function up() + { + $this->forge->addField($this->COLUMNS); + $currenttime = new RawSql('CURRENT_TIMESTAMP'); + $this->forge->addField([ + 'created_at' => [ + 'type' => 'TIMESTAMP', + 'default' => $currenttime, + + ], + 'updated_at' => [ + 'type' => 'TIMESTAMP', + 'null' => true, + + ], + 'deleted_at' => [ + 'type' => 'TIMESTAMP', + 'null' => true, + + ], + ]); + $this->forge->addPrimaryKey('id'); + $this->forge->addForeignKey('tarifa_encuadernacion_id','tarifa_encuadernacion','id'); + $this->forge->addForeignKey('maquina_tarea_id','maquina_tareas','id'); + $this->forge->createTable("tarifa_encuadernacion_maquinas"); + } + + public function down() + { + $this->forge->dropTable("tarifa_encuadernacion_maquinas"); + } +} diff --git a/ci4/app/Database/Migrations/2024-12-17-183619_TarifaExtraMaquinaTable.php b/ci4/app/Database/Migrations/2024-12-17-183619_TarifaExtraMaquinaTable.php new file mode 100644 index 00000000..fe58d938 --- /dev/null +++ b/ci4/app/Database/Migrations/2024-12-17-183619_TarifaExtraMaquinaTable.php @@ -0,0 +1,65 @@ + [ + 'type' => 'INT', + 'unsigned' => true, + 'auto_increment' => true, + ], + 'tarifa_extra_id' => [ + 'type' => 'INT', + 'unsigned' => true, + 'constraint' => 10, + ], + 'maquina_id' => [ + 'type' => 'INT', + 'unsigned' => true, + 'constraint' => 10, + ], + 'maquina_tarea_id' => [ + 'type' => 'INT', + 'unsigned' => true, + 'constraint' => 10, + ] + + ]; + public function up() + { + $this->forge->addField($this->COLUMNS); + $currenttime = new RawSql('CURRENT_TIMESTAMP'); + $this->forge->addField([ + 'created_at' => [ + 'type' => 'TIMESTAMP', + 'default' => $currenttime, + + ], + 'updated_at' => [ + 'type' => 'TIMESTAMP', + 'null' => true, + + ], + 'deleted_at' => [ + 'type' => 'TIMESTAMP', + 'null' => true, + + ], + ]); + $this->forge->addPrimaryKey('id'); + $this->forge->addForeignKey('tarifa_extra_id','tarifa_extra','id'); + $this->forge->addForeignKey('maquina_tarea_id','maquina_tareas','id'); + $this->forge->createTable("tarifa_extra_maquinas"); + } + + public function down() + { + $this->forge->dropTable("tarifa_extra_maquinas"); + } +} diff --git a/ci4/app/Database/Seeds/MaquinaTareaSeeder.php b/ci4/app/Database/Seeds/MaquinaTareaSeeder.php new file mode 100644 index 00000000..2accb9ec --- /dev/null +++ b/ci4/app/Database/Seeds/MaquinaTareaSeeder.php @@ -0,0 +1,49 @@ + "Grapar", + "description" => "Grapar (acabado)" + ], + [ + "name" => "Preparación en guillotina", + "description" => "Guillotina (manipulado)" + ], + [ + "name" => "Espiral", + "description" => "Perforadora Wire-o/Espiral (manipulado)" + ], + [ + "name" => "Plegar", + "description" => "Plegadora-Grapadora (manipulado)" + ], + [ + "name" => "Coser", + "description" => "Cosedora hilo (manipulado)" + ], + [ + "name" => "Cubrir", + "description" => "Encuadernadora cola caliente (manipulado)" + ], + [ + "name" => "Corte", + "description" => "Manipulado" + ], + [ + "name" => "Marcapáginas", + "description" => "Acabado" + ], + ]; + $m->insertBatch($data); + } +} diff --git a/ci4/app/Entities/Clientes/ClienteEntity.php b/ci4/app/Entities/Clientes/ClienteEntity.php index 417871e4..a82664e0 100755 --- a/ci4/app/Entities/Clientes/ClienteEntity.php +++ b/ci4/app/Entities/Clientes/ClienteEntity.php @@ -1,6 +1,8 @@ "int", "user_update_id" => "int", ]; + + public function comercial() : UserEntity + { + $m = model(UserModel::class); + return $m->find($this->attributes["comercial_id"]); + } } diff --git a/ci4/app/Entities/Configuracion/ServicioClienteEntity.php b/ci4/app/Entities/Configuracion/ServicioClienteEntity.php new file mode 100644 index 00000000..1c824f3e --- /dev/null +++ b/ci4/app/Entities/Configuracion/ServicioClienteEntity.php @@ -0,0 +1,59 @@ + null, + "code" => null, + ]; + protected $casts = [ + "nombre" => "string", + "code" => "string", + ]; + + public function withManipuladoTarifas() + { + $this->attributes["tarifas_manipulado"] = $this->getManipuladoTarifas(); + return $this; + } + public function withAcabadoTarifas() + { + $this->attributes["tarifas_acabado"] = $this->getAcabadoTarifas(); + return $this; + } + public function withAllTarifas(){ + $this->withManipuladoTarifas(); + $this->withAcabadoTarifas(); + return $this; + } + public function getManipuladoTarifas(): ?object + { + $model = model(ServicioClienteModel::class); + return $model->builder()->select("lg_tarifa_manipulado.*") + ->join("servicio_cliente_tareas","servicio_cliente_tareas.servicio_cliente_id = servicios_cliente.id",'left') + ->join("lg_tarifa_manipulado","lg_tarifa_manipulado.id = servicio_cliente_tareas.tarifa_manipulado_id",'left') + ->where("servicio_cliente_tareas.servicio_cliente_id",$this->attributes["id"]) + ->where("lg_tarifa_manipulado.id IS NOT NULL",NULL,FALSE) + ->where("servicio_cliente_tareas.deleted_at", NULL) // Exclude soft-deleted rows + ->get()->getFirstRow(); + } + public function getAcabadoTarifas(): ?object + { + $model = model(ServicioClienteModel::class); + return $model->builder()->select("lg_tarifa_acabado.*") + ->join("servicio_cliente_tareas","servicio_cliente_tareas.servicio_cliente_id = servicios_cliente.id",'left') + ->join("lg_tarifa_acabado","lg_tarifa_acabado.id = servicio_cliente_tareas.tarifa_acabado_id",'left') + ->where("servicio_cliente_tareas.servicio_cliente_id",$this->attributes["id"]) + ->where("servicio_cliente_tareas.deleted_at", NULL) // Exclude soft-deleted rows + ->where("lg_tarifa_acabado.id IS NOT NULL",NULL,FALSE) + ->get()->getFirstRow(); + } +} diff --git a/ci4/app/Entities/Configuracion/TareaMaquinaEntity.php b/ci4/app/Entities/Configuracion/TareaMaquinaEntity.php new file mode 100644 index 00000000..97b8f8d7 --- /dev/null +++ b/ci4/app/Entities/Configuracion/TareaMaquinaEntity.php @@ -0,0 +1,20 @@ + null, + "name" => null, + "description" => null, + ]; + protected $casts = [ + "id" => "integer", + "name" => "string", + "description" => "?string", + ]; + +} diff --git a/ci4/app/Entities/Pedidos/PedidoEntity.php b/ci4/app/Entities/Pedidos/PedidoEntity.php index 016bf7e2..57b81396 100644 --- a/ci4/app/Entities/Pedidos/PedidoEntity.php +++ b/ci4/app/Entities/Pedidos/PedidoEntity.php @@ -1,7 +1,11 @@ "float", "total_tirada" => "float", ]; + /** + * Devuelve la entidad `PedidoEntity` con sus relaciones + * + * @return self + */ + public function withAllRelations() : self + { + $this->attributes["pedido_lineas"] = $this->lineas(); + $this->attributes["presupuesto"] = $this->presupuesto(); + + return $this; + } + public function lineas(): array + { + $q = model(PedidoLineaModel::class); + $q->where("pedido_id",$this->attributes["id"]); + return $q->findAll(); + } + public function ubicacion(): ?UbicacionesEntity + { + $lineas = $this->lineas(); + $ubicacion = null; + foreach ($lineas as $key => $linea) { + $ubicacion = $linea->ubicacion(); + } + return $ubicacion; + } + public function presupuesto() : PresupuestoEntity + { + $q = model(PedidoLineaModel::class); + $p = model(PresupuestoModel::class); + $presupuesto_id = $q->where("pedido_id",$this->attributes["id"])->first()->presupuesto_id; + return $p->find($presupuesto_id); + } + public function orden_trabajo() : ?OrdenTrabajoEntity + { + $m = model(OrdenTrabajoModel::class); + return $m->where("pedido_id",$this->attributes["id"])->first(); + } + public function cliente() : ?ClienteEntity { diff --git a/ci4/app/Entities/Pedidos/PedidoLineaEntity.php b/ci4/app/Entities/Pedidos/PedidoLineaEntity.php index 38efab3f..dc059079 100644 --- a/ci4/app/Entities/Pedidos/PedidoLineaEntity.php +++ b/ci4/app/Entities/Pedidos/PedidoLineaEntity.php @@ -1,6 +1,8 @@ "int", "ubicacion_id" => "int", ]; + public function ubicacion() : UbicacionesEntity + { + $m = model(UbicacionesModel::class); + return $m->find($this->attributes["ubicacion_id"]); + } } diff --git a/ci4/app/Entities/Presupuestos/PresupuestoAcabadosEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoAcabadosEntity.php index 02af9b3a..e43cd5ed 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoAcabadosEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoAcabadosEntity.php @@ -1,6 +1,10 @@ "int", "sobrecubierta" => "int", ]; + + public function maquinas() : array + { + $m = model(TarifaAcabadoMaquinaModel::class); + $tarifa_maquinas = $m->where("tarifa_acabado_id",$this->attributes["tarifa_acabado_id"])->findAll(); + $maquinaModel = model(MaquinaModel::class); + $maquinas = []; + foreach ($tarifa_maquinas as $key => $tarifa_maquina) { + $maquinas[] = $maquinaModel->find($tarifa_maquina->maquina_id); + } + return $maquinas; + } + public function tarifa() : TarifaAcabadoEntity + { + $m = model(TarifaAcabadoModel::class); + return $m->find($this->attributes["tarifa_acabado_id"]); + } } diff --git a/ci4/app/Entities/Presupuestos/PresupuestoEncuadernacionesEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoEncuadernacionesEntity.php index 560fa668..81e257f8 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoEncuadernacionesEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoEncuadernacionesEntity.php @@ -1,6 +1,9 @@ "float", "margen" => "float", ]; + public function maquinas() : array + { + $m = model(TarifaEncuadernacionMaquinaModel::class); + return $m->where("tarifa_encuadernacion_id",$this->attributes["tarifa_encuadernado_id"])->findAll(); + } + public function tarifa() : TarifaEncuadernacionEntity + { + $m = model(TarifaEncuadernacionModel::class); + return $m->find($this->attributes["tarifa_encuadernado_id"]); + } } diff --git a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php index 3969835e..660beb08 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoEntity.php @@ -1,6 +1,18 @@ null, "total_costes" => null, "total_margenes" => null, - "total_antes_descuento" => null, + "total_antes_descuento" => null, "total_descuento" => null, "total_descuentoPercent" => null, "total_precio_unidad" => null, @@ -165,4 +177,111 @@ class PresupuestoEntity extends \CodeIgniter\Entity\Entity 'paginasCuadernillo' => "int", 'lomo_redondo' => "boolean", ]; + /** + * Devuelve la entity con un campo `presupuesto_lineas` con las lineas de presupuesto asociadas + * + * @return this + */ + public function withPresupuestoLineas() + { + $this->attributes["presupuesto_lineas"] = $this->presupuestoLineas(); + return $this; + } + /** + * Obtiene las lineas de presupuesto del actual presupuesto + * + * @return array + */ + public function presupuestoLineas(): array + { + $model = model(PresupuestoLineaModel::class); + + $q = $model->where('presupuesto_id', $this->attributes["id"])->findAll(); + + return $q; + } + /** + * Obtiene las lineas de presupuesto del actual presupuesto + * + * @return PresupuestoLineaEntity + */ + public function presupuestoLineaImpresion(): PresupuestoLineaEntity + { + $model = model(PresupuestoLineaModel::class); + + $q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo",["lp_rot_bn","lp_rot_color","lp_color","lp_colorhq","lp_bn","lp_bnhq"])->first(); + + return $q; + } + /** + * Obtiene las lineas de presupuesto del actual presupuesto + * + * @return PresupuestoLineaEntity + */ + public function presupuestoLineaCubierta(): PresupuestoLineaEntity + { + $model = model(PresupuestoLineaModel::class); + + $q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo",["lp_cubierta"])->first(); + + return $q; + } + /** + * Obtiene las lineas de presupuesto del actual presupuesto + * + * @return PresupuestoLineaEntity + */ + public function presupuestoLineaSobreCubierta(): ?PresupuestoLineaEntity + { + $model = model(PresupuestoLineaModel::class); + + $q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo",["lp_sobrecubierta"])->first(); + + return $q; + } + public function hasSobrecubierta() : bool + { + $hasSobrecubierta = false; + $model = model(PresupuestoLineaModel::class); + $q = $model->where('presupuesto_id', $this->attributes["id"])->whereIn("tipo",["lp_sobrecubierta"])->countAllResults(); + if($q > 0){ + $hasSobrecubierta = true; + } + return $hasSobrecubierta; + } + public function cliente() : ClienteEntity + { + $m = model(ClienteModel::class); + return $m->find($this->attributes["cliente_id"]); + } + public function encuadernaciones(): array + { + $m = model(PresupuestoEncuadernacionesModel::class); + return $m->where("presupuesto_id",$this->attributes["id"])->findAll(); + } + public function acabados(): array + { + $m = model(PresupuestoAcabadosModel::class); + return $m->where("presupuesto_id",$this->attributes["id"])->findAll(); + } + public function preimpresiones(): array + { + $m = model(PresupuestoPreimpresionesModel::class); + return $m->where("presupuesto_id",$this->attributes["id"])->findAll(); + } + public function manipulados(): array + { + $m = model(PresupuestoManipuladosModel::class); + return $m->where("presupuesto_id",$this->attributes["id"])->findAll(); + } + public function extras(): array + { + $m = model(PresupuestoServiciosExtraModel::class); + return $m->where("presupuesto_id",$this->attributes["id"])->findAll(); + } + public function papel_formato() : PapelFormatoEntity + { + $m = model(PapelFormatoModel::class); + return $m->find($this->attributes["papel_formato_id"]); + } } diff --git a/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php index d13afe12..f0705d98 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php @@ -1,7 +1,18 @@ "double", "total_linea" => "double", ]; + + /** + * Devuelve la entity MaquinaEntity asociada a esta linea de presupuesto + * + * @return MaquinaEntity + */ + public function maquina(): MaquinaEntity + { + $m = model(MaquinaModel::class); + return $m->find($this->attributes["maquina_id"]); + } + /** + * Devuelve la entity PapelImpresion asociada a esta linea de presupuesto. + * + * @return PapelImpresion + */ + public function papel_impresion(): PapelImpresion + { + $m = model(PapelImpresionModel::class); + return $m->find($this->attributes['papel_impresion_id']); + } + /** + * Devuelve la entity PapelGenerico asociada a esta linea de presupuesto. + * + * @return PapelGenerico + */ + public function papel_generico(): PapelGenerico + { + $m = model(PapelGenericoModel::class); + return $m->find($this->attributes['papel_id']); + } + /** + * Devuelve la entity MaquinasTarifasImpresionEntity asociada a esta linea de presupuesto. + * + * @return MaquinasTarifasImpresionEntity + */ + public function tarifa_impresion(): MaquinasTarifasImpresionEntity + { + $m = model(MaquinasTarifasImpresionModel::class); + return $m->find($this->attributes['tarifa_impresion_id']); + } + + public function get_impresion_logo(){ + $logo = config(LogoImpresion::class); + return $logo->get_logo_path($this->attributes["tipo"]); + } + public function get_nombre_tarea() : ?string + { + $nombre = null; + $impresion_bn = ["lp_bn","lp_bnhq","lp_rot_bn"]; + $impresion_color = ["lp_color","lp_colorhq","lp_rot_color"]; + $impresion_cubierta = ["lp_cubierta"]; + $impresion_guardas = ["lp_guardas"]; + $impresion_sobrecubierta = ["lp_sobrecubierta"]; + + $is_bn = in_array($this->attributes["tipo"],$impresion_bn); + $is_color = in_array($this->attributes["tipo"],$impresion_color); + $is_impresion_cubierta = in_array($this->attributes["tipo"],$impresion_cubierta); + $is_impresion_guarda = in_array($this->attributes["tipo"],$impresion_guardas); + $is_impresion_sobrecubierta = in_array($this->attributes["tipo"],$impresion_sobrecubierta); + + if($is_bn) $nombre ="Impresión B/N"; + if($is_color) $nombre ="Impresión color"; + if($is_impresion_cubierta) $nombre ="Impresión cubierta"; + if($is_impresion_guarda) $nombre ="Impresión guarda"; + if($is_impresion_sobrecubierta) $nombre ="Impresión sobrecubierta"; + + return $nombre; + } } - \ No newline at end of file diff --git a/ci4/app/Entities/Presupuestos/PresupuestoManipuladosEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoManipuladosEntity.php index d7b3d752..2fec8009 100644 --- a/ci4/app/Entities/Presupuestos/PresupuestoManipuladosEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoManipuladosEntity.php @@ -1,6 +1,9 @@ "float", "margen" => "float", ]; + public function maquinas() : array + { + $m = model(TarifaManipuladoMaquinaModel::class); + return $m->where("tarifa_manipulado_id",$this->attributes["tarifa_manipulado_id"])->findAll(); + } + public function tarifa() : TarifaManipuladoEntity + { + $m = model(TarifaManipuladoModel::class); + return $m->find($this->attributes["tarifa_manipulado_id"]); + } } diff --git a/ci4/app/Entities/Presupuestos/PresupuestoPreimpresionesEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoPreimpresionesEntity.php index 7fa9cdb4..9a0fef88 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoPreimpresionesEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoPreimpresionesEntity.php @@ -1,6 +1,9 @@ "float", "margen" => "float", ]; + public function maquinas() : array + { + $m = model(TarifaPreimpresionMaquinaModel::class); + return $m->where("tarifa_preimpresion_id",$this->attributes["tarifa_preimpresion_id"])->findAll(); + } + public function tarifa() : TarifapreimpresionEntity + { + $m = model(TarifapreimpresionModel::class); + return $m->find($this->attributes["tarifa_preimpresion_id"]); + } } diff --git a/ci4/app/Entities/Presupuestos/PresupuestoServiciosExtraEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoServiciosExtraEntity.php index 68b12931..b68f6c2f 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoServiciosExtraEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoServiciosExtraEntity.php @@ -1,6 +1,9 @@ "float", "margen" => "float", ]; + + public function maquinas() : array + { + $m = model(TarifaExtraMaquinaModel::class); + return $m->where("tarifa_extra_id",$this->attributes["tarifa_extra_id"])->findAll(); + } + public function tarifa() : TarifaextraEntity + { + $m = model(TarifaextraModel::class); + return $m->find($this->attributes["tarifa_extra_id"]); + } } diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php new file mode 100644 index 00000000..bf4d8f5f --- /dev/null +++ b/ci4/app/Entities/Produccion/OrdenTrabajoDateEntity.php @@ -0,0 +1,62 @@ + null, + "fecha_entrega_at" => null, + "fecha_entrega_change_at" => null, + "fecha_entrega_real_at" => null, + "fecha_entrega_real_warning" => null, + "fecha_impresion_at" => null, + "fecha_encuadernado_at" => null, + "fecha_externo_at" => null, + "fecha_entrega_warning" => null, + "fecha_entrega_warning_revised" => null, + "pendiente_ferro_at" => null, + "ferro_en_cliente_at" => null, + "ferro_ok_at" => null, + "interior_bn_at" => null, + "interior_color_at" => null, + "preparacion_interiores_at" => null, + "cubierta_at" => null, + "plastificado_at" => null, + "encuadernacion_at" => null, + "corte_at" => null, + "embalaje_at" => null, + "envio_at" => null, + "entrada_manipulado_at" => null + + ]; + protected $datamap = []; + protected $dates = ['created_at', 'updated_at', 'deleted_at']; + protected $casts = [ + // "fecha_entrada_at" => "?datetime", + // "fecha_entrega_at" => "?datetime", + // "fecha_entrega_change_at" => "?datetime", + // "fecha_entrega_real_at" => "?datetime", + // "fecha_entrega_real_warning" => "?bool", + // "fecha_impresion_at" => "?datetime", + // "fecha_encuadernado_at" => "?datetime", + // "fecha_externo_at" => "?datetime", + // "fecha_entrega_warning" => "?bool", + // "fecha_entrega_warning_revised" => "?bool", + // "pendiente_ferro_at" => "?datetime", + // "ferro_en_cliente_at" => "?datetime", + // "ferro_ok_at" => "?datetime", + // "interior_bn_at" => "?datetime", + // "interior_color_at" => "?datetime", + // "preparacion_interiores_at" => "?datetime", + // "cubierta_at" => "?datetime", + // "plastificado_at" => "?datetime", + // "encuadernacion_at" => "?datetime", + // "corte_at" => "?datetime", + // "embalaje_at" => "?datetime", + // "envio_at" => "?datetime", + // "entrada_manipulado_at" => "?datetime" + ]; +} diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php new file mode 100644 index 00000000..9ef6a01c --- /dev/null +++ b/ci4/app/Entities/Produccion/OrdenTrabajoEntity.php @@ -0,0 +1,104 @@ + null, + "user_created_id" => null, + "user_updated_id" => null, + "fecha_entrega_warning" => false, + "fecha_entrega_warning_revised" => false, + "total_tirada" => null, + "total_precio" => null, + "tipo_entrada" => "out", + "progreso" => 0.00, + "estado" => "I", + "comentarios" => null, + "revisar_formato" => false, + "revisar_lomo" => false, + "revisar_solapa" => false, + "revisar_isbn" => false, + "revisar_codigo_barras" => false, + "realizar_imposicion" => false, + "enviar_impresion" => false, + ]; + protected $casts = [ + "pedido_id" => "integer", + "user_created_id" => "integer", + "user_updated_id" => "?integer", + "fecha_entrega_warning" => "bool", + "fecha_entrega_warning_revised" => "bool", + "total_tirada" => "float", + "total_precio" => "float", + "tipo_entrada" => "string", + "progreso" => "float", + "estado" => "string", + "comentarios" => "string", + "revisar_formato" => "bool", + "revisar_lomo" => "bool", + "revisar_solapa" => "bool", + "revisar_isbn" => "bool", + "revisar_codigo_barras" => "bool", + "realizar_imposicion" => "bool", + "enviar_impresion" => "bool", + ]; + + + /** + * Devuelve las tareas de la orden de trabajo. + * + * @return array + */ + public function tareas(): array + { + $m = model(OrdenTrabajoTarea::class); + return $m->where("orden_trabajo_id", $this->attributes["id"])->findAll(); + } + /** + * Devuelve el pedido de la orden de trabajo + * + * @return PedidoEntity + */ + public function pedido(): ?PedidoEntity + { + $m = model(PedidoModel::class); + return $m->find($this->attributes["pedido_id"]); + } + public function dates(): ?OrdenTrabajoDateEntity + { + $m = model(OrdenTrabajoDate::class); + return $m->find($this->attributes["id"]); + } + public function users(): ?OrdenTrabajoUserEntity + { + $m = model(OrdenTrabajoUser::class); + return $m->find($this->attributes["id"]); + } + + /** + * Almacena en la tabla `orden_trabajo_dates` las fechas correspondientes del pedido. + * Se almacenan en una tabla externa porque puede haber modificaciones de estas fechas + * en la orden del trabajo, pero en el pedido quedarán fijas. + * + * @todo Falta implementacion + * @return boolean + */ + public function storeDates($data): self + { + $ot_dates = new OrdenTrabajoDateEntity(); + $this->attributes["dates"] = $ot_dates->fill($data); + return $this; + } +} diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoMaquetacionEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoMaquetacionEntity.php new file mode 100644 index 00000000..4fbf1eba --- /dev/null +++ b/ci4/app/Entities/Produccion/OrdenTrabajoMaquetacionEntity.php @@ -0,0 +1,12 @@ + null, + "orden_trabajo_id" => null, + "presupuesto_linea_id" => null, + "nombre" => null, + "orden" => null, + "maquina_id" => null, + "imposicion_id" => null, + "tiempo_estimado" => null, + "tiempo_real" => null, + "comment" => null, + ]; + protected $datamap = []; + protected $dates = ['created_at', 'updated_at', 'deleted_at']; + protected $casts = [ + "id" => "integer", + "orden_trabajo_id" => "integer", + "presupuesto_linea_id" => "?integer", + "nombre" => "string", + "orden" => "integer", + "maquina_id" => "?integer", + "imposicion_id" => "?integer", + "tiempo_estimado" => "?float", + "tiempo_real" => "?float", + "comment" => "?string" + ]; + + /** + * Orden de trabajo de la tarea + * + * @return OrdenTrabajoEntity + */ + public function orden_trabajo() : OrdenTrabajoEntity + { + $m = model(OrdenTrabajoModel::class); + return $m->find($this->attributes["orden_trabajo_id"]); + } + /** + * Tarea orden de trabajo con orden de trabajo + * + * @return self + */ + public function withOrdenTrabajo() : self + { + $this->attributes["orden_trabajo"] = $this->orden_trabajo(); + return $this; + } + /** + * Devuelve la maquina actual de esta tarea + * + * @return Maquina + */ + public function maquina_actual() : Maquina + { + $m = model(MaquinaModel::class); + return $m->find($this->attributes["maquina_id"]); + } + /** + * Devuelve el presupuesto linea origen de esta tarea + * + * @return PresupuestoLineaEntity + */ + public function presupuesto_linea() : PresupuestoLineaEntity + { + $m = model(PresupuestoLineaModel::class); + return $m->find($this->attributes["presupuesto_linea_id"]); + } + /** + * Devuelve la maquina original del presupuesto linea + * + * @return Maquina + */ + public function maquina_presupuesto_linea() : Maquina + { + return $this->presupuesto_linea()->maquina(); + } + /** + * Devuelve el presupuesto acabado origen de esta tarea + * + * @return PresupuestoAcabadosEntity + */ + public function presupuesto_acabado() : PresupuestoAcabadosEntity + { + $m = model(PresupuestoAcabadosModel::class); + return $m->find($this->attributes["presupuesto_linea_id"]); + } + +} diff --git a/ci4/app/Entities/Produccion/OrdenTrabajoUserEntity.php b/ci4/app/Entities/Produccion/OrdenTrabajoUserEntity.php new file mode 100644 index 00000000..138c5d56 --- /dev/null +++ b/ci4/app/Entities/Produccion/OrdenTrabajoUserEntity.php @@ -0,0 +1,39 @@ + null, + "user_created_id"=> null, + "user_update_id"=> null, + "inaplazable_revised_change_user_id"=> null, + "ferro_disponible_hecho_user_id"=> null, + "ferro_disponible_ok_user_id"=> null, + "ferro_entregado_user_id"=> null, + "pendiente_ferro_user_id"=> null, + "ferro_en_cliente_user_id"=> null, + "ferro_ok_user_id"=> null, + "interior_bn_user_id"=> null, + "interior_color_user_id"=> null, + "preparacion_interior_user_id"=> null, + "cubierta_user_id"=> null, + "plastificado_user_id"=> null, + "encuadernacion_user_id"=> null, + "corte_user_id"=> null, + "embalaje_user_id"=> null, + "entrada_manipulado_user_id"=> null, + "pre_formato_user_id"=> null, + "pre_lomo_user_id"=> null, + "pre_solapa_user_id"=> null, + "pre_codbarras_user_id"=> null, + "pre_imposicion_user_id"=> null, + "pre_imprimir_user_id" => null + ]; +} diff --git a/ci4/app/Entities/Tarifas/Maquinas/TarifaAcabadoMaquinaEntity.php b/ci4/app/Entities/Tarifas/Maquinas/TarifaAcabadoMaquinaEntity.php new file mode 100644 index 00000000..107370f6 --- /dev/null +++ b/ci4/app/Entities/Tarifas/Maquinas/TarifaAcabadoMaquinaEntity.php @@ -0,0 +1,30 @@ + null, + "tarifa_acabado_id" => null, + "maquina_id" => null, + "maquina_tarea_id" => null, + ]; + protected $casts = [ + "id" => "integer", + "tarifa_acabado_id" => "integer", + "maquina_id" => "integer", + "maquina_tarea_id" => "?integer", + + ]; + + public function tarifa_acabado(): TarifaAcabadoEntity + { + $m = model(TarifaAcabadoModel::class); + return $m->find($this->attributes["tarifa_acabado_id"]); + } +} diff --git a/ci4/app/Entities/Tarifas/Maquinas/TarifaEncuadernacionMaquinaEntity.php b/ci4/app/Entities/Tarifas/Maquinas/TarifaEncuadernacionMaquinaEntity.php new file mode 100644 index 00000000..f0d9ee92 --- /dev/null +++ b/ci4/app/Entities/Tarifas/Maquinas/TarifaEncuadernacionMaquinaEntity.php @@ -0,0 +1,34 @@ + null, + "tarifa_encuadernacion_id" => null, + "maquina_id" => null, + "maquina_tarea_id" => null, + + + ]; + protected $casts = [ + "id" => "integer", + "tarifa_encuadernacion_id" => "integer", + "maquina_id" => "integer", + "maquina_tarea_id" => "?integer", + + + ]; + + public function tarifa_encuadernacion(): TarifaEncuadernacionEntity + { + $m = model(TarifaEncuadernacionModel::class); + return $m->find($this->attributes["tarifa_encuadernacion_id"]); + } +} diff --git a/ci4/app/Entities/Tarifas/Maquinas/TarifaExtraMaquinaEntity.php b/ci4/app/Entities/Tarifas/Maquinas/TarifaExtraMaquinaEntity.php new file mode 100644 index 00000000..9532f153 --- /dev/null +++ b/ci4/app/Entities/Tarifas/Maquinas/TarifaExtraMaquinaEntity.php @@ -0,0 +1,32 @@ + null, + "tarifa_extra_id" => null, + "maquina_id" => null, + "maquina_tarea_id" => null, + ]; + protected $casts = [ + "id" => "integer", + "tarifa_extra_id" => "integer", + "maquina_id" => "integer", + "maquina_tarea_id" => "?integer", + + ]; + + public function tarifa_extra(): TarifaextraEntity + { + $m = model(TarifaextraModel::class); + return $m->find($this->attributes["tarifa_extra_id"]); + } +} diff --git a/ci4/app/Entities/Tarifas/Maquinas/TarifaManipuladoMaquinaEntity.php b/ci4/app/Entities/Tarifas/Maquinas/TarifaManipuladoMaquinaEntity.php new file mode 100644 index 00000000..ed8fb93c --- /dev/null +++ b/ci4/app/Entities/Tarifas/Maquinas/TarifaManipuladoMaquinaEntity.php @@ -0,0 +1,31 @@ + null, + "tarifa_manipulado_id" => null, + "maquina_id" => null, + "maquina_tarea_id" => null, + + ]; + protected $casts = [ + "id" => "integer", + "tarifa_manipulado_id" => "integer", + "maquina_id" => "integer", + "maquina_tarea_id" => "?integer", + + ]; + + public function tarifa_manipulado(): TarifaManipuladoEntity + { + $m = model(TarifaManipuladoModel::class); + return $m->find($this->attributes["tarifa_manipulado_id"]); + } +} diff --git a/ci4/app/Entities/Tarifas/Maquinas/TarifaPreimpresionMaquinaEntity.php b/ci4/app/Entities/Tarifas/Maquinas/TarifaPreimpresionMaquinaEntity.php new file mode 100644 index 00000000..2eb4f991 --- /dev/null +++ b/ci4/app/Entities/Tarifas/Maquinas/TarifaPreimpresionMaquinaEntity.php @@ -0,0 +1,31 @@ + null, + "tarifa_preimpresion_id" => null, + "maquina_id" => null, + "maquina_tarea_id" => null, + + ]; + protected $casts = [ + "id" => "integer", + "tarifa_preimpresion_id" => "integer", + "maquina_id" => "integer", + "maquina_tarea_id" => "?integer", + + ]; + + public function tarifa_acabado(): TarifapreimpresionEntity + { + $m = model(TarifapreimpresionModel::class); + return $m->find($this->attributes["tarifa_preimpresion_id"]); + } +} diff --git a/ci4/app/Entities/Tarifas/TarifaEncuadernacionEntity.php b/ci4/app/Entities/Tarifas/TarifaEncuadernacionEntity.php index 03d68989..1aa85454 100755 --- a/ci4/app/Entities/Tarifas/TarifaEncuadernacionEntity.php +++ b/ci4/app/Entities/Tarifas/TarifaEncuadernacionEntity.php @@ -31,4 +31,6 @@ class TarifaEncuadernacionEntity extends \CodeIgniter\Entity\Entity "user_updated_id" => "int", "is_deleted" => "int", ]; + + } diff --git a/ci4/app/Entities/Tarifas/TarifaEncuadernacionLinea.php b/ci4/app/Entities/Tarifas/TarifaEncuadernacionLinea.php index 6a72e00c..b1a8c0b7 100755 --- a/ci4/app/Entities/Tarifas/TarifaEncuadernacionLinea.php +++ b/ci4/app/Entities/Tarifas/TarifaEncuadernacionLinea.php @@ -1,9 +1,9 @@ null, @@ -38,4 +38,6 @@ class TarifaEncuadernacionLinea extends \CodeIgniter\Entity\Entity "user_updated_id" => "int", "is_deleted" => "int", ]; + + } diff --git a/ci4/app/Helpers/time_helper.php b/ci4/app/Helpers/time_helper.php new file mode 100644 index 00000000..6e1381ce --- /dev/null +++ b/ci4/app/Helpers/time_helper.php @@ -0,0 +1,25 @@ + "Orden de trabajo", + "ots" => "Órdenes de trabajo", + "btn_pedido_produccion_accion" => "Pasar a producción", + "datatable" => [ + "pedido_id"=> "Order ID", + "fecha_encuadernacion"=> "Bookbinding date", + "cliente"=> "Client", + "titulo"=> "Title", + "ubicacion"=> "Location", + "tirada"=> "Runs", + "impresion"=> "Printing", + ] +]; \ No newline at end of file diff --git a/ci4/app/Language/es/App.php b/ci4/app/Language/es/App.php index 80a35a45..f2f5f26f 100755 --- a/ci4/app/Language/es/App.php +++ b/ci4/app/Language/es/App.php @@ -589,13 +589,13 @@ return [ // v1.2.1 "global_select" => "Selecciona un artículo", - /** * * SAFEKAT * - */ - + */ + + "progress" => "Progreso", // NOMBRES DE LOS PERMISOS "permisos_index" => "Listar", "permisos_view" => "Ver", @@ -695,6 +695,7 @@ return [ "menu_papelgenerico" => "Papel generico", "menu_papelimpresion" => "Papel impresión", "menu_series_facturas" => "Series facturas", + "menu_servicios_cliente" => "Servicios cliente", "menu_ubicaciones" => "Ubicaciones", "menu_serviciocliente" => "Servicio cliente", "menu_tamanioformatos" => "Tamaño formatos", @@ -782,6 +783,7 @@ return [ "menu_orden_trabajo_100" => "OTs 100%", "menu_orden_trabajo_finalizados" => "OTs finalizados", "menu_orden_trabajo_pendientes" => "OTs pendientes", + "menu_planning_rotativa" => "Planning rotativa", "menu_ordentrabajomaquetacion" => "Orden de trabajo maquetación", "menu_ordenmaquina" => "Orden máquina", diff --git a/ci4/app/Language/es/Maquinas.php b/ci4/app/Language/es/Maquinas.php index 1c8cfd7f..3ee7b210 100755 --- a/ci4/app/Language/es/Maquinas.php +++ b/ci4/app/Language/es/Maquinas.php @@ -42,6 +42,7 @@ return [ 'userUpdatedId' => 'User Updated ID', 'velocidad' => 'Velocidad', 'velocidadCorte' => 'Velocidad Corte', + 'maquina_tarea' => 'Máquina tarea', 'validation' => [ 'alto_menor_alto_impresion' => 'El campo \'Alto impresión\' debe ser menor que \'Alto\'', 'ancho_menor_ancho_impresion' => '\'Ancho Impresión\' debe ser menor que \'Ancho\'', diff --git a/ci4/app/Language/es/Produccion.php b/ci4/app/Language/es/Produccion.php new file mode 100644 index 00000000..eddedcd4 --- /dev/null +++ b/ci4/app/Language/es/Produccion.php @@ -0,0 +1,74 @@ + [ + "pedido_id"=> "Pedido ID", + "fecha_encuadernacion"=> "Fecha encuadernación", + "cliente"=> "Cliente", + "titulo"=> "Título", + "ubicacion"=> "Ubicación", + "tirada"=> "Tirada", + "impresion"=> "Impresión", + "fecha_entrega_at" => "Fecha entrega prevista", + "maquina" => "Máquina", + "ancho" => "Ancho", + "alto" => "Alto", + "papel" => "Papel", + "gramaje" => "Gramaje", + "corte" => "Corte", + "metros_sel" => "Metros_sel", + "metros_papel" => "Metros papel", + "tareas" => "Tareas", + "tiradas" => "Tiradas", + "tiempo" => "Tiempo", + "progreso" => "Progreso", + "logo" => "Logo impresion", + + ], + "task" => [ + "order" => "Orden", + "task" => "Tarea", + "note" => "Nota", + "maquina_presupuesto" => "Máquina presupuesto", + "maquina_actual" => "Máquina actual", + "tiempo_estimado" => "Tiempo estimado", + "tiempo" => "Tiempo" + ], + "finalizadas" => "Finalizadas", + "pendiente_ferro" => "Ferro pendiente", + "pendientes" => "Pendientes", + "ferro_ok" => "Ferro ok", + "envio" => "Envío", + "ot" => "Orden trabajo", + "ots" => "Órdenes trabajo", + "tiempo_procesamiento" => "Tiempo procesamiento", + "fecha_impresion" => "Fecha impresión", + "fecha_encuadernado" => "Fecha encuadernado", + "fecha_entrega_externo" => "Fecha entrega externo", + "fecha_entrega_real" => "Fecha entrega real", + "fecha_entrega_estimada" => "Fecha entrega estimada", + "formato" => "Formato", + "paginas" => "Páginas", + "guillotina" => "Guillotina", + "tirada" => "Tirada", + "merma" => "Merma", + "pendiente_ferro" => "Pendiente ferro", + "ferro_cliente" => "Ferro cliente", + "impresion_color" => "Impresión color", + "portada" => "portada", + "plakene_traslucido" => "Plakene traslúcido", + "plastificado_mate" => "Plastificado mate", + "espiral" => "Espiral", + "embalaje" => "Embalaje", + "tiempo_consumido" => "Tiempo consumido", + "tiempo_estimado" => "Tiempo estimado", + "finalizar_orden" => "Finalizar orden", + "comments" => "Comentarios orden trabajo", + "preview_pdf" => "Previsualizar PDF", + "imprimir_codigo_safekat" => "Imprimir código SAFEKAT", + "imprimir_ferro" => "Imprimir ferro", + "planning_rotativa" => "Planning rotativa", + "solapa" => "Solapa", + "papel_gramajes" => "Papel y gramajes" + +]; \ No newline at end of file diff --git a/ci4/app/Language/es/ServicioCliente.php b/ci4/app/Language/es/ServicioCliente.php new file mode 100644 index 00000000..5218a72b --- /dev/null +++ b/ci4/app/Language/es/ServicioCliente.php @@ -0,0 +1,14 @@ + "Servicios cliente", + "infoTarifaManipulado" => "La tarifa seleccionada estará asociada al servicio.", + "infoTarifaAcabado" => "La tarifa seleccionada estará asociada al servicio.", + + "datatable" => [ + "nombre" => "Nombre", + "code" => "Código", + "created_at" => "Fecha creación", + ] +]; \ No newline at end of file diff --git a/ci4/app/Models/Configuracion/MaquinaModel.php b/ci4/app/Models/Configuracion/MaquinaModel.php index b2f269e8..159d5e02 100755 --- a/ci4/app/Models/Configuracion/MaquinaModel.php +++ b/ci4/app/Models/Configuracion/MaquinaModel.php @@ -375,4 +375,24 @@ class MaquinaModel extends \App\Models\BaseModel return $builder->orderBy("t1.id", "asc")->get()->getResultObject(); } + + /** + * Query for select2 + * + * @param string|null $q Query param from select2 ajax request + * @param string|null $type Tipo de maquina impresion,manipulado,acabado + * @return array + */ + public function getSelectQuery(?string $q = null, ?string $type = null) : array + { + $query = $this->builder()->select(["id","nombre","tipo as description"]) + ->where("deleted_at",null); + if($q){ + $query->like("nombre",$q); + } + if($type){ + $query->where("tipo",$type); + } + return $query->get()->getResultArray(); + } } diff --git a/ci4/app/Models/Configuracion/MaquinaTareaModel.php b/ci4/app/Models/Configuracion/MaquinaTareaModel.php new file mode 100644 index 00000000..536b7fd9 --- /dev/null +++ b/ci4/app/Models/Configuracion/MaquinaTareaModel.php @@ -0,0 +1,68 @@ +builder()->select(["id","name","description"]) + ->where("deleted_at",null); + if($q){ + $query->like("nombre",$q); + } + + return $query->get()->getResultArray(); + } +} diff --git a/ci4/app/Models/Configuracion/ServicioClienteModel.php b/ci4/app/Models/Configuracion/ServicioClienteModel.php new file mode 100644 index 00000000..657081b5 --- /dev/null +++ b/ci4/app/Models/Configuracion/ServicioClienteModel.php @@ -0,0 +1,143 @@ +builder()->select(["id", "nombre", "code", "created_at"])->where("deleted_at", null); + return $q; + } + /** + * Actualiza la tarifa de acabado `lg_tarifas_acabado` si ya existe una asociada o inserta si ya no existe. + * + * @param integer $servicio_cliente_id + * @param integer $tarifa_acabado_id + * @return boolean + */ + public function upsertTarifaAcabado(int $servicio_cliente_id, int $tarifa_acabado_id): bool + { + $servicioClienteTareaModel = model(ServicioClienteTareaModel::class); + $q = $servicioClienteTareaModel + ->where("servicio_cliente_id", $servicio_cliente_id); + if ($q->countAllResults() > 0) { + $this->detachTarifas($servicio_cliente_id); + } + $r = $this->attachTarifaAcabado($servicio_cliente_id, $tarifa_acabado_id); + return $r; + } + /** + * Actualiza la tarifa de manipulado `lg_tarifas_manipulado` si ya existe una asociada o inserta si ya no existe. + * + * @param integer $servicio_cliente_id + * @param integer $tarifa_manipulado_id + * @return boolean + */ + public function upsertTarifaManipulado(int $servicio_cliente_id, int $tarifa_manipulado_id): bool + { + $servicioClienteTareaModel = model(ServicioClienteTareaModel::class); + $q = $servicioClienteTareaModel + ->where("servicio_cliente_id", $servicio_cliente_id); + if ($q->countAllResults() > 0) { + $this->detachTarifas($servicio_cliente_id); + } + $r = $this->attachTarifaManipulado($servicio_cliente_id, $tarifa_manipulado_id); + return $r; + } + /** + * Asocia tarifa de acabado a servicio cliente + * + * @param integer $servicio_cliente_id + * @param integer $tarifa_acabado_id + * @return integer + */ + public function attachTarifaAcabado(int $servicio_cliente_id, int $tarifa_acabado_id): int + { + $servicioClienteTareaModel = model(ServicioClienteTareaModel::class); + $id = $servicioClienteTareaModel->insert([ + "servicio_cliente_id" => $servicio_cliente_id, + "tarifa_acabado_id" => $tarifa_acabado_id + ]); + return $id; + } + /** + * Asocia tarifa de manipulado a servicio cliente + * + * @param integer $servicio_cliente_id + * @param integer $tarifa_manipulado_id + * @return integer + */ + public function attachTarifaManipulado(int $servicio_cliente_id, int $tarifa_manipulado_id): int + { + $servicioClienteTareaModel = model(ServicioClienteTareaModel::class); + $id = $servicioClienteTareaModel->insert([ + "servicio_cliente_id" => $servicio_cliente_id, + "tarifa_manipulado_id" => $tarifa_manipulado_id + ]); + return $id; + } + /** + * Elimina todas las tarifas asociadas a un servicio cliente + * + * @param integer $servicio_cliente_id + * @return bool + */ + public function detachTarifas(int $servicio_cliente_id): bool + { + $servicioClienteTareaModel = model(ServicioClienteTareaModel::class); + $s = $servicioClienteTareaModel->where("servicio_cliente_id", $servicio_cliente_id)->delete(); + return $s; + } +} diff --git a/ci4/app/Models/Configuracion/ServicioClienteTareaModel.php b/ci4/app/Models/Configuracion/ServicioClienteTareaModel.php new file mode 100644 index 00000000..8017161e --- /dev/null +++ b/ci4/app/Models/Configuracion/ServicioClienteTareaModel.php @@ -0,0 +1,53 @@ +builder() + ->select([ + "orden_trabajo_tareas.orden", + "mp.nombre as maquina_presupuesto", + "m.nombre as maquina_tarea", + "orden_trabajo_tareas.tiempo_estimado", + "orden_trabajo_tareas.tiempo_real" + ]) + ->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left") + ->join("lg_maquinas m", "lg_maquinas.id = orden_trabajo_tareas.maquina_id", "left") + ->join("lg_maquinas mp", "lg_maquinas.id = presupuesto_linea.maquina_id", "left") + ->join("lg_imposiciones", "lg_imposiciones.id = orden_trabajo_tareas.imposicion_id", "left") + ->where("orden_trabajo_tareas.deleted_at", NULL); + + return $q; + } + + protected function updateOrdenTrabajoUser(array $data) : array + { + if(!isset($data["data"])){ + return $data; + }else{ + $this->updateUserDateMap($data["data"]); + } + return $data; + } + protected function updateUserDateMap($data){ + $mapping = [ + "fecha_encuadernado_at" => "encuadernacion_user_id", + // "fecha_externo_at" => "null", + "fecha_impresion_at" => "null", + "pendiente_ferro_at" => "pendiente_ferro_user_id", + "ferro_en_cliente_at" => "ferro_en_cliente_user_id", + "ferro_ok_at" => "ferro_ok_user_id", + "interior_bn_at" => "interior_bn_user_id", + "interior_color_at" => "interior_color_user_id", + "preparacion_interiores_at" => "preparacion_interior_user_id", + "cubierta_at" => "cubierta_user_id", + "plastificado_at" => "plastificado_user_id", + "corte_at" => "corte_user_id", + "embalaje_at" => "embalaje_user_id", + "entrada_manipulado_at" => "entrada_manipulado_user_id" + ]; + $otUser = model(OrdenTrabajoUser::class); + $auth_user_id = auth()->user()->id; + foreach ($data as $key => $value) { + if(isset($mapping[$key])){ + if($value){ + $otUser->update($data["orden_trabajo_id"],[$mapping[$key] => $auth_user_id]); + } + } + } + } +} diff --git a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php new file mode 100644 index 00000000..ea1e00af --- /dev/null +++ b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoModel.php @@ -0,0 +1,120 @@ + "integer", + "user_created_id" => "?integer", + "user_updated_id" => "?integer", + "fecha_entrega_warning" => "bool", + "fecha_entrega_warning_revised" => "bool", + "total_tirada" => "?integer", + "total_precio" => "?integer", + "tipo_entrada" => "?integer", + "progreso" => "float", + "revisar_formato" => "bool", + "revisar_lomo" => "bool", + "revisar_solapa" => "bool", + "revisar_isbn" => "bool", + "revisar_codigo_barras" => "bool", + "realizar_imposicion" => "bool", + "enviar_impresion" => "bool" + ]; + protected array $castHandlers = []; + + // Dates + protected $useTimestamps = true; + protected $dateFormat = 'datetime'; + protected $createdField = 'created_at'; + protected $updatedField = 'updated_at'; + protected $deletedField = 'deleted_at'; + + // Validation + protected $validationRules = []; + protected $validationMessages = []; + protected $skipValidation = false; + protected $cleanValidationRules = true; + + // Callbacks + protected $allowCallbacks = true; + protected $beforeInsert = []; + protected $afterInsert = []; + protected $beforeUpdate = []; + protected $afterUpdate = []; + protected $beforeFind = []; + protected $afterFind = []; + protected $beforeDelete = []; + protected $afterDelete = []; + + public function getDatatableQuery() : BaseBuilder + { + $q = $this->builder() + ->select([ + "ordenes_trabajo.id", + "ordenes_trabajo.pedido_id", + "orden_trabajo_dates.fecha_encuadernado_at", + "clientes.nombre as cliente_nombre", + "presupuestos.titulo as presupuesto_titulo", + "ordenes_trabajo.estado", + "ubicaciones.nombre as ubicacion_nombre", + "pedidos.total_tirada", + "tipos_presupuestos.codigo as tipo_presupuesto_impresion", + "ordenes_trabajo.progreso", + "presupuesto_linea.tipo as presupuesto_linea_tipo", + "orden_trabajo_dates.ferro_ok_at" + ]) + ->join("orden_trabajo_dates","orden_trabajo_dates.orden_trabajo_id = ordenes_trabajo.id","left") + ->join("pedidos","pedidos.id = ordenes_trabajo.pedido_id","left") + ->join("pedidos_linea","pedidos.id = pedidos_linea.pedido_id","left") + ->join("presupuestos","presupuestos.id = pedidos_linea.presupuesto_id","left") + ->join("presupuesto_linea","presupuestos.id = presupuesto_linea.presupuesto_id","left") + ->join("clientes","clientes.id = presupuestos.cliente_id","left") + ->join("tipos_presupuestos","presupuestos.tipo_impresion_id = tipos_presupuestos.id","left") + ->join("ubicaciones","ubicaciones.id = pedidos_linea.ubicacion_id","left") + ->whereIn("presupuesto_linea.tipo",["lp_bn","lp_bnhq","lp_rot_bn","lp_color","lp_colorhq","lp_rot_color"]) + ->where("ordenes_trabajo.deleted_at",null) + ->groupBy("ordenes_trabajo.id"); + return $q; + } + + public function updateMaquinas(OrdenTrabajoEntity $ot) + { + + } +} diff --git a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoTarea.php b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoTarea.php new file mode 100644 index 00000000..3c6d1e84 --- /dev/null +++ b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoTarea.php @@ -0,0 +1,90 @@ +builder() + ->select([ + "orden_trabajo_tareas.orden", + "mp.nombre as maquina_presupuesto", + "m.nombre as maquina_tarea", + "orden_trabajo_tareas.tiempo_estimado", + "orden_trabajo_tareas.tiempo_real" + ]) + ->join("presupuesto_linea","presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id","left") + ->join("lg_maquinas m","lg_maquinas.id = orden_trabajo_tareas.maquina_id","left") + ->join("lg_maquinas mp","lg_maquinas.id = presupuesto_linea.maquina_id","left") + ->join("lg_imposiciones", "lg_imposiciones.id = orden_trabajo_tareas.imposicion_id" , "left") + ->where("orden_trabajo_tareas.deleted_at" , NULL); + + return $q; + } + + + +} diff --git a/ci4/app/Models/OrdenTrabajo/OrdenTrabajoUser.php b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoUser.php new file mode 100644 index 00000000..2c56c3c6 --- /dev/null +++ b/ci4/app/Models/OrdenTrabajo/OrdenTrabajoUser.php @@ -0,0 +1,103 @@ + "integer", + "user_created_id" => "?integer", + "user_update_id" => "?integer", + "inaplazable_revised_change_user_id" => "?integer", + "ferro_disponible_hecho_user_id" => "?integer", + "ferro_disponible_ok_user_id" => "?integer", + "ferro_entregado_user_id" => "?integer", + "pendiente_ferro_user_id" => "?integer", + "ferro_en_cliente_user_id" => "?integer", + "ferro_ok_user_id" => "?integer", + "interior_bn_user_id" => "?integer", + "interior_color_user_id" => "?integer", + "preparacion_interior_user_id" => "?integer", + "cubierta_user_id" => "?integer", + "plastificado_user_id" => "?integer", + "encuadernacion_user_id" => "?integer", + "corte_user_id" => "?integer", + "embalaje_user_id" => "?integer", + "entrada_manipulado_user_id" => "?integer", + "pre_formato_user_id" => "?integer", + "pre_lomo_user_id" => "?integer", + "pre_solapa_user_id" => "?integer", + "pre_codbarras_user_id" => "?integer", + "pre_imposicion_user_id" => "?integer", + "pre_imprimir_user_id" => "?integer" + ]; + protected array $castHandlers = []; + + // Dates + protected $useTimestamps = true; + protected $dateFormat = 'datetime'; + protected $createdField = 'created_at'; + protected $updatedField = 'updated_at'; + protected $deletedField = 'deleted_at'; + + // Validation + protected $validationRules = []; + protected $validationMessages = []; + protected $skipValidation = false; + protected $cleanValidationRules = true; + + // Callbacks + protected $allowCallbacks = true; + protected $beforeInsert = []; + protected $afterInsert = []; + protected $beforeUpdate = []; + protected $afterUpdate = []; + protected $beforeFind = []; + protected $afterFind = []; + protected $beforeDelete = []; + protected $afterDelete = []; + + + +} diff --git a/ci4/app/Models/Pedidos/PedidoModel.php b/ci4/app/Models/Pedidos/PedidoModel.php index e67db27d..9c955f40 100644 --- a/ci4/app/Models/Pedidos/PedidoModel.php +++ b/ci4/app/Models/Pedidos/PedidoModel.php @@ -2,6 +2,9 @@ namespace App\Models\Pedidos; +use App\Entities\Presupuestos\OrdenTrabajoEntity; +use App\Models\OrdenTrabajo\OrdenTrabajoModel; + use function PHPSTORM_META\map; class PedidoModel extends \App\Models\BaseModel @@ -90,7 +93,7 @@ class PedidoModel extends \App\Models\BaseModel return $lineasPresupuesto; } - public function getPedidoPresupuestoTipoImpresion(int $presupuesto_id) : array|object|null + public function getPedidoPresupuestoTipoImpresion(int $presupuesto_id): array|object|null { $q = $this->db->table($this->table) ->select( @@ -185,15 +188,51 @@ class PedidoModel extends \App\Models\BaseModel public function getPedidoPresupuestoFicheros($pedido_id) { $query = $this->db->table($this->table) - ->select([ - 'presupuesto_ficheros.nombre as fileName', - 'presupuesto_ficheros.file_path as filePath' - ]) - ->join('pedidos_linea', 'pedidos_linea.id = pedidos.id', 'left') - ->join('presupuestos', 'presupuestos.id = pedidos_linea.presupuesto_id', 'left') - ->join('presupuesto_ficheros', 'presupuesto_ficheros.presupuesto_id = presupuestos.id', 'left') - ->where('pedidos.id', $pedido_id); - $presupuesto_ficheros = $query->get()->getFirstRow(); - return $presupuesto_ficheros; + ->select([ + 'presupuesto_ficheros.nombre as fileName', + 'presupuesto_ficheros.file_path as filePath' + ]) + ->join('pedidos_linea', 'pedidos_linea.id = pedidos.id', 'left') + ->join('presupuestos', 'presupuestos.id = pedidos_linea.presupuesto_id', 'left') + ->join('presupuesto_ficheros', 'presupuesto_ficheros.presupuesto_id = presupuestos.id', 'left') + ->where('pedidos.id', $pedido_id); + $presupuesto_ficheros = $query->get()->getFirstRow(); + return $presupuesto_ficheros; + } + + /** + * Crea una orden de trabajo asociada al pedido + * + * @param integer $pedido_id + * @return void + */ + public function createOrdenTrabajo(int $pedido_id) + { + $otModel = model(OrdenTrabajoModel::class); + $ot = new OrdenTrabajoEntity(["pedido_id" => $pedido_id]); + $existOt = $this->hasOrdenTrabajo($pedido_id); + if ($existOt) { + $ot = $otModel->find($pedido_id); + return $ot; + } + $otModel->updateMaquinas($ot); + } + + /** + * Comprueba si el pedido tiene ya una orden de trabajo asociada + * + * @param integer $pedido_id + * @return boolean + */ + public function hasOrdenTrabajo(int $pedido_id): bool + { + $hasOrdenTrabajo = false; + $q = $this->builder()->select("orden_trabajo.pedido_id") + ->join("ordenes_trabajo", "ordenes_trabajo.pedido_id = pedidos.id", "left") + ->where("ordenes_trabajo.pedido_id", $pedido_id)->countAllResults(); + if ($q > 0) { + $hasOrdenTrabajo = true; + } + return $hasOrdenTrabajo; } } diff --git a/ci4/app/Models/Tarifas/Maquinas/TarifaAcabadoMaquinaModel.php b/ci4/app/Models/Tarifas/Maquinas/TarifaAcabadoMaquinaModel.php new file mode 100644 index 00000000..cd5d9c29 --- /dev/null +++ b/ci4/app/Models/Tarifas/Maquinas/TarifaAcabadoMaquinaModel.php @@ -0,0 +1,75 @@ +builder()->select( + [ + "tarifa_acabado_maquinas.id", + "lg_maquinas.nombre as maquinaNombre", + "maquina_tareas.name as tareaNombre" + ] + )->join("lg_maquinas","lg_maquinas.id = tarifa_acabado_maquinas.maquina_id","left") + ->join("maquina_tareas","maquina_tareas.id = tarifa_acabado_maquinas.maquina_tarea_id","left") + ->where("tarifa_acabado_maquinas.deleted_at",null); + if ($tarifa_acabado_id) + $query->where("tarifa_acabado_maquinas.tarifa_acabado_id", $tarifa_acabado_id); + return $query; + + } +} diff --git a/ci4/app/Models/Tarifas/Maquinas/TarifaEncuadernacionMaquinaModel.php b/ci4/app/Models/Tarifas/Maquinas/TarifaEncuadernacionMaquinaModel.php new file mode 100644 index 00000000..6673625f --- /dev/null +++ b/ci4/app/Models/Tarifas/Maquinas/TarifaEncuadernacionMaquinaModel.php @@ -0,0 +1,74 @@ +builder()->select( + [ + "tarifa_encuadernacion_maquinas.id", + "lg_maquinas.nombre as maquinaNombre", + "maquina_tareas.name as tareaNombre" + ] + )->join("lg_maquinas","lg_maquinas.id = tarifa_encuadernacion_maquinas.maquina_id","left") + ->join("maquina_tareas","maquina_tareas.id = tarifa_encuadernacion_maquinas.maquina_tarea_id","left") + ->where("tarifa_encuadernacion_maquinas.deleted_at",null); + if ($tarifa_encuadernacion_id) + $query->where("tarifa_encuadernacion_maquinas.tarifa_encuadernacion_id", $tarifa_encuadernacion_id); + return $query; + } +} diff --git a/ci4/app/Models/Tarifas/Maquinas/TarifaExtraMaquinaModel.php b/ci4/app/Models/Tarifas/Maquinas/TarifaExtraMaquinaModel.php new file mode 100644 index 00000000..1ee4be1e --- /dev/null +++ b/ci4/app/Models/Tarifas/Maquinas/TarifaExtraMaquinaModel.php @@ -0,0 +1,75 @@ +builder()->select( + [ + "tarifa_extra_maquinas.id", + "lg_maquinas.nombre as maquinaNombre", + "maquina_tareas.name as tareaNombre" + ] + )->join("lg_maquinas", "lg_maquinas.id = tarifa_extra_maquinas.maquina_id", "left") + ->join("maquina_tareas", "maquina_tareas.id = tarifa_extra_maquinas.maquina_tarea_id", "left") + ->where("tarifa_extra_maquinas.deleted_at", null); + if ($tarifa_extra_id) + $query->where("tarifa_extra_maquinas.tarifa_extra_id", $tarifa_extra_id); + return $query; + } +} diff --git a/ci4/app/Models/Tarifas/Maquinas/TarifaManipuladoMaquinaModel.php b/ci4/app/Models/Tarifas/Maquinas/TarifaManipuladoMaquinaModel.php new file mode 100644 index 00000000..4dc7430d --- /dev/null +++ b/ci4/app/Models/Tarifas/Maquinas/TarifaManipuladoMaquinaModel.php @@ -0,0 +1,75 @@ +builder()->select( + [ + "tarifa_manipulado_maquinas.id", + "lg_maquinas.nombre as maquinaNombre", + "maquina_tareas.name as tareaNombre" + ] + )->join("lg_maquinas", "lg_maquinas.id = tarifa_manipulado_maquinas.maquina_id", "left") + ->join("maquina_tareas", "maquina_tareas.id = tarifa_manipulado_maquinas.maquina_tarea_id", "left") + ->where("tarifa_manipulado_maquinas.deleted_at", null); + if ($tarifa_manipulado_id) + $query->where("tarifa_manipulado_maquinas.tarifa_manipulado_id", $tarifa_manipulado_id); + return $query; + } +} diff --git a/ci4/app/Models/Tarifas/Maquinas/TarifaPreimpresionMaquinaModel.php b/ci4/app/Models/Tarifas/Maquinas/TarifaPreimpresionMaquinaModel.php new file mode 100644 index 00000000..582e5bc3 --- /dev/null +++ b/ci4/app/Models/Tarifas/Maquinas/TarifaPreimpresionMaquinaModel.php @@ -0,0 +1,75 @@ +builder()->select( + [ + "tarifa_preimpresion_maquinas.id", + "lg_maquinas.nombre as maquinaNombre", + "maquina_tareas.name as tareaNombre" + ] + )->join("lg_maquinas", "lg_maquinas.id = tarifa_preimpresion_maquinas.maquina_id", "left") + ->join("maquina_tareas", "maquina_tareas.id = tarifa_preimpresion_maquinas.maquina_tarea_id", "left") + ->where("tarifa_preimpresion_maquinas.deleted_at", null); + if ($tarifa_preimpresion_id) + $query->where("tarifa_preimpresion_maquinas.tarifa_preimpresion_id", $tarifa_preimpresion_id); + return $query; + } +} diff --git a/ci4/app/Models/UserModel.php b/ci4/app/Models/UserModel.php index e8b34efe..cd7d2944 100644 --- a/ci4/app/Models/UserModel.php +++ b/ci4/app/Models/UserModel.php @@ -5,10 +5,13 @@ declare(strict_types=1); namespace App\Models; use App\Entities\Usuarios\UsersEntity; +use CodeIgniter\Shield\Authentication\Traits\HasAccessTokens; use CodeIgniter\Shield\Models\UserModel as ShieldUserModel; class UserModel extends ShieldUserModel { + use HasAccessTokens; + protected function initialize(): void { parent::initialize(); diff --git a/ci4/app/Services/MessageService.php b/ci4/app/Services/MessageService.php deleted file mode 100644 index 8202257d..00000000 --- a/ci4/app/Services/MessageService.php +++ /dev/null @@ -1,14 +0,0 @@ - "encuadernacion_user_id", + // "fecha_externo_at" => "null", + "fecha_impresion_at" => "null", + "pendiente_ferro_at" => "pendiente_ferro_user_id", + "ferro_en_cliente_at" => "ferro_en_cliente_user_id", + "ferro_ok_at" => "ferro_ok_user_id", + "interior_bn_at" => "interior_bn_user_id", + "interior_color_at" => "interior_color_user_id", + "preparacion_interiores_at" => "preparacion_interior_user_id", + "cubierta_at" => "cubierta_user_id", + "plastificado_at" => "plastificado_user_id", + "corte_at" => "corte_user_id", + "embalaje_at" => "embalaje_user_id", + "entrada_manipulado_at" => "entrada_manipulado_user_id" + ]; + + /** + * Pedido Entity + * + * @var PedidoEntity + */ + protected PedidoEntity $pedido; + /** + * Presupuesto Entity + * + * @var PresupuestoEntity + */ + protected PresupuestoEntity $presupuesto; + + public function __construct() { + $this->otModel = model(OrdenTrabajoModel::class); + $this->otDate = model(OrdenTrabajoDate::class); + $this->otTarea = model(OrdenTrabajoTarea::class); + $this->otUser = model(OrdenTrabajoUser::class); + $this->userModel = model(UserModel::class); + + } + public function init(int $orden_trabajo_id): self + { + $this->otModel = model(OrdenTrabajoModel::class); + $this->ot = $this->otModel->find($orden_trabajo_id); + $pedido = $this->ot->pedido(); + $this->setPedido($pedido); + return $this; + } + /** + * Establece el pedido sobre el que se va a trabajar + * + * @param PedidoEntity $pedido + * @return self + */ + public function setPedido(PedidoEntity $pedido): self + { + $this->pedido = $pedido; + $this->presupuesto = $this->pedido->presupuesto(); + $this->otModel = model(OrdenTrabajoModel::class); + $this->otDate = model(OrdenTrabajoDate::class); + $this->otTarea = model(OrdenTrabajoTarea::class); + return $this; + } + /** + * Devuelve la orden de trabajo. + * + * @return OrdenTrabajoEntity + */ + public function getOrdenTrabajo(): OrdenTrabajoEntity + { + return $this->ot; + } + + /** + * Crea una instancia de la orden de trabajo + * + * @return self + */ + public function createOrdenTrabajo(): OrdenTrabajoEntity|DatabaseException + { + + $auth_user = auth()->user(); + $ot = new OrdenTrabajoEntity(); + $ot_exists = $this->pedido->orden_trabajo(); + if ($ot_exists) { + return $ot_exists; + } + $data = [ + "pedido_id" => $this->pedido->id, + "user_created_id" => $auth_user->id, + "user_updated_id" => $auth_user->id, + "total_tirada" => $this->pedido->total_tirada, + "total_precio" => $this->pedido->total_precio + ]; + $ot->fill($data); + $this->otModel->save($ot); + $ot_id = $this->otModel->getInsertID(); + $ot->id = $ot_id; + $this->init($ot_id); + $this->storeOrdenTrabajoUsers(); + $this->storeOrdenTrabajoDates(); + $this->storeAllTareas(); + return $this->ot; + } + + /** + * Inserta las fechas del pedido asociado a la orden de trabajo en `orden_trabajo_tareas` + * + * @param OrdenTrabajoEntity $ot + * @return integer|boolean|string ID + */ + protected function storeOrdenTrabajoDates() : int|bool|string + { + $fecha_encuadernado = Time::now()->addDays(2)->format("Y-m-d"); + $fecha_entrega_real = Time::now()->addDays(5)->format("Y-m-d"); + $fecha_embalaje_at = Time::now()->addDays(4)->format("Y-m-d"); + return $this->otDate->insert([ + "orden_trabajo_id" => $this->ot->id, + "fecha_encuadernado_at" => $fecha_encuadernado, + "fecha_entrega_real_at" => $fecha_entrega_real, + "fecha_impresion_at" => Time::now()->format("Y-m-d"), + "embalaje_at" => $fecha_embalaje_at, + "fecha_entrega_externo" => $this->pedido->fecha_entrega_externo, + ]); + } + protected function storeOrdenTrabajoUsers() : int|bool|string + { + return $this->otUser->insert([ + "orden_trabajo_id" => $this->ot->id, + ]); + } + protected function storeAllTareas() + { + $this->storeOrdenTrabajoTareas(); + $this->storeOrdenTrabajoAcabadoTareas(); + $this->storeOrdenTrabajoManipuladoTareas(); + $this->storeOrdenTrabajoPreimpresionTareas(); + $this->storeOrdenTrabajoEncuadernacionTareas(); + $this->storeOrdenTrabajoExtraTareas(); + } + public function resetAllTareas(): BaseResult|bool + { + $r = $this->otTarea->where("orden_trabajo_id", $this->ot->id)->delete(purge: true); + $this->storeAllTareas(); + return $r; + } + /** + * Inserta las tareas de la orden de trabajo. + * Acepta como argumento una entidad de la orden de trabajo OrdenTrabajoEntity + * + * + * @return integer|boolean Numero de registro insertados o `FALSE` si error + */ + protected function storeOrdenTrabajoTareas(): int|bool + { + + $p_lineas = $this->presupuesto->presupuestoLineas(); + $ot_tareas = []; + + foreach ($p_lineas as $key => $p_linea) { + $p_linea_maquina = $p_linea->maquina(); + $nombre = $p_linea->get_nombre_tarea(); + $ot_tareas["orden_trabajo_id"] = $this->ot->id; + $ot_tareas["presupuesto_linea_id"] = $p_linea->id; + $ot_tareas["nombre"] = $nombre; + $ot_tareas["orden"] = $p_linea_maquina->orden_planning ?? 0; + $ot_tareas["maquina_id"] = $p_linea_maquina->id; + $ot_tareas["imposicion_id"] = null; + $ot_tareas["tiempo_estimado"] = $p_linea->horas_maquina; + $ot_tareas["tiempo_real"] = $p_linea->horas_maquina; //? Tiempo real se inserta manual? + $insert_query_result = $this->otTarea->insert($ot_tareas); + $ot_tareas = []; + } + return $insert_query_result; + } + protected function storeOrdenTrabajoAcabadoTareas(): bool + { + $p_lineas = $this->presupuesto_lineas_acabado(); + foreach ($p_lineas as $key => $p_linea) { + $p_linea_maquinas = $p_linea->maquinas(); + $ot_tareas = []; + if (count($p_linea_maquinas) > 0) { + foreach ($p_linea_maquinas as $key => $linea) { + $ot_tareas["orden_trabajo_id"] = $this->ot->id; + $ot_tareas["presupuesto_acabado_id"] = $p_linea->id; + $ot_tareas["nombre"] = $p_linea->tarifa()->nombre; + $ot_tareas["orden"] = $linea->orden_planning ?? 0; + $ot_tareas["maquina_id"] = $linea->id; + $ot_tareas["imposicion_id"] = null; + $this->otTarea->insert($ot_tareas); + $ot_tareas = []; + } + } else { + $ot_tareas["orden_trabajo_id"] = $this->ot->id; + $ot_tareas["presupuesto_acabado_id"] = $p_linea->id; + $ot_tareas["nombre"] = $p_linea->tarifa()->nombre ?? ""; + $this->otTarea->insert($ot_tareas); + } + } + return true; + } + protected function storeOrdenTrabajoManipuladoTareas(): bool + { + $p_lineas = $this->presupuesto_lineas_manipulado(); + foreach ($p_lineas as $key => $p_linea) { + $p_linea_maquinas = $p_linea->maquinas(); + $ot_tareas = []; + if (count($p_linea_maquinas) > 0) { + foreach ($p_linea_maquinas as $key => $linea) { + $ot_tareas["orden_trabajo_id"] = $this->ot->id; + $ot_tareas["presupuesto_manipulado_id"] = $p_linea->id; + $ot_tareas["nombre"] = $p_linea->tarifa()->nombre; + $ot_tareas["orden"] = $linea->orden_planning ?? 0; + $ot_tareas["maquina_id"] = $linea->id; + $ot_tareas["imposicion_id"] = null; + $this->otTarea->insert($ot_tareas); + $ot_tareas = []; + } + } else { + $ot_tareas["orden_trabajo_id"] = $this->ot->id; + $ot_tareas["presupuesto_manipulado_id"] = $p_linea->id; + $ot_tareas["nombre"] = $p_linea->tarifa()->nombre ?? ""; + $this->otTarea->insert($ot_tareas); + } + } + return true; + } + protected function storeOrdenTrabajoPreimpresionTareas(): bool + { + $p_lineas = $this->presupuesto_lineas_preimpresion(); + foreach ($p_lineas as $key => $p_linea) { + $p_linea_maquinas = $p_linea->maquinas(); + $ot_tareas = []; + if (count($p_linea_maquinas) > 0) { + foreach ($p_linea_maquinas as $key => $linea) { + $ot_tareas["orden_trabajo_id"] = $this->ot->id; + $ot_tareas["presupuesto_preimpresion_id"] = $p_linea->id; + $ot_tareas["nombre"] = $p_linea->tarifa()->nombre; + $ot_tareas["orden"] = $linea->orden_planning ?? 0; + $ot_tareas["maquina_id"] = $linea->id; + $ot_tareas["imposicion_id"] = null; + $this->otTarea->insert($ot_tareas); + $ot_tareas = []; + } + } else { + $ot_tareas["orden_trabajo_id"] = $this->ot->id; + $ot_tareas["presupuesto_preimpresion_id"] = $p_linea->id; + $ot_tareas["nombre"] = $p_linea->tarifa()->nombre ?? ""; + $this->otTarea->insert($ot_tareas); + } + } + return true; + } + protected function storeOrdenTrabajoEncuadernacionTareas(): bool + { + $p_lineas = $this->presupuesto_lineas_encuadernaciones(); + foreach ($p_lineas as $key => $p_linea) { + $p_linea_maquinas = $p_linea->maquinas(); + $ot_tareas = []; + if (count($p_linea_maquinas) > 0) { + foreach ($p_linea_maquinas as $key => $linea) { + $ot_tareas["orden_trabajo_id"] = $this->ot->id; + $ot_tareas["presupuesto_encuadernado_id"] = $p_linea->id; + $ot_tareas["nombre"] = $p_linea->tarifa()->nombre; + $ot_tareas["orden"] = $linea->orden_planning ?? 0; + $ot_tareas["maquina_id"] = $linea->id; + $ot_tareas["imposicion_id"] = null; + $this->otTarea->insert($ot_tareas); + $ot_tareas = []; + } + } else { + $ot_tareas["orden_trabajo_id"] = $this->ot->id; + $ot_tareas["presupuesto_encuadernado_id"] = $p_linea->id; + $ot_tareas["nombre"] = $p_linea->tarifa()->nombre ?? ""; + $this->otTarea->insert($ot_tareas); + } + } + return true; + } + protected function storeOrdenTrabajoExtraTareas(): bool + { + $p_lineas = $this->presupuesto_lineas_extras(); + foreach ($p_lineas as $key => $p_linea) { + $p_linea_maquinas = $p_linea->maquinas(); + $ot_tareas = []; + if (count($p_linea_maquinas) > 0) { + foreach ($p_linea_maquinas as $key => $linea) { + $ot_tareas["orden_trabajo_id"] = $this->ot->id; + $ot_tareas["presupuesto_extra_id"] = $p_linea->id; + $ot_tareas["nombre"] = $p_linea->tarifa()->nombre; + $ot_tareas["orden"] = $linea->orden_planning; + $ot_tareas["maquina_id"] = $linea->id; + $ot_tareas["imposicion_id"] = null; + $this->otTarea->insert($ot_tareas); + $ot_tareas = []; + } + } else { + $ot_tareas["orden_trabajo_id"] = $this->ot->id; + $ot_tareas["presupuesto_extra_id"] = $p_linea->id; + $ot_tareas["nombre"] = $p_linea->tarifa()->nombre ?? ""; + + $this->otTarea->insert($ot_tareas); + } + } + return true; + } + + + + public function getTareas(): array + { + $p_lineas_with_maquina = $this->getPresupuestoLineasWithMaquina(); + $tareas = []; + $tarea = []; + foreach ($p_lineas_with_maquina as $key => $linea) { + $tarea["orden"] = $linea->maquina->orden_planning; + $tarea["maquina_tipo"] = $linea->maquina->tipo; + $tarea["maquina_nombre"] = $linea->maquina->nombre; + $tarea["nota"] = null; + $tareas[] = $tarea; + $tarea = []; + } + return ["tareas" => $tareas]; + } + + public function getPdf() + { + return view("themes/vuexy/pdfs/orden_trabajo",$this->getDataPdf()); + } + /** + * Query para mostrar en datatable + * + * @return BaseBuilder + */ + public function taskDatatableQuery(): BaseBuilder + { + $q = $this->otModel->builder()->select([ + "orden_trabajo_tareas.id", + "orden_trabajo_tareas.orden", + "orden_trabajo_tareas.nombre", + "lgmp.nombre as maquina_presupuesto_linea", + "orden_trabajo_tareas.maquina_id as maquina_tarea", + "lg_maquinas.nombre as maquina_nombre", + "lg_imposiciones.id as imposicion_id", + "orden_trabajo_tareas.tiempo_estimado", + "orden_trabajo_tareas.tiempo_real", + "orden_trabajo_tareas.comment", + + ]) + ->join("orden_trabajo_tareas", "orden_trabajo_tareas.orden_trabajo_id = ordenes_trabajo.id", "left") + ->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left") + ->join("presupuesto_acabados", "presupuesto_acabados.id = orden_trabajo_tareas.presupuesto_acabado_id", "left") + ->join("presupuesto_manipulados", "presupuesto_manipulados.id = orden_trabajo_tareas.presupuesto_manipulado_id", "left") + ->join("presupuesto_preimpresiones", "presupuesto_preimpresiones.id = orden_trabajo_tareas.presupuesto_preimpresion_id", "left") + ->join("presupuesto_encuadernaciones", "presupuesto_encuadernaciones.id = orden_trabajo_tareas.presupuesto_encuadernado_id", "left") + ->join("presupuesto_serviciosExtra", "presupuesto_serviciosExtra.id = orden_trabajo_tareas.presupuesto_extra_id", "left") + ->join("lg_maquinas", "lg_maquinas.id = orden_trabajo_tareas.maquina_id", "left") + ->join("lg_maquinas as lgmp", "lgmp.id = presupuesto_linea.maquina_id", "left") + ->join("lg_imposiciones", "lg_imposiciones.id = orden_trabajo_tareas.imposicion_id", "left") + ->where("orden_trabajo_tareas.orden_trabajo_id", $this->ot->id) + ->where("orden_trabajo_tareas.deleted_at", null) + ->orderBy("orden_trabajo_tareas.orden", "ASC"); + return $q; + } + /** + * Query para mostrar en datatable + * + * @return BaseBuilder + */ + public function planningRotativaQueryDatatable(): BaseBuilder + { + $q = $this->otModel->builder()->select([ + "ordenes_trabajo.id as otId", + "orden_trabajo_dates.fecha_entrega_real_at", + "presupuestos.titulo as presupuesto_titulo", + "orden_trabajo_tareas.maquina_id", + "lg_maquinas.nombre as maquina_planning_nombre", + "ordenes_trabajo.total_tirada as ot_tirada", + "lg_papel_formato.ancho as maquina_ancho", + "lg_papel_formato.alto as maquina_alto", + // "JSON_EXTRACT(presupuesto_linea.formas,'$.maquina_ancho') as maquina_ancho", + // "JSON_EXTRACT(presupuesto_linea.formas,'$.maquina_alto') as maquina_alto", + "lg_papel_impresion.nombre as papel_impresion", + "presupuesto_linea.gramaje as papel_gramaje", + + + + ]) + ->join("orden_trabajo_tareas", "orden_trabajo_tareas.orden_trabajo_id = ordenes_trabajo.id", "left") + ->join("orden_trabajo_dates", "orden_trabajo_dates.orden_trabajo_id = ordenes_trabajo.id", "left") + ->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left") + ->join("presupuestos", "presupuestos.id = presupuesto_linea.presupuesto_id", "right") + ->join("lg_papel_formato", "lg_papel_formato.id = presupuestos.papel_formato_id", "left") + ->join("lg_maquinas", "lg_maquinas.id = orden_trabajo_tareas.maquina_id", "left") + ->join("lg_papel_impresion", "lg_papel_impresion.id = presupuesto_linea.papel_impresion_id", "left") + ->join("lg_maquinas as lgmp", "lgmp.id = presupuesto_linea.maquina_id", "left") + ->join("lg_imposiciones", "lg_imposiciones.id = orden_trabajo_tareas.imposicion_id", "left") + // ->where("orden_trabajo_tareas.orden_trabajo_id", $this->ot->id) + ->whereIn("presupuesto_linea.tipo", ["lp_rot_bn","lp_rot_color"]) + ->where("orden_trabajo_tareas.deleted_at", null) + ->orderBy("orden_trabajo_tareas.orden", "ASC"); + return $q; + } + /** + * Query para mostrar en datatable + * + * @return BaseBuilder + */ + public function costDatatableQuery(): BaseBuilder + { + $q = $this->otModel->builder()->select([ + "orden_trabajo_tareas.id", + "orden_trabajo_tareas.orden", + "orden_trabajo_tareas.nombre", + "lgmp.nombre as maquina_presupuesto_linea", + "orden_trabajo_tareas.maquina_id as maquina_tarea", + "lg_maquinas.nombre as maquina_nombre", + "lg_imposiciones.id as imposicion_id", + "orden_trabajo_tareas.tiempo_estimado", + "orden_trabajo_tareas.tiempo_real" + ]) + ->join("orden_trabajo_tareas", "orden_trabajo_tareas.orden_trabajo_id = ordenes_trabajo.id", "left") + ->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left") + ->join("presupuesto_acabados", "presupuesto_acabados.id = orden_trabajo_tareas.presupuesto_acabado_id", "left") + ->join("presupuesto_manipulados", "presupuesto_manipulados.id = orden_trabajo_tareas.presupuesto_manipulado_id", "left") + ->join("presupuesto_preimpresiones", "presupuesto_preimpresiones.id = orden_trabajo_tareas.presupuesto_preimpresion_id", "left") + ->join("presupuesto_encuadernaciones", "presupuesto_encuadernaciones.id = orden_trabajo_tareas.presupuesto_encuadernado_id", "left") + ->join("presupuesto_serviciosExtra", "presupuesto_serviciosExtra.id = orden_trabajo_tareas.presupuesto_extra_id", "left") + ->join("lg_maquinas", "lg_maquinas.id = orden_trabajo_tareas.maquina_id", "left") + ->join("lg_maquinas as lgmp", "lgmp.id = presupuesto_linea.maquina_id", "left") + ->join("lg_imposiciones", "lg_imposiciones.id = orden_trabajo_tareas.imposicion_id", "left") + ->where("orden_trabajo_tareas.orden_trabajo_id", $this->ot->id) + ->where("orden_trabajo_tareas.deleted_at", null) + ->orderBy("orden_trabajo_tareas.orden", "ASC"); + return $q; + } + public function papelGramajeDatatableQuery() : BaseBuilder + { + $q = $this->otModel->builder()->select([ + "lg_papel_impresion.nombre as papelImpresionNombre", + "lg_papel_impresion.gramaje as papelImpresionGramaje", + "COUNT(orden_trabajo_tareas.id) as tareasCount", + "SUM(ordenes_trabajo.total_tirada) as totalTirada", + "SUM(orden_trabajo_tareas.tiempo_real) as tiempoReal" + ]) + ->join("orden_trabajo_tareas", "orden_trabajo_tareas.orden_trabajo_id = ordenes_trabajo.id", "left") + ->join("presupuesto_linea", "presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id", "left") + ->join("lg_papel_impresion","presupuesto_linea.papel_impresion_id = lg_papel_impresion.id","left") + ->where("orden_trabajo_tareas.deleted_at", null) + ->where("orden_trabajo_tareas.presupuesto_linea_id IS NOT NULL", NULL,FALSE); + + + + return $q; + } + /** + * Get a summary from ot with the following structure + * + * @return array + * ```php + * [ + * "ot" => OrdenTrabajoEntity + * "dates" => OrdenTrabajoDateEntity + * "tasks" => array + * ]; + * ``` + */ + public function getSummary(): array + { + + $summary = [ + "ot" => $this->ot, + "pedido" => $this->pedido, + "presupuesto" => $this->presupuesto, + "dates" => $this->ot->dates(), + "tasks" => $this->ot->tareas(), + "acabados" => $this->presupuesto->acabados(), + "preimpresiones" => $this->presupuesto->preimpresiones(), + "manipulados" => $this->presupuesto->manipulados(), + "encuadernaciones" => $this->presupuesto->encuadernaciones(), + "impresion_interior_bn" => $this->getTareaImpresionInteriorBn(), + "impresion_interior_color" => $this->getTareaImpresionInteriorColor(), + "tareas_acabado" => $this->tareas_acabado(), + "tareas_manipulado" => $this->tareas_manipulado(), + "tareas_encuadernacion" => $this->tareas_encuadernacion(), + "tareas_preimpresion" => $this->tareas_preimpresion(), + "tareas_impresion" => $this->tareas_impresion(), + ]; + return $summary; + } + public function getDataPdf(){ + $logistica_data = $this->logistica_data(); + return [ + "ot" => $this->ot, + "pedido" => $this->pedido, + "presupuesto" => $this->presupuesto, + "cliente" => $this->presupuesto->cliente(), + "ubicacion" => $this->pedido->ubicacion()->nombre, + "dates" => $this->ot->dates(), + "tasks" => $this->ot->tareas(), + "papel_formato" => $this->presupuesto->papel_formato(), + "acabados" => $this->presupuesto->acabados(), + "preimpresiones" => $this->presupuesto->preimpresiones(), + "manipulados" => $this->presupuesto->manipulados(), + "encuadernaciones" => $this->presupuesto->encuadernaciones(), + "linea_impresion" => $this->presupuesto->presupuestoLineaImpresion(), + "linea_cubierta" => $this->presupuesto->presupuestoLineaCubierta(), + "peso_unidad" => $logistica_data["peso_unidad"], + "peso_pedido" => $logistica_data["peso_pedido"] + ]; + } + public function getTareaImpresionSobreCubierta() : array + { + $q = $this->otTarea->select('orden_trabajo_tareas.*') + ->join("presupuesto_linea","presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id","left") + ->where("orden_trabajo_tareas.orden_trabajo_id",$this->ot->id) + ->whereIn("presupuesto_linea.tipo",["lp_sobrecubierta"])->findAll(); + return $q; + } + public function getTareaImpresionCubierta() : array + { + $q = $this->otTarea->select('orden_trabajo_tareas.*') + ->join("presupuesto_linea","presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id","left") + ->where("orden_trabajo_tareas.orden_trabajo_id",$this->ot->id) + ->whereIn("presupuesto_linea.tipo",["lp_cubierta"])->findAll(); + return $q; + } + public function getTareaImpresionInteriorBn() : array + { + $q = $this->otTarea->select('orden_trabajo_tareas.*') + ->join("presupuesto_linea","presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id","left") + ->where("orden_trabajo_tareas.orden_trabajo_id",$this->ot->id) + ->whereIn("presupuesto_linea.tipo",["lp_rot_bn","lp_bn","lp_bnhq"])->findAll(); + return $q; + } + public function getTareaImpresionInteriorColor() : array + { + $q = $this->otTarea->select('orden_trabajo_tareas.*') + ->join("presupuesto_linea","presupuesto_linea.id = orden_trabajo_tareas.presupuesto_linea_id","left") + ->where("orden_trabajo_tareas.orden_trabajo_id",$this->ot->id) + ->whereIn("presupuesto_linea.tipo",["lp_rot_color","lp_color","lp_colorhq"])->findAll(); + return $q; + } + public function getPresupuestoLineaImpresion(){ + } + public function tareas_acabado(): array + { + $q = $this->otTarea->where("presupuesto_acabado_id IS NOT NULL",NULL,FALSE)->findAll(); + return $q; + } + public function tareas_impresion(): array + { + $q = $this->otTarea->where("presupuesto_linea_id IS NOT NULL",NULL,FALSE)->findAll(); + return $q; + } + public function tareas_encuadernacion(): array + { + $q = $this->otTarea->where("presupuesto_encuadernado_id IS NOT NULL",NULL,FALSE)->findAll(); + return $q; + } + public function tareas_preimpresion(): array + { + $q = $this->otTarea->where("presupuesto_preimpresion_id IS NOT NULL",NULL,FALSE)->findAll(); + return $q; + } + public function tareas_manipulado(): array + { + $q = $this->otTarea->where("presupuesto_manipulado_id IS NOT NULL",NULL,FALSE)->findAll(); + return $q; + } + /**======================================================================== + * UPDATES + *========================================================================**/ + + public function updateOrdenTrabajoTarea($tarea_id,$data) : bool + { + return $this->otTarea->update($tarea_id,$data); + } + + public function updateOrdenTrabajoDate($data) + { + // return $this->otDate->find($this->ot->id); + $r = $this->otDate->update($this->ot->id,$data); + $ot_users = $this->ot->users(); + $ot_users = $ot_users->toArray(); + $user_id = $ot_users[$this->MAPPING_DATE_USER[$data["name"]]]; + $user = $this->userModel->find($user_id); + return ["user" => $user,"status" => $r]; + } + + public function updateOrdenTrabajo($data) : bool + { + return $this->otModel->update($this->ot->id,$data); + } + /**======================================================================== + * RELATION METHODS + *========================================================================**/ + /** + * Obtiene el pedido asociado a esta clase + * + * @return PedidoEntity + */ + public function getPedido(): PedidoEntity + { + return $this->pedido; + } + + public function getCliente(): ClienteEntity + { + return $this->presupuesto->cliente(); + } + + + public function getPresupuesto(): PresupuestoEntity + { + return $this->presupuesto; + } + /** + * Devuelve las lineas de presupuesto con la máquina asociada a cada una + * + * @return array + */ + protected function getPresupuestoLineasWithMaquina(): array + { + $presupuesto_lineas = $this->presupuesto->presupuestoLineas(); + foreach ($presupuesto_lineas as $key => $linea) { + $linea->maquina = $linea->maquina(); + } + return $presupuesto_lineas; + } + protected function presupuesto_lineas_acabado(): array + { + return $this->presupuesto->acabados(); + } + protected function presupuesto_lineas_manipulado(): array + { + return $this->presupuesto->manipulados(); + } + protected function presupuesto_lineas_preimpresion(): array + { + return $this->presupuesto->preimpresiones(); + } + protected function presupuesto_lineas_encuadernaciones(): array + { + return $this->presupuesto->encuadernaciones(); + } + protected function presupuesto_lineas_extras(): array + { + return $this->presupuesto->extras(); + } + protected function logistica_data() : array + { + $presupuesto_lineas = $this->presupuesto->presupuestoLineas(); + $peso = 0; + foreach ($presupuesto_lineas as $key => $linea) { + $peso += $linea->peso; + } + return [ + "peso_unidad" => $peso, + "peso_pedido" => $peso*$this->ot->total_tirada + ]; + + } + + +} diff --git a/ci4/app/Services/TarifaMaquinaService.php b/ci4/app/Services/TarifaMaquinaService.php new file mode 100644 index 00000000..2cf5fd31 --- /dev/null +++ b/ci4/app/Services/TarifaMaquinaService.php @@ -0,0 +1,58 @@ +tarifaAcabadoMaquina = model(TarifaAcabadoMaquinaModel::class); + $this->tarifaManipuladoMaquina = model(TarifaManipuladoMaquinaModel::class); + $this->tarifaEncuadernacionMaquina = model(TarifaEncuadernacionMaquinaModel::class); + $this->tarifaPreimpresionMaquina = model(TarifaPreimpresionMaquinaModel::class); + $this->tarifaExtraMaquina = model(TarifaExtraMaquinaModel::class); + + } + + public function attachAcabadoToMaquina(int $tarifa_acabado_id, int $maquina_id, int $maquina_tarea_id): bool|int|string + { + return $this->tarifaAcabadoMaquina->insert(["tarifa_acabado_id" => $tarifa_acabado_id, "maquina_id" => $maquina_id, "maquina_tarea_id" => $maquina_tarea_id]); + } + public function attachManipuladoToMaquina(int $tarifa_manipulado_id, int $maquina_id, int $maquina_tarea_id): bool|int|string + { + return $this->tarifaManipuladoMaquina->insert(["tarifa_manipulado_id" => $tarifa_manipulado_id, "maquina_id" => $maquina_id, "maquina_tarea_id" => $maquina_tarea_id]); + } + public function attachPreimpresionToMaquina(int $tarifa_preimpresion_id, int $maquina_id, int $maquina_tarea_id): bool|int|string + { + return $this->tarifaPreimpresionMaquina->insert(["tarifa_preimpresion_id" => $tarifa_preimpresion_id, "maquina_id" => $maquina_id, "maquina_tarea_id" => $maquina_tarea_id]); + } + public function attachEncuadernacionToMaquina(int $tarifa_encuadernacion_id, int $maquina_id, int $maquina_tarea_id): bool|int|string + { + return $this->tarifaEncuadernacionMaquina->insert(["tarifa_encuadernacion_id" => $tarifa_encuadernacion_id, "maquina_id" => $maquina_id, "maquina_tarea_id" => $maquina_tarea_id]); + } + public function attachExtraToMaquina(int $tarifa_extra_id, int $maquina_id, int $maquina_tarea_id): bool|int|string + { + return $this->tarifaExtraMaquina->insert(["tarifa_extra_id" => $tarifa_extra_id, "maquina_id" => $maquina_id, "maquina_tarea_id" => $maquina_tarea_id]); + } + +} diff --git a/ci4/app/Views/themes/vuexy/components/forms/servicio_cliente.php b/ci4/app/Views/themes/vuexy/components/forms/servicio_cliente.php new file mode 100644 index 00000000..a90d9058 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/components/forms/servicio_cliente.php @@ -0,0 +1,61 @@ +
+
+ +
+ + +
+ +
+ + + +
+ +
+ + +
+ +
+ +
+ + +
+
+ +
+
Seleccione tipo de tarifa
+
+ + +
+
+
+ +
+
+ + + +
+
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/components/forms/tarifa_maquinas.php b/ci4/app/Views/themes/vuexy/components/forms/tarifa_maquinas.php new file mode 100644 index 00000000..57917575 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/components/forms/tarifa_maquinas.php @@ -0,0 +1,30 @@ +
+
+
+
+ + +
+
+ + +
+
+
+ +
+ +
+
+ + + + + + + + + + +
Acción
+
diff --git a/ci4/app/Views/themes/vuexy/components/tables/ot_table.php b/ci4/app/Views/themes/vuexy/components/tables/ot_table.php new file mode 100644 index 00000000..a611a1c4 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/components/tables/ot_table.php @@ -0,0 +1,22 @@ +
+ + + + + + + + + + + + + + + + + + + +
+
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/components/tables/ot_task_table.php b/ci4/app/Views/themes/vuexy/components/tables/ot_task_table.php new file mode 100644 index 00000000..cc9e048c --- /dev/null +++ b/ci4/app/Views/themes/vuexy/components/tables/ot_task_table.php @@ -0,0 +1,20 @@ +
+ + + + + + + + + + + + + + + + + +
+
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/components/tables/planning_papel_gramaje_table.php b/ci4/app/Views/themes/vuexy/components/tables/planning_papel_gramaje_table.php new file mode 100644 index 00000000..b6f75226 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/components/tables/planning_papel_gramaje_table.php @@ -0,0 +1,17 @@ +
+ + + + + + + + + + + + + + +
(gr)(HH:MM)
+
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/components/tables/planning_rot_table.php b/ci4/app/Views/themes/vuexy/components/tables/planning_rot_table.php new file mode 100644 index 00000000..883d34f6 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/components/tables/planning_rot_table.php @@ -0,0 +1,38 @@ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/components/tables/servicios_cliente_table.php b/ci4/app/Views/themes/vuexy/components/tables/servicios_cliente_table.php new file mode 100644 index 00000000..1631175b --- /dev/null +++ b/ci4/app/Views/themes/vuexy/components/tables/servicios_cliente_table.php @@ -0,0 +1,14 @@ + + + + + + + + + + + + + +
diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/servicios_cliente/ServicioClienteEdit.php b/ci4/app/Views/themes/vuexy/form/configuracion/servicios_cliente/ServicioClienteEdit.php new file mode 100644 index 00000000..fa36dee6 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/configuracion/servicios_cliente/ServicioClienteEdit.php @@ -0,0 +1,37 @@ +include('themes/_commonPartialsBs/select2bs5') ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> +extend('themes/vuexy/main/defaultlayout') ?> + +section('content'); ?> +
+
+ +
+
+

+
+ +
+ + + + "formServicioCliente"]); ?> + +
+ + + +
+ +
+ +
+ +endSection() ?> +section("additionalExternalJs") ?> + +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/servicios_cliente/viewServicioCliente.php b/ci4/app/Views/themes/vuexy/form/configuracion/servicios_cliente/viewServicioCliente.php new file mode 100644 index 00000000..e8cc5050 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/configuracion/servicios_cliente/viewServicioCliente.php @@ -0,0 +1,37 @@ +include('themes/_commonPartialsBs/select2bs5') ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> +extend('themes/vuexy/main/defaultlayout') ?> + +section('content'); ?> +
+
+ +
+
+

+
+ +
+ + + + "tableServiciosCliente"]); ?> + +
+ + + +
+ +
+ +
+ +endSection() ?> +section("additionalExternalJs") ?> + +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidoForm.php b/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidoForm.php index 641ad9c8..a0a9bf5f 100644 --- a/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidoForm.php +++ b/ci4/app/Views/themes/vuexy/form/pedidos/viewPedidoForm.php @@ -19,15 +19,26 @@ user()->inGroup('cliente-admin') || auth()->user()->inGroup('cliente-editor'))) : ?> - + - $pedidoEntity->id,"type" => "pedido"]) ?> + $pedidoEntity->id, "type" => "pedido"]) ?> -
- "btn btn-secondary float-start"]) ?> -
+ +
+
+
+ "btn btn-secondary float-start"]) ?> +
+ estado == 'finalizado') : ?> +
+ +
+ + +
+
@@ -43,9 +54,13 @@ "> + + endSection() ?> section('additionalExternalJs') ?> + + diff --git a/ci4/app/Views/themes/vuexy/form/produccion/ot/otComments.php b/ci4/app/Views/themes/vuexy/form/produccion/ot/otComments.php new file mode 100644 index 00000000..222d64f9 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/produccion/ot/otComments.php @@ -0,0 +1,6 @@ + +
+ + + +
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/produccion/ot/otCosts.php b/ci4/app/Views/themes/vuexy/form/produccion/ot/otCosts.php new file mode 100644 index 00000000..c6d7826b --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/produccion/ot/otCosts.php @@ -0,0 +1,18 @@ +
+
+

+ +

+ +
+
+
+ +
+
+
+
+
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/produccion/ot/otDates.php b/ci4/app/Views/themes/vuexy/form/produccion/ot/otDates.php new file mode 100644 index 00000000..26d44620 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/produccion/ot/otDates.php @@ -0,0 +1,79 @@ +
+
+

+ +

+ +
+
+
+ +
+ + +
+ + +
+ + + +
+ + +
+ + +
+ + +
+ + +
+ +
+
+ + + + +
+ +
+ + +
+ + +
+
+
+
+
+
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/produccion/ot/otDetails.php b/ci4/app/Views/themes/vuexy/form/produccion/ot/otDetails.php new file mode 100644 index 00000000..3c2279e5 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/produccion/ot/otDetails.php @@ -0,0 +1,42 @@ +
+
+

+ +

+ +
+
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+
+
+
+
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/produccion/ot/otFerrosEnvios.php b/ci4/app/Views/themes/vuexy/form/produccion/ot/otFerrosEnvios.php new file mode 100644 index 00000000..4a38ec45 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/produccion/ot/otFerrosEnvios.php @@ -0,0 +1,77 @@ +
+
+ +

Indica si tiene ferro y las horas de entrega del mismo. Se le enviará un mensaje a comercial asociado indicando cuando estará disponible el ferro.

+
+
+
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+
+ +
+
+ +
+
+
+ +

Introduce el número de seguimiento de envío. Se le enviará un mensaje al cliente asociado indicando el envío y el tracking.

+
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ +
+
+ +
+
+ +
+
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/produccion/ot/otPortada.php b/ci4/app/Views/themes/vuexy/form/produccion/ot/otPortada.php new file mode 100644 index 00000000..508202ff --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/produccion/ot/otPortada.php @@ -0,0 +1,22 @@ +
+
+

+ +

+ +
+
+
+ + +
+
+ +
+
+
+
+
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/produccion/ot/otPreimpresionReview.php b/ci4/app/Views/themes/vuexy/form/produccion/ot/otPreimpresionReview.php new file mode 100644 index 00000000..bc0093b6 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/produccion/ot/otPreimpresionReview.php @@ -0,0 +1,121 @@ +
+
Revisión
+
+ + + +
+ +
+ +
+
 
+
+ + + +
+
+
+
 
+
+ +
+
+
+
+
+ +

Enviar un mensaje al comercial indicando que faltan materiales. + La orden se marcará y aparecerá en el listado: OTs pendientes de material

+
+
+
+ + +
+
+ +
+
+ +
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/produccion/ot/otProgress.php b/ci4/app/Views/themes/vuexy/form/produccion/ot/otProgress.php new file mode 100644 index 00000000..1cbcb577 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/produccion/ot/otProgress.php @@ -0,0 +1,95 @@ +
+
+

+ +

+ +
+
+
+
+ +
+
+
+
+
+
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+
+
+

:

+
+
+

:

+
+
+
+
+
+ +
+
+
+
+
+
+
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/produccion/ot/otTask.php b/ci4/app/Views/themes/vuexy/form/produccion/ot/otTask.php new file mode 100644 index 00000000..113178d8 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/produccion/ot/otTask.php @@ -0,0 +1,72 @@ +
+
+

+ +

+ +
+
+
+
+ +
+ +
+
+ + + + + + + + +
+
+
+
+
+
+
\ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/produccion/ot/viewPlanningRotativa.php b/ci4/app/Views/themes/vuexy/form/produccion/ot/viewPlanningRotativa.php new file mode 100644 index 00000000..44177691 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/produccion/ot/viewPlanningRotativa.php @@ -0,0 +1,45 @@ +include('themes/_commonPartialsBs/select2bs5') ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/sweetalert') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> +extend('themes/vuexy/main/defaultlayout') ?> + + +section('content'); ?> + +
+
+ +
+ +
+endSection() ?> + +section('css') ?> + +endSection() ?> + +section("additionalExternalJs") ?> + + + + +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/produccion/viewOrdenTrabajoEdit.php b/ci4/app/Views/themes/vuexy/form/produccion/viewOrdenTrabajoEdit.php new file mode 100644 index 00000000..59191045 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/form/produccion/viewOrdenTrabajoEdit.php @@ -0,0 +1,156 @@ +include('themes/_commonPartialsBs/select2bs5') ?> +include('themes/_commonPartialsBs/datatables') ?> +include('themes/_commonPartialsBs/sweetalert') ?> +include('themes/_commonPartialsBs/_confirm2delete') ?> +extend('themes/vuexy/main/defaultlayout') ?> +section('content'); ?> +
+
+
+
+
+
+
+
+
+
+ + +
+
+ + +
+ +
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
+ "> + + + +
+
+
+
+ + + \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php b/ci4/app/Views/themes/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php index 022b3896..cb6651ef 100644 --- a/ci4/app/Views/themes/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php +++ b/ci4/app/Views/themes/vuexy/form/tarifas/acabado/viewTarifaAcabadoForm.php @@ -51,7 +51,7 @@ - + @@ -62,11 +62,27 @@ - +
+
+

+ +

+
+
+ "tarifa_maquina_component","tarifaId" => $tarifaacabadoEntity->id ]) ?> +
+
+
+
endSection() ?> +section("additionalExternalJs") ?> + +endSection() ?> section("additionalInlineJs") ?> const lastColNr = $('#tableOfTarifasacabado').find("tr:first th").length - 1; diff --git a/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php b/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php index 31a06d68..2d3eb35b 100644 --- a/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php +++ b/ci4/app/Views/themes/vuexy/form/tarifas/encuadernacion/viewTarifaEncuadernacionForm.php @@ -124,14 +124,29 @@ - +
+
+

+ +

+
+
+ "tarifa_maquina_component","tarifaId" => $tarifaEncuadernacionEntity->id ]) ?> +
+
+
+
endSection() ?> - +section("additionalExternalJs") ?> + +endSection() ?> diff --git a/ci4/app/Views/themes/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php b/ci4/app/Views/themes/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php index c7dc35c9..3603cdca 100644 --- a/ci4/app/Views/themes/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php +++ b/ci4/app/Views/themes/vuexy/form/tarifas/manipulado/viewTarifaManipuladoForm.php @@ -62,8 +62,25 @@ +
+
+

+ +

+
+
+ "tarifa_maquina_component","tarifaId" => $tarifaManipuladoEntity->id ]) ?> +
+
+
+
endSection() ?> +section("additionalExternalJs") ?> + +endSection() ?> section("additionalInlineJs") ?> diff --git a/ci4/app/Views/themes/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionForm.php b/ci4/app/Views/themes/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionForm.php index c76aeffd..ff1ac32a 100644 --- a/ci4/app/Views/themes/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionForm.php +++ b/ci4/app/Views/themes/vuexy/form/tarifas/preimpresion/viewTarifapreimpresionForm.php @@ -15,11 +15,10 @@
" - /> + type="submit" + class="btn btn-primary float-start me-sm-3 me-1" + name="save" + value="" /> "btn btn-secondary"]) ?>
@@ -27,4 +26,21 @@ +
+
+

+ +

+
+
+ "tarifa_maquina_component", "tarifaId" => $tarifapreimpresionEntity->id]) ?> +
+
+
+
endSection() ?> +section("additionalExternalJs") ?> + +endSection() ?> \ No newline at end of file diff --git a/ci4/app/Views/themes/vuexy/main/defaultlayout.php b/ci4/app/Views/themes/vuexy/main/defaultlayout.php index c2cccd59..0efeba1a 100644 --- a/ci4/app/Views/themes/vuexy/main/defaultlayout.php +++ b/ci4/app/Views/themes/vuexy/main/defaultlayout.php @@ -69,6 +69,7 @@ $picture = "/assets/img/default-user.png"; + @@ -80,6 +81,7 @@ $picture = "/assets/img/default-user.png"; + @@ -343,9 +345,11 @@ $picture = "/assets/img/default-user.png"; + + diff --git a/ci4/app/Views/themes/vuexy/main/menus/configuracion_menu.php b/ci4/app/Views/themes/vuexy/main/menus/configuracion_menu.php index 2b556ebd..b362bc6a 100644 --- a/ci4/app/Views/themes/vuexy/main/menus/configuracion_menu.php +++ b/ci4/app/Views/themes/vuexy/main/menus/configuracion_menu.php @@ -99,6 +99,13 @@ if ( user()->inGroup('admin') || auth()->user()->inGroup('beta')) { ?> + + + user()->inGroup('admin') || auth()->user()->inGroup('beta')) { ?> - diff --git a/ci4/app/Views/themes/vuexy/pdfs/orden_trabajo.php b/ci4/app/Views/themes/vuexy/pdfs/orden_trabajo.php new file mode 100644 index 00000000..51cc37f0 --- /dev/null +++ b/ci4/app/Views/themes/vuexy/pdfs/orden_trabajo.php @@ -0,0 +1,322 @@ + + + + + + + + + Rotativa + + + +
+
+
titulo ?>
+
format("d/m/Y H:i:s") ?>
+
+
+
+
+ portada_path)) ?>"> +
+
+
+

fecha_encuadernado_at ? week_day_humanize(Time::createFromFormat("Y-m-d", $dates->fecha_encuadernado_at)->getDayOfWeek(),true) : "" ?>

+
Comercial: first_name . " " . $cliente->comercial()->last_name ?>
+ +
+
+
+

fecha_encuadernado_at ? Time::createFromFormat("Y-m-d", $dates->fecha_encuadernado_at)?->format("d/m/Y") : "" ?>

+ +
+ + + + + + + + + + + + + + + + + + + + + +
IN
PO
PL
EN
MA
+
+
+
+
+ + + + +
RF
+
+
+
+
+ BCLF 100 +
+
+ 0:3 +
+
+ EM 300 +
+
+ BRILLO +
+
+
+
+

id ?>

+
+
+
+
+
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + +
Cliente +

nombre ?>

+
Titulo +

titulo ?>

+
ISBNisbn ?>
CIFcif ?>
+ +
+
+
+
+
+ A +
+
+
+
+ A +
+
+
+
+ A +
+
+
+
+ A +
+
+
+
+ + + + + +
Imposicion400x400
+
+
+ + +
+
+ +
+
IMP. INTERIOR
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
PáginasEjemplaresTintasFormasMáquinaClicsTiempo
paginas ?>tirada ?>??formas)->formas ?>maquina()->nombre ?>rotativa_clicks_total ?>horas_maquina * 3600) ?>
papel_impresion ?>papel_impresion()->gramaje . " " . "gr" ?>_________ metros
+
+
Comentarios impresión interior
+
+

+

+
+

+

+
+
+
+ +
+
IMP. CUBIERTA
+ + + + + + + + + + + + + + + + + + + + + + + +
TintasEjemplaresMaquinaMarcapaginasTiempo
??tirada ?>maquina()->nombre ?>marcapaginas ? "SI" : "NO" ?>horas_maquina * 3600) ?>
formas)->maquina_ancho ?>xformas)->maquina_alto ?>ancho ?>xalto ?>papel_impresion ?>papel_impresion()->gramaje . " " . "gr" ?>
+
+
Comentarios cubierta
+
+

+

+
+
+
+
+
ENCUADERNACIÓN
+ + + + + + + +
Plastificadotarifa()->nombre ?>UVI ??
+ + + + + +
MAQUINA ??
+ + + + + +
OPERARIO ??
+ 0): ?> + + + + + + + + + + + $value): ?> + + + + + + + + + + +
EncuadernacionSolapasSobrecubiertaPlegadoGuardasRetractiladoMarcapáginas
tarifa()->nombre ?>solapas ? "SI" : "NO" ?>hasSobrecubierta() ? "SI" : "NO" ?> ______ pliegos de ______ guardas ? "SI" : "NO" ?>retractilado ? "SI" : "NO" ?>marcapaginas ? "SI" : "NO" ?>
+
+
Comentarios encuadernacion:
+
+

+

+
+
+ +
+ +
+
LOGISTICA
+ + + + + + + + + + + + + +
Peso UnidadPeso PedidoCajasCorte Pie
grgr--
+
+
Comentarios logistica:
+
+

+

+
+
+
+ + +
+ + + \ No newline at end of file diff --git a/ci4/composer.json b/ci4/composer.json index fae7031e..55142a7f 100755 --- a/ci4/composer.json +++ b/ci4/composer.json @@ -13,7 +13,7 @@ "php": "^8.2", "codeigniter4/framework": "^4.0", "codeigniter4/shield": "^1.0", - "dompdf/dompdf": "^2.0", + "dompdf/dompdf": "^3.0", "firebase/php-jwt": "^6.10", "hermawan/codeigniter4-datatables": "^0.7.2", "nicolab/php-ftp-client": "^2.0", diff --git a/ci4/composer.lock b/ci4/composer.lock index 1ba99102..fd1ad0f9 100644 --- a/ci4/composer.lock +++ b/ci4/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c0e2ec73d12ca7372057585d362765f7", + "content-hash": "939889ce4de6a8168b475984ff4401bd", "packages": [ { "name": "codeigniter4/framework", @@ -211,32 +211,34 @@ }, { "name": "dompdf/dompdf", - "version": "v2.0.8", + "version": "v3.0.1", "source": { "type": "git", "url": "https://github.com/dompdf/dompdf.git", - "reference": "c20247574601700e1f7c8dab39310fca1964dc52" + "reference": "2d622faf9aa1f8f7f24dd094e49b5cf6c0c5d4e6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/dompdf/dompdf/zipball/c20247574601700e1f7c8dab39310fca1964dc52", - "reference": "c20247574601700e1f7c8dab39310fca1964dc52", + "url": "https://api.github.com/repos/dompdf/dompdf/zipball/2d622faf9aa1f8f7f24dd094e49b5cf6c0c5d4e6", + "reference": "2d622faf9aa1f8f7f24dd094e49b5cf6c0c5d4e6", "shasum": "" }, "require": { + "dompdf/php-font-lib": "^1.0.0", + "dompdf/php-svg-lib": "^1.0.0", "ext-dom": "*", "ext-mbstring": "*", "masterminds/html5": "^2.0", - "phenx/php-font-lib": ">=0.5.4 <1.0.0", - "phenx/php-svg-lib": ">=0.5.2 <1.0.0", "php": "^7.1 || ^8.0" }, "require-dev": { + "ext-gd": "*", "ext-json": "*", "ext-zip": "*", "mockery/mockery": "^1.3", - "phpunit/phpunit": "^7.5 || ^8 || ^9", - "squizlabs/php_codesniffer": "^3.5" + "phpunit/phpunit": "^7.5 || ^8 || ^9 || ^10", + "squizlabs/php_codesniffer": "^3.5", + "symfony/process": "^4.4 || ^5.4 || ^6.2 || ^7.0" }, "suggest": { "ext-gd": "Needed to process images", @@ -267,9 +269,100 @@ "homepage": "https://github.com/dompdf/dompdf", "support": { "issues": "https://github.com/dompdf/dompdf/issues", - "source": "https://github.com/dompdf/dompdf/tree/v2.0.8" + "source": "https://github.com/dompdf/dompdf/tree/v3.0.1" }, - "time": "2024-04-29T13:06:17+00:00" + "time": "2024-12-05T14:59:38+00:00" + }, + { + "name": "dompdf/php-font-lib", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/dompdf/php-font-lib.git", + "reference": "6137b7d4232b7f16c882c75e4ca3991dbcf6fe2d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dompdf/php-font-lib/zipball/6137b7d4232b7f16c882c75e4ca3991dbcf6fe2d", + "reference": "6137b7d4232b7f16c882c75e4ca3991dbcf6fe2d", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "symfony/phpunit-bridge": "^3 || ^4 || ^5 || ^6" + }, + "type": "library", + "autoload": { + "psr-4": { + "FontLib\\": "src/FontLib" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-2.1-or-later" + ], + "authors": [ + { + "name": "The FontLib Community", + "homepage": "https://github.com/dompdf/php-font-lib/blob/master/AUTHORS.md" + } + ], + "description": "A library to read, parse, export and make subsets of different types of font files.", + "homepage": "https://github.com/dompdf/php-font-lib", + "support": { + "issues": "https://github.com/dompdf/php-font-lib/issues", + "source": "https://github.com/dompdf/php-font-lib/tree/1.0.1" + }, + "time": "2024-12-02T14:37:59+00:00" + }, + { + "name": "dompdf/php-svg-lib", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/dompdf/php-svg-lib.git", + "reference": "eb045e518185298eb6ff8d80d0d0c6b17aecd9af" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dompdf/php-svg-lib/zipball/eb045e518185298eb6ff8d80d0d0c6b17aecd9af", + "reference": "eb045e518185298eb6ff8d80d0d0c6b17aecd9af", + "shasum": "" + }, + "require": { + "ext-mbstring": "*", + "php": "^7.1 || ^8.0", + "sabberworm/php-css-parser": "^8.4" + }, + "require-dev": { + "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "Svg\\": "src/Svg" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "LGPL-3.0-or-later" + ], + "authors": [ + { + "name": "The SvgLib Community", + "homepage": "https://github.com/dompdf/php-svg-lib/blob/master/AUTHORS.md" + } + ], + "description": "A library to read, parse and export to PDF SVG files.", + "homepage": "https://github.com/dompdf/php-svg-lib", + "support": { + "issues": "https://github.com/dompdf/php-svg-lib/issues", + "source": "https://github.com/dompdf/php-svg-lib/tree/1.0.0" + }, + "time": "2024-04-29T13:26:35+00:00" }, { "name": "firebase/php-jwt", @@ -734,96 +827,6 @@ }, "time": "2020-10-15T08:29:30+00:00" }, - { - "name": "phenx/php-font-lib", - "version": "0.5.6", - "source": { - "type": "git", - "url": "https://github.com/dompdf/php-font-lib.git", - "reference": "a1681e9793040740a405ac5b189275059e2a9863" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/dompdf/php-font-lib/zipball/a1681e9793040740a405ac5b189275059e2a9863", - "reference": "a1681e9793040740a405ac5b189275059e2a9863", - "shasum": "" - }, - "require": { - "ext-mbstring": "*" - }, - "require-dev": { - "symfony/phpunit-bridge": "^3 || ^4 || ^5 || ^6" - }, - "type": "library", - "autoload": { - "psr-4": { - "FontLib\\": "src/FontLib" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-2.1-or-later" - ], - "authors": [ - { - "name": "Fabien Ménager", - "email": "fabien.menager@gmail.com" - } - ], - "description": "A library to read, parse, export and make subsets of different types of font files.", - "homepage": "https://github.com/PhenX/php-font-lib", - "support": { - "issues": "https://github.com/dompdf/php-font-lib/issues", - "source": "https://github.com/dompdf/php-font-lib/tree/0.5.6" - }, - "time": "2024-01-29T14:45:26+00:00" - }, - { - "name": "phenx/php-svg-lib", - "version": "0.5.4", - "source": { - "type": "git", - "url": "https://github.com/dompdf/php-svg-lib.git", - "reference": "46b25da81613a9cf43c83b2a8c2c1bdab27df691" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/dompdf/php-svg-lib/zipball/46b25da81613a9cf43c83b2a8c2c1bdab27df691", - "reference": "46b25da81613a9cf43c83b2a8c2c1bdab27df691", - "shasum": "" - }, - "require": { - "ext-mbstring": "*", - "php": "^7.1 || ^8.0", - "sabberworm/php-css-parser": "^8.4" - }, - "require-dev": { - "phpunit/phpunit": "^7.5 || ^8.5 || ^9.5" - }, - "type": "library", - "autoload": { - "psr-4": { - "Svg\\": "src/Svg" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL-3.0-or-later" - ], - "authors": [ - { - "name": "Fabien Ménager", - "email": "fabien.menager@gmail.com" - } - ], - "description": "A library to read, parse and export to PDF SVG files.", - "homepage": "https://github.com/PhenX/php-svg-lib", - "support": { - "issues": "https://github.com/dompdf/php-svg-lib/issues", - "source": "https://github.com/dompdf/php-svg-lib/tree/0.5.4" - }, - "time": "2024-04-08T12:52:34+00:00" - }, { "name": "phpseclib/phpseclib", "version": "3.0.42", @@ -3037,5 +3040,5 @@ "php": "^8.2" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.6.0" } diff --git a/httpdocs/assets/js/safekat/components/alerts/sweetAlert.js b/httpdocs/assets/js/safekat/components/alerts/sweetAlert.js new file mode 100644 index 00000000..108b7b3f --- /dev/null +++ b/httpdocs/assets/js/safekat/components/alerts/sweetAlert.js @@ -0,0 +1,20 @@ + + + +export const alertConfirmationDelete = (title,type="primary") => { + return Swal.fire({ + title: '¿Estás seguro?', + text: "Esta acción es irreversible.", + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#d33', + confirmButtonText: 'Sí', + cancelButtonText: 'Cancelar', + customClass: { + confirmButton: 'btn btn-danger me-1', + cancelButton: 'btn btn-label-secondary' + }, + buttonsStyling: false + }) +} diff --git a/httpdocs/assets/js/safekat/components/datatables/ServicioClienteDatatable.js b/httpdocs/assets/js/safekat/components/datatables/ServicioClienteDatatable.js new file mode 100644 index 00000000..efb2e7af --- /dev/null +++ b/httpdocs/assets/js/safekat/components/datatables/ServicioClienteDatatable.js @@ -0,0 +1,44 @@ + +class ServicioClienteDatatable { + constructor(domItem) { + this.datatableItem = domItem + + this.datatableColumns = [ + { data: 'nombre', searchable: true, sortable: true }, + { data: 'code', searchable: true, sortable: true }, + { data: 'created_at', searchable: true, sortable: true }, + { + data: 'action', searchable: false, sortable: false, + render: (d, t) => { + return `
+ +
` + } + } + ] + + + + } + init() { + this.datatable = this.datatableItem.DataTable({ + processing: true, + layout: { + topStart: 'pageLength', + topEnd: 'search', + bottomStart: 'info', + bottomEnd: 'paging' + }, + serverSide: true, + pageLength: 25, + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + columns: this.datatableColumns, + ajax: '/configuracion/servicios/datatable' + }); + } + +} + +export default ServicioClienteDatatable; \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/components/datatables/otDatatable.js b/httpdocs/assets/js/safekat/components/datatables/otDatatable.js new file mode 100644 index 00000000..49ecb2d0 --- /dev/null +++ b/httpdocs/assets/js/safekat/components/datatables/otDatatable.js @@ -0,0 +1,125 @@ + +class OrdenTrabajoDatatable { + constructor(domItem) { + this.item = domItem + this.datatableItem = this.item.find("#ot-datatable-finalizados") + this.datatablePendientesItem = this.item.find("#ot-datatable-pendientes") + this.datatableFerroPendienteItem = this.item.find("#ot-datatable-ferro-pendiente") + this.datatableFerroOkItem = this.item.find("#ot-datatable-ferro-ok") + + + this.datatableColumns = [ + { data: 'pedido_id', searchable: false, sortable: false }, + { data: 'fecha_encuadernado_at', searchable: false, sortable: false }, + { data: 'cliente_nombre', searchable: false, sortable: false }, + { data: 'presupuesto_titulo', searchable: false, sortable: false }, + { data: 'ubicacion_nombre', searchable: false, sortable: false }, + { data: 'total_tirada', searchable: false, sortable: false }, + { data: 'tipo_presupuesto_impresion', searchable: false, sortable: false }, + { + data: 'logo', searchable: false, sortable: false, render: (d, t) => { + return `logo-impresion` + } + }, + { + data: 'progreso', searchable: false, sortable: false, render: (d, t) => { + return `
+
${d}%
+
+ ` + } + }, + { + data: 'action', searchable: false, sortable: false, + render: (d, t) => { + return `
+ + + +
` + } + } + ] + } + init() { + this.datatable = this.datatableItem.DataTable({ + processing: true, + layout: { + topStart: 'pageLength', + topEnd: 'search', + bottomStart: 'info', + bottomEnd: 'paging' + }, + columnDefs : [ + { className: 'dt-center', targets: '_all' }, + ], + serverSide: true, + pageLength: 25, + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + columns: this.datatableColumns, + ajax: '/produccion/ordentrabajo/datatable' + }); + } + initPendientes() { + this.datatable = this.datatablePendientesItem.DataTable({ + processing: true, + layout: { + topStart: 'pageLength', + topEnd: 'search', + bottomStart: 'info', + bottomEnd: 'paging' + }, + columnDefs : [ + { className: 'dt-center', targets: '_all' }, + ], + serverSide: true, + pageLength: 25, + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + columns: this.datatableColumns, + ajax: '/produccion/ordentrabajo/datatable_pendientes' + }); + } + initFerroPendiente() { + this.datatable = this.datatableFerroPendienteItem.DataTable({ + processing: true, + layout: { + topStart: 'pageLength', + topEnd: 'search', + bottomStart: 'info', + bottomEnd: 'paging' + }, + serverSide: true, + pageLength: 25, + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + columns: this.datatableColumns, + ajax: '/produccion/ordentrabajo/datatable_ferro_pendiente' + }); + } + initFerroOk() { + this.datatable = this.datatableFerroOkItem.DataTable({ + processing: true, + layout: { + topStart: 'pageLength', + topEnd: 'search', + bottomStart: 'info', + bottomEnd: 'paging' + }, + serverSide: true, + pageLength: 25, + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + columns: this.datatableColumns, + ajax: '/produccion/ordentrabajo/datatable_ferro_ok' + }); + } + +} + +export default OrdenTrabajoDatatable; \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/components/datepicker.js b/httpdocs/assets/js/safekat/components/datepicker.js new file mode 100644 index 00000000..b5ef5800 --- /dev/null +++ b/httpdocs/assets/js/safekat/components/datepicker.js @@ -0,0 +1,28 @@ + +import { Spanish } from "../../../../themes/vuexy/vendor/libs/flatpickr/es.js" + +class DatePicker { + constructor(domItem, options) { + this.item = domItem + this.options = options + this.itemDate = null; + this.init() + } + init() { + this.itemDate = this.item.flatpickr({ ...this.options, locale: Spanish }) + + } + setDateFormat(dateFormat = "dd/mm/yy") { + this.item.flatpickr("option", "dateFormat", dateFormat) + } + getDate() { + return this.itemDate.getDate() + } + setDate(date) { + if(!isNaN(new Date(date))){ + this.itemDate.setDate(date,true,this.options.dateFormat) + } + } +} + +export default DatePicker; \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/components/forms/formClass.js b/httpdocs/assets/js/safekat/components/forms/formClass.js new file mode 100644 index 00000000..2da9cace --- /dev/null +++ b/httpdocs/assets/js/safekat/components/forms/formClass.js @@ -0,0 +1,30 @@ + + + +class FormClass +{ + constructor(domItem) { + this.item = domItem + this.formData = null + } + + validateField() + { + + } + setAsValid(field) + { + } + setAsInvalid(field){} + addSuccessFeedback(field){} + addErrorFeedback(field){} + getFormData() { + let data = {} + this.item.serializeArray().forEach((e) => { + data[e.name] = e.value + } + ) + this.formData = data + return this.formData + } +} \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/components/forms/servicioClienteForm.js b/httpdocs/assets/js/safekat/components/forms/servicioClienteForm.js new file mode 100644 index 00000000..00cf3c46 --- /dev/null +++ b/httpdocs/assets/js/safekat/components/forms/servicioClienteForm.js @@ -0,0 +1,125 @@ +import Ajax from '../ajax.js' +import ClassSelect from '../select2.js' + +class ServicioClienteForm { + /** + * + * @param {*} domItem jQuery item of the form html element + */ + constructor(domItem) { + this.item = domItem + this.btnNew = this.item.find("#btn-new-servicio-cliente") + this.btnUpdate = this.item.find("#btn-update-servicio-cliente") + this.selectItemTarifaAcabado = this.item.find("#servicio-cliente-tarifa-acabado") + this.selectItemTarifaManipulado = this.item.find("#servicio-cliente-tarifa-manipulado") + this.selectTarifaAcabado = new ClassSelect(this.selectItemTarifaAcabado, '/tarifas/acabados/select', "Seleccione una tarifa", true) + this.selectTarifaManipulado = new ClassSelect(this.selectItemTarifaManipulado, '/tarifasmanipulado/select', "Seleccione una tarifa", true) + this.checkTarifaAcabado = this.item.find("#check-tarifa-acabado") + this.checkTarifaManipulado = this.item.find("#check-tarifa-manipulado") + + + } + init() { + this.modelId = this.item.data('id') + this.uri = `/configuracion/servicios/${this.modelId}` + this.uriUpdate = `/configuracion/servicios/update/${this.modelId}` + this.uriPost = `/configuracion/servicios` + this.btnNew.on("click", this.handlePost.bind(this)) + this.btnUpdate.on("click", this.handlePut.bind(this)) + this.handleGet() + this.selectTarifaAcabado.init() + this.selectTarifaManipulado.init() + this.btnUpdate.removeClass("d-none") + this.checkTarifaAcabado.change(() => { + console.log("Acabado", this.checkTarifaAcabado.is(":checked")) + if (this.checkTarifaAcabado.is(":checked")) { + this.item.find("#container-tarifa-acabado-select").removeClass("d-none") + this.item.find("#container-tarifa-manipulado-select").addClass("d-none") + } else { + this.item.find("#container-tarifa-acabado-select").addClass("d-none") + this.item.find("#container-tarifa-manipulado-select").removeClass("d-none") + } + }) + this.checkTarifaManipulado.change(() => { + console.log("Manipulado", this.checkTarifaManipulado.is(":checked")) + if (this.checkTarifaManipulado.is(":checked")) { + this.item.find("#container-tarifa-acabado-select").addClass("d-none") + this.item.find("#container-tarifa-manipulado-select").removeClass("d-none") + } else { + this.item.find("#container-tarifa-acabado-select").removeClass("d-none") + this.item.find("#container-tarifa-manipulado-select").addClass("d-none") + } + }) + } + handleGet() { + const ajax = new Ajax( + this.uri, + null, + null, + this.handleGetSuccess.bind(this), + this.handleGetError.bind(this) + ) + ajax.get() + } + handleGetSuccess(data) { + this.item.find('[name="nombre"]').val(data.nombre) + this.item.find('[name="code"]').val(data.code) + if(data?.tarifas_acabado){ + this.selectTarifaAcabado.setOption(data.tarifas_acabado.id,data.tarifas_acabado.nombre) + this.checkTarifaAcabado.prop("checked",true) + this.checkTarifaAcabado.trigger("change") + this.selectTarifaManipulado.reset() + } + if(data?.tarifas_manipulado){ + this.checkTarifaManipulado.prop("checked",true) + this.selectTarifaManipulado.setOption(data.tarifas_manipulado.id,data.tarifas_manipulado.nombre) + this.checkTarifaManipulado.trigger("change") + this.selectTarifaAcabado.reset() + } + + } + handleGetError(e) { + console.error(e) + } + handlePost() { + let bodyData = this.getFormData() + const ajax = new Ajax( + this.uriPost, + bodyData, + null, + this.handlePostSuccess.bind(this), + this.handlePostError.bind(this) + ) + ajax.post() + } + handlePostSuccess() { + this.item.reset() + } + handlePostError() { } + handlePut() { + let bodyData = this.getFormData() + const ajax = new Ajax( + this.uriUpdate, + bodyData, + null, + this.handlePutSuccess.bind(this), + this.handlePutError.bind(this) + ) + ajax.post() + } + handlePutSuccess(data) { + // this.item.reset() + this.handleGet(data) + } + handlePutError() { } + + getFormData() { + let data = {} + this.item.serializeArray().forEach((e) => { + data[e.name] = e.value + } + ) + return data + } +} +export default ServicioClienteForm \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/configuracion/servicio_cliente/edit.js b/httpdocs/assets/js/safekat/pages/configuracion/servicio_cliente/edit.js new file mode 100644 index 00000000..5bc6d4b2 --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/configuracion/servicio_cliente/edit.js @@ -0,0 +1,6 @@ +import ServicioClienteForm from '../../../components/forms/servicioClienteForm.js' + +$(document).ready(() => { + const formServicioCliente = new ServicioClienteForm($("#formServicioCliente")) + formServicioCliente.init() +}) diff --git a/httpdocs/assets/js/safekat/pages/configuracion/servicio_cliente/index.js b/httpdocs/assets/js/safekat/pages/configuracion/servicio_cliente/index.js new file mode 100644 index 00000000..5ee98e58 --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/configuracion/servicio_cliente/index.js @@ -0,0 +1,4 @@ +import ServicioClienteDatatable from '../../../components/datatables/ServicioClienteDatatable.js' + +const servicioClienteDatatable = new ServicioClienteDatatable($("#tableServiciosCliente")) +servicioClienteDatatable.init() diff --git a/httpdocs/assets/js/safekat/pages/produccion/edit.js b/httpdocs/assets/js/safekat/pages/produccion/edit.js new file mode 100644 index 00000000..7b232a4a --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/produccion/edit.js @@ -0,0 +1,7 @@ + +import OrdenTrabajo from "./ot.js"; + +$(function() { + const ot = new OrdenTrabajo($("#ot-edit")) + ot.init() +}) \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/produccion/index.js b/httpdocs/assets/js/safekat/pages/produccion/index.js new file mode 100644 index 00000000..acf97f71 --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/produccion/index.js @@ -0,0 +1,9 @@ +import OrdenTrabajoDatatable from '../../components/datatables/otDatatable.js' + +$(function() { + const otDatatable = new OrdenTrabajoDatatable($("#ots-datatables-container")) + otDatatable.init() + otDatatable.initPendientes() + otDatatable.initFerroPendiente() + otDatatable.initFerroOk() +}) \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/produccion/ot.js b/httpdocs/assets/js/safekat/pages/produccion/ot.js new file mode 100644 index 00000000..616b8a4e --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/produccion/ot.js @@ -0,0 +1,471 @@ +import Ajax from "../../components/ajax.js" +import ClassSelect from "../../components/select2.js"; +import DatePicker from "../../components/datepicker.js"; +import { alertConfirmationDelete } from "../../components/alerts/sweetAlert.js"; +import Modal from "../../components/modal.js" + +class OrdenTrabajo { + constructor(domItem) { + this.item = domItem + this.otForm = this.item.find("#ot-edit-form") + this.modelId = this.item.data("id"); + this.tareasTableItem = this.item.find("#ot-task-table"); + this.tareasId = [] + this.summaryData = {} + this.tareaCommentModal = new Modal($("#modalCommentTarea")) + this.alertOrdenTrabajo = this.item.find("#alert-orden-trabajo"); + this.btnFinalizarPedido = this.item.find("#btn-finalizar-orden-pedido") + this.btnResetTareas = this.item.find("#btn-reset-tareas") + this.datatableColumns = [ + { data: 'orden', searchable: true, sortable: true, render: this._renderOrdenTarea.bind(this), width: "10%" }, + { data: 'nombre', searchable: true, sortable: true, width: "20%" }, + { data: 'maquina_presupuesto_linea', searchable: true, sortable: true, width: "20%" }, + { data: 'maquina_tarea', searchable: false, sortable: false, render: this._renderMaquinaSelectTable.bind(this), width: "20%" }, + // { data: 'imposicion_id', searchable: false, sortable: false }, + { data: 'tiempo_estimado', searchable: false, sortable: false }, + { data: 'tiempo_real', searchable: false, sortable: false }, + { + data: 'action', searchable: false, sortable: false, width: "10%", render: this._renderActionCell.bind(this) + }, + ] + + + + + } + configDatePickers() { + const option = { + altInput: true, + altFormat: "d/m/Y", + dateFormat: "Y-m-d", + allowInput: true, + } + this.tiempoProcesamiento = new DatePicker(this.otForm.find("#ot-tiempo-procesamiento"), { + dateFormat: "H:i", + enableTime: true, + noCalendar: true, + time_24hr: true, + allowInput: true, + }) + this.fechaImpresion = new DatePicker(this.otForm.find("#ot-fecha-impresion"), option) + this.fechaEncuadernado = new DatePicker(this.otForm.find("#ot-fecha-encuadernado"), option) + this.fechaEntregaExterno = new DatePicker(this.otForm.find("#ot-fecha-entrega-externo"), option) + this.fechaEntregaReal = new DatePicker(this.otForm.find("#ot-fecha-entrega-real"), option) + this.fechaEntregaEstimada = new DatePicker(this.otForm.find("#ot-fecha-entrega-estimada"), option) + + this.pendienteFerro = new DatePicker(this.otForm.find("#ot-pendiente-ferro"), option) + this.ferroCliente = new DatePicker(this.otForm.find("#ot-ferro-cliente"), option) + this.ferroOk = new DatePicker(this.otForm.find("#ot-ferro-ok"), option) + this.plakeneTraslucido = new DatePicker(this.otForm.find("#ot-plakene-traslucido"), option) + this.impresionColor = new DatePicker(this.otForm.find("#ot-impresion-color"), option) + this.portada = new DatePicker(this.otForm.find("#ot-portada"), option) + this.plastificadoMate = new DatePicker(this.otForm.find("#ot-plastificado-mate"), option) + this.prepGuillotina = new DatePicker(this.otForm.find("#ot-prep-guillotina"), option) + this.espiral = new DatePicker(this.otForm.find("#ot-espiral"), option) + this.embalaje = new DatePicker(this.otForm.find("#ot-embalaje"), option) + this.envio = new DatePicker(this.otForm.find("#ot-envio"), option) + + + } + eventTareas() { + this.otForm.on("change", ".select-maquina-tarea-datatable", this.handleTareaChange.bind(this)) + this.otForm.on("change", ".orden-tarea", this.handleTareaChange.bind(this)) + this.otForm.on("click", ".increase-order", (event) => { + const input_orden_tarea = $(event.currentTarget).parent().parent().find('.orden-tarea') + let actual_value = parseInt(input_orden_tarea.val()) + input_orden_tarea.val(actual_value + 1).trigger("change") + }) + this.otForm.on("click", ".decrease-order", (event) => { + const input_orden_tarea = $(event.currentTarget).parent().parent().find('.orden-tarea') + let actual_value = parseInt(input_orden_tarea.val()) + if (actual_value > 0) { + input_orden_tarea.val(actual_value - 1).trigger("change") + } + }) + } + unbindEventTareas() { + this.otForm.off("change", ".select-maquina-tarea-datatable") + this.otForm.off("change", ".orden-tarea") + this.otForm.off("click", ".increase-order") + this.otForm.off("click", ".decrease-order") + } + init() { + this.configDatePickers() + this.initDatatableTareas() + this.tareasTableItem.on("draw.dt", this.createSelectMaquinaTarea.bind(this)) + this.tareasTableItem.on("xhr.dt", this.unbindEventTareas.bind(this)) + this.otForm.on("click", "#btn-upload-portada", this.handleUploadPortada.bind(this)) + this.otForm.on("click", "#btn-finalizar-orden-pedido", this.handleFinalizarPedido.bind(this)) + this.tareasTableItem.on("click", ".ot-tarea-btn-delete", this.handleTareaDeleteConfirmation.bind(this)) + this.item.on("click", "#btn-reset-tareas", this.handleResetTareasDeleteConfirmation.bind(this)) + this.otForm.on("click", ".ot-tarea-comment", this.handleNoteTarea.bind(this)) + $("#btn-update-tarea-comment").on("click", this.handleTareaNoteSubmit.bind(this)) + this.otForm.on("keyup","#ot-comment",this.handleOtComment.bind(this)) + + this._handleGetData() + this.handleGetPortada() + } + initDatatableTareas() { + this.datatableTareas = this.tareasTableItem.DataTable({ + processing: true, + paging: false, + layout: { + topStart: 'pageLength', + topEnd: 'search', + bottomStart: 'info', + bottomEnd: 'paging' + }, + serverSide: true, + responsive : true, + createdRow: this.filterCreatedRow.bind(this), + pageLength: 10, + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + columns: this.datatableColumns, + ajax: '/produccion/ordentrabajo/tareas/datatable/' + this.modelId + }); + } + getFormData() { + let data = {} + this.otForm.serializeArray().forEach((e) => { + data[e.name] = e.value + } + ) + return data + } + _handleGetData() { + const ajax = new Ajax(`/produccion/ordentrabajo/summary/${this.modelId}`, + null, + null, + this.handleSummarySuccess.bind(this), + this.handleSummaryError.bind(this) + ) + ajax.get(); + } + _renderMaquinaSelectTable(d, t) { + this.tareasId.push(d.id) + return `` + + } + _renderActionCell(d, t) { + + let cell = `
+ + +
` + return cell; + } + _renderOrdenTarea(d, t) { + + return ` +
+ +
+ + +
+
+ ` + } + createSelectMaquinaTarea() { + try { + this.tareasId.forEach(element => { + let selectItem = this.item.find("#select-maquina-tarea-" + element); + let maquina_id = selectItem.data("maquina-id") + let maquinaSelects = new ClassSelect(selectItem, `/maquinas/select`, "Seleccione una maquina", true); + maquinaSelects.init(); + if (maquina_id) { + maquinaSelects.setVal(maquina_id) + } else { + maquinaSelects.reset() + } + }); + } catch (error) { + } finally { + this.eventTareas() + + } + + } + filterCreatedRow(row, data, dataIndex, cells) { + if (data.maquina_tarea.maquina_id == null) { + } + } + + /**======================================================================== + * DETAILS + *========================================================================**/ + handleSummarySuccess(data) { + try { + this.summaryData = data + this.otForm.off("change", ".ot-date") + this.otForm.off("change", ".ot-preview") + this.fillOtDetails() + this.fillOtDates() + this.fillPreimpresionReview() + } catch (error) { + + } finally { + this.otForm.on("change", ".ot-date", this.handleDateChange.bind(this)) + this.otForm.on("change", ".ot-preview", this.handlePreimpresionReviewChange.bind(this)) + + } + + } + handleSummaryError(error) { } + fillPreimpresionReview() { + console.log(this.summaryData.ot) + this.otForm.find("[name=fecha_entrega_warning]").prop("checked", this.summaryData.ot.fecha_entrega_warning) + this.otForm.find("[name=fecha_entrega_warning_revised]").prop("checked", this.summaryData.ot.fecha_entrega_warning_revised) + this.otForm.find("[name=revisar_formato]").prop("checked", this.summaryData.ot.revisar_formato) + this.otForm.find("[name=revisar_lomo]").prop("checked", this.summaryData.ot.revisar_lomo) + this.otForm.find("[name=revisar_solapa]").prop("checked", this.summaryData.ot.revisar_solapa) + this.otForm.find("[name=revisar_isbn]").prop("checked", this.summaryData.ot.revisar_isbn) + this.otForm.find("[name=revisar_codigo_barras]").prop("checked", this.summaryData.ot.revisar_codigo_barras) + this.otForm.find("[name=realizar_imposicion]").prop("checked", this.summaryData.ot.realizar_imposicion) + this.otForm.find("[name=enviar_impresion]").prop("checked", this.summaryData.ot.enviar_impresion) + + } + fillOtDetails() { + const progreso = this.summaryData.ot.progreso + this.otForm.find("#ot-progress-bar").attr('aria-valuenow',progreso).text(progreso + "%").css("width",progreso + "%") + this.otForm.find("#ot-paginas").val(this.summaryData.presupuesto.paginas) + this.otForm.find("#ot-tirada").val(this.summaryData.presupuesto.tirada) + this.otForm.find("#ot-merma").val(this.summaryData.presupuesto.merma) + } + fillOtDates() { + this.fechaImpresion.setDate(this.summaryData.dates.fecha_impresion_at) + this.fechaEncuadernado.setDate(this.summaryData.dates.fecha_encuadernado_at) + // this.fechaEntregaExterno.setDate(this.summaryData.dates.fecha_entrega_externo_) + this.fechaEntregaReal.setDate(this.summaryData.dates.fecha_entrega_real_at) + this.fechaEntregaEstimada.setDate(this.summaryData.dates.fecha_entrega_at) + + this.pendienteFerro.setDate(this.summaryData.dates.pendiente_ferro_at) + this.ferroCliente.setDate(this.summaryData.dates.ferro_en_cliente_at) + this.ferroOk.setDate(this.summaryData.dates.ferro_ok_at) + // this.plakeneTraslucido.setDate(this.summaryData.dates.fecha_impresion_at) + this.impresionColor.setDate(this.summaryData.dates.interior_color_at) + this.portada.setDate(this.summaryData.dates.cubierta_at) + this.plastificadoMate.setDate(this.summaryData.dates.plastificado_at) + this.prepGuillotina.setDate(this.summaryData.dates.corte_at) + this.espiral.setDate(this.summaryData.dates.fecha_impresion_at) + this.embalaje.setDate(this.summaryData.dates.embalaje_at) + this.envio.setDate(this.summaryData.dates.envio_at) + + } + + handleTareaChange(event) { + const key = $(event.currentTarget).attr("name") + const data = {} + data[key] = $(event.currentTarget).val() + data["orden_trabajo_tarea_id"] = $(event.currentTarget).data("id") + console.log(data); + const ajax = new Ajax( + "/produccion/ordentrabajo/update/tarea", + data, + null, + this.handleTareaChangeSuccess.bind(this), + this.handleTareaChangeError.bind(this) + ) + ajax.post(); + } + handleTareaNoteSubmit(event) { + const data = {} + data["comment"] = $("#comment-tarea").val() + data["orden_trabajo_tarea_id"] = $("#comment-tarea").data("id") + const ajax = new Ajax( + "/produccion/ordentrabajo/update/tarea", + data, + null, + this.handleTareaChangeSuccess.bind(this), + this.handleTareaChangeError.bind(this) + ) + ajax.post(); + } + handleTareaChangeSuccess(data) { + this.datatableTareas.ajax.reload() + this.tareaCommentModal.item.modal("hide") + this._handleGetData(); + } + handleTareaChangeError(error) { } + handleOtComment(event){ + console.log($(event.currentTarget).val()) + const ajax = new Ajax( + "/produccion/ordentrabajo/update", + { + "orden_trabajo_id" : this.modelId, + "name" : $(event.currentTarget).attr("name"), + "comentarios" : $(event.currentTarget).val() + }, + null, + null, + null + ) + ajax.post(); + } + handleDateChange(event) { + const key = $(event.currentTarget).attr("name") + const data = {} + const element = $(event.currentTarget); + data[key] = $(event.currentTarget).val() + data["orden_trabajo_id"] = this.modelId + data["name"] = key; + console.log(data) + const ajax = new Ajax( + "/produccion/ordentrabajo/update/date", + data, + null, + this.handleDateChangeSuccess.bind(this, element), + this.handleDateChangeError.bind(this) + ) + ajax.post(); + + } + handleDateChangeSuccess(formItem, response) { + formItem.addClass("is-valid") + formItem.parent().append(`
${[response.user.first_name, response.user.last_name].join(" ")}
`) + } + handleDateChangeError(errors) { } + handlePreimpresionReviewChange(event) { + const key = $(event.currentTarget).attr("name") + const data = {} + data[key] = $(event.currentTarget).is(":checked") ? 1 : 0 + data["orden_trabajo_id"] = this.modelId + const ajax = new Ajax( + "/produccion/ordentrabajo/update", + data, + null, + this.handlePreimpresionReviewChangeSuccess.bind(this), + this.handlePreimpresionReviewChangeError.bind(this) + ) + ajax.post(); + + } + handlePreimpresionReviewChangeSuccess(response) { + + } + handlePreimpresionReviewChangeError(error) { + + } + handleUploadPortada(event) { + + + let data = new FormData() + data.set("orden_trabajo_id", this.modelId) + data.set("portada_file", this.otForm.find("#portada-file-input")[0].files[0]) + const ajax = new Ajax( + "/produccion/ordentrabajo/upload/portada", + data, + null, + this.handleUploadPortadaSuccess.bind(this), + this.handleUploadPortadaError.bind(this) + ) + ajax.ajaxForm("POST"); + + } + handleUploadPortadaSuccess(response) { + this.handleGetPortada() + this.otForm.find("#portada-file-input").val(null) + } + handleUploadPortadaError(errors) { } + handleGetPortada() { + this.item.find(".portada-loader").prop("hidden", false); + this.item.find("#portada-orden-trabajo").prop("hidden", true); + $.ajax({ + url: '/produccion/ordentrabajo/portada/' + this.modelId, + method: 'GET', + xhrFields: { + responseType: 'blob' // Expect binary data + }, + success: this.handleGetPortadaSuccess.bind(this), + error: this.handleGetPortadaError.bind(this) + }); + } + handleGetPortadaSuccess(data) { + const imageUrl = URL.createObjectURL(data); + $('#portada-orden-trabajo').attr('src', imageUrl); + this.item.find(".portada-loader").prop("hidden", true); + this.item.find("#portada-orden-trabajo").prop("hidden", false); + } + handleGetPortadaError(errors) { } + handleFinalizarPedido() { + const ajax = new Ajax( + "/produccion/ordentrabajo/update", + { + orden_trabajo_id: this.modelId, + estado: 'F' + }, + null, + this.handleEstadoChangeSuccess.bind(this), + this.handleEstadoChangeError.bind(this) + ); + ajax.post() + } + handleEstadoChangeSuccess() { + this.alertOrdenTrabajo.removeClass("alert-info").addClass("alert-success") + this.btnFinalizarPedido.prop("disabled", true); + } + handleEstadoChangeError() { } + handleTareaDeleteConfirmation(event) { + const orden_tarea_id = $(event.currentTarget).data("id") + alertConfirmationDelete("¿Estás seguro de realizar esta acción?") + .then(result => { + if (result.isConfirmed) { + this.handleDeleteTarea(orden_tarea_id) + } + }) + } + handleResetTareasDeleteConfirmation(event) { + alertConfirmationDelete("¿Estás seguro de realizar esta acción?") + .then(result => { + if (result.isConfirmed) { + this.handleDeleteResetTareas() + } + }) + } + handleDeleteResetTareas() { + const ajax = new Ajax( + "/produccion/ordentrabajo/reset/tareas/" + this.modelId, + null, + null, + this.handleDeleteTareaSuccess.bind(this), + this.handleDeleteTareaError.bind(this) + ); + ajax.delete() + } + handleDeleteResetTareasSuccess(response) { + this.datatableTareas.ajax.reload() + } + handleDeleteResetTareasError() { } + handleDeleteTarea(orden_tarea_id) { + const ajax = new Ajax( + "/produccion/ordentrabajo/tareas/" + orden_tarea_id, + null, + null, + this.handleDeleteTareaSuccess.bind(this), + this.handleDeleteTareaError.bind(this) + ); + ajax.delete() + } + handleDeleteTareaSuccess(response) { + this.datatableTareas.ajax.reload() + } + handleDeleteTareaError() { } + handleNoteTarea(event) { + let tarea_id = $(event.currentTarget).data("id"); + const tarea = this.summaryData.tasks.find(task => task.id == tarea_id) + if (tarea) { + $("#comment-tarea").attr("data-id", tarea_id) + $("#comment-type").text(tarea.nombre ?? "") + $("#comment-tarea").val(tarea.comment) + this.tareaCommentModal.toggle() + } + } + +} + + +export default OrdenTrabajo; \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/produccion/planning_rotativa/index.js b/httpdocs/assets/js/safekat/pages/produccion/planning_rotativa/index.js new file mode 100644 index 00000000..d16243f7 --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/produccion/planning_rotativa/index.js @@ -0,0 +1,7 @@ +import PlanningRotativa from "./planning_rotativa.js"; + +$(function(){ + const planningRotativa = new PlanningRotativa($("#planning-rotativa-page")); + planningRotativa.init(); + console.log("PL") +}) \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/produccion/planning_rotativa/planning_rotativa.js b/httpdocs/assets/js/safekat/pages/produccion/planning_rotativa/planning_rotativa.js new file mode 100644 index 00000000..ac2a232f --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/produccion/planning_rotativa/planning_rotativa.js @@ -0,0 +1,90 @@ +import ClassSelect from "../../../components/select2.js"; + +class PlanningRotativa { + constructor(domItem) { + this.item = domItem + this.tablePlanningRot = this.item.find("#planning-rotativa-datatable") + this.papelGramajeTablePlanning = this.item.find("#planning-papel-datatable") + + this.datatableColumns = [ + { data: 'otId', searchable: false, sortable: false }, + { data: 'fecha_entrega_real_at', searchable: true, sortable: false }, + { data: 'presupuesto_titulo', searchable: true, sortable: false }, + { data: 'maquina_planning_nombre', searchable: true, sortable: false }, + { data: 'ot_tirada', searchable: false, sortable: false }, + { data: 'maquina_ancho', searchable: false, sortable: false }, + { data: 'maquina_alto', searchable: false, sortable: false }, + { data: 'papel_impresion', searchable: false, sortable: false }, + { data: 'papel_gramaje', searchable: false, sortable: false }, + { data: 'action', searchable: false, sortable: false, render: this._renderBtnAction }, + + ] + this.papelGramajeDatatableColumns = [ + { data: 'papelImpresionNombre', searchable: true, sortable: true }, + { data: 'papelImpresionGramaje', searchable: true, sortable: true }, + { data: 'tareasCount', searchable: true, sortable: true }, + { data: 'totalTirada', searchable: false, sortable: false }, + { data: 'tiempoReal', searchable: false, sortable: false }, + + ] + this.maquinaSelectFilter = new ClassSelect($("#maquina-select-filter"), `/maquinas/select`, "Seleccione una maquina", true); + this.maquinaSelectFilter.config.dropdownParent = this.item + } + init() { + this.maquinaSelectFilter.init() + this.datatablePlanningRot = this.tablePlanningRot.DataTable({ + processing: true, + layout: { + topStart: 'pageLength', + topEnd: 'search', + bottomStart: 'info', + bottomEnd: 'paging' + }, + + serverSide: true, + responsive: true, + pageLength: 10, + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + columns: this.datatableColumns, + ajax: '/produccion/ordentrabajo/planning/rotativa/datatable' + }); + this.papelGramajeDatatable = this.papelGramajeTablePlanning.DataTable({ + processing: true, + layout: { + topStart: 'pageLength', + topEnd: 'search', + bottomStart: 'info', + bottomEnd: 'paging' + }, + + serverSide: true, + responsive: true, + pageLength: 10, + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + columns: this.papelGramajeDatatableColumns, + ajax: '/produccion/ordentrabajo/planning/papel/datatable' + }); + this.item.on("keyup", ".planning-filter", (event) => { + console.log(this.datatablePlanningRot.column($(event.currentTarget).attr("name"))) + let columnIndex = this.datatableColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name")) + this.datatablePlanningRot.column(columnIndex).search($(event.currentTarget).val()).draw() + }) + this.item.on("change", "#maquina-select-filter", (event) => { + let columnIndex = this.datatableColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name")) + this.datatablePlanningRot.column(columnIndex).search(this.maquinaSelectFilter.getText()).draw() + }) + } + _renderBtnAction(d) { + return ` Ver orden` + } + _columnFiltering() { + this.api().columns() + console.log(this.api().columns()) + } + +} +export default PlanningRotativa; \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/produccion/to_prod.js b/httpdocs/assets/js/safekat/pages/produccion/to_prod.js new file mode 100644 index 00000000..125c5254 --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/produccion/to_prod.js @@ -0,0 +1,47 @@ +import Ajax from "../../components/ajax.js" +$(() => { + $("#button-pedido-to-prod").on("click", (event) => { + const pedidoId = $(event.currentTarget).data("id"); + Swal.fire({ + title: '¿Estás seguro?', + text: "Esta acción creará la orden de trabajo del pedido", + icon: 'warning', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#d33', + confirmButtonText: 'Sí', + cancelButtonText: 'Cancelar', + customClass: { + confirmButton: 'btn btn-primary me-1', + cancelButton: 'btn btn-label-secondary' + }, + buttonsStyling: false + }).then((result) => { + if (result.isConfirmed) { + let ajax = new Ajax( + "/pedidos/produccion/" + pedidoId, + null, + null, + (response) => { + Swal.fire({ + title: response.message, + icon: 'success', + showCancelButton: true, + showConfirmButton: false, + cancelButtonText: 'Cancelar', + customClass: { + confirmButton: 'btn btn-primary me-1', + cancelButton: 'btn btn-label-secondary' + }, + buttonsStyling: false + }) + }, + null, + ) + ajax.post() + } + }).catch((err) => { + + }); + }) +}) \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/tarifas/maquinas/acabado/index.js b/httpdocs/assets/js/safekat/pages/tarifas/maquinas/acabado/index.js new file mode 100644 index 00000000..719cf685 --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/tarifas/maquinas/acabado/index.js @@ -0,0 +1,7 @@ +import TarifaMaquina from "../../tarifaMaquina.js" + + +$(() => { + const tarifaMaquinaAcabado = new TarifaMaquina($("#tarifa_maquina_component"),"acabado"); + tarifaMaquinaAcabado.init() +}) \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/tarifas/maquinas/encuadernacion/index.js b/httpdocs/assets/js/safekat/pages/tarifas/maquinas/encuadernacion/index.js new file mode 100644 index 00000000..f97516eb --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/tarifas/maquinas/encuadernacion/index.js @@ -0,0 +1,7 @@ +import TarifaMaquina from "../../tarifaMaquina.js" + + +$(() => { + const tarifaMaquina = new TarifaMaquina($("#tarifa_maquina_component"),"encuadernacion"); + tarifaMaquina.init() +}) \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/tarifas/maquinas/extra/index.js b/httpdocs/assets/js/safekat/pages/tarifas/maquinas/extra/index.js new file mode 100644 index 00000000..3db07acc --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/tarifas/maquinas/extra/index.js @@ -0,0 +1,7 @@ +import TarifaMaquina from "../../tarifaMaquina.js" + + +$(() => { + const tarifaMaquina = new TarifaMaquina($("#tarifa_maquina_component"),"extra"); + tarifaMaquina.init() +}) \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/tarifas/maquinas/manipulado/index.js b/httpdocs/assets/js/safekat/pages/tarifas/maquinas/manipulado/index.js new file mode 100644 index 00000000..502e7bfb --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/tarifas/maquinas/manipulado/index.js @@ -0,0 +1,7 @@ +import TarifaMaquina from "../../tarifaMaquina.js" + + +$(() => { + const tarifaMaquina = new TarifaMaquina($("#tarifa_maquina_component"),"manipulado"); + tarifaMaquina.init() +}) \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/tarifas/maquinas/preimpresion/index.js b/httpdocs/assets/js/safekat/pages/tarifas/maquinas/preimpresion/index.js new file mode 100644 index 00000000..766b1a1c --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/tarifas/maquinas/preimpresion/index.js @@ -0,0 +1,7 @@ +import TarifaMaquina from "../../tarifaMaquina.js" + + +$(() => { + const tarifaMaquina = new TarifaMaquina($("#tarifa_maquina_component"),"preimpresion"); + tarifaMaquina.init() +}) \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/pages/tarifas/tarifaMaquina.js b/httpdocs/assets/js/safekat/pages/tarifas/tarifaMaquina.js new file mode 100644 index 00000000..ec23428e --- /dev/null +++ b/httpdocs/assets/js/safekat/pages/tarifas/tarifaMaquina.js @@ -0,0 +1,94 @@ +import ClassSelect from "../../components/select2.js"; +import Ajax from "../../components/ajax.js"; +class TarifaMaquina { + constructor(domItem, type = "acabado") { + this.item = domItem + this.type = type + this.tarifaId = this.item.data("id") + this.btnNewTarifaMaquina = this.item.find("#btn-new-tarifa-maquina") + this.selectTarifaMaquina = new ClassSelect(this.item.find("#select-tarifa-maquina"), `/tarifas/maquinas/${this.type}/select`, "Seleccione una maquina", true); + this.selectMaquinaTarea = new ClassSelect(this.item.find("#select-maquina-tarea"), `/tarifas/maquinas/tareas/select`, "Seleccione una tarea", true); + this.datatableItem = this.item.find("#table-tarifa-maquinas") + this.datatableColumns = [ + { data: 'maquinaNombre', searchable: false, sortable: false }, + { data: 'tareaNombre', searchable: false, sortable: false }, + { + data: 'action', searchable: false, sortable: false, + render: (d, t) => { + return `
+ +
` + } + } + ] + + } + init() { + // this.btnNewTarifaMaquina.prop("disabled",true) + this.selectMaquinaTarea.init() + this.selectTarifaMaquina.init() + this.datatable = this.datatableItem.DataTable({ + processing: true, + layout: { + topStart: 'pageLength', + topEnd: 'search', + bottomStart: 'info', + bottomEnd: 'paging' + }, + serverSide: true, + pageLength: 25, + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + columns: this.datatableColumns, + ajax: `/tarifas/maquinas/${this.type}/datatable/${this.tarifaId}` + }); + this.events(); + } + events() { + this.btnNewTarifaMaquina.on("click", this.handleNewTarifaMaquina.bind(this)); + this.datatable.on("click", ".tarifa-maquina-btn-delete", this.handleDeleteTarifaMaquina.bind(this)) + } + handleNewTarifaMaquina() { + let key = `tarifa_${this.type}_id` + let bodyData = { + maquina_id: this.selectTarifaMaquina.getVal(), + maquina_tarea_id: this.selectMaquinaTarea.getVal() + } + bodyData[key] = this.tarifaId; + + const ajax = new Ajax( + `/tarifas/maquinas/${this.type}`, + bodyData, + null, + this.handleNewTarifaMaquinaSuccess.bind(this), + this.handleNewTarifaMaquinaError.bind(this), + ) + ajax.post() + } + handleNewTarifaMaquinaSuccess(response) { + this.datatable.ajax.reload() + this.selectMaquinaTarea.reset() + this.selectTarifaMaquina.reset() + console.log(response) + } + handleNewTarifaMaquinaError(error) { } + + handleDeleteTarifaMaquina(event) { + const tarifaMaquinaId = $(event.currentTarget).data("id") + const ajax = new Ajax( + `/tarifas/maquinas/${this.type}/${tarifaMaquinaId}`, + null, + null, + this.handleDeleteTarifaMaquinaSuccess.bind(this), + this.handleDeleteTarifaMaquinaError.bind(this), + ) + ajax.delete() + } + handleDeleteTarifaMaquinaSuccess() { + this.datatable.ajax.reload() + } + handleDeleteTarifaMaquinaError() { } + +} +export default TarifaMaquina \ No newline at end of file diff --git a/httpdocs/themes/vuexy/css/pdf.ot.css b/httpdocs/themes/vuexy/css/pdf.ot.css new file mode 100644 index 00000000..38c24b85 --- /dev/null +++ b/httpdocs/themes/vuexy/css/pdf.ot.css @@ -0,0 +1,329 @@ +@page { + size: A4; + margin: 0; + } + @media print { + html, body { + width: 210mm; + height: 297mm; + } + /* ... the rest of the rules ... */ + } +html,body { + font-family: Arial, sans-serif; + width: 210mm; + height: 297mm; + max-width: 210mm; + max-height: 297mm; + background-color: #f9f9f9; +} +body{ + border: 2px solid; + padding: 20px; + +} +.cubierta{ + color: #007bff; +} +.encuadernacion{ + color: green; +} +.impresion{ + color: #ff4000; +} +.container { + width: 100%; + width: 210mm; + height: 297mm; + background: #fff; + padding: 20px; + box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); + border: 2px solid; + +} +.header { + display: flex; + justify-content: space-between; + align-items: center; +} +.cover{ + display: flex; + justify-content: start; + align-items: center; + gap: 10px; + margin-top: 10px; + margin-bottom: 10px; +} +.portada-info{ + display: flex; + flex-direction: column; + width: 100%; +} +.portada-row{ + display: flex; + align-items: center; + justify-items: center; + justify-content: space-between; + background-color: #4ba0fccc; + width: 100%; + height: 5mm; + border: solid 2px; + margin: 2px; + border-color: black; + +} +.portada-row-2{ + display: flex; + align-items: center; + justify-items: center; + background-color: #ff4000; + width: 100%; + height: 35mm; + color: white; + margin: 2px; + border: 2px solid; + border-color: black; + +} +.portada{ + height: 40mm; +} +.presupuesto-title{ + color: #007bff; + font-size: medium; + line-height: 0; +} +.pl-2{ + padding-left: 0.5rem; +} +.pr-2{ + padding-right: 0.5rem; +} +.pt-2{ + padding-top: 0.5rem; +} +.flex-row{ + display: flex; + width: 100%; + justify-content: start; + align-items: flex-start; +} +.date{ + padding-left: 0.5rem; + padding-top: 0px; + width: 100%; + line-height: 0px; + stroke-width: 5px; + font-size: medium; +} +#presupuesto-section{ + width: 100%; +} +.flex-col{ + display: flex; + padding: 0; + flex-direction: column; +} +.cliente-title{ + color: red; + font-size: medium; + stroke-width: 10px; + line-height: 0px; +} + +.header .title { + font-size: 24px; + font-weight: bold; + color: #333; +} + +.section { + margin-top: 0.5rem; + border-top: 1px solid #ddd; + padding-top: 0.2rem; +} +.section-title { + font-weight: bold; + margin-bottom: 10px; +} +table { + width: 100%; + border-collapse: collapse; + margin-bottom: 5px; + font-size: 12px; +} +table th, table td { + border: 2px solid #000000; + text-align: center; +} +table th { + background-color: #f4f4f4; + font-weight: bold; +} +table td{ + font-weight: bold; +} +.comments { + color: #555; + font-style: italic; + margin-top: 0.2rem; +} +.comment-content { + line-height: 0; + width: 100%; + height: 50px; + border: solid; + border-width: 1px; +} +.footer { + text-align: center; + margin-top: 0.5rem; + font-size: 14px; + color: #777; +} +.row-logo-impresion{ + text-align: center; +} +.portada-img{ + border: black; + border-style: solid; + border-width: 2px; + height: 40mm; + width: 100px; + max-width: 30mm; + border: 2px solid; + border-color: black; + border-radius: 5%; +} +.portada-text{ + color: white; +} + +.t-header{ + color: black; + width: 25%; +} +.t-cell{ + background-color: white; + color: black; + text-align: start; + padding-left: 0.2rem; +} +.t-row{ + font-size: 10px; +} +.esquema{ + display: flex; + justify-content:flex-end; + width: 100%; + justify-items: flex-end; + +} +.pagina-imposicion-outer-start{ + border-top: 2px solid; + border-left: 2px solid; + border-bottom: 2px solid; + width: 50px; + height: 100px; + display: flex; + align-items: center; + justify-content: center; +} +.pagina-imposicion-outer-end{ + border-top: 2px solid; + border-right: 2px solid; + border-bottom: 2px solid; + width: 50px; + height: 100px; + display: flex; + align-items: center; + justify-content: center; +} +.pagina-imposicion-outer{ + border-top: 2px solid; + border-bottom: 2px solid; + width: 50px; + height: 100px; + display: flex; + align-items: center; + justify-content: center; +} +.pagina-imposicion-inner{ + border: 2px solid; + font-size: 25px; + width: 40px; + height: 90px; + display: flex; + align-items: center; + justify-content: center; + +} +.square-wrapper{ + display: grid; + grid-template-columns: repeat(2,1fr); + margin-left: 10px; + +} +.square{ + width: 100px; + height: 50px; + display: flex; + align-items: center; + justify-content: center; + font-weight: bold; +} +.cod{ + width: 200px; + height: 100px; + display: flex; + flex-direction: column; + background-color: orange; + margin-left: 10px; + color: white; + align-items: center; + justify-content: space-between; + font-weight: bold; +} +.cod-code{ + font-weight: bold; + color: white; +} +.esquema-imposicion-wrapper{ + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + margin-left: 2rem; + gap: 10px; +} +.imposicion{ + display: flex; + align-items: center; + justify-content: center; + width: 200px; +} +.imposicion td{ + font-size: large; +} +.cod-barras{ + width: 190px; + height: 50px; + margin: 5px; + background-color: white; +} +.bg-white{ + background-color: white; + color: black; +} +.bg-red{ + background-color: red; + color: white; +} +.bg-gray{ + background-color: gray; + color:white +} +.bg-blue{ + background-color: blue; + color: white; +} diff --git a/httpdocs/themes/vuexy/vendor/libs/flatpickr/es.js b/httpdocs/themes/vuexy/vendor/libs/flatpickr/es.js new file mode 100644 index 00000000..948a923b --- /dev/null +++ b/httpdocs/themes/vuexy/vendor/libs/flatpickr/es.js @@ -0,0 +1,51 @@ + +export const Spanish = { + weekdays: { + shorthand: ["Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb"], + longhand: [ + "Domingo", + "Lunes", + "Martes", + "Miércoles", + "Jueves", + "Viernes", + "Sábado", + ], + }, + months: { + shorthand: [ + "Ene", + "Feb", + "Mar", + "Abr", + "May", + "Jun", + "Jul", + "Ago", + "Sep", + "Oct", + "Nov", + "Dic", + ], + longhand: [ + "Enero", + "Febrero", + "Marzo", + "Abril", + "Mayo", + "Junio", + "Julio", + "Agosto", + "Septiembre", + "Octubre", + "Noviembre", + "Diciembre", + ], + }, + ordinal: function () { + return "º"; + }, + firstDayOfWeek: 1, + rangeSeparator: " a ", + time_24hr: true, +};