浏览代码

Merge branch 'dev' into dev-vj

Vijayakrishnan 3 年之前
父节点
当前提交
916843de93

+ 64 - 0
.env.example

@@ -0,0 +1,64 @@
+APP_NAME=Stag
+APP_ENV=local
+APP_KEY=base64:1yKRgeLWTeEXTfh51vXtJaf6GJaRUn4NHzdlOdyDpRY=
+APP_DEBUG=true
+APP_URL=http://localhost
+
+LOG_CHANNEL=stack
+
+DB_CONNECTION=pgsql
+DB_HOST=127.0.0.1
+DB_PORT=5432
+DB_DATABASE=stag2
+DB_USERNAME=postgres
+DB_PASSWORD=pass
+
+DB_HOST_FDB=localhost
+DB_PORT_FDB=5432
+DB_DATABASE_FDB=fdbhealth
+DB_USERNAME_FDB=postgres
+DB_PASSWORD_FDB=pass
+
+BROADCAST_DRIVER=log
+CACHE_DRIVER=file
+QUEUE_CONNECTION=sync
+SESSION_DRIVER=file
+SESSION_LIFETIME=120
+
+REDIS_HOST=127.0.0.1
+REDIS_PASSWORD=null
+REDIS_PORT=6379
+
+MAIL_MAILER=smtp
+MAIL_HOST=smtp.mailtrap.io
+MAIL_PORT=2525
+MAIL_USERNAME=null
+MAIL_PASSWORD=null
+MAIL_ENCRYPTION=null
+MAIL_FROM_ADDRESS=null
+MAIL_FROM_NAME="${APP_NAME}"
+
+AWS_ACCESS_KEY_ID=
+AWS_SECRET_ACCESS_KEY=
+AWS_DEFAULT_REGION=us-east-1
+AWS_BUCKET=
+
+PUSHER_APP_ID=
+PUSHER_APP_KEY=
+PUSHER_APP_SECRET=
+PUSHER_APP_CLUSTER=mt1
+
+MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
+MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
+
+BACKEND_URL="http://localhost:8080/api"
+ADMIN_PORTAL_URL="http://localhost:3000"
+
+AUTH_URL="https://pro.leadershiphealth.local"
+
+BACKEND_WS_URL=http://localhost:8080/ws
+AGORA_APPID=9d04292b03524927a8fe9d937a448d85
+AGORA_MODE=screen
+
+GOOGLE_SPREADSHEET_ID=15pM6zM5o-S55SCLO5qkAbKCWAzYRZvDkAbgnsDNqWjk
+GOOGLE_SPREADSHEET_PRODUCTS_SHEET_NAME=records

+ 152 - 0
app/Console/Commands/clientsToGsheet.php

@@ -0,0 +1,152 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Models\BDTDevice;
+use App\Models\Client;
+use App\Models\SimpleProduct;
+use Google\Service\Sheets\ValueRange;
+use Google_Client;
+use Illuminate\Console\Command;
+use Revolution\Google\Sheets\Facades\Sheets;
+use Revolution\Google\Sheets\Sheets as SheetsSheets;
+
+class clientsToGsheet extends Command
+{
+  
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'clients:export-to-gsheet';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'Export records to gsheet';
+
+    /**
+     * Create a new command instance.
+     *
+     * @return void
+     */
+    public function __construct()
+    {
+        parent::__construct();
+    }
+
+    /**
+     * Execute the console command.
+     *
+     * @return int
+     */
+    public function handle()
+    {
+        $this->pushSheet();
+        return 0;
+    }
+
+
+    function pushSheet(){
+
+        $spreadsheetId = config('app.googleSpreadsheetId');
+        $googleSpreadsheetProductsSheetName = config('app.googleSpreadsheetProductsSheetName'); 
+       
+        $client = $this->getApiClient();
+        $service = new \Google\Service\Sheets($client);
+
+        
+        $values = $this->getValues();
+
+
+        $range = $googleSpreadsheetProductsSheetName.'!A1:V1';
+        $body = new ValueRange([
+            'values' => $values
+        ]);
+        $params = [
+           'valueInputOption' => 'RAW'
+        ];
+
+        $result = $service->spreadsheets_values->append($spreadsheetId, $range, $body, $params);
+
+        $this->info(json_encode($result));
+
+    }
+
+
+    function getApiClient(){
+      
+        $KEY_FILE_LOCATION = storage_path('stag-gsheets-d9ead2f78b4b.json');
+
+        $client = new Google_Client();
+        $client->setApplicationName("My Rooster Admin");
+        $client->setAuthConfig($KEY_FILE_LOCATION);
+        
+        $client->setScopes([\Google\Service\Sheets::DRIVE, \Google\Service\Sheets::SPREADSHEETS]);
+
+        return $client;
+
+    }
+
+
+    private function getValues(){
+
+        $values = [];
+
+        $values[] = [
+            'Chart Number',
+			'Name',
+			'Issued Yet?',
+			'Client',
+			'Used?',
+			'MCP',
+			'Issue Date',
+			'Last Meas. Date',
+			'Last Meas. Days Ago',
+			'Days with Remote Meas. this Month',
+			'Days with Remote Meas. last Month',
+			'Client Engagement Status Category',
+			'Admin Engagement Assessment Status',
+			'Mcp Engagement Assessment Status',
+			'Default Na Engagement Assessment Status'
+        ];
+
+        Client::whereNull('shadow_pro_id')->chunk(function($clients) use ($values){
+            foreach($clients as $patient){
+                $patientStr =($patient->chart_number).'~~'.
+                ($patient->displayName()).'~~'.
+                (@$patient->mcp ? $patient->mcp->displayName() : '--').'~~'.
+                ($patient->mailing_address_state).'~~'.
+                ($patient->getPrimaryCoverage()?$patient->getPrimaryCoverage()->insuranceDisplayName():'-').'~~'.
+                (friendly_date($patient->most_recent_completed_mcp_note_date) ).'~~'.
+                ($patient->nextMcpAppointment ? friendly_date_time($patient->nextMcpAppointment->raw_date.' '.$patient->nextMcpAppointment->raw_start_time) : '-').'~~'.
+                (friendlier_date_time($patient->most_recent_cellular_bp_measurement_at) ).'~~'.
+                (friendlier_date_time($patient->most_recent_cellular_weight_measurement_at) ).'~~'.
+                (friendly_date_time($patient->created_at, false)).'~~'.
+                ($patient->getMcpAssignedOn()).'~~'.
+                (count($patient->activeNotes)).'~~'.
+                ($patient->client_engagement_status_category == 'DUMMY'? 'Test Record': $patient->client_engagement_status_category).'~~'.
+                ($patient->temparatureGunDeliveryStatus()).'~~'.
+                ($patient->pulseOximeterDeliveryStatus()).'~~'.
+                ($patient->hasBPDevice()?'DELIVERED':'').'~~'.
+                ($patient->hasWeightScaleDevice()?'DELIVERED':'').'~~';
+                $values[] = explode('~~', $patientStr);
+            }
+        });
+       
+        return $values;
+    }
+
+    
+}
+
+				
+			
+			
+				
+			
+				
+				

+ 1 - 24
app/Http/Controllers/AdminController.php

@@ -40,30 +40,7 @@ class AdminController extends Controller
         $filters = $request->all();
         $patients = Client::whereNull('shadow_pro_id');
 
-        // filters
-        /*
-        array:18 [▼
-          "age_category" => "LESS_THAN"
-          "age_value_1" => "34"
-          "age_value_2" => null
-          "sex" => "M"
-          "bmi_category" => "BETWEEN"
-          "bmi_value_1" => "20"
-          "bmi_value_2" => "25"
-          "last_visit_category" => "LESS_THAN"
-          "last_visit_value_1" => "2021-10-14"
-          "last_visit_value_2" => null
-          "next_appointment_category" => "LESS_THAN"
-          "next_appointment_value_1" => "2021-10-15"
-          "status" => "ACTIVE"
-          "last_weighed_in_category" => "EXACTLY"
-          "last_weighed_in_value_1" => "2021-10-07"
-          "last_bp_category" => "BETWEEN"
-          "last_bp_value_1" => "2021-10-01"
-          "last_bp_value_2" => "2021-10-31"
-        ]
-        */
-
+       
         if ($request->input('name')) {
             $name = trim($request->input('name'));
             if ($name) {

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

@@ -1045,6 +1045,7 @@ SELECT client.name_first, client.name_last,
        client.dob,
        client.is_enrolled_in_rm,
        client.most_recent_completed_mcp_note_date,
+       client.most_recent_completed_mcp_note_id,
        client.cell_number,
        client.is_assigned_cellular_bp_device,
        client.is_assigned_cellular_weight_scale_device,

+ 26 - 0
public/css/style.css

@@ -3026,4 +3026,30 @@ body .vakata-context .vakata-context-separator>a {
 }
 .table-columns tr:last-child .move-down {
     display: none;
+}
+
+.table-dnd-on-drag {
+    background-color: #fff7de !important;
+    box-shadow: 6px 3px 5px #e9e9e9, 0 1px 0 #ccc inset, 0 -1px 0 #ccc inset;
+    transition: 0.3s;
+}
+.table-dnd-on-drag td {
+    font-weight: bold;
+    border-top: none;
+}
+.table-dnd-no-change {
+    opacity: 0.5;
+    transition: 0.3s;
+}
+.droppable-section-active {
+    border: 2px dashed #00bcd4;
+}
+[draggable] {
+    cursor:all-scroll;
+}
+body.forced-masking {
+    opacity: 0.6 !important;
+}
+body.forced-masking #mask {
+    display: block !important;
 }

+ 2 - 2
resources/views/app/dna/dashboard/encounters_pending_my_review.blade.php

@@ -16,7 +16,7 @@
                         <th class="border-0">Gender</th>
                         <th class="border-0">Coverage</th>
                         <th class="border-0">MCP</th>
-                        <th class="border-0">Timestamp</th>
+                        <th class="border-0">Date</th>
                         <th class="border-0"></th>
                     </tr>
                 </thead>
@@ -46,7 +46,7 @@
                             @include('app.patient.coverage_column_renderer', ['patient'=>$row->client])
                         </td>
                         <td class="text-nowrap">
-                            {{$row->client->mcp->name_display ?? '' }}
+                            {{$row->hcpPro->name_display ?? '' }}
                         </td>
                         <td class="text-nowrap">
                             {{friendly_date($row->effective_dateest)}}

+ 3 - 3
resources/views/app/dna/dashboard/encounters_pending_my_review_dashboard.blade.php

@@ -16,7 +16,7 @@
                         <th class="border-0">Gender</th>
                         <th class="border-0">Coverage</th>
                         <th class="border-0">MCP</th>
-                        <th class="border-0">Timestamp</th>
+                        <th class="border-0">Date</th>
                         <th class="border-0"></th>
                     </tr>
                 </thead>
@@ -27,7 +27,7 @@
                             {{$row->client->chart_number}}
                         </td>
                         <td>
-                            <a href="{{ route('patients.view.dashboard', $row->client) }}">
+                            <a href="{{route('patients.view.notes.view.dashboard', ['patient' => $row->client, 'note' => $row])}}">
                                 {{$row->client->displayName()}}
                             </a>
                         </td>
@@ -46,7 +46,7 @@
                             @include('app.patient.coverage_column_renderer', ['patient'=>$row->client])
                         </td>
                         <td class="text-nowrap">
-                            {{$row->client->mcp->name_display ?? '' }}
+                            {{$row->hcpPro->name_display ?? '' }}
                         </td>
                         <td class="text-nowrap">
                             {{friendly_date($row->effective_dateest)}}

+ 12 - 1
resources/views/app/practice-management/remote-monitoring.blade.php

@@ -13,6 +13,9 @@
                     <b class="font-size-14">{{friendly_month(date((request()->input('y') ?: 'Y') . '-' . (request()->input('m') ?: 'm') . '-d'))}}</b>
                 </span>
                 <?php
+
+use App\Models\Note;
+
                 $mStr = request()->input('m') ? request()->input('m') : date('m');
                 $yStr = request()->input('y') ? request()->input('y') : date('Y');
                 $rcmStartDate = $yStr . '-' . $mStr . '-' . '01';
@@ -84,10 +87,12 @@
                                 <?php
 
                                 $daysDiff = -1;
+                                $mostRecentCompletedMcpNote = null;
                                 if($iPatient->most_recent_completed_mcp_note_date) {
                                     $careMonthLastDay = date_add(date_create($rcmStartDate), date_interval_create_from_date_string("1 month"));
                                     $careMonthLastDay = date_sub($careMonthLastDay, date_interval_create_from_date_string("1 day"));
                                     $daysDiff = date_diff($careMonthLastDay, date_create($iPatient->most_recent_completed_mcp_note_date))->days;
+                                    $mostRecentCompletedMcpNote = Note::where('id', $iPatient->most_recent_completed_mcp_note_id)->first();
                                 }
                                 $lastVisitWithin90Days = ($daysDiff !== -1 && $daysDiff <= 90);
 
@@ -125,7 +130,13 @@
                                     <td>
                                         <div class="d-flex align-items-baseline">
                                             <i class="mr-1 text-sm fa {{$lastVisitWithin90Days ? 'fa-check text-success' : 'fa-exclamation-triangle text-danger'}}"></i>
-                                            <span>{{$iPatient->most_recent_completed_mcp_note_date ? friendly_date($iPatient->most_recent_completed_mcp_note_date) : '-'}}</span>
+                                            @if($mostRecentCompletedMcpNote)
+                                                <a href = "{{route('patients.view.notes.view.dashboard', ['patient' => $iPatient->client_uid, 'note' => $mostRecentCompletedMcpNote])}}">
+                                                    <span>{{$iPatient->most_recent_completed_mcp_note_date ? friendly_date($iPatient->most_recent_completed_mcp_note_date) : '-'}}</span>
+                                                </a>
+                                            @else
+                                                <span>-</span>
+                                            @endif
                                         </div>
                                         @if(!$lastVisitWithin90Days)
                                             <div class="text-sm font-italic text-secondary">No visit in over 90 days</div>

+ 180 - 3
resources/views/app/practice-management/visit-templates/visit-template-segment-templates/index.blade.php

@@ -1,6 +1,7 @@
 @extends('app.practice-management.visit-templates.single')
 @section('visitTemplateTab')
-<div class="row">
+
+<div id="visitTemplateSegmentTemplates" class="row">
     <div class="col-md-12">
         <div class="card mb-2">
             <div class="card-header border-bottom-0 px-1 py-2 d-flex align-items-center">
@@ -22,7 +23,7 @@
 
                     </div>
                     <div class="card-body p-0">
-                        <div class="table-responsive">
+                        <div class="table-responsive" data-position="LEFT" droppable-section>
                             @include('app.practice-management.visit-templates.visit-template-segment-templates.segment-templates-list', ['position' => 'LEFT'])
                         </div>
                     </div>
@@ -37,7 +38,7 @@
                         </div>
                     </div>
                     <div class="card-body p-0">
-                        <div class="table-responsive">
+                        <div class="table-responsive" data-position="RIGHT" droppable-section>
                             @include('app.practice-management.visit-templates.visit-template-segment-templates.segment-templates-list', ['position' => 'RIGHT'])
                         </div>
                     </div>
@@ -49,5 +50,181 @@
             {{ $visitTemplateSegmentTemplates->appends(request()->input())->links() }}
         </div>
     </div>
+
+    <div class="col-md-12 mt-4">
+        <div class="card mb-2">
+            <div class="card-header border-bottom-0 px-1 py-2 d-flex align-items-center">
+                <strong class="mr-4">
+                    <i class="fas fa-trash text-danger"></i>
+                    Deactivated Segment Templates
+                </strong>
+            </div>
+        </div>
+
+        <div class="row">
+            <div class="col-md-6">
+                <div class="card">
+                    <div class="card-body p-0">
+                        <div class="table-responsive">
+                            @include('app.practice-management.visit-templates.visit-template-segment-templates.segment-templates-list-deactivated')
+                        </div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    </div>
+
 </div>
+
+<script>
+var draggableVisitTemplateSegmentTemplates = null;
+(function($){
+    draggableVisitTemplateSegmentTemplates = {
+        recordsPerPage: '<?= $visitTemplateSegmentTemplates->perPage() ?>',
+        currentPage: '<?= $visitTemplateSegmentTemplates->currentPage() ?>',
+        preservePositionIndexNumber: false,
+        draggedDeactivatedRecordUid: null,
+
+        recalculateRowsPositionIndexes: function(table, leftRightPosition){
+            var self = this;
+            self.forceShowMask();
+            var currentRowsData = [];
+            var rows = $(table).find('tbody tr');
+            $.each(rows, function(i, row){
+                var uid = $(row).data('uid');
+                var currentPositionIndex = parseInt($(row).data('positionindex'));
+                var heading = $(row).data('heading');
+                var subheading = $(row).data('subheading');
+                var displayTitle = $(row).data('displaytitle');
+                var leftOrRight = $(row).data('leftorright');
+                currentRowsData.push({uid:uid, position: currentPositionIndex,heading:heading, subheading:subheading, displayTitle:displayTitle, leftOrRight:leftOrRight});                
+            });
+            var _currentRowsData = JSON.stringify(currentRowsData);
+            
+            var sortedByPositionIndexAscending = currentRowsData.sort(function(a, b){
+                var aPositionIndex = a.position;
+                var bPositionIndex = b.position; 
+                return ((aPositionIndex < bPositionIndex) ? -1 : ((aPositionIndex > bPositionIndex) ? 1 : 0));
+            });
+
+            var originalCurrentRowsData = JSON.parse(_currentRowsData);
+
+            var updatedData = [];
+            $.each(originalCurrentRowsData, function(i, r){
+                if(self.preservePositionIndexNumber){
+                  r.position = sortedByPositionIndexAscending[i].position;  
+                }else{
+                    r.position = i;
+                    var currentPage = parseInt(self.currentPage);
+                    currentPage = isNaN(currentPage) ? 1:currentPage;
+                    if(currentPage > 1){
+                        r.position = i + parseInt(self.recordsPerPage);
+                    }                    
+                }
+                
+                updatedData.push(r);
+            });
+            self.updatePositionIndexes(updatedData);
+        },
+        updatePositionIndexes: async function(data){
+            var self = this;
+            var error = null;
+            for (var row of data) {
+                row.positionIndex = row.position;
+                var response = await $.post('/api/visitTemplateSegmentTemplate/updateBasic', row, function(res){return res});
+                if(!response.success){
+                    error = true;
+                    toastr.error(response.message);
+                }
+            }
+            
+            fastReload();
+            setTimeout(function(){
+                self.forceHideMask();
+            },1000);
+        },
+        initDraggableTable: function(){
+            var self = this;
+            $(".table-dnd").tableDnD({
+                onDragClass: 'table-dnd-on-drag',
+                onDrop: function(table, row){
+                    var tableLeftRightPosition = $(table).data('position');
+                    self.recalculateRowsPositionIndexes(table, tableLeftRightPosition);
+                },
+                onDragStart: function(table, row) {
+                    $(table).find('tbody tr').addClass('table-dnd-no-change');
+                    $(row).removeClass('table-dnd-no-change');
+                },
+                onDragStop: function(table, row) {
+                    $(table).find('tbody tr').removeClass('table-dnd-no-change');
+                },
+            });
+        },
+        initOnDroppableSection: function(){
+            var self = this;
+            $('[droppable-section]').on('dragover', function(e){
+                $(e.currentTarget).addClass('droppable-section-active');
+                return false;
+            }).on('drop', function (e) {
+                $(e.currentTarget).removeClass('droppable-section-active');
+                var position = $(e.currentTarget).data('position');
+                self.updateDraggedDeactivatedRecord(position);
+                return false;
+            });
+            $('[draggable-item]').on('dragstart', function(e){
+                self.draggedDeactivatedRecordUid = $(e.currentTarget).data('uid');
+            });
+        },
+        updateDraggedDeactivatedRecord: function(position){
+            var self = this;
+            self.forceShowMask();
+            var positionUrl = position == 'LEFT' ? 'moveToLeft':'moveToRight';
+            $.post('/api/visitTemplateSegmentTemplate/reactivate', {uid: self.draggedDeactivatedRecordUid, memo:''}, function(response){
+                if(response.success){
+                  $.post('/api/visitTemplateSegmentTemplate/'+positionUrl, {uid:self.draggedDeactivatedRecordUid}, function(res){
+                      if(res.success){
+                          self.draggedDeactivatedRecordUid = null;
+                          fastReload();
+                          self.forceHideMask();
+                      }
+                  },'json');  
+                }
+            },'json');            
+        },
+        forceShowMask: function(){
+            $('body').addClass('forced-masking');
+        },
+        forceHideMask: function(){
+            $('body').removeClass('forced-masking');
+        },
+        init: function(){
+            this.initDraggableTable();
+            this.initOnDroppableSection();
+        }
+    };
+    
+})(jQuery);
+</script>
+
+<script>
+        (function() {
+            function init() {
+                draggableVisitTemplateSegmentTemplates.init();
+                addMCHook('reArrangePositionIndexes', function() {
+                    draggableVisitTemplateSegmentTemplates.forceShowMask();
+                    fastReload();
+                    setTimeout(function(){
+                        var tables = $('.table-dnd');
+                        $.each(tables, function(i, table){
+                            var tableLeftRightPosition = $(table).data('position');
+                            draggableVisitTemplateSegmentTemplates.recalculateRowsPositionIndexes(table, tableLeftRightPosition);
+                        });
+                    },500);
+                });
+            }
+            addMCInitializer('visitTemplateSegmentTemplates', init, '#visitTemplateSegmentTemplates')
+
+        }).call(window);
+    </script>
+
 @endSection

+ 65 - 0
resources/views/app/practice-management/visit-templates/visit-template-segment-templates/segment-templates-list-deactivated.blade.php

@@ -0,0 +1,65 @@
+<table data-position="{{ @$position }}" class="table table-sm table-striped border-top p-0 m-0">
+	<thead class="bg-light">
+		<tr>
+			<th class="border-0">Display title</th>
+			<th class="border-0">Heading</th>
+			<th class="border-0">Sub-heading</th>
+			<th class="border-0">Segment Template</th>
+			<th class="border-0">Left/Right</th>
+			<th class="border-0">Status</th>
+			<th class="border-0">&nbsp;</th>
+		</tr>
+	</thead>
+	<tbody>
+		<?php $rowsCount = 0; ?>
+		@foreach($visitTemplateSegmentTemplates as $template)
+			@if(!$template->is_active)
+				<?php $rowsCount++; ?>
+				<tr draggable="true" data-uid="{{ $template->uid }}" draggable-item>
+					<td><i class="fas fa-arrows-alt mr-2"></i> {{ $template->display_title }}</td>
+					<td>{{ $template->heading }}</td>
+					<td>{{ $template->subheading }}</td>
+					<td>{{ $template->segmentTemplate ? $template->segmentTemplate->default_display_title : '---' }}</td>
+					<td>{{ $template->left_or_right }}</td>
+					<td>
+						<div>
+							@if($template->is_active)
+							<span class="text-success">ACTIVE</span>
+							@if($template->reactivation_memo)
+							<div style="width:300px;">
+								<small class="text-muted"><b>Memo: </b>{{ $template->reactivation_memo }}</small>
+								@include('app.practice-management.visit-templates.visit-template-segment-templates.update-memo')
+							</div>
+							@endif
+							@else
+							<span class="text-danger">INACTIVE</span>
+							@if($template->deactivation_memo)
+							<div style="width:300px;">
+								<small class="text-muted"><b>Memo: </b>{{ $template->deactivation_memo }}</small>
+								@include('app.practice-management.visit-templates.visit-template-segment-templates.update-memo')
+							</div>
+							@endif
+							@endif
+						</div>
+					</td>
+					<td>
+						<div class="d-flex align-items-center">
+							<div class="mr-2">
+								@include('app.practice-management.visit-templates.visit-template-segment-templates.update', ['position' => @$position])
+							</div>
+							<div>
+								@include('app.practice-management.visit-templates.visit-template-segment-templates.activate-deactivate')
+							</div>
+						</div>
+					</td>
+				</tr>
+			@endif
+		@endforeach
+		@if(!$rowsCount)
+		<tr>
+			<td colspan="7">No deactivated records found!</td>
+		</tr>
+		@endif
+	</tbody>
+
+</table>

+ 9 - 10
resources/views/app/practice-management/visit-templates/visit-template-segment-templates/segment-templates-list.blade.php

@@ -1,12 +1,10 @@
-<table class="table table-sm table-striped border-top p-0 m-0">
+<table data-position="{{ @$position }}" class="table table-sm table-striped border-top p-0 m-0 table-dnd">
 	<thead class="bg-light">
 		<tr>
 			<th class="border-0">Display title</th>
 			<th class="border-0">Heading</th>
 			<th class="border-0">Sub-heading</th>
-			<th class="border-0">Position Index</th>
 			<th class="border-0">Segment Template</th>
-			<th class="border-0">Created At</th>
 			<th class="border-0">Status</th>
 			<th class="border-0">&nbsp;</th>
 		</tr>
@@ -14,15 +12,13 @@
 	<tbody>
 		<?php $rowsCount = 0; ?>
 		@foreach($visitTemplateSegmentTemplates as $template)
-			@if(@$position === $template->left_or_right)
+			@if(@$position === $template->left_or_right && $template->is_active)
 				<?php $rowsCount++; ?>
-				<tr>
-					<td>{{ $template->display_title }}</td>
+				<tr id="{{ $template->uid }}" data-uid="{{ $template->uid }}" data-positionindex="{{ $template->position_index }}" data-heading="{{ $template->heading }}" data-subheading="{{ $template->subheading }}" data-displaytitle="{{ $template->display_title }}" data-leftorright="{{ $template->left_or_right }}">
+					<td class="text-nowrap">&boxH; &nbsp; &nbsp; {{ $template->display_title }}</td>
 					<td>{{ $template->heading }}</td>
 					<td>{{ $template->subheading }}</td>
-					<td>{{ $template->position_index }}</td>
 					<td>{{ $template->segmentTemplate ? $template->segmentTemplate->default_display_title : '---' }}</td>
-					<td>{{ friendly_date_time($template->created_at) }}</td>
 					<td>
 						<div>
 							@if($template->is_active)
@@ -49,9 +45,12 @@
 							<div class="mr-2">
 								@include('app.practice-management.visit-templates.visit-template-segment-templates.update', ['position' => @$position])
 							</div>
-							<div>
+							<div class="mr-3">
 								@include('app.practice-management.visit-templates.visit-template-segment-templates.activate-deactivate')
 							</div>
+							<div>
+							@include('app.practice-management.visit-templates.visit-template-segment-templates.switch-position', ['position' => @$position])
+							</div>
 						</div>
 					</td>
 				</tr>
@@ -59,7 +58,7 @@
 		@endforeach
 		@if(!$rowsCount)
 		<tr>
-			<td colspan="8">No records found!</td>
+			<td colspan="6">No records found!</td>
 		</tr>
 		@endif
 	</tbody>

+ 25 - 0
resources/views/app/practice-management/visit-templates/visit-template-segment-templates/switch-position.blade.php

@@ -0,0 +1,25 @@
+<div moe>
+	<a start show href="#">
+		@if(@$position == 'LEFT')
+		<span class="text-secondary" title="Move to Right"><i class="fas fa-hand-point-right"></i></span>
+		@else
+		<span class="text-secondary" title="Move to Left"><i class="fas fa-hand-point-left"></i></span>
+		@endif
+	</a>
+	<form url="{{ @$position == 'LEFT' ? '/api/visitTemplateSegmentTemplate/moveToRight' : '/api/visitTemplateSegmentTemplate/moveToLeft' }}" class="mt-2" hook="reArrangePositionIndexes" right>
+		<input type="hidden" name="uid" value="{{ $template->uid }}">
+		<div class="mb-2 w-100">
+			<label>Are you sure?</label>
+		</div>
+
+		<div class="mt-3">
+			@if(@$position == 'LEFT')
+				<button submit class="btn btn-sm btn-primary mr-2">Move to Right</button>
+			@else
+				<button submit class="btn btn-sm btn-primary mr-2">Move to Left</button>
+			@endif
+
+			<button cancel class="btn btn-default border">Cancel</button>
+		</div>
+	</form>
+</div>

+ 1 - 0
resources/views/layouts/template.blade.php

@@ -75,6 +75,7 @@
             crossorigin="anonymous"></script>
 
     <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/TableDnD/1.0.5/jquery.tablednd.min.js"></script>
 
     @yield('head')
 </head>