{{-- LAB DENEY TALEP FORMU — içerik parçası (belge sayfası: saha/log/lab-belge). Eski bağımsız `pdf/lab-request` görünümünden taşındı (11.11.2026); o görünüm dompdf/önizleme metotlarıyla birlikte hiçbir rotaya bağlı değildi. Gerekenler: $log, $firm, $allTests (kategoriye göre gruplu), $assignments, $templateInfo, $derinlikler (atama id → "4.00-4.45"; Excel'le aynı hesap, SahaLogController::sampleDepth). --}} @php /* ────────────────────────────────────────────────────── Veri hazırlığı ────────────────────────────────────────────────────── */ $isCozum = strtoupper($firm->short_name) === 'ÇÖZÜM'; /* Talep no ve tarih TALEPTEN (24.11.2026: lab ataması deney talebine geçti; tarih = onay tarihi). Talepsiz çağrıda eskisi gibi tire ve bugün. */ $belgeTalepNo = isset($talep) && $talep ? $talep->talep_no : '—'; $belgeTarihi = isset($talep) && $talep ? \App\Services\LabTalepFormu::tarih($talep) : now()->format('d.m.Y'); $sortedAsgn = $assignments->sortBy(fn($a) => $a->row->sira_no ?? 0)->values(); $selByAsgn = []; foreach ($sortedAsgn as $a) { $selByAsgn[$a->id] = $a->tests->pluck('id')->flip()->toArray(); } $orderedTests = collect(); $catCounts = []; foreach ($allTests as $cat => $tests) { $catCounts[$cat] = count($tests); foreach ($tests as $t) { $orderedTests->push($t); } } // Kategori etiketleri: ÇÖZÜM'ün Excel'indeki ile birebir $catLabels = $isCozum ? [ 'zemin' => 'ZEMİN', 'kaya' => 'KAYA - DOĞAL YAPI TAŞLARI', 'agrega' => 'AGREGA', ] : [ 'zemin' => 'ZEMİN DENEYLERİ', 'kaya' => 'KAYA DENEYLERİ', 'agrega' => 'AGREGA DENEYLERİ', ]; $nTests = $orderedTests->count(); /* ── Sütun genişlikleri (px) ────────────────────────────── ÇÖZÜM: No sütunu yok → 3 sabit sütun (Kuyu No / Numune Tipi / Derinlik) ARTER ve diğerleri: 4 sabit sütun (No / Sondaj No / Numune No / Derinlik) Test sütunu: 18px ────────────────────────────────────────────────────────── */ $colTest = 18; // px — her test sütunu if ($isCozum) { // Excel'den alınan birebir ölçüler (4.664 Excel birimi = 18px temel alınarak) $colKuyu = 46; // px — Kuyu No (12 Excel birimi) $colNumune = 36; // px — Numune Tipi (9.33 Excel birimi) $colDerinlik = 79; // px — Derinlik(m) (20.55 Excel birimi) $fixedCols = 3; $fixedW = $colKuyu + $colNumune + $colDerinlik; // 161px $issuerColspan = 2; // Kuyu No + Numune Tipi } else { $colNo = 20; // px — No $colSondaj = 45; // px — Sondaj No $colNumune = 45; // px — Numune No $colDerinlik = 58; // px — Derinlik $fixedCols = 4; $fixedW = $colNo + $colSondaj + $colNumune + $colDerinlik; // 168px $issuerColspan = 3; // No + Sondaj No + Numune No } $tableWidth = $fixedW + $nTests * $colTest; $totalCols = $fixedCols + $nTests; /* ── Header hücre genişlikleri (Excel merge oranlarına göre) ── */ $hdrLogo = round($tableWidth * 0.1547); $hdrCompany = round($tableWidth * 0.3979); $hdrDocLabel = round($tableWidth * 0.1161); $hdrDocTitle = $tableWidth - $hdrLogo - $hdrCompany - $hdrDocLabel; /* ── Info satırı colspan hesabı ── issuer rowspan=3 colspan=$issuerColspan info-lbl : Derinlik(1) + lblTestSpan test sütun info-val : keskaSpan test sütun pft-lbl : pftLblSpan test sütun pft-val : pftValSpan test sütun ────────────────────────────────── */ $lblTestSpan = max(1, (int)round($nTests * 4 / 51)); $lblSpan = 1 + $lblTestSpan; // Derinlik sütunu + test sütunları $pftLblSpan = max(1, (int)round($nTests * 6 / 51)); $pftValSpan = max(1, (int)round($nTests * 18 / 51)); $keskaSpan = $nTests - $lblTestSpan - $pftLblSpan - $pftValSpan; if ($keskaSpan < 1) $keskaSpan = 1; /* ── Template bilgileri ── */ $companyName = $templateInfo['companyName'] ?? $firm->name; $companySub = $templateInfo['companySub'] ?? ''; $docCode = $templateInfo['docCode'] ?? ''; $logoPath = public_path('images/lab-logos/' . strtoupper($firm->short_name) . '.png'); $logoUrl = asset('images/lab-logos/' . strtoupper($firm->short_name) . '.png'); @endphp {{-- ══════════════════════════════════════════════════ KAPSAYICI — her iki tablo aynı genişlikte ══════════════════════════════════════════════════ --}}
{{-- ════════════════════════════ HEADER (Excel satır 1-6) ════════════════════════════ --}} @if($isCozum) {{-- ── ÇÖZÜM: Logo | Form Başlığı | Adres | DocCode ── Excel satır 1-4 yapısına birebir uygun Logo(B:E)≈10% Başlık(F:V)≈20% Adres(W:AN)≈50% DocCode(AO:AY)≈20% ──────────────────────────────────────────────────── --}} @php $cHdrLogo = $colKuyu + $colNumune; // B+C sütunları = 82px (logo alanı) $cHdrTitle = round($tableWidth * 0.195); // form başlığı $cHdrAddress = round($tableWidth * 0.525); // adres $cHdrDoc = $tableWidth - $cHdrLogo - $cHdrTitle - $cHdrAddress; @endphp {{-- Satır 1+2+3: Logo (rowspan=4) | Başlık (rowspan=4) | Adres (rowspan=4) | boş --}} {{-- Satır 4: DocCode --}}
@if(file_exists($logoPath)) CJ @else CJ @endif
{{ $companyName }}
{{ $companySub }}
{{ $docCode }}
@else {{-- ── Varsayılan (ARTER vb.): Logo | Firma+Adres | DOKÜMAN ADI | DENEY TALEP FORMU ── --}} {{-- Logo (rowspan=2) --}} {{-- Firma adı + adresi (rowspan=2) --}} {{-- DOKÜMAN ADI: --}} {{-- DENEY TALEP FORMU --}}
@if(file_exists($logoPath)) {{ $firm->short_name }} @else {{ strtoupper($firm->short_name) }} @endif
{{ $companyName }}
@if($companySub)
{{ $companySub }}
@endif
DOKÜMAN ADI:
DENEY TALEP FORMU
{{ $docCode }} Talep No:  {{ $belgeTalepNo }}    Tarih: {{ $belgeTarihi }}
@endif {{-- ════════════════════════════════════════════════════════════ BİRLEŞİK ANA TABLO (Excel satır 7+) ─ Info satırları (İŞVEREN / ADI / ADRESİ / TEL) ─ Kategori başlıkları (ZEMİN | KAYA | AGREGA) ─ Dikey test adları ─ Veri satırları (+ minimum 15 satır) Tek + tek → tüm satırlar hizalı ════════════════════════════════════════════════════════════ --}}
@if($isCozum) @else @endif @foreach($orderedTests as $_t) @endforeach @if($isCozum) {{-- ══════════════════════════════════════════════════════ ÇÖZÜM TABLOSU (Excel Row 5-8 yapısı) Row 1: Sabit başlıklar (rowspan=3) + Kategoriler Row 2: TS standart kodları (dikey, kısa) Row 3: Test adları (dikey, uzun) Veri Satırları Alt bilgi: İŞİN ADI / TALEP TARİHİ ══════════════════════════════════════════════════════ --}} {{-- ── ROW 1: Kategoriler (Excel Row 5 — height:27px) Sabit sütunlar rowspan=3 ile tüm başlık satırlarını kapsar ── --}} @foreach($catCounts as $cat => $count) @if($count > 0) @endif @endforeach {{-- ── ROW 2: TS Standart Kodları (Excel Row 6 — height:118px) ── --}} @foreach($orderedTests as $t) @endforeach {{-- ── ROW 3: Test Adları (Excel Row 7+8 birleşik — height:259px) ── --}} @foreach($orderedTests as $t) @endforeach {{-- ── VERİ SATIRLARI ── --}} @forelse($sortedAsgn as $idx => $a) @foreach($orderedTests as $t) @if(isset($selByAsgn[$a->id][$t->id])) @else @endif @endforeach @empty @endforelse {{-- ── BOŞ SATIRLAR (min 15) ── --}} @for($e = $sortedAsgn->count(); $e < 15; $e++) @foreach($orderedTests as $_t)@endforeach @endfor {{-- ── ALT BİLGİ: İŞİN ADI / TALEP TARİHİ ── --}} @php /* Sütun toplamı = 3 sabit + nTests. "TALEP TARİHİ" etiketi 2 deney sütununa (36px) sığmıyor, "TALEP TA" diye kesiliyordu; satır da 1 sütun fazlaydı. Etiket 6 deney sütunu (108px), tarih kalanı. */ $halfTests = (int) floor($nTests / 2); $otherHalf = $nTests - $halfTests; $tarihLblSp = max(1, min(6, $otherHalf - 1)); $tarihValSp = max(1, $otherHalf - $tarihLblSp); @endphp @else {{-- ══════════════════════════════════════════════════════ VARSAYILAN TABLO (ARTER vb.) İŞVEREN bilgileri üstte, tek test satırı ══════════════════════════════════════════════════════ --}} {{-- ── INFO ROW 1: ADI ── --}} {{-- ── INFO ROW 2: ADRESİ ── --}} {{-- ── INFO ROW 3: TEL ── --}} {{-- ── KATEGORİ + SABİT SÜTUN BAŞLIKLARI (rowspan=2) ── --}} @foreach($catCounts as $cat => $count) @if($count > 0) @endif @endforeach {{-- ── DİKEY TEST ADLARI ── --}} @foreach($orderedTests as $t) @endforeach {{-- ── VERİ SATIRLARI ── --}} @forelse($sortedAsgn as $idx => $a) @foreach($orderedTests as $t) @if(isset($selByAsgn[$a->id][$t->id])) @else @endif @endforeach @empty @endforelse {{-- ── BOŞ SATIRLAR (min 15) ── --}} @for($e = $sortedAsgn->count(); $e < 15; $e++) @foreach($orderedTests as $_t)@endforeach @endfor @endif
Kuyu No Numune Tipi Derinlik (m) {{ $catLabels[$cat] ?? strtoupper($cat) }}
{{ $t->test_code ?? '' }}
{{ $t->test_name }}
{{ $log->sondaj_no }} {{ $a->row->ornek_turu ?? '' }} {{ $derinlikler[$a->id] ?? '' }}X
Atama bulunamadı.
İŞİN ADI {{ $log->project->title ?? '' }} TALEP TARİHİ {{ $belgeTarihi }}
İŞVEREN
FİRMANIN
ADI KESKA MÜHENDİSLİK PFT-ADA-PRS {{ $log->project->pafta_ada_parsel ?? ($log->project->title ?? '') }}
ADRESİ {{ $log->project->address ?? '' }} PROJE ADI {{ $log->project->title ?? '' }}
TEL. / FAX / E-MAİL TARİH {{ $belgeTarihi }}
No Sondaj No Numune No DERİNLİK (m) {{ $catLabels[$cat] ?? strtoupper($cat) }}
{{ $t->test_name }}
{{ $idx + 1 }} {{ $log->sondaj_no }} {{ $a->row->ornek_turu ?? '' }} {{ $derinlikler[$a->id] ?? '' }}X
Atama bulunamadı.
{{ $e + 1 }}
{{-- ── İMZA ── --}}
Talep Eden İsim / İmza / Tarih
Şef Onayı İsim / İmza / Tarih
Laboratuvar Yetkilisi İsim / İmza / Tarih
{{-- /container --}}