diff --git a/app/Http/Controllers/CreateProjectController.php b/app/Http/Controllers/CreateProjectController.php index 560370de..41139a98 100755 --- a/app/Http/Controllers/CreateProjectController.php +++ b/app/Http/Controllers/CreateProjectController.php @@ -1218,6 +1218,7 @@ public function receiveIdEquipment(Equipment $equipment) public function processStep2(Request $request) { + // Valide e processe os dados do formulário $file = $request->file('documento'); diff --git a/app/Http/Controllers/PreparedProjectController.php b/app/Http/Controllers/PreparedProjectController.php index 70e44093..b2f774f0 100755 --- a/app/Http/Controllers/PreparedProjectController.php +++ b/app/Http/Controllers/PreparedProjectController.php @@ -18,6 +18,7 @@ use App\Models\Unit; use App\Models\AmbitsEquipment; use Illuminate\Support\Facades\Auth; +use App\Services\PdfWrapper; // use PDF; @@ -174,23 +175,12 @@ public function showAllEquipmentsInProjectForQrCode($projectId) } - // 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)) { @@ -198,61 +188,94 @@ public function showAllEquipmentsInProjectForQrCode($projectId) // } // $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'); // } + public function showDetailsEquipmentForQrCode($equipmentId, $projectId) { + // Busca os detalhes do equipamento, projeto e empresa $detailsEquipment = Equipment::find($equipmentId); $detailsCompanyProject = CompanyProject::find($projectId); $detailsPlant = Plant::where('plant_id', $detailsCompanyProject->plant_id)->first(); $detailsCompany = Company::where('company_id', $detailsPlant->company_id)->first(); + + // Definir o caminho da logo da empresa $logoPath = public_path('companies_logo/' . ($detailsCompany->company_logo ?: 'logoISPT4.0.jpg')); + + // Verificar se o caminho do logo existe, se não, usa um logo padrão if (!file_exists($logoPath)) { $logoPath = public_path('companies_logo/logoISPT4.0.jpg'); } + + $isptLogoPath = public_path('/img/ispt/ispt.jpg'); + + // Associar equipamentos ao QR Code $associatedEquipments = QrcodesAssociatedEquipment::where('equipment_id', $detailsEquipment->equipment_id)->get(); $associatedArray = []; $qrCodeImages = []; + + // Gerar QR Codes para cada equipamento associado foreach ($associatedEquipments as $associatedEquipment) { - $associatedArray[$associatedEquipment->id] = $associatedEquipment->component_tag; + // Extrair o texto após o '@' + $componentParts = explode('@', $associatedEquipment->component_tag); + $associatedArray[$associatedEquipment->id] = isset($componentParts[1]) ? $componentParts[1] : $associatedEquipment->component_tag; + + // Gerar QR Code $qrCode = new QrCode($associatedEquipment->component_tag); $writer = new PngWriter(); + + // Converter o QR Code para imagem base64 $qrCodeImages[$associatedEquipment->id] = 'data:image/png;base64,' . base64_encode($writer->write($qrCode)->getString()); } - $html = view('projectsClients.showDetailsEquipmentForQrCodePdf', [ + // dd($detailsEquipment->equipmentType->equipment_type_id); + + return view('projectsClients.showDetailsEquipmentForQrCodePdf', [ 'detailsEquipment' => $detailsEquipment, 'logoPath' => $logoPath, 'qrCodeImages' => $qrCodeImages, - 'associatedArray' => $associatedArray - ])->render(); + 'associatedArray' => $associatedArray, + 'isptLogoPath'=> $isptLogoPath + ]); + + + // // Usar PdfWrapper para gerar o PDF + // $pdfWrapper = new PdfWrapper(); + // // Gera e retorna o PDF com os detalhes e QR Codes + // return $pdfWrapper + // ->loadView('projectsClients.showDetailsEquipmentForQrCodePdf', [ + // 'detailsEquipment' => $detailsEquipment, + // 'logoPath' => $logoPath, + // 'qrCodeImages' => $qrCodeImages, + // 'associatedArray' => $associatedArray, + // 'isptLogoPath'=> $isptLogoPath + // ]) + // ->setOrientation('landscape') + // ->stream('nome_do_arquivo.pdf'); // Exibe o PDF diretamente no navegador - $mpdf = new \Mpdf\Mpdf(['mode' => 'utf-8', 'format' => 'A4']); - $mpdf->WriteHTML($html); - $mpdf->Output('nome_do_arquivo.pdf', 'I'); } @@ -306,7 +329,7 @@ public function PreparedProject($ProjectId) ->with('units', $checkUnits) ->with('numberProject', $numberProject) ->with('equipmentsProjects', $equipmentsProjects); - + } public function getAmbits($equipmentType) diff --git a/app/Http/Controllers/ProjectoDatacontroller.php b/app/Http/Controllers/ProjectoDatacontroller.php index c919c34b..da569625 100755 --- a/app/Http/Controllers/ProjectoDatacontroller.php +++ b/app/Http/Controllers/ProjectoDatacontroller.php @@ -21,9 +21,6 @@ use ZipArchive; - - - use Yajra\DataTables\Facades\DataTables; use Carbon\Carbon; diff --git a/app/Models/Equipment.php b/app/Models/Equipment.php index 40d20a40..3013f2f6 100755 --- a/app/Models/Equipment.php +++ b/app/Models/Equipment.php @@ -43,13 +43,6 @@ public function specificAttributes() ->orderBy('general_attributes_equipaments.general_attributes_equipment_description', 'asc'); } - //Trocar para EquipmentWorkHistory - public function equipmentAssociationAmbit() - { - //Antiga hasMany , apenas colocado hasOne para funcionar o datatables - return $this->hasOne(EquipmentAssociationAmbit::class, 'equipment_id', 'equipment_id'); - } - public function orderEquipmentTasks() { return $this->hasMany(OrderEquipmentTasks::class, 'equipment_id', 'equipment_id'); diff --git a/app/Models/EquipmentAssociationAmbit.php b/app/Models/EquipmentAssociationAmbit.php index 771bedbf..28e6d1d0 100755 --- a/app/Models/EquipmentAssociationAmbit.php +++ b/app/Models/EquipmentAssociationAmbit.php @@ -25,4 +25,8 @@ public function Equipment(){ return $this->belongsTo(Equipment::class,'equipment_id', 'equipment_id'); } + public function equipmentWorkHistory() + { + return $this->belongsTo(EquipmentWorkHistory::class, 'equipmentWorkHistorys_id', 'equipmentWorkHistorys_id'); + } } diff --git a/app/Services/PdfWrapper.php b/app/Services/PdfWrapper.php index 21511fce..686f7df2 100644 --- a/app/Services/PdfWrapper.php +++ b/app/Services/PdfWrapper.php @@ -10,12 +10,20 @@ class PdfWrapper { protected Browsershot $pdfGenerator; protected string $html; + protected $orientation = 'portrait'; public function __construct() { $this->pdfGenerator = new Browsershot(); } + // Método para configurar a orientação (paisagem ou retrato) + public function setOrientation($orientation): self + { + $this->orientation = $orientation; + return $this; + } + // Load view and render HTML public function loadView(string $bladeFile, array $data = []): self { @@ -50,6 +58,7 @@ public function generate(): Browsershot return $this->pdfGenerator ->html($this->html) ->format('A4') + ->landscape($this->orientation === 'landscape') // Verifica se deve ser paisagem ->scale(0.7) ->fullPage() ->setOption('printBackground', true) diff --git a/public/templateExcel/Valves_Template.xlsx b/public/templateExcel/Valves_Template.xlsx index 29d05803..9438b91b 100644 Binary files a/public/templateExcel/Valves_Template.xlsx and b/public/templateExcel/Valves_Template.xlsx differ diff --git a/resources/views/projectsClients/showDetailsEquipmentForQrCodePdf.blade copy.php b/resources/views/projectsClients/showDetailsEquipmentForQrCodePdf.blade copy.php new file mode 100644 index 00000000..67e564f3 --- /dev/null +++ b/resources/views/projectsClients/showDetailsEquipmentForQrCodePdf.blade copy.php @@ -0,0 +1,176 @@ + + + + + + + + Document + + + + + + + + @php $contador = 0; @endphp + @foreach ($associatedArray as $id => $componentTag) + + @if ($contador % 4 == 0 && $contador != 0) +
+ @endif + + @php + $parts = explode('@', $componentTag); + $tagName = $parts[0]; // a parte antes do '@' + $tagType = $parts[1]; // a parte depois do '@' + @endphp + +
+
+
+
+
+
+ ISPT 4.0 +
+
+ +
+
+
+ QR Code +
Tag : {{ $tagName }}
+
{{$tagType}}
+ +
{{ $detailsEquipment->equipmentType->equipment_type_name }}
+
{{ $detailsEquipment->unit->unit_name }}
+ +
+ Logo Esquerdo +
+ +
+ Logo da Empresa +
+
+
+ @php $contador++; @endphp + @endforeach + + + diff --git a/resources/views/projectsClients/showDetailsEquipmentForQrCodePdf.blade.php b/resources/views/projectsClients/showDetailsEquipmentForQrCodePdf.blade.php index 67e564f3..6a542a19 100644 --- a/resources/views/projectsClients/showDetailsEquipmentForQrCodePdf.blade.php +++ b/resources/views/projectsClients/showDetailsEquipmentForQrCodePdf.blade.php @@ -4,113 +4,27 @@ - - Document + Card Example + + .card-header { + flex-basis: 40%; + display: flex; + justify-content: center; + align-items: center; + text-align: center; + padding: 0; + /* Remove qualquer padding adicional */ + } + + .title-card { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + height: 100%; + } + + + .card-footer { + flex-basis: 60%; + display: flex; + flex-direction: column; + /* Stack rows vertically */ + justify-content: space-between; + /* Distribute space evenly */ + text-align: center; + } + + .card-footer .row { + width: 100%; + height: 100%; + margin-left: 0.4px; + /* flex-grow: 1; */ + /* Make each row grow equally to fill the space */ + display: flex; + justify-content: center; + align-items: center; + border: 1px solid gray; + /* Optional: add some separation between rows */ + } + + .qr-code { + /* margin-top: 5px; */ + width: 15mm; + height: 15mm; + } + + .tag-name-qrcode { + font-size: 10px; + margin: 0; + padding: 0; + } + + .img-company { + margin-top: 7px; + width: 12mm; + height: 12mm; + } + + .blue { + background-color: #09255C; + color: white; + /* border-radius: 5px; */ + + display: flex; + justify-content: center; + align-items: center; + box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1); + font-weight: bold; + } + + .gray { + background-color: #EAF3F6; + color: black; + /* border-radius: 5px; */ + + display: flex; + justify-content: center; + align-items: center; + box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1); + font-weight: bold; + } + + .dark-blue { + background-color: #00B0EA; + color: white; + /* border-radius: 5px; */ + + display: flex; + justify-content: center; + align-items: center; + box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1); + font-weight: bold; + } + - - @php $contador = 0; @endphp - @foreach ($associatedArray as $id => $componentTag) - - @if ($contador % 4 == 0 && $contador != 0) -
- @endif - - @php - $parts = explode('@', $componentTag); - $tagName = $parts[0]; // a parte antes do '@' - $tagType = $parts[1]; // a parte depois do '@' - @endphp - -
-
-
-
+ @foreach ($associatedArray as $key => $value) + + @if ($detailsEquipment->equipmentType->equipment_type_id == 3) +
+
+
+
+
+ Logo da Empresa +
+
+ Logo da Empresa +
+
+
+
Paragem ###
+
N.Ispt ###
+
Tag ###
+
+
+
+ QR Code +
+
+

{{ $associatedArray[$key] }}

+
+
+
-
- ISPT 4.0 -
-
- + + +
-
- QR Code -
Tag : {{ $tagName }}
-
{{$tagType}}
+ -
{{ $detailsEquipment->equipmentType->equipment_type_name }}
-
{{ $detailsEquipment->unit->unit_name }}
- -
- Logo Esquerdo + + @elseif($detailsEquipment->equipmentType->equipment_type_id == 1) +
+
+
+
+
+ Logo da Empresa +
+
+ Logo da Empresa +
+
+
+
Paragem ###
+
N.Ispt ###
+
Tag ###
+
+
+
+ QR Code +
+
+

{{ $associatedArray[$key] }}

+
+
+
- -
- Logo da Empresa + + +
-
- @php $contador++; @endphp - @endforeach + + + + + @elseif($detailsEquipment->equipmentType->equipment_type_id == 2) +
+
+
+
+
+ Logo da Empresa +
+
+ Logo da Empresa +
+
+
+
Paragem ###
+
N.Ispt ###
+
Tag ###
+
+
+
+ QR Code +
+
+

{{ $associatedArray[$key] }}

+
+
+
+
+ + + +
+ @endif + @endforeach + diff --git a/vendor/laravel/sail/database/mysql/create-testing-database.sh b/vendor/laravel/sail/database/mysql/create-testing-database.sh deleted file mode 100755 index aeb1826f..00000000 --- a/vendor/laravel/sail/database/mysql/create-testing-database.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -mysql --user=root --password="$MYSQL_ROOT_PASSWORD" <<-EOSQL - CREATE DATABASE IF NOT EXISTS testing; - GRANT ALL PRIVILEGES ON \`testing%\`.* TO '$MYSQL_USER'@'%'; -EOSQL diff --git a/vendor/laravel/sail/stubs/mysql.stub b/vendor/laravel/sail/stubs/mysql.stub deleted file mode 100755 index c4d66f97..00000000 --- a/vendor/laravel/sail/stubs/mysql.stub +++ /dev/null @@ -1,20 +0,0 @@ -mysql: - image: 'mysql/mysql-server:8.0' - ports: - - '${FORWARD_DB_PORT:-3306}:3306' - environment: - MYSQL_ROOT_PASSWORD: '${DB_PASSWORD}' - MYSQL_ROOT_HOST: "%" - MYSQL_DATABASE: '${DB_DATABASE}' - MYSQL_USER: '${DB_USERNAME}' - MYSQL_PASSWORD: '${DB_PASSWORD}' - MYSQL_ALLOW_EMPTY_PASSWORD: 1 - volumes: - - 'sail-mysql:/var/lib/mysql' - - './vendor/laravel/sail/database/mysql/create-testing-database.sh:/docker-entrypoint-initdb.d/10-create-testing-database.sh' - networks: - - sail - healthcheck: - test: ["CMD", "mysqladmin", "ping", "-p${DB_PASSWORD}"] - retries: 3 - timeout: 5s