Files

247 lines
12 KiB
PHP

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Estimation Report - {{ $project->code }}</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'DejaVu Sans', sans-serif; font-size: 10px; color: #1e293b; padding: 30px; line-height: 1.4; }
.header { border-bottom: 2px solid #0f172a; padding-bottom: 10px; margin-bottom: 20px; }
.header .company-title { font-size: 16px; font-weight: bold; color: #0f172a; letter-spacing: 0.5px; }
.header .report-title { font-size: 12px; font-weight: bold; color: #475569; text-transform: uppercase; margin-top: 2px; }
.meta-container { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.meta-container td { padding: 4px 0; vertical-align: top; }
.meta-label { font-weight: bold; color: #475569; width: 120px; }
.meta-val { color: #0f172a; }
.section-title { font-size: 11px; font-weight: bold; background: #e2e8f0; color: #0f172a; padding: 6px 8px; margin-top: 15px; margin-bottom: 8px; text-transform: uppercase; }
table.items-table { width: 100%; border-collapse: collapse; margin-bottom: 15px; }
table.items-table th { background: #f1f5f9; padding: 6px 8px; text-align: left; font-size: 9px; text-transform: uppercase; color: #475569; border-bottom: 1px solid #cbd5e1; }
table.items-table td { padding: 6px 8px; border-bottom: 1px solid #e2e8f0; vertical-align: middle; }
table.items-table .num { text-align: right; font-family: 'DejaVu Sans', sans-serif; }
.subtotal-row td { font-weight: bold; background: #f8fafc; border-top: 1px solid #cbd5e1; }
/* Summary Analysis Card */
.summary-box { width: 100%; border: 1px solid #e2e8f0; border-radius: 6px; padding: 12px; margin-top: 10px; background: #f8fafc; }
.summary-box-title { font-weight: bold; font-size: 11px; margin-bottom: 8px; text-transform: uppercase; color: #0f172a; border-bottom: 1px solid #e2e8f0; padding-bottom: 4px; }
.summary-grid { display: table; width: 100%; }
.summary-row { display: table-row; }
.summary-col-label { display: table-cell; padding: 4px 0; font-weight: bold; color: #475569; }
.summary-col-val { display: table-cell; padding: 4px 0; text-align: right; font-family: 'DejaVu Sans', sans-serif; font-size: 11px; font-weight: bold; }
.text-emerald { color: #047857; }
.text-rose { color: #be123c; }
.unprofitable-warning { background: #fffbeb; border: 1px solid #fef3c7; color: #92400e; padding: 8px 12px; border-radius: 6px; margin-bottom: 15px; font-size: 9px; }
.page-break { page-break-before: always; }
.footer { margin-top: 30px; text-align: center; font-size: 8px; color: #94a3b8; border-top: 1px solid #e2e8f0; padding-top: 10px; }
</style>
</head>
<body>
<div class="header">
<div class="company-title">GREAT SWISS BUILDER CONSTRUCTION</div>
<div class="report-title">Project Budget Estimation Report</div>
</div>
<!-- Project Metadata -->
<table class="meta-container">
<tr>
<td class="meta-label">Project Code:</td>
<td class="meta-val">{{ $project->code }}</td>
<td class="meta-label">Date Generated:</td>
<td class="meta-val">{{ now()->format('F d, Y') }}</td>
</tr>
<tr>
<td class="meta-label">Project Name:</td>
<td class="meta-val" style="padding-right: 20px;">{{ $project->name }}</td>
<td class="meta-label">Project Type:</td>
<td class="meta-val" style="text-transform: capitalize;">{{ $project->project_type }}</td>
</tr>
<tr>
<td class="meta-label">Client Name:</td>
<td class="meta-val">{{ $project->client_name ?: 'N/A' }}</td>
<td class="meta-label">Location:</td>
<td class="meta-val">{{ $project->location ?: 'N/A' }}</td>
</tr>
<tr>
<td class="meta-label">Contract Value:</td>
<td class="meta-val" style="font-weight: bold;">{{ number_format($project->contract_value, 2) }}</td>
<td class="meta-label">Status:</td>
<td class="meta-val" style="text-transform: capitalize;">{{ $project->status instanceof \Modules\ProjectManagement\Enums\ProjectStatus ? $project->status->label() : ($project->status === 'under_bidding' ? 'Planning' : ucwords(str_replace('_', ' ', $project->status))) }}</td>
</tr>
</table>
@if($project->is_unprofitable)
<div class="unprofitable-warning">
<strong>Warning: Profit Margin Alert</strong><br>
This project has been flagged as unprofitable. The estimated cost centers exceed the registered contract value. Special oversight is required during authorization.
</div>
@endif
<!-- 1. Materials Cost -->
<div class="section-title">1. Materials Cost Breakdown</div>
<table class="items-table">
<thead>
<tr>
<th style="width: 5%;">#</th>
<th style="width: 45%;">Material Name</th>
<th style="width: 12%;">Unit</th>
<th style="width: 13%; text-align: right;">Est. Qty</th>
<th style="width: 13%; text-align: right;">Unit Cost</th>
<th style="width: 12%; text-align: right;">Total Cost</th>
</tr>
</thead>
<tbody>
@forelse($project->materialsEstimates as $index => $est)
<tr>
<td>{{ $index + 1 }}</td>
<td style="font-weight: bold; color: #334155;">{{ $est->material->name }}</td>
<td>{{ $est->material->unit }}</td>
<td class="num">{{ number_format($est->estimated_qty, 2) }}</td>
<td class="num">{{ number_format($est->unit_cost, 2) }}</td>
<td class="num" style="font-weight: bold;">{{ number_format($est->estimated_qty * $est->unit_cost, 2) }}</td>
</tr>
@empty
<tr>
<td colspan="6" style="text-align: center; color: #94a3b8; font-style: italic;">No materials allocated.</td>
</tr>
@endforelse
<tr class="subtotal-row">
<td colspan="5" style="text-align: right;">Subtotal Materials Cost</td>
<td class="num">{{ number_format($totals['materials'], 2) }}</td>
</tr>
</tbody>
</table>
<!-- 2. Labor Manpower Cost -->
<div class="section-title">2. Labor Manpower Cost Breakdown</div>
<table class="items-table">
<thead>
<tr>
<th style="width: 5%;">#</th>
<th style="width: 30%;">Target Task</th>
<th style="width: 25%;">Labor Record</th>
<th style="width: 12%;">Category</th>
<th style="width: 13%; text-align: right;">Rate / hr</th>
<th style="width: 13%; text-align: right;">Est. Hours</th>
<th style="width: 12%; text-align: right;">Total Cost</th>
</tr>
</thead>
<tbody>
@php $laborIdx = 1; @endphp
@forelse($project->tasks as $task)
@foreach($task->taskLabors as $tl)
<tr>
<td>{{ $laborIdx++ }}</td>
<td>{{ $task->name }}</td>
<td style="font-weight: bold; color: #334155;">{{ $tl->labor->name }}</td>
<td style="text-transform: capitalize;">{{ $tl->labor->category }}</td>
<td class="num">{{ number_format($tl->labor->hourly_rate, 2) }}</td>
<td class="num">{{ number_format($tl->estimated_hours, 1) }}</td>
<td class="num" style="font-weight: bold;">{{ number_format($tl->estimated_hours * $tl->labor->hourly_rate, 2) }}</td>
</tr>
@endforeach
@empty
@endforelse
@if($laborIdx === 1)
<tr>
<td colspan="7" style="text-align: center; color: #94a3b8; font-style: italic;">No labor trade allocations.</td>
</tr>
@endif
<tr class="subtotal-row">
<td colspan="6" style="text-align: right;">Subtotal Labor Cost</td>
<td class="num">{{ number_format($totals['labor'], 2) }}</td>
</tr>
</tbody>
</table>
<!-- 3. Equipment Machinery Cost -->
<div class="section-title">3. Equipment & Machinery Cost Breakdown</div>
<table class="items-table">
<thead>
<tr>
<th style="width: 5%;">#</th>
<th style="width: 30%;">Target Task</th>
<th style="width: 25%;">Equipment / Tool</th>
<th style="width: 12%;">Owner</th>
<th style="width: 13%; text-align: right;">Rate / hr</th>
<th style="width: 13%; text-align: right;">Est. Hours</th>
<th style="width: 12%; text-align: right;">Total Cost</th>
</tr>
</thead>
<tbody>
@php $equipIdx = 1; @endphp
@forelse($project->tasks as $task)
@foreach($task->taskEquipments as $te)
<tr>
<td>{{ $equipIdx++ }}</td>
<td>{{ $task->name }}</td>
<td style="font-weight: bold; color: #334155;">{{ $te->equipment->name }}</td>
<td>{{ $te->equipment->owner_name ?: 'Unspecified' }}</td>
<td class="num">{{ number_format($te->equipment->hourly_rate, 2) }}</td>
<td class="num">{{ number_format($te->estimated_hours, 1) }}</td>
<td class="num" style="font-weight: bold;">{{ number_format($te->estimated_hours * $te->equipment->hourly_rate, 2) }}</td>
</tr>
@endforeach
@empty
@endforelse
@if($equipIdx === 1)
<tr>
<td colspan="7" style="text-align: center; color: #94a3b8; font-style: italic;">No equipment allocations.</td>
</tr>
@endif
<tr class="subtotal-row">
<td colspan="6" style="text-align: right;">Subtotal Equipment Cost</td>
<td class="num">{{ number_format($totals['equipment'], 2) }}</td>
</tr>
</tbody>
</table>
<!-- Summary Box -->
<div class="summary-box">
<div class="summary-box-title">Financial Estimation Summary</div>
<div class="summary-grid">
<div class="summary-row">
<span class="summary-col-label">A. Total Materials Cost Center:</span>
<span class="summary-col-val">{{ number_format($totals['materials'], 2) }}</span>
</div>
<div class="summary-row">
<span class="summary-col-label">B. Total Labor Manpower Cost Center:</span>
<span class="summary-col-val">{{ number_format($totals['labor'], 2) }}</span>
</div>
<div class="summary-row">
<span class="summary-col-label">C. Total Equipment Machinery Cost Center:</span>
<span class="summary-col-val">{{ number_format($totals['equipment'], 2) }}</span>
</div>
<div class="summary-row" style="border-top: 1px solid #cbd5e1; padding-top: 4px;">
<span class="summary-col-label" style="font-size: 11px; color: #0f172a;">Total Combined Budget Estimate (A+B+C):</span>
<span class="summary-col-val" style="font-size: 11px; color: #0f172a;">{{ number_format($totals['sum'], 2) }}</span>
</div>
<div class="summary-row">
<span class="summary-col-label">Project Registered Contract Value:</span>
<span class="summary-col-val">{{ number_format($project->contract_value, 2) }}</span>
</div>
<div class="summary-row">
<span class="summary-col-label" style="color: #0f172a;">Projected Gross Profit Margin:</span>
<span class="summary-col-val {{ $totals['margin'] >= 0 ? 'text-emerald' : 'text-rose' }}">
{{ number_format($totals['margin'], 2) }} ({{ number_format($totals['margin_pct'], 2) }}%)
</span>
</div>
</div>
</div>
<div class="footer">
<p>Great Swiss Builder Construction &middot; Confidential Internal Document &middot; Page 1 of 1</p>
</div>
</body>
</html>