瀏覽代碼

Group actions items by category

Vijayakrishnan Krishnan 4 年之前
父節點
當前提交
7e8dd724a3
共有 2 個文件被更改,包括 18 次插入5 次删除
  1. 3 1
      app/Models/Client.php
  2. 15 4
      resources/views/app/patient/action-items.blade.php

+ 3 - 1
app/Models/Client.php

@@ -35,7 +35,9 @@ class Client extends Model
     }
 
     public function actionItems () {
-        return $this->hasMany(ActionItem::class, 'client_id', 'id')->orderBy('created_at', 'desc');
+        return $this->hasMany(ActionItem::class, 'client_id', 'id')
+            ->orderBy('action_item_category', 'asc')
+            ->orderBy('created_at', 'desc');
     }
 
     public function infoLines() {

+ 15 - 4
resources/views/app/patient/action-items.blade.php

@@ -50,22 +50,31 @@
                 </form>
             </div>
         </div>
-        <table class="table table-striped table-sm table-bordered mb-0" style="table-layout: fixed">
+        <table class="table table-sm table-bordered mb-0" style="table-layout: fixed">
             <thead>
             <tr>
-                <th class="px-2 text-secondary border-bottom-0">Created</th>
                 <th class="px-2 text-secondary border-bottom-0">Category</th>
                 <th class="px-2 text-secondary border-bottom-0">Facility</th>
                 <th class="px-2 text-secondary border-bottom-0 w-25">Action</th>
+                <th class="px-2 text-secondary border-bottom-0">Created</th>
                 <th class="px-2 text-secondary border-bottom-0">Status</th>
                 <th class="px-2 text-secondary border-bottom-0">&nbsp;</th>
             </tr>
             </thead>
             <tbody>
+            <?php $prevItemType = false; ?>
             @foreach($patient->actionItems as $item)
+                @if(!$prevItemType || $prevItemType !== $item->action_item_category)
+                    <tr class="bg-light">
+                        <td colspan="6" class="font-weight-bold px-2">
+                            {{ucwords(str_replace("_", " ", strtolower($item->action_item_category)))}}
+                        </td>
+                    </tr>
+                @endif
                 <tr>
-                    <td class="px-2">{{friendly_date_time($item->created_at, false)}}</td>
-                    <td class="px-2">{{ucwords(str_replace("_", " ", strtolower($item->action_item_category)))}}</td>
+                    <td class="px-2">
+                        &nbsp;
+                    </td>
                     <td class="px-2">
                         {{$item->facility ? $item->facility->name : ''}}
                         <span moe>
@@ -108,6 +117,7 @@
                         </span>
                         <div class="text-sm text-secondary">{{$item->content_detail}}</div>
                     </td>
+                    <td class="px-2">{{friendly_date_time($item->created_at, false)}}</td>
                     <td class="px-2">
                         {{$item->status_category}}
                         <span moe>
@@ -171,6 +181,7 @@
                         </div>
                     </td>
                 </tr>
+                <?php $prevItemType = $item->action_item_category; ?>
             @endforeach
             </tbody>
         </table>