Jelajahi Sumber

added columns to bdt devices report

= 3 tahun lalu
induk
melakukan
eddc930eb7

+ 16 - 0
app/Models/Client.php

@@ -281,6 +281,16 @@ class Client extends Model
             ->first();
     }
 
+    public function previousCareMonth()
+    {
+        $cmStartDate = date('Y-m-d', strtotime('first day of last month'));
+        
+        return CareMonth
+            ::where('client_id', $this->id)
+            ->where('start_date',  $cmStartDate)
+            ->first();
+    }
+
     public function measurementsInCareMonth(CareMonth $careMonth)
     {
         $cmStartDate = strtotime($careMonth->start_date);
@@ -915,4 +925,10 @@ ORDER BY m.ts DESC
         }
         return false;
     }
+
+    public function clientEngagementStatus(){
+        return $this->hasOne(Status::class, 'id', 'client_engagement_status_id');
+    }
+
+
 }

+ 26 - 2
resources/views/app/admin/bdt_devices_table.blade.php

@@ -1,19 +1,28 @@
-	<table class="table table-striped p-0 m-0 table-sm border-top border-bottom text-nowrap">
+	<table class="table table-striped p-0 m-0 table-sm border-top border-bottom ">
 		<thead class="bg-light">
 			<tr>
+			<th class="border-0">Device Type</th>
 				<th class="border-0">IMEI</th>
 				<th class="border-0">Issued Yet?</th>
 				<th class="border-0">Client</th>
+				<th class="border-0">Used?</th>
 				<th class="border-0">MCP</th>
 				<th class="border-0">Issue Date</th>
 				<th class="border-0">Supply Order Status</th>
 				<th class="border-0">Last Meas. Date</th>
 				<th class="border-0">Last Meas. Days Ago</th>
+				<th class="border-0"># Days with Remote Meas. this Month</th>
+				<th class="border-0"># Days with Remote Meas. last Month</th>
+				<th class="border-0">Client Engagement Status Category</th>
+				<th class="border-0">Admin Engagement Assessment Status</th>
+				<th class="border-0">Mcp Engagement Assessment Status</th>
+				<th class="border-0">Default Na Engagement Assessment Status</th>
 			</tr>
 		</thead>
 		<tbody>
 			@foreach($bdtDevices as $bdtDevice)
 			<tr>
+				<td>{{$bdtDevice->category}}</td>
 				<td>{{$bdtDevice->imei}}</td>
 				<td>{{$bdtDevice->clientBDTDevice ? 'Yes': 'No'}}</td>
 				<td>
@@ -25,6 +34,7 @@
 						-
 					@endif 
 				</td>
+				<td>{{@$bdtDevice->clientBDTDevice->mostRecentMeasurement ? 'Yes': 'No'}}</td>
 				<td>
 					@if($bdtDevice->clientBDTDevice && $bdtDevice->clientBDTDevice->client && $bdtDevice->clientBDTDevice->client->mcp)
 						{{$bdtDevice->clientBDTDevice->client->mcp->name_first}} {{$bdtDevice->clientBDTDevice->client->mcp->name_last}}
@@ -79,9 +89,23 @@
 						-
 					@endif 	
 				</td>
+				<td>
+					@if($bdtDevice->clientBDTDevice)
+						{{$bdtDevice->clientBDTDevice->client->currentCareMonth()->number_of_days_with_remote_measurements}}
+					@endif
+				</td>
+				<td>
+					@if($bdtDevice->clientBDTDevice)
+						{{$bdtDevice->clientBDTDevice->client->previousCareMonth()->number_of_days_with_remote_measurements}}
+					@endif
+				</td>
+				<td>{{@$bdtDevice->clientBDTDevice->client->client_engagement_status_category}}
+				<td>{{@$bdtDevice->clientBDTDevice->client->adminEngagementAssessmentStatus->status_category}}
+				<td>{{@$bdtDevice->clientBDTDevice->client->mcpEngagementAssessmentStatus->status_category}}
+				<td>{{@$bdtDevice->clientBDTDevice->client->defaultNaEngagementAssessmentStatus->status_category}}
 			</tr>
 			@endforeach
-
+		
 			@if(count($bdtDevices) === 0)
 			<tr>
 				<td colspan="24">No records found!</td>