|
@@ -69,32 +69,40 @@
|
|
|
$bpDevice = $client->firstCellularBPDevice();
|
|
|
$bpMeasurements = [];
|
|
|
if ($bpDevice) {
|
|
|
- $bpMeasurements["first"] = \App\Models\Measurement
|
|
|
+ $records = \App\Models\Measurement
|
|
|
::where('imei', $bpDevice->device->imei)
|
|
|
->where('client_id', $client->id)
|
|
|
->where('is_cellular_zero', false)
|
|
|
->orderBy('ts')
|
|
|
- ->first();
|
|
|
- $bpMeasurements["last"] = \App\Models\Measurement
|
|
|
- ::where('imei', $bpDevice->device->imei)
|
|
|
- ->where('client_id', $client->id)
|
|
|
- ->where('is_cellular_zero', false)
|
|
|
- ->orderBy('ts', 'DESC')
|
|
|
- ->first();
|
|
|
+ ->get();
|
|
|
+ if(count($records)) {
|
|
|
+ $bpMeasurements["first"] = $records[0];
|
|
|
+ $bpMeasurements["last"] = $records[count($records) - 1];
|
|
|
+ $bpMeasurements["count"] = count($records);
|
|
|
+ }
|
|
|
+ // get num measurement days
|
|
|
+ $dayCount = [];
|
|
|
+ for($i = 0; $i<count($records); $i++) {
|
|
|
+ $date = friendly_date_short_with_tz_from_timestamp_divide1000($records[$i]->ts);
|
|
|
+ if(!in_array($date, $dayCount)) {
|
|
|
+ $dayCount[] = $date;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
?>
|
|
|
@if($bpDevice)
|
|
|
+ <?php $bpSO = $client->supplyOrderForCellularBPDevice(); ?>
|
|
|
<div class="d-flex align-items-baseline mb-1">
|
|
|
- <span class="width-100px">IMEI:</span>
|
|
|
- <span class="ml-3">{{$bpDevice->device->imei}}</span>
|
|
|
+ <span class="width-100px">Ordered:</span>
|
|
|
+ <span class="ml-3">{{$bpSO ? 'Yes' : 'No'}}</span>
|
|
|
</div>
|
|
|
<div class="d-flex align-items-baseline mb-1">
|
|
|
<span class="width-100px">Sent:</span>
|
|
|
- <span class="ml-3">Yes</span>*
|
|
|
+ <span class="ml-3">{{$bpSO && $bpSO->shipment && $bpSO->shipment->status === 'DISPATCHED' ? 'Yes' : 'No'}}</span>
|
|
|
</div>
|
|
|
<div class="d-flex align-items-baseline mb-1">
|
|
|
- <span class="width-100px">Arrived:</span>
|
|
|
- <span class="ml-3">Yes</span>*
|
|
|
+ <span class="width-100px">IMEI:</span>
|
|
|
+ <span class="ml-3">{{$bpDevice->device->imei}}</span>
|
|
|
</div>
|
|
|
<div class="d-flex align-items-baseline mb-1">
|
|
|
<span class="width-100px">First Use:</span>
|
|
@@ -116,6 +124,22 @@
|
|
|
-
|
|
|
@endif
|
|
|
</div>
|
|
|
+ <div class="d-flex align-items-baseline mb-1">
|
|
|
+ <span class="width-100px">Total Meas.:</span>
|
|
|
+ @if(@$bpMeasurements["count"])
|
|
|
+ <span class="ml-3">{{ $bpMeasurements["count"] }}</span>
|
|
|
+ @else
|
|
|
+ -
|
|
|
+ @endif
|
|
|
+ </div>
|
|
|
+ <div class="d-flex align-items-baseline mb-1">
|
|
|
+ <span class="width-100px">Total Meas. Days:</span>
|
|
|
+ @if(@$dayCount)
|
|
|
+ <span class="ml-3">{{ count($dayCount) }}</span>
|
|
|
+ @else
|
|
|
+ -
|
|
|
+ @endif
|
|
|
+ </div>
|
|
|
@endif
|
|
|
</td>
|
|
|
|
|
@@ -124,36 +148,44 @@
|
|
|
$weightScale = $client->firstCellularWeightDevice();
|
|
|
$weightMeasurements = [];
|
|
|
if ($weightScale) {
|
|
|
- $weightMeasurements["first"] = \App\Models\Measurement
|
|
|
+ $records = \App\Models\Measurement
|
|
|
::where('imei', $weightScale->device->imei)
|
|
|
->where('client_id', $client->id)
|
|
|
->where('is_cellular_zero', false)
|
|
|
->orderBy('ts')
|
|
|
- ->first();
|
|
|
- $weightMeasurements["last"] = \App\Models\Measurement
|
|
|
- ::where('imei', $weightScale->device->imei)
|
|
|
- ->where('client_id', $client->id)
|
|
|
- ->where('is_cellular_zero', false)
|
|
|
- ->orderBy('ts', 'DESC')
|
|
|
- ->first();
|
|
|
+ ->get();
|
|
|
+ if(count($records)) {
|
|
|
+ $weightMeasurements["first"] = $records[0];
|
|
|
+ $weightMeasurements["last"] = $records[count($records) - 1];
|
|
|
+ $weightMeasurements["count"] = count($records);
|
|
|
+ }
|
|
|
+ // get num measurement days
|
|
|
+ $dayCount = [];
|
|
|
+ for($i = 0; $i<count($records); $i++) {
|
|
|
+ $date = friendly_date_short_with_tz_from_timestamp_divide1000($records[$i]->ts);
|
|
|
+ if(!in_array($date, $dayCount)) {
|
|
|
+ $dayCount[] = $date;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
?>
|
|
|
@if($weightScale)
|
|
|
+ <?php $wsSO = $client->supplyOrderForCellularWeightScale(); ?>
|
|
|
<div class="d-flex align-items-baseline mb-1">
|
|
|
- <span class="width-100px">IMEI:</span>
|
|
|
- <span class="ml-3">{{$weightScale->device->imei}}</span>
|
|
|
+ <span class="width-100px">Ordered:</span>
|
|
|
+ <span class="ml-3">{{$wsSO ? 'Yes' : ''}}</span>
|
|
|
</div>
|
|
|
<div class="d-flex align-items-baseline mb-1">
|
|
|
<span class="width-100px">Sent:</span>
|
|
|
- <span class="ml-3">Yes</span>*
|
|
|
+ <span class="ml-3">{{$wsSO && $wsSO->shipment && $wsSO->shipment->status === 'DISPATCHED' ? 'Yes' : 'No'}}</span>
|
|
|
</div>
|
|
|
<div class="d-flex align-items-baseline mb-1">
|
|
|
- <span class="width-100px">Arrived:</span>
|
|
|
- <span class="ml-3">Yes</span>*
|
|
|
+ <span class="width-100px">IMEI:</span>
|
|
|
+ <span class="ml-3">{{$weightScale->device->imei}}</span>
|
|
|
</div>
|
|
|
<div class="d-flex align-items-baseline mb-1">
|
|
|
<span class="width-100px">First Use:</span>
|
|
|
- @if($weightMeasurements["first"])
|
|
|
+ @if(@$weightMeasurements["first"])
|
|
|
<span class="ml-3">{{ round($weightMeasurements["first"]->value, 2) . ' lbs' }}</span>
|
|
|
<span class="ml-3 text-secondary">{{date("Y-m-d", $weightMeasurements["first"]->ts/1000)}}</span>
|
|
|
<span class="ml-3">{{date_diff(date_create(date("Y-m-d", $weightMeasurements["first"]->ts/1000)), date_create('now'))->days}} days ago</span>
|
|
@@ -163,7 +195,7 @@
|
|
|
</div>
|
|
|
<div class="d-flex align-items-baseline mb-1">
|
|
|
<span class="width-100px">Last Use:</span>
|
|
|
- @if($weightMeasurements["last"])
|
|
|
+ @if(@$weightMeasurements["last"])
|
|
|
<span class="ml-3">{{ round($weightMeasurements["last"]->value, 2) . ' lbs' }}</span>
|
|
|
<span class="ml-3 text-secondary">{{date("Y-m-d", $weightMeasurements["last"]->ts/1000)}}</span>
|
|
|
<span class="ml-3">{{date_diff(date_create(date("Y-m-d", $weightMeasurements["last"]->ts/1000)), date_create('now'))->days}} days ago</span>
|
|
@@ -171,6 +203,22 @@
|
|
|
-
|
|
|
@endif
|
|
|
</div>
|
|
|
+ <div class="d-flex align-items-baseline mb-1">
|
|
|
+ <span class="width-100px">Total Meas.:</span>
|
|
|
+ @if(@$weightMeasurements["count"])
|
|
|
+ <span class="ml-3">{{ $weightMeasurements["count"] }}</span>
|
|
|
+ @else
|
|
|
+ -
|
|
|
+ @endif
|
|
|
+ </div>
|
|
|
+ <div class="d-flex align-items-baseline mb-1">
|
|
|
+ <span class="width-100px">Total Meas. Days:</span>
|
|
|
+ @if(@$dayCount)
|
|
|
+ <span class="ml-3">{{ count($dayCount) }}</span>
|
|
|
+ @else
|
|
|
+ -
|
|
|
+ @endif
|
|
|
+ </div>
|
|
|
@endif
|
|
|
</td>
|
|
|
|