diff --git a/app/Http/Controllers/LanguageController.php b/app/Http/Controllers/LanguageController.php new file mode 100644 index 00000000..acae3ed8 --- /dev/null +++ b/app/Http/Controllers/LanguageController.php @@ -0,0 +1,21 @@ +input('locale'); + + if (!in_array($locale, ['en', 'pt'])) { + abort(400); + } + + session(['locale' => $locale]); + return redirect()->back(); + } +} diff --git a/app/Http/Controllers/WorkstationsJobsController.php b/app/Http/Controllers/WorkstationsJobsController.php index b7b11c6f..a739e030 100644 --- a/app/Http/Controllers/WorkstationsJobsController.php +++ b/app/Http/Controllers/WorkstationsJobsController.php @@ -16,7 +16,8 @@ class WorkstationsJobsController extends Controller { public function receiveAnswersEquipment(Request $request) - { + { + // Primeiro ele deve criar a associação entre id atual do control + perguntas e respostas $receiveAnswersElementalTasks = new workstationsTaskAnswers; $receiveAnswersElementalTasks->control_equipment_workstation_id = $request->control_equipment_workstationid; @@ -49,7 +50,7 @@ public function receiveAnswersEquipment(Request $request) // Armazenando a string JSON no banco de dados $receiveAnswersElementalTasks->answer_json = $jsonString; - // $receiveAnswersElementalTasks->save(); + $receiveAnswersElementalTasks->save(); // update departure_date value $receiveDataControlWs = ControlEquipmentWorkstation::find($request->control_equipment_workstationid); @@ -92,9 +93,7 @@ public function receiveAnswersEquipment(Request $request) $elemental_tasks_id = null; $further_tasks_id = $next_todo; } - // dd($recebeDataControlId->id_workstations ); - - + if ($request->stateEquipment == "cancel") { $deleteDataControlWhereRefreashPage = ControlEquipmentWorkstation::where('id_workstations', $receiveDataControlWs->id_workstations) ->where('equipment_id', $receiveDataEquipment->equipment_id) @@ -297,7 +296,57 @@ public function getEquipmentData($equipment_id) 'task_todo' => $controlEquipmentWorkstation->elemental_tasks_id ]); } else + // Busca as tarefas do Equipamento a serem feitas + $equipmentTasks = DB::table('users as u') + ->join('construction_workstations as cw', 'u.user_name', '=', 'cw.name_workstations') + ->join('workstations_association_tasks as wat', 'cw.id_workstations', '=', 'wat.id_workstations') + ->join('equipments as e', 'wat.company_projects_id', '=', 'e.company_projects_id') + ->join('ordered_equipment_tasks as oet', 'e.equipment_id', '=', 'oet.equipment_id') + ->where('u.email', $userEmail->email) + ->select('e.equipment_id', 'e.equipment_tag', DB::raw('GROUP_CONCAT(DISTINCT COALESCE(oet.elemental_tasks_id, oet.further_tasks_id) ORDER BY oet.execution_order) AS equipment_all_tasks')) + ->groupBy('e.equipment_id', 'e.equipment_tag') + ->orderBy('e.equipment_id', 'ASC') + ->get(); + //Busca as tarefas que podem ser feitas pela WS Atual a partir do Email + $userTasks = DB::table('users as u') + ->join('construction_workstations as cw', 'u.user_name', '=', 'cw.name_workstations') + ->join('workstations_association_tasks as wat', 'cw.id_workstations', '=', 'wat.id_workstations') + ->where('u.email', $userEmail->email) + ->select('cw.id_workstations', 'cw.name_workstations', DB::raw('GROUP_CONCAT(COALESCE(wat.elemental_tasks_id, wat.further_tasks_id)) AS all_tasks')) + ->groupBy('cw.id_workstations', 'cw.name_workstations') + ->get(); + + // Convertendo as tarefas do usuário em um array + $tasksArray = explode(',', $userTasks->pluck('all_tasks')->first()); + + $controlEquipmentWorkstation = ControlEquipmentWorkstation::where('equipment_id', $receiveDataEquipment->equipment_id) + ->whereIn('elemental_tasks_id', $tasksArray) + ->whereNull('id_workstations') + ->whereNull('entry_date') + ->whereNull('departure_date') + ->first(); + + // Se encontrar um dado que satisfaca as verificacoes acima deve implementar a tarefa para esta WS. + if ($controlEquipmentWorkstation) { + + $controlEquipmentWorkstation->id_workstations = $findDataWs->id_workstations; + $controlEquipmentWorkstation->entry_date = now(); + $controlEquipmentWorkstation->save(); + + $receiveDataElementalTask = ElementalTasks::find($controlEquipmentWorkstation->elemental_tasks_id); + + //Returning the values to a view "values" + return view('workstations.workstations', [ + 'receiveDataElementalTask' => $receiveDataElementalTask, + 'receiveDataEquipment' => $receiveDataEquipment, + 'control_ew_id' => $controlEquipmentWorkstation->control_equipment_workstation_id, + 'task_todo' => $controlEquipmentWorkstation->elemental_tasks_id + ]); + } else + + //cria a nova linha + $equipmentData = DB::select('CALL ManageEquipmentTasks(?, ?)', [$userEmail->email, $equipment_id]); //cria a nova linha $equipmentData = DB::select('CALL ManageEquipmentTasks(?, ?)', [$userEmail->email, $equipment_id]); diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index a237b67b..a3524b19 100755 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -36,6 +36,7 @@ class Kernel extends HttpKernel \Illuminate\View\Middleware\ShareErrorsFromSession::class, \App\Http\Middleware\VerifyCsrfToken::class, \Illuminate\Routing\Middleware\SubstituteBindings::class, + \App\Http\Middleware\Language::class, ], 'api' => [ diff --git a/app/Http/Middleware/Language.php b/app/Http/Middleware/Language.php new file mode 100644 index 00000000..4906e51a --- /dev/null +++ b/app/Http/Middleware/Language.php @@ -0,0 +1,25 @@ +setLocale(session('locale')); + } + + return $next($request); + } +} diff --git a/config/app.php b/config/app.php index 1bbd47cc..0f3e510b 100755 --- a/config/app.php +++ b/config/app.php @@ -83,9 +83,7 @@ | */ - // 'locale' => 'en', - 'locale' => 'pt', - + 'locale' => 'en', /* |-------------------------------------------------------------------------- diff --git a/resources/lang/en/messages.php b/resources/lang/en/messages.php new file mode 100644 index 00000000..187668f5 --- /dev/null +++ b/resources/lang/en/messages.php @@ -0,0 +1,140 @@ + [ + //navbarMenu + 'dashboard' => 'Dashboard', + + 'planning' => [ + 'description' => 'In planning', + 'text' => 'In planning for 2023' + ], + 'prepared' => [ + 'description' => 'Prepared', + 'text' => 'Waiting for the work to start.' + ], + 'on_going' => [ + 'description' => 'On going', + 'text' => 'Work in progress.' + ], + 'finished' => [ + 'description' => 'Finished.', + 'text' => 'Last projects 2023.' + ], + ], + + //alterar na view Portfolio + 'portfolio' => [ + 'top_view_part' => [ + 'management_assets' => 'Management assets', + 'portfolio' => 'portfolio', + 'managing_assets' => 'Managing Assets', + ], + 'change_buttons' => [ + 'create_assets' => 'Create assets', + 'asset_table' => 'Asset table', + ], + 'asset_table' => [ + ''=> '', + ], + 'users_table' => [ + 'id' => 'ID', + 'name' => 'Name', + 'email' => 'Email', + 'user_type' => 'User type', + 'actions' => [ + 'actions' => 'Actions', + 'details' => 'Details', + 'edit'=> 'Edit', + 'delete' => 'Delete' + ], + ], + ], + + 'users_listUsers' => [ + //Navbar + 'users' => 'Users', + 'companies' => 'Companies', + 'create_users' => 'Create users', + + 'top_view_part' => [ + 'companies' => 'Companies', + 'administration' => 'Administration', + 'users_table' => 'Users table', + 'companies_table' => 'Companies Table', + ], + ], + + // View : Create Users + 'pendingUsers' => [ + 'create_users' => 'Create Users', + 'administration' => 'Administration', + 'submit_form' => 'Submit Form', + 'pending_users' => 'Pending Users', + 'submit' => 'Submit', + 'table_pending_user' => [ + 'name' => 'Name', + 'email' => 'Email', + 'verify' => 'Verify' + ], + ], + + // View : createProject + 'createProject' => [ + //NavbarMenu + "create_project"=> "Create a project", + + 'project_work_details' => 'Project Work Details', + 'project_identification' => 'Project identification', + 'ispt_project_number' => 'ISPT Project Number', + 'ispt_project_manager' => 'ISPT Project Manager', + 'compan_project_manager' => 'Company Project Manager', + //Selecionar uma empresa. + 'select_company' => [ + 'contracting_company' => 'Contracting Company', + 'select_company' => 'Select a contracting Company', + ], + //Selecionar ou criar uma instalacao + 'select_plant' => [ + 'plant' => 'Select Plant', + 'create_new_plant' => 'Create a new plant', + 'new_plant' => 'New plant', + 'plant_address' => 'Plant address', + 'select_plant' => 'Select Plant', + ], + 'company_project_number' => 'Company Project Number', + 'project_start_date' => 'Project Start Date', + ], + + + 'profile' => [ + 'show_profile' => [ + 'profile' => 'Profile', + 'full_name' => 'Full Name', + 'nif' => 'Nif', + 'email_address' => 'Email address', + 'user_type' => 'User type', + 'mobile_phone' => 'Mobile phone', + 'account_creation_date' => 'account_creation_date' + ], + 'edit_profile' => [ + 'edit_profile'=> 'Edit profile', + 'update_your_logo' => 'Update your logo', + 'image' => 'Image', + 'full_name'=> 'Full name', + 'nif' => 'Nif', + 'email_address' => 'Email address', + 'mobile_phone' => 'mobile_phone', + ], + ], + + //Botoes gerais ISPT4.0 + 'buttons' => [ + 'save' => 'save', + ], + + 'welcome' => 'Welcome to our application!', +]; diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php new file mode 100644 index 00000000..e69de29b diff --git a/resources/lang/pt/messages.php b/resources/lang/pt/messages.php new file mode 100644 index 00000000..f1b642fc --- /dev/null +++ b/resources/lang/pt/messages.php @@ -0,0 +1,136 @@ + [ + //navbarMenu + 'dashboard' => 'Dashboard', + + 'planning' => [ + 'description' => 'Em planeamento', + 'text' => 'Em planeamento de 2023' + ], + 'prepared' => [ + 'description' => 'Preparadas', + 'text' => 'Aguarda o início da obra.' + ], + 'on_going' => [ + 'description' => 'Em execução', + 'text' => 'Obra em curso.' + ], + 'finished' => [ + 'description' => 'Concluídas', + 'text' => 'Últimas obras de 2023.' + ], + + ], + + 'portfolio' => [ + 'top_view_part' => [ + 'management_assets' => 'Gestão de ativos', + 'portfolio' => 'Portefólio', + 'managing_assets' => 'Gerir ativos', + ], + 'change_buttons' => [ + 'create_assets' => 'Criar ativos', + 'asset_table' => 'Tabela de ativos', + ], + 'users_table' => [ + 'id' => 'ID', + 'name' => 'Nome', + 'email' => 'Email', + 'user_type' => 'Tipo de Utilizador', + 'actions' => [ + 'actions' => 'Ações', + 'details' => 'Detalhes', + 'edit' => 'Editar', + 'delete' => 'Excluir' + ], + + ], + ], + + 'users_listUsers' => [ + //Navbar + 'users' => 'Utilizadores', + 'companies' => 'Clientes', + 'create_users' => 'Criar Utilizadores', + + 'top_view_part' => [ + 'companies' => 'Empresas', + 'administration' => 'Administração', + 'users_table' => 'Tabela Utilizadores', + 'companies_table' => 'Tabela Empresas', + ], + ], + + // View : Create Users + 'pendingUsers' => [ + 'create_users' => 'Criar Utilizadores', + 'administration' => 'Administração', + 'submit_form' => 'Enviar Formulário', + 'pending_users' => 'Utilizadores Pendentes', + 'submit' => 'Enviar', + 'table_pending_user' => [ + 'name' => 'Nome', + 'email' => 'Email', + 'verify' => 'Verificar' + ], + ], + + // View : createProject + 'createProject' => [ + //NavbarMenu + "create_project" => "Criar obra", + + 'project_work_details' => 'Detalhes Técnicos do Projeto', + 'project_identification' => 'Identificação do projecto', + 'ispt_project_number' => 'Número do Projeto ISPT', + 'ispt_project_manager' => 'Gestor de Projeto ISPT', + 'compan_project_manager' => 'Gestor de Projeto da Empresa', + //Selecionar uma empresa. + 'select_company' => [ + 'contracting_company' => 'Empresa Contratante', + 'select_company' => 'Selecionar uma Empresa', + ], + //Selecionar ou criar uma instalacao + 'select_plant' => [ + 'plant' => 'Instalação', + 'create_new_plant' => 'Criar uma nova Instalacao', + 'new_plant' => 'Nova Instalação', + 'plant_address' => 'Morada Instalação', + 'select_plant' => 'Selecione uma Instalação', + ], + 'company_project_number' => 'Número do Projeto da Empresa', + 'project_start_date' => 'Data de Início do Projeto', + ], + + //view: usersProfiles + 'profile' => [ + 'show_profile' => [ + 'profile' => 'Perfil', + 'full_name' => 'Nome e Apelido', + 'nif' => 'Nif', + 'email_address' => 'Email', + 'user_type' => 'Tipo de utilizador', + 'mobile_phone' => 'Telemóvel', + 'account_creation_date' => 'Conta Criada em' + ], + 'edit_profile' => [ + 'update_your_logo' => 'Actualizar o seu logótipo', + 'image' => 'Imagem', + 'full_name'=> 'Nome e Apelido', + 'nif' => 'Nif', + 'email_address' => 'Email', + 'mobile_phone' => 'Telemóvel', + ], + ], + + 'buttons' => [ + 'save' => 'Guardar', + ], + + 'welcome' => 'Bem-vindo à nossa aplicação!', + // outras traduções +]; diff --git a/resources/views/Admin/CrudUsers/listCompany.blade.php b/resources/views/Admin/CrudUsers/listCompany.blade.php index 7fff767a..51a3ce1e 100755 --- a/resources/views/Admin/CrudUsers/listCompany.blade.php +++ b/resources/views/Admin/CrudUsers/listCompany.blade.php @@ -11,12 +11,12 @@
| ID | -Nome | -Tipo de Utilizador | -Ações | -{{__('messages.portfolio.users_table.id')}} | +{{__('messages.portfolio.users_table.name')}} | +{{__('messages.portfolio.users_table.email')}} | +{{__('messages.portfolio.users_table.user_type')}} | +{{__('messages.portfolio.users_table.actions.actions')}} | + @foreach ($users as $user) @@ -59,12 +59,12 @@ class="actions-btn btn btn-light circle "> - Detalhes + {{__('messages.portfolio.users_table.actions.details')}} - Editar + {{__('messages.portfolio.users_table.actions.edit')}} diff --git a/resources/views/Admin/DataManagement/manageassets.blade.php b/resources/views/Admin/DataManagement/manageassets.blade.php index aff9ae2e..f6157b6b 100755 --- a/resources/views/Admin/DataManagement/manageassets.blade.php +++ b/resources/views/Admin/DataManagement/manageassets.blade.php @@ -6,12 +6,14 @@
|---|
Dashboard
+{{ __('messages.dashboard.dashboard') }}
Criar obra
+{{ __('messages.createProject.create_project') }}
Portefólio +
{{ __('messages.portfolio.top_view_part.portfolio') }}
@@ -290,7 +324,7 @@ class="d-block">{{ Auth::user()->userType?->type_user }}Gerir Ativos
+{{ __('messages.portfolio.top_view_part.management_assets') }}
Administração +
{{ __('messages.users_listUsers.top_view_part.administration') }}
@@ -308,19 +342,19 @@ class="d-block">{{ Auth::user()->userType?->type_user }}Utilizadores
+{{ __('messages.users_listUsers.users') }}
Clientes
+{{ __('messages.users_listUsers.companies') }}
Criar Utilizadores
+{{ __('messages.users_listUsers.create_users') }}