Ver Fonte

Admin update

Samson Mutunga há 10 meses atrás
pai
commit
f674efbb28

+ 1 - 1
app/Http/Controllers/AdminController.php

@@ -179,7 +179,7 @@ class AdminController extends Controller
         $this->filterDateMultiQuery($request, $orders, 'created_at', 'created_at_date_category', 'created_at_date_value_1', 'created_at_date_value_2');
 
 
-        $orders = $orders->orderBy('created_at', 'DESC');
+        $orders = $orders->whereRaw('parent_order_id IS NULL')->orderBy('created_at', 'DESC');
 
         $clonedOrdersQuery = clone $orders;
         $ordersSummary = $this->getOrdersQuickSummary($clonedOrdersQuery);

+ 10 - 4
app/Models/StoreOrder.php

@@ -21,6 +21,10 @@ class StoreOrder extends BaseModel
         return $this->hasOne(User::class, 'id', 'user_id');
     }
 
+    public function associatedOrders($parentOrderId){
+        return StoreOrder::where('parent_order_id', $parentOrderId)->get();
+    }
+
     
     public function paymentMethod(){
         return $this->hasOne(PaymentMethod::class, 'id', 'payment_method_id');
@@ -69,10 +73,12 @@ class StoreOrder extends BaseModel
 
 
     public function total(){
-        $detail = json_decode($this->detail_json);
-        $selectedOptions = json_decode(@$detail->selected_options);
-        if(!$selectedOptions) return 0;
-        return floatval(@$selectedOptions->tests_total);
+        $total = $this->order_total;
+        $orders = $this->associatedOrders($this->id);
+        foreach($orders as $order){
+            $total = $total +  $order->order_total;
+        }
+        return $total;
     }
 
     public function lab(){

+ 3 - 0
config/app.php

@@ -51,6 +51,9 @@ return [
     'check_hepatitis_c' => env('check_hepatitis_c'),
     'check_hiv_antibody' => env('check_hiv_antibody'),
     'check_hiv_rna' => env('check_hiv_rna'),
+    'check_trichomoniasis' => env('check_trichomoniasis'),
+    'check_doxy_pep' => env('check_doxy_pep'),
+    'check_trichomoniasis_test_and_comprehensive_wellness_with_urinalysis' => env('check_trichomoniasis_test_and_comprehensive_wellness_with_urinalysis'),
 
     /*
     |--------------------------------------------------------------------------

+ 17 - 15
config/constants.php

@@ -16,21 +16,23 @@ return [
     ],
 
     'tests' => [
-      'check_10_test_panel_with_early_rna' => '11 Test Panel With Early RNA',
-      'check_10_test_panel' => '11 Test Panel',
-      'check_hsv_1' => 'Herpes 1',
-      'check_hsv_2' => 'Herpes 2',
-      'check_hsv_1_2' => 'Herpes I & II',
-      'check_chlamydia' => 'Chlamydia',
-      'check_gonorrhea' => 'Gonorrhea',
-      'check_chlamydia_gonorrhea' => 'Chlamydia + Gonorrhea',
-      'check_syphillis' => 'Syphilis',
-      'check_hepatitis_a' => 'Hepatitis A',
-      'check_hepatitis_b' => 'Hepatitis B',
-      'check_hepatitis_c' => 'Hepatitis C',
-      'check_hiv_antibody' => 'HIV-1 + HIV-2 Antibody (4th Gen)',
-      'check_hiv_rna' => 'HIV RNA Early Detection',
-      'check_trichomoniasis' => 'Trichomoniasis'
+      'check_10_test_panel_with_early_rna' => '11-Test Panel With Early RNA',
+    'check_10_test_panel' => '11-Test Panel',
+    'check_hsv_1' => 'Herpes 1',
+    'check_hsv_2' => 'Herpes 2',
+    'check_hsv_1_2' => 'Herpes I & II',
+    'check_chlamydia' => 'Chlamydia',
+    'check_gonorrhea' => 'Gonorrhea',
+    'check_chlamydia_gonorrhea' => 'Chlamydia + Gonorrhea',
+    'check_syphillis' => 'Syphilis',
+    'check_hepatitis_a' => 'Hepatitis A',
+    'check_hepatitis_b' => 'Hepatitis B',
+    'check_hepatitis_c' => 'Hepatitis C',
+    'check_hiv_antibody' => 'HIV-1 + HIV-2 Antibody (4th Gen)',
+    'check_hiv_rna' => 'HIV RNA Early Detection',
+    'check_trichomoniasis' => 'Trichomoniasis',
+    'check_trichomoniasis_test_and_comprehensive_wellness_with_urinalysis' => 'Trichomoniasis + Comprehensive Wellness Panel With a Urinalysis',
+    'check_doxy_pep' => 'DoxyPEP'
     ],
 
     'countries' => [

+ 10 - 0
resources/views/app/my-account/admin/orders/partials/order-tests-summary.blade.php

@@ -8,5 +8,15 @@ $tests = (object) $order->testsRequestedInHumanReadable();
                 <td class="w-50 w-lg-75 px-2">{{ $test }}</td>
             </tr>
         @endforeach
+        @foreach($order->associatedOrders($order->id) as $assocOrder)
+        <?php
+            $tests = (object) $assocOrder->testsRequestedInHumanReadable();
+        ?>
+        @foreach ($tests as $test)
+            <tr>
+                <td class="w-50 w-lg-75 px-2">{{ $test }}</td>
+            </tr>
+        @endforeach
+        @endforeach
     </tbody>
 </table>

+ 6 - 2
resources/views/app/my-account/admin/orders/sub/dashboard.blade.php

@@ -60,13 +60,17 @@
                 <div class="card-body">
                     <div>
                         <?php
-                        $tests = (object) $order->testsRequestedInHumanReadable();
+                        $tests = $order->testsRequestedInHumanReadable();
+                        $subOrders = $order->associatedOrders($order->id);
+                        foreach($subOrders as $subOrder){
+                            $tests = array_merge($tests, $subOrder->testsRequestedInHumanReadable());
+                        }
                         ?>
 
                     </div>
                     <table class="table table-sm table-bordered border w-100 mb-0">
                         <tbody>
-                            @foreach ($tests as $test)
+                            @foreach ($tests as $key=>$test)
                                 <tr>
                                     <td class="w-50 w-lg-75 px-2">{{ $test }}</td>
                                 </tr>

+ 8 - 1
resources/views/app/my-account/admin/orders/sub/preview-invoice.blade.php

@@ -86,7 +86,14 @@
                                 <tr height="15">
                                     <td colspan="5"></td>
                                 </tr>
-                                @foreach($order->testsRequested() as  $tkey => $test)
+                                <?php 
+                                    $ordersTests = $order->testsRequested();
+                                    $subOrders = $order->associatedOrders($order->id);
+                                    foreach($subOrders as $subOrder){
+                                        $ordersTests = array_merge($ordersTests, $subOrder->testsRequested());
+                                    }
+                                ?>
+                                @foreach($ordersTests as  $tkey => $test)
                                 <tr>
                                   <td colspan="3" style="padding:0 0 0 15px;vertical-align:top;font-family:'Helvetica Neue',Helvetica,Arial,sans-serif">
                                     <span style="font-weight:600;">{{ str_replace('Check ', '', toHumanReadable($test)) }}</span>