208 lines
11 KiB
PHP
208 lines
11 KiB
PHP
@php
|
|
$isExport = $isExport ?? false;
|
|
@endphp
|
|
|
|
<div class="table-responsive" style="overflow-x: auto;">
|
|
<table class="table table-bordered table-striped">
|
|
<thead class="bg-header text-white text-center">
|
|
<tr>
|
|
<th rowspan="2" class="align-middle" style="width: 400px;">Sectors and Subsectors</th>
|
|
<th colspan="2" class="align-middle" style="width: 350px;">Direct Emissions (tCO2e)</th>
|
|
<th colspan="2">Indirect emissions from the use of grid-supplied electricity, heat, steam
|
|
and/or cooling</th>
|
|
<th colspan="2">Emissions occurring outside the city boundary as a result of in-city
|
|
activities
|
|
</th>
|
|
<th rowspan="2" class="align-middle">Please explain any excluded sources, identify any
|
|
emissions covered under an ETS and provide any other comments</th>
|
|
</tr>
|
|
<tr>
|
|
<th>Emissions in <br>tCO2e</th>
|
|
<th>Notation Key <br>(if needed)</th>
|
|
<th>Emissions in <br>tCO2e</th>
|
|
<th>Notation Key <br>(if needed)</th>
|
|
<th>Emissions in <br>tCO2e</th>
|
|
<th>Notation Key <br>(if needed)</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@php
|
|
$sumDirectAll = $sumIndirectAll = $sumOutsideAll = 0;
|
|
@endphp
|
|
@foreach ($gpcData as $sector => $subSectors)
|
|
@php
|
|
$sumDirectSector = $sumIndirectSector = $sumOutsideSector = 0;
|
|
$keyDirectSector = $keyIndirectSector = $keyOutsideSector = null;
|
|
$no = 1;
|
|
@endphp
|
|
|
|
@foreach ($subSectors as $subSector => $data)
|
|
<tr class="text-right">
|
|
<td class="bg-header text-white text-left">{{ ucfirst($sector) }} @if ($subSector)
|
|
> {{ $subSector }}
|
|
@endif
|
|
</td>
|
|
|
|
@for ($i = 1; $i <= 3; $i++)
|
|
@php
|
|
$crf = $data[$i] ?? null;
|
|
@endphp
|
|
|
|
@if ($crf)
|
|
@php
|
|
$gpcValue = '';
|
|
$totalValue = 0;
|
|
$gpcCodes = $crf->gpc_code;
|
|
if (is_array($gpcCodes)) {
|
|
foreach ($gpcCodes as $gpcCode) {
|
|
$gpcValue = $gpc[$gpcCodes[0]] ?? 'ERR';
|
|
$value = $gpc[$gpcCode] ?? 0;
|
|
$totalValue += is_numeric($value) ? $value : 0;
|
|
}
|
|
} else {
|
|
$gpcValue = $gpc[$crf->gpc_code] ?? 'ERR';
|
|
}
|
|
|
|
$gpcValue = $totalValue !== 0 ? $totalValue : $gpcValue;
|
|
|
|
if (is_numeric($gpcValue)) {
|
|
if ($i == 1) {
|
|
$sumDirectSector += $gpcValue;
|
|
if ($sector !== 'Generation of grid-supplied energy') {
|
|
$sumDirectAll += $gpcValue;
|
|
}
|
|
} elseif ($i == 2) {
|
|
$sumIndirectSector += $gpcValue;
|
|
if ($sector !== 'Generation of grid-supplied energy') {
|
|
$sumIndirectAll += $gpcValue;
|
|
}
|
|
} elseif ($i == 3) {
|
|
$sumOutsideSector += $gpcValue;
|
|
if ($sector !== 'Generation of grid-supplied energy') {
|
|
$sumOutsideAll += $gpcValue;
|
|
}
|
|
}
|
|
}
|
|
|
|
$currentSum =
|
|
$i == 1
|
|
? $sumDirectSector
|
|
: ($i == 2
|
|
? $sumIndirectSector
|
|
: $sumOutsideSector);
|
|
|
|
if ($currentSum === 0) {
|
|
if (!is_numeric($gpcValue)) {
|
|
$keyValue =
|
|
$gpcValue == 'ERR' ? $crf->notation_key : $gpcValue;
|
|
if ($no == 1) {
|
|
if ($i == 1) {
|
|
$keyDirectSector = $keyValue;
|
|
} elseif ($i == 2) {
|
|
$keyIndirectSector = $keyValue;
|
|
} elseif ($i == 3) {
|
|
$keyOutsideSector = $keyValue;
|
|
}
|
|
}
|
|
|
|
if (
|
|
($i == 1 &&
|
|
$keyValue != $keyDirectSector &&
|
|
$keyDirectSector != null) ||
|
|
($i == 2 &&
|
|
$keyValue != $keyIndirectSector &&
|
|
$keyIndirectSector != null) ||
|
|
($i == 3 &&
|
|
$keyValue != $keyOutsideSector &&
|
|
$keyOutsideSector != null)
|
|
) {
|
|
if ($i == 1) {
|
|
$keyDirectSector = null;
|
|
} elseif ($i == 2) {
|
|
$keyIndirectSector = null;
|
|
} elseif ($i == 3) {
|
|
$keyOutsideSector = null;
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if ($i == 1) {
|
|
$keyDirectSector = null;
|
|
} elseif ($i == 2) {
|
|
$keyIndirectSector = null;
|
|
} elseif ($i == 3) {
|
|
$keyOutsideSector = null;
|
|
}
|
|
}
|
|
@endphp
|
|
|
|
@if ($gpcValue == 'ERR')
|
|
<td></td>
|
|
<td class="text-left">{{ $crf->notation_key }}</td>
|
|
@elseif (is_numeric($gpcValue))
|
|
<td>{{ $isExport ? $gpcValue : getFormattedValue($gpcValue, 2) }}</td>
|
|
<td></td>
|
|
@else
|
|
<td></td>
|
|
<td class="text-left">{{ $gpcValue }}</td>
|
|
@endif
|
|
@else
|
|
<td class="bg-dark"></td>
|
|
<td class="bg-dark"></td>
|
|
@endif
|
|
@endfor
|
|
<td class="text-left">
|
|
{{ isset($data['info']) ? $data['info'] : '' }}
|
|
</td>
|
|
@php
|
|
$no++;
|
|
@endphp
|
|
</tr>
|
|
@endforeach
|
|
<tr class="font-weight-bold text-right">
|
|
<td class="bg-header text-white text-left">Total {{ ucfirst($sector) }}</td>
|
|
|
|
@if ($keyDirectSector === null && $sumDirectSector !== 0)
|
|
<td>{{ $isExport ? $sumDirectSector : getFormattedValue($sumDirectSector, 2) }}</td>
|
|
<td></td>
|
|
@else
|
|
<td></td>
|
|
<td class="text-left"> {{ $keyDirectSector }}</td>
|
|
@endif
|
|
@if ($keyIndirectSector === null && $sumIndirectSector !== 0)
|
|
<td>{{ $isExport ? $sumIndirectSector : getFormattedValue($sumIndirectSector, 2) }}
|
|
</td>
|
|
<td></td>
|
|
@elseif ($keyIndirectSector === null && $sumIndirectSector === 0 && $sector != 'Stationary Energy')
|
|
<td class="bg-dark"></td>
|
|
<td class="bg-dark"></td>
|
|
@else
|
|
<td></td>
|
|
<td class="text-left"> {{ $keyIndirectSector }}</td>
|
|
@endif
|
|
@if ($keyOutsideSector === null && $sumOutsideSector !== 0)
|
|
<td>{{ $isExport ? $sumOutsideSector : getFormattedValue($sumOutsideSector, 2) }}
|
|
</td>
|
|
<td></td>
|
|
@else
|
|
<td></td>
|
|
<td class="text-left"> {{ $keyOutsideSector }}</td>
|
|
@endif
|
|
<td></td>
|
|
</tr>
|
|
@endforeach
|
|
<!-- Total All Row -->
|
|
<tr class="font-weight-bold text-right">
|
|
<td class="bg-header text-white text-left">Total Emissions (excluding generation of
|
|
grid-supplied energy)</td>
|
|
<td>{{ $isExport ? $sumDirectAll : getFormattedValue($sumDirectAll, 2) }}</td>
|
|
<td></td>
|
|
<td>{{ $isExport ? $sumIndirectAll : getFormattedValue($sumIndirectAll, 2) }}</td>
|
|
<td></td>
|
|
<td>{{ $isExport ? $sumOutsideAll : getFormattedValue($sumOutsideAll, 2) }}</td>
|
|
<td></td>
|
|
<td></td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div> |