Переглянути джерело

Practice > My Favorites [wip]

Vijayakrishnan 4 роки тому
батько
коміт
b16533c012

+ 12 - 0
app/Http/Controllers/PracticeManagementController.php

@@ -8,6 +8,7 @@ use App\Models\Client;
 use App\Models\McpRequest;
 use App\Models\Note;
 use App\Models\Pro;
+use App\Models\ProFavorite;
 use App\Models\ProGeneralAvailability;
 use App\Models\ProRate;
 use App\Models\ProSpecificAvailability;
@@ -147,6 +148,17 @@ class PracticeManagementController extends Controller
         return view('app.practice-management.my-text-shortcuts', compact('myTextShortcuts'));
     }
 
+    public function myFavorites(Request $request)
+    {
+        $performer = $this->performer();
+        $myFavorites = ProFavorite::where('pro_id', $performer->pro_id)
+            ->where('is_removed', false)
+            ->orderBy('category', 'asc')
+            ->orderBy('position_index', 'asc')
+            ->get();
+        return view('app.practice-management.my-favorites', compact('myFavorites'));
+    }
+
     public function proAvailability(Request $request, $proUid = null)
     {
         $performer = $this->performer();

+ 12 - 3
app/Models/Pro.php

@@ -262,14 +262,14 @@ class Pro extends Model
     public function getMyClientIds(){
 
         $accessibleClientIds = [];
-        
+
         $clientProAccesses = ClientProAccess::where('pro_id', $this->id)->get();
         foreach($clientProAccesses as $cpa){
             $accessibleClientIds[] = $cpa->client_id;
         }
 
         $appointmentClientIds = [];
-    
+
         $appointments = Appointment::where('pro_id', $this->id)->get();
         foreach($appointments as $appts){
             $appointmentClientIds[] = $appts->client_id;
@@ -288,8 +288,17 @@ class Pro extends Model
         foreach($clients as $client){
             $clientIds[] = $client->id;
         }
-        
+
         return $clientIds;
     }
 
+    public function favoritesByCategory($_category) {
+        return ProFavorite::where('pro_id', $this->id)
+            ->where('is_removed', false)
+            ->where('category', $_category)
+            ->orderBy('category', 'asc')
+            ->orderBy('position_index', 'asc')
+            ->get();
+    }
+
 }

+ 16 - 0
app/Models/ProFavorite.php

@@ -0,0 +1,16 @@
+<?php
+
+namespace App\Models;
+
+# use Illuminate\Database\Eloquent\Model;
+
+class ProFavorite extends Model
+{
+
+    protected $table = 'pro_favorite';
+
+    public function pro() {
+        return $this->hasOne(Pro::class, 'pro_id', 'id');
+    }
+
+}

+ 58 - 0
resources/views/app/practice-management/my-favorites.blade.php

@@ -0,0 +1,58 @@
+@extends ('layouts/template')
+
+@section('content')
+
+    <div class="p-3 mcp-theme-1">
+    <div class="card">
+
+        <div class="card-header px-3 py-2 d-flex align-items-center">
+            <strong class="">
+                <i class="fas fa-user-injured"></i>
+                Favorites
+            </strong>
+            <span class="ml-3 text-secondary">
+                You can add Allergy, Rx and Dx entries to your favorites from their respective sections
+            </span>
+        </div>
+        <div class="card-body p-0">
+            <table class="table table-condensed p-0 m-0">
+                <thead class="bg-light">
+                <tr>
+                    <th class="px-3 border-0 width-100px">Category</th>
+                    <th class="border-0">Content</th>
+                    <th class="border-0 w-25">&nbsp;</th>
+                </tr>
+                </thead>
+                <tbody>
+                @foreach($myFavorites as $favorite)
+                    <tr>
+                        <td class="px-3">{{ $favorite->category }}</td>
+                        <td><pre class="mb-0">{{ $favorite->data }}</pre></td>
+                        <td>
+                            <div class="d-flex align-items-center">
+                                <div moe relative wide class="mr-2">
+                                    <a start show class="text-danger">
+                                        <i class="fa fa-trash-alt"></i>
+                                    </a>
+                                    <form url="/api/proFavorite/remove" right>
+                                        <input type="hidden" name="uid" value="{{$favorite->uid}}">
+                                        <p>
+                                            Are you sure you want to remove this from your favorites?
+                                        </p>
+                                        <div class="form-group m-0">
+                                            <button submit class="btn btn-danger btn-sm mr-2">Yes</button>
+                                            <button cancel class="btn btn-default border btn-sm mr-2">No</button>
+                                        </div>
+                                    </form>
+                                </div>
+                            </div>
+                        </td>
+                    </tr>
+                @endforeach
+                </tbody>
+            </table>
+        </div>
+    </div>
+    </div>
+
+@endsection

+ 2 - 2
resources/views/layouts/template.blade.php

@@ -85,7 +85,7 @@
                 @endif
                 <li class="nav-item dropdown">
                     <a class="nav-link dropdown-toggle" href="#" id="practice-management" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="mr-1 fas fa-tasks"></i> Practice</a>
-                    <div class="dropdown-menu" aria-labelledby="practice-management">
+                    <div class="dropdown-menu mcp-theme-1" aria-labelledby="practice-management">
                         {{--<a class="dropdown-item" href="{{ route('practice-management.dashboard') }}">Dashboard</a>--}}
                         @if($pro && $pro->pro_type == 'ADMIN')
                             <a class="dropdown-item" href="/practice-management/rates/all">Payment Rates</a>
@@ -95,8 +95,8 @@
                         <a class="dropdown-item" href="/practice-management/bills/not-yet-signed">Pending Bills to Sign</a>
                         <a class="dropdown-item" href="/practice-management/notes/not-yet-signed">Pending Notes to Sign</a>
                         <a class="dropdown-item" href="{{ route('unmapped-sms') }}">Unmapped SMS</a>
-                        {{--<a class="dropdown-item" href="/practice-management/hr">HR</a>--}}
                         <a class="dropdown-item" href="{{ route('practice-management.myTextShortcuts') }}">My Text Shortcuts</a>
+                        <a class="dropdown-item" href="{{ route('practice-management.myFavorites') }}">My Favorites</a>
                         <a class="dropdown-item" href="{{ route('practice-management.proAvailability') }}">Pro Availability</a>
                         <a class="dropdown-item" href="{{ route('practice-management.proCalendar') }}">Pro Calendar</a>
                     </div>

+ 1 - 0
routes/web.php

@@ -77,6 +77,7 @@ Route::middleware('pro.auth')->group(function () {
         Route::get('notes/{filter?}', 'PracticeManagementController@notes')->name('notes');
         Route::get('bills/{filter?}', 'PracticeManagementController@bills')->name('bills');
         Route::get('my-text-shortcuts', 'PracticeManagementController@myTextShortcuts')->name('myTextShortcuts');
+        Route::get('my-favorites', 'PracticeManagementController@myFavorites')->name('myFavorites');
         Route::get('pro-availability/{proUid?}', 'PracticeManagementController@proAvailability')->name('proAvailability');
         Route::get('calendar/{proUid?}', 'PracticeManagementController@calendar')->name('proCalendar');