@php $x = 0 @endphp @foreach($shipment->consignments as $consignment) @php $x = $x + 1 @endphp @if($x < count($shipment->consignments))
@else
@endif
Shipment No. {{$shipment->instruction}}
{{$shipment->instruction}}
WEIGHT LIST  
Shipper
@foreach($shipment->companies as $company) @if((int)$company->pivot->type === 1) {{$company->name}}
{!! $company->address !!} @break @endif @endforeach
Consignee
@foreach($shipment->companies as $company) @if((int)$company->pivot->type === 2) {{$company->name}}
{!! $company->address !!} @break @endif @endforeach
@if(!empty($shipment->poNumber)) PO Number(s): {{$shipment->poNumber}} @endif  
Container Number
{{ $consignment['containerNumber'] }}
Seal Number
@if($consignment['customSeal'] !== null) {{$consignment['customSeal']}} @else {{$consignment['seal']}} @endif
No Ctns
{{ count($consignment['cartons']) }}
 

@if(!empty($shipment->grades)) @if(count($shipment->grades) > 1) @if($shipment->grades[0]->pivot->type === 2) Grade/Lot: {{$shipment->grades[0]->name}}
@else Grade/Lot: {{$shipment->grades[1]->name}}
@endif @else Grade/Lot: {{$shipment->grades[0]->name}}
@endif @endif @if(!empty($shipment->mopiNumber)) MoPI No: {{$shipment->mopiNumber}}
@endif @if(!empty($shipment->batch)) Batch No: {{$shipment->batch}} @endif
@php $lines = '' @endphp @php $last = '' @endphp @if(count($consignment['cartons']) > 0) @for($i = 0; $i < count($consignment['cartons']); $i++) @if($i == 0) @php $last = $consignment['cartons'][$i]['shippingNumber'] @endphp @endif @if($i > 0) @if(($consignment['cartons'][$i]['shippingNumber'] - $consignment['cartons'][$i - 1]['shippingNumber']) > 1) @php $lines = $lines.", ".$last."-".$consignment['cartons'][$i - 1]['shippingNumber'] @endphp @php $last = $consignment['cartons'][$i]['shippingNumber'] @endphp @endif @endif @endfor @if($last != $consignment['cartons'][count($consignment['cartons']) - 1]['shippingNumber']) @php $lines = $lines.", ".$last."-".$consignment['cartons'][count($consignment['cartons']) - 1]['shippingNumber'] @endphp @else @php $lines = $lines.", ".$last @endphp @endif @endif @php $lines = trim($lines, ", ") @endphp @if($lines == '') @if(!empty($consignment->bales)) @for($i = 0; $i < count($consignment->bales); $i++) @if($i == 0) @php $last = $consignment->bales[$i]->progno @endphp @endif @if($i > 0) @if(($consignment->bales[$i]->progno - $consignment->bales[$i - 1]->progno) > 1) @php $lines = $lines.", ".$last."-".$consignment->bales[$i - 1]->progno @endphp @php $last = $consignment->bales[$i]->progno @endphp @endif @endif @endfor @if($last != $consignment->bales[count($consignment->bales) - 1]->progno) @php $lines = $lines.", ".$last."-".$consignment->bales[count($consignment->bales) - 1]->progno @endphp @else @php $lines = $lines.", ".$last @endphp @endif @endif @php $lines = trim($lines, ", ") @endphp @endif Nos: {{$lines}} Description of Goods
{{$shipment->description}} @if($shipment->contract != null && $shipment->contract != '' && $shipment->contract != 'N/A') CONTRACT NUMBER {{$shipment->contract}} @endif
@if(count($consignment['cartons']) > 0 || count($consignment->bales) > 0)
Number Gross Tare Net Number Gross Tare Net Number Gross Tare Net
@php $reminder = count($consignment['cartons']) % 3 @endphp @php $firstColumn = array(); $secondColumn = array(); $thirdColumn = array() @endphp @if($reminder === 0) @for($i = 0; $i < count($consignment['cartons']) / 3; $i++) @php $firstColumn[] = $consignment['cartons'][$i] @endphp @php $secondColumn[] = $consignment['cartons'][$i + (count($consignment['cartons']) / 3)] @endphp @php $thirdColumn[] = $consignment['cartons'][$i + ((count($consignment['cartons']) / 3) * 2)] @endphp @endfor @endif @if($reminder > 0) @for($i = 0; $i <= count($consignment['cartons']) / 3; $i++) @php $firstColumn[] = $consignment['cartons'][$i] @endphp @if(($i + (count($consignment['cartons']) / 3)) + 1 < count($consignment['cartons'])) @php $secondColumn[] = $consignment['cartons'][($i + (count($consignment['cartons']) / 3)) + 1] @endphp @endif @if(($i + ((count($consignment['cartons']) / 3) * 2)) + 2 < count($consignment['cartons'])) @php $thirdColumn[] = $consignment['cartons'][($i + ((count($consignment['cartons']) / 3) * 2)) + 2] @endphp @endif @endfor @endif @php $gross = 0; $net = 0; $tare = 0 @endphp @for($i = 0; $i < count($firstColumn); $i++) @if($i < count($secondColumn)) @else @endif @if($i < count($thirdColumn)) @else @endif
{{$firstColumn[$i]['shippingNumber']}} @if($consignment['customTare'] == null || $consignment['customTare'] == '') {{ number_format($firstColumn[$i]['gross'], 2, '.', ',') }} @php $gross += $firstColumn[$i]['gross'] @endphp @else {{ number_format(($firstColumn[$i]['net'] + $consignment['customTare']), 2, '.', ',') }} @php $gross += ($firstColumn[$i]['net'] + $consignment['customTare']) @endphp @endif @if($consignment['customTare'] == null || $consignment['customTare'] == '') {{ $firstColumn[$i]['tare'] }} @php $tare += $firstColumn[$i]['tare'] @endphp @else {{ $consignment['customTare'] }} @php $tare += $consignment['customTare'] @endphp @endif {{ number_format($firstColumn[$i]['net'], 2, '.', ',') }} @php $net += $firstColumn[$i]['net'] @endphp {{ $secondColumn[$i]['shippingNumber'] }} @if($consignment['customTare'] == null || $consignment['customTare'] == '') {{ number_format($secondColumn[$i]['gross'], 2, '.', ',') }} @php $gross += $secondColumn[$i]['gross'] @endphp @else {{ number_format(($secondColumn[$i]['net'] + $consignment['customTare'] ), 2, '.', ',') }} @php $gross += ($secondColumn[$i]['net'] + $consignment['customTare']) @endphp @endif @if($consignment['customTare'] == null || $consignment['customTare'] == '') {{ $secondColumn[$i]['tare'] }} @php $tare += $secondColumn[$i]['tare'] @endphp @else {{$consignment['customTare'] }} @php $tare += $consignment['customTare'] @endphp @endif {{ number_format($secondColumn[$i]['net'], 2, '.', ',') }} @php $net += $secondColumn[$i]['net'] @endphp         {{ $thirdColumn[$i]['shippingNumber'] }} @if($consignment['customTare'] == null || $consignment['customTare'] == '') {{ number_format($thirdColumn[$i]['gross'], 2, '.', ',') }} @php $gross += $thirdColumn[$i]['gross'] @endphp @else {{ number_format(($thirdColumn[$i]['net'] + $consignment['customTare']), 2, '.', ',') }} @php $gross += $thirdColumn[$i]['net'] + $consignment['customTare'] @endphp @endif @if($consignment['customTare'] == null || $consignment['customTare'] == '') {{$thirdColumn[$i]['tare']}} @php $tare += $thirdColumn[$i]['tare'] @endphp @else {{$consignment['customTare']}} @php $tare += $consignment['customTare'] @endphp @endif {{ number_format($thirdColumn[$i]['net'], 2, '.', ',') }} @php $net += $thirdColumn[$i]['net'] @endphp        
@endfor @if(!empty($consignment->bales)) @for($i = 0; $i < count($consignment->bales) / 3; $i++)
{{$consignment->bales[$i]->progno}} {{$consignment->bales[$i]->mass}} 1.00 {{$consignment->bales[$i]->mass - 1.00}} @if(($i + 33) < count($consignment->bales)) {{$consignment->bales[$i + 33]->progno}} @endif @if(($i + 33) < count($consignment->bales)) {{$consignment->bales[$i + 33]->mass}} @endif @if(($i + 33) < count($consignment->bales)) 1.00 @endif @if(($i + 33) < count($consignment->bales)) {{$consignment->bales[$i + 33]->mass - 1.00}} @endif @if(($i + 66) < count($consignment->bales)) {{$consignment->bales[$i + 66]->progno}} @endif @if(($i + 66) < count($consignment->bales)) {{$consignment->bales[$i + 66]->mass}} @endif @if(($i + 66) < count($consignment->bales)) 1.00 @endif @if(($i + 66) < count($consignment->bales)) {{$consignment->bales[$i + 66]->mass - 1}} @endif
@endfor @endif
TOTAL:      {{ number_format($gross, 2, '.', ',') }} kg gross
{{ number_format($tare, 2, '.', ',') }} kg tare
{{ number_format($net, 2, '.', ',') }} kg net
@endif
@endforeach