Files

198 lines
11 KiB
PHP
Executable File

@extends('layouts.main')
@push('styles')
<link href="{{ asset('/elite/bower_components/datatables/jquery.dataTables.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('elite/tables/css/buttons.dataTables.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
<style>
th{
white-space: nowrap;
}
</style>
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
<h4 class="page-title">{{ __('investigations.edit_investigation') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('investigations.dashboard') }}</a></li>
<li><a href="/investigations/index">{{ __('investigations.investigations') }}</a></li>
<li class="active">{{ __('investigations.edit') }}</li>
</ol>
</div>
</div>
@include('investigations::investigations.menu')
<div class="row">
<div class="col-sm-12">
<!--Flash messages at the top -->
@include('flash::message')
<div class="white-box">
{{ Form::model($investigations, ['method' => 'POST', 'route' => ['investigations.update.hmis.options']]) }}
<div class="table-responsive">
<table id="table" class="table table-striped">
<thead>
<tr>
<th hidden>Id</th>
<th>{{ __('investigations.investigation_name') }}</th>
<th>{{ __('investigations.hmis_category_out_patient_number') }}</th>
<th>{{ __('investigations.hmis_category_out_patient') }}</th>
<th>{{ __('investigations.hmis_category_in_patient_number') }}</th>
<th>{{ __('investigations.hmis_category_in_patient') }}</th>
</tr>
</thead>
<tbody>
@php
$counter = 0;
@endphp
@foreach($investigations as $investigation)
<tr>
<td hidden>{{ Form::text('id[]', $investigation->id, ['class' => 'form-control']) }}</td>
<td>
<p style="display: none">{{ $investigation->name }}</p>
{{ Form::text('name[]', $investigation->name, ['class' => 'form-control compulsory', 'required']) }}
<div class="help-block with-errors"></div>
</td>
@php
$hmis_no_outpatient_array = explode(",", $investigation->hmis_no_outpatient);
$hmis_outpatient_category_array = explode(",", $investigation->hmis_category);
@endphp
<td>{{ Form::text('hmis_no_outpatient[]', $investigation->hmis_no_outpatient, ['class' => 'form-control','placeholder' => '']) }}</td>
<td>
@if(count($hmis_no_outpatient_array) > 0)
<!-- only display one field for noe -->
@for($i=0; $i < 1; $i++)
{{ Form::select('hmis_category[]', $hmis_categories, isset($hmis_outpatient_category_array[$i]) ? $hmis_outpatient_category_array[$i] : "", ['class' => 'form-control']) }}
@endfor
@endif
</td>
<td>
@php
$inpatient_option =$investigation->hmis_category_inpatient;
$inpatient_other = array_filter($inpatient_hmis_categories, function ($item) use ($inpatient_option) {
return $item['id'] !== $inpatient_option;
});
$inpatient_selected = array_filter($inpatient_hmis_categories, function ($item) use ($inpatient_option) {
return $item['id'] == $inpatient_option;
});
$categories_option = $investigation->hmis_no_inpatient;
$selected_hmis_categories_option=array_filter($inpatient_hmis_category_options, function ($item) use ($categories_option) {
return $item['id'] == $categories_option;
});
$other_hmis_categories_options= array_filter($inpatient_hmis_category_options, function ($item) use ($categories_option) {
return $item['id'] != $categories_option;
});
@endphp
{{-- {{ Form::text('hmis_no_inpatient[]', $investigation->hmis_no_inpatient, ['class' => 'form-control']) }} --}}
<select class="form-control hmis_category_inpatient" id="{{ 'hmis_category_inpatient_'. $counter }}" name="hmis_category_inpatient[]">
<option value selected='<?php echo empty($inpatient_selected)? 'selected ':''; ?>'>- Select HMIS category -</option>
@foreach ($inpatient_selected as $option)
<option value="{{ $option['id'] }}" selected>{{ $option['title'] }}</option>
@endforeach
@foreach ($inpatient_other as $inpatient_item)
<option value="{{ $inpatient_item['id'] }}">{{ $inpatient_item['title'] }}</option>
@endforeach
</select>
<div class="help-block with-errors"></div>
</td>
<td>
{{-- {{ Form::select('hmis_category_inpatient[]', $hmis_categories_ip, $investigation->hmis_category_inpatient, ['class' => 'form-control']) }} --}}
<select class="form-control inpatient_hmis_category_options" id="{{ 'inpatient_hmis_category_options_'. $counter }}" name="hmis_no_inpatient[]">
@if (empty($selected_hmis_categories_option))
<option value selected='selected'>- Select HMIS category <?php echo empty($inpatient_selected)? 'first ':'Option'; ?> -</option>
@else
@foreach ($selected_hmis_categories_option as $selected_option )
<option value="{{ $selected_option['id'] }}" selected>{{ $selected_option['name'] }}</option>
@endforeach
@endif
@if (!empty($inpatient_selected))
@foreach ($other_hmis_categories_options as $option )
<option value="{{ $option['id'] }}">{{ $option['name'] }}</option>
@endforeach
@endif
</select>
<div class="help-block with-errors"></div>
</td>
</tr>
@php
$counter++;
@endphp
@endforeach
</tbody>
</table>
</div>
{{ Form::button(__('investigations.submit'),['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10']) }}
{{ Form::button(__('investigations.cancel'),['type'=>'reset','class'=>'btn btn-default waves-effect waves-light']) }}
{{ Form::close() }}
</div>
</div>
</div>
@include('investigations.menu')
@endsection
@push('scripts')
<script src="{{ asset('elite/js/validator.js') }}"></script>
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/dataTables.buttons.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/buttons.flash.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/jszip.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/pdfmake.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/vfs_fonts.js') }}"></script>
<script src="{{ asset('elite/tables/js/buttons.html5.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/buttons.print.min.js') }}"></script>
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<script>
$(document).ready(function () {
$('#table').DataTable({
dom: 'Bfrtip',
pageLength: 30,
// bPaginate: false,
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
});
$('.hmis_category_inpatient,.inpatient_hmis_category_options').select2();
$('#table tbody').on('change','.hmis_category_inpatient', function(e) {
if(!$('.hmis_category_inpatient').hasClass('select2-hidden-accessible')) $('.hmis_category_inpatient,.inpatient_hmis_category_options').select2();
let counter = this.id.split("_");let id = this.id;
category_options(id,counter);
});
});
function category_options(id,counter){
let category = $('#'+id).val();
$.ajax({
type: "POST",
url: "/get_hmis_categories_options",
data: {hmis_category: category},
cache: false,
success: function (response) {
if(response == 'false'){
alert("<?php echo __('procedures.failed_options'); ?>");
} else {
$('#inpatient_hmis_category_options_'+counter[3]).html(response);
$('#inpatient_hmis_category_options_'+counter[3]).prop('required',true);
}
}
});
}
</script>
@endpush