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

Updated inputs to createForGeneric

Vijayakrishnan 3 жил өмнө
parent
commit
03febc11c2

+ 4 - 0
app/Models/Pro.php

@@ -566,4 +566,8 @@ class Pro extends Model
         return $this->hasOne(Client::class, 'id', 'shadow_client_id');
     }
 
+    public function defaultCompanyPro() {
+        return $this->hasOne(CompanyPro::class, 'id', 'default_company_pro_id');
+    }
+
 }

+ 30 - 0
resources/views/app/generic-bills/add-bill-form/Note.blade.php

@@ -1,5 +1,32 @@
 <?php $genericPro = @$note && $note->allyPro ? $note->allyPro : $pro; ?>
 <?php $genericRates = $genericPro->genericRates(); ?>
+<?php $genericCompanyPro = $genericPro->defaultCompanyPro; ?>
+
+{{-- if no defaultCompanyPro on this pro, STOP --}}
+@if(!$genericPro->defaultCompanyPro)
+    <form url="/api/bill/createForGeneric">
+        <div class="border rounded bg-aliceblue p-2 text-nowrap">
+            <div class="mb-2 font-weight-bold">
+                <i class="fa fa-exclamation-triangle text-warning-mellow mr-2"></i>
+                Cannot create bill!
+            </div>
+            Default company pro is not set.
+        </div>
+    </form>
+@else
+    {{-- if no generic rates for this pro, STOP --}}
+    @if(!$genericRates || !count($genericRates))
+        <form url="/api/bill/createForGeneric">
+            <div class="border rounded bg-aliceblue p-2 text-nowrap">
+                <div class="mb-2 font-weight-bold">
+                    <i class="fa fa-exclamation-triangle text-warning-mellow mr-2"></i>
+                    Cannot create bill!
+                </div>
+                No generic rates found for pro.
+            </div>
+        </form>
+    @else
+
 <form url="/api/bill/createForGeneric">
     @if(hasActiveGenericBill($genericPro, @$patient, @$entityType, @$entityUid))
         <div class="border rounded bg-aliceblue p-2 width-200px">
@@ -34,3 +61,6 @@
     @endif
 </form>
 @include('app.generic-bills.add-bill-form._default-script')
+
+    @endif
+@endif

+ 3 - 3
resources/views/app/generic-bills/add-bill-form/_default-fields.blade.php

@@ -1,8 +1,8 @@
 <div class="mb-2 min-width-300px">
-    <label for="" class="text-secondary text-sm">Pro</label>
-    <input type="text" class="form-control form-control-sm" value="{{$genericPro->displayName()}}" readonly>
+    <label for="" class="text-secondary text-sm">Company Pro</label>
+    <div class="p-2 border bg-light rounded">{{$genericCompanyPro->pro->displayName()}} / {{$genericCompanyPro->company->name}}</div>
 </div>
-<input type="hidden" name="genericProUid" value="{{$genericPro->uid}}">
+<input type="hidden" name="genericCompanyProUid" value="{{$genericCompanyPro->uid}}">
 @if(@$note)
     <input type="hidden" name="optionalNoteUid" value="{{$note->uid}}">
 @endif

+ 33 - 5
resources/views/app/generic-bills/add-bill-form/default.blade.php

@@ -1,8 +1,36 @@
 <?php $genericPro = @$note && $note->allyPro ? $note->allyPro : $pro; ?>
 <?php $genericRates = $genericPro->genericRates(); ?>
-<form url="/api/bill/createForGeneric">
-    @include('app.generic-bills.add-bill-form._default-fields')
-    @include('app.generic-bills.add-bill-form._default-actions')
-</form>
-@include('app.generic-bills.add-bill-form._default-script')
+<?php $genericCompanyPro = $genericPro->defaultCompanyPro; ?>
+
+{{-- if no defaultCompanyPro on this pro, STOP --}}
+@if(!$genericCompanyPro)
+    <form url="/api/bill/createForGeneric">
+        <div class="border rounded bg-aliceblue p-2 text-nowrap">
+            <div class="mb-2 font-weight-bold">
+                <i class="fa fa-exclamation-triangle text-warning-mellow mr-2"></i>
+                Cannot create bill!
+            </div>
+            Default company pro is not set.
+        </div>
+    </form>
+@else
+    {{-- if no generic rates for this pro, STOP --}}
+    @if(!$genericRates || !count($genericRates))
+        <form url="/api/bill/createForGeneric">
+            <div class="border rounded bg-aliceblue p-2 text-nowrap">
+                <div class="mb-2 font-weight-bold">
+                    <i class="fa fa-exclamation-triangle text-warning-mellow mr-2"></i>
+                    Cannot create bill!
+                </div>
+                No generic rates found for pro.
+            </div>
+        </form>
+    @else
+        <form url="/api/bill/createForGeneric">
+            @include('app.generic-bills.add-bill-form._default-fields')
+            @include('app.generic-bills.add-bill-form._default-actions')
+        </form>
+        @include('app.generic-bills.add-bill-form._default-script')
+    @endif
+@endif