diff --git a/app/Http/Controllers/ExecutionProjectController.php b/app/Http/Controllers/ExecutionProjectController.php index 795eef88..2a92c2df 100755 --- a/app/Http/Controllers/ExecutionProjectController.php +++ b/app/Http/Controllers/ExecutionProjectController.php @@ -6,6 +6,7 @@ use App\Models\EquipmentWorkHistory; use App\Models\Plant; use App\Models\Unit; +use App\Models\User; use Illuminate\Http\Request; use App\Models\CompanyProject; use App\Models\ConstructionWorkstation; @@ -415,6 +416,38 @@ public function enterWorkstation() return view('workstations/index'); } + // public function receiveExecutionProject($ProjectId) + // { + // $DatasProject = CompanyProject::find($ProjectId); + // $equipmentsTypes = EquipmentType::all(); + + // $receivePlant = Plant::where('plant_id', $DatasProject->plant_id)->first(); + // $receiveCompany = Company::where('company_id', $receivePlant->company_id)->first(); + + // // Busca na model User + // $filteredUsers = User::where('type_users', 5) + // ->whereRaw("SUBSTRING_INDEX(user_name, '-', -1) = ?", [$DatasProject->company_projects_id]) + // ->whereRaw("SUBSTRING_INDEX(SUBSTRING_INDEX(email, '@', 1), '-', 1) = ?", [$DatasProject->project_company_number]) + // ->get(); + + // // Adicionando a nova coluna realPassword + // $filteredUsers->map(function ($user) { + // $user->realPassword = explode('@', $user->email)[0]; + // return $user; + // }); + + // $receiveDetailsWs = ConstructionWorkstation::where('name_workstations',$filteredUsers->user_name)->get(); + + // //Deve buscar o nome do posto de trabalho tambem. + // // Retornando a view com os dados necessários + // return view('projectsClients/executionProjectNew', [ + // 'DatasProject' => $DatasProject, + // 'equipmentsTypes' => $equipmentsTypes, + // 'receiveCompany' => $receiveCompany, + // 'filteredUsers' => $filteredUsers + // ]); + // } + public function receiveExecutionProject($ProjectId) { $DatasProject = CompanyProject::find($ProjectId); @@ -423,12 +456,35 @@ public function receiveExecutionProject($ProjectId) $receivePlant = Plant::where('plant_id', $DatasProject->plant_id)->first(); $receiveCompany = Company::where('company_id', $receivePlant->company_id)->first(); - // return view('projectsClients/executionProject') - return view('projectsClients/executionProjectNew') - ->with('DatasProject', $DatasProject) - ->with('equipmentsTypes', $equipmentsTypes) - ->with('receiveCompany', $receiveCompany); + // Busca na model User + $filteredUsers = User::where('type_users', 5) + ->whereRaw("SUBSTRING_INDEX(user_name, '-', -1) = ?", [$DatasProject->company_projects_id]) + ->whereRaw("SUBSTRING_INDEX(SUBSTRING_INDEX(email, '@', 1), '-', 1) = ?", [$DatasProject->project_company_number]) + ->get(); + // Adicionando a nova coluna realPassword + $filteredUsers->map(function ($user) { + $user->realPassword = explode('@', $user->email)[0]; + return $user; + }); + + // Busca todos os workstations relevantes + $allWorkstations = ConstructionWorkstation::whereIn('name_workstations', $filteredUsers->pluck('user_name'))->get()->keyBy('name_workstations'); + + // Adicionando a nomenclatura de workstation aos usuários filtrados + $filteredUsers->map(function ($user) use ($allWorkstations) { + if (isset ($allWorkstations[$user->user_name])) { + $user->nomenclature_workstation = $allWorkstations[$user->user_name]->nomenclature_workstation; + } + return $user; + }); + // Retornando a view com os dados necessários + return view('projectsClients/executionProjectNew', [ + 'DatasProject' => $DatasProject, + 'equipmentsTypes' => $equipmentsTypes, + 'receiveCompany' => $receiveCompany, + 'filteredUsers' => $filteredUsers + ]); } public function changeFromExecutionToPlanning($projectID) diff --git a/app/Http/Controllers/PreparedProjectController.php b/app/Http/Controllers/PreparedProjectController.php index 31309c49..8db8bc52 100755 --- a/app/Http/Controllers/PreparedProjectController.php +++ b/app/Http/Controllers/PreparedProjectController.php @@ -73,98 +73,180 @@ class PreparedProjectController extends Controller // $mpdf->Output('equipamentos_projeto_' . $projectId . '.pdf', 'I'); // } + + // public function showAllEquipmentsInProjectForQrCode($projectId) + // { + // $equipments = Equipment::where('company_projects_id', $projectId)->get(); + + // $equipmentData = []; + // foreach ($equipments as $equipment) { + // $qrCode = new QrCode($equipment->equipment_tag); + // $writer = new PngWriter(); + // $qrCodeImage = 'data:image/png;base64,' . base64_encode($writer->write($qrCode)->getString()); + + // $associatedEquipments = QrcodesAssociatedEquipment::where('equipment_id', $equipment->equipment_id)->get(); + // $associatedArray = []; + // foreach ($associatedEquipments as $associatedEquipment) { + // $associatedArray[$associatedEquipment->id] = $associatedEquipment->component_tag; + // } + + // $equipmentData[] = [ + // 'equipment' => $equipment, + // 'qrCodeImage' => $qrCodeImage, + // 'associatedArray' => $associatedArray + // ]; + // } + + // $detailsCompanyProject = CompanyProject::find($projectId); + // $detailsPlant = Plant::where('plant_id', $detailsCompanyProject->plant_id)->first(); + + // $detailsCompany = Company::where('company_id', $detailsPlant->company_id)->first(); + + // $logoPath = public_path('companies_logo/' . ($detailsCompany->company_logo ?: 'logoISPT4.0.jpg')); + + // if (!file_exists($logoPath)) { + // $logoPath = public_path('companies_logo/logoISPT4.0.jpg'); + // } + + // // dd($equipmentData); + + // $html = view('projectsClients.showAllEquipmentsInProjectQrCodePdf', [ + // 'equipmentData' => $equipmentData, + // 'logoPath' => $logoPath + // ])->render(); + + // $mpdf = new \Mpdf\Mpdf([ + // 'mode' => 'utf-8', + // 'format' => 'A4' + // ]); + // $mpdf->WriteHTML($html); + // $mpdf->Output('equipamentos_projeto_' . $projectId . '.pdf', 'I'); + // } + public function showAllEquipmentsInProjectForQrCode($projectId) { $equipments = Equipment::where('company_projects_id', $projectId)->get(); - + $equipmentData = []; foreach ($equipments as $equipment) { - $qrCode = new QrCode($equipment->equipment_tag); - $writer = new PngWriter(); - $qrCodeImage = 'data:image/png;base64,' . base64_encode($writer->write($qrCode)->getString()); - $associatedEquipments = QrcodesAssociatedEquipment::where('equipment_id', $equipment->equipment_id)->get(); $associatedArray = []; + foreach ($associatedEquipments as $associatedEquipment) { - $associatedArray[$associatedEquipment->id] = $associatedEquipment->component_tag; + $qrCode = new QrCode($associatedEquipment->component_tag); + $writer = new PngWriter(); + $qrCodeImage = 'data:image/png;base64,' . base64_encode($writer->write($qrCode)->getString()); + + $associatedArray[] = [ + 'id' => $associatedEquipment->id, + 'component_tag' => $associatedEquipment->component_tag, + 'qrCodeImage' => $qrCodeImage + ]; } - + $equipmentData[] = [ 'equipment' => $equipment, - 'qrCodeImage' => $qrCodeImage, 'associatedArray' => $associatedArray ]; } - + $detailsCompanyProject = CompanyProject::find($projectId); $detailsPlant = Plant::where('plant_id', $detailsCompanyProject->plant_id)->first(); - - $detailsCompany= Company::where('company_id', $detailsPlant->company_id)->first(); - + $detailsCompany = Company::where('company_id', $detailsPlant->company_id)->first(); $logoPath = public_path('companies_logo/' . ($detailsCompany->company_logo ?: 'logoISPT4.0.jpg')); - + if (!file_exists($logoPath)) { $logoPath = public_path('companies_logo/logoISPT4.0.jpg'); } - - // dd($equipmentData); - + $html = view('projectsClients.showAllEquipmentsInProjectQrCodePdf', [ 'equipmentData' => $equipmentData, 'logoPath' => $logoPath ])->render(); - - $mpdf = new \Mpdf\Mpdf([ - 'mode' => 'utf-8', - 'format' => 'A4' - ]); + + $mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8', 'format' => 'A4']); $mpdf->WriteHTML($html); $mpdf->Output('equipamentos_projeto_' . $projectId . '.pdf', 'I'); } + + // public function showDetailsEquipmentForQrCode($equipmentId, $projectId) + // { + // $detailsEquipment = Equipment::find($equipmentId); + + // // Gera o QR Code + // $qrCode = new QrCode($detailsEquipment->equipment_tag); + // $writer = new PngWriter(); + + // // Converte o QR Code para base64 para incorporar na página + // $qrCodeImage = 'data:image/png;base64,' . base64_encode($writer->write($qrCode)->getString()); + + // $detailsCompanyProject = CompanyProject::find($projectId); + // $detailsPlant = Plant::where('plant_id', $detailsCompanyProject->plant_id)->first(); + + // $detailsCompany= Company::where('company_id', $detailsPlant->company_id)->first(); + + // $logoPath = public_path('companies_logo/' . ($detailsCompany->company_logo ?: 'logoISPT4.0.jpg')); + + // if (!file_exists($logoPath)) { + // $logoPath = public_path('companies_logo/logoISPT4.0.jpg'); + // } + + // $associatedEquipments = QrcodesAssociatedEquipment::where('equipment_id', $detailsEquipment->equipment_id)->get(); + + // $associatedArray = []; + // foreach ($associatedEquipments as $associatedEquipment) { + // $associatedArray[$associatedEquipment->id] = $associatedEquipment->component_tag; + // } + + // $html = view('projectsClients.showDetailsEquipmentForQrCodePdf', [ + // 'detailsEquipment' => $detailsEquipment, + // 'logoPath' => $logoPath, + // 'qrCodeImage' => $qrCodeImage, + // 'associatedArray' => $associatedArray + // ])->render(); + + // // Define a orientação da folha como horizontal (Landscape) + // $mpdf = new \Mpdf\Mpdf([ + // 'mode' => 'utf-8', + // 'format' => 'A4' // Define o formato como A4 e orientação como Landscape (horizontal) + // ]); + // $mpdf->WriteHTML($html); + // $mpdf->Output('nome_do_arquivo.pdf', 'I'); + // } + public function showDetailsEquipmentForQrCode($equipmentId, $projectId) { $detailsEquipment = Equipment::find($equipmentId); - - // Gera o QR Code - $qrCode = new QrCode($detailsEquipment->equipment_tag); - $writer = new PngWriter(); - - // Converte o QR Code para base64 para incorporar na página - $qrCodeImage = 'data:image/png;base64,' . base64_encode($writer->write($qrCode)->getString()); - $detailsCompanyProject = CompanyProject::find($projectId); $detailsPlant = Plant::where('plant_id', $detailsCompanyProject->plant_id)->first(); - - $detailsCompany= Company::where('company_id', $detailsPlant->company_id)->first(); - + $detailsCompany = Company::where('company_id', $detailsPlant->company_id)->first(); $logoPath = public_path('companies_logo/' . ($detailsCompany->company_logo ?: 'logoISPT4.0.jpg')); if (!file_exists($logoPath)) { $logoPath = public_path('companies_logo/logoISPT4.0.jpg'); } - $associatedEquipments = QrcodesAssociatedEquipment::where('equipment_id', $detailsEquipment->equipment_id)->get(); - $associatedArray = []; + $qrCodeImages = []; + foreach ($associatedEquipments as $associatedEquipment) { $associatedArray[$associatedEquipment->id] = $associatedEquipment->component_tag; + $qrCode = new QrCode($associatedEquipment->component_tag); + $writer = new PngWriter(); + $qrCodeImages[$associatedEquipment->id] = 'data:image/png;base64,' . base64_encode($writer->write($qrCode)->getString()); } $html = view('projectsClients.showDetailsEquipmentForQrCodePdf', [ 'detailsEquipment' => $detailsEquipment, 'logoPath' => $logoPath, - 'qrCodeImage' => $qrCodeImage, + 'qrCodeImages' => $qrCodeImages, 'associatedArray' => $associatedArray ])->render(); - // Define a orientação da folha como horizontal (Landscape) - $mpdf = new \Mpdf\Mpdf([ - 'mode' => 'utf-8', - 'format' => 'A4' // Define o formato como A4 e orientação como Landscape (horizontal) - ]); + $mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8', 'format' => 'A4']); $mpdf->WriteHTML($html); $mpdf->Output('nome_do_arquivo.pdf', 'I'); } diff --git a/app/Http/Controllers/WorkstationsJobsController.php b/app/Http/Controllers/WorkstationsJobsController.php index 6cff2f81..f59ddc0f 100755 --- a/app/Http/Controllers/WorkstationsJobsController.php +++ b/app/Http/Controllers/WorkstationsJobsController.php @@ -94,7 +94,6 @@ public function receiveQuestionsEquipment($equipmentID) public function receiveAnswersEquipment(Request $request, $control_equipment_workstation_id) { - //No request recebemos ID(NUmero da tarela elementar) , esta variavel vai receber este ID apos selerar o id da string $elementalTaskID = 0; diff --git a/resources/views/Templates/templateWorkstations.blade.php b/resources/views/Templates/templateWorkstations.blade.php index 925af51a..524ec665 100755 --- a/resources/views/Templates/templateWorkstations.blade.php +++ b/resources/views/Templates/templateWorkstations.blade.php @@ -520,7 +520,6 @@ function(qrCodeMessage) { }); }); --}} - {{-- --}} - {{-- --}} - - - {{-- --}} - {{-- --}} - {{-- Novo teste --}} - --}} + + diff --git a/resources/views/projectsClients/executionProjectNew.blade.php b/resources/views/projectsClients/executionProjectNew.blade.php index c7991ac9..e100136b 100755 --- a/resources/views/projectsClients/executionProjectNew.blade.php +++ b/resources/views/projectsClients/executionProjectNew.blade.php @@ -39,22 +39,25 @@ Equipamentos + +
+ Postos de Trabalho +
+
Tarefas
- {{--
- Postos de Trabalho -
--}}
-

Detalhes da Obra

+

Detalhes da Obra

+ @@ -111,10 +114,13 @@ @@ -139,6 +145,40 @@ +
+
+

Postos de Trabalho

+
+
+
+ +
+ +
+ + + + + + + + + + @foreach ($filteredUsers as $user) + + + + + + @endforeach + + +
Nome do PostoLoginSenha
{{ $user->nomenclature_workstation}}{{ $user->email }}{{ $user->realPassword }}
+ +
+
+ +

Tarefas

@@ -151,6 +191,8 @@
+ + {{--

Postos de Trabalho

@@ -178,6 +220,7 @@
--}}
+ @@ -187,70 +230,71 @@ @endsection diff --git a/resources/views/projectsClients/showAllEquipmentsInProjectQrCodePdf.blade.php b/resources/views/projectsClients/showAllEquipmentsInProjectQrCodePdf.blade.php index 7dd32549..62dbd535 100644 --- a/resources/views/projectsClients/showAllEquipmentsInProjectQrCodePdf.blade.php +++ b/resources/views/projectsClients/showAllEquipmentsInProjectQrCodePdf.blade.php @@ -127,11 +127,11 @@ @php $globalCounter = 0; @endphp @foreach ($equipmentData as $data) - @foreach ($data['associatedArray'] as $id => $componentTag) + @foreach ($data['associatedArray'] as $component) @php - $parts = explode('@', $componentTag); + $parts = explode('@', $component['component_tag']); $tagName = $parts[0]; - $tagType = $parts[1] ?? ''; // Use '??' para evitar erros se '@' não estiver presente + $tagType = $parts[1] ?? 'Tipo não especificado'; // Garante que o tipo não seja nulo @endphp
@@ -149,23 +149,19 @@
- {{-- QR Code --}} - QR Code - + QR Code de {{ $tagName }}
Tag : {{ $tagName }}
{{ $tagType }}
-
{{ $data['equipment']->equipmentType->equipment_type_name }}
-
{{ $data['equipment']->unit->unit_name }}
-
- Logo Esquerdo + Logo Esquerdo
Logo Esquerdo
+
@@ -177,6 +173,7 @@ @endforeach @endforeach + diff --git a/resources/views/projectsClients/showDetailsEquipmentForQrCodePdf.blade.php b/resources/views/projectsClients/showDetailsEquipmentForQrCodePdf.blade.php index f89368f4..622fd1d9 100644 --- a/resources/views/projectsClients/showDetailsEquipmentForQrCodePdf.blade.php +++ b/resources/views/projectsClients/showDetailsEquipmentForQrCodePdf.blade.php @@ -152,7 +152,7 @@
- QR Code + QR Code
Tag : {{ $tagName }}
{{$tagType}}
@@ -160,12 +160,12 @@
{{ $detailsEquipment->unit->unit_name }}
- Logo Esquerdo + Logo Esquerdo
+
- {{-- Logo Esquerdo --}} - Logo da Empresa + Logo da Empresa