diff --git a/ci4/app/Config/Routes.php b/ci4/app/Config/Routes.php index f94097e3..0278a980 100755 --- a/ci4/app/Config/Routes.php +++ b/ci4/app/Config/Routes.php @@ -646,6 +646,8 @@ $routes->group('messages', ['namespace' => 'App\Controllers\Chat'], function ($r $routes->get('datatable/pedido', 'ChatController::datatable_pedido_messages', ['as' => 'getDatatablePedidoMessages']); $routes->get('datatable/factura', 'ChatController::datatable_factura_messages', ['as' => 'getDatatableFacturaMessages']); $routes->get('datatable/ots', 'ChatController::datatable_ot_messages', ['as' => 'getDatatableOtMessages']); + $routes->get('datatable/direct', 'ChatController::datatable_direct_messages', ['as' => 'getDatatableDirectMessages']); + $routes->post('direct', 'ChatController::store_new_direct_message', ['as' => 'storeNewDirectMessage']); $routes->post('direct/client', 'ChatController::store_new_direct_message_client', ['as' => 'storeNewDirectMessageClient']); diff --git a/ci4/app/Controllers/Chat/ChatController.php b/ci4/app/Controllers/Chat/ChatController.php index 1df0f469..2c70160d 100755 --- a/ci4/app/Controllers/Chat/ChatController.php +++ b/ci4/app/Controllers/Chat/ChatController.php @@ -363,14 +363,13 @@ class ChatController extends BaseController $query = $this->userModel->builder()->select( [ "id", - "CONCAT(first_name,' ',last_name,'(',username,')') as name" + "CONCAT(first_name,' ',last_name) as name" ] ) ->where("deleted_at", null) ->whereNotIn("id", [auth()->user()->id]); if ($this->request->getGet("q")) { $query->groupStart() - ->orLike("users.username", $this->request->getGet("q")) ->orLike("CONCAT(first_name,' ',last_name)", $this->request->getGet("q")) ->groupEnd(); } @@ -538,6 +537,23 @@ class ChatController extends BaseController ->toJson(true); } + public function datatable_direct_messages() + { + $auth_user_id = auth()->user()->id; + $isAdmin = auth()->user()->inGroup('admin'); + $query = $this->chatModel->getQueryDatatableDirectMessages($auth_user_id); + 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") : "") + ->edit('updated_at', fn($q) => $q->updated_at ? Time::createFromFormat('Y-m-d H:i:s', $q->updated_at)->format("d/m/Y H:i") : "") + ->edit("creator",fn($q) => $q->userId == $auth_user_id ? ''.lang("App.me").'' : $q->creator) + ->add("viewed", fn($q) => $this->chatModel->isMessageChatViewed($q->chatMessageId)) + ->add("action", fn($q) => ["type" => "direct", "modelId" => $q->id, "isAdmin" => $isAdmin,"chatMessageId" => $q->chatMessageId, "lang" => [ + "view_chat" => lang('Chat.view_chat'), + "view_by_alt_message" => lang('Chat.view_by_alt_message') + ]]) + + ->toJson(true); + } public function get_notifications_not_viewed_from_message(int $chat_message_id) { $unviewedNotifications = $this->chatModel->getUsersNotificationNotViewedFromChat($chat_message_id); @@ -605,14 +621,13 @@ class ChatController extends BaseController $query = $this->userModel->builder()->select( [ "id", - "CONCAT(first_name,' ',last_name,'(',username,')') as name" + "CONCAT(first_name,' ',last_name) as name" ] ) ->where("deleted_at", null) ->whereNotIn("id", $chat_users_id); if ($this->request->getGet("q")) { $query->groupStart() - ->orLike("users.username", $this->request->getGet("q")) ->orLike("CONCAT(first_name,' ',last_name)", $this->request->getGet("q")) ->groupEnd(); } diff --git a/ci4/app/Controllers/Produccion/Ordentrabajo.php b/ci4/app/Controllers/Produccion/Ordentrabajo.php index e3098a42..ce6dacdd 100755 --- a/ci4/app/Controllers/Produccion/Ordentrabajo.php +++ b/ci4/app/Controllers/Produccion/Ordentrabajo.php @@ -707,7 +707,7 @@ class Ordentrabajo extends BaseController $r = $this->produccionService->storeOrdenTrabajoTareaProgressDate($validatedData); $otTareaEntity = $this->otTarea->find($validatedData['ot_tarea_id']); $data = [ - "tiempo_trabajado" => float_seconds_to_hhmm_string($otTareaEntity->tiempo_real), + "tiempo_trabajado" => float_seconds_to_hhmmss_string($otTareaEntity->tiempo_real), "tarea" => $otTareaEntity, "estado" => $validatedData['estado'], ]; @@ -728,7 +728,7 @@ class Ordentrabajo extends BaseController { $otTareaEntity = $this->otTarea->find($orden_trabajo_tarea_id); $data = [ - "tiempo_trabajado" => float_seconds_to_hhmm_string($otTareaEntity->tiempo_trabajado()), + "tiempo_trabajado" => float_seconds_to_hhmmss_string($otTareaEntity->tiempo_trabajado()), "progress_dates" => $otTareaEntity->progress_dates(), ]; return $this->response->setJSON($data); diff --git a/ci4/app/Database/Migrations/2025-05-19-204800_AddAliasOtColumnMaquinasTable.php b/ci4/app/Database/Migrations/2025-05-19-204800_AddAliasOtColumnMaquinasTable.php new file mode 100644 index 00000000..0d5f03ca --- /dev/null +++ b/ci4/app/Database/Migrations/2025-05-19-204800_AddAliasOtColumnMaquinasTable.php @@ -0,0 +1,26 @@ + [ + "type" => "VARCHAR", + "constraint" => 255, + "null" => true + ], + ]; + public function up() + { + $this->forge->addColumn('lg_maquinas', $this->COLUMNS); + } + + public function down() + { + $this->forge->dropColumn('lg_maquinas', array_keys($this->COLUMNS)); + } +} diff --git a/ci4/app/Database/Seeds/DefaultConfigVariablesSeeder.php b/ci4/app/Database/Seeds/DefaultConfigVariablesSeeder.php index 32b94966..64336be4 100755 --- a/ci4/app/Database/Seeds/DefaultConfigVariablesSeeder.php +++ b/ci4/app/Database/Seeds/DefaultConfigVariablesSeeder.php @@ -23,6 +23,11 @@ class DefaultConfigVariablesSeeder extends Seeder "value" => 6000, "description" => "Número de libros máximos que se puede producir al día" ], + [ + "name" => "maquina_guillotina_id_default", + "value" => 20, + "description" => "ID de máquina que se asigna a tareas de corte tras impresión" + ] ]; public function run() { diff --git a/ci4/app/Database/Seeds/MaquinaAliasOtSeeder.php b/ci4/app/Database/Seeds/MaquinaAliasOtSeeder.php new file mode 100644 index 00000000..3bc58523 --- /dev/null +++ b/ci4/app/Database/Seeds/MaquinaAliasOtSeeder.php @@ -0,0 +1,40 @@ + "6136p", + "alias" => "6136p" + ], + [ + "value" => "c6100", + "alias" => "c6100" + ], + [ + "value" => "2250p", + "alias" => "2250p" + ], + [ + "value" => "C14 000", + "alias" => "C14 000" + ], + [ + "value" => "IX", + "alias" => "IX" + ] + + ]; + foreach ($data as $key => $row) { + $m->like('nombre', $row['value'])->set(['alias_ot' => $row['alias']])->update(); + } + } +} diff --git a/ci4/app/Entities/Configuracion/Maquina.php b/ci4/app/Entities/Configuracion/Maquina.php index 6b9f6cf8..1d8fbc8e 100755 --- a/ci4/app/Entities/Configuracion/Maquina.php +++ b/ci4/app/Entities/Configuracion/Maquina.php @@ -42,7 +42,8 @@ class Maquina extends \CodeIgniter\Entity\Entity "updated_at" => null, "user_created_id" => 0, "user_updated_id" => 0, - "etiqueta_envio" => false + "etiqueta_envio" => false, + "alias_ot" => null, ]; protected $casts = [ "is_padre" => "boolean", @@ -70,6 +71,7 @@ class Maquina extends \CodeIgniter\Entity\Entity "is_deleted" => "int", "user_created_id" => "int", "user_updated_id" => "int", + "alias_ot" => "?string" ]; public function papeles_impresion() : ?array diff --git a/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php b/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php index 38744e7e..74ba61ae 100755 --- a/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php +++ b/ci4/app/Entities/Presupuestos/PresupuestoLineaEntity.php @@ -248,6 +248,10 @@ class PresupuestoLineaEntity extends \CodeIgniter\Entity\Entity return in_array($this->attributes['tipo'], ["lp_bn", "lp_bnhq", "lp_rot_bn"]); } + public function isImpresionInteriorPlana():bool + { + return in_array($this->attributes['tipo'], ["lp_bn", "lp_bnhq", "lp_colorhq","lp_color"]); + } public function tinta(): string { $tinta = ""; diff --git a/ci4/app/Language/en/Maquinas.php b/ci4/app/Language/en/Maquinas.php index 96f5ee61..2d87ba4a 100755 --- a/ci4/app/Language/en/Maquinas.php +++ b/ci4/app/Language/en/Maquinas.php @@ -29,6 +29,7 @@ return [ 'min' => 'Min POD', 'moduleTitle' => 'Machines', 'nombre' => 'Name', + 'alias_ot' => 'Alias', 'observaciones' => 'Remarks', 'ordenPlanning' => 'Planning order', 'padreId' => 'Variante', diff --git a/ci4/app/Language/es/Chat.php b/ci4/app/Language/es/Chat.php index 10458366..e7d0a29c 100755 --- a/ci4/app/Language/es/Chat.php +++ b/ci4/app/Language/es/Chat.php @@ -60,6 +60,7 @@ return [ "subscribe_admin_chat_wrong" => "Tienes que seleccionar un usuario.", "help_select_chat_department_user" => "Solamente son listados los usuarios que pertenecen al personal. Los clientes no son listados, para añadirlos a la conversación se realiza desde la sección de mensajería de las diferentes secciones(presupuesto,pedido,factura ...)", "store_department" => "Crear departamento", + "direct_messsages" => "Mensajes directos", "mail" => [ "mail_subject" => "Nuevo mensaje" ] diff --git a/ci4/app/Language/es/Maquinas.php b/ci4/app/Language/es/Maquinas.php index a8ea07b9..b09ab7ce 100755 --- a/ci4/app/Language/es/Maquinas.php +++ b/ci4/app/Language/es/Maquinas.php @@ -3,175 +3,179 @@ return [ - 'acabado' => 'acabado', - 'alto' => 'Alto', - 'altoClick' => 'Alto Click', - 'altoImpresion' => 'Alto Impresion', - 'ancho' => 'Ancho', - 'anchoImpresion' => 'Ancho Impresion', - 'createdAt' => 'Created At', - 'deletedAt' => 'Deleted At', - 'duracionJornada' => 'Duracion Jornada', - 'forzarNumFormasHorizontalesPortada' => 'Forzar Num Formas Horizontales Cubierta', - 'forzarNumFormasVerticalesPortada' => 'Forzar Num Formas Verticales Cubierta', - 'id' => 'ID', - 'impresion' => 'impresion', - 'isDeleted' => 'Is Deleted', - 'isPadre' => 'Usar para variante?', - 'isRotativa' => 'Es Rotativa?', - 'isTinta' => 'Inkjet', - 'isEtiquetaEnvio' => 'Etiqueta títulos', - 'manipulado' => 'manipulado', - 'maquina' => 'Maquina', - 'maquinaList' => 'Lista Máquinas', - 'maquinas' => 'Máquinas', - 'max' => 'POD Max', - 'metrosxminuto' => 'Metros x minuto', - 'min' => 'POD Min', - 'moduleTitle' => 'Máquinas', - 'nombre' => 'Nombre', - 'observaciones' => 'Observaciones', - 'ordenPlanning' => 'Orden Planning', - 'padreId' => 'Variante', - 'precioHoraCorte' => 'Precio Hora Corte', - 'precioTintaCG' => 'Precio Tinta CG', - 'precioTintaColor' => 'Precio Tinta Color', - 'precioTintaNegro' => 'Precio Tinta Negro', - 'tipo' => 'Tipo', - 'updatedAt' => 'Updated At', - 'userCreatedId' => 'User Created ID', - 'userUpdatedId' => 'User Updated ID', - 'velocidad' => 'Velocidad', - 'velocidadCorte' => 'Velocidad Corte', - 'maquina_tarea' => 'Máquina tarea', - 'namePlaceholderDuplicated' => "Inserte el nombre de la máquina a duplicar ...", - '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\'', - 'alto' => [ - 'decimal' => 'El campo {field} debe contener un número decimal.', - 'greater_than' => 'El campo {field} debe ser mayor que {param}', - ], + 'acabado' => 'acabado', + 'alto' => 'Alto', + 'altoClick' => 'Alto Click', + 'altoImpresion' => 'Alto Impresion', + 'ancho' => 'Ancho', + 'anchoImpresion' => 'Ancho Impresion', + 'createdAt' => 'Created At', + 'deletedAt' => 'Deleted At', + 'duracionJornada' => 'Duracion Jornada', + 'forzarNumFormasHorizontalesPortada' => 'Forzar Num Formas Horizontales Cubierta', + 'forzarNumFormasVerticalesPortada' => 'Forzar Num Formas Verticales Cubierta', + 'id' => 'ID', + 'impresion' => 'impresion', + 'isDeleted' => 'Is Deleted', + 'isPadre' => 'Usar para variante?', + 'isRotativa' => 'Es Rotativa?', + 'isTinta' => 'Inkjet', + 'isEtiquetaEnvio' => 'Etiqueta títulos', + 'manipulado' => 'manipulado', + 'maquina' => 'Maquina', + 'maquinaList' => 'Lista Máquinas', + 'maquinas' => 'Máquinas', + 'max' => 'POD Max', + 'metrosxminuto' => 'Metros x minuto', + 'min' => 'POD Min', + 'moduleTitle' => 'Máquinas', + 'nombre' => 'Nombre', + 'alias_ot' => 'Alias', + 'observaciones' => 'Observaciones', + 'ordenPlanning' => 'Orden Planning', + 'padreId' => 'Variante', + 'precioHoraCorte' => 'Precio Hora Corte', + 'precioTintaCG' => 'Precio Tinta CG', + 'precioTintaColor' => 'Precio Tinta Color', + 'precioTintaNegro' => 'Precio Tinta Negro', + 'tipo' => 'Tipo', + 'updatedAt' => 'Updated At', + 'userCreatedId' => 'User Created ID', + 'userUpdatedId' => 'User Updated ID', + 'velocidad' => 'Velocidad', + 'velocidadCorte' => 'Velocidad Corte', + 'maquina_tarea' => 'Máquina tarea', + 'namePlaceholderDuplicated' => "Inserte el nombre de la máquina a duplicar ...", + '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\'', + 'alto' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'greater_than' => 'El campo {field} debe ser mayor que {param}', + ], - 'ancho' => [ - 'decimal' => 'El campo {field} debe contener un número decimal.', - 'greater_than' => 'El campo {field} debe ser mayor que {param}', - ], + 'ancho' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'greater_than' => 'El campo {field} debe ser mayor que {param}', + ], - 'forzar_num_formas_horizontales_cubierta' => [ - 'integer' => 'El campo {field} debe contener un número entero.', + 'forzar_num_formas_horizontales_cubierta' => [ + 'integer' => 'El campo {field} debe contener un número entero.', - ], + ], - 'forzar_num_formas_verticales_cubierta' => [ - 'integer' => 'El campo {field} debe contener un número entero.', + 'forzar_num_formas_verticales_cubierta' => [ + 'integer' => 'El campo {field} debe contener un número entero.', - ], + ], - 'alto_click' => [ - 'decimal' => 'El campo {field} debe contener un número decimal.', - 'required' => 'El campo {field} es obligatorio.', - 'greater_than' => 'El campo {field} debe ser mayor que {param}', - ], + 'alto_click' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + 'greater_than' => 'El campo {field} debe ser mayor que {param}', + ], - 'alto_impresion' => [ - 'decimal' => 'El campo {field} debe contener un número decimal.', - 'required' => 'El campo {field} es obligatorio.', - 'greater_than' => 'El campo {field} debe ser mayor que {param}', - ], + 'alto_impresion' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + 'greater_than' => 'El campo {field} debe ser mayor que {param}', + ], - 'ancho_impresion' => [ - 'decimal' => 'El campo {field} debe contener un número decimal.', - 'required' => 'El campo {field} es obligatorio.', - 'greater_than' => 'El campo {field} debe ser mayor que {param}', - ], + 'ancho_impresion' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', + 'greater_than' => 'El campo {field} debe ser mayor que {param}', + ], - 'duracion_jornada' => [ - 'integer' => 'El campo {field} debe contener un número entero.', - 'required' => 'El campo {field} es obligatorio.', + 'duracion_jornada' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + 'required' => 'El campo {field} es obligatorio.', - ], + ], - 'max' => [ - 'integer' => 'El campo {field} debe contener un número entero.', - 'required' => 'El campo {field} es obligatorio.', + 'max' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + 'required' => 'El campo {field} es obligatorio.', - ], + ], - 'metrosxminuto' => [ - 'max_length' => 'El campo {field} no puede exeder de {param} caracteres de longitud.', - 'required' => 'El campo {field} es obligatorio.', + 'metrosxminuto' => [ + 'max_length' => 'El campo {field} no puede exceder de {param} caracteres de longitud.', + 'required' => 'El campo {field} es obligatorio.', - ], + ], - 'min' => [ - 'integer' => 'El campo {field} debe contener un número entero.', - 'required' => 'El campo {field} es obligatorio.', + 'min' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + 'required' => 'El campo {field} es obligatorio.', - ], + ], - 'nombre' => [ - 'max_length' => 'El campo {field} no puede exeder de {param} caracteres de longitud.', - 'required' => 'El campo {field} es obligatorio.', + 'nombre' => [ + 'max_length' => 'El campo {field} no puede exceder de {param} caracteres de longitud.', + 'required' => 'El campo {field} es obligatorio.', - ], + ], + 'alias' => [ + 'max_length' => 'El campo {field} no puede exceder de {param} caracteres de longitud.', + ], - 'observaciones' => [ - 'max_length' => 'El campo {field} no puede exeder de {param} caracteres de longitud.', - 'required' => 'El campo {field} es obligatorio.', + 'observaciones' => [ + 'max_length' => 'El campo {field} no puede exceder de {param} caracteres de longitud.', + 'required' => 'El campo {field} es obligatorio.', - ], + ], - 'orden_planning' => [ - 'integer' => 'El campo {field} debe contener un número entero.', - 'required' => 'El campo {field} es obligatorio.', + 'orden_planning' => [ + 'integer' => 'El campo {field} debe contener un número entero.', + 'required' => 'El campo {field} es obligatorio.', - ], + ], - 'precio_hora_corte' => [ - 'decimal' => 'El campo {field} debe contener un número decimal.', - 'required' => 'El campo {field} es obligatorio.', + 'precio_hora_corte' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', - ], + ], - 'precio_tinta_cg' => [ - 'decimal' => 'El campo {field} debe contener un número decimal.', - 'required' => 'El campo {field} es obligatorio.', + 'precio_tinta_cg' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', - ], + ], - 'precio_tinta_color' => [ - 'decimal' => 'El campo {field} debe contener un número decimal.', - 'required' => 'El campo {field} es obligatorio.', + 'precio_tinta_color' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', - ], + ], - 'precio_tinta_negro' => [ - 'decimal' => 'El campo {field} debe contener un número decimal.', - 'required' => 'El campo {field} es obligatorio.', + 'precio_tinta_negro' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', - ], + ], - 'tipo' => [ - 'in_list' => 'El campo {field} debe ser uno uno de: {param}.', - 'required' => 'El campo {field} es obligatorio.', + 'tipo' => [ + 'in_list' => 'El campo {field} debe ser uno uno de: {param}.', + 'required' => 'El campo {field} es obligatorio.', - ], + ], - 'velocidad' => [ - 'decimal' => 'El campo {field} debe contener un número decimal.', - 'required' => 'El campo {field} es obligatorio.', + 'velocidad' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', - ], - - 'velocidad_corte' => [ - 'decimal' => 'El campo {field} debe contener un número decimal.', - 'required' => 'El campo {field} es obligatorio.', - - ], + ], + 'velocidad_corte' => [ + 'decimal' => 'El campo {field} debe contener un número decimal.', + 'required' => 'El campo {field} es obligatorio.', ], -]; \ No newline at end of file + ], + + +]; diff --git a/ci4/app/Language/es/Produccion.php b/ci4/app/Language/es/Produccion.php index 3d990871..a7907544 100755 --- a/ci4/app/Language/es/Produccion.php +++ b/ci4/app/Language/es/Produccion.php @@ -202,5 +202,10 @@ return [ "tareas_finalizadas" => "Las tareas de esta OT y máquina están marcadas como finalizadas", "ot_not_found" => "La orden de trabajo número {ot_id} no existe" - ] + ], + 'hunkeler' => "Corte HUNKELER", + 'tecnau' => "Corte TECNAU", + 'end_cut' => "Corte final", + "interior_cut" => "Preparación interior", + "cover_cut" => "Preparación cubierta" ]; diff --git a/ci4/app/Models/Chat/ChatModel.php b/ci4/app/Models/Chat/ChatModel.php index 5ac10631..bc3351c1 100755 --- a/ci4/app/Models/Chat/ChatModel.php +++ b/ci4/app/Models/Chat/ChatModel.php @@ -136,7 +136,7 @@ class ChatModel extends Model $chatDeparmentModel = model(ChatDeparmentModel::class); $ot = $model->find($orden_trabajo_id); return $this->insert([ - "title" => "[OT]".$ot->id . "[" . $chatDeparmentModel->getDisplay($chat_department_id) . "]", + "title" => "[OT]" . $ot->id . "[" . $chatDeparmentModel->getDisplay($chat_department_id) . "]", "orden_trabajo_id" => $orden_trabajo_id, "chat_department_id" => $chat_department_id ]); @@ -381,8 +381,7 @@ class ChatModel extends Model $row->title = $row->facturaId; $rows_new[] = $row; - } - elseif ($row->ordenTrabajoId) { + } elseif ($row->ordenTrabajoId) { // $row->model = $facturaModel->find($row->facturaId); $row->uri = "/chat/ot/" . $row->ordenTrabajoId . "#accordionChatOrdenTrabajo"; $row->avatar = "OT"; @@ -439,8 +438,7 @@ class ChatModel extends Model $row->chatDisplay .= "[INTERNAL]"; $row->title = $row->facturaId; $rows_new[] = $row; - } - elseif ($row->ordenTrabajoId) { + } elseif ($row->ordenTrabajoId) { $row->uri = "/produccion/ordentrabajo/edit/" . $row->ordenTrabajoId . "#accordionChatOrdenTrabajo"; $row->avatar = "OT"; $row->chatDisplay .= "[INTERNAL]"; @@ -847,7 +845,7 @@ class ChatModel extends Model ->join("users u", "u.id = cm.sender_id", 'left') ->where("chats.presupuesto_id is NOT NULL", NULL, FALSE); - if (auth()->user()->inGroup("cliente-administrador","cliente")) { + if (auth()->user()->inGroup("cliente-administrador", "cliente")) { $query->where('presupuestos.cliente_id', auth()->user()->cliente_id) ->where("chats.chat_department_id is NOT NULL", NULL, FALSE); } @@ -878,7 +876,7 @@ class ChatModel extends Model ->join("presupuestos", "presupuestos.id = pedidos_linea.presupuesto_id", 'left') ->where("chats.pedido_id is NOT NULL", NULL, FALSE); - if (auth()->user()->inGroup("cliente-administrador","cliente")) { + if (auth()->user()->inGroup("cliente-administrador", "cliente")) { $query->where('presupuestos.cliente_id', auth()->user()->cliente_id) ->where("chats.chat_department_id is NOT NULL", NULL, FALSE); } @@ -908,10 +906,10 @@ class ChatModel extends Model ->join("facturas", "facturas.id = chats.factura_id", "left") ->where("chats.factura_id is NOT NULL", NULL, FALSE); - if (auth()->user()->inGroup("cliente-administrador","cliente")) { - $query->where('facturas.cliente_id', auth()->user()->cliente_id) - ->where("chats.chat_department_id is NOT NULL", NULL, FALSE); - } + if (auth()->user()->inGroup("cliente-administrador", "cliente")) { + $query->where('facturas.cliente_id', auth()->user()->cliente_id) + ->where("chats.chat_department_id is NOT NULL", NULL, FALSE); + } return $query->groupBy('chatMessageId'); } public function getQueryDatatableMessageOrdenTrabajo(int $user_id): BaseBuilder @@ -938,10 +936,42 @@ class ChatModel extends Model ->join("ordenes_trabajo", "ordenes_trabajo.id = chats.orden_trabajo_id", "left") ->where("chats.orden_trabajo_id is NOT NULL", NULL, FALSE); - if (auth()->user()->inGroup("cliente-administrador","cliente")) { - $query->where('facturas.cliente_id', auth()->user()->cliente_id) - ->where("chats.chat_department_id is NOT NULL", NULL, FALSE); - } + if (auth()->user()->inGroup("cliente-administrador", "cliente")) { + $query->where('facturas.cliente_id', auth()->user()->cliente_id) + ->where("chats.chat_department_id is NOT NULL", NULL, FALSE); + } + return $query->groupBy('chatMessageId'); + } + public function getQueryDatatableDirectMessages(): BaseBuilder + { + $query = $this->builder() + ->select([ + "chats.id", + "cm.id as chatMessageId", + "u.id as userId", + "cm.message", + "chats.created_at", + " + ( + SELECT cm2.updated_at + FROM chat_messages cm2 + WHERE cm2.chat_id = chats.id + ORDER BY cm2.updated_at DESC LIMIT 1 + ) as updated_at", + "CONCAT(u.first_name,' ',u.last_name) as creator", + "chats.title as title", + ]) + ->join("chat_messages cm", "chats.id = cm.chat_id", "left") + ->join("users u", "u.id = cm.sender_id", 'left') + ->where("chats.presupuesto_id", NULL) + ->where("chats.pedido_id", NULL) + ->where("chats.factura_id", NULL) + ->where("chats.orden_trabajo_id", NULL) + ->groupStart() + ->orWhere("cm.receiver_id",auth()->user()->id) + ->orWhere("cm.sender_id",auth()->user()->id) + ->groupEnd(); + return $query->groupBy('chatMessageId'); } public function createNewDirectChat(string $title, string $message, array $users) diff --git a/ci4/app/Models/Configuracion/MaquinaModel.php b/ci4/app/Models/Configuracion/MaquinaModel.php index 74e96cb7..616a5b1b 100755 --- a/ci4/app/Models/Configuracion/MaquinaModel.php +++ b/ci4/app/Models/Configuracion/MaquinaModel.php @@ -54,6 +54,7 @@ class MaquinaModel extends \App\Models\BaseModel "user_created_id", "user_updated_id", "etiqueta_envio", + "alias_ot", ]; protected $returnType = "App\Entities\Configuracion\Maquina"; @@ -149,6 +150,10 @@ class MaquinaModel extends \App\Models\BaseModel "label" => "Maquinas.velocidadCorte", "rules" => "decimal", ], + "alias_ot" => [ + "label" => "Maquinas.alias_ot", + "rules" => "trim|max_length[255]", + ], ]; protected $validationMessages = [ @@ -196,6 +201,9 @@ class MaquinaModel extends \App\Models\BaseModel "max_length" => "Maquinas.validation.nombre.max_length", "required" => "Maquinas.validation.nombre.required", ], + "alias_ot" => [ + "max_length" => "Maquinas.validation.alias.max_length" + ], "observaciones" => [ "max_length" => "Maquinas.validation.observaciones.max_length", //"required" => "Maquinas.validation.observaciones.required", diff --git a/ci4/app/Services/ProductionService.php b/ci4/app/Services/ProductionService.php index 0105df94..8b0ec7e6 100755 --- a/ci4/app/Services/ProductionService.php +++ b/ci4/app/Services/ProductionService.php @@ -84,6 +84,7 @@ class ProductionService extends BaseService * @var string */ public string $statusColor; + public int $guillotinaMaquinaId; /** * Valor límite del POD * @@ -212,6 +213,7 @@ class ProductionService extends BaseService $this->statusColor = $this->ordenTrabajoConfig->OT_COLORS["sin_imprimir"]; $this->configVariableModel = model(ConfigVariableModel::class); $this->podValue = $this->configVariableModel->getVariable('POD')->value; + $this->guillotinaMaquinaId = $this->configVariableModel->getVariable('maquina_guillotina_id_default')->value; $this->OT_TAREA_STATUS_TITLE = [ "P" => lang('Produccion.tarea_estados.P'), "F" => lang('Produccion.tarea_estados.F'), @@ -368,6 +370,8 @@ class ProductionService extends BaseService $this->storeOrdenTrabajoManipuladoTareas(); // $this->storeOrdenTrabajoPreimpresionTareas(); $this->storeOrdenTrabajoEncuadernacionTareas(); + $this->storeTareaCorteFinal(); + // $this->storeOrdenTrabajoExtraTareas(); } /** @@ -408,10 +412,36 @@ class ProductionService extends BaseService $ot_tareas["tiempo_real"] = 0; $insert_query_result = $this->otTarea->insert($ot_tareas); $ot_tareas = []; + $this->storeTareaCorteBloque($p_linea); $this->storeTareaCorte($p_linea); } return $insert_query_result; } + /** + * Inserta una tarea de corte si la impresion es en `rotativa` + * + * @return OrdenTrabajoTareaEntity|null + */ + protected function storeTareaCorteFinal(): ?OrdenTrabajoTareaEntity + { + + $presupuestoLineaImpresion = $this->presupuesto->presupuestoLineaImpresion(); + $data = [ + 'orden_trabajo_id' => $this->ot->id, + 'presupuesto_linea_id' => $presupuestoLineaImpresion->id, + 'nombre' => lang('Produccion.end_cut'), + 'maquina_id' => $this->defaultMaquinaCorte->id, + 'orden' => $this->defaultMaquinaCorte->orden_planning, + 'tiempo_estimado' => 0, + 'tiempo_real' => 0, + 'is_corte' => true, + 'tipo_corte' => "bobina", + ]; + $tareaId = $this->otTarea->insert($data); + $otCorte = $this->otTarea->find($tareaId); + return $otCorte; + } + /** * Inserta una tarea de corte si la impresion es en `rotativa` * @@ -421,23 +451,64 @@ class ProductionService extends BaseService protected function storeTareaCorte(PresupuestoLineaEntity $pLinea): ?OrdenTrabajoTareaEntity { $otCorte = null; + $presupuestoTipo = $this->presupuesto->tipo_presupuesto()->codigo; + $isRusticaFresado = str_contains($presupuestoTipo, "Fresado"); + $data = [ + 'orden_trabajo_id' => $this->ot->id, + 'presupuesto_linea_id' => $pLinea->id, + 'nombre' => 'Corte', + 'maquina_id' => $this->guillotinaMaquinaId, + 'orden' => $pLinea->maquina()->orden_planning + 1, + 'tiempo_estimado' => $pLinea->rotativa_tiempo_corte * 60, + 'tiempo_real' => 0, + 'is_corte' => true, + 'tipo_corte' => "prep", + ]; + if ($pLinea->isCubierta()) { + $data['nombre'] = lang('Produccion.cover_cut'); + $tareaId = $this->otTarea->insert($data); + $otCorte = $this->otTarea->find($tareaId); + } + if ($pLinea->isImpresionInteriorPlana() || $pLinea->isRotativa()) { + $data['nombre'] = lang('Produccion.interior_cut'); + //* Si es rustica fresado y rotativa no se añade preparación de interior en guillotina + if (!$isRusticaFresado && !$pLinea->isRotativa()) { + $tareaId = $this->otTarea->insert($data); + $otCorte = $this->otTarea->find($tareaId); + return $otCorte; + } + } + return $otCorte; + } + + /** + * Inserta una tarea de corte a bloque + * Se añade después de una tarea de impresión interior en rotativa. + * + * + * @param PresupuestoLineaEntity $pLinea + * @return OrdenTrabajoTareaEntity|null + */ + protected function storeTareaCorteBloque(PresupuestoLineaEntity $pLinea) + { + $otCorte = null; + $name = $this->cosido() ? lang('Produccion.hunkeler') : lang('Produccion.tecnau'); if ($pLinea->isRotativa()) { $tareaId = $this->otTarea->insert([ 'orden_trabajo_id' => $this->ot->id, 'presupuesto_linea_id' => $pLinea->id, - 'nombre' => 'Corte', + 'nombre' => $name, 'maquina_id' => $this->defaultMaquinaCorte->id, - 'orden' => $this->defaultMaquinaCorte->orden_planning, + 'orden' => $pLinea->maquina()->orden_planning + 1, 'tiempo_estimado' => $pLinea->rotativa_tiempo_corte * 60, 'tiempo_real' => 0, 'is_corte' => true, - 'tipo_corte' => "bobina", + 'tipo_corte' => "bloque", ]); $otCorte = $this->otTarea->find($tareaId); } return $otCorte; } - /** * General las tareas de acabado segun las líneas de presupuesto_acabados * @@ -1329,7 +1400,7 @@ class ProductionService extends BaseService public function tareaUpdateMaquinaCorte($orden_trabajo_id): bool { $cvm = model(ConfigVariableModel::class); - $otTarea = $this->otTarea->where('orden_trabajo_id', $orden_trabajo_id)->where('is_corte', true)->first(); + $otTarea = $this->otTarea->where('orden_trabajo_id', $orden_trabajo_id)->where('is_corte', true)->whereIn('tipo_corte', ['bobina', 'guillotina'])->first(); $toggleCorte = "bobina"; if ($otTarea->tipo_corte == "bobina") { $maquina_id = $cvm->where('name', "id_maquina_guillotina_corte_ot_tarea")->first()["value"]; diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/maquinas/_maquinaFormItems.php b/ci4/app/Views/themes/vuexy/form/configuracion/maquinas/_maquinaFormItems.php index 2b64ba70..cc027ddb 100755 --- a/ci4/app/Views/themes/vuexy/form/configuracion/maquinas/_maquinaFormItems.php +++ b/ci4/app/Views/themes/vuexy/form/configuracion/maquinas/_maquinaFormItems.php @@ -6,6 +6,13 @@ + +
+ +