فهرست منبع

Patient -> supply orders refactor

Samson Mutunga 1 سال پیش
والد
کامیت
9157a9db80
2فایلهای تغییر یافته به همراه15 افزوده شده و 8 حذف شده
  1. 8 1
      app/Http/Controllers/PatientController.php
  2. 7 7
      resources/views/app/patient/supply-orders.blade.php

+ 8 - 1
app/Http/Controllers/PatientController.php

@@ -38,6 +38,7 @@ use Illuminate\Support\Facades\File;
 use App\Models\Measurement;
 use App\Models\ClientReviewRequest;
 use App\Models\Point;
+use App\Models\SupplyOrderView;
 use Illuminate\Support\Facades\Http;
 use PDF;
 
@@ -614,8 +615,14 @@ class PatientController extends Controller
 
     public function supplyOrders(Request $request, Client $patient, SupplyOrder $supplyOrder = null)
     {
+        $supplyOrders = null;
+        $activeSupplyOrders = null;
+        $cancelledSupplyOrders = null;
+        $supplyOrders = SupplyOrderView::where('client_id', $patient->id)->orderBy('created_at', 'desc')->get();
+        $activeSupplyOrders = SupplyOrderView::where('client_id', $patient->id)->where('is_cancelled', false)->orderBy('created_at', 'desc')->get();
+        $cancelledSupplyOrders = SupplyOrderView::where('client_id', $patient->id)->where('is_cancelled', true)->orderBy('created_at', 'desc')->get();
         $products = Product::where('is_active', true)->orderBy('created_at', 'desc')->get();
-        return view('app.patient.supply-orders', compact('patient', 'supplyOrder', 'products'));
+        return view('app.patient.supply-orders', compact('patient', 'supplyOrder', 'products', 'supplyOrders', 'activeSupplyOrders', 'cancelledSupplyOrders'));
     }
 
     public function shipments(Request $request, Client $patient, Shipment $shipment = null)

+ 7 - 7
resources/views/app/patient/supply-orders.blade.php

@@ -98,14 +98,14 @@
             <div class="flex-grow-1">
                 <table class="table table-sm table-striped table-bordered mb-0" style="table-layout: fixed">
                     <?php
-                    $supplyOrdersList = $patient->activeSupplyOrders;
+                    $supplyOrdersList = $activeSupplyOrders;
                     if(request()->input('filter')) {
                         switch(request()->input('filter')) {
                             case 'cancelled':
-                                $supplyOrdersList = $patient->cancelledSupplyOrders;
+                                $supplyOrdersList = $cancelledSupplyOrders;
                                 break;
                             case 'all':
-                                $supplyOrdersList = $patient->supplyOrders;
+                                $supplyOrdersList = $supplyOrders;
                                 break;
                         }
                     }
@@ -128,11 +128,11 @@
                                 <td>
                                     @if(request()->input('note-uid') && request()->input('popupmode'))
                                         <a class="c-pointer" onclick="return refreshDynamicStagPopup('{{route('patients.view.supply-orders', ['patient' => $patient, 'supplyOrder' => $iSupplyOrder])}}?{{request()->input('filter') ? 'filter=' . request()->input('filter') : ''}}&popupmode=1&{{request()->input('note-uid') ? 'note-uid=' . request()->input('note-uid') : ''}}')">
-                                            {{ $iSupplyOrder->product->title }}
+                                            {{ $iSupplyOrder->product_title }}
                                         </a>
                                     @else
                                         <a href="{{route('patients.view.supply-orders', ['patient' => $patient, 'supplyOrder' => $iSupplyOrder])}}{{request()->input('filter') ? '?filter=' . request()->input('filter') : ''}}">
-                                            {{ $iSupplyOrder->product->title }}
+                                            {{ $iSupplyOrder->product_title }}
                                         </a>
                                     @endif
                                     @if($iSupplyOrder->is_cancelled)
@@ -141,12 +141,12 @@
                                 </td>
                                 <td>{{ $iSupplyOrder->reason }}</td>
                                 <td>{{ friendlier_date_time($iSupplyOrder->created_at) }}</td>
-                                <td>{{ $iSupplyOrder->is_signed_by_pro ? $iSupplyOrder->signedPro->displayName() : '-' }}</td>
+                                <td>{{ $iSupplyOrder->signed_by_pro_display_name ? $iSupplyOrder->signed_by_pro_display_name : '-' }}</td>
                                 <td>{{ $iSupplyOrder->is_cancelled ? 'Yes' : 'No' }}</td>
                                 <td>
                                     @if($iSupplyOrder->shipment_id)
                                         <i class="fa fa-building"></i>
-                                        {{$iSupplyOrder->shipment->status ? $iSupplyOrder->shipment->status : 'CREATED'}}
+                                        {{$iSupplyOrder->shipment_status ? $iSupplyOrder->shipment_status : 'CREATED'}}
                                     @elseif($iSupplyOrder->is_cleared_for_shipment)
                                         <span class="text-info">
                                             <i class="fa fa-user-nurse"></i>