Эх сурвалжийг харах

Generic bills: pagination

Vijayakrishnan Krishnan 1 долоо хоног өмнө
parent
commit
298b9d17fb

+ 5 - 1
app/Helpers/helpers.php

@@ -141,7 +141,7 @@ if(!function_exists('inchesAfterFeetFromInches')) {
 }
 
 if(!function_exists('genericBills')) {
-    function genericBills(Pro $performerPro, $patient,$careMonth, $entityType, $entityUid) {
+    function genericBills(Pro $performerPro, $patient,$careMonth, $entityType, $entityUid, $paginate = false) {
         $genericBills = Bill::where('bill_service_type', 'GENERIC');
         if($performerPro->pro_type !== 'ADMIN') {
             $genericBills = $genericBills->where('generic_pro_id', $performerPro->id);
@@ -163,6 +163,10 @@ if(!function_exists('genericBills')) {
 
 
         }
+        if($paginate) {
+            return $genericBills->orderBy('created_at', 'DESC')->paginate(25);
+        }
+
         return $genericBills->orderBy('created_at', 'DESC')->get();
     }
 }

+ 12 - 2
resources/views/app/generic-bills/inline.blade.php

@@ -10,8 +10,9 @@ use App\Models\Client;
 /** @var Client $patient */
 /** @var $entityType */
 /** @var $entityUid */
+/** @var $paginate */
 
-$genericBills = genericBills($pro, @$patient, @$careMonth, @$entityType, @$entityUid);
+$genericBills = genericBills($pro, @$patient, @$careMonth, @$entityType, @$entityUid, @$paginate);
 ?>
 
 @if(!count($genericBills))
@@ -23,11 +24,20 @@ $genericBills = genericBills($pro, @$patient, @$careMonth, @$entityType, @$entit
 @else
     <div class="{{@$class ? $class : ''}}">
         <div class="d-flex align-items-center mb-2">
-            <p class="font-weight-bold m-0">{{@$label ? $label : 'Admin.'}} Bills</p>
+            <p class="font-weight-bold m-0 font-size-16">{{@$label ? $label : 'Admin.'}} Bills</p>
             @if(!@$noCreate)
                 <span class="mx-2 text-secondary">|</span>
                 @include('app.generic-bills.create_generic-bill')
             @endif
+            @if(@$paginate)
+                <div class="ml-auto">
+                    <div class="px-3 mt-3 d-flex align-items-center">
+                        {{ $genericBills->links() }}
+                        <div class="ml-4 mb-3">Showing <b>{{ $genericBills->firstItem() }}</b> to <b>{{ $genericBills->lastItem() }}</b> (page
+                            {{ $genericBills->currentPage() }}) of <b>{{ $genericBills->total() }}</b></div>
+                    </div>
+                </div>
+            @endif
         </div>
             <table class="table table-sm table-striped mb-0 table-bordered">
                 <thead class="bg-light">

+ 1 - 1
resources/views/app/practice-management/generic-bills.blade.php

@@ -4,7 +4,7 @@
 
     <div class="p-3 mcp-theme-1">
 
-    @include('app.generic-bills.inline', ['adminView' => true, 'noCreate' => true])
+    @include('app.generic-bills.inline', ['adminView' => true, 'noCreate' => true, 'paginate' => true])
 
     </div>