Kaynağa Gözat

Prevent entry addition when bill existing

Vijayakrishnan Krishnan 5 yıl önce
ebeveyn
işleme
a45fca0082

+ 128 - 124
resources/views/app/patient/care-month/dashboard.blade.php

@@ -66,6 +66,32 @@
 
         <?php
         $entries = $careMonth->entries;
+
+        $cmBills = $careMonth->getBillsOfType('CM');
+        $activeCMBill = false;
+        $cancelledCMBills = new \Illuminate\Support\Collection();
+        foreach ($cmBills as $cmBill) {
+            if(!$cmBill->is_cancelled && $careMonth->cm_bill_id === $cmBill->id) {
+                $activeCMBill = $cmBill;
+                break;
+            }
+            else if($cmBill->is_cancelled) {
+                $cancelledCMBills->add($cmBill);
+            }
+        }
+
+        $rmBills = $careMonth->getBillsOfType('RM');
+        $activeRMBill = false;
+        $cancelledRMBills = new \Illuminate\Support\Collection();
+        foreach ($rmBills as $rmBill) {
+            if(!$rmBill->is_cancelled && $careMonth->rm_bill_id === $rmBill->id) {
+                $activeRMBill = $rmBill;
+                break;
+            }
+            else if($rmBill->is_cancelled) {
+                $cancelledRMBills->add($rmBill);
+            }
+        }
         ?>
 
         <div class="row">
@@ -73,53 +99,57 @@
                 <div class="d-flex align-items-center">
                     <h6 class="my-0 text-secondary font-weight-bold text-dark">CM Time Entries</h6>
                     <span class="mx-2 text-secondary">|</span>
-                    <div moe>
-                        <a start show class="py-0 mb-3">Add</a>
-                        <form url="/api/careMonthEntry/createForCm">
-                            <input type="hidden" name="careMonthUid" value="{{ $careMonth->uid }}">
-                            <div class="mb-2">
-                                <select class="form-control form-control-sm" name="proUid">
-                                    <option value="">-- Select Pro --</option>
-                                    @foreach($pros as $pro)
-                                    <option value="{{ $pro->uid }}">{{ $pro->name_display }}</option>
-                                    @endforeach
-                                </select>
-                            </div>
-                            <div class="mb-2">
-                                <input type="date" class="form-control form-control-sm" name="effectiveDate"
-                                       value="" placeholder="Effective Date">
-                            </div>
-                            <div class="mb-2">
-                                <input type="number" min="0" max="9999" class="form-control form-control-sm cm-time-value" name="timeInSeconds"
-                                       value="" placeholder="Time in Seconds">
-                            </div>
-                            <div class="mb-2 d-flex align-items-center">
-                                <span>Time Specific:</span>
-                                <input type="checkbox" name="isTimeSpecific" class="ml-1"
-                                       onchange="enableTimeSpecificFields(this.checked, 'cm-time-value', 'cm-time-range')">
-                            </div>
-                            <div class="mb-2">
-                                <input type="time" class="form-control form-control-sm cm-time-range" name="startingTime"
-                                       value="" placeholder="Starting Time" disabled>
-                            </div>
-                            <div class="mb-2">
-                                <input type="time" class="form-control form-control-sm cm-time-range" name="endingTime"
-                                       value="" placeholder="Ending Time" disabled>
-                            </div>
-                            <div class="mb-2">
-                                <input type="text" class="form-control form-control-sm" name="contentText"
-                                       value="" placeholder="Content Text">
-                            </div>
-                            <div class="mb-2">
-                                <input type="text" class="form-control form-control-sm" name="contentDetail"
-                                       value="" placeholder="Content Detail">
-                            </div>
-                            <div class="d-flex align-items-center">
-                                <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
-                                <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
-                            </div>
-                        </form>
-                    </div>
+                    @if(!$activeCMBill)
+                        <div moe>
+                            <a start show class="py-0 mb-3">Add</a>
+                            <form url="/api/careMonthEntry/createForCm">
+                                <input type="hidden" name="careMonthUid" value="{{ $careMonth->uid }}">
+                                <div class="mb-2">
+                                    <select class="form-control form-control-sm" name="proUid">
+                                        <option value="">-- Select Pro --</option>
+                                        @foreach($pros as $pro)
+                                        <option value="{{ $pro->uid }}">{{ $pro->name_display }}</option>
+                                        @endforeach
+                                    </select>
+                                </div>
+                                <div class="mb-2">
+                                    <input type="date" class="form-control form-control-sm" name="effectiveDate"
+                                           value="" placeholder="Effective Date">
+                                </div>
+                                <div class="mb-2">
+                                    <input type="number" min="0" max="9999" class="form-control form-control-sm cm-time-value" name="timeInSeconds"
+                                           value="" placeholder="Time in Seconds">
+                                </div>
+                                <div class="mb-2 d-flex align-items-center">
+                                    <span>Time Specific:</span>
+                                    <input type="checkbox" name="isTimeSpecific" class="ml-1"
+                                           onchange="enableTimeSpecificFields(this.checked, 'cm-time-value', 'cm-time-range')">
+                                </div>
+                                <div class="mb-2">
+                                    <input type="time" class="form-control form-control-sm cm-time-range" name="startingTime"
+                                           value="" placeholder="Starting Time" disabled>
+                                </div>
+                                <div class="mb-2">
+                                    <input type="time" class="form-control form-control-sm cm-time-range" name="endingTime"
+                                           value="" placeholder="Ending Time" disabled>
+                                </div>
+                                <div class="mb-2">
+                                    <input type="text" class="form-control form-control-sm" name="contentText"
+                                           value="" placeholder="Content Text">
+                                </div>
+                                <div class="mb-2">
+                                    <input type="text" class="form-control form-control-sm" name="contentDetail"
+                                           value="" placeholder="Content Detail">
+                                </div>
+                                <div class="d-flex align-items-center">
+                                    <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
+                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                                </div>
+                            </form>
+                        </div>
+                    @else
+                        <span class="text-secondary">Cannot modify. Bill existing.</span>
+                    @endif
                 </div>
                 <table class="table table-striped table-sm table-bordered mt-2 mb-0">
                     <thead>
@@ -168,53 +198,57 @@
                 <div class="d-flex align-items-center">
                     <h6 class="my-0 text-secondary font-weight-bold text-dark">RM Time Entries</h6>
                     <span class="mx-2 text-secondary">|</span>
-                    <div moe>
-                        <a start show class="py-0 mb-3">Add</a>
-                        <form url="/api/careMonthEntry/createForRm">
-                            <input type="hidden" name="careMonthUid" value="{{ $careMonth->uid }}">
-                            <div class="mb-2">
-                                <select class="form-control form-control-sm" name="proUid">
-                                    <option value="">-- Select Pro --</option>
-                                    @foreach($pros as $pro)
-                                        <option value="{{ $pro->uid }}">{{ $pro->name_display }}</option>
-                                    @endforeach
-                                </select>
-                            </div>
-                            <div class="mb-2">
-                                <input type="date" class="form-control form-control-sm" name="effectiveDate"
-                                       value="" placeholder="Effective Date">
-                            </div>
-                            <div class="mb-2">
-                                <input type="number" min="0" max="9999" class="form-control form-control-sm rm-time-value" name="timeInSeconds"
-                                       value="" placeholder="Time in Seconds">
-                            </div>
-                            <div class="mb-2 d-flex align-items-center">
-                                <span>Time Specific:</span>
-                                <input type="checkbox" name="isTimeSpecific" class="ml-1"
-                                       onchange="enableTimeSpecificFields(this.checked, 'rm-time-value', 'rm-time-range')">
-                            </div>
-                            <div class="mb-2">
-                                <input type="time" class="form-control form-control-sm rm-time-range" name="startingTime"
-                                       value="" placeholder="Starting Time" disabled>
-                            </div>
-                            <div class="mb-2">
-                                <input type="time" class="form-control form-control-sm rm-time-range" name="endingTime"
-                                       value="" placeholder="Ending Time" disabled>
-                            </div>
-                            <div class="mb-2">
-                                <input type="text" class="form-control form-control-sm" name="contentText"
-                                       value="" placeholder="Content Text">
-                            </div>
-                            <div class="mb-2">
-                                <input type="text" class="form-control form-control-sm" name="contentDetail"
-                                       value="" placeholder="Content Detail">
-                            </div>
-                            <div class="d-flex align-items-center">
-                                <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
-                                <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
-                            </div>
-                        </form>
-                    </div>
+                    @if(!$activeRMBill)
+                        <div moe>
+                            <a start show class="py-0 mb-3">Add</a>
+                            <form url="/api/careMonthEntry/createForRm">
+                                <input type="hidden" name="careMonthUid" value="{{ $careMonth->uid }}">
+                                <div class="mb-2">
+                                    <select class="form-control form-control-sm" name="proUid">
+                                        <option value="">-- Select Pro --</option>
+                                        @foreach($pros as $pro)
+                                            <option value="{{ $pro->uid }}">{{ $pro->name_display }}</option>
+                                        @endforeach
+                                    </select>
+                                </div>
+                                <div class="mb-2">
+                                    <input type="date" class="form-control form-control-sm" name="effectiveDate"
+                                           value="" placeholder="Effective Date">
+                                </div>
+                                <div class="mb-2">
+                                    <input type="number" min="0" max="9999" class="form-control form-control-sm rm-time-value" name="timeInSeconds"
+                                           value="" placeholder="Time in Seconds">
+                                </div>
+                                <div class="mb-2 d-flex align-items-center">
+                                    <span>Time Specific:</span>
+                                    <input type="checkbox" name="isTimeSpecific" class="ml-1"
+                                           onchange="enableTimeSpecificFields(this.checked, 'rm-time-value', 'rm-time-range')">
+                                </div>
+                                <div class="mb-2">
+                                    <input type="time" class="form-control form-control-sm rm-time-range" name="startingTime"
+                                           value="" placeholder="Starting Time" disabled>
+                                </div>
+                                <div class="mb-2">
+                                    <input type="time" class="form-control form-control-sm rm-time-range" name="endingTime"
+                                           value="" placeholder="Ending Time" disabled>
+                                </div>
+                                <div class="mb-2">
+                                    <input type="text" class="form-control form-control-sm" name="contentText"
+                                           value="" placeholder="Content Text">
+                                </div>
+                                <div class="mb-2">
+                                    <input type="text" class="form-control form-control-sm" name="contentDetail"
+                                           value="" placeholder="Content Detail">
+                                </div>
+                                <div class="d-flex align-items-center">
+                                    <button class="btn btn-sm btn-primary mr-2" submit>Save</button>
+                                    <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
+                                </div>
+                            </form>
+                        </div>
+                    @else
+                        <span class="text-secondary">Cannot modify. Bill existing.</span>
+                    @endif
                 </div>
                 <table class="table table-striped table-sm table-bordered mt-2 mb-0">
                     <thead>
@@ -263,36 +297,6 @@
 
         <hr class="m-negator mt-4 mb-3">
 
-        <?php
-        $cmBills = $careMonth->getBillsOfType('CM');
-        $activeCMBill = false;
-        $cancelledCMBills = new \Illuminate\Support\Collection();
-        foreach ($cmBills as $cmBill) {
-            if(!$cmBill->is_cancelled && $careMonth->cm_bill_id === $cmBill->id) {
-                $activeCMBill = $cmBill;
-                break;
-            }
-            else if($cmBill->is_cancelled) {
-                $cancelledCMBills->add($cmBill);
-            }
-        }
-        ?>
-
-        <?php
-        $rmBills = $careMonth->getBillsOfType('RM');
-        $activeRMBill = false;
-        $cancelledRMBills = new \Illuminate\Support\Collection();
-        foreach ($rmBills as $rmBill) {
-            if(!$rmBill->is_cancelled && $careMonth->rm_bill_id === $rmBill->id) {
-                $activeRMBill = $rmBill;
-                break;
-            }
-            else if($rmBill->is_cancelled) {
-                $cancelledRMBills->add($rmBill);
-            }
-        }
-        ?>
-
         <div class="row">
 
             {{-- active cm bill --}}