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

Show quicktext, hh:mm & amount against entry

Vijayakrishnan 4 жил өмнө
parent
commit
53c7acf0ef

+ 14 - 0
app/Helpers/helpers.php

@@ -323,3 +323,17 @@ if(!function_exists('convertToTimezone')) {
         return $_returnRaw ? $date : $date->format('Y-m-d H:i:s');
     }
 }
+
+if(!function_exists('minutes_to_hhmm')) {
+    function minutes_to_hhmm($_minutes)
+    {
+        $h = intval(floor($_minutes / 60));
+        $m = $_minutes;
+        if($h > 0) {
+            $m = $_minutes - $h * 60;
+        }
+        $h = ($h < 10 ? '0' : '') . $h;
+        $m = ($m < 10 ? '0' : '') . $m;
+        return $h . ':' . $m;
+    }
+}

+ 7 - 0
app/Models/Measurement.php

@@ -28,4 +28,11 @@ class Measurement extends Model
         }
         return $minutes;
     }
+
+    public function entriesByPro($pro) {
+        return ClientProgramMonthEntry::where('measurement_id', $this->id)
+            ->where('pro_id', $pro->id)
+            ->where('is_cancelled', false)
+            ->get();
+    }
 }

+ 37 - 11
resources/views/app/patient/programs.blade.php

@@ -149,8 +149,8 @@
             <div class="card-body p-0">
 
                 <div class="row">
-                    <div class="col-4 pr-0">
-                        <div class="border-right">
+                    <div class="col-4 pr-0 border-right">
+                        <div class="">
                             {{-- setup --}}
                             <div class="border-bottom py-1 px-3">
                                 <span class="mr-1 text-secondary">Setup</span>
@@ -388,8 +388,8 @@
                             @endif
                             @if(!!$programMonth)
                                 <div class="ml-auto pr-2">
-                                    <b>{{ $programMonth->time_in_minutes }}</b> mins billed,
-                                    <b>{{ $program->max_monthly_time_in_minutes - $programMonth->time_in_minutes }}</b> mins remaining
+                                    <b>{{ minutes_to_hhmm($programMonth->time_in_minutes) }}</b> billed,
+                                    <b>{{ minutes_to_hhmm($program->max_monthly_time_in_minutes - $programMonth->time_in_minutes) }}</b> remaining
                                 </div>
                             @endif
                         </div>
@@ -407,8 +407,8 @@
                         ?>
                         @foreach($programMeasurements as $measurement)
                             <?php $minutes = $measurement->minutesEntered($pro); ?>
-                            <div class="d-flex align-items-center py-1 px-2 border-bottom">
-                                <div moe relative class="mr-2">
+                            <div class="d-flex align-items-start py-1 px-2 border-bottom">
+                                {{--<div moe relative class="mr-2">
                                     <a class="on-hover-opaque" start show title="Delete">
                                         <i class="font-size-11 fa fa-trash-alt text-danger"></i>
                                     </a>
@@ -441,14 +441,22 @@
                                             <button class="btn btn-sm btn-default mr-2 border" cancel>Cancel</button>
                                         </div>
                                     </form>
+                                </div>--}}
+                                <div>
+                                    <div class="d-flex">
+                                        <span>{{ $measurement->label }}:</span>
+                                        <span class="font-weight-bold ml-1">{{ $measurement->value }}</span>
+                                    </div>
+                                    <div>
+                                        <span class="font-weight-normal text-secondary text-sm">
+                                            {{ friendly_date_time($measurement->effective_date, false) }}
+                                        </span>
+                                    </div>
                                 </div>
-                                <span>{{ $measurement->label }}:</span>
-                                <span class="font-weight-bold ml-1">{{ $measurement->value }}</span>
-                                <span class="font-weight-normal text-secondary ml-2 text-sm">(as on {{ friendly_date_time($measurement->effective_date, false) }})</span>
                                 @php $matchingClientPrograms = $pro->canAddCPMEntryForMeasurement($measurement, $pro); @endphp
                                 @if(1) {{-- TODO:--}}
                                     <div moe>
-                                        <a href="#" class="ml-2 font-weight-normal" start show><i class="fa fa-clock"></i> <b>Entry</b></a>
+                                        <a href="#" class="ml-2 font-weight-normal text-nowrap" start show><b>+ Entry</b></a>
                                         <form url="/api/clientProgramMonthEntry/create">
                                             <input type="hidden" name="measurementUid" value="{{ $measurement->uid }}">
                                             <input type="hidden" name="proUid" value="{{ $pro->uid }}">
@@ -488,7 +496,25 @@
                                     </div>
                                 @endif
                                 @if(!!$programMonth)
-                                    <span class="ml-auto pr-2 text-secondary">{!!  $minutes ? '<b>' . $minutes . '</b> mins billed' : '<i class="fa fa-exclamation-triangle"></i>&nbsp;Entry pending' !!} </span>
+                                    @if($minutes)
+                                        <?php $entries = $measurement->entriesByPro($pro); ?>
+                                        <div class="ml-auto">
+                                        @foreach($entries as $entry)
+                                            <div class="d-flex align-items-start mb-1 pr-2">
+                                                <span class="width-200px text-sm text-right pr-2 text-secondary">{{ $entry->quick_text }}</span>
+                                                <span class="pr-2 text-sm">
+                                                    <i class="fa fa-clock text-secondary on-hover-opaque"></i>
+                                                    {{ minutes_to_hhmm($entry->time_in_minutes) }}
+                                                </span>
+                                                <span class="text-sm font-weight-bold">
+                                                    ${{ round($pro->hourly_rate * ($entry->time_in_minutes / 60), 1) }}
+                                                </span>
+                                            </div>
+                                        @endforeach
+                                        </div>
+                                    @else
+                                        <span class="ml-auto pr-2 text-secondary"><i class="fa fa-exclamation-triangle"></i>&nbsp;Entry pending</span>
+                                    @endif
                                 @elseif($filter === '')
                                     <span class="ml-auto pr-2 text-secondary">Entry pending</span>
                                 @endif