From 52d44e5571eac21b8f5028a2a255110c48bb613e Mon Sep 17 00:00:00 2001 From: Ronald-pro <36841157+Ronald-pro@users.noreply.github.com> Date: Thu, 29 Feb 2024 10:44:33 +0300 Subject: [PATCH 1/4] change on the facility directory search --- app/Http/Controllers/DirectoryController.php | 14 +++++ app/Models/DirectoryLog.php | 17 ++++++ resources/views/directory/search.blade.php | 62 +++++++++++++++++++- routes/web.php | 4 ++ 4 files changed, 94 insertions(+), 3 deletions(-) create mode 100644 app/Models/DirectoryLog.php diff --git a/app/Http/Controllers/DirectoryController.php b/app/Http/Controllers/DirectoryController.php index c0be76d..b1a2390 100644 --- a/app/Http/Controllers/DirectoryController.php +++ b/app/Http/Controllers/DirectoryController.php @@ -4,6 +4,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Http; +use App\Models\DirectoryLog; class DirectoryController extends Controller { @@ -25,4 +26,17 @@ public function directory(Request $request, $facility) return response()->json(['error' => 'API request failed'], $response->status()); } } + public function directoryLog(Request $request) + { + $searchTerm = $request->input('search_term'); + $resultCount = $request->input('result_count'); + + // Save the log + DirectoryLog::create([ + 'search_term' => $searchTerm, + 'result_count' => $resultCount, + ]); + + return response()->json(['status' => 'success']); + } } diff --git a/app/Models/DirectoryLog.php b/app/Models/DirectoryLog.php new file mode 100644 index 0000000..1a8bc66 --- /dev/null +++ b/app/Models/DirectoryLog.php @@ -0,0 +1,17 @@ + + @@ -30,9 +31,14 @@ .logo { max-height: 50px; - /* Set the max height of your logo */ } + @@ -57,8 +63,9 @@
- + +
@@ -70,6 +77,7 @@ Facility Name MFL Code Contact + County Facility Type More @@ -139,6 +147,9 @@ { data: 'Contact' }, + { + data: 'County' + }, { data: 'Facility Type' }, @@ -153,13 +164,33 @@ $('#searchButton').on('click', function() { var facility = $('#searchInput').val(); + if (!facility.trim()) { + Swal.fire({ + icon: 'warning', + title: 'Empty Search', + text: 'Please Enter Facility Name or MFL Code.', + }); + return; + } + Swal.fire({ title: "loading results......", showConfirmButton: false, allowOutsideClick: false }); - var apiUrl = "{{ env('ART_URL') }}directory/" + mfl + '/' + facility; + // var apiUrl = "{{ env('ART_URL') }}directory/" + mfl + '/' + facility; + var isCode = /^\d{5}$/.test(facility); + + var apiUrl; + if (isCode) { + apiUrl = "{{ env('ART_URL') }}facility/directory?code=" + facility; + } else { + apiUrl = "{{ env('ART_URL') }}facility/directory?name=" + facility; + } + + // Hide error message + $('#error-message').hide(); $.ajax({ url: apiUrl, method: 'GET', @@ -180,6 +211,7 @@ 'Facility Name': facility.name, 'MFL Code': facility.code, 'Contact': facility.telephone, + 'County': facility.county, 'Facility Type': facility.facility_type, 'More': moreLink }); @@ -193,6 +225,7 @@ // Show the result table section $('#resultTableSection').show(); + saveSearchLog(facility, facilities.length); }, error: function(error) { console.log(error); @@ -204,6 +237,29 @@ } }); }); + + function saveSearchLog(searchTerm, resultCount) { + // search log + $.ajax({ + headers: { + 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') + }, + url: "{{ route('directory_log') }}", + method: 'POST', + data: { + search_term: searchTerm, + result_count: resultCount + }, + success: function(response) { + // console.log(response); + + }, + error: function(error) { + console.log(error); + + } + }); + } }); diff --git a/routes/web.php b/routes/web.php index 370cea8..5aa6d30 100644 --- a/routes/web.php +++ b/routes/web.php @@ -69,6 +69,9 @@ Route::get('/high/risk/task', ['uses' => 'App\Http\Controllers\HighRiskController@task', 'as' => 'task']); //Route::get('/high/risk/sender', ['uses' => 'App\Http\Controllers\HighRiskController@sender', 'as' => 'sender']); + // facility directory + Route::post('/directory_log', ['uses' => 'App\Http\Controllers\DirectoryController@directoryLog', 'as' => 'directory_log']); + Route::post('/tet', ['uses' => 'App\Http\Controllers\NishauriController@tet', 'as' => 'tet']); Auth::routes(); @@ -313,4 +316,5 @@ Route::get('/program/data', ['uses' => 'App\Http\Controllers\NewReportController@program', 'as' => 'program_data']); Route::get('/program_filter', ['uses' => 'App\Http\Controllers\NewReportController@program_filter', 'as' => 'program_filter']); + }); From 101512a1901be6ebe33444db559a36f09d29372b Mon Sep 17 00:00:00 2001 From: Joshua Murithi Date: Mon, 11 Mar 2024 09:51:31 +0300 Subject: [PATCH 2/4] aligning stretched Coat of arms --- resources/views/landing/page.blade.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/landing/page.blade.php b/resources/views/landing/page.blade.php index 1871ab7..405ee86 100644 --- a/resources/views/landing/page.blade.php +++ b/resources/views/landing/page.blade.php @@ -37,8 +37,8 @@
- - ART Directory Logo + + ART Directory Logo
Facility Directory
From 51955f165240509bdd819df23940e94cc012a366 Mon Sep 17 00:00:00 2001 From: Joshua Murithi Date: Mon, 11 Mar 2024 10:06:09 +0300 Subject: [PATCH 3/4] aligning width --- resources/views/landing/page.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/landing/page.blade.php b/resources/views/landing/page.blade.php index 405ee86..8c5d75d 100644 --- a/resources/views/landing/page.blade.php +++ b/resources/views/landing/page.blade.php @@ -38,7 +38,7 @@
- ART Directory Logo + ART Directory Logo
Facility Directory
From ee9d9f0f9044e6cd104c488aeded37b8c3bda982 Mon Sep 17 00:00:00 2001 From: Ronald-pro <36841157+Ronald-pro@users.noreply.github.com> Date: Thu, 28 Mar 2024 11:01:58 +0300 Subject: [PATCH 4/4] added drug delivery status tracking --- app/Http/Controllers/NishauriController.php | 82 ++++ app/Models/NishauriDrugDelivery.php | 18 + app/Models/NishauriDrugOrder.php | 17 + .../large-vertical-sidebar/header.blade.php | 7 +- .../views/nishauri/drug_delivery.blade.php | 422 ++++++++++++++++++ routes/web.php | 4 + 6 files changed, 549 insertions(+), 1 deletion(-) create mode 100644 app/Models/NishauriDrugDelivery.php create mode 100644 app/Models/NishauriDrugOrder.php create mode 100644 resources/views/nishauri/drug_delivery.blade.php diff --git a/app/Http/Controllers/NishauriController.php b/app/Http/Controllers/NishauriController.php index 4a59898..220dd33 100644 --- a/app/Http/Controllers/NishauriController.php +++ b/app/Http/Controllers/NishauriController.php @@ -18,6 +18,8 @@ use Illuminate\Support\Facades\Auth; use DB; use Carbon\Carbon; +use App\Models\NishauriDrugDelivery; +use App\Models\NishauriDrugOrder; class NishauriController extends Controller @@ -843,4 +845,84 @@ public function filter_nishauri_uptake(Request $request) return $data; } } + + public function drug_delivery_list() + { + if (Auth::user()->access_level == 'Facility') { + + $drug_delivery = NishauriDrugDelivery::select('tbl_nishauri_drug_order.id as order_id', 'tbl_appointment.appntmnt_date', 'tbl_client.clinic_number', 'tbl_nishauri_drug_order.mode', 'tbl_nishauri_drug_order.delivery_method', 'tbl_nishauri_drug_order.delivery_person', 'tbl_nishauri_drug_order.delivery_person_contact', 'tbl_nishauri_drug_order.delivery_pickup_time', 'tbl_nishauri_drug_order.status', 'tbl_nishauri_drug_order.appointment_id') + ->leftJoin('tbl_appointment', 'tbl_appointment.id', '=', 'tbl_nishauri_drug_order.appointment_id') + ->leftJoin('tbl_client', 'tbl_client.id', '=', 'tbl_nishauri_drug_order.program_identifier') + ->where('tbl_client.mfl_code', Auth::user()->facility_id) + ->where('tbl_nishauri_drug_order.status', '=', 'Pending') + ->get(); + $drug_dispatch = NishauriDrugDelivery::select('tbl_nishauri_drug_order.id as order_id', 'tbl_appointment.appntmnt_date', 'tbl_client.clinic_number', 'tbl_nishauri_drug_order.mode', 'tbl_nishauri_drug_order.delivery_method', 'tbl_nishauri_drug_order.delivery_person', 'tbl_nishauri_drug_order.delivery_person_contact', 'tbl_nishauri_drug_order.delivery_pickup_time', 'tbl_nishauri_drug_order.status', 'tbl_nishauri_drug_order.appointment_id') + ->leftJoin('tbl_appointment', 'tbl_appointment.id', '=', 'tbl_nishauri_drug_order.appointment_id') + ->leftJoin('tbl_client', 'tbl_client.id', '=', 'tbl_nishauri_drug_order.program_identifier') + ->where('tbl_client.mfl_code', Auth::user()->facility_id) + ->where('tbl_nishauri_drug_order.status', '=', 'Approved') + ->get(); + + $drug_fullfilled = NishauriDrugDelivery::select('tbl_nishauri_drug_order.id as order_id', 'tbl_appointment.appntmnt_date', 'tbl_client.clinic_number', 'tbl_nishauri_drug_order.mode', 'tbl_nishauri_drug_order.delivery_method', 'tbl_nishauri_drug_order.delivery_person', 'tbl_nishauri_drug_order.delivery_person_contact', 'tbl_nishauri_drug_order.delivery_pickup_time', 'tbl_nishauri_drug_order.status', 'tbl_nishauri_drug_order.appointment_id') + ->leftJoin('tbl_appointment', 'tbl_appointment.id', '=', 'tbl_nishauri_drug_order.appointment_id') + ->leftJoin('tbl_client', 'tbl_client.id', '=', 'tbl_nishauri_drug_order.program_identifier') + ->where('tbl_client.mfl_code', Auth::user()->facility_id) + ->where('tbl_nishauri_drug_order.status', '=', 'Fullfilled') + ->get(); + + return view('nishauri.drug_delivery', compact('drug_delivery', 'drug_dispatch', 'drug_fullfilled')); + } + } + + public function delivery_approval(Request $request) + { + try { + $client = NishauriDrugDelivery::where('appointment_id', $request->appointment_id) + ->update([ + 'status' => 'Approved', + 'updated_at' => date('Y-m-d H:i:s') + ]); + + // dd( $client); + if ($client) { + NishauriDrugOrder::create([ + 'order_id' => $request->order_id, + 'initiated_by' => Auth::user()->id, + ]); + Alert::success('Success', 'Delivery Successfully Approved'); + return redirect('delivery/list'); + } else { + Alert::error('Failed', 'Could not approve please try again later.'); + return back(); + } + } catch (Exception $e) { + } + } + + public function delivery_dispatch(Request $request) + { + try { + $client = NishauriDrugDelivery::where('appointment_id', $request->appointment_id) + ->update([ + 'status' => 'Dispatched', + 'updated_at' => date('Y-m-d H:i:s') + ]); + + // dd( $client); + if ($client) { + NishauriDrugOrder::where('order_id', $request->order_id) + ->update([ + 'initiated_by' => Auth::user()->id, + 'dispatch_notes' => $request->dispatch_notes, + 'updated_at' => date('Y-m-d H:i:s') + ]); + Alert::success('Success', 'Delivery Successfully Dispatched'); + return redirect('delivery/list'); + } else { + Alert::error('Failed', 'Could not dispatch please try again later.'); + return back(); + } + } catch (Exception $e) { + } + } } diff --git a/app/Models/NishauriDrugDelivery.php b/app/Models/NishauriDrugDelivery.php new file mode 100644 index 0000000..7d3bdfe --- /dev/null +++ b/app/Models/NishauriDrugDelivery.php @@ -0,0 +1,18 @@ +access_level == 'Facility') -
+ +
+ + +
+ @endif @endif diff --git a/resources/views/nishauri/drug_delivery.blade.php b/resources/views/nishauri/drug_delivery.blade.php new file mode 100644 index 0000000..74f8936 --- /dev/null +++ b/resources/views/nishauri/drug_delivery.blade.php @@ -0,0 +1,422 @@ +@extends('layouts.master') +@section('page-css') + + + +@endsection + +@section('main-content') +@include('sweetalert::alert') + + + + + +
+

+
+
+ +
+
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + @if (count($drug_delivery) > 0) + @foreach($drug_delivery as $result) + + + + + + + + + + + + + + @endforeach + @endif + + +
No.CCC NumberAppointment DateRequest ModeDelivery MethodDelivery PersonDelivery Person ContactPick Up TimeStatusAction
{{ $loop->iteration }} {{$result->clinic_number}} {{$result->appntmnt_date}} {{$result->mode}} {{$result->delivery_method}} {{$result->delivery_person}} {{$result->delivery_person_contact}} {{$result->delivery_pickup_time}} {{$result->status}} + + + + +
+ +
+ +
+
+
+
+

+
+
+ +
+
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + + @if (count($drug_dispatch) > 0) + @foreach($drug_dispatch as $result) + + + + + + + + + + + + + + @endforeach + @endif + + +
No.CCC NumberAppointment DateRequest ModeDelivery MethodDelivery PersonDelivery Person ContactPick Up TimeStatusAction
{{ $loop->iteration }} {{$result->clinic_number}} {{$result->appntmnt_date}} {{$result->mode}} {{$result->delivery_method}} {{$result->delivery_person}} {{$result->delivery_person_contact}} {{$result->delivery_pickup_time}} {{$result->status}} + + + + +
+ +
+ +
+
+
+
+

+
+
+ +
+
+ +
+
+ +
+
+ + + + + + + + + + + + + + + + + @if (count($drug_fullfilled) > 0) + @foreach($drug_fullfilled as $result) + + + + + + + + + + + + + + @endforeach + @endif + + +
No.CCC NumberAppointment DateRequest ModeDelivery MethodDelivery PersonDelivery Person ContactPick Up TimeStatus
{{ $loop->iteration }} {{$result->clinic_number}} {{$result->appntmnt_date}} {{$result->mode}} {{$result->delivery_method}} {{$result->delivery_person}} {{$result->delivery_person_contact}} {{$result->delivery_pickup_time}} {{$result->status}}
+ +
+ +
+
+
+
+
+ + + + + + + +@endsection + +@section('page-js') + + + + + + + + + + + + + +@endsection \ No newline at end of file diff --git a/routes/web.php b/routes/web.php index 5aa6d30..454d3bc 100644 --- a/routes/web.php +++ b/routes/web.php @@ -316,5 +316,9 @@ Route::get('/program/data', ['uses' => 'App\Http\Controllers\NewReportController@program', 'as' => 'program_data']); Route::get('/program_filter', ['uses' => 'App\Http\Controllers\NewReportController@program_filter', 'as' => 'program_filter']); + Route::get('/delivery/list', ['uses' => 'App\Http\Controllers\NishauriController@drug_delivery_list', 'as' => 'drug_delivery_list']); + Route::post('/approve/delivery', ['uses' => 'App\Http\Controllers\NishauriController@delivery_approval', 'as' => 'approve-delivery']); + Route::post('/approve/dispatch', ['uses' => 'App\Http\Controllers\NishauriController@delivery_dispatch', 'as' => 'approve-dispatch']); + });