@extends('layouts.app') @section('title', $pageTitle ?? 'CSR Costing') @section('contents')
@php $scheduleLines = $project->lines->where('line_kind', 'schedule')->values(); $nonScheduledLines = $project->lines->where('line_kind', 'item_b')->sortBy('sort_order')->values(); $boqTotal = (float) ($totals['grand'] ?? $totals['item_a'] ?? 0); $_showTotal = \App\Support\RatePresentation::pkrRound3Split($boqTotal); $schemeBoqLock = $schemeBoqLock ?? ['locked' => false]; $boqLocked = (bool) ($schemeBoqLock['locked'] ?? false); $nsStartIdx = $scheduleLines->count(); @endphp @if ($boqLocked)
{{ $schemeBoqLock['reason'] ?? 'Cost Estimate is locked while PC-I is approved.' }}
@endif @if (session('status'))
{{ session('status') }}
@endif

Cost Estimate

{{ $project->name }}

@if ($project->bpms_scheme_label) {{ $project->bpms_scheme_label }} @endif @if ($project->csrBook) {{ $project->csrBook->name }} @endif @if ($project->scheme_reference) {{ $project->scheme_reference }} @endif
@if ($project->isPublished()) Published {{ $project->published_at?->timezone(config('app.timezone'))->format('d M Y, H:i') }} @else Draft — not published yet @endif @if ($boqLocked) Locked @endif

Cost Estimate Total

Rs.{{ $_showTotal['main'] }}{{ $_showTotal['tail'] }}

@if (can_csr_boq_capability('list') || can_csr_boq_capability('view')) All Cost Estimates @endif @if ($project->bpms_scheme_id) Grand Summary @endif @if (can_csr_boq_capability('edit') && ! $boqLocked) Edit Cost Estimate Edit details @endif @if (can_csr_boq_capability('publish') && ! $project->isPublished() && ! $boqLocked)
@csrf
@endif @if (can_csr_boq_capability('delete') && ! $boqLocked)
@csrf @method('DELETE')
@endif

Cost Estimate Schedule

Est QTY × selected labour and/or composite rates. Grouped by chapter.

@php $boqShowLastChapterId = null; $footShowTotal = 0.0; @endphp @forelse ($scheduleLines as $lineIndex => $line) @php $lineLetter = \App\Support\BoqLineLetters::forIndex($lineIndex); $chapter = $line->scheduleItem?->section?->chapter; $chapterId = $chapter?->id; $showChapterBanner = $chapter !== null && (int) $chapterId !== (int) ($boqShowLastChapterId ?? 0); $compactDesc = $chapter !== null; if ($showChapterBanner) { $boqShowLastChapterId = $chapterId; } if ($chapter === null) { $boqShowLastChapterId = null; $compactDesc = false; } $qty = (float) $line->quantity; $labourRate = (float) ($line->labour_rate_pkr ?? 0); $compositeRate = (float) ($line->composite_rate_pkr ?? 0); $dbLabour = (float) ($line->scheduleItem?->labour_rate_pkr ?? $labourRate); $dbComposite = (float) ($line->scheduleItem?->composite_rate_pkr ?? $compositeRate); $useLabour = (bool) ($line->include_labour_in_total ?? false); $useComposite = (bool) ($line->include_composite_in_total ?? true); if ($useLabour && $useComposite) { $useComposite = false; } if (! $useLabour && ! $useComposite) { $useComposite = true; } $lineTotal = (float) ($line->line_total ?? 0); if ($lineTotal <= 0) { $rate = $useLabour ? $labourRate : $compositeRate; $lineTotal = \App\Services\PC\BoqLineCalculator::materialLineTotal($rate, null, null, $qty); } $footShowTotal += max(0.0, $lineTotal); @endphp @if ($showChapterBanner) @endif @empty @endforelse @if ($scheduleLines->isNotEmpty()) @endif
Bill Description Est QTY Unit Labour Rs Composite Rs Total Amount
{{ $chapter->name }} @if ($chapter->relationLoaded('workType') && $chapter->workType) {{ $chapter->workType->name }} @endif
{{ $lineLetter }} @include('csr-costing.boq.partials.schedule-line-description', ['line' => $line, 'compact' => $compactDesc]) {{ \App\Support\RatePresentation::pkr11($qty) }} {{ $line->unit ?: '—' }} @if ($useLabour)Use@endif {{ \App\Support\RatePresentation::pkrRound3($labourRate) }} @if (abs($labourRate - $dbLabour) > 0.0005) DB: {{ \App\Support\RatePresentation::pkrRound3($dbLabour) }} @endif @if ($useComposite)Use@endif {{ \App\Support\RatePresentation::pkrRound3($compositeRate) }} @if (abs($compositeRate - $dbComposite) > 0.0005) DB: {{ \App\Support\RatePresentation::pkrRound3($dbComposite) }} @endif {{ \App\Support\RatePresentation::pkrRound3($lineTotal) }}
No schedule lines yet.
Cost Estimate Total Sum of schedule line amounts {{ \App\Support\RatePresentation::pkrRound3($footShowTotal) }}
@if ($nonScheduledLines->isNotEmpty())

Non Scheduled Items

@foreach ($nonScheduledLines as $nsIdx => $nsLine) @php $nsAttachments = \App\Support\BoqSchemeFileUrls::enrichBoqAttachments( (int) $project->id, is_array($nsLine->item_b_attachments ?? null) ? $nsLine->item_b_attachments : [] ); $nsQty = (float) ($nsLine->quantity ?? 0); $nsPrice = (float) ($nsLine->composite_rate_pkr ?? 0); $nsAmt = (float) ($nsLine->line_total ?? $nsLine->item_b_amount ?? 0); @endphp @endforeach
S No Description Qty Price Amount Upload
{{ \App\Support\BoqLineLetters::forIndex($nsStartIdx + $nsIdx) }} {{ $nsLine->description_snapshot ?: $nsLine->item_b_title }} {{ $nsQty > 0 ? \App\Support\RatePresentation::pkrRound3($nsQty) : '—' }} {{ $nsPrice > 0 ? \App\Support\RatePresentation::pkrRound3($nsPrice) : '—' }} {{ \App\Support\RatePresentation::pkrRound3($nsAmt) }} @forelse ($nsAttachments as $att) @if (! empty($att['view_url'])) {{ $att['original_name'] ?? 'View file' }} @endif @empty @endforelse
@endif

Cost Estimate Total

Rs.{{ $_showTotal['main'] }}{{ $_showTotal['tail'] }}

@if ($project->bpms_scheme_id) @endif
@endsection