Forráskód Böngészése

Pro-financials - grand total and per-company totals on top

Vijayakrishnan 3 éve
szülő
commit
b2d20e67bf

+ 19 - 1
app/Http/Controllers/PracticeManagementController.php

@@ -1001,6 +1001,24 @@ SELECT effective_date, count(*), sum(number_of_units) as units FROM bill WHERE c
         } else {
             $targetPro = $performerPro;
         }
+
+        // calculate totals (without pagination)
+        $fPros = Pro::whereNotNull('balance')->where('balance', '>', 0)->get();
+        $grandTotal = 0;
+        $companies = [];
+        foreach ($fPros as $row) {
+            foreach($row->companyPros as $companyPro) {
+                if($companyPro->balance) {
+                    if(!isset($companies[$companyPro->company->name])) {
+                        $companies[$companyPro->company->name] = 0;
+                    }
+                    $companies[$companyPro->company->name] += $companyPro->balance;
+                    $grandTotal += $companyPro->balance;
+                }
+            }
+        }
+        arsort($companies);
+
         $fPros = Pro::whereNotNull('balance');
         if($targetPro) {
             $fPros = $fPros->where('uid', $targetPro->uid);
@@ -1010,7 +1028,7 @@ SELECT effective_date, count(*), sum(number_of_units) as units FROM bill WHERE c
             ->orderBy('name_first')
             ->orderBy('name_last')
             ->paginate();
-        return view('app.practice-management.pro-financials', compact('fPros', 'targetPro'));
+        return view('app.practice-management.pro-financials', compact('fPros', 'targetPro', 'grandTotal', 'companies'));
     }
 
     public function hcpBillMatrix(Request $request, $proUid = null)

+ 16 - 34
resources/views/app/practice-management/pro-financials.blade.php

@@ -2,28 +2,25 @@
 
 @section('content')
 
-    <?php
-    // calculate totals
-    $grandTotal = 0;
-    $companies = [];
-    foreach ($fPros as $row) {
-        foreach($row->companyPros as $companyPro) {
-            if($companyPro->balance) {
-                if(!isset($companies[$companyPro->company->name])) {
-                    $companies[$companyPro->company->name] = 0;
-                }
-                $companies[$companyPro->company->name] += $companyPro->balance;
-                $grandTotal += $companyPro->balance;
-            }
-        }
-    }
-    arsort($companies);
-    ?>
-
     <div class="p-3 mcp-theme-1" id="processing-bill-matrix">
 
         <div class="card">
-            <div class="card-header px-2 py-1 d-flex align-items-center">
+            <!-- totals -->
+            <div class="card-header px-2 py-2 font-weight-bold bg-white">
+                <div class="d-flex align-items-baseline mb-1">
+                    <div class="font-size-16 width-100px">{{friendly_money($grandTotal)}}</div>
+                    <div class="font-size-16">Total</div>
+                </div>
+                @foreach($companies as $name => $total)
+                    @if(intval(round($total)) !== 0)
+                        <div class="d-flex align-items-baseline">
+                            <div class="width-100px">{{friendly_money($total)}}</div>
+                            <div>{{$name}}</div>
+                        </div>
+                    @endif
+                @endforeach
+            </div>
+            <div class="card-header px-2 py-1 d-flex align-items-center border-bottom-0">
                 <strong class="text-nowrap">
                     <i class="fas fa-user"></i>
                     Pro Financials
@@ -41,21 +38,6 @@
                     <a href="/practice-management/pro-financials" class="ml-2">Clear Filter</a>
                 @endif
             </div>
-            <!-- totals -->
-            <div class="card-header px-2 py-2 font-weight-bold bg-white border-bottom-0">
-                <div class="d-flex align-items-baseline mb-1">
-                    <div class="font-size-16 width-100px">{{friendly_money($grandTotal)}}</div>
-                    <div class="font-size-16">Total</div>
-                </div>
-                @foreach($companies as $name => $total)
-                    @if(intval(round($total)) !== 0)
-                        <div class="d-flex align-items-baseline">
-                            <div class="width-100px">{{friendly_money($total)}}</div>
-                            <div>{{$name}}</div>
-                        </div>
-                    @endif
-                @endforeach
-            </div>
             <div class="card-body p-0">
                 <table class="table table-sm table-striped table-hover p-0 m-0">
                     <thead class="bg-light">