diff --git a/.env b/.env index 9f849a3c..7b1c55aa 100755 --- a/.env +++ b/.env @@ -18,7 +18,7 @@ DB_PORT=3306 # Alteracoes para funcionar com o servidor, porem não funciona na firma DB_HOST=ispt-innovation.com -DB_DATABASE=ispt40_version01_BK +DB_DATABASE=ispt40_version01 DB_USERNAME=ispt40 DB_PASSWORD=qu3ro3ntr@r diff --git a/app/Http/Controllers/CreateProjectController.php b/app/Http/Controllers/CreateProjectController.php index 7dc7ab0e..b7a3963d 100755 --- a/app/Http/Controllers/CreateProjectController.php +++ b/app/Http/Controllers/CreateProjectController.php @@ -438,6 +438,11 @@ public function finishCreatingProject($numberProject) // Recebe todos os dados dos postos de Trabalho $receiveWorkstaions = ConstructionWorkstation::where('company_projects_id', $numberProject)->get(); + // Verifica se a coleção está vazia + if ($receiveWorkstaions->isEmpty()) { + return redirect()->back()->with('danger', 'Nenhum posto foi criado ainda..'); + } + foreach ($receiveWorkstaions as $workstation) { // Verifica se o ID da workstation está presente na tabela WorkstationsAssociationTasks $exists = WorkstationsAssociationTasks::where('id_workstations', $workstation->id_workstations)->exists(); @@ -689,10 +694,10 @@ public function createWorkStations(Request $request) //Apos criar a Workstation vamos criar um login para pode aceder os postos de trabalho na obra $loginWorkStation = new User; $loginWorkStation->user_name = $workstation->name_workstations; - $loginWorkStation->email = $receveProjectCompanyNumber->project_company_name . '-' . $receiveNumberWorkstation . '@isptgroup.com'; - $loginWorkStation->password = bcrypt($receveProjectCompanyNumber->project_company_name . '-' . $receiveNumberWorkstation); + $loginWorkStation->email = $receveProjectCompanyNumber->company_projects_id . '-' . $receiveNumberWorkstation . '@isptgroup.com'; + $loginWorkStation->password = bcrypt($receveProjectCompanyNumber->company_projects_id . '-' . $receiveNumberWorkstation); $loginWorkStation->type_users = 5; - $loginWorkStation->user_nif = $receveProjectCompanyNumber->project_company_name . '-' . $receiveNumberWorkstation; + $loginWorkStation->user_nif = $receveProjectCompanyNumber->company_projects_id . '-' . $receiveNumberWorkstation; $loginWorkStation->save(); } @@ -730,7 +735,7 @@ public function showStep1($company_projects_id) $receiveCompanyManager = ''; $receiveCompanyManagerID = null; // Inicialize com null ou um valor padrão apropriado - + // Se o project_company_responsible for igual a null, significa que ainda não foi definido após a criação da Obra. // Se foi definido, deve buscar o nome do User atribuído. if ($projects->project_company_responsible === null) { @@ -1321,13 +1326,13 @@ function normalize($value) 'typePendingLog' => 1, 'duplicate_line' => $i + 1, 'original_line' => $uniqueRowsHashmap[$key] + 1, - 'reason' => 'Duplicata no Excel - (Original Line '. $uniqueRowsHashmap[$key] + 1 .') referente aos campos: ' . $columnRealNames[0] . ' e ' . $columnRealNames[1] . '.' + 'reason' => 'Duplicata no Excel - (Original Line ' . $uniqueRowsHashmap[$key] + 1 . ') referente aos campos: ' . $columnRealNames[0] . ' e ' . $columnRealNames[1] . '.' ]; //este e criado apenas para o PendingEquipment a indicar a reason de sua criacao. $pending_equipment_creation_log = [ 'excel_Name' => $originalFileName, - 'reason' => 'Duplicata no Excel - (Original Line '. $uniqueRowsHashmap[$key] + 1 .') referente aos campos: ' . $columnRealNames[0] . ' e ' . $columnRealNames[1] . '.(Duplicate Line ' .$i + 1 .')' + 'reason' => 'Duplicata no Excel - (Original Line ' . $uniqueRowsHashmap[$key] + 1 . ') referente aos campos: ' . $columnRealNames[0] . ' e ' . $columnRealNames[1] . '.(Duplicate Line ' . $i + 1 . ')' ]; $pendingEquipament = new PendingEquipment; @@ -1447,7 +1452,7 @@ function normalize($value) $countEquipment++; //Deve adicionar tambem os outros atributos espesificos para o equipameto. - + //Criar o equipment Work History $newEquipmentWorkHistory = new EquipmentWorkHistory; @@ -1825,4 +1830,40 @@ public function getAttributes($id) $equipment = Equipment::with('specificAttributes')->find($id); return response()->json($equipment->specificAttributes); } + + public function removingElementalTasksFromProject(Request $request) + { + + $receiveAllEquipmentWorkHistory = EquipmentWorkHistory::where('company_projects_id', $request->numberProject) + ->where('equipment_status_project', 0) + ->get(); + $equipmentWorkHistoryIds = $receiveAllEquipmentWorkHistory->pluck('equipmentWorkHistorys_id')->toArray(); + + + $tasksToDelete = $request->tasks; // IDs das tarefas a serem deletadas vindo do request. + + // Loop através dos IDs de EquipmentWorkHistory + foreach ($equipmentWorkHistoryIds as $historyId) { + // Recuperar todas as tarefas associadas ao EquipmentWorkHistory atual + $tasks = OrderEquipmentTasks::where('equipmentWorkHistorys_id', $historyId)->get(); + + // Filtrar e deletar as tarefas que estão no array $tasksToDelete + $filteredTasks = $tasks->whereIn('elemental_tasks_id', $tasksToDelete); + OrderEquipmentTasks::destroy($filteredTasks->pluck('id')); // Deletar tarefas filtradas + + // Recuperar novamente as tarefas restantes após a exclusão para reordenar + $remainingTasks = OrderEquipmentTasks::where('equipmentWorkHistorys_id', $historyId) + ->orderBy('execution_order') + ->get(); + + // Reordenar as execution_order das tarefas restantes + foreach ($remainingTasks as $index => $task) { + $task->execution_order = $index + 1; // Ajustar a execution_order baseada no índice + $task->save(); // Salvar as mudanças + } + } + return back()->with('success','Tarefas removidas de todos os equipamentos com sucesso !!'); + + } + } diff --git a/app/Http/Middleware/CheckUserType.php b/app/Http/Middleware/CheckUserType.php index a5971054..0ace13ca 100755 --- a/app/Http/Middleware/CheckUserType.php +++ b/app/Http/Middleware/CheckUserType.php @@ -79,7 +79,7 @@ protected function getAllowedRoutesForUserType($userType) 'createCompany','ShowPendingUser','register','download','projectDetails_11','editEquipment','EditprocessStep1','createWorkStations','workstationsAssociationTasks','finishCreatingProject', 'preparedProject','EditProjectForArticulated','companyEdit','reportingDataClient','ExecutionProject', 'changeFromExecutionToPlanning','deleteWorkstation','deleteProject','showQrcodesInProject','showDataDetailsProjectClient', - 'getDataAmbitsOfProject', 'showReportingForAmbitsProject','getEquipmentsOfAmbit','getDataEquipmentsOfProject', + 'getDataAmbitsOfProject', 'showReportingForAmbitsProject','getEquipmentsOfAmbit','getDataEquipmentsOfProject','removingElementalTasksFromProject', ]; diff --git a/resources/views/projectsClients/testRoute.blade.php b/resources/views/projectsClients/testRoute.blade.php index 567d71b7..3b981dc4 100644 --- a/resources/views/projectsClients/testRoute.blade.php +++ b/resources/views/projectsClients/testRoute.blade.php @@ -723,7 +723,7 @@ class="form-control card_inputs" id="isolation"
Mais + href="{{ route('showAmbitDetailsProjectHistory', ['equipmentStatus'=>2,'projectID' => $detailsEquipmentWorkHistory->company_projects_id, 'equipmentID' => $dataEquipment->equipment_id]) }}">Mais Detalhes
@@ -1337,7 +1337,7 @@ class="form-control card_inputs" id="isolationEquipment"
Mais + href="{{ route('showAmbitDetailsProjectHistory', ['equipmentStatus'=>2,'projectID' => $detailsEquipmentWorkHistory->company_projects_id, 'equipmentID' => $dataEquipment->equipment_id]) }}">Mais Detalhes
@@ -2135,7 +2135,7 @@ class="form-control card_inputs"
Mais + href="{{ route('showAmbitDetailsProjectHistory', ['equipmentStatus'=>2,'projectID' => $detailsEquipmentWorkHistory->company_projects_id, 'equipmentID' => $dataEquipment->equipment_id]) }}">Mais Detalhes
diff --git a/resources/views/projectsClients/workStation_3.blade.php b/resources/views/projectsClients/workStation_3.blade.php index cd2cbf88..6fb38cf2 100755 --- a/resources/views/projectsClients/workStation_3.blade.php +++ b/resources/views/projectsClients/workStation_3.blade.php @@ -14,6 +14,19 @@ @endif + @if (session('danger')) + + + @endif + @if (session('errors')) @php $allMissingTasks = session('errors'); @@ -49,13 +62,16 @@ class="fas fa-minus"> @endforeach - + {{-- ./card card-danger --}} @endif + {{-- ./row --}} - @if (count($allMissingTasks['elemental']) > 0) +
+ + {{-- @if (count($allMissingTasks['elemental']) > 0)
@@ -76,9 +92,67 @@ class="fas fa-minus"> @endforeach
-
{{-- ./card card-danger --}} +
- @endif + @endif --}} +
+
+ @csrf + + @if (count($allMissingTasks['elemental']) > 0) +
+
+

Tarefas elementares não atribuídas - (Seleciona para remover da obra, se necessário)

+
+ +
+
+
+
    + @foreach ($allMissingTasks['elemental'] as $taskId => $taskDetails) +
  • +
    + + {{ $taskDetails['code'] }} - {{ $taskDetails['description'] }} +
    + +
  • + @endforeach +
+
+ + +
+ @endif +
+ + +
+ + + + @if (count($allMissingTasks['further']) > 0)
@@ -103,17 +177,12 @@ class="fas fa-minus">
{{-- ./card card-danger --}}
@endif - {{-- ./row --}} + - {{-- --}} + @endif @@ -157,16 +226,16 @@ class="fas fa-minus">
-
- +
@@ -238,8 +307,7 @@ class="btn btn-primary previous float-left mb-3">Articulado {{-- ./content --}} @foreach ($listWorkstations as $listWorkstation) - - @livewire('articulado.select-elemental-tasks-in-wonkstation', ['workstation' => $listWorkstation, 'key' => $listWorkstation->id_workstations]) + @livewire('articulado.select-elemental-tasks-in-wonkstation', ['workstation' => $listWorkstation, 'key' => $listWorkstation->id_workstations]) {{-- modal-remover --}} diff --git a/routes/web.php b/routes/web.php index df716b6e..42faf717 100755 --- a/routes/web.php +++ b/routes/web.php @@ -260,7 +260,8 @@ Route::post('CreateNewEquipmentFromPendingEquipment/{id}', 'CreateNewEquipmentFromPendingEquipment')->name('CreateNewEquipmentFromPendingEquipment'); Route::post('create-equipament-project', 'createEquipamentProject')->name('createEquipamentProject'); Route::get('equipments/{id}/attributes', 'getAttributes'); - + Route::post('removingElementalTasksFromProject','removingElementalTasksFromProject')->name('removingElementalTasksFromProject'); + /* |-------------------------------------------------------------------------- | Template Excel