diff --git a/app/Http/Controllers/ProjectoDatacontroller.php b/app/Http/Controllers/ProjectoDatacontroller.php index 612ed13a..5398deb1 100755 --- a/app/Http/Controllers/ProjectoDatacontroller.php +++ b/app/Http/Controllers/ProjectoDatacontroller.php @@ -42,11 +42,57 @@ class ProjectoDatacontroller extends Controller { + public function completedEquipmentInProject(Request $request) + { + + //Busca a ultima ocorrencia ou seja o ultima dado criado para deste equipamento para a obra atual. + $equipmentHistoryDetails = EquipmentWorkHistory::where('equipment_id', $request->equipment_id) + ->where('company_projects_id', $request->company_projects_id) + ->orderBy('equipmentWorkHistorys_id', 'desc') // Correct method for descending order + ->first(); + + //Atualiza para o equipamento ir para os concluidos, mesmo sem fazer as tarefas. + $equipmentHistoryDetails->equipment_status_project = 1; + $equipmentHistoryDetails->justification_for_finalization = $request->reason; + $equipmentHistoryDetails->save(); + + //Recebe todas as tarefas ja feitas neste equipamento + $receiveTaskOfControl = ControlEquipmentWorkstation::where('equipmentWorkHistorys_id', $equipmentHistoryDetails->equipmentWorkHistorys_id) + ->whereNotNull('departure_date') + ->where('status', '1') + ->get(); + + //recebe todas as tarefas previamente associadas + $receiveAllTasksForEquipmentHistory = OrderEquipmentTasks::where('equipmentWorkHistorys_id', $equipmentHistoryDetails->equipmentWorkHistorys_id)->get(); + + + // Colete todos os 'elemental_tasks_id' da variável $receiveTaskOfControl + $taskControlIds = $receiveTaskOfControl->pluck('elemental_tasks_id')->toArray(); + + // Filtre as tarefas em $receiveAllTasksForEquipmentHistory que NÃO estão em $taskControlIds + $tasksToDelete = $receiveAllTasksForEquipmentHistory->filter(function ($task) use ($taskControlIds) { + return !in_array($task->elemental_tasks_id, $taskControlIds); + }); + + // Deleta as tarefas não correspondentes + if ($tasksToDelete->isNotEmpty()) { + OrderEquipmentTasks::whereIn('id', $tasksToDelete->pluck('id'))->delete(); + } + + // Voltar home da Obra em execussao + return redirect()->route('ExecutionProject', ['projectID' => $equipmentHistoryDetails->company_projects_id]) + ->with('success', 'Equipamento ' . $equipmentHistoryDetails->equipment->equipment_tag . 'foi alterado para "Concluido"'); + + } + public function createPDFforcompletedEquipment($equipmentId) { + //Busca os detalhes do equipamento $detailsEquipmentWorkHistory = EquipmentWorkHistory::where('equipment_id', $equipmentId)->first(); + //Busca os detalhes do equipamento $detailsEquipment = Equipment::where('equipment_id', $equipmentId)->first(); + // Inicializa o array para armazenar os atributos específicos $specificAttributesArray = []; @@ -73,8 +119,6 @@ public function createPDFforcompletedEquipment($equipmentId) // Atribui o array de 'SpecificAttributes' ao modelo usando o método 'setAttribute' $detailsEquipment->setAttribute('specificAttributes', $specificAttributesArray); - // dd($detailsEquipment); - // Recebe apenas as tarefas já feitas $completedTasksHistory = ControlEquipmentWorkstation::with('workstationsTaskAnswers', 'receiveImages') ->where('equipmentWorkHistorys_id', $detailsEquipmentWorkHistory->equipmentWorkHistorys_id) @@ -103,8 +147,8 @@ public function createPDFforcompletedEquipment($equipmentId) $latestDate = null; } - // Apos receber todas as tarefas deve verificar qual o ambito atual e comparar em qual ambito foram feitas as tarefas, ai sim verificar oque foi feito no Ambito antigo e oque foi feito no atual. + // Apos receber todas as tarefas deve verificar qual o ambito atual e comparar em qual ambito foram feitas as tarefas, ai sim verificar oque foi feito no Ambito antigo e oque foi feito no atual. // histórico de âmbitos por time_change_ambit do mais antigo ao mais recente $receiveAmbitHistory = HistoryOfEquipmentAmbitsInTheProject::where('equipmentWorkHistorys_id', $detailsEquipmentWorkHistory->equipmentWorkHistorys_id) ->orderBy('time_change_ambit', 'desc') @@ -125,21 +169,27 @@ public function createPDFforcompletedEquipment($equipmentId) // Contador para a ordem dos âmbitos $ambitCounter = 1; + + // Itera sobre cada âmbito anterior foreach ($receiveAmbitHistory as $index => $ambitHistory) { $ambitId = $ambitHistory->history_of_equipment_ambits_id; + // Verifica se há tarefas associadas a esse âmbito if ($tasksByAmbit->has($ambitId)) { $tasksForAmbit = $tasksByAmbit->get($ambitId); + foreach ($tasksForAmbit as $taskHistory) { if ($ambitId == $latestAmbitHistory->history_of_equipment_ambits_id) { + // Se a tarefa pertence ao último âmbito (mais recente) $taskHistory->cardTypeStyle = 'gray'; $taskHistory->typeStatusHistory = 'historic'; } else { + // Se a tarefa pertence a âmbitos anteriores $taskHistory->cardTypeStyle = 'blue'; $taskHistory->AmbitHistoryTimeChange = $ambitHistory->time_change_ambit; @@ -154,8 +204,10 @@ public function createPDFforcompletedEquipment($equipmentId) } } + // $workstationTaskAnswer = $taskHistory->workstationsTaskAnswers->first(); + if ($workstationTaskAnswer && $workstationTaskAnswer->answer_json) { $answersArray = json_decode($workstationTaskAnswer->answer_json, true); $formattedAnswers = []; @@ -191,6 +243,7 @@ public function createPDFforcompletedEquipment($equipmentId) return $group->sortByDesc('departure_date')->first(); }); + // Define os caminhos das logos- Simbolo ISPT_4.0 $defaultLogoPath = '/img/ispt/4.0/Ispt4.0_Símbolo_Fundo_Azul-Marinho@2x-100.jpg'; @@ -226,16 +279,13 @@ public function createPDFforcompletedEquipment($equipmentId) ]); } } - //Precisamos receber o Tipo de equipamento e detalhes da Obra, alem do atributos especificos de acordo com o tipo de equipamento. - // Converte as imagens para base64 usando o serviço PdfWrapper $pdfWrapper = new PdfWrapper(); // Gera e retorna o PDF return $pdfWrapper - // ->setIncludePath('$PATH:/usr/bin') ->loadView('projectsClients.pdf.testePdf', [ diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index b693b25d..680cf9f2 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -1,6 +1,6 @@ { - "name": "ispt4.0_erros (copy)", - "lockfileVersion": 2, + "name": "ispt4.0_Laravel", + "lockfileVersion": 3, "requires": true, "packages": { "node_modules/@babel/code-frame": { diff --git a/package-lock.json b/package-lock.json index 1c9e3342..8ce594d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "ispt4.0_erros (copy)", + "name": "ispt4.0_Laravel", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/public/receiveImagesControlEquipmentWorkstation/2600_4098/img1.png b/public/receiveImagesControlEquipmentWorkstation/2600_4098/img1.png new file mode 100644 index 00000000..50975d14 Binary files /dev/null and b/public/receiveImagesControlEquipmentWorkstation/2600_4098/img1.png differ diff --git a/resources/views/projectsClients/pdf/testePdf.blade.php b/resources/views/projectsClients/pdf/testePdf.blade.php index 5d614fe1..62873a06 100644 --- a/resources/views/projectsClients/pdf/testePdf.blade.php +++ b/resources/views/projectsClients/pdf/testePdf.blade.php @@ -1,100 +1,9 @@ -{{-- @php - $pageCounter = 1; - @endphp - - - - - @foreach ($receiveAllTasksHistiory as $task_todo) -
- - -
- @include('components.elemental-tasks', ['task_todo' => $task_todo]) -
-
-
- @if (isset($taskImages[$task_todo->control_equipment_workstation_id]) && is_array($taskImages[$task_todo->control_equipment_workstation_id])) -
- @foreach ($taskImages[$task_todo->control_equipment_workstation_id] as $image) -
- Image -
- @endforeach -
- @endif -
- - @php - $pageCounter++; - @endphp - @endforeach - -
--}} - - - - -{{-- - - @php - $pageCounter = 1; - @endphp - - @foreach ($receiveAllTasksHistiory as $task_todo) -
- -
-
- @include( - 'projectsClients.pdf._header', - compact('tag', 'numeroPanini', 'nObra', 'ambito', 'projectLogoPath', 'companyLogoPath')) -
- -
- @include('components.elemental-tasks', ['task_todo' => $task_todo]) -
-
-
- @if (isset($taskImages[$task_todo->control_equipment_workstation_id]) && is_array($taskImages[$task_todo->control_equipment_workstation_id])) -
- @foreach ($taskImages[$task_todo->control_equipment_workstation_id] as $image) -
- Image -
- @endforeach -
- @endif -
- - -
- @php - $pageCounter++; - @endphp - @endforeach - -
--}} - @extends('components.pdf-layout') +@php + $totalPages = count($receiveAllTasksHistiory) + 1; // Add 1 for the first page +@endphp + @section('firstPage')
@@ -103,7 +12,7 @@
Company Logo + style="max-width: 150px; max-height: 150px; padding: 5px;">
@@ -123,7 +32,7 @@

OBRA Nº:N/A
FICHA Nº: {{ $detailsEquipmentWorkHistory->ispt_number }} -
FOLHA: 1 de 2 +
PAGINA : 1 de {{ $totalPages }}

@@ -141,60 +50,9 @@ - @if ($detailsEquipment->equipment_type_id == 3) - - {{-- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
I - ESPECIFICAÇÕES TÉCNICAS PSV
TAG Válvula: {{ $detailsEquipment->equipment_tag ?? 'N/A' }}Descrição: {{ $detailsEquipment->equipment_description ?? 'N/A' }}N Série: {{ $detailsEquipment->equipment_serial_number ?? 'N/A' }}Marca: {{ $detailsEquipment->equipment_brand ?? 'N/A' }}
Modelo: {{ $detailsEquipment->specificAttributes[8]['value'] ?? 'N/A' }}Dimensão: {{ $detailsEquipment->specificAttributes[8]['value'] ?? 'N/A' }}Rating: {{ $detailsEquipment->specificAttributes[17]['value'] ?? 'N/A' }}Dim Certa: {{ $detailsEquipment->specificAttributes[10]['value'] ?? 'N/A' }}
Main Equipament: {{ $detailsEquipment->specificAttributes[18]['value'] ?? 'N/A' }} - P&ID: {{ $detailsEquipment->specificAttributes[11]['value'] ?? 'N/A' }}Nº SAP: {{ $detailsEquipment->specificAttributes[12]['value'] ?? 'N/A' }}Manufacturer: {{ $detailsEquipment->specificAttributes[22]['value'] ?? 'N/A' }} -
dn_ent: {{ $detailsEquipment->specificAttributes[9]['value'] ?? 'N/A' }}dn_sai: {{ $detailsEquipment->specificAttributes[39]['value'] ?? 'N/A' }}rating_flange_mount: - {{ $detailsEquipment->specificAttributes[33]['value'] ?? 'N/A' }} - rating_flange_jusante: - {{ $detailsEquipment->specificAttributes[34]['value'] ?? 'N/A' }} -
sp_bar_cold: {{ $detailsEquipment->specificAttributes[19]['value'] ?? 'N/A' }} - back_presure_bar: - {{ $detailsEquipment->specificAttributes[20]['value'] ?? 'N/A' }} -
--}} - + @@ -213,17 +71,20 @@ + {{ $detailsEquipment->specificAttributes[10]['value'] ?? 'N/A' }} + + {{ $detailsEquipment->specificAttributes[18]['value'] ?? 'N/A' }} + + {{ $detailsEquipment->specificAttributes[22]['value'] ?? 'N/A' }} + + {{ $detailsEquipment->specificAttributes[33]['value'] ?? 'N/A' }} + + {{ $detailsEquipment->specificAttributes[34]['value'] ?? 'N/A' }} + - - + + + + + + + + +
I - ESPECIFICAÇÕES TÉCNICAS PSVRating: {{ $detailsEquipment->specificAttributes[17]['value'] ?? 'N/A' }} Dim Certa: - {{ $detailsEquipment->specificAttributes[10]['value'] ?? 'N/A' }}
Main Equipament: - {{ $detailsEquipment->specificAttributes[18]['value'] ?? 'N/A' }} P&ID: {{ $detailsEquipment->specificAttributes[11]['value'] ?? 'N/A' }} Nº SAP: {{ $detailsEquipment->specificAttributes[12]['value'] ?? 'N/A' }} Manufacturer: - {{ $detailsEquipment->specificAttributes[22]['value'] ?? 'N/A' }}
dn_ent: {{ $detailsEquipment->specificAttributes[9]['value'] ?? 'N/A' }} @@ -231,75 +92,186 @@ dn_sai: {{ $detailsEquipment->specificAttributes[39]['value'] ?? 'N/A' }} rating_flange_mount: - {{ $detailsEquipment->specificAttributes[33]['value'] ?? 'N/A' }} rating_flange_jusante: - {{ $detailsEquipment->specificAttributes[34]['value'] ?? 'N/A' }}
sp_bar_cold: - {{ $detailsEquipment->specificAttributes[19]['value'] ?? 'N/A' }}back_presure_bar: - {{ $detailsEquipment->specificAttributes[20]['value'] ?? 'N/A' }}Material: {{ $detailsEquipment->specificAttributes[9]['value'] ?? 'N/A' }} + Isolamento: + {{ $detailsEquipment->specificAttributes[39]['value'] ?? 'N/A' }} + Andaime: + {{ $detailsEquipment->specificAttributes[33]['value'] ?? 'N/A' }} + Grua: + {{ $detailsEquipment->specificAttributes[34]['value'] ?? 'N/A' }} +
sp_bar_cold: + {{ $detailsEquipment->specificAttributes[19]['value'] ?? 'N/A' }} + back_presure_bar: + {{ $detailsEquipment->specificAttributes[20]['value'] ?? 'N/A' }} +
- - @elseif($detailsEquipment->equipment_type_id == 1) - + @elseif ($detailsEquipment->equipment_type_id == 1) + - - - - + + + + - - - - + + + + - - + + + + + + + + + + + + + + + + + + + + +
I - ESPECIFICAÇÕES TÉCNICAS CV
TAG Válvula: PP.PCV-116Tipo de Atuador: LinearTipo de Válvula: ControleAtuador: RotativoTAG Válvula: {{ $detailsEquipment->equipment_tag ?? 'N/A' }}Descrição: {{ $detailsEquipment->equipment_description ?? 'N/A' }}N Série: {{ $detailsEquipment->equipment_serial_number ?? 'N/A' }}Marca: {{ $detailsEquipment->equipment_brand ?? 'N/A' }}
Fabricante da Válvula: FisherTipo de Atuador: EletroModelo da Válvula: Globo FrontalAtuador: PneumáticoModelo: {{ $detailsEquipment->specificAttributes[8]['value'] ?? 'N/A' }} + Dimensão: {{ $detailsEquipment->specificAttributes[8]['value'] ?? 'N/A' }} + Rating: {{ $detailsEquipment->specificAttributes[17]['value'] ?? 'N/A' }} + Dim Certa: + {{ $detailsEquipment->specificAttributes[10]['value'] ?? 'N/A' }} +
Modelo de Atuador: Fisher 1BMais especificações aqui...Main Equipament: + {{ $detailsEquipment->specificAttributes[18]['value'] ?? 'N/A' }} + P&ID: {{ $detailsEquipment->specificAttributes[11]['value'] ?? 'N/A' }} + Nº SAP: {{ $detailsEquipment->specificAttributes[12]['value'] ?? 'N/A' }} + Material: {{ $detailsEquipment->specificAttributes[22]['value'] ?? 'N/A' }} +
Fabricante: + {{ $detailsEquipment->specificAttributes[18]['value'] ?? 'N/A' }} + Isolamento: + {{ $detailsEquipment->specificAttributes[11]['value'] ?? 'N/A' }} + Fabricante do atuador: + {{ $detailsEquipment->specificAttributes[12]['value'] ?? 'N/A' }} + Modelo do atuador: + {{ $detailsEquipment->specificAttributes[22]['value'] ?? 'N/A' }} +
N. de série do atuador: + {{ $detailsEquipment->specificAttributes[18]['value'] ?? 'N/A' }} + Fabricante do posicionador: + {{ $detailsEquipment->specificAttributes[11]['value'] ?? 'N/A' }} + N. de série do posicionador: + {{ $detailsEquipment->specificAttributes[12]['value'] ?? 'N/A' }} + Andaime: {{ $detailsEquipment->specificAttributes[22]['value'] ?? 'N/A' }} +
Grua: {{ $detailsEquipment->specificAttributes[22]['value'] ?? 'N/A' }} + sp_bar_cold: + {{ $detailsEquipment->specificAttributes[19]['value'] ?? 'N/A' }} + back_pressure_bar: + {{ $detailsEquipment->specificAttributes[20]['value'] ?? 'N/A' }} +
- @else - + @elseif($detailsEquipment->equipment_type_id == 2) + - - - - + + + + - - - - + + + + - - + + + + + + + + + +
I - ESPECIFICAÇÕES TÉCNICAS ISV
TAG Válvula: PP.PCV-116Tipo de Atuador: LinearTipo de Válvula: ControleAtuador: RotativoTAG Válvula: {{ $detailsEquipment->equipment_tag ?? 'N/A' }}Descrição: {{ $detailsEquipment->equipment_description ?? 'N/A' }}N Série: {{ $detailsEquipment->equipment_serial_number ?? 'N/A' }}Marca: {{ $detailsEquipment->equipment_brand ?? 'N/A' }}
Fabricante da Válvula: FisherTipo de Atuador: EletroModelo da Válvula: Globo FrontalAtuador: PneumáticoModelo: {{ $detailsEquipment->specificAttributes[8]['value'] ?? 'N/A' }} + Dimensão: {{ $detailsEquipment->specificAttributes[8]['value'] ?? 'N/A' }} + Rating: {{ $detailsEquipment->specificAttributes[17]['value'] ?? 'N/A' }} + Dim Certa: + {{ $detailsEquipment->specificAttributes[10]['value'] ?? 'N/A' }} +
Modelo de Atuador: Fisher 1BMais especificações aqui...Main Equipament: + {{ $detailsEquipment->specificAttributes[18]['value'] ?? 'N/A' }} + P&ID: {{ $detailsEquipment->specificAttributes[11]['value'] ?? 'N/A' }} + Nº SAP: {{ $detailsEquipment->specificAttributes[12]['value'] ?? 'N/A' }} + Material: + {{ $detailsEquipment->specificAttributes[22]['value'] ?? 'N/A' }} +
Fabricante: + {{ $detailsEquipment->specificAttributes[18]['value'] ?? 'N/A' }} + Isolamento: + {{ $detailsEquipment->specificAttributes[11]['value'] ?? 'N/A' }} + Andaime: {{ $detailsEquipment->specificAttributes[12]['value'] ?? 'N/A' }} + Grua: + {{ $detailsEquipment->specificAttributes[22]['value'] ?? 'N/A' }} +
@endif -
-
+ + @endsection @section('loopPages') + + @php + $pageCounter = 2; // Start from page 2, assuming the first page is already handled + @endphp + @foreach ($receiveAllTasksHistiory as $task_todo)
@@ -335,8 +323,7 @@
@include('components.elemental-tasks', ['task_todo' => $task_todo]) - @if (isset($taskImages[$task_todo->control_equipment_workstation_id]) && - is_array($taskImages[$task_todo->control_equipment_workstation_id])) + @if (isset($taskImages[$task_todo->control_equipment_workstation_id]) && is_array($taskImages[$task_todo->control_equipment_workstation_id]))
@foreach ($taskImages[$task_todo->control_equipment_workstation_id] as $image)
@@ -352,15 +339,20 @@ + + @php + $pageCounter++; // Increment the page counter for each iteration + @endphp @endforeach + @endsection diff --git a/resources/views/projectsClients/showAmbitDetailProjectHistory.blade.php b/resources/views/projectsClients/showAmbitDetailProjectHistory.blade.php index 3a41ae30..84be8236 100644 --- a/resources/views/projectsClients/showAmbitDetailProjectHistory.blade.php +++ b/resources/views/projectsClients/showAmbitDetailProjectHistory.blade.php @@ -24,10 +24,6 @@
- - {{-- receiveComments --}} - -

Comentários sobre o Equipamento

@@ -143,9 +139,9 @@ class="fas fa-plus">
-
+ @foreach ($receiveAllTasksHistiory as $elemental_tasks_id => $tasks) @if (!empty($tasks['latest'])) @php @@ -153,12 +149,12 @@ class="fas fa-plus"> @endphp @include('components.elemental-tasks', ['task_todo' => $task_todo]) - @endif @endforeach + {{-- ESTA modal recebe corretamento os historicos para cada tarefa ja executada, porem a questao e que da forma que esta atualmente se tirar de comentario, os valores do tipo radio simplemente não aparecem --}} - + {{--
--}} - +
- - - - - - - -
+ + + +
diff --git a/routes/web.php b/routes/web.php index 1d130c7a..cfa1bc15 100755 --- a/routes/web.php +++ b/routes/web.php @@ -67,6 +67,7 @@ Route::get('showAllEquipmentsInProjectForQrCode/{projectId}', [PreparedProjectController::class, 'showAllEquipmentsInProjectForQrCode'])->name('showAllEquipmentsInProjectForQrCode'); +Route::post('completedEquipmentInProject',[ProjectoDatacontroller::class,'completedEquipmentInProject'])->name('completedEquipmentInProject'); Route::get('testRelatorio', [ProjectoDatacontroller::class, 'testRelatorio'])->name('testRelatorio');