updated streamline-setup v2

This commit is contained in:
2025-01-15 08:53:49 -08:00
committed by alec.turner
parent a2ce9248f0
commit 4b569f81b0
20228 changed files with 2932048 additions and 63204 deletions
@@ -0,0 +1,609 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-6 col-md-7 col-sm-7 col-xs-12">
<h4 class="page-title">{{ __('pharmacy.confirm_ward_dispensation_per_chart') }}</h4>
</div>
<div class="col-lg-6 col-sm-5 col-md-5 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li class="active">{{ __('pharmacy.confirm_ward_dispensation_per_chart') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('flash::message')
@foreach ($errors->all() as $error)
<div>{{ $error }}</div>
@endforeach
</div>
</div>
@include('pharmacy::pharmacy.ward_dispensing_menu')
<div class="row">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-12">
<div class="panel">
<div class="panel-heading" style="display: none;">{{ __('pharmacy.ward_dispensing_chart') }}</div>
<div class="panel-body">
<div class="row">
<div class="col-md-6">
{{ __('pharmacy.showing_results_from') }} :
<br><h3 style="color: #0060BF; font-weight: bolder;"> {{ is_null($ward_id) ? '' : ($ward_id == 0 ? 'All wards' : get_name($ward_id, 'id', 'name', 'wards')) }} {!! is_null($search_by) ? '<b></b>' : '' !!}</h3>
</div>
</div>
</div>
</div>
<div class="panel">
{{ Form::open(['route' => 'pharmacy.store_approved_dispensings_per_chart', 'class' => 'typeahead', 'method' => 'ANY']) }}
<input type="hidden" name="incoming_chart_id" value="{{ $incoming_chart_record->id }}">
<div class="panel-body">
<div class="row">
<div class="col-sm-12">
@php
$count = 1;
$facade_batches_options = [];
$option_batches = "<option value=''>-select-</option>";
foreach ($batches_array as $item_batch) {
$option_batches .= "<option value='$item_batch->id'>". $item_batch->batch_number." (Expiry Date: ".$item_batch->expiry_date.")</option>";
$facade_batches_options[$item_batch->id] = $item_batch->batch_number." (Expiry Date: ".$item_batch->expiry_date.")";
}
@endphp
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table table-bordered">
<thead>
<tr>
<th>#</th>
<th>{{ __('pharmacy.drug') }}</th>
<th>{{ __('pharmacy.quantity_total') }}</th>
<th>{{ __('pharmacy.quantity_dispensed') }}</th>
<th>{{ __('pharmacy.comment') }}</th>
<th>{{ __('pharmacy.action') }}</th>
</tr>
</thead>
<tbody>
@if(count($drugs_to_dispense_array) > 0)
@for($i = 0; $i < count($drugs_to_dispense_array); $i++)
@php if (empty($drugs_to_dispense_array[$i])) {continue;} @endphp
<tr id="row_item_id_{{$drugs_to_dispense_array[$i]}}">
<td>
{{ $i + 1 }}
</td>
<td>
@php
$auto_deductable_batches_array = get_pharmacy_batch_watcher_ids_to_use_based_on_needed_quantity($drugs_to_dispense_array[$i], 1, $quantities_to_dispense_array[$i]);
if ($auto_deductable_batches_array){
$get_drug_batches = track_batch_stock(1,$drugs_to_dispense_array[$i],'pharmacy_stock');
//filter out all batches and get the batches for each drug
$filtered_batches = [];
foreach ($get_drug_batches as $data) {
$batch_number = $data['id'];
if (isset($facade_batches_options[$batch_number])) {
$filtered_batches[$batch_number] = $facade_batches_options[$batch_number];
}
}
}
@endphp
{{ $drugs[$drugs_to_dispense_array[$i]] }}
@foreach ($auto_deductable_batches_array as $deductable_batch => $batch_quantity)
<div class=row>
<label class="label label-info">
<div class="row">
<div class="col-sm-3">
Batch dispensed from
</div>
<div class="col-sm-5">
<input type="hidden" name="item_ids[]" value="{{ $drugs_to_dispense_array[$i] }}">
<input type="hidden" name="batch_item_ids[]" value="{{ $drugs_to_dispense_array[$i] }}">
{{-- <input type="hidden" name="batch_patient_id[]" value="{{ $batch_details->patient_id }}"> --}}
{{ Form::select('batch_dispensed_from[]', $filtered_batches, $deductable_batch, ['class' => '','style' => 'color: black; font-size: 14px;'])}}
</div>
<div class="col-sm-1"></div>
<div class="col-sm-2">
{{ Form::text('batch_quantity_dispensed[]', $batch_quantity, ['class' => 'form-control', 'style' => 'padding: 1px 5px; height: 20px;'])}}
</div>
</div>
</label>
</div>
@endforeach
<div class=row>
<label class="label label-info" id="batch_dropdown_{{$drugs_to_dispense_array[$i]}}"></label>
</div>
<label class="label label-primary add_batch" id="add_batch_{{$drugs_to_dispense_array[$i]}}">Add batch</label>
<input type="hidden" name="item_name[]" class="item_name_{{$drugs_to_dispense_array[$i]}}" value="{{ get_name($drugs_to_dispense_array[$i], 'id', 'name', 'drugs') }}" >
</td>
<td>
{{ $quantities_to_dispense_array[$i] }}
</td>
<td>
<input type="hidden" name="drug_id[]" value="{{ $drugs_to_dispense_array[$i] }}" >
<input type="number" name="quantity_dispensed[]" value="{{ $quantities_to_dispense_array[$i] }}" step=".01" class="form-control quantity_dispensed_{{$drugs_to_dispense_array[$i]}}" readonly="" required>
</td>
<td>
<textarea name="comments[]" class="form-control"></textarea>
</td>
<td>
<button class="btn btn-info btn-rounded drugDetail" value="{{ $drugs_to_dispense_array[$i] }}">{{ __('pharmacy.view_details') }}</button>
&nbsp; &nbsp;
<a class="btn btn-warning btn-rounded" href="/edit_ward_dispensing_chart/{{ $incoming_chart_record->id }}">{{ __('pharmacy.edit_chart') }}</a>
</td>
</tr>
@endfor
@endif
</tbody>
</table>
</div>
</div>
</div>
@if($cancer_protocol_orders)
<hr/>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table table-bordered">
<thead>
<tr>
<th>Patient</th>
<th>Drugs</th>
<th>Factor</th>
<th>Factor Value</th>
<th>Dosage</th>
<th>Amount to Dispense</th>
<th>Quantity to reduce on stock</th>
<th>Instructions</th>
</tr>
</thead>
<tbody>
@php $cancer_protocol_count = 0; @endphp
@foreach($cancer_protocol_orders as $cancer_protocol_order)
{{ Form::hidden('protocol_ward_charts_id[]', $cancer_protocol_order->id) }}
@php
$patient_id = $cancer_protocol_order->patient_id;
$protocol_id = $cancer_protocol_order->protocol_id;
$height = $cancer_protocol_order->height;
$weight = $cancer_protocol_order->weight;
$vitals_date_taken = $cancer_protocol_order->vitals_date_taken;
$request_comment = $cancer_protocol_order->request_comment;
$ward_id = $cancer_protocol_order->ward_id;
$protocol_drug_ids = explode(',', $cancer_protocol_order->protocol_drug_id);
$protocol_section = explode(',', $cancer_protocol_order->protocol_section);
$protocol_drug_factor = explode(',', $cancer_protocol_order->protocol_drug_factor);
$protocol_drug_factor_value = explode(',', $cancer_protocol_order->protocol_drug_factor_value);
$protocol_drug_dose = explode(',', $cancer_protocol_order->protocol_drug_dose);
$protocol_drug_dosage_label = explode(',', $cancer_protocol_order->protocol_drug_dosage_label);
$protocol_drug_unit_value = explode(',', $cancer_protocol_order->protocol_drug_unit_value);
$protocol_dosage_to_dispense = explode(',', $cancer_protocol_order->protocol_dosage_to_dispense);
$protocol_quantity_to_dispense = explode(',', $cancer_protocol_order->protocol_quantity_to_dispense);
$protocol_instruction = json_decode($cancer_protocol_order->protocol_instruction, false);
@endphp
<tr>
<td rowspan="{{ count($protocol_section) + 1 }}">
<h4>
{{ get_full_name($patient_id, 'id', 'first_name', 'last_name', 'patients') }} ({{ get_name($patient_id, 'id', 'number', 'patients') }})
<br><br>
Height: {{ $height }} &nbsp;&nbsp; Weight: {{ $weight }}
<br>
Taken on: {{ Carbon\Carbon::parse($vitals_date_taken)->toDateTimeString() }}
<br><br>
Request Comment: {{ $request_comment }}
<br><br>
Protocol Name: {{ get_name($protocol_id, 'id', 'name', 'cancer_protocols') }}
<br><br>
Prescribed By: {{ get_full_name($cancer_protocol_order->created_by, 'id', 'first_name', 'last_name', 'users') }}
</h4>
</td>
</tr>
@for($i = 0; $i < count($protocol_drug_ids); $i++)
<tr>
<td>
{{ $drugs[$protocol_drug_ids[$i]] }}
{{ Form::hidden('protocol_drug_ids[]', $protocol_drug_ids[$i]) }}
{{ Form::hidden('protocol_patient_id[]', $cancer_protocol_order->patient_id) }}
{{ Form::hidden('protocol_episode_id[]', $cancer_protocol_order->episode_id) }}
{{ Form::hidden('protocol_ward_id[]', $cancer_protocol_order->ward_id) }}
@php
$auto_deductable_batches_array = get_pharmacy_batch_watcher_ids_to_use_based_on_needed_quantity($protocol_drug_ids[$i], 1, $protocol_quantity_to_dispense[$i]);
if ($auto_deductable_batches_array){
$get_drug_batches = track_batch_stock(1,$protocol_drug_ids[$i],'pharmacy_stock');
//filter out all batches and get the batches for each drug
$filtered_batches = [];
foreach ($get_drug_batches as $data) {
$batch_number = $data['id'];
if (isset($facade_batches_options[$batch_number])) {
$filtered_batches[$batch_number] = $facade_batches_options[$batch_number];
}
}
}
@endphp
@if(count($auto_deductable_batches_array) > 0)
<br><br>
<table class="table table-bordered">
<thead><th><code>Batches To Dispense From</code></th></thead>
<tbody><td id="cancer_batch_dropdown_{{$protocol_drug_ids[$i]}}">
@foreach ($auto_deductable_batches_array as $deductable_batch => $batch_quantity)
<div class="row">
<div class="col-md-9">
<input type="hidden" name="cancer_batch_item_ids[]" value="{{ $protocol_drug_ids[$i] }}">
{{ Form::select('cancer_batch_dispensed_from[]', $filtered_batches, $deductable_batch, ['class' => '','style' => 'color: black; font-size: 14px;'])}}
</div>
<div class="col-md-1"></div>
<div class="col-md-2">
{{ Form::text('cancer_batch_quantity_dispensed[]', $batch_quantity, ['class' => 'form-control', 'style' => 'padding: 1px 5px; height: 20px;'])}}
</div>
</div>
<hr>
@endforeach
</td></tbody>
</table>
<label class="label label-primary cancer_add_batch" id="cancer_add_batch_{{$protocol_drug_ids[$i]}}">Add batch</label>
@endif
@php
$drug_details = \Streamline\Models\Drug::find($protocol_drug_ids[$i]);
@endphp
{{ Form::hidden('drug_strength[]', $drug_details->strength, ['id' => 'protocol_drug_strength_' . $cancer_protocol_count]) }}
{{ Form::hidden('drug_pack[]', $drug_details->pack, ['id' => 'protocol_drug_pack_' . $cancer_protocol_count]) }}
<br><br>
@if ($protocol_section[$i] == 'pre_chemo')
<i>Pre-Chemo</i>
@elseif ($protocol_section[$i] == 'chemo')
<i>Chemo</i>
@else
<i>Post-Chemo</i>
@endif
</td>
<td>
@if ($protocol_drug_factor[$i] == 1)
BSA
@php $protocol_drug_factor_label = "m<sup>2</sup>" @endphp
@elseif ($protocol_drug_factor[$i] == 2)
Weight
@php $protocol_drug_factor_label = "Kg" @endphp
@else
Standard
@php $protocol_drug_factor_label = "" @endphp
@endif
{{ Form::hidden('protocol_drug_factor[]', $protocol_drug_factor[$i], ['id' => 'protocol_drug_factor_' . $cancer_protocol_count]) }}
</td>
<td>
{{ Form::number('protocol_drug_factor_value[]', $protocol_drug_factor_value[$i], ['class' => 'form-control', 'readonly', 'id' => 'protocol_drug_factor_value_' . $cancer_protocol_count]) }}
{!! $protocol_drug_factor_label !!}
</td>
<td>
{{ Form::number('protocol_drug_dose[]', $protocol_drug_dose[$i], ['class' => 'form-control', 'id' => 'protocol_drug_dose_' . $cancer_protocol_count, 'onchange'=>'change_protocol_calculations(\'drug_dose\', ' . $cancer_protocol_count . ')', (Auth::user()->can('alter-cancer-protocol-chart-dispensing')) ? '' : 'readonly']) }}
{{ Form::hidden('protocol_drug_dose_label[]', $protocol_drug_dosage_label[$i]) }}
{!! $protocol_drug_dosage_label[$i] !!}
</td>
<td>
{{ Form::number('protocol_dosage_to_dispense[]', $protocol_dosage_to_dispense[$i], ['class' => 'form-control', 'id' => 'protocol_dosage_to_dispense_' . $cancer_protocol_count, 'onchange'=>'change_protocol_calculations(\'dosage_to_dispense\', ' . $cancer_protocol_count . ')', (Auth::user()->can('alter-cancer-protocol-chart-dispensing')) ? '' : 'readonly']) }}</div>
{{ $protocol_drug_unit_value[$i] }}
</td>
<td>
{{ Form::number('protocol_quantity_to_dispense[]', $protocol_quantity_to_dispense[$i], ['class' => 'form-control', 'id' => 'protocol_quantity_to_dispense_' . $cancer_protocol_count, (Auth::user()->can('alter-cancer-protocol-chart-dispensing')) ? '' : 'readonly']) }}
{{ $drug_forms[$drug_details->form_id] }}
</td>
<td>{{ Form::textarea('protocol_instruction[]', $protocol_instruction[$i], ['class' => 'form-control', 'rows' => '3']) }}</td>
</tr>
@php $cancer_protocol_count++; @endphp
@endfor
@endforeach
</tbody>
</table>
</div>
<hr>
@endif
<div class="row">
<div class="col-sm-3">
<div class="form-group">
{{ Form::label('received_by', __('pharmacy.received_by_title')) }}
{{ Form::select('received_by', $staff_array, '', ['id'=>'received_by','class' => 'form-control col-sm-8 compulsory ward_allocation','required']) }}
</div>
</div>
<div class="col-sm-3">
<div class="form-group">
</div>
</div>
<div class="col-sm-3">
{{ Form::label('approval_date',__('pharmacy.approved_and_dispensed_on')) }}
<div class="input-group">
{{ Form::text('approval_date', \Carbon\Carbon::now()->format('d/m/Y'), ['class' => 'form-control compulsory', 'required' => 'true','readonly','id'=>'approval_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
<div class="col-sm-3">
{{ Form::label('approved_by',__('pharmacy.approved_by_title')) }}
<br>
<font style="color: blue; font-weight: bolder;">
<strong>{{ get_full_name(auth()->user()->id, 'id', 'first_name', 'last_name', 'users') }}</strong></font>
</div>
<div class="col-sm-12">
<button type="submit" class="btn btn-success btn-rounded" id="submitChart" name="submit_chart" value="submit_chart">
{{ __('pharmacy.approve_and_dispense') }}
</button>
</div>
</div>
</div>
{{ Form::close() }}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal" id="showDrugDetailsModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">{{ __('pharmacy.details') }}</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>#</th>
<th>{{ __('pharmacy.name') }}</th>
<th>{{ __('pharmacy.ward') }}</th>
<th>{{ __('pharmacy.drug') }}</th>
<th>{{ __('pharmacy.quantity') }}</th>
</tr>
</thead>
<tbody id="patients_table"></tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<!-- data time picker dependency -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<!-- add datatables -->
<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/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>
<!-- validator -->
<script src="{{ asset('elite/js/validator.js') }}"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#datepicker-autoclose,#datepicker-autoclose-1,#datepicker-autoclose-2,#approval_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy',
setDate: new Date(),
readOnly: true
});
$('#search_by').change(function () {
if ($(this).val() == 1) {
$('#date_search').show();
$('#date_range_search').hide();
}
else if ($(this).val() == 2) {
$('#date_range_search').show();
$('#date_search').hide();
}
else {
$('#date_search,#date_range_search').hide();
}
});
$('.prescription-drugs,#received_by,.batchDispensed').select2({
placeholder: "-- Select --"
});
$('.select2-selection.select2-selection--single').css('height','calc(2.85rem)');
$('.select2-selection.select2-selection--single').css('padding','2px 5px');
//$('.select2-selection.select2-selection--single').css('border-left', '3px solid #F08080');/*add compulsory class*/
$('.select2-selection.select2-selection--single.sec_d').css('border-left', '3px solid #aaa');
$('.select2-selection__arrow').css('top','2px');
/*$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy',
{ extend: 'csv',
message: 'WARD DISPENSING PER CHART'
},
{ extend: 'excel',
message: 'WARD DISPENSING PER CHART',
exportOptions: {
columns: [ 0, 1, 2]
},
sheetName: 'WARD DISPENSING PER CHART ON STREAMLINE'
},
{ extend: 'pdf',
message: 'WARD DISPENSING PER CHART',
orientation: 'landscape',
pageSize: 'LETTER',
exportOptions: {
columns: [ 0, 1, 2]
},
customize: function(doc) {
doc.defaultStyle.fontSize = 10;
}
},
{ extend: 'print',
message: 'WARD DISPENSING PER CHART',
exportOptions: {
columns: [ 0, 1, 2 ]
},
customize: function (win) {
$(win.document.body)
.css('font-size', '10pt')
.css('background', '#fff')
.prepend(
'<img src="<?php echo asset('uploads/logo/logo-sm.png'); ?>" style="position:absolute; top:0; right:0;" />'
);
$(win.document.body).find('table')
.addClass('compact')
.css('font-size', 'inherit');
}
}
]
});*/
$(".drugDetail").click(function(e) {
e.preventDefault();
var incomingChartId = {!! json_encode($incoming_chart_record->id) !!};
var drugId = $(this).val();
console.log(incomingChartId);
console.log(drugId);
$("#showDrugDetailsModal").modal("show");
$.ajax({
type: "POST",
url: "/drug_chart_details",
data: {
drug_id: drugId,
chart_id: incomingChartId
},
cache: false,
success: function (response) {
$('#patients_table').html(response);
}
});
});
$('.table').on('click', '[id^="addNewBatch"]', function (e) {
let id = /\d+(?=\D*$)/.exec($(this).attr('id'));
console.log("adding on for drug id "+id);
let item_name = $(".item_name_"+id).val();
$(".quantity_dispensed_"+id).removeAttr('readonly');
let item_qty_dispensed = $(".quantity_dispensed_"+id).val();
e.preventDefault();
//create another <tr> that we are going to append to
$("<tr><td></td><td>"+item_name+"<br><br><label class='label label-info'>Batch dispensed from<input type='hidden' name='item_ids[]' value='"+id+"'><input type='hidden' name='item_name[]' value='"+item_name+"'><select class='batchDispensed' style='color: black; font-size: 14px; padding: 2px;' required='' name='batch_dispensed_from[]'>@php echo $option_batches; @endphp</select></label></td><td></td><td><input type='hidden' name='drug_id[]' value='"+id+"'><input type='number' name='quantity_dispensed[]' value='' step='.01' class='form-control' required></td><td><textarea name='comments[]' class='form-control'></textarea></td><td></td></tr>").insertAfter( $("#row_item_id_"+id) );
generalSelect2Set('batchDispensed');
});
function generalSelect2Set(id) {
$('.'+id).select2({
/* width: "100%" */
});
$('#'+id).next('.select2-container').find('.select2-selection').css('height', '25px');
$('#'+id).next('.select2-container').find('.select2-selection__rendered').css('margin', '2px');
}
let all_batches_count = 0;
$(".add_batch").click(function (e) {
e.preventDefault();
let drug_id = /\d+(?=\D*$)/.exec($(this).attr('id'));
$("#batch_dropdown_"+drug_id).append("<br><span class='all-batch-"+all_batches_count+"'><div class='row'><div class='col-sm-3'>&nbsp;&nbsp;<input type='hidden' name='batch_item_ids[]' value='"+drug_id+"'>Batch dispensed from </div><div class='col-sm-5'><select style='color: black; font-size: 14px;' required name='batch_dispensed_from[]'><?php echo $option_batches; ?></select></div><div class='col-sm-1'></div><div class='col-sm-2'><input type='number' name='batch_quantity_dispensed[]' class='form-control' style='padding: 1px 5px; height: 20px; width: 50%: margin-left: 50%'/></div><label class='label label-danger remove_batch' id='all-batch-"+all_batches_count+"'>Remove</label></div></span>");
all_batches_count++;
});
$(".cancer_add_batch").click(function (e) {
e.preventDefault();
let drug_id = /\d+(?=\D*$)/.exec($(this).attr('id'));
$("#cancer_batch_dropdown_"+drug_id).append('<div class="row all-batch-' + all_batches_count + '">' +
'<div class="col-md-8">' +
'<input type="hidden" name="cancer_batch_item_ids[]" value="' + drug_id + '">' +
"<select style='color: black; font-size: 14px;' required name='cancer_batch_dispensed_from[]'><?php echo $option_batches; ?></select>" +
'</div>' +
'<div class="col-md-1"></div><div class="col-md-2">' +
'<input type="number" name="cancer_batch_quantity_dispensed[]" class="form-control" style="padding: 1px 5px; height: 20px;"/></div>' +
'<div class="col-md-1"><label class="label label-danger remove_batch" id="all-batch-' + all_batches_count + '">Remove</label></div></div><hr>');
all_batches_count++;
});
$(".table").on("click", ".remove_batch", function (e) {
e.preventDefault();
let batch_count = /\d+(?=\D*$)/.exec($(this).attr('id'));
//if class is "undeletable", proceed to remove
$(".all-batch-"+batch_count).remove();
$(this).remove();
});
});
function change_protocol_calculations(type, id) {
let drug_strength = $('#protocol_drug_strength_' + id).val();
let drug_pack = $('#protocol_drug_pack_' + id).val();
if (type === 'drug_dose') {
let protocol_drug_factor = $('#protocol_drug_factor_' + id).val();
let protocol_drug_factor_value = $('#protocol_drug_factor_value_' + id).val();
let protocol_drug_dose = $('#protocol_drug_dose_' + id).val();
let dosage_to_dispense = protocol_drug_dose;
if (protocol_drug_factor === 1 || protocol_drug_factor === 2) {
dosage_to_dispense = protocol_drug_dose * protocol_drug_factor_value;
}
let quantity_to_dispense = Math.ceil((dosage_to_dispense / drug_strength) / drug_pack);
$('#protocol_dosage_to_dispense_' + id).val(dosage_to_dispense);
$('#protocol_quantity_to_dispense_' + id).val(quantity_to_dispense);
} else if (type === 'dosage_to_dispense') {
let dosage_to_dispense = $('#protocol_dosage_to_dispense_' + id).val();
let quantity_to_dispense = Math.ceil((dosage_to_dispense / drug_strength) / drug_pack);
$('#protocol_quantity_to_dispense_' + id).val(quantity_to_dispense);
}
}
</script>
@endpush
@@ -0,0 +1,508 @@
@extends('layouts.main')
@push('styles')
<style type="text/css">
#t_header th {
background-color: #708090;
color: #000;
}
.color-tr{
background: #FFFF99;
}
.aTable tr {
background-color: #DDD;
}
.table_no_padding td{
padding: 4px;
}
.btn-default-bluish {
background: #b6cce2;
border: 1px solid #e4e7ea;
}
</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">{{ __('pharmacy.confirm_prescription_details') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="{{ route('pharmacy.confirm_prescriptions') }}">{{ __('pharmacy.unconfirmed_prescriptions') }}</a></li>
<li class="active">{{ __('pharmacy.confirm_prescription_details') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('patients::allergies.header')
<br>
</div>
</div>
@if( Auth::user()->can('view-previous-patient-prescriptions'))
@if(count($previous_treatments) > 0)
<div class="white-box" style="padding-top: 2px;">
<h3>{{ __('prescriptions.previous_prescriptions') }}</h3>
<div class="table-responsive">
<table class="table table-striped color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('prescriptions.date') }}</th>
<th>{{ __('prescriptions.clinic') }}</th>
<th>{{ __('prescriptions.primary_diagnosis') }}</th>
<th>{{ __('prescriptions.other_diagnoses') }}</th>
<th>{{ __('prescriptions.prescribed_by') }}</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach($previous_treatments as $past_treatment)
@php
$past_drug_ids_array = explode(",", $past_treatment->drugs);
$past_dosage_array = explode(",", $past_treatment->doses);
$past_quantities_array = explode(",", $past_treatment->quantities_dispensed);
$past_frequencies_array = explode(",", $past_treatment->frequencies);
$past_durations_array = explode(",", $past_treatment->durations);
$past_instructions_array = explode(",", $past_treatment->instructions);
@endphp
<tr>
<td>
{{ streamline_date_time($past_treatment->created_at) }}
<br>
@if(check_if_episode_is_a_followup($past_treatment->episode_id))
<small style="color: green"><br>({{ __('patient_episode.review_from') }} {{ streamline_date(get_name(get_name($past_treatment->episode_id, 'id', 'parent_episode_id', 'patient_episodes'), 'id', 'created_at', 'patient_episodes')) }})</small>
@endif
</td>
<td>
{{ get_name(get_name($past_treatment->episode_id, 'id', 'clinic_id', 'patient_episodes'), "id", "name", "clinics") }}
</td>
<td>
{{ get_name(get_name($past_treatment->episode_id, 'episode_id', 'primary_diagnosis', 'consultations'), 'id', 'name', 'diagnoses') }}
</td>
<td></td>
<td>{{ get_full_name($past_treatment->created_by, "id", "first_name", "last_name", "users") }}</td>
<td>
<a class="btn btn-rounded btn-xs btn-default-bluish view_detail_{{ $past_treatment->id }}" onclick="past_episode_row_details({{ $past_treatment->id }})">{{ __('prescriptions.view_details') }}</a>
</td>
</tr>
<tr class="past_episode_row" id="past_episode_row{{ $past_treatment->id }}" style="display: none">
<td colspan="6">
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table class="table table-striped table-bordered">
<thead>
<tr>
<td><b>{{ __('prescriptions.drug') }}</b></td>
<td><b>{{ __('prescriptions.dosage') }}</b></td>
<td><b>{{ __('prescriptions.duration_in_days') }}</b></td>
<td><b>{{ __('prescriptions.quantity') }}</b></td>
<td><b>{{ __('prescriptions.instruction') }}</b></td>
</tr>
</thead>
<tbody>
@for ($w = 0; $w < count($past_drug_ids_array); $w++)
@php
$past_drug_unit_id = get_name($past_drug_ids_array[$w], 'id', 'unit_id', 'drugs');
$past_frequency_name = get_name($past_frequencies_array[$w], 'id', 'name', 'dosage_frequencies');
$past_unit = get_name($past_drug_unit_id, 'id', 'name', 'drug_units');
$past_unit = $past_unit=="N/A"?"":$past_unit;
$past_drug_unit = "<small>" . $past_unit . "</small>";
@endphp
<tr>
<td>
{{ get_name($past_drug_ids_array[$w], "id", "name", "drugs") }}
</td>
<td>
{{ $past_dosage_array[$w] }} {!! $past_drug_unit !!} &nbsp;&nbsp; {{ $past_frequency_name }}
</td>
<td>
{{ isset($past_durations_array[$w]) ? $past_durations_array[$w] : "" }}
</td>
<td>
{{ $past_quantities_array[$w] }}
</td>
<td>
{{ isset($past_instructions_array[$w]) ? $past_instructions_array[$w] : "" }}
</td>
</tr>
@endfor
<tr>
<td>
<b>{{ __('prescriptions.order_comments') }}</b>
</td>
<td colspan="2">
{!! $past_treatment->order_comments == 1 !!}
</td>
<td>
<b>{{ __('prescriptions.dispensation_status') }}</b>
</td>
<td>
{!! $past_treatment->dispense_status == 1 ? "<span style='color: green'>Dispensed</span>" : "<span style='color: red'>Not dispensed</span>" !!}
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@if(Auth::user()->can('view-patients-home'))
<a href="/patient_episodes/set_patient_id/{{ $patient->id }}" class="btn btn-rounded btn-primary btn-sm"><i class="fa fa-hand-pointer-o"></i> <strong>{{ __('prescriptions.patient_home') }}</strong></a>
@endif
</div>
@endif
@endif
<div class="row">
<div class="col-sm-12">
<div class="white-box">
@include('flash::message')
@if($treatment->is_treatment_progressive != 0)
<h3 class="text-center">{{ __('pharmacy.progressive_prescriptions') }}</h3>
@php $original_prescription = Streamline\Models\TreatmentOpdProgressive::find($treatment->is_treatment_progressive); @endphp
<h4>{{ __('pharmacy.original_prescription') }}</h4>
<div class="table-responsive">
<table class="table table-striped color-bordered-table success-bordered-table">
<thead>
<tr>
<th>#</th>
<th>{{ __('pharmacy.drug_name') }}</th>
<th>{{ __('pharmacy.dose') }}</th>
<th>{{ __('pharmacy.frequency') }}</th>
<th>{{ __('pharmacy.duration') }}</th>
<th>{{ __('pharmacy.quantity_to_dispense') }}</th>
<th>{{ __('pharmacy.instructions') }}</th>
<th>{{ __('pharmacy.amount') }}</th>
</tr>
</thead>
<tbody>
@if($original_prescription)
@php
$drug_explode = explode(",", $original_prescription->drugs);
$dose_explode = explode(",", $original_prescription->dose);
$drug_frequency_explode = explode(",", $original_prescription->drug_frequency);
$instruction_explode = explode(",", $original_prescription->instruction);
$duration_explode = explode(",", $original_prescription->durations);
$quantity_to_dispense = explode(",", $original_prescription->quantities_to_dispense);
$treatment_amount = 0;
$grand_treatment_total = 0;
$quantity_given_so_far = array_fill(0, count($drug_explode), 0);
$quantity_prescribed = array_fill(0, count($drug_explode), 0);
@endphp
@for ($x = 0; $x < count($drug_explode); $x++)
@php
$treatment_subtotal = 0;
// check if the patient category is attached to a price list
$price_list_id = is_patient_category_attached_to_price_list($patient_id);
if(patient_insurance_status($patient_id) == 1){
$item_insurance_details = get_item_insurance_pricing($patient_id, $drug_explode[$x], 4, true, 0);
$treatment_amount = $item_insurance_details[2];
} else {
if ($price_list_id) {
$treatment_amount = get_price_list_category_price($price_list_id, 3, $drug_explode[$x]);
} else {
$treatment_amount = get_name($drug_explode[$x], "id", "non_insured_price", "drugs");
}
}
if(isset($quantity_to_dispense[$x]) && $quantity_to_dispense[$x] != ""){
$treatment_subtotal = $quantity_to_dispense[$x] * $treatment_amount;
}
$grand_treatment_total += $treatment_subtotal;
$quantity_prescribed[$x] = $quantity_to_dispense[$x];
@endphp
<tr>
<td>{{ $x+1 }}.</td>
<td>{{ get_name($drug_explode[$x], 'id', 'name', 'drugs') }}</td>
<td>
@php
$form_id = get_name($drug_explode[$x], 'id', 'form_id', 'drugs');
$unit_id = get_name($drug_explode[$x], 'id', 'unit_id', 'drugs');
$form_name = get_name($form_id, 'id', 'name', 'drug_forms');
$unit_name = get_name($unit_id, 'id', 'name', 'drug_units');
@endphp
@if(isset($dose_explode[$x]) && $dose_explode[$x] != "")
{{ $dose_explode[$x] }} {{ $unit_name }}
@endif
</td>
<td>
@if(isset($drug_frequency_explode[$x]) && $drug_frequency_explode[$x] != "")
{{ get_name($drug_frequency_explode[$x], 'id', 'name', 'dosage_frequencies') }}
@endif
</td>
<td>{{ $duration_explode[$x] }}</td>
<td>{{ $quantity_to_dispense[$x] }}</td>
<td>{{ isset($instruction_explode[$x]) ? $instruction_explode[$x] : "" }}</td>
<td>{{ ugandan_shillings($treatment_subtotal) }}</td>
</tr>
@endfor
<tr>
<td colspan="6"></td>
<td><strong>{{ __('pharmacy.total') }}</strong></td>
<td><strong>{{ ugandan_shillings($grand_treatment_total) }}</strong></td>
</tr>
<tr>
<td colspan="6"></td>
<td><strong>{{ __('pharmacy.prescribed_by') }}</strong></td>
<td><strong>{{ get_full_name($original_prescription->prescribed_by, 'id', 'first_name', 'last_name', 'users') }}</strong></td>
</tr>
@else
<tr><td colspan="8">{{ __('pharmacy.no_records') }}</td></tr>
@endif
</tbody>
</table>
</div>
<hr>
<h4>{{ __('pharmacy.first_dispense') }}</h4>
@endif
<div class="row">
<div class="col-sm-12">
<form id="form" action="{{ url('store_prescription_confirmation') }}" method="post">
{{ csrf_field() }}
<div class="table-responsive">
<table class="table table-striped color-bordered-table success-bordered-table">
<thead>
<tr>
<th>#</th>
<th>{{ __('pharmacy.drug_name') }}</th>
<th>{{ __('pharmacy.dose') }}</th>
<th>{{ __('pharmacy.frequency') }}</th>
<th>{{ __('pharmacy.duration') }}</th>
<th>{{ __('pharmacy.quantity') }}</th>
<th>{{ __('pharmacy.quantity_in_pharmacy') }}</th>
<th>{{ __('pharmacy.instructions') }}</th>
<th>{{ __('pharmacy.amount') }}</th>
<th width="5%">{{ __('pharmacy.to_be_purcharsed_elsewhere') }}</th>
</tr>
</thead>
<tbody>
@php $i=1; @endphp
@if($treatment)
@php
$drug_explode = explode(",", $treatment->drugs);
$dose_explode = explode(",", $treatment->doses);
$dose2_explode = explode(",", $treatment->dose2);
$drug_frequency_explode = explode(",", $treatment->frequencies);
$instruction_explode = explode(",", $treatment->instruction);
$duration_explode = explode(",", $treatment->durations);
//$long_term_explode = explode(",", $treatment_row['Long_Term']);
$dispense_explode = explode(",", $treatment->dispensed);
//$form_explode = explode(",", $treatment_row['Form']);
$quantity_to_dispense = explode(",", $treatment->quantities_dispensed);
$treatment_amount = 0;
$treatment_amount_total = 0;
$grand_treatment_total = 0;
@endphp
<input type="hidden" value="{{ $treatment->id }}" name="treatment_id" />
<input type="hidden" value="{{ $treatment->tta }}" name="tta" />
<input type="hidden" value="{{ $treatment->patient_id }}" name="patient_id">
@for ($x = 0; $x < count($drug_explode); $x++)
@php
$treatment_subtotal = 0;
// check if the patient category is attached to a price list
$price_list_id = is_patient_category_attached_to_price_list($patient_id);
if(patient_insurance_status($patient_id) == 1){
$item_insurance_details = get_item_insurance_pricing($patient_id, $drug_explode[$x], 4, true, 0);
$treatment_amount = $item_insurance_details[2];
} else {
if ($price_list_id) {
$treatment_amount = get_price_list_category_price($price_list_id, 3, $drug_explode[$x]);
} else {
$treatment_amount = get_name($drug_explode[$x], "id", "non_insured_price", "drugs");
}
}
if(isset($quantity_to_dispense[$x]) && $quantity_to_dispense[$x] != ""){
$treatment_subtotal = $quantity_to_dispense[$x] * $treatment_amount;
}
$grand_treatment_total += $treatment_subtotal;
// add amounts to totals
$treatment_amount_total += $treatment_amount;
@endphp
<tr>
<td>{{ $x+1 }}.</td>
<td>
<input type="hidden" name="drug_id[]" value="{{ $drug_explode[$x] }}">
@if(get_name($drug_explode[$x], 'id', 'insurance_coverage', 'drugs') == 1)
<input type="text" readonly style="color: green" step="0.01" name="drug_name[]" class="form-control col-sm-12" value="{{ get_name($drug_explode[$x], 'id', 'name', 'drugs') }}">
@else
<input type="text" readonly style="color: orange" step="0.01" name="drug_name[]" class="form-control col-sm-12" value="{{ get_name($drug_explode[$x], 'id', 'name', 'drugs') }}">
@endif
</td>
<td>
@php
$form_id = get_name($drug_explode[$x], 'id', 'form_id', 'drugs');
$unit_id = get_name($drug_explode[$x], 'id', 'unit_id', 'drugs');
$form_name = get_name($form_id, 'id', 'name', 'drug_forms');
$unit_name = get_name($unit_id, 'id', 'name', 'drug_units');
@endphp
@if(isset($dose_explode[$x]) && $dose_explode[$x] != "")
<input type="text" readonly class="form-control col-sm-12" value="{{ $dose_explode[$x] }} {{ $unit_name }}">
{{ Form::hidden('dose[]', $dose_explode[$x]) }}
@else
{{ Form::hidden('dose[]', 0) }}
@endif
</td>
@if (!empty($dose2_explode[$x]))
@php
$form_id2 = get_name($dose2_explode[$x], 'id', 'form_id', 'drugs');
$form_name2 = get_name($form_id2, 'id', 'name', 'drug_units');
@endphp
<input type="hidden" readonly class="form-control col-sm-12" value="{{ $dose2_explode[$x] }} {{ $form_name2 }}">
{{ Form::hidden('dose2[]', $dose2_explode[$x]) }}
@endif
<td>
@if(isset($drug_frequency_explode[$x]) && $drug_frequency_explode[$x] != "")
<input type="text" readonly step="0.01" name="frequency[]" class="form-control col-sm-12" value="{{ get_name($drug_frequency_explode[$x], 'id', 'name', 'dosage_frequencies') }}">
@else
{{ Form::hidden('frequency[]', 0) }}
@endif
</td>
<td>
<input type="text" readonly step="0.01" name="duration[]" class="form-control col-sm-12" value="{{ $duration_explode[$x] }}">
</td>
<td>
<input type="text" readonly step="0.01" name="quantity_to_dispense[]" class="form-control col-sm-12" value="{{ $quantity_to_dispense[$x] }}">
</td>
@php
$drug_pharmacy_stock = 0;
$batch_records = \Streamline\Models\ItemBatchWatcher::where(['item_type' => 1, 'item_id' => $drug_explode[$x]])->where('pharmacy_stock', '!=', 0)->get();
if(count($batch_records) > 0){
foreach($batch_records as $record){
$drug_pharmacy_stock += $record->pharmacy_stock;
}
}
@endphp
<td>{{ Form::text('quantity_in_pharmacy', $drug_pharmacy_stock, ['class' => 'form-control', 'readonly']) }}</td>
<td>
<textarea name="instructions[]" readonly class="form-control col-sm-12">{{ $instruction_explode[$x] ?? "" }}</textarea>
</td>
<td>
{{ ugandan_shillings($treatment_subtotal) }}
{{ Form::hidden('treatment_subtotal[]', $treatment_subtotal, ['id' => 'treatment_subtotal_' . $drug_explode[$x]]) }}
</td>
<td><input type="checkbox" class="purchased_elsewhere" name="purchased_elsewhere[]" value="{{ $drug_explode[$x] }}" /></td>
</tr>
@endfor
<tr>
<td colspan="6"></td>
<td><strong>{{ __('pharmacy.total') }}</strong></td>
<td><strong>{{ ugandan_shillings($grand_treatment_total) }}</strong></td>
<td></td>
</tr>
@php $i++; @endphp
@else
<tr><td colspan="9">{{ __('pharmacy.no_records') }}</td></tr>
@endif
</tbody>
</table>
</div>
@if(isset($treatment->order_comments))
<hr>
{{ Form::label('order_comments', 'Treatment Order Comments') }}
<textarea name="order_comments" rows="6" readonly class="form-control">{{ $treatment->order_comments }}</textarea>
<br><br>
@endif
<div class="control-group">
<a class="btn btn-warning btn-rounded btn-small" href="alter_prescriptions/{{ $treatment->id }}/ {{ $treatment->patient_id }}">{{ __('pharmacy.alter') }}</a>&nbsp;
<button type="submit" class="btn btn-success btn-rounded btn-small" name="complete" id="complete_button" value="complete">{{ __('pharmacy.confirm') }}</button>&nbsp;
@if(Auth::user()->can('view-progressive-prescriptions') && $treatment->is_treatment_progressive == 0)<a style="float: right;" class="btn btn-primary btn-rounded btn-small" id="dispense_progressive" href="/dispense_treatment_progressively/{{ $treatment->id }}" onclick="return confirm('Are you sure you want to confirm and dispense this order progressively?')">{{ __('pharmacy.confirm_and_dispense_progressively') }}</a>@endif
{{--<a class="btn btn-success btn-small btn-rounded" onclick="return submitDispense();" id="confirm_button">Confirm</a>--}}
</div>
<br>
<div style="float: right;">
{{ __('pharmacy.prescribed_by') }} : <span style="color: blue">{{ get_name($treatment->created_by, 'id', 'first_name', 'users')}} {{ get_name($treatment->created_by, 'id', 'last_name', 'users') }}</span> ({{ get_name($treatment->created_by, 'id', 'phone', 'users') }})
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('js/streamline_plugins/jquery.session.js') }}"></script>
<script>
function submitDispense() {
// begin checking to ensure there is enough quantity dispensed
let drug_id = $("input[name='drug_id[]']" ).map(function(){
return this.value;
}).get();
let quantity_dispensed = $("input[name='quantity_to_dispense[]']" ).map(function(){
return this.value;
}).get();
$.ajax({
url: '/check_dispensed_drugs_quantity',
data: {'drug_id_array[]':drug_id, 'quantity_dispensed_array[]':quantity_dispensed},
success: function(response){
if (response[0] === "1") {
alert(response[1]);
return false;
} else {
$("#alter_button").hide();
$("#confirm_button").hide();
$("#complete_button").show();
}
}
});
}
let current_past_episode = 0;
function past_episode_row_details(id) {
$('.past_episode_row').hide();
if (current_past_episode !== id) {
$('#past_episode_row' + id).show();
current_past_episode = id;
$('.view_detail_'+id).html("Hide Details");
} else {
current_past_episode = 0;
$('.view_detail_'+id).html("View Details");
}
}
</script>
@endpush
@@ -0,0 +1,245 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
<link href="{{ asset('elite/bower_components/typeahead.js-master/dist/typehead-min.css') }}" rel="stylesheet">
@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">{{ __('pharmacy.progressive_treatments') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="{{ route('pharmacy.index') }}">{{ __('pharmacy.pharmacist') }}</a></li>
<li class="active">{{ __('pharmacy.confirm') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default" style="border-radius: 5px;">
<div class="panel-body">
{{ Form::open(['method'=>'post','route' => 'pharmacy.confirm_progressive_prescriptions', 'class' => 'typeahead']) }}
{{ Form::hidden('patient_id', 0, ['id' => 'patient_id']) }}
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>{{ __('pharmacy.select_date') }}:</label>
<select class="form-control compulsory required" name="dates" id="dates" required>
<option value="today">{{ __('pharmacy.today') }}</option>
<option value="yesterday">{{ __('pharmacy.yesterday') }}</option>
<option value="custom_date">{{ __('pharmacy.custom_date') }}</option>
<option value="custom_date_range">{{ __('pharmacy.date_range') }}</option>
</select>
</div>
</div>
<div class="col-md-2" id="sDate" style="display: none;">
<div class="form-group">
{{ Form::label('start_date', __('pharmacy.date_on')) }}
<div class="input-group">
{{ Form::text('start_date', '', ['class'=>'form-control required compulsory', 'readonly', 'id'=>'start_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-2" id="eDate" style="display: none;">
<div class="form-group">
{{ Form::label('end_date', __('pharmacy.end_date')) }}
<div class="input-group">
{{ Form::text('end_date', '', ['class'=>'form-control required compulsory', 'readonly', 'id'=>'end_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-3">
{{ Form::label('search_patient', __('pharmacy.search_by_patient')) }}
<div class="input-group">
<select class="form-control" name="patient_number" id="patient_number"></select>
</div>
</div>
<div class="col-md-2">
<div class="form-group" style="margin-top: 25px;">
{{ Form::submit(__('pharmacy.submit'), ['class'=>'btn btn-success pull-right']) }}
</div>
</div>
</div>
{{ Form::close() }}
</div>
</div>
</div>
</div>
<div class="white-box">
@include('flash::message')
@if(isset($display))
<div class="row">
<div class="col-md-12">
<div class="panel" style="border-radius: 5px;">
<div class="panel-body">
<h3 class="label label-info col-lg-5"> {!! isset($display) ? $display : '' !!}</h3>
</div>
</div>
</div>
</div>
@endif
<div class="table-responsive">
<table class="table table-striped color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('pharmacy.date_first_ordered') }}</th>
<th>{{ __('pharmacy.date_last_updated') }}</th>
<th>{{ __('pharmacy.patient_name') }}</th>
<th>{{ __('pharmacy.patient_category') }}</th>
<th>{{ __('pharmacy.prescribed_by') }}</th>
<th>{{ __('pharmacy.actions') }}</th>
</tr>
</thead>
<tbody>
@if(count($prescriptions) > 0)
@foreach($prescriptions as $prescription)
<tr>
<td>{{ streamline_date_time_short($prescription->created_at) }}</td>
<td>
@if(!is_null($prescription->updated_at) && !is_null($prescription->updated_by))
{{ streamline_date_time_short($prescription->updated_at) }} by {{ get_full_name($prescription->updated_by, 'id', 'first_name', 'last_name', 'users') }}
@endif
</td>
<td>{!! insurance_flag($prescription->patient_id) !!} ({{ get_name($prescription->patient_id, 'id', 'number', 'patients') }})</td>
<td>{{ isset($categories[get_name($prescription->patient_id, 'id', 'category_id', 'patients')]) ? $categories[get_name($prescription->patient_id, 'id', 'category_id', 'patients')] : "" }}</td>
<td>{{ get_full_name($prescription->created_by, 'id', 'first_name', 'last_name', 'users') }}</td>
<td>
<a class="btn btn-success" href="/confirm_progressive_prescriptions_details/{{ $prescription->id }}">{{ __('pharmacy.select') }}</a>
</td>
</tr>
@endforeach
@else
<tr>
<td class="text-center" style="color: red" colspan="6">{{ __('pharmacy.there_are_no_unconfirmed_progessive_treatments') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.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>
$('#patient_number').change(function () {
let id = $('#patient_number').val();
$('#patient_id').val(id);
});
$('#patient_number').select2({
placeholder: 'Search by patient details (names and number)',
ajax: {
url: '/patients/search_patient_by_name_number',
dataType: 'json',
delay: 250,
processResults: function (data) {
return {
results: $.map(data, function (item) {
return {
text: item.first_name + " " + item.last_name + " (" + item.number + ")",
id: item.id
}
})
};
},
cache: true
}
});
$('#dates').change(function (e) {
if($(this).val() === "custom_date"){
$("#eDate").hide();
$("#sDate").show();
}else if($(this).val() === "custom_date_range"){
$("#sDate").show();
$("#eDate").show();
}else{
$("#eDate").hide();
$("#sDate").hide();
}
});
$('#end_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
$('#start_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
$('.table').DataTable({
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
],
"aoColumnDefs": [{
"aTargets": [2,3],
"defaultContent": "",
}],
"pageLength": 25
});
$('#staff_member').select2({
placeholder: "-- select --"
});
$('#staff_member_accountant').select2({
placeholder: "-- select --"
});
</script>
@endpush
@push('styles')
<style type="text/css">
.nav-tabs .nav-item.show .nav-link, .nav-tabs .nav-link.active {
background-color: #a8b5b1;
border-color: #ddd #ddd #fff;
}
.nav-tabs .nav-item.show .nav-link, .nav-tabs .nav-link:hover {
background-color: #a8b5b1;
}
.nav-tabs > li.active > a, .nav-tabs > li.active > a:hover, .nav-tabs > li.active > a:focus {
color: #555;
background-color: #a8b5b1;
}
</style>
@endpush
@@ -0,0 +1,473 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
<link href="{{ asset('elite/bower_components/typeahead.js-master/dist/typehead-min.css') }}" rel="stylesheet">
@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">{{ __('pharmacy.confirm_progressive_treatment') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="{{ route('pharmacy.index') }}">{{ __('pharmacy.pharmacist') }}</a></li>
<li class="active">{{ __('pharmacy.confirm') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('patients::allergies.header')
<br>
</div>
</div>
<div class="white-box">
@include('flash::message')
<h4>{{ __('pharmacy.original_prescription') }}</h4>
<div class="table-responsive">
<table class="table table-striped color-bordered-table success-bordered-table">
<thead>
<tr>
<th>#</th>
<th>{{ __('pharmacy.drug_name') }}</th>
<th>{{ __('pharmacy.dose') }}</th>
<th>{{ __('pharmacy.frequency') }}</th>
<th>{{ __('pharmacy.duration') }}</th>
<th>{{ __('pharmacy.quantity_to_dispense') }}</th>
<th>{{ __('pharmacy.instructions') }}</th>
<th>{{ __('pharmacy.amount') }}</th>
</tr>
</thead>
<tbody>
@if($original_prescription)
@php
$drug_explode = explode(",", $original_prescription->drugs);
$dose_explode = explode(",", $original_prescription->dose);
$drug_frequency_explode = explode(",", $original_prescription->drug_frequency);
$instruction_explode = explode(",", $original_prescription->instruction);
$duration_explode = explode(",", $original_prescription->durations);
$quantity_to_dispense = explode(",", $original_prescription->quantities_to_dispense);
$treatment_amount = 0;
$grand_treatment_total = 0;
$quantity_given_so_far = array_fill(0, count($drug_explode), 0);
$quantity_prescribed = array_fill(0, count($drug_explode), 0);
@endphp
@for ($x = 0; $x < count($drug_explode); $x++)
@php
$treatment_subtotal = 0;
// get insurance status for drug
$drug_insurance_status = get_name($drug_explode[$x], "id", "insurance_coverage", "drugs");
// check if the patient category is attached to a price list
$price_list_id = is_patient_category_attached_to_price_list($patient_id);
if ($price_list_id) {
$treatment_amount = get_price_list_category_price($price_list_id, 3, $drug_explode[$x]);
} else {
// check if drug and patient is eligible for insurance
if($drug_insurance_status == 1 && patient_insurance_status($patient_id) == 1){
$treatment_amount = get_name($drug_explode[$x], "id", "insured_price", "drugs");
} else {
$treatment_amount = get_name($drug_explode[$x], "id", "non_insured_price", "drugs");
}
}
if(isset($quantity_to_dispense[$x]) && $quantity_to_dispense[$x] != ""){
$treatment_subtotal = $quantity_to_dispense[$x] * $treatment_amount;
} else {
$treatment_subtotal = 0;
}
$grand_treatment_total += $treatment_subtotal;
$quantity_prescribed[$x] = $quantity_to_dispense[$x];
@endphp
<tr>
<td>{{ $x+1 }}.</td>
<td>{{ get_name($drug_explode[$x], 'id', 'name', 'drugs') }}</td>
<td>
@php
$form_id = get_name($drug_explode[$x], 'id', 'form_id', 'drugs');
$unit_id = get_name($drug_explode[$x], 'id', 'unit_id', 'drugs');
$form_name = get_name($form_id, 'id', 'name', 'drug_forms');
$unit_name = get_name($unit_id, 'id', 'name', 'drug_units');
@endphp
@if(isset($dose_explode[$x]) && $dose_explode[$x] != "")
{{ $dose_explode[$x] }} {{ $unit_name }}
@endif
</td>
<td>
@if(isset($drug_frequency_explode[$x]) && $drug_frequency_explode[$x] != "")
{{ get_name($drug_frequency_explode[$x], 'id', 'name', 'dosage_frequencies') }}
@endif
</td>
<td>{{ $duration_explode[$x] }}</td>
<td>{{ $quantity_to_dispense[$x] }}</td>
<td>{{ isset($instruction_explode[$x]) ? $instruction_explode[$x] : "" }}</td>
<td>{{ ugandan_shillings($treatment_subtotal) }}</td>
</tr>
@endfor
<tr>
<td colspan="6"></td>
<td><strong>{{ __('pharmacy.total') }}</strong></td>
<td><strong>{{ ugandan_shillings($grand_treatment_total) }}</strong></td>
</tr>
<tr>
<td colspan="6"></td>
<td><strong>{{ __('pharmacy.prescribed_by') }}</strong></td>
<td><strong>{{ get_full_name($original_prescription->prescribed_by, 'id', 'first_name', 'last_name', 'users') }}</strong></td>
</tr>
@else
<tr><td colspan="8">{{ __('pharmacy.no_records') }}</td></tr>
@endif
</tbody>
</table>
</div>
@if(isset($original_prescription->order_comments))
<hr>
{{ Form::label('order_comments', __('pharmacy.treatment_order_comments')) }}
<textarea name="order_comments" rows="6" readonly class="form-control">{{ $original_prescription->order_comments }}</textarea>
<br><br>
@endif
@if(count($previous_progressive_treatments) > 0)
@php $total_amount_paid_so_far = 0; @endphp
<hr>
<h4>{{ __('pharmacy.treatment_given') }}</h4>
<div class="table-responsive">
<table class="table table-striped color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('pharmacy.date') }}</th>
<th>{{ __('pharmacy.drugs') }}</th>
<th>{{ __('pharmacy.dose') }}</th>
<th>{{ __('pharmacy.frequency') }}</th>
<th>{{ __('pharmacy.duration') }}</th>
<th>{{ __('pharmacy.quantities_dispensed') }}</th>
<th>{{ __('pharmacy.amount') }}</th>
</tr>
</thead>
<tbody>
@foreach($previous_progressive_treatments as $treatment)
@php
$drugs = explode(",", $treatment->drugs);
$doses = explode(",", $treatment->doses);
$drug_frequency_explode = explode(",", $treatment->frequencies);
$instruction_explode = explode(",", $treatment->instruction);
$duration_explode = explode(",", $treatment->durations);
$quantity_to_dispense = explode(",", $treatment->quantities_dispensed);
$status_text = "";
if($treatment->payment_status == 1) {
$status_text .= __('pharmacy.paid_comma');
} else {
$status_text .= __('pharmacy.not_paid_comma');
}
if($treatment->dispense_status == 1) {
$status_text .= __('pharmacy.dispensed');
} else {
$status_text .= __('pharmacy.not_dispensed');
}
@endphp
<tr>
<td rowspan="<?php echo count($drugs); ?>">
{{ __('pharmacy.created_on') }} {{ streamline_date_time($treatment->created_at) }} by {{ get_full_name($treatment->created_by, 'id', 'first_name', 'last_name', 'users') }}
<br><br>
<span class="text-success">{{ $status_text }}</span>
</td>
<td>{{ get_drug_name($drugs[0]) }}</td>
<td>
@php
$unit_id = get_name($drugs[0], 'id', 'unit_id', 'drugs');
$unit_name = get_name($unit_id, 'id', 'name', 'drug_units');
@endphp
@if(isset($doses[0]) && $doses[0] != "")
{{ $doses[0] }} {{ $unit_name }}
@endif
</td>
<td>
@if(isset($drug_frequency_explode[0]) && $drug_frequency_explode[0] != "")
{{ get_name($drug_frequency_explode[0], 'id', 'name', 'dosage_frequencies') }}
@endif
</td>
<td>
{{ $duration_explode[0] }}
</td>
<td>
@php
$form_id = get_name($drugs[0], 'id', 'form_id', 'drugs');
$form_name = get_name($form_id, 'id', 'name', 'drug_forms');
$quantity_given_so_far[0] += $quantity_to_dispense[0];
@endphp
{{ $quantity_to_dispense[0] }} {{ $form_name }}
</td>
<td>
@php
$treatment_subtotal = 0;
// get insurance status for drug
$drug_insurance_status = get_name($drugs[0], "id", "insurance_coverage", "drugs");
// check if the patient category is attached to a price list
$price_list_id = is_patient_category_attached_to_price_list($patient_id);
if ($price_list_id) {
$treatment_amount = get_price_list_category_price($price_list_id, 3, $drugs[0]);
} else {
// check if drug and patient is eligible for insurance
if($drug_insurance_status == 1 && patient_insurance_status($patient_id) == 1){
$treatment_amount = get_name($drugs[0], "id", "insured_price", "drugs");
} else {
$treatment_amount = get_name($drugs[0], "id", "non_insured_price", "drugs");
}
}
$treatment_subtotal = $quantity_to_dispense[0] * $treatment_amount;
$total_amount_paid_so_far += $treatment_subtotal;
@endphp
{{ ugandan_shillings($treatment_subtotal) }}
</td>
</tr>
@for($i=1; $i < count($drugs); $i++)
<tr>
<td>{{ get_drug_name($drugs[$i]) }}</td>
<td>
@php
$unit_id = get_name($drugs[$i], 'id', 'unit_id', 'drugs');
$unit_name = get_name($unit_id, 'id', 'name', 'drug_units');
@endphp
@if(isset($doses[$i]) && $doses[$i] != "")
{{ $doses[$i] }} {{ $unit_name }}
@endif
</td>
<td>
@if(isset($drug_frequency_explode[$i]) && $drug_frequency_explode[$i] != "")
{{ get_name($drug_frequency_explode[$i], 'id', 'name', 'dosage_frequencies') }}
@endif
</td>
<td>{{ $duration_explode[$i] }}</td>
<td>
@php
$form_id = get_name($drugs[$i], 'id', 'form_id', 'drugs');
$form_name = get_name($form_id, 'id', 'name', 'drug_forms');
$quantity_given_so_far[$i] += $quantity_to_dispense[$i];
@endphp
{{ $quantity_to_dispense[$i] }} {{ $form_name }}
</td>
<td>
@php
$treatment_subtotal = 0;
// get insurance status for drug
$drug_insurance_status = get_name($drugs[$i], "id", "insurance_coverage", "drugs");
// check if the patient category is attached to a price list
$price_list_id = is_patient_category_attached_to_price_list($patient_id);
if ($price_list_id) {
$treatment_amount = get_price_list_category_price($price_list_id, 3, $drugs[$i]);
} else {
// check if drug and patient is eligible for insurance
if($drug_insurance_status == 1 && patient_insurance_status($patient_id) == 1){
$treatment_amount = get_name($drugs[$i], "id", "insured_price", "drugs");
} else {
$treatment_amount = get_name($drugs[$i], "id", "non_insured_price", "drugs");
}
}
$treatment_subtotal = $quantity_to_dispense[$i] * $treatment_amount;
$total_amount_paid_so_far += $treatment_subtotal;
@endphp
{{ ugandan_shillings($treatment_subtotal) }}
</td>
</tr>
@endfor
@endforeach
<tr>
<td colspan="5"></td>
<td><strong>{{ __('pharmacy.total_amount_prescribed_so_far') }}</strong></td>
<td><strong>{{ ugandan_shillings($total_amount_paid_so_far) }}</strong></td>
</tr>
<tr>
<td colspan="5"></td>
<td><strong>{{ __('pharmacy.total_amount_remaining') }}</strong></td>
<td><strong>{{ ugandan_shillings($grand_treatment_total - $total_amount_paid_so_far) }}</strong></td>
</tr>
</tbody>
</table>
</div>
@endif
<hr>
<h4>{{ __('pharmacy.prescibe_new_treatment') }}</h4>
{{ Form::open(['route' => 'pharmacy.save_progressive_prescriptions', 'data-toggle' => 'validator']) }}
<div class="table-responsive">
<table class="table table-striped color-bordered-table success-bordered-table">
<thead>
<tr>
<th>#</th>
<th>{{ __('pharmacy.drug_name') }}</th>
<th>{{ __('pharmacy.dose') }}</th>
<th>{{ __('pharmacy.frequency') }}</th>
<th>{{ __('pharmacy.duration') }}</th>
<th width="5%">{{ __('pharmacy.quantity_prescribed') }}</th>
<th width="5%">{{ __('pharmacy.quantity_dispensed') }}</th>
<th>{{ __('pharmacy.quantity_to_dispense') }}</th>
<th>{{ __('pharmacy.instructions') }}</th>
<th>{{ __('pharmacy.amount') }}</th>
</tr>
</thead>
<tbody>
@if($original_prescription)
@php $patient_insurance_status = patient_insurance_status($original_prescription->patient_id); @endphp
{{ Form::hidden('patient_id', $original_prescription->patient_id) }}
{{ Form::hidden('patient_insurance_status', $patient_insurance_status, ['id' => 'patient_insurance_status']) }}
{{ Form::hidden('episode_id', $original_prescription->episode_id) }}
{{ Form::hidden('progressive_id', $original_prescription->id) }}
@php
$i=1;
$drug_explode = explode(",", $original_prescription->drugs);
$dose_explode = explode(",", $original_prescription->dose);
$drug_frequency_explode = explode(",", $original_prescription->drug_frequency);
$instruction_explode = explode(",", $original_prescription->instruction);
$duration_explode = explode(",", $original_prescription->durations);
$quantity_to_dispense = explode(",", $original_prescription->quantities_to_dispense);
$treatment_amount = 0;
$grand_treatment_total = 0;
@endphp
@for ($x = 0; $x < count($drug_explode); $x++)
@php
$treatment_subtotal = 0;
// get insurance status for drug
$drug_insurance_status = get_name($drug_explode[$x], "id", "insurance_coverage", "drugs");
// get insurance status for drug
$drug_insurance_status = get_name($drug_explode[$x], "id", "insurance_coverage", "drugs");
// check if the patient category is attached to a price list
$price_list_id = is_patient_category_attached_to_price_list($patient_id);
if ($price_list_id) {
$treatment_amount = get_price_list_category_price($price_list_id, 3, $drug_explode[$x]);
} else {
// check if drug and patient is eligible for insurance
if($drug_insurance_status == 1 && patient_insurance_status($patient_id) == 1){
$treatment_amount = get_name($drug_explode[$x], "id", "insured_price", "drugs");
} else {
$treatment_amount = get_name($drug_explode[$x], "id", "non_insured_price", "drugs");
}
}
$treatment_subtotal = $treatment_amount;
$grand_treatment_total += $treatment_subtotal;
@endphp
<tr>
<td>{{ $x+1 }}.</td>
<td>{{ get_name($drug_explode[$x], 'id', 'name', 'drugs') }} {{ Form::hidden('drug_id[]', $drug_explode[$x]) }}</td>
<td>
@php
$form_id = get_name($drug_explode[$x], 'id', 'form_id', 'drugs');
$unit_id = get_name($drug_explode[$x], 'id', 'unit_id', 'drugs');
$form_name = get_name($form_id, 'id', 'name', 'drug_forms');
$unit_name = get_name($unit_id, 'id', 'name', 'drug_units');
@endphp
@if(isset($dose_explode[$x]) && $dose_explode[$x] != "")
{{ $dose_explode[$x] }} {{ $unit_name }}
{{ Form::hidden('dose[]', $dose_explode[$x]) }}
@else
{{ Form::hidden('dose[]', 0) }}
@endif
</td>
<td>
@if(isset($drug_frequency_explode[$x]) && $drug_frequency_explode[$x] != "")
{{ get_name($drug_frequency_explode[$x], 'id', 'name', 'dosage_frequencies') }}
{{ Form::hidden('frequency[]', $drug_frequency_explode[$x]) }}
@else
{{ Form::hidden('frequency[]', 0) }}
@endif
</td>
<td>{{ Form::number('duration[]', 1, ['class' => 'form-control compulsory', 'required']) }} {{ __('pharmacy.days') }}</td>
<td>{{ Form::number('quantity_prescribed[]', $quantity_prescribed[$x], ['class' => 'form-control compulsory', 'readonly']) }}</td>
<td>{{ Form::number('quantity_given_so_far[]', $quantity_given_so_far[$x], ['class' => 'form-control compulsory', 'readonly']) }}</td>
<td>{{ Form::number('quantity_dispensed[]', 0, ['class' => 'form-control compulsory', 'required', 'id' => 'quantity_dispensed' . $x, 'min' => 0, 'max' => $quantity_prescribed[$x]-$quantity_given_so_far[$x], ($quantity_given_so_far[$x] >= $quantity_prescribed[$x]) ? 'readonly' : '']) }}</td>
<td>{{ Form::textarea('instructions[]', "", ['class' => 'form-control', 'rows' => '3']) }}</td>
<td id="drug_price<?php echo $x; ?>">{{ $treatment_subtotal }} UGx</td>
<input type="hidden" id="selling_price<?php echo $x; ?>" value="<?php echo $treatment_amount ?>">
</tr>
@endfor
<tr>
<td colspan="8"></td>
<td><strong>{{ __('pharmacy.total') }}</strong></td>
<td><strong id="grand_total_column">{{ ugandan_shillings($grand_treatment_total) }}</strong></td>
</tr>
@php $i++; @endphp
@else
<tr><td colspan="8">{{ __('pharmacy.no_records') }}</td></tr>
@endif
</tbody>
</table>
</div>
<br>
{{ Form::button("Submit",['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10 submit-btn']) }}
<a href="/pharmacy/cancel_progressive_prescriptions/{{ $original_prescription->id }}" class="btn btn-primary pull-right">{{ __('pharmacy.cancel_progressive_treatment') }}</a>
{{ Form::close() }}
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<script>
// $('#staff_member').select2({
// placeholder: "-- select --"
// });
$("[id^='quantity_dispensed']").on("change keyup", function () {
var id = /\d+(?=\D*$)/.exec($(this).attr('id'));
var selling_price = parseInt($("#selling_price" + id).val());
var cost = this.value * selling_price;
$("#drug_price" + id).text(cost + " UGx");
var auto_price_grand_total = 0;
$("[id^=drug_price]").each(function(){
var auto_price = $(this).text();
if (auto_price.slice(-3) == 'UGx') {
var auto_price_integer = parseInt(auto_price.slice(0,-3));
auto_price_grand_total += auto_price_integer;
}
});
$("#grand_total_column").text(auto_price_grand_total + " UGx");
});
</script>
@endpush
@@ -0,0 +1,6 @@
<div class="panel panel-default">
<div class="panel-body">
<a href="{{ route('pharmacy.pharmacy_dispensation_report_patients') }}" class="nav-item btn btn-default ti-plus"> {{ __('pharmacy.search_by_patient') }}</a>
<a href="{{ route('pharmacy.pharmacy_dispensation_report_drugs') }}" class="nav-item btn btn-default ti-pencil"> {{ __('pharmacy.search_by_drug') }}</a>
</div>
</div>
@@ -0,0 +1,239 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-6 col-md-7 col-sm-7 col-xs-12">
<h4 class="page-title">{{ __('pharmacy.dispensation_report_details') }}</h4>
</div>
<div class="col-lg-6 col-sm-5 col-md-5 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="{{ url('pharmacy_dispensation_report') }}">{{ __('pharmacy.dispensation_report') }}</a></li>
<li class="active">{{ __('pharmacy.dispensation_report_details') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel">
<div class="panel-heading">{{ __('pharmacy.dispensation_report_details') }}</div>
<div class="panel-body">
<div><h3>{{ __('pharmacy.out_patient_department') }}</h3></div>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table dataTable no-footer">
<thead>
<tr>
<th>#</th>
<th>{{ __('pharmacy.patient') }}</th>
<th>{{ __('pharmacy.quantity') }}</th>
<th>{{ __('pharmacy.dispensed_by') }}</th>
<th>{{ __('pharmacy.dispensed_on') }}</th>
<th>{{ __('pharmacy.clinic') }}</th>
</tr>
</thead>
<tbody>
@php $opd_counter = 1; $total_opd_quantity = 0; @endphp
@if(count($opd_dispensations))
@foreach($opd_dispensations as $opd_record)
<?php
$drugs_array = explode(",", $opd_record->drugs);
$quantities_array = explode(",", $opd_record->quantity_dispensed);
?>
@for ($i=0; $i < count($drugs_array); $i++)
@if($drugs_array[$i] == $selected_drug_id)
<tr>
<td>{{ $opd_counter }}</th>
<td>{{ get_full_name($opd_record->patient_id, "id", "first_name", "last_name", "patients") }}</td>
<td>{{ $quantities_array[$i] }}</td>
@php
$total_opd_quantity += $quantities_array[$i];
@endphp
<td>{{ get_full_name($opd_record->created_by, "id", "first_name", "last_name", "users") }}</td>
<td>{{ streamline_date_time_short($opd_record->created_at) }}</td>
<?php
$episode_id = get_name($opd_record->treatment_id, "id", "episode_id", "treatments");
$clinic_id = get_name($episode_id, "id", "clinic_id", "patient_episodes");
?>
<td>{{ get_name($clinic_id, "id", "name", "clinics") }}</td>
</tr>
@php $opd_counter++; @endphp
@endif
@endfor
@endforeach
<tr>
<td><strong>{{ __('pharmacy.total') }}</strong></td>
<td></td>
<td><strong>{{ $total_opd_quantity }}</strong></td>
<td></td>
<td></td>
<td></td>
</tr>
@endif
</tbody>
</table>
</div>
<div><h3>{{ __('pharmacy.in_patient_department') }}</h3></div>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table dataTable no-footer">
<thead>
<tr>
<th>#</th>
<th>{{ __('pharmacy.patient') }}</th>
<th>{{ __('pharmacy.quantity') }}</th>
<th>{{ __('pharmacy.dispensed_by') }}</th>
<th>{{ __('pharmacy.dispensed_on') }}</th>
<th>{{ __('pharmacy.ward') }}</th>
</tr>
</thead>
<tbody>
@php $ward_counter = 1; $total_ipd_quantity = 0; @endphp
@if(count($ward_dispensations))
@foreach($ward_dispensations as $ward_record)
<tr>
<td>{{ $ward_counter }}</th>
<td>{{ get_full_name($ward_record->patient_id, "id", "first_name", "last_name", "patients") }}</td>
<td>{{ $ward_record->quantity_given }}</td>
@php $total_ipd_quantity += $ward_record->quantity_given; @endphp
<td>{{ get_full_name($ward_record->created_by, "id", "first_name", "last_name", "users") }}</td>
<td>{{ streamline_date($ward_record->created_at) }}</td>
<td>{{ get_name($ward_record->ward_id, "id", "name", "wards") }}</td>
</tr>
@php $ward_counter++; @endphp
@endforeach
<tr>
<td><strong>{{ __('pharmacy.total') }}</strong></td>
<td></td>
<td><strong>{{ $total_ipd_quantity }}</strong></td>
<td></td>
<td></td>
<td></td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<!-- data time picker dependency -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<!-- -->
<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 type="text/javascript">
$(document).ready(function() {
$('#datepicker-autoclose,#datepicker-autoclose-1,#datepicker-autoclose-2').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy'
});
$('#search_by').change(function () {
if ($(this).val() == 1) {
$('#date_search').show();
$('#date_range_search').hide();
}
else if ($(this).val() == 2) {
$('#date_range_search').show();
$('#date_search').hide();
}
else {
$('#date_search,#date_range_search').hide();
}
});
$('#drugs_select').select2({
placeholder: "Select drugs"
});
$('.select2-selection.select2-selection--single').css('height','calc(3.85rem)');
$('.select2-selection.select2-selection--single').css('padding-top','5px');
//$('.select2-selection.select2-selection--single').css('border-left', '3px solid #F08080');/*add compulsory class*/
$('.select2-selection.select2-selection--single.sec_d').css('border-left', '3px solid #aaa');
$('.select2-selection__arrow').css('top','3px');
$(".remove").on("click", function () {
$(this).parent().parent().remove();
});
$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy',
{
extend: 'csv',
message: 'DISPENSED DRUGS REPORT - STREAMLINE'
},
{
extend: 'excel',
message: 'DISPENSED DRUGS REPORT - STREAMLINE',
exportOptions: {
columns: [ 0, 1, 2, 3, 4 ]
},
sheetName: 'DISPENSED DRUGS REPORT - STREAMLINE'
},
{
extend: 'pdf',
message: 'DISPENSED DRUGS REPORT - STREAMLINE',
orientation: 'landscape',
pageSize: 'LETTER',
exportOptions: {
columns: [ 0, 1, 2, 3, 4 ]
},
customize: function(doc) {
doc.defaultStyle.fontSize = 10;
}
},
{
extend: 'print',
message: 'DISPENSED DRUGS REPORT - STREAMLINE',
exportOptions: {
columns: [ 0, 1, 2, 3, 4 ]
},
customize: function (win) {
$(win.document.body)
.css('font-size', '10pt')
.css('background', '#fff')
.prepend(
'<img src="<?php echo asset('uploads/logo/logo-sm.png'); ?>" style="position:absolute; top:0; right:0;" />'
);
$(win.document.body).find('table')
.addClass('compact')
.css('font-size', 'inherit');
}
}
]
});
});
</script>
@endpush
@@ -0,0 +1,205 @@
@extends('layouts.main')
@push('styles')
<style type="text/css">
#t_header th {
background-color: #708090;
color: #000;
}
.color-tr{
background: #FFFF99;
}
.aTable tr {
background-color: #DDD;
}
.table_no_padding td{
padding: 4px;
}
</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">{{ __('pharmacy.dispensing_details') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="{{ route('pharmacy.index') }}">{{ __('pharmacy.incoming_prescriptions') }}</a></li>
<li class="active">{{ __('pharmacy.dispensing_details') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('patients::allergies.header')
<br>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="white-box">
@include('flash::message')
<div class="row">
<div class="col-sm-12">
<form id="form" action="{{ url('dispense_prescription') }}" method="post">
{{ csrf_field() }}
<div class="table-responsive">
<table class="table success-table table-sm table-striped table-hover">
<thead>
<tr>
<th>#</th>
<th style="width: 25%">{{ __('pharmacy.drug_name') }}</th>
<th style="width: 15%">{{ __('pharmacy.dose') }}</th>
<th style="width: 15%">{{ __('pharmacy.frequency') }}</th>
<th style="width: 10%">{{ __('pharmacy.duration') }}</th>
<th style="width: 8%">{{ __('pharmacy.quantity') }}</th>
<th style="width: 8%">{{ __('pharmacy.amount') }}</th>
<th style="width: 25%">{{ __('pharmacy.instructions') }}</th>
<th style="width: 25%"></th>
</tr>
</thead>
<tbody>
@if($treatment)
@php
$total_amount_to_pay = 0;
$drug_explode = explode(",", $treatment->drugs);
$dose_explode = explode(",", $treatment->doses);
$dose2_explode = explode(",", $treatment->dose2);
$drug_frequency_explode = explode(",", $treatment->frequencies);
$instruction_explode = explode(",", $treatment->instruction);
$duration_explode = explode(",", $treatment->durations);
//$long_term_explode = explode(",", $treatment_row['Long_Term']);
$dispense_explode = explode(",", $treatment->dispensed);
//$form_explode = explode(",", $treatment_row['Form']);
$quantity_to_dispense = explode(",", $treatment->quantities_dispensed);
$purchased_elsewhere = explode(",", $treatment->purchased_elsewhere);
@endphp
<tr>
<td colspan="9">
<h4>{{ __('pharmacy.prescribed_on') }} {{ streamline_date_time($treatment->created_at) }} {{ __('pharmacy.by') }} <span style="color: blue">{{ isset($treatment) ? get_full_name($treatment->created_by, 'id', 'first_name', 'last_name', 'users'): "" }}</span> ({{ isset($treatment) ? get_name($treatment->created_by, 'id', 'phone', 'users') : "" }})</h4>
</td>
</tr>
<input type="hidden" value="{{ $treatment->id }}" name="treatment_id" />
<input type="hidden" value="{{ $treatment->tta }}" name="tta" />
<input type="hidden" value="{{ $treatment->patient_id }}" name="patient_id">
@for ($x = 0; $x < count($drug_explode); $x++)
<tr>
<td>{{ $x+1 }}.</td>
<td>
<input type="hidden" name="drug_id[]" value="{{ $drug_explode[$x] }}">
@if(get_name($drug_explode[$x], 'id', 'insurance_coverage', 'drugs') == 1)
<input type="text" readonly style="color: green" step="0.01" name="drug_name[]" class="form-control col-sm-12" value="{{ get_name($drug_explode[$x], 'id', 'name', 'drugs') }}">
@else
<input type="text" readonly style="color: orange" step="0.01" name="drug_name[]" class="form-control col-sm-12" value="{{ get_name($drug_explode[$x], 'id', 'name', 'drugs') }}">
@endif
</td>
<td>
@php
$form_id = isset($drug_explode[$x]) ? get_name($drug_explode[$x], 'id', 'form_id', 'drugs') : "";
$unit_id = isset($drug_explode[$x]) ? get_name($drug_explode[$x], 'id', 'unit_id', 'drugs') : "";
$form_name = isset($form_id) ? get_name($form_id, 'id', 'name', 'drug_forms') : "";
$unit_name = isset($unit_id) ? get_name($unit_id, 'id', 'name', 'drug_units') : "";
@endphp
<input type="text" readonly class="form-control col-sm-12" value="{{ isset($dose_explode[$x]) ? $dose_explode[$x] : "" }} {{ $unit_name }}">
{{ Form::hidden('dose[]', isset($dose_explode[$x]) ? $dose_explode[$x] : "") }}
</td>
@if (!empty($dose2_explode[$x]))
@php
$form_id2 = isset($drug_explode[$x]) ? get_name($dose2_explode[$x], 'id', 'form_id', 'drugs') : "";
$form_name2 = isset($drug_explode[$x]) ? get_name($form_id2, 'id', 'name', 'drug_units') : "";
@endphp
<input type="hidden" readonly class="form-control col-sm-12" value="{{ isset($dose2_explode[$x]) ? $dose2_explode[$x] : "" }} {{ $form_name2 }}">
{{ Form::hidden('dose2[]', isset($dose2_explode[$x]) ? $dose2_explode[$x] : "") }}
@endif
<td>
<input type="text" readonly step="0.01" name="frequency[]" class="form-control col-sm-12" value="{{ get_name( isset($drug_frequency_explode[$x]) ? $drug_frequency_explode[$x] : "", 'id', 'name', 'dosage_frequencies') }}">
</td>
<td>
<input type="text" readonly step="0.01" name="duration[]" class="form-control col-sm-12" value="{{ isset($duration_explode[$x]) ? $duration_explode[$x] : "" }}">
</td>
<td>
<input type="text" readonly step="0.01" name="quantity_to_dispense[]" class="form-control col-sm-12" value="{{ isset($quantity_to_dispense[$x]) ? $quantity_to_dispense[$x] : ""}}">
</td>
<td>
@php
$treatment_amount = 0;
$insurance_amount = 0;
if(get_name($drug_explode[$x], "id", "name", "drugs") != "N/A"){
// insurance flag
$is_insured = 0;
$insurance_amount = 0;
// get insurance status for drug
$drug_insurance_status = get_name($drug_explode[$x], "id", "insurance_coverage", "drugs");
// check if the patient category is attached to a price list
$price_list_id = is_patient_category_attached_to_price_list($treatment->patient_id);
if ($price_list_id) {
$treatment_amount = get_price_list_category_price($price_list_id, 3, $drug_explode[$x]);
} else {
// check if drug and patient is eligible for insurance
if($drug_insurance_status == 1 && patient_insurance_status($treatment->patient_id) == 1){
$treatment_amount = get_name($drug_explode[$x], "id", "insured_price", "drugs");
$insurance_amount = get_name($drug_explode[$x], "id", "non_insured_price", "drugs") - $treatment_amount;
$is_insured = 1;
} else {
$treatment_amount = get_name($drug_explode[$x], "id", "non_insured_price", "drugs");
}
}
if(isset($quantity_to_dispense[$x]) && $quantity_to_dispense[$x] != ""){
$treatment_subtotal = $quantity_to_dispense[$x] * $treatment_amount;
$insurance_amount *= $quantity_to_dispense[$x];
} else {
$treatment_subtotal = 0;
}
}
$total_amount_to_pay += $treatment_subtotal;
@endphp
{{ ugandan_shillings($treatment_subtotal) }}
</td>
<td>
<textarea name="instructions[]" readonly class="form-control col-sm-12">{{ isset($instruction_explode[$x]) ? $instruction_explode[$x] : "" }}</textarea>
</td>
<td>
@if($purchased_elsewhere[$x] == 1)
<code>Purchased Elsewhere</code>
@endif
</td>
</tr>
@endfor
<tr>
<td colspan="5"></td>
<td><h5>{{ __('pharmacy.total') }}</h5></td>
<td>{{ ugandan_shillings($total_amount_to_pay) }}</td>
<td></td>
</tr>
@else
<tr><td colspan="9">{{ __('pharmacy.no_records') }}</td></tr>
@endif
</tbody>
</table>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('js/streamline_plugins/jquery.session.js') }}"></script>
@endpush
@@ -0,0 +1,697 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
<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/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
@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">{{ __('pharmacy.pharmacy_drugs_stock_reconciliation') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('home.dashboard') }}</a></li>
<li><a href="{{ route('stores.index') }}">{{ __('stores.stores') }}</a></li>
<li class="active">{{ __('pharmacy.pharmacy_drugs_stock_reconciliation') }}</li>
</ol>
</div>
</div>
<!--Flash messages at the top -->
@include('flash::message')
<div class="white-box">
{{ Form::open(['route' => 'pharmacy.drugs_stock_reconciliation', 'method' => 'ANY', 'role' => 'search']) }}
<div class="row">
<div class="col-md-6">
<div class="form-group" id="drug_names">
{{ Form::select('search_items_ids[]',$drugs_dropdown,'',['id'=>'drug_ids', 'multiple'=>true, 'class' => 'form-control col-sm-8 drug_ids']) }}
</div>
</div>
<div class="col-md-6">
<button type="submit" class="btn btn-info"><span class="glyphicon glyphicon-search"></span>{{ __('pharmacy.select_items_to_reconcile') }}</button>
</div>
</div>
{{ Form::close() }}
</div>
<div class="white-box">
<form action="{{ url('store_pharmacy_drugs_stock_count') }}" method="POST" name="pharmacy_stock_form" id="pharmacy_stock_form">
{{ csrf_field() }}
<div class="row">
<div class="col-sm-12">
<div class="col-sm-6 hidden_input" style="display: none;">
<div class="alert alert-info">
<strong>The reconciliation fields are arranged in the following order:</strong>
<button type="button" class="close" data-dismiss="alert">×</button>
<span>
<div class="row hidden_input" style="border: 2px solid #cbd1da">
<div class="col-sm-12 hidden_input" style="display: none;">
Batch Number
</div>
<div class="col-sm-12 hidden_input" style="display: none;">
Batch Unit Cost
</div>
<div class="col-sm-12 hidden_input" style="display: none;">
Batch Quantity
</div>
<div class="col-sm-12 hidden_input" style="display: none;">
Batch Expiry Date
</div>
</div>
</span>
</div>
</div>
<p class="text-muted m-b-30">{{ __('stores.export_data_to_csv_excel_pdf') }}</p>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>{{ __('stores.drug_name') }}</th>
<th>{{ __('pharmacy.pharmacy_system_stock') }}</th>
@if(track_items_using_batches())
<td>{{ __('stores.batch_details_and_others') }}</td>
@endif
<th>{{ __('pharmacy.pharmacy_physical_stock') }}</th>
<th>{{ __('stores.difference') }}</th>
<th class="hidden_input" style="display: none;">{{ __('pharmacy.expiry_date') }}</th>
<th>{{ __('stores.variance_in_stock') }}</th>
<th>{{ __('stores.reason_for_difference') }}</th>
<th>{{ __('stores.selling_price') }}</th>
<th class="hidden_input" style="display: none;">{{ __('stores.is_it_initial_stock') }}</th>
</tr>
</thead>
<tfoot>
<tr>
<th>{{ __('stores.drug_name') }}</th>
<th>{{ __('pharmacy.pharmacy_system_stock') }}</th>
@if(track_items_using_batches())
<td>{{ __('stores.batch_details_and_others') }}</td>
@endif
<th>{{ __('pharmacy.pharmacy_physical_stock') }}</th>
<th>{{ __('stores.difference') }}</th>
<th class="hidden_input" style="display: none;">{{ __('pharmacy.expiry_date') }}</th>
<th>{{ __('stores.variance_in_stock') }}</th>
<th>{{ __('stores.reason_for_difference') }}</th>
<th>{{ __('stores.selling_price') }}</th>
<th class="hidden_input" style="display: none;">{{ __('stores.is_it_initial_stock') }}</th>
</tr>
</tfoot>
<tbody>
<tr class="hidden_input" style="display: none;">
<td></td>
<td></td>
@if(track_items_using_batches())
<td></td>
@endif
<td></td>
<td></td>
<td></td>
<td></td>
<td class="hidden_input" style="display: none;"></td>
<td>
<b>{{ __('stores.select_all') }}</b>
</td>
<td>
<input type="checkbox" id="select_all_as_initial_stock" name="select_all_as_initial_stock">
</td>
</tr>
@foreach($drugs as $drug)
@php
$drug_pharmacy_stock = 0;
$batch_records = \Streamline\Models\ItemBatchWatcher::where(['item_type' => 1, 'item_id' => $drug->id])->where('pharmacy_stock', '!=', 0)->get();
if (count($batch_records) > 0) {
foreach ($batch_records as $batch_record) {
$drug_pharmacy_stock += $batch_record->pharmacy_stock;
}
}
@endphp
<tr>
<td>
@if($drug->insurance_coverage == 1)
<span style="color: green;"> {{ $drug->name }} </span>
@else
<span style="color: orange;"> {{ $drug->name }} </span>
@endif
</td>
<td>
<div>
{{ $drug_pharmacy_stock }}
<div class="hidden_input" style="display: none;">
<input type="hidden" name="drug_id[]" value="{{ $drug->id }}">
<input type="hidden" class="form-control" id="cost_price_{{ $drug->id }}" name="cost_price[]" value="{{ $drug->cost_price }}">
</div>
<input type="hidden" name="system_stock[]" class="form-control" id="system_stock_{{ $drug->id }}" value="{{ $drug_pharmacy_stock }}">
</div>
</td>
@if(track_items_using_batches())
<td id="div_to_append_{{ $drug->id }}">
@if(count($batch_records) > 0)
@foreach($batch_records as $record)
<div class="row" style="border: 2px solid #cbd1da; margin-bottom: 2px;" id="div_for_{{ $drug->id }}_{{ $record->batch_number }}">
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px;">
{{ Form::hidden('item_batch_watcher_id[]', $record->id, ['class' => 'batch_record_id_class_'.$record->id]) }}
{{ Form::hidden('batch_drug_id[]', $drug->id, ['class' => 'batch_id_class_'.$drug->id]) }}
{{ Form::hidden('batch_quotation_id[]', $record->id) }}
<input type="hidden" name="" value="{{ $record->pharmacy_stock }}" id="batch_quantity_{{ $record->id }}">
<input type="hidden" name="" value="0" class="batch_variance_balance_{{ $drug->id }}" id="variance_batch_cost_{{ $record->id }}">
<div class="shown_input">
<b>{{ __('stores.batch') }}:</b> <span id="shown_batch_{{ $record->batch_number }}">{{ $record->batch_number }}</span>
</div>
<div class="hidden_input" style="display: none;">
{{ Form::text('batch_number[]', $record->batch_number, ['class' => 'form-control batch_number_'.$drug->id, 'readonly' => 'true']) }}
</div>
</div>
<div class="col-sm-12" style="padding: 0px;">
<div class="shown_input">
<b>{{ __('stores.quantity') }}:</b><font color="blue">{{ $record->pharmacy_stock }}</font> <br/>
@if(Auth::user()->can('remove-batch-during-stock-reconciliation'))
{{-- <small>
@php
$batch_no = $record->batch_number;
$drug_id = $drug->id;
@endphp
<a href="#" style="color: red;" onclick="deleteBatch({{ $drug_id }}, '{{ $batch_no }}')">Remove batch</a>
</small> --}}
@endif
@if(Auth::user()->can('edit-batch-during-stock-reconciliation'))
<small>
@php
$batch_no = $record->batch_number;
$drug_id = $drug->id;
@endphp
<a href="#" id="{{ $batch_no }}" style="color: red;" onclick="editBatch({{$record->id}},{{ $drug_id }}, $(this).attr('id'))">{{ __('stores.edit_batch') }}</a>
</small>
@endif
</div>
{{-- <div class="hidden_input" style="display: none;">
<input type="number" name="batch_quantity_balance[]" value="{{ $record->pharmacy_stock }}" class="form-control batch_qty batch_quantity_balance_{{ $drug->id }}">
</div> --}}
</div>
<div class="col-sm-12 shown_input" style="word-wrap:break-word;padding: 0px;">
<b>{{ __('stores.unit_cost') }}: </b>{{ $record->cost_price }}
</div>
<div class="hidden_input" style="display: none;">
<span style="display:flex;width:25rem;">
@if(Auth::user()->can('edit-unit-cost-during-pharmacy-drugs-stock-reconciliation'))
{{ Form::text('batch_unit_cost[]', $record->cost_price, ['class' => 'form-control batch_unit_cost_'.$drug->id.'','id'=>'batch_unit_cost_'.$record->id.'']) }}
@else
{{ Form::text('batch_unit_cost[]', $record->cost_price, ['class' => 'form-control batch_unit_cost_'.$drug->id.'','id'=>'batch_unit_cost_'.$record->id.'','readonly']) }}
@endif
{{ getCurrencyCode() }}
</span>
</div>
<div class="hidden_input" style="display: none;">
<span style="display:flex;width:25rem;">
<input type="number" name="batch_quantity_balance[]" value="{{ $record->pharmacy_stock }}" class="form-control batch_qty batch_quantity_balance_{{ $drug->id }}" id="batch_quantity_balance_{{ $record->id }}">
QTY
</span>
</div>
<div class="col-sm-12" style="padding: 0px;">
<div class="shown_input">
<b>{{ __('stores.expiry_date') }}:</b> <span>{{ $record->expiry_date }}</span>
</div>
<div class="hidden_input" style="display: none;">
<div class="input-group">
<input type="text" name="expiry_date[]" value="{{ $record->expiry_date }}" autocomplete="off" class="form-control expiry_date_input">
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
@endforeach
@else
<div class="row" style="border: 2px solid #cbd1da">
<div class="col-sm-12" style="padding: 0px;">
{{ Form::hidden('item_batch_watcher_id[]', 0) }}
{{ Form::hidden('batch_drug_id[]', $drug->id) }}
{{ Form::hidden('batch_quotation_id[]', 0) }}
<div class="shown_input">
<!-- kk -->
</div>
<div class="hidden_input" style="display: none;">
{{ Form::text('batch_number[]', '', ['class' => 'form-control col-sm-12 new_batch_number_'.$drug->id, 'placeholder' => 'Batch']) }}
</div>
</div>
<div class="col-sm-12" style="padding: 0px;">
<div class="hidden_input" style="display: none;">
<span style="display:flex;width:25rem;">
{{ Form::text('batch_unit_cost[]', 0, ['class' => 'form-control new_batch_unit_cost_'.$drug->id.'', 'placeholder' => 'Unit cost']) }}
{{ getCurrencyCode() }}
</span>
</div>
</div>
<div class="col-sm-12" style="padding: 0px;">
<div class="hidden_input" style="display: none;">
<span style="display:flex;width:22rem;">
<input type="number" name="batch_quantity_balance[]" class="form-control col-md-12 new_batch_qty new_batch_quantity_balance_{{ $drug->id }}" placeholder="Quantity">
QTY
</span>
</div>
</div>
<div class="col-sm-12" style="padding: 0px;">
<div class="hidden_input" style="display: none;">
<div class="input-group">
<input type="text" name="expiry_date[]" autocomplete="off" placeholder="Expiry date" class="form-control col-md-12 expiry_date_input">
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
@endif
<div class="row show_on_edit" style="display: none;" id="add_batch_{{ $drug->id }}"><a href="#">{{ __('stores.add_batch_small') }}<div>
</td>
@endif
<td>
<div class="shown_input" id="shown_input_{{ $drug->id }}">
{{ $drug_pharmacy_stock == 0 ? $drug_pharmacy_stock : $drug_pharmacy_stock }}
</div>
<div class="hidden_input" style="display: none;">
<input type="number" name="physical_stock[]" readonly class="form-control" id="physical_stock_{{ $drug->id }}" value="{{ $drug_pharmacy_stock == 0 ? $drug_pharmacy_stock : $drug_pharmacy_stock }}" onblur="calculateDifference({{ $drug->id }},{{ $drug->cost_price}}, {{ $drug->non_insured_price}},{{ $drug_pharmacy_stock == 0 ? $drug_pharmacy_stock : $drug_pharmacy_stock}});">
</div>
</td>
<td>
<input type="text" name="difference[]" class="form-control" id="difference_in_stock_{{ $drug->id }}" readonly>
</td>
<td class="hidden_input" style="display: none;">{{-- <input type="text" name="expiry_date[]" value="{{ $drug->expiry_date }}" class="form-control col-md-12 expiry_date_input" readonly> --}}</td>
<td>
<div id="difference_in_cost_value_{{ $drug->id }}">
</div>
<input type="hidden" name="difference_in_cost_value[]" class="form-control" id="difference_in_cost_value_input_{{ $drug->id }}">
</td>
<td>
<textarea class="hidden_input" style="display: none;" name="reason_for_difference[]" class="form-control"></textarea>
</td>
<td>
<div>
{{ ugandan_shillings($drug->non_insured_price) }}
</div>
</td>
<td class="hidden_input" style="display: none;">
@if(is_null($drug->pharmacy_opening_stock))
<input type="checkbox" name="is_initial_stock[]" class="initial_stock_checkboxes" value="{{ $drug->id }}">
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="form-group row">
<div class="col-sm-12"><br><hr></div>
<div class="col-sm-3">
<div class="input-group">
<input type="text" name="reconciliation_date" placeholder="Reconciliation date" class="form-control col-sm-12" id="reconciliation_date" autocomplete="off" required>
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
<div class="col-sm-3">
<div style="float: right; padding-top: 5px; font-size: 14px;">
{{ Form::label('account_id', __('stores.general_comment')) }}
</div>
</div>
{{-- <div class="col-sm-3">
{{ Form::text('account_id', $stock_adjustment_chart_of_account->name, ['class' => 'form-control', 'id' => 'account_id']) }}
<div class="help-block with-errors"></div>
</div> --}}
<div class="col-sm-6">
{{ Form::textarea('general_comment','',['class' => 'form-control', 'placeholder' => __('pharmacy.add_general_comment'), 'rows' => 4]) }}
</div>
<div class="col-sm-12">
<hr>
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">×</button>
<span>
<strong>{{ __('pharmacy.note') }}:</strong>
{{ __('pharmacy.stock_differences_are_reflected_in') }} <b>{{ $stock_adjustment_chart_of_account->name }}</b> {{ __('pharmacy.if_it_is_not_opening_stock') }}. {!! __('pharmacy.if_it_is_the_opening_stock_then_the_affected_account') !!}
</span>
</div>
</div>
{{-- <div class="col-sm-4">
<div style="float: right; padding-top: 5px; font-size: 16px;">
{{ Form::label('account_id', __('stores.select_chart_of_account_affected')) }}
</div>
</div>
<div class="col-sm-4">
{{ Form::select('account_id', $chart_of_accounts, null, ['class' => 'form-control', 'id' => 'account_id']) }}
<div class="help-block with-errors"></div>
</div>
<div class="col-sm-4">
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">×</button>
<span>
This is the account that will be affected by the variances incase it is not the intial stock take of the drug
</span>
</div>
</div> --}}
</div>
</div>
<div class="col-sm-1">
<div style="float: right; position: absolute; bottom: 0;">
<button class="btn btn-default" id="cancel_edit" style="display: none;">{{ __('stores.cancel') }}</button>
<button class="btn btn-success" id="edit_stock" style="margin-bottom: 0px;">{{ __('stores.edit_stock') }}</button>
<!-- <input type="submit" name="save_stock" value="{{ __('stores.save_for_later') }}" class="btn btn-success btn-lg" id="save_stock" style="display: none;"><br><br> -->
<input type="submit" name="reconcile_stock" value="{{ __('stores.reconcile') }}" class="btn btn-success btn-lg" id="reconcile_stock" style="display: none;">
</div>
</div>
</div>
</form>
</div>
<div class="modal fade" id="editBatchModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="exampleModalLabel1"><br><br>{{ __('stores.edit_batch') }}</h4>
</div>
<div class="modal-body">
{{ Form::hidden('batch_record_id', '', ['class' => 'form-control', 'id' => 'batch_record_id',]) }}
{{ Form::hidden('original_drug_id', '', ['class' => 'form-control', 'id' => 'original_drug_id',]) }}
{{ Form::text('original_batch_number', '', ['class' => 'form-control', 'id' => 'original_batch_number', 'readonly']) }}
<br><br>
{{ Form::text('new_batch_number_edit', '', ['class' => 'form-control', 'id' => 'new_batch_number_edit', 'placeholder' => __('stores.new_batch_number')]) }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ __('triage.cancel') }}</button>
<a class="btn btn-success" id="submitNewBatchNumber">{{ __('stores.submit') }}</a>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.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/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
],
drawCallback: function( settings ) {
console.log('DataTables has redrawn the table' );
showHiddenInputs();
}
});
$('.drug_ids').select2({
placeholder: "Select"
});
$('#edit_stock').click(function(e){
e.preventDefault();
$('.hidden_input,#save_stock,#reconcile_stock,.show_on_edit').show();
$('.shown_input').hide();
$(this).hide();
});
function showHiddenInputs(){
if($('#edit_stock').css('display') == 'none'){
$('.hidden_input,#save_stock,#reconcile_stock').show();
$('.shown_input').hide();
$(this).hide();
}
}
// $('body').delegate('#edit_stock', 'click', function (e) {
// e.preventDefault();
// $('.hidden_input,#save_stock,#reconcile_stock').show();
// $('.shown_input').hide();
// $(this).hide();
// });
var created_at = {!! json_encode(calculate_back_date()) !!}
$('#reconciliation_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy',
startDate: new Date(created_at),
endDate:new Date(),
readOnly: true
});
$('.expiry_date_input').datepicker({
autoclose: true,
todayHighlight: true,
format: 'yyyy-mm-dd',
});
$(document).on("change keyup", ".batch_qty, .new_batch_qty, .batch_quantity_balance, .new_batch_quantity_balance, .batch_unit_cost, .new_batch_unit_cost", function () {
var id = /\d+(?=\D*$)/.exec($(this).attr('class')) || [];
var id_unit_cost = /\d+(?=\D*$)/.exec($(this).attr('id')) || [];
if (id.length > 0) id = id[0];
if (id_unit_cost.length > 0) id_unit_cost = id_unit_cost[0];
var total_quantity = 0;
var variance_cost_per_batch = 0;
var original_stock_batch = parseFloat($('#batch_quantity_' + id_unit_cost).val()) || 0;
var unit_cost = parseFloat($('#batch_unit_cost_' + id_unit_cost).val()) || 0;
// Calculate for existing batches
$(".batch_quantity_balance_" + id).each(function () {
var batch_qty = parseInt($(this).val()) || 0;
total_quantity += batch_qty;
});
// Calculate variance for existing batches
$("#batch_quantity_balance_" + id_unit_cost).each(function () {
var batch_qty = parseInt($(this).val()) || 0;
var variance_per_batch = batch_qty - original_stock_batch;
var variance_cost_batch = unit_cost * variance_per_batch;
$('#variance_batch_cost_' + id_unit_cost).val(variance_cost_batch);
});
// Calculate for new batches
var unit_costs = [];
$('.new_batch_unit_cost_' + id).each(function () {
unit_costs.push(parseFloat($(this).val()) || 0); // Ensure it's a float, default to 0 if not a number
});
$(".new_batch_quantity_balance_" + id).each(function (index) {
var batch_qty = parseInt($(this).val()) || 0;
var unit_cost = unit_costs[index] || 0; // Use corresponding unit cost
var variance = batch_qty * unit_cost;
total_quantity += batch_qty;
variance_cost_per_batch += variance;
});
$(".batch_variance_balance_"+id).each(function () {
var batch_cost = parseInt($(this).val());
variance_cost_per_batch += batch_cost;
});
// Update the total quantities and variance costs
$("#shown_input_" + id).text(total_quantity);
$("#physical_stock_" + id).val(total_quantity);
$("#difference_in_cost_value_input_" + id).val(variance_cost_per_batch);
$("#difference_in_cost_value_" + id).html(variance_cost_per_batch + " Ugx");
// Call the calculateDifference function
var drug_cost = parseFloat($("#cost_price_" + id).val()) || 0;
var drug_price = parseFloat($("#non_insured_price_" + id).val()) || 0;
var drug_system_stock = parseInt($("#system_stock_" + id).val()) || 0;
calculateDifference(id, drug_cost, drug_price, drug_system_stock);
});
$('#select_all_as_initial_stock').change(function() {
if (this.checked === true) {
$(".initial_stock_checkboxes").each(function() {
this.checked = true;
});
} else {
$(".initial_stock_checkboxes").each(function() {
this.checked = false;
});
}
});
$('#reconcile_stock').click(function(e){
var empty_compulsory_fields = [];
$(".initial_stock_checkboxes").each(function () {
if (this.checked === false) {
not_initial_stocks_selects = $(this).text();
empty_compulsory_fields.push(not_initial_stocks_selects);
$(this).css('border','1px solid #F08080');
}
});
/* check if the array containing empty compulsory fields is not empty then return false */
if (empty_compulsory_fields.length != 0 && $("#account_id").val() === "") {
alert("<?php echo __('stores.please_select_account') ?>");
$("#account_id").focus();
$("#account_id").css('border','1px solid #F08080');
e.preventDefault();
return false;
}
});
function calculateDifference(drugId,drugCost,drugPrice,stockQuantity) {
var systemStockValue = $("#system_stock_" + drugId).val();
var physicalStockValue = $("#physical_stock_" + drugId).val();
var difference = physicalStockValue - systemStockValue;
var differenceInCostValue = difference * drugCost;
var salesInMoneyValue = systemStockValue * drugPrice;
$("#difference_in_stock_" + drugId).val(difference);
calculateShrinkage(drugId,salesInMoneyValue,physicalStockValue,differenceInCostValue);
}
function calculateShrinkage(drugId,systemStockMoneyValue,physicalStockMoneyValue,differenceInCostValue) {
var shrinkage = systemStockMoneyValue - physicalStockMoneyValue;
systemStockMoneyValue = parseInt(systemStockMoneyValue, 10);
var shrinkagePercentage = 0;
if (systemStockMoneyValue === 0) {
shrinkagePercentage = 0;
} else {
shrinkagePercentage = differenceInCostValue/systemStockMoneyValue * 100;
}
$("#shrinkage_" + drugId).html(shrinkagePercentage.toFixed(2));
$("#shrinkage_input_" + drugId).val(shrinkagePercentage.toFixed(2));//fill hidden input with value
}
$("[id^='add_batch_']").on("click", function (e) {
e.preventDefault();
var id = /\d+(?=\D*$)/.exec($(this).attr('id'));
console.log("clicked div to append == " + id);
var code= {!! json_encode(getCurrencyCode()) !!}
$("#div_to_append_"+id).prepend(`
<div class='row appended_div_row' style='border: 2px solid #cbd1da'>
<div class='col-sm-12' style='padding: 0px;'>
<input type='hidden' name='item_batch_watcher_id[]' value='0'/>
<input type='hidden' name='batch_quotation_id[]' value='0'/>
<input type='hidden' name='batch_drug_id[]' value='${id}'>
<input type="hidden" name="" value="0" class="batch_variance_balance_${id}" id="new_variance_batch_cost">
<div class='hidden_input'>
<input type='text' name='batch_number[]' class='form-control col-sm-12 new_batch_number_${id}' placeholder='Batch'>
</div>
</div>
<div class='col-sm-12' style='padding: 0px;'>
<div class='hidden_input'>
<span style="display:flex;width:22rem;">
<input type='number' name='batch_unit_cost[]' value='0' class='form-control col-md-12 new_batch_unit_cost new_batch_unit_cost_${id}' placeholder='Unit cost'>
${code}
</span>
</div>
</div>
<div class='col-sm-12' style='padding: 0px;'>
<div class='hidden_input'> <span style="display:flex;width:22rem;"><input type='number' name='batch_quantity_balance[]' class='form-control col-md-12 new_batch_qty new_batch_quantity_balance_${id}' placeholder='Quantity'>
QTY</span>
</div>
</div>
<div class='col-sm-12' style='padding: 0px;'>
<div class='hidden_input'>
<div class='input-group'>
<input type='text' name='expiry_date[]' autocomplete='off' placeholder='Expiry date' class='form-control col-md-12 expiry_date_input'>
<span class='input-group-addon'><i class='icon-calender'></i></span>
</div>
</div>
</div>
</div>`);
});
$("[id^='div_to_append_']").on("focus", ".expiry_date_input", function (e) {
$(this).datepicker({
autoclose: true,
todayHighlight: true,
format: 'yyyy-mm-dd'
});
});
function deleteBatch(drugId, batchNumber){
event.preventDefault();
console.log("drug id ====== " + drugId);
console.log("batch number ======= " + batchNumber);
var r = confirm("Are you sure you want to remove this batch?. Note that this will reduce the stock of this drug");
if (r == true) {
console.log("removing drug batch");
$.ajax({
method: 'POST',
url: '/remove_item_batch',
data: {'item_id' : drugId, 'batch_number': batchNumber, 'item_type': 1},
success: function(response){
if(response == 1){
//alert('batch ' + batchNumber +' has been succeffully removed');
$("#div_for_"+drugId+"_"+batchNumber).hide();
} else if(response == 0){
alert('system could not find the batch');
}
},
error: function(jqXHR, textStatus, errorThrown) {
alert(JSON.stringify(jqXHR));
console.log(JSON.stringify(jqXHR));
}
});
} else {
return false;
}
}
function editBatch(batchRecordId, drugId, batchNumber){
console.log(batchNumber);
event.preventDefault();
console.log("drug id ====== " + drugId);
console.log("batch number ======= " + batchNumber);
$("#original_drug_id").val(drugId);
$("#batch_record_id").val(batchRecordId);
$("#original_batch_number").val(batchNumber);
$("#editBatchModal").modal("show");
}
$("#submitNewBatchNumber").click(function(e){
let drugId = $("#original_drug_id").val();
let originalBatchRecordId = $("#batch_record_id").val();
let originalBatchNumber = $("#original_batch_number").val();
let newBatchNumberEdit = $("#new_batch_number_edit").val();
console.log("drugId=="+drugId+" originalBatchNumber=="+originalBatchNumber+" newBatchEdit=="+newBatchNumberEdit);
$.ajax({
method: 'POST',
url: '/editing_item_batch_number',
data: {'item_id' : drugId, 'original_batch_record_id': originalBatchRecordId, 'original_batch_number': originalBatchNumber, 'new_batch_number_edit': newBatchNumberEdit, 'item_type': 1},
success: function(response){
if(response == 1){
alert('batch ' + originalBatchNumber +' has been successfully edited');
$("#shown_batch_"+originalBatchNumber).html(newBatchNumberEdit);
$("#editBatchModal").modal("hide");
$("#"+originalBatchNumber).attr("id",newBatchNumberEdit);
$("#new_batch_number_edit").val("");
} else if(response == 0){
alert('system could not complete batch edit the batch');
}
},
error: function(jqXHR, textStatus, errorThrown) {
alert(JSON.stringify(jqXHR));
console.log(JSON.stringify(jqXHR));
}
});
});
</script>
@endpush
@@ -0,0 +1,185 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<!-- <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" />
@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">{{ __('pharmacy.drugs_stock_reconciliation_report') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li class="active">{{ __('pharmacy.drugs_stock_reconciliation_report') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="panel panel-default">
<div class="panel-body">
{{ Form::open(['method'=>'post','route' => 'stores.stock_reconciliation_report']) }}
<br/>
<h3>{{ __('pharmacy.select_a_date_range') }}</h3>
<br/>
<div class="form-group">
<select class="form-control compulsory required" name="dates" id="dates" required>
<option value="">-select-</option>
<option value="today">{{ __('pharmacy.today') }}</option>
<option value="yesterday">{{ __('pharmacy.yesterday') }}</option>
<option value="custom_date">{{ __('pharmacy.custom_date') }}</option>
<option value="custom_date_range">{{ __('pharmacy.date_range') }}</option>
</select>
</div>
<div id="sDate" style="display: none;">
<div class="form-group">
{{ Form::label('start_date', __('pharmacy.date_on')) }}
<div class="input-group">
{{ Form::text('start_date', '', ['class'=>'form-control required compulsory', 'readonly', 'id'=>'start_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div id="eDate" style="display: none;">
<div class="form-group">
{{ Form::label('end_date', __('pharmacy.end_date')) }}
<div class="input-group">
{{ Form::text('end_date', '', ['class'=>'form-control required compulsory', 'readonly', 'id'=>'end_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="form-group">
{{ Form::submit(__('pharmacy.submit'), ['class'=>'btn btn-success pull-right']) }}
</div>
{{ Form::close() }}
</div>
</div>
</div>
<!-- <div class="col-xs-1"></div> -->
<div class="col-md-9">
<div class="row">
<div class="panel panel-default col-md-12">
<div class="panel-body panel-primary">
<br/>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('pharmacy.date') }}</th>
<th>{{ __('pharmacy.staff_in_charge') }}</th>
<th>{{ __('pharmacy.reconciliation_id') }}</th>
<th>{{ __('pharmacy.action') }}</th>
</tr>
@php
$counter = 0;
@endphp
</thead>
<tbody>
@if(count($reconciled_stocks) > 0)
@foreach($reconciled_stocks as $record)
<tr>
<td>{{ streamline_date($record->created_at) }}</td>
<td>{{ get_full_name($record->created_by, 'id', 'first_name', 'last_name', 'users') }}</td>
<td>{{ sprintf("%04u", $record->stock_count_identifier) }}</td>
<td>
{{ Form::open(['method'=>'post','route' => 'pharmacy.drugs_stock_reconciliation_report_details']) }}
{{ Form::hidden('stock_count_identifier', $record->stock_count_identifier) }}
{{ Form::submit('Details', ['class'=>'btn btn-success']) }}
{{ Form::close() }}
</td>
</tr>
@php
$counter++;
@endphp
@endforeach
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script>
$('#dates').change(function (e) {
if($(this).val() === "custom_date"){
$("#eDate").hide();
$("#sDate").show();
}else if($(this).val() === "custom_date_range"){
$("#sDate").show();
$("#eDate").show();
}else{
$("#eDate").hide();
$("#sDate").hide();
}
});
</script>
<script type="text/javascript">
jQuery('#custom_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
</script>
<script type="text/javascript">
jQuery('#end_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
</script>
<script type="text/javascript">
jQuery('#start_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
</script>
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<script>
$('#staff_member').select2({
placeholder: "-- select --"
});
</script>
@endpush
@@ -0,0 +1,130 @@
@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/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
@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">{{ __('pharmacy.drugs_stock_reconciliation_report_details') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="{{ route('pharmacy.drugs_stock_reconciliation_report') }}">{{ __('pharmacy.pharmacy_drugs_stock_reconciliation_report') }}</a></li>
<li class="active">{{ __('pharmacy.drugs_stock_reconciliation_report_details') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<!--Flash messages at the top -->
@include('flash::message')
<div class="white-box">
<div class="row">
<div class="col-sm-12">
<p class="text-muted m-b-30">{{ __('stores.export_data_to_csv_excel_pdf') }}</p>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>{{ __('stores.drug_name') }}</th>
<th>{{ __('stores.system_stock') }}</th>
<th>{{ __('stores.physical_stock') }}</th>
<th>{{ __('stores.difference') }}</th>
<th>{{ __('stores.reason_for_difference') }}</th>
<th>{{ __('pharmacy.reconciled_by') }}</th>
<th>{{ __('pharmacy.performed_on') }}</th>
</tr>
</thead>
<tfoot>
<tr>
<th>{{ __('stores.drug_name') }}</th>
<th>{{ __('stores.system_stock') }}</th>
<th>{{ __('stores.physical_stock') }}</th>
<th>{{ __('stores.difference') }}</th>
<th>{{ __('stores.reason_for_difference') }}</th>
<th>{{ __('pharmacy.reconciled_by') }}</th>
<th>{{ __('pharmacy.performed_on') }}</th>
</tr>
</tfoot>
<tbody>
@foreach($drugs_reconciled as $reconciliation_record)
@php
$drug_name = get_name($reconciliation_record->drug_id, "id", "name", "drugs");
$insurance_coverage = get_name($reconciliation_record->drug_id, "id", "insurance_coverage", "drugs");
@endphp
<tr>
<td>
@if($insurance_coverage == 1)
<span style="color: green;"> {{ $drug_name }} </span>
@else
<span style="color: orange;"> {{ $drug_name }} </span>
@endif
</td>
<td>
<div>
{{ $reconciliation_record->system_stock }}
</div>
</td>
<td>
<div>
{{ $reconciliation_record->physical_stock }}
</div>
</td>
<td>
<div>
{{ $reconciliation_record->difference }}
</div>
</td>
<td>
<div>
{{ $reconciliation_record->reason_for_difference }}
</div>
</td>
<td>
<div>
{{ get_full_name($reconciliation_record->created_by, 'id', 'first_name', 'last_name', 'users') }}
</div>
</td>
<td>
<div>
{{ streamline_date($reconciliation_record->created_at) }}
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<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/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
});
</script>
@endpush
@@ -0,0 +1,447 @@
@extends('layouts.main')
@push('styles')
<style type="text/css">
#t_header th {
background-color: #708090;
color: #000;
}
.color-tr{
background: #FFFF99;
}
.aTable tr {
background-color: #DDD;
}
.table_no_padding td{
padding: 4px;
}
</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">{{ __('pharmacy.edit_dispensing_details') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="{{ route('pharmacy.index') }}">{{ __('pharmacy.incoming_prescriptions') }}</a></li>
<li class="active">{{ __('pharmacy.edit_dispensing_details') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('patients::allergies.header')
<br>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="white-box">
<h4 class="heading">{{ __('pharmacy.prescription_details_for') }} {{ date_format($treatment->created_at, 'l \, jS F Y') }}</h4>
<div class="row">
<div class="col-sm-12">
<form id="form" action="{{ url('pharmacy/save_altered_prescription') }}" method="post">
{{ csrf_field() }}
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table" id="table">
<thead>
<tr>
<th style="width: 2%">#</th>
<th style="width: 25%">{{ __('pharmacy.drug_name') }}</th>
<th style="width: 15%">{{ __('pharmacy.dose') }}</th>
<th style="width: 15%">{{ __('pharmacy.frequency') }}</th>
<th style="width: 10%">{{ __('pharmacy.duration') }}</th>
<th style="width: 8%">{{ __('pharmacy.quantity') }}</th>
<th style="width: 10%">{{ __('pharmacy.price') }}</th>
<th style="width: 25%">{{ __('pharmacy.instructions') }}</th>
</tr>
</thead>
<tbody>
@if(!is_null($treatment))
@php
$i=1; $total_drugs_price = 0;
$drug_explode = explode(",", $treatment->drugs);
$dose_explode = explode(",", $treatment->doses);
$dose2_explode = explode(",", $treatment->dose2);
$drug_frequency_explode = explode(",", $treatment->frequencies);
$instruction_explode = explode(",", $treatment->instruction);
$duration_explode = explode(",", $treatment->durations);
$dispense_explode = explode(",", $treatment->dispensed);
$quantity_to_dispense = explode(",", $treatment->quantities_dispensed);
@endphp
<input type="hidden" value="{{ $treatment->id }}" name="treatment_id" />
<input type="hidden" value="{{ $treatment->tta }}" name="tta" />
<input type="hidden" value="{{ $treatment->patient_id }}" name="patient_id">
@for ($x = 0; $x < count($drug_explode); $x++)
@if(in_array($drug_explode[$x], $dispensed_drugs_array))
<tr style="background-color: #FFFF99;">
<td>
<a href="#" style="color: maroon"><sup></sup></a>
</td>
<td>
@if(get_name($drug_explode[$x], 'id', 'insurance_coverage', 'drugs') == 1)
{!! '<font style="color: green">'.get_name($drug_explode[$x], 'id', 'name', 'drugs').'</font>' !!}
@else
{!! '<font style="color: orange">'.get_name($drug_explode[$x], 'id', 'name', 'drugs').'</font>' !!}
@endif
<span class="label label-info">{{ __('pharmacy.already_dispensed') }}</span>
</td>
<td>
@php
$form_id = get_name($drug_explode[$x], 'id', 'form_id', 'drugs');
$form_name = get_name($form_id, 'id', 'name', 'drug_units');
$drug_form = get_name($drug_explode[$x], "id", "name", "unit_of_measure");
@endphp
<div class="row">
<div class="col-sm-6">
{{ $dose_explode[$x] }}
<span style="font-size: smaller">{{ $form_name }}</span>
<span style="margin-bottom: 4px; font-size: smaller;" id="equiv1{{ $drug_explode[$x] }}"></span>
</div>
<div class="col-sm-6">
@if (!empty($dose2_explode[$x]))
@php
$form_id2 = get_name($dose2_explode[$x], 'id', 'form_id', 'drugs');
$form_name2 = get_name($form_id2, 'id', 'name', 'drug_units');
@endphp
<span style="font-size: smaller">{{ $form_name2 }}</span>
<span style="margin-bottom: 4px; font-size: smaller;" id="equiv2{{ $drug_explode[$x] }}"></span>
@else
<a id="" style="font-size: xx-small; color: #98AFC7;"></a>
@endif
</div>
</div>
</td>
<td>
{{ $dosage_frequencies[$drug_frequency_explode[$x]] }}
</td>
<td>
@php
$duration_array = explode(' ',$duration_explode[$x]);
$duration = $duration_array[0]; //e.g $duration_array=['2','days'];
@endphp
{{ $duration }} {{ __('pharmacy.days') }}
</td>
<td>
{{ $quantity_to_dispense[$x] }}
</td>
<td class="center" id="auto_price{{ $drug_explode[$x] }}">
@php
$selling_price = get_name($drug_explode[$x], 'id', 'non_insured_price', 'drugs');
$price = $quantity_to_dispense[$x] * $selling_price;
$total_drugs_price = $total_drugs_price + $price;
echo ugandan_shillings($price);
@endphp
</td>
<td>
{{ $instruction_explode[$x] }}
</td>
</tr>
@else
@if(get_name($drug_explode[$x], 'id', 'name', 'drugs') != "N/A")
<tr>
<td>
<a href="#" class="remove_field" style="color: maroon"><sup>X</sup></a>
</td>
<td>
<input type="hidden" name="drug_id[]" value="{{ $drug_explode[$x] }}">
@if(get_name($drug_explode[$x], 'id', 'insurance_coverage', 'drugs') == 1)
<input type="text" readonly style="color: green" name="drug_name[]" class="form-control col-sm-12" value="{{ get_name($drug_explode[$x], 'id', 'name', 'drugs') }}">
@else
<input type="text" readonly style="color: orange" name="drug_name[]" class="form-control col-sm-12" value="{{ get_name($drug_explode[$x], 'id', 'name', 'drugs') }}">
@endif
</td>
<td>
@php
$form_id = get_name($drug_explode[$x], 'id', 'form_id', 'drugs');
$form_name = get_name($form_id, 'id', 'name', 'drug_units');
$drug_form = get_name($drug_explode[$x], "id", "name", "unit_of_measure")
@endphp
<div class="row">
<div class="col-sm-6">
<input type="number" name="dose[]" step="0.001" id="dose{{ $drug_explode[$x] }}" class="form-control col-sm-6" value="{{ $dose_explode[$x] }}">
<span style="font-size: smaller">{{ $form_name }}</span>
<span style="margin-bottom: 4px; font-size: smaller;" id="equiv1{{ $drug_explode[$x] }}"></span>
</div>
<div class="col-sm-6">
@if (!empty($dose2_explode[$x]))
@php
$form_id2 = get_name($dose2_explode[$x], 'id', 'form_id', 'drugs');
$form_name2 = get_name($form_id2, 'id', 'name', 'drug_units');
@endphp
<input type="hidden" name="dose2[]" id="dose2{{ isset($drug_explode[$x]) ? $drug_explode[$x] : '' }}" class="form-control col-sm-12" value="{{ $dose2_explode[$x] }}">
<span style="font-size: smaller">{{ $form_name2 }}</span>
<span style="margin-bottom: 4px; font-size: smaller;" id="equiv2{{ isset($drug_explode[$x]) ? $drug_explode[$x] : '' }}"></span>
@else
<a id="add_dose{{ isset($drug_explode[$x]) ? $drug_explode[$x] : '' }}" style="font-size: xx-small; color: #98AFC7;">{{ __('pharmacy.add_dose') }}</a>
<div id="dose_two_span{{ isset($drug_explode[$x]) ? $drug_explode[$x] : '' }}" style="display: none;">
<input type='number' name='dose_two[]' class="form-control col-sm-12" value="{{ isset($dose2_explode[$x]) ? $dose2_explode[$x] : '' }}" id="dose_two{{ isset($drug_explode[$x]) ? $drug_explode[$x] : '' }}">
<span style="font-size: smaller" >{{ $form_name }}</span>
<span style="margin-bottom: 4px; font-size: smaller;" id="equiv2{{ isset($drug_explode[$x]) ? $drug_explode[$x] : '' }}"></span>
</div>
@endif
</div>
</div>
</td>
<td>
{{ Form::select('frequency[]',$dosage_frequencies,$drug_frequency_explode[$x],['class' => 'form-control compulsory','id' => 'frequency'.$drug_explode[$x],'required']) }}
</td>
<td>
@php
$duration_array = explode(' ',$duration_explode[$x]);
$duration = $duration_array[0]; //e.g $duration_array=['2','days'];
@endphp
<input type="number" name="duration[]" id="duration{{ $drug_explode[$x] }}" class="form-control col-sm-12" value="{{ $duration }}">
<span style="font-size: xx-small;">{{ __('pharmacy.duration_in_days') }}</span>
</td>
<td>
<input type="text" name="quantity_to_dispense[]" id="quantity_dispensed{{ $drug_explode[$x] }}" readonly class="form-control col-sm-12" value="{{ $quantity_to_dispense[$x] }}">
<input type="hidden" id="drug_form{{ $drug_explode[$x] }}" value="{{ $form_name }}">
<input type="hidden" id="selling_price{{ $drug_explode[$x] }}" value="{{ get_name($drug_explode[$x], 'id', 'non_insured_price', 'drugs') }}">
<input type="hidden" name="pack[]" id="pack{{ $drug_explode[$x] }}" value="{{ get_name($drug_explode[$x], 'id', 'pack', 'drugs') }}">
<input type="hidden" name="strength[]" id="strength{{ $drug_explode[$x] }}" value="{{ get_name($drug_explode[$x], 'id', 'strength', 'drugs') }}">
</td>
<td class="center" id="auto_price{{ $drug_explode[$x] }}">
@php
$selling_price = get_name($drug_explode[$x], 'id', 'non_insured_price', 'drugs');
$price = $quantity_to_dispense[$x] * $selling_price;
$total_drugs_price = $total_drugs_price + $price;
echo ugandan_shillings($price);
@endphp
</td>
<td>
<textarea name="instructions[]" readonly class="form-control col-sm-12">{{ $instruction_explode[$x] }}</textarea>
</td>
</tr>
@endif
@endif
@endfor
<tr id="initial_grand_total_row"><td colspan="5"></td><td><strong>{{ __('pharmacy.total') }}:</strong></td><td id="grand_total_column"> {{ ugandan_shillings($total_drugs_price) }}</td><td></td></tr>
@php $x++; @endphp
@else
<tr><td colspan="8">{{ __('pharmacy.no_records') }}</td></tr>
@endif
<tr>
<td colspan="8">
<a class="add_field_button label label-inverse" style="color: white;">{{ __('pharmacy.add_more_drugs') }}</a>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-sm-3" style="margin-top: 3%;">
<b>{{ __('pharmacy.type_of_error') }}</b>
<table class="table table-bordered table-primary table-blue table-striped table-vertical-center table-condensed">
<tbody>
<tr>
<th scope="row"><div align="left">{{ __('pharmacy.wrong_dosage') }}</div></th>
<td>
<input type="checkbox" name="wrong_dosage" id="wrong_dosage" value="<?php echo __('pharmacy.yes') ?>">
</td>
</tr>
<th scope="row">
<div align="left">{{ __('pharmacy.wrong_frequency') }}</div>
</th>
<td><input type="checkbox" name="wrong_frequency" id="wrong_frequency" value="<?php echo __('pharmacy.yes') ?>"></td>
</tr>
<tr>
<th scope="row">
<div align="left">{{ __('pharmacy.inadequate_funds') }}</div>
</th>
<td><input type="checkbox" name="inadequate_funds" id="inadequate_funds" value="<?php echo __('pharmacy.yes') ?>"></td>
</tr>
<tr>
<th scope="row">
<div align="left">{{ __('pharmacy.other') }}</div>
</th>
<td><input type="checkbox" name="other_error" id="other_error" value="<?php echo __('pharmacy.yes') ?>"></td>
</tr>
</tbody>
</table>
</div>
<div class="col-sm-3" style="margin-top: 3%;">
<b>{{ __('pharmacy.severity_of_error') }}</b>
<table class="table table-bordered table-primary table-blue table-striped table-vertical-center table-condensed">
<tbody>
<tr>
<th scope="row"><div align="left">{{ __('pharmacy.mild') }}</div></th>
<td>
<input type="radio" name="severity_of_error" id="mild" value="<?php echo __('pharmacy.mild') ?>" required="required">
</td>
</tr>
<tr>
<th scope="row">
<div align="left">{{ __('pharmacy.moderate') }}</div>
</th>
<td><input type="radio" name="severity_of_error" id="moderate" value="<?php echo __('pharmacy.moderate') ?>" required="required"></td>
</tr>
<tr>
<th scope="row">
<div align="left">{{ __('pharmacy.severe') }}</div>
</th>
<td><input type="radio" name="severity_of_error" id="severe" value="<?php echo __('pharmacy.severe') ?>" required="required"></td>
</tr>
</tbody>
</table>
</div>
<div class="col-sm-6" style="margin-top: 3%;">
<div class="control-group">
<div class="control-label">{{ __('pharmacy.comments') }}</div>
<div class="controls">
<textarea name="comment" id="comment" class="form-control col-sm-12" rows="6"></textarea>
</div>
</div>
</div>
<div class="col-sm-12" style="margin-top: 3%;">
@if($treatment->dispensed == 0)
<div style="float: right;">
{{ __('pharmacy.prescribed_by') }} : <font color="blue">{{ get_name($treatment->created_by, 'id', 'first_name', 'users') }} {{ get_name($treatment->created_by, 'id', 'last_name', 'users') }}</font> ({{ get_name($treatment->created_by, 'id', 'phone', 'users') }})
<input type="hidden" name="prescribed_by" value="{{ $treatment->created_by }}">
</div>
<div class="control-group">
<button type="submit" class="btn btn-success btn-small" name="save_alterations" id="alter_prescription_button">{{ __('pharmacy.alter_prescriptions') }}</button>&nbsp;
</div>
@else
<div>
<span style="color: red;">{{ __('pharmacy.prescription_dispensed_warning') }}!</span>
</div>
@endif
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('js/streamline_plugins/jquery.session.js') }}"></script>
<script type="text/javascript">
$('#alter_prescription_button').click(function () {
if ($('#wrong_dosage').is(':checked') || $('#inadequate_funds').is(':checked') || $('#wrong_frequency').is(':checked') || $('#other_error').is(':checked'))
{
return true;
} else {
alert("<?php echo __('pharmacy.select_type_of_error') ?>");
return false;
}
});
//For the adding of a dynamic row
var max_fields = 8; //maximum input boxes allowed
var wrapper = $("#table"); //Fields wrapper
var add_button = $(".add_field_button"); //Add button ID
var x = 1; //initial text box count
$(add_button).click(function (e) { //on add input button click
e.preventDefault();
if (x < max_fields) { //max input box allowed
x++; //row increment
var j = x + 1;
$(wrapper).append('<tr><td><a href="#" class="remove_field" style="color: maroon"><sup>X</sup></a>&nbsp;</td>\n\ <td><select name="drug_id[]" class="form-control col-sm-12"><option value=""><?php echo $drugsDropDown; ?></option></select></td>\n\
<td><input type="number" name="dose[]" step="0.001" id="dose'+j+'" class="form-control col-sm-12"></td>\n\
<td><select name="frequency[]" id="frequency'+j+'" required="required" class="form-control col-sm-12"><option value=""><?php echo $frequencyDropDown; ?></option></select></td>\n\
<td><input type="number" name="duration[]" id="duration'+j+'" class="form-control col-sm-12"></td>\n\
<input type="hidden" id="drug_form'+j+'" value="">\n\
<input type="hidden" id="selling_price'+j+'" value="">\n\
<input type="hidden" name="pack[]" id="pack'+j+'" value="">\n\
<input type="hidden" name="strength[]" id="strength'+j+'" value="">\n\
<td><input type="number" name="quantity_to_dispense[]" id="quantity_dispensed'+j+'" class="form-control col-sm-12"></td>\n\
<td></td>\n\
<td><textarea name="instructions[]" class="form-control col-sm-12"></textarea></td></tr>'
); //add input box
}
});
$("[id^='dose'],[id^='frequency'],[id^='duration'], [id^='quantity_dispensed']").on("change keyup", function () {
var id = /\d+(?=\D*$)/.exec($(this).attr('id'));
var pack = parseFloat($("#pack" + id).val());
var strength = parseFloat($("#strength" + id).val()) || 0;
var dose1 = parseFloat($("#dose" + id).val()) || 0;
var dose2 = parseFloat($("#dose_two" + id).val()) || 0;
var equiv1 = dose1 / strength;
var equiv2 = dose2 / strength;
$("#equiv1" + id).text("(" + equiv1 + " " + $("#drug_form" + id).val() + ")");
$("#equiv2" + id).text("(" + equiv2 + " " + $("#drug_form" + id).val() + ")");
var equiv_total = (dose1 + dose2) / strength;
if (isNaN(equiv_total) || equiv_total === Infinity) {
var equiv_total = 0;
}
var frequency_id = $("#frequency" + id).val() || 0;
var duration_days = parseInt($("#duration" + id).val()) || 0;
$.ajax({
url: '/prescriptions/get_factor/'+frequency_id,
data: {},
success: function(data){
var factor = parseFloat(data);
var quantity = parseFloat(equiv_total * factor * duration_days) || 0;
var required = quantity / pack;
var dispense = Math.ceil(required); // @TODO Roundup this to the nearest whole number
$("#quantity_dispensed" + id).val(dispense);
var selling_price = parseInt($("#selling_price" + id).val());
var cost = dispense * selling_price;
$("#auto_price" + id).text(cost + " UGx");
},
error: function(response){
console.log(response.responseJSON);
console.log("error in trying to get factor for frequency");
}
});
//auto calculate grand total of the drugs
var auto_price_grand_total = 0;
$("[id^=auto_price]").each(function(){
var auto_price = $(this).text();
//console.log("each price = " + auto_price);
auto_price = auto_price.trim();
// console.log("each price trimmed = " + auto_price);
if (auto_price.slice(-3) == 'UGx') { //if the auto_price column is a UGx
var without_ugx = auto_price.slice(0,-3); /*remove 'UGx' e.g turn 2300UGx to 2300*/
//console.log("each price without_ugx = " + without_ugx);
if (without_ugx.indexOf(',') !== -1) { without_ugx = without_ugx.replace(',',''); }
var auto_price_integer = parseInt(without_ugx);
auto_price_grand_total += auto_price_integer;
//console.log(auto_price_integer);
}
});
$("#grand_total_column").text(auto_price_grand_total + " UGx");
});
$(".remove_field").click(function (e) { //user click on remove text
e.preventDefault();
$(this).parent().parent('tr').remove();
x--;
$("#initial_grand_total_row").hide();
});
$("[id^='add_dose']").click(function () {
var span_id = $(this).attr('id');
var id = span_id.replace('add_dose','');
$("#link_add_dose"+id).hide();
$("#add_dose"+id).hide();
$("#dose_two_span"+id).show();
});
</script>
@endpush
@@ -0,0 +1,379 @@
@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/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
@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">{{ __('pharmacy.edit_requisition') }} #{{ sprintf('%04u', $requisition_id) }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="{{ route('pharmacy.index') }}">{{ __('pharmacy.pharmacist') }}</a></li>
<li class="active">{{ __('pharmacy.edit_requisition') }} </li>
</ol>
</div>
</div>
@include('flash::message')
<div class="row">
<div class="col-sm-12">
<div class="white-box">
<h4>{{ __('pharmacy.previous_requisition_from') }} {{ get_requisition_origin($results[0]->requisition_origin) }}
<span style="color: blue">{{ get_full_name($results[0]->created_by, "id", "first_name", "last_name", "users") }}</span> {{ streamline_date($results[0]->created_at) }} </h4>
<div class="row">
<div class="col-sm-12">
<form name="requisition_form" id="form" action="{{ url('update_previous_requisition') }}" method="post">
{{ csrf_field() }}
<input type="hidden" name="item_type" value="{{ $item_type }}">
<input type="hidden" name="requisition_id" value="{{ $requisition_id }}">
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
{{-- <th>{{ __('pharmacy.date') }}</th> --}}
<th class="center">{{ get_name($item_type, 'id', 'name', 'quotation_types') }}</th>
<th style="width: 20%">{{ __('pharmacy.store_stock') }}</th>
<th style="width:20%;">{{ get_requisition_origin($results[0]->requisition_origin) }} {{ __('stores.stock') }}</th>
<th style="width: 18%">{{ __('pharmacy.quantity') }}</th>
@if($item_type !=2 && $item_type !=4) <th style="width: 18%">{{ __('pharmacy.units') }}</th>@endif
</tr>
</thead>
<tbody>
@php $i=1; @endphp
@if(!is_null($results))
@foreach($results as $result)
<!-- 1-drug 2-sundry 3-dental 4-radiology 5-Lab -->
@php
$items_array = explode(",", $result->drug_id);
$quantity_array = explode(",", $result->quantity_requested);
@endphp
@if($result->quotation_type_id == 1)
@for($i=0; $i < count($items_array) ; $i++)
<tr>
<input type="hidden" name="drug_id[]" value="{{ $items_array[$i] }}">
{{-- <td>
{{ streamline_date($result->created_at) }}
</td> --}}
<td>
{{ get_name($items_array[$i], 'id', 'name', 'drugs') }}
</td>
<td>
@forelse($result->batches[$i]->store_batches as $record)
<div class="row" style="background-color: #e1e1ef; border-radius: 5px 5px; border: 2px #c4b7b7 solid; margin-bottom: 2px; margin-right: 2px;">
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.batch') }}: </b>{{ $record->batch_number }}
</div>
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.quantity') }}: </b>{{ $record->store_stock }}<br>
<b>{{ __('stores.expiry_date') }}: </b>{{ streamline_date_plain($record->expiry_date) }}
</div>
</div>
@empty
@endforelse
Total Stock: {{ $result->batches[$i]->total_store_stock }}
</td>
<td>
@forelse($result->batches[$i]->lab_batches as $record)
<div class="row" style="background-color: #e1e1ef; border-radius: 5px 5px; border: 2px #c4b7b7 solid; margin-bottom: 2px;">
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.batch') }}: </b>{{ $record->batch_number }}
</div>
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.quantity') }}: </b>{{ $record->lab_stock }}<br>
<b>{{ __('stores.expiry_date') }}: </b>{{ streamline_date_plain($record->expiry_date) }}
</div>
</div>
@empty
@endforelse
Total : {{ $result->batches[$i]->total_lab_stock }}
</td>
<td>
<input type="number" name="quantity_requested[]" class="form-control col-sm-12 compulsory" value="{{ $quantity_array[$i] }}">
</td>
<td>
<?php
$drug_form = get_name($items_array[$i], 'id', 'form_id', 'drugs');
$form_name = get_name($drug_form, 'id', 'name', 'unit_of_measure');
?>
<input type="hidden" name="units[]" value="{{ $drug_form }}"/>
{{ $form_name }}
</td>
</tr>
@endfor
@elseif($result->quotation_type_id == 2)
@for($i=0; $i < count($items_array) ; $i++)
<tr>
<input type="hidden" name="drug_id[]" value="{{ $items_array[$i] }}">
{{-- <td>
{{ streamline_date($result->created_at) }}
</td> --}}
<td>
{{ get_name($items_array[$i], 'id', 'name', 'sundries') }}
</td>
<td>
@forelse($result->batches[$i]->store_batches as $record)
<div class="row" style="background-color: #e1e1ef; border-radius: 5px 5px; border: 2px #c4b7b7 solid; margin-bottom: 2px; margin-right: 2px;">
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.batch') }}: </b>{{ $record->batch_number }}
</div>
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.quantity') }}: </b>{{ $record->store_stock }}<br>
<b>{{ __('stores.expiry_date') }}: </b>{{ streamline_date_plain($record->expiry_date) }}
</div>
</div>
@empty
@endforelse
Total Stock: {{ $result->batches[$i]->total_store_stock }}
</td>
<td>
@if ($result->requisition_origin == 2)
@forelse($result->batches[$i]->lab_batches as $record)
<div class="row" style="background-color: #e1e1ef; border-radius: 5px 5px; border: 2px #c4b7b7 solid; margin-bottom: 2px;">
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.batch') }}: </b>{{ $record->batch_number }}
</div>
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.quantity') }}: </b>{{ $record->lab_stock }}<br>
<b>{{ __('stores.expiry_date') }}: </b>{{ streamline_date_plain($record->expiry_date) }}
</div>
</div>
@empty
@endforelse
Total : {{ $result->batches[$i]->total_lab_stock }}
@elseif ($result->requisition_origin == 3)
@forelse($result->batches[$i]->imaging_batches as $record)
<div class="row" style="background-color: #e1e1ef; border-radius: 5px 5px; border: 2px #c4b7b7 solid; margin-bottom: 2px;">
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.batch') }}: </b>{{ $record->batch_number }}
</div>
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.quantity') }}: </b>{{ $record->radiology_stock }}<br>
<b>{{ __('stores.expiry_date') }}: </b>{{ streamline_date_plain($record->expiry_date) }}
</div>
</div>
@empty
@endforelse
Total : {{ $result->batches[$i]->total_imaging_stock }}
@else
@forelse($result->batches[$i]->pharmacy_batches as $record)
<div class="row" style="background-color: #e1e1ef; border-radius: 5px 5px; border: 2px #c4b7b7 solid; margin-bottom: 2px;">
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.batch') }}: </b>{{ $record->batch_number }}
</div>
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.quantity') }}: </b>{{ $record->pharmacy_stock }}<br>
<b>{{ __('stores.expiry_date') }}: </b>{{ streamline_date_plain($record->expiry_date) }}
</div>
</div>
@empty
@endforelse
Total : {{ $result->batches[$i]->total_pharmacy_stock }}
@endif
</td>
<td>
<input type="number" name="quantity_requested[]" class="form-control col-sm-12 compulsory" value="{{ $quantity_array[$i] }}">
</td>
<?php
$drug_form = get_name($items_array[$i], 'id', 'form_id', 'sundries');
$form_name = get_name($drug_form, 'id', 'name', 'unit_of_measure');
?>
<input type="hidden" name="units[]" value="{{ $drug_form }}"/>
{{-- <td>
{{ $form_name }}
</td> --}}
</tr>
@endfor
@elseif($result->quotation_type_id == 3)
@for($i=0; $i < count($items_array) ; $i++)
<tr>
<input type="hidden" name="drug_id[]" value="{{ $items_array[$i] }}">
{{-- <td>
{{ streamline_date($result->created_at) }}
</td> --}}
<td>
{{ get_name($items_array[$i], 'id', 'name', 'dentals') }}
</td>
<td>
<input type="number" name="quantity_requested[]" class="form-control col-sm-12 compulsory" value="{{ $quantity_array[$i] }}">
</td>
<td>
<?php
$drug_form = get_name($items_array[$i], 'id', 'form_id', 'dentals');
$form_name = get_name($drug_form, 'id', 'name', 'unit_of_measure');
?>
<input type="hidden" name="units[]" value="{{ $drug_form }}"/>
{{ $form_name }}
</td>
</tr>
@endfor
@elseif($result->quotation_type_id == 4)
@for($i=0; $i < count($items_array) ; $i++)
<tr>
<input type="hidden" name="drug_id[]" value="{{ $items_array[$i] }}">
{{-- <td>
{{ streamline_date($result->created_at) }}
</td> --}}
<td>
{{ get_name($items_array[$i], 'id', 'name', 'radiologies') }}
</td>
<td>
@forelse($result->batches[$i]->store_batches as $record)
<div class="row" style="background-color: #e1e1ef; border-radius: 5px 5px; border: 2px #c4b7b7 solid; margin-bottom: 2px; margin-right: 2px;">
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.batch') }}: </b>{{ $record->batch_number }}
</div>
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.quantity') }}: </b>{{ $record->store_stock }}<br>
<b>{{ __('stores.expiry_date') }}: </b>{{ streamline_date_plain($record->expiry_date) }}
</div>
</div>
@empty
@endforelse
Total Stock: {{ $result->batches[$i]->total_store_stock }}
</td>
<td>
@forelse($result->batches[$i]->lab_batches as $record)
<div class="row" style="background-color: #e1e1ef; border-radius: 5px 5px; border: 2px #c4b7b7 solid; margin-bottom: 2px;">
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.batch') }}: </b>{{ $record->batch_number }}
</div>
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.quantity') }}: </b>{{ $record->lab_stock }}<br>
<b>{{ __('stores.expiry_date') }}: </b>{{ streamline_date_plain($record->expiry_date) }}
</div>
</div>
@empty
@endforelse
Total : {{ $result->batches[$i]->total_lab_stock }}
</td>
<td>
<input type="number" name="quantity_requested[]" class="form-control col-sm-12 compulsory" value="{{ $quantity_array[$i] }}">
</td>
<?php
$drug_form = get_name($items_array[$i], 'id', 'form_id', 'drugs');
$form_name = get_name($drug_form, 'id', 'name', 'unit_of_measure');
?>
<input type="hidden" name="units[]" value="{{ $drug_form }}"/>
{{-- <td>
{{ $form_name }}
</td> --}}
</tr>
@endfor
@elseif($result->quotation_type_id == 5)
@for($i=0; $i < count($items_array) ; $i++)
<tr>
<input type="hidden" name="drug_id[]" value="{{ $items_array[$i] }}">
{{-- <td>
{{ streamline_date($result->created_at) }}
</td> --}}
<td>
{{ get_name($items_array[$i], 'id', 'name', 'labs') }}
</td>
<td>
@forelse($result->batches[$i]->store_batches as $record)
<div class="row" style="background-color: #e1e1ef; border-radius: 5px 5px; border: 2px #c4b7b7 solid; margin-bottom: 2px; margin-right: 2px;">
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.batch') }}: </b>{{ $record->batch_number }}
</div>
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.quantity') }}: </b>{{ $record->store_stock }}<br>
<b>{{ __('stores.expiry_date') }}: </b>{{ streamline_date_plain($record->expiry_date) }}
</div>
</div>
@empty
@endforelse
Total Stock: {{ $result->batches[$i]->total_store_stock }}
</td>
<td>
@forelse($result->batches[$i]->lab_batches as $record)
<div class="row" style="background-color: #e1e1ef; border-radius: 5px 5px; border: 2px #c4b7b7 solid; margin-bottom: 2px;">
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.batch') }}: </b>{{ $record->batch_number }}
</div>
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.quantity') }}: </b>{{ $record->lab_stock }}<br>
<b>{{ __('stores.expiry_date') }}: </b>{{ streamline_date_plain($record->expiry_date) }}
</div>
</div>
@empty
@endforelse
Total : {{ $result->batches[$i]->total_lab_stock }}
</td>
<td>
<input type="number" name="quantity_requested[]" class="form-control col-sm-12 compulsory" value="{{ $quantity_array[$i] }}">
</td>
<td>
<?php
$drug_form = get_name($items_array[$i], 'id', 'unit_id', 'labs');
$form_name = get_name($drug_form, 'id', 'name', 'unit_of_measure');
?>
<input type="hidden" name="units[]" value="{{ $drug_form }}"/>
{{ $form_name }}
</td>
</tr>
@endfor
@endif
@endforeach
@else
<tr><td colspan="4">{{ __('pharmacy.no_records') }}</td></tr>
@endif
</tbody>
</table>
</div>
</div>
<div class="col-sm-4">
<div class="control-group">
<input type="submit" class="btn btn-success btn-small" id="submit_button" value="<?php echo __('pharmacy.update_requisition') ?>"/>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<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>
<!-- data time piker dependency -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<!-- -->
<script type="text/javascript">
$('.datepicker-autoclose,#datepicker-autoclose1').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy',
setDate: new Date(),
readOnly: true
});
</script>
@endpush
@@ -0,0 +1,227 @@
@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/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
@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">{{ __('pharmacy.edit_requisition') }} # {{ sprintf('%04u', $requisition_id) }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="{{ route('pharmacy.index') }}">{{ __('pharmacy.pharmacist') }}</a></li>
<li class="active">{{ __('pharmacy.edit_requisition') }} </li>
</ol>
</div>
</div>
@include('flash::message')
<div class="row">
<div class="col-sm-12">
<div class="white-box">
<div class="row">
<div class="col-sm-8">
<form name="quotation_form" id="quotation_form" action="#" method="post">
{{ csrf_field() }}
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th style="width: 20">{{ __('pharmacy.date') }}</th>
<th style="width: 50%">{{ __('pharmacy.name') }}</th>
<th style="width: 20%">{{ __('pharmacy.quantity') }}</th>
<th style="width: 10%"></th>
</tr>
</thead>
<tfoot>
<tr>
<th>{{ __('pharmacy.date') }}</th>
<th>{{ __('pharmacy.name') }}</th>
<th>{{ __('pharmacy.quantity') }}</th>
<th></th>
</tr>
</tfoot>
<tbody>
@if(!is_null($requisition_results))
@foreach($requisition_results as $result)
@php
$drug_id_explode = explode(",", $result->drug_id);
$quantity_explode = explode(",", $result->quantity_requested);
$supplier_id = $result->supplier_id;
$expected_date = $result->expected_date;
@endphp
@for ($x = 0; $x < count($drug_id_explode); $x++)
@php
$drug_form_id = 0;
if($result->quotation_type_id == 1){
$drug_form_id = get_name($drug_id_explode[$x], "id", "form_id", "drugs");
} else if($result->quotation_type_id == 2){
$drug_form_id = 0;//get_name($drug_id_explode[$x], "id", "form_id", "sundries");
} else if($result->quotation_type_id == 5){
$drug_form_id = get_name($drug_id_explode[$x], "id", "form_id", "labs");
}
$drug_form_name = get_name($drug_form_id, "id", "name", "unit_of_measure");
@endphp
<tr>
<td>{{ streamline_date($result->created_at) }}</td>
@if($result->quotation_type_id == 1)
<td>{{ get_name($drug_id_explode[$x], "id", "name", "drugs") }}</td>
@elseif($result->quotation_type_id == 2)
<td>{{ get_name($drug_id_explode[$x], "id", "name", "sundries") }}</td>
@elseif($result->quotation_type_id == 5)
<td>{{ get_name($drug_id_explode[$x], "id", "name", "labs") }}</td>
@endif
<td>
<input type="hidden" name="drug_id[]" value="{{ $drug_id_explode[$x] }}"/>
<input type="number" min="0" step="0.001" class="form-control col-sm-6 compulsory" value="{{ isset($quantity_explode[$x]) ? $quantity_explode[$x] : '' }}" name="quantity[]">
</td>
<td>{{ $drug_form_name }}</td>
</tr>
@endfor
@endforeach
<input type="hidden" id="temporary_requisition_id" name="temporary_requisition_id" value="{{ $requisition_id }}">
@else
<tr><td colspan="3">{{ __('pharmacy.no_records') }}</td></tr>
@endif
</tbody>
</table>
</div>
</div>
<div class="col-sm-4">
<input type="hidden" name="item_type" value="{{ $quotation_type }}">
<!-- <div class="form-group">
{{ Form::label('supplier', __('pharmacy.supplier')) }}
{{ Form::select('supplier', $suppliers , $supplier_id, ['class'=>'form-control compulsory', 'required']) }}
</div>
<div class="form-group">
{{ Form::label('expected_date',__('pharmacy.expected_date')) }}
<div class="input-group">
{{ Form::text('expected_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'datepicker-autoclose']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
<div class="help-block with-errors"></div>
</div>
<div> <small><a href="#" data-toggle="modal" data-target="#addNewSupplier">add supplier</a></small> </div><br> -->
{{ Form::button(__('pharmacy.update_requisition'),['type'=>'submit','form'=>'quotation_form','id'=>'save_temporary_request','name'=>'update_temporary_requisition','value'=>'1','formaction'=>'store_pharmacy_requisition','class'=>'btn btn-default waves-effect waves-light m-r-10']) }}
<br>
{{ Form::button(__('pharmacy.complete_request'),['type'=>'submit','form'=>'quotation_form','id'=>'submit_quotation_for_drugs','name'=>'complete_previously_temporary_requisition','value'=>'1','formaction'=>'store_pharmacy_requisition','class'=>'btn btn-success waves-effect waves-light m-r-10']) }}
{{ Form::close() }}
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="addNewSupplier" tabindex="-1" role="dialog" aria-labelledby="addNewSupplierLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="addNewSupplierLabel">{{ __('pharmacy.add_new_supplier') }}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="form-group">
{{ Form::label('supplier_name', __('pharmacy.supplier_name')) }}
{{ Form::text('supplier_name', '', ['class'=>'form-control compulsory', 'required','id'=>'supplier_name']) }}
</div>
<div class="form-group">
{{ Form::label('supplier_company', __('pharmacy.company')) }}
{{ Form::text('supplier_company', '', ['class'=>'form-control compulsory', 'required','id'=>'supplier_company']) }}
</div>
<div class="form-group">
{{ Form::label('supplier_contact', __('pharmacy.mobile_number')) }}
{{ Form::number('supplier_contact', '', ['class'=>'form-control compulsory', 'required','id'=>'supplier_contact']) }}
</div>
<div class="form-group">
{{ Form::label('supplier_address', __('pharmacy.address')) }}
{{ Form::text('supplier_address', '', ['class'=>'form-control compulsory', 'required','id'=>'supplier_address']) }}
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">{{ __('pharmacy.close') }}</button>
<button type="button" class="btn btn-success" data-dismiss="modal" id="saveNewSupplier">{{ __('pharmacy.save_changes') }}</button>
</div>
</div>
</div>
</div
@endsection
@push('scripts')
<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>
<!-- data time piker dependency -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<!-- -->
<script>
$('#datepicker-autoclose').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy',
setDate: new Date(),
readOnly: true
});
$('#saveNewSupplier').click(function(e){
var supplier_name = $('#supplier_name').val();
var supplier_company = $('#supplier_company').val();
var supplier_contact = $('#supplier_contact').val();
var supplier_address = $('#supplier_address').val();
$.ajax({
url: '/save_new_supplier',
type: 'get',
data: {supplier_name:supplier_name, supplier_company:supplier_company, supplier_contact:supplier_contact, supplier_address:supplier_address},
success: function(response){
console.log(response);
},
error: function(response){
console.log('there was an error');
}
});
})
</script>
@endpush
@push('styles')
<style type="text/css">
th,td{
border-left: 1px solid #dddddd;
}
tr{
border-right: 1px solid #dddddd;
}
tr:last-of-type {
border-bottom: 1px solid #dddddd;
}
</style>
@endpush
@@ -0,0 +1,404 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-6 col-md-7 col-sm-7 col-xs-12">
<h4 class="page-title">{{ __('pharmacy.edit_ward_dispensing_chart') }} <font color="blue">({{ get_name($incoming_chart->chart_ward_id, "id", "name", "wards")}})</font></h4>
</div>
<div class="col-lg-6 col-sm-5 col-md-5 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li class="active">{{ __('pharmacy.edit_ward_dispensing_chart') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('flash::message')
@foreach ($errors->all() as $error)
<div>{{ $error }}</div>
@endforeach
</div>
</div>
@include('pharmacy::pharmacy.ward_dispensing_menu')
<div class="row">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-12">
<div class="panel">
{{ Form::open(['route' => 'pharmacy.update_ward_dispensing_per_chart', 'class' => 'typeahead', 'method' => 'ANY']) }}
<input type="hidden" name="incoming_chart_id" value="{{ $incoming_chart->id }}">
<input type="hidden" name="chart_ward_id" value="{{ $incoming_chart->chart_ward_id }}">
<div class="panel-body">
<div class="row">
<div class="col-sm-12">
@php
$count = 1;
@endphp
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table table-bordered">
<thead>
<tr>
<th>#</th>
<th>{{ __('pharmacy.patient_number') }}</th>
<th>{{ __('pharmacy.patient_name') }}</th>
<th>{{ __('pharmacy.ward') }}</th>
<th>{{ __('pharmacy.date_of_admission') }}</th>
<th>{{ __('pharmacy.drugs_given_so_far') }}</th>
<th>{{ __('pharmacy.drug_and_qty_given') }}</th>
<th>{{ __('pharmacy.action') }}</th>
</tr>
</thead>
<tbody>
@if(count($patient_ass_array) > 0)
@foreach($patient_ass_array as $patient_id => $drug_id_qty_arr)
@php
$inpatient_info_id = $patient_inpatient_info_array[$patient_id];
$in_patient = \Streamline\Models\InpatientInfo::find($inpatient_info_id);
if (!$in_patient) {continue;}
@endphp
<tr>
<td>
{{ $count }}
</td>
<td>
{{ get_name($patient_id, "id", "number", "patients") }}
</td>
<td>
{{ get_full_name($patient_id, "id", "first_name", "last_name", "patients") }}
</td>
<td>
{{ get_name($in_patient->ward_id, "id", "name", "wards") }}
</td>
<td>
{{ streamline_date($in_patient->created_at) }}
</td>
<td>
<?php
//get the quantity given so far of this particular treatment
$ward_quantities_given_option1 = \Streamline\Models\WardTreatmentDispensation::where(['patient_id' => $in_patient->patient_id, 'episode_id' => $in_patient->episode_id])->get();
$drug_quantity_dispensed_so_far = 0;
if(count($ward_quantities_given_option1) > 0){
foreach($ward_quantities_given_option1 as $ward_quantity_given){
$drug_quantity_dispensed_so_far += $ward_quantity_given->quantity_given;
}
}
$ward_quantities_given_option2 = DB::table('ward_treatment_dispensations')->where(['patient_id' => $in_patient->patient_id, 'episode_id' => $in_patient->episode_id])->groupBy('drug_id')->selectRaw('*, sum(quantity_given) as quantity_given')->get();
?>
@foreach($ward_quantities_given_option2 as $record)
<div class="row" style="background-color: #dde4e6; padding: 5px; word-wrap: break-word;">
<div class="col-sm-8">
{{ get_name($record->drug_id, "id", "name", "drugs") }}
</div>
<div class="col-sm-4">
<strong>{{ __('pharmacy.quantity_given') }}</strong>
</div>
<?php
$dispensation_details = \Streamline\Models\WardTreatmentDispensation::where(['patient_id' => $in_patient->patient_id, 'episode_id' => $in_patient->episode_id, 'drug_id' => $record->drug_id])->get();
?>
@foreach($dispensation_details as $dispensation)
<div class="col-sm-8">
{{ __('pharmacy.date') }}: {{ streamline_date($dispensation->created_at)}}
{{ __('pharmacy.by') }}: <font color="blue">{{ get_full_name($dispensation->created_by, "id", "first_name", "last_name", "users")}}</font>
</div>
<div class="col-sm-4">
Qty:
{{ $dispensation->quantity_given }}
</div>
@endforeach
<div class="col-sm-8" style="border-top:1px solid rgb(173 171 171);"><strong>{{ __('pharmacy.total') }}</strong></div>
<div class="col-sm-4" style="border-top:1px solid rgb(173 171 171);"><strong>{{ $record->quantity_given }}</strong></div>
</div>
@endforeach
</td>
<td>
<div class="form-group" id="drugs_given_row_{{ $count }}">
<div class="row input_fields_wrap copy1" id="wrapper_{{ $count }}">
@foreach($drug_id_qty_arr as $drug_id => $qty)
<div class="col-sm-8">
{{ Form::select('dispensed_drugs[]', $drugs, $drug_id, ['class' => 'form-control prescription-drugs']) }}
</div>
<div class="col-sm-3">
{{ Form::number('quantity_dispensed[]', $qty, ['class' => 'form-control', 'placeholder' => 'Quantity Given','style'=> 'padding-left: 5px;padding-right:5px;']) }}
</div>
<div class="col-sm-12" style="display: none;">
{{ Form::hidden('patient_id[]', $in_patient->patient_id) }}
{{ Form::hidden('episode_id[]', $in_patient->episode_id) }}
{{ Form::hidden('inpatient_info_id[]', $in_patient->id) }}
{{ Form::hidden('ward_id[]', $in_patient->ward_id) }}
</div>
@endforeach
</div>
<label class="label label-primary" id="add_drug_row_{{ $count }}">{{ __('pharmacy.add_drug_small') }}</label>
</div>
</td>
<td>
<a href="/patient_episodes/set_patient_id/{{ $in_patient->patient_id }}" class="btn btn-info btn-rounded btn-sm">{{ __('investigations.select_patient') }}</a>
<br>
<a href="/select_inpatient_sheet/{{ $in_patient->patient_id }}/{{ $in_patient->episode_id }}" class="btn btn-default btn-rounded btn-sm">{{ __('pharmacy.go_to_inpatient_sheet') }}</a>
<button class="btn btn-primary btn-sm btn-rounded viewPrescription" value="{{ $in_patient->patient_id }}_{{ $in_patient->episode_id }}">
{{ __('pharmacy.view_ward_prescription') }}
</button>
</td>
</tr>
@php $count++; @endphp
@endforeach
@endif
</tbody>
</table>
</div>
<button type="submit" class="btn btn-success btn-rounded" id="submitChart" name="submit_chart" value="submit_chart">
{{ __('pharmacy.update_chart') }}
</button>
</div>
</div>
</div>
{{ Form::close() }}
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal" id="showPatientPrescriptionModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">{{ __('pharmacy.details') }}</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<table class="success-table table-sm table-striped table-hover">
<thead>
<tr>
<th>#</th>
<th style="width: 25%">{{ __('pharmacy.drug_name') }}</th>
<th style="width: 15%">{{ __('pharmacy.dose') }}</th>
<th style="width: 15%">{{ __('pharmacy.frequency') }}</th>
<th style="width: 10%">{{ __('pharmacy.duration') }}</th>
<th style="width: 8%">{{ __('pharmacy.quantity') }}</th>
<th style="width: 25%">{{ __('pharmacy.instructions') }}</th>
</tr>
</thead>
<tbody id="show_patient_prescriptions">
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<!-- data time picker dependency -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<!-- add datatables -->
<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/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>
<!-- validator -->
<script src="{{ asset('elite/js/validator.js') }}"></script>
<script type="text/javascript">
function submitDispense(){
// begin checking to ensure there is enough quantity dispensed
let drug_id = $("input[name='drug_id[]']" ).map(function(){
return this.value;
}).get();
let quantity_dispensed = $("input[name='quantity_dispensed[]']" ).map(function(){
return this.value;
}).get();
$.ajax({
url: '/check_dispensed_drugs_quantity',
data: {'drug_id_array[]':drug_id, 'quantity_dispensed_array[]':quantity_dispensed},
success: function(response){
if (response[0] === "1") {
alert(response[1]);
return false;
} else {
//
}
}
});
}
$(document).ready(function() {
$('#datepicker-autoclose,#datepicker-autoclose-1,#datepicker-autoclose-2').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy'
});
$('#search_by').change(function () {
if ($(this).val() == 1) {
$('#date_search').show();
$('#date_range_search').hide();
}
else if ($(this).val() == 2) {
$('#date_range_search').show();
$('#date_search').hide();
}
else {
$('#date_search,#date_range_search').hide();
}
});
$('#prescription-drugs').select2({
placeholder: "Select Drug"
});
$('.select2-selection.select2-selection--single').css('height','calc(3.85rem)');
$('.select2-selection.select2-selection--single').css('padding-top','5px');
//$('.select2-selection.select2-selection--single').css('border-left', '3px solid #F08080');/*add compulsory class*/
$('.select2-selection.select2-selection--single.sec_d').css('border-left', '3px solid #aaa');
$('.select2-selection__arrow').css('top','3px');
$("input[id^='quantity_returned']").each(function () {
var id = parseInt(this.id.replace("quantity_returned", ""), 10);
$("#quantity_returned" + id + ",#quantity_dispensed" + id + ",#total" + id).change(function () {
var quantity_returned = $("#quantity_returned" + id).val();
var quantity_dispensed = $("#quantity_dispensed" + id).val();
var total_dispensed = parseFloat(quantity_returned) + parseFloat(quantity_dispensed);
$("#total" + id).val(total_dispensed);
});
});
$(".remove").on("click", function () {
$(this).parent().parent().remove();
});
var max_fields = 25;
var x1 = 0;
$("[id^='add_drug_row_']").on("click", function (e) {
//get the id by filtering to get only the digit from "id" attribute
var id = /\d+(?=\D*$)/.exec($(this).attr('id'));
console.log('The id = '+ id);
e.preventDefault();
if (x1 < max_fields) {
x1++;
console.log('cloning wrapper id = '+id);
var copy1 = $('#wrapper_'+id).clone();
copy1.attr("class", 'row input_fields_wrap');
copy1.attr("id", 'copy1' + x1);
copy1.append('<a href="#" class="remove_field" style="color: maroon"><sup>X</sup></a>');
copy1.insertAfter('#wrapper_'+id);
}
});
$("#wrapper").on("click", ".remove_field", function (e) {
e.preventDefault();
$(this).parent('div').remove();
x1--;
});
$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy',
{ extend: 'csv',
message: 'WARD DISPENSING PER CHART'
},
{ extend: 'excel',
message: 'WARD DISPENSING PER CHART',
exportOptions: {
columns: [ 0, 1, 2, 4, 5 ]
},
sheetName: 'WARD DISPENSING PER CHART ON STREAMLINE'
},
{ extend: 'pdf',
message: 'WARD DISPENSING PER CHART',
orientation: 'landscape',
pageSize: 'LETTER',
exportOptions: {
columns: [ 0, 1, 2, 4, 5 ]
},
customize: function(doc) {
doc.defaultStyle.fontSize = 10;
}
},
{ extend: 'print',
message: 'WARD DISPENSING PER CHART',
exportOptions: {
columns: [ 0, 1, 2, 4, 5 ]
},
customize: function (win) {
$(win.document.body)
.css('font-size', '10pt')
.css('background', '#fff')
.prepend(
'<img src="<?php echo asset('uploads/logo/logo-sm.png'); ?>" style="position:absolute; top:0; right:0;" />'
);
$(win.document.body).find('table')
.addClass('compact')
.css('font-size', 'inherit');
}
}
]
});
$('.viewPrescription').click(function(e){
e.preventDefault();
var patientId = "";
var episodeId = "";
var patientIdAttachedWithEpisodeIdString = $(this).val();
var patient_episode_array = patientIdAttachedWithEpisodeIdString.split("_");
patientId = patient_episode_array[0];
episodeId = patient_episode_array[1];
$("#showPatientPrescriptionModal").modal("show");
$.ajax({
type: "POST",
url: "/view_ward_patient_prescriptions",
data: {
patient_id: patientId,
episode_id: episodeId
},
cache: false,
success: function (response) {
$('#show_patient_prescriptions').html(response);
}
});
})
});
</script>
@endpush
@@ -0,0 +1,276 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
<link href="{{ asset('/elite/bower_components/datatables/jquery.dataTables.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('elite/bower_components/typeahead.js-master/dist/typehead-min.css') }}" rel="stylesheet">
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-md-6">
<h4 class="page-title">{{ __('pharmacy.unconfirmed_prescriptions') }}</h4>
</div>
<div class="col-md-6">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="{{ route('pharmacy.index') }}">{{ __('pharmacy.confirmed_prescriptions') }}</a></li>
<li class="active">{{ __('pharmacy.unconfirmed_prescriptions') }}</li>
</ol>
</div>
</div>
<div class="panel">
<div class="panel-heading" style="display: none;">{{ __('pharmacy.ward_dispensing_chart') }}</div>
<div class="panel-body">
{{ Form::open(['route' => 'pharmacy.confirm_prescriptions', 'class' => 'typeahead', 'method' => 'ANY', 'role' => 'search']) }}
{{ Form::hidden('patient_id', 0, ['id' => 'patient_id']) }}
<div class="row">
<div class="col-md-3">
<div class="form-group" id="searchby">
{{ Form::label('search_by', __('pharmacy.prescription_date')) }}
{{ Form::select('search_by', ['3'=>__('pharmacy.all_records'),'0'=>__('pharmacy.last_24_hours'),'1'=>__('pharmacy.custom_date'),'2'=>__('pharmacy.date_range')], '', ['class' => 'form-control','id'=>'search_by', 'required']) }}
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-3" style="display: none;" id="date_search">
<div class="form-group" id="reg_date" style="padding-top: 23px;">
<div class="input-group">
{{ Form::text('reg_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'datepicker-autoclose']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-3" style="display: none;" id="date_range_search">
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{ Form::label('start_date', __('pharmacy.from')) }}
<div class="input-group">
{{ Form::text('start_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-1']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group" id="reg_date">
{{ Form::label('end_date', __('pharmacy.to')) }}
<div class="input-group">
{{ Form::text('end_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-2']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3">
{{ Form::label('search_patient', __('pharmacy.search_by_patient')) }}
<div class="input-group">
<select class="form-control" name="patient_number" id="patient_number"></select>
</div>
</div>
<div class="col-md-3">
<div class="form-group" style="padding-top: 5px;"><br>
{{ Form::button(__('pharmacy.submit'),['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10', 'id'=>'select_patient']) }}
</div>
</div>
</div>
{{ Form::close() }}
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="white-box">
@include('flash::message')
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active nav-item"> <a href="#unconfirmed" class="nav-link" aria-controls="home" role="tab" data-toggle="tab" aria-expanded="true"> {{ __('pharmacy.unconfirmed_title') }}</a> </li>
<li role="presentation" class="nav-item"> <a href="#confirmed" class="nav-link" aria-controls="home" role="tab" data-toggle="tab" aria-expanded="true"> {{ __('pharmacy.confirmed_title') }}</a> </li>
</ul>
</div>
<div class="card-block">
<div class="tab-content">
<div id="unconfirmed" class="tab-pane active">
<div class="table-responsive">
<div class="table-responsive">
<table class="table table-striped color-bordered-table success-bordered-table table-bordered">
<thead>
<tr>
<th>{{ __('pharmacy.date') }}</th>
<th>{{ __('pharmacy.patient_number') }}</th>
<th>{{ __('pharmacy.patient_name') }}</th>
<th>{{ __('pharmacy.category') }}</th>
<th>{{ __('pharmacy.payment') }}</th>
<th>{{ __('pharmacy.ward') }}</th>
<th>{{ __('pharmacy.prescribed_by') }}</th>
<th>{{ __('pharmacy.actions') }}</th>
</tr>
</thead>
<tbody>
@if(count($unconfirmed_prescriptions) > 0)
@foreach($unconfirmed_prescriptions as $prescription)
<tr>
<td>{{ streamline_date_time_short($prescription->created_at) }}</td>
<td>{{ get_name($prescription->patient_id, 'id', 'number', 'patients') }}</td>
<td>{!! insurance_flag($prescription->patient_id) !!}</td>
<td>{{ isset($categories[get_name($prescription->patient_id, 'id', 'category_id', 'patients')]) ? $categories[get_name($prescription->patient_id, 'id', 'category_id', 'patients')] : "" }}</td>
<td>{!! $prescription->payment_status == 1 ? "<label class='label label-success'>Paid</label>" : "<label class='label label-danger'>Not Paid</label>" !!}</td>
<td>
@if($prescription->tta == 1)
{{ get_ward_name($prescription->patient_id, $prescription->episode_id) }}
@else
<label class="label label-info" style='font-size: x-small'>OPD</label>
@endif
</td>
<td>{{ get_full_name($prescription->created_by, 'id', 'first_name', 'last_name', 'users') }}</td>
<td>
<form action="{{ url('confirm_dispensing_details') }}" method="post">
{{ csrf_field() }}
<input value="{{ $prescription->id }}" type="hidden" name="treatment_id"/>
<input value="{{ $prescription->patient_id }}" type="hidden" name="patient_id"/>
<input value="{{ $prescription->episode_id }}" type="hidden" name="episode_id"/>
<button type="submit" class="btn btn-success btn-rounded btn-sm">Confirm</button>
</form>
</td>
</tr>
@endforeach
@else
<tr>
<td class="text-center" style="color: red" colspan="8">{{ __('pharmacy.no_records') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
</div>
<div id="confirmed" class="tab-pane">
<div class="table-responsive">
<div class="table-responsive">
<table class="table table-striped color-bordered-table success-bordered-table table-bordered">
<thead>
<tr>
<th>{{ __('pharmacy.date') }}</th>
<th>{{ __('pharmacy.patient_number') }}</th>
<th>{{ __('pharmacy.patient_name') }}</th>
<th>{{ __('pharmacy.category') }}</th>
<th>{{ __('pharmacy.payment') }}</th>
<th>{{ __('pharmacy.ward') }}</th>
<th>{{ __('pharmacy.actions') }}</th>
</tr>
</thead>
<tbody>
@if(count($confirmed_prescriptions) > 0)
@foreach($confirmed_prescriptions as $prescription)
<tr>
<td>{{ streamline_date_time_short($prescription->created_at) }}</td>
<td>{{ get_name($prescription->patient_id, 'id', 'number', 'patients') }}</td>
<td>{!! insurance_flag($prescription->patient_id) !!}</td>
<td>{{ isset($categories[get_name($prescription->patient_id, 'id', 'category_id', 'patients')]) ? $categories[get_name($prescription->patient_id, 'id', 'category_id', 'patients')] : "" }}</td>
<td>{!! $prescription->payment_status == 1 ? "<label class='label label-success'>Paid</label>" : "<label class='label label-danger'>Not Paid</label>" !!}</td>
<td>
@if($prescription->tta == 1)
{{ get_ward_name($prescription->patient_id, $prescription->episode_id) }}
@else
<label class="label label-info" style='font-size: x-small'>OPD</label>
@endif
</td>
<td>
<a class="btn btn-warning btn-rounded btn-small" href="alter_prescriptions/{{ $prescription->id }}/ {{ $prescription->patient_id }}">Alter</a>
</td>
</tr>
@endforeach
@else
<tr>
<td class="text-center" style="color: red" colspan="7">{{ __('pharmacy.no_records') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.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>
$(document).ready(function() {
$('#datepicker-autoclose,#datepicker-autoclose-1,#datepicker-autoclose-2').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy'
});
$('#search_by').change(function () {
if ($(this).val() == 1) {
$('#date_search').show();
$('#date_range_search').hide();
}
else if ($(this).val() == 2) {
$('#date_range_search').show();
$('#date_search').hide();
}
else {
$('#date_search,#date_range_search').hide();
}
});
$('#patient_number').change(function () {
let id = $('#patient_number').val();
$('#patient_id').val(id);
});
$('#patient_number').select2({
placeholder: 'Search by patient details (names and number)',
ajax: {
url: '/patients/search_patient_by_name_number',
dataType: 'json',
delay: 250,
processResults: function (data) {
return {
results: $.map(data, function (item) {
return {
text: item.first_name + " " + item.last_name + " (" + item.number + ")",
id: item.id
}
})
};
},
cache: true
}
});
});
</script>
@endpush
@@ -0,0 +1,299 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-6 col-md-7 col-sm-7 col-xs-12">
<h4 class="page-title">{{ __('pharmacy.incoming_ward_chart') }}</h4>
</div>
<div class="col-lg-6 col-sm-5 col-md-5 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li class="active">{{ __('pharmacy.incoming_ward_chart') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('flash::message')
@foreach ($errors->all() as $error)
<div>{{ $error }}</div>
@endforeach
</div>
</div>
@include('pharmacy::pharmacy.ward_dispensing_menu')
<div class="row">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-12">
<div class="panel">
<div class="panel-heading" style="display: none;">{{ __('pharmacy.ward_dispensing_chart') }}</div>
<div class="panel-body">
{{ Form::open(['route' => 'pharmacy.incoming_ward_charts', 'class' => 'typeahead', 'method' => 'ANY', 'role' => 'search']) }}
<div class="row">
<div class="col-md-3">
<div class="form-group">
{{ Form::label('ward_id', __('pharmacy.wards')) }}
{{ Form::select('ward_id', $wards, '', ['class' => 'form-control compulsory', 'required']) }}
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-3">
<div class="form-group" id="searchby">
{{ Form::label('search_by', __('pharmacy.admission_date')) }}
{{ Form::select('search_by', ['3'=>__('pharmacy.all_records'),'0'=>__('pharmacy.last_24_hours'),'1'=>__('pharmacy.custom_date'),'2'=>__('pharmacy.date_range')], '', ['class' => 'form-control','id'=>'search_by', 'required']) }}
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-3" style="display: none;" id="date_search">
<div class="form-group" id="reg_date" style="padding-top: 23px;">
<div class="input-group">
{{ Form::text('reg_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'datepicker-autoclose']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-3" style="display: none;" id="date_range_search">
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{ Form::label('start_date', __('pharmacy.from')) }}
<div class="input-group">
{{ Form::text('start_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-1']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group" id="reg_date">
{{ Form::label('end_date', __('pharmacy.to')) }}
<div class="input-group">
{{ Form::text('end_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-2']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group" style="padding-top: 5px;"><br>
{{ Form::button(__('pharmacy.submit'),['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10', 'id'=>'select_patient']) }}
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-md-6">
{{ __('pharmacy.showing_results_from') }} :
<br><h3 style="color: #0060BF; font-weight: bolder;"> {{ is_null($ward_id) ? __('pharmacy.show_patients_all_wards') : ($ward_id == 0 ? 'All wards' : get_name($ward_id, 'id', 'name', 'wards')) }} {!! is_null($search_by) ? '<b>in the last 24 hours</b>' : '' !!} </h3>
</div>
</div>
{{ Form::close() }}
</div>
</div>
<div class="panel">
<div class="panel-body">
<div class="row">
<div class="col-sm-12">
@php
$count = 1;
@endphp
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table table-bordered">
<thead>
<tr>
<th>#</th>
<th>{{ __('pharmacy.time_of_chart_submission') }}</th>
<th>{{ __('pharmacy.staff_in_charge') }}</th>
<th>{{ __('pharmacy.source_ward') }}</th>
<th>{{ __('pharmacy.status') }}</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
@if(count($incoming_charts) > 0)
@foreach($incoming_charts as $ward_chart)
<tr>
<td>
{{ $count }}
</td>
<td>
{{ streamline_date_time($ward_chart->created_at) }}
</td>
<td>
{{ get_full_name($ward_chart->created_by, "id", "first_name", "last_name", "users") }}
</td>
<td>
{{ get_name($ward_chart->chart_ward_id, "id", "name", "wards") == "N/A" ? "All wards" : get_name($ward_chart->chart_ward_id, "id", "name", "wards") }}
</td>
<td>
{!! $ward_chart->completion_status == 1 ? "<span class='label label-success'>Approved<span>" : "<span class='label label-warning'>Pending</span>" !!}
</td>
<td>
@if(Auth::user()->can('approve-ward-dispensings-per-chart'))
<a class="btn btn-success" href="approve_ward_dispensing_per_chart/{{ $ward_chart->id }}">
{{ __('pharmacy.approve') }}
</a>
@endif
</td>
<td>
@if(Auth::user()->can('cancel-ward-chart-dispensing'))
<a class="btn btn-danger" href="cancel_ward_dispensing_per_chart/{{ $ward_chart->id }}">
{{ __('pharmacy.cancel') }}
</a>
@endif
</td>
</tr>
@php $count++; @endphp
@endforeach
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<!-- data time picker dependency -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<!-- add datatables -->
<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/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>
<!-- validator -->
<script src="{{ asset('elite/js/validator.js') }}"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#datepicker-autoclose,#datepicker-autoclose-1,#datepicker-autoclose-2').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy'
});
$('#search_by').change(function () {
if ($(this).val() == 1) {
$('#date_search').show();
$('#date_range_search').hide();
}
else if ($(this).val() == 2) {
$('#date_range_search').show();
$('#date_search').hide();
}
else {
$('#date_search,#date_range_search').hide();
}
});
$('.prescription-drugs').select2({
placeholder: "Select Drug"
});
$('.select2-selection.select2-selection--single').css('height','calc(3.85rem)');
$('.select2-selection.select2-selection--single').css('padding-top','5px');
//$('.select2-selection.select2-selection--single').css('border-left', '3px solid #F08080');/*add compulsory class*/
$('.select2-selection.select2-selection--single.sec_d').css('border-left', '3px solid #aaa');
$('.select2-selection__arrow').css('top','3px');
$(".remove").on("click", function () {
$(this).parent().parent().remove();
});
var max_fields = 25;
var x1 = 0;
$("[id^='add_drug_row_']").on("click", function (e) {
//get the id by filtering to get only the digit from "id" attribute
var id = /\d+(?=\D*$)/.exec($(this).attr('id'));
console.log('The id = '+ id);
e.preventDefault();
if (x1 < max_fields) {
x1++;
console.log('cloning wrapper id = '+id);
var copy1 = $('#wrapper_'+id).clone();
copy1.attr("class", 'row input_fields_wrap');
copy1.attr("id", 'copy1' + x1);
copy1.append('<a href="#" class="remove_field" style="color: maroon"><sup>X</sup></a>');
copy1.insertAfter('#wrapper_'+id);
}
});
$("#wrapper").on("click", ".remove_field", function (e) {
e.preventDefault();
$(this).parent('div').remove();
x1--;
});
$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy',
{ extend: 'csv',
message: 'WARD DISPENSING PER CHART'
},
{ extend: 'excel',
message: 'WARD DISPENSING PER CHART',
exportOptions: {
columns: [ 0, 1, 2, 4, 5 ]
},
sheetName: 'WARD DISPENSING PER CHART ON STREAMLINE'
},
{ extend: 'pdf',
message: 'WARD DISPENSING PER CHART',
orientation: 'landscape',
pageSize: 'LETTER',
exportOptions: {
columns: [ 0, 1, 2, 4, 5 ]
},
customize: function(doc) {
doc.defaultStyle.fontSize = 10;
}
},
{ extend: 'print',
message: 'WARD DISPENSING PER CHART',
exportOptions: {
columns: [ 0, 1, 2, 4, 5 ]
},
customize: function (win) {
$(win.document.body)
.css('font-size', '10pt')
.css('background', '#fff')
.prepend(
'<img src="<?php echo asset('uploads/logo/logo-sm.png'); ?>" style="position:absolute; top:0; right:0;" />'
);
$(win.document.body).find('table')
.addClass('compact')
.css('font-size', 'inherit');
}
}
]
});
});
</script>
@endpush
@@ -0,0 +1,696 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
<link href="{{ asset('elite/bower_components/typeahead.js-master/dist/typehead-min.css') }}" rel="stylesheet">
@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">{{ __('pharmacy.incoming_prescriptions') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="{{ route('pharmacy.index') }}">{{ __('pharmacy.pharmacist') }}</a></li>
<li class="active">{{ __('pharmacy.incoming_prescriptions') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default" style="border-radius: 5px;">
<div class="panel-body">
{{ Form::open(['method'=>'post','route' => 'pharmacy.search', 'class' => 'typeahead']) }}
{{ Form::hidden('patient_id', 0, ['id' => 'patient_id']) }}
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>{{ __('pharmacy.select_date') }}:</label>
<select class="form-control compulsory required" name="dates" id="dates" required>
<option value="today">{{ __('pharmacy.today') }}</option>
<option value="yesterday">{{ __('pharmacy.yesterday') }}</option>
<option value="custom_date">{{ __('pharmacy.custom_date') }}</option>
<option value="custom_date_range">{{ __('pharmacy.date_range') }}</option>
</select>
</div>
</div>
<div class="col-md-2" id="sDate" style="display: none;">
<div class="form-group">
{{ Form::label('start_date', __('pharmacy.date_on')) }}
<div class="input-group">
{{ Form::text('start_date', '', ['class'=>'form-control required compulsory', 'readonly', 'id'=>'start_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-2" id="eDate" style="display: none;">
<div class="form-group">
{{ Form::label('end_date', __('pharmacy.end_date')) }}
<div class="input-group">
{{ Form::text('end_date', '', ['class'=>'form-control required compulsory', 'readonly', 'id'=>'end_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-3">
{{ Form::label('search_patient', __('pharmacy.search_by_patient')) }}
<div class="input-group">
<select class="form-control" name="patient_number" id="patient_number"></select>
</div>
</div>
<div class="col-md-2">
<div class="form-group" style="margin-top: 25px;">
{{ Form::submit(__('pharmacy.submit'), ['class'=>'btn btn-success pull-right']) }}
</div>
</div>
</div>
{{ Form::close() }}
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
@include('flash::message')
@if(isset($display))
<div class="row">
<div class="col-md-12">
<div class="panel" style="border-radius: 5px;">
<div class="panel-body">
<h3 class="label label-info col-lg-5"> {!! isset($display) ? $display : '' !!}</h3>
</div>
</div>
</div>
</div>
@endif
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active nav-item"> <a href="#pending_paid" class="nav-link" aria-controls="home" role="tab" data-toggle="tab" aria-expanded="true"> {{ __('pharmacy.paid_but_pending') }}</a> </li>
<li role="presentation" class="nav-item"> <a href="#pending_unpaid" class="nav-link" aria-controls="home" role="tab" data-toggle="tab" aria-expanded="true"> {{ __('pharmacy.unpaid_and_pending') }}</a> </li>
<li role="presentation" class="nav-item"> <a href="#paid_dispensed" class="nav-link" aria-controls="home" role="tab" data-toggle="tab" aria-expanded="true"> {{ __('pharmacy.paid_and_dispensed') }}</a> </li>
<li role="presentation" class="nav-item"> <a href="#unpaid_dispensed" class="nav-link" aria-controls="home" role="tab" data-toggle="tab" aria-expanded="true"> {{ __('pharmacy.unpaid_but_dispensed') }}</a> </li>
</ul>
</div>
<div class="card-block">
<div class="tab-content">
<div id="pending_paid" class="tab-pane active">
<div class="table-responsive">
<table class="table table-striped color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('pharmacy.date') }}</th>
<th>{{ __('pharmacy.patient_number') }}</th>
<th>{{ __('pharmacy.patient_name') }}</th>
<th>{{ __('pharmacy.patient_category') }}</th>
<th>{{ __('pharmacy.payment') }}</th>
<th>{{ __('pharmacy.amount') }}</th>
<th>{{ __('pharmacy.ward') }}</th>
<th>{{ __('pharmacy.prescribed_by') }}</th>
<th>{{ __('pharmacy.actions') }}</th>
</tr>
</thead>
<tbody>
@if(count($pending_paid_prescriptions) > 0)
@foreach($pending_paid_prescriptions as $prescription)
@php
$treatment_amount = 0;
$treatment_amount_total = 0;
$insurance_amount = 0;
$insurance_amount_total = 0;
$grand_total_for_treatment = 0;
// ids of the ordered drugs
$drug_ids = explode(",", $prescription->drugs);
// quantities of the ordered drugs
$drug_quantities = explode(",", $prescription->quantities_dispensed);
for ($i = 0; $i < count($drug_ids); $i++){
if(get_name($drug_ids[$i], "id", "name", "drugs") != "N/A"){
// get insurance status for drug
$drug_insurance_status = get_name($drug_ids[$i], "id", "insurance_coverage", "drugs");
// insurance flag
$is_insured = 0;
$insurance_amount = 0;
// get insurance status for drug
$drug_insurance_status = get_name($drug_ids[$i], "id", "insurance_coverage", "drugs");
// check if the patient category is attached to a price list
$price_list_id = is_patient_category_attached_to_price_list($prescription->patient_id);
if ($price_list_id) {
$treatment_amount = get_price_list_category_price($price_list_id, 3, $drug_ids[$i]);
} else {
// check if drug and patient is eligible for insurance
if($drug_insurance_status == 1 && patient_insurance_status($prescription->patient_id) == 1){
$treatment_amount = get_name($drug_ids[$i], "id", "insured_price", "drugs");
$insurance_amount = get_name($drug_ids[$i], "id", "non_insured_price", "drugs") - $treatment_amount;
$is_insured = 1;
} else {
$treatment_amount = get_name($drug_ids[$i], "id", "non_insured_price", "drugs");
}
}
if(isset($drug_quantities[$i]) && $drug_quantities[$i] != ""){
$treatment_subtotal = $drug_quantities[$i] * $treatment_amount;
$insurance_amount *= $drug_quantities[$i];
} else {
$treatment_subtotal = 0;
}
// add amounts to totals
$treatment_amount_total += $treatment_amount;
$insurance_amount_total += $insurance_amount;
$grand_total_for_treatment += $treatment_subtotal;
}
}
@endphp
<tr>
<td>{{ streamline_date_time_short($prescription->created_at) }}</td>
<td>{{ get_name($prescription->patient_id, 'id', 'number', 'patients') }}</td>
<td>{!! insurance_flag($prescription->patient_id) !!}</td>
<td>{{ isset($categories[get_name($prescription->patient_id, 'id', 'category_id', 'patients')]) ? $categories[get_name($prescription->patient_id, 'id', 'category_id', 'patients')] : "" }}</td>
<td>{!! $prescription->payment_status == 1 ? "<label class='label label-success'>Paid</label>" : "<label class='label label-danger'>Not Paid</label>" !!}</td>
<td>
{{ ugandan_shillings($grand_total_for_treatment) }}
</td>
<td>
@if($prescription->tta == 1)
{{ get_ward_name($prescription->patient_id, $prescription->episode_id) }}
@else
<label class="label label-info" style='font-size: x-small'>OPD</label>
@endif
</td>
<td>{{ get_full_name($prescription->created_by, 'id', 'first_name', 'last_name', 'users') }}</td>
@php
$episode = \Streamline\Models\PatientEpisode::where('id', $prescription->episode_id)->pluck('paid_over')->first();
@endphp
<td>
@if($prescription->payment_status == 1)
<div class="row">
<div class="col-8">
<form action="{{ url('view_dispensing_details') }}" method="post">
{{ csrf_field() }}
<input value="{{ $prescription->id }}" type="hidden" name="treatment_id"/>
<input value="{{ $prescription->patient_id }}" type="hidden" name="patient_id"/>
<input value="{{ $prescription->episode_id }}" type="hidden" name="episode_id"/>
<button type="submit" class="btn btn-success btn-rounded btn-sm">{{ __('pharmacy.dispense') }}</button>
</form>
</div>
<div class="col-4"></div>
</div>
@else
<button class="btn btn-success btn-rounded btn-sm" disabled>{{ __('pharmacy.dispense') }}</button>
@endif
</td>
</tr>
@endforeach
@else
<tr>
<td class="text-center" style="color: red" colspan="7">{{ __('pharmacy.no_incoming_prescriptions') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
<div id="pending_unpaid" class="tab-pane">
<div class="table-responsive">
<table class="table table-striped color-bordered-table success-bordered-table table-bordered">
<thead>
<tr>
<th>{{ __('pharmacy.date') }}</th>
<th>{{ __('pharmacy.patient_number') }}</th>
<th>{{ __('pharmacy.patient_name') }}</th>
<th>{{ __('pharmacy.patient_category') }}</th>
<th>{{ __('pharmacy.payment') }}</th>
<th>{{ __('pharmacy.amount') }}</th>
<th>{{ __('pharmacy.ward') }}</th>
<th>{{ __('pharmacy.prescribed_by') }}</th>
<th>{{ __('pharmacy.actions') }}</th>
</tr>
</thead>
<tbody>
@if(count($pending_unpaid_prescriptions) > 0)
@foreach($pending_unpaid_prescriptions as $prescription)
@php
$treatment_amount = 0;
$treatment_amount_total = 0;
$insurance_amount = 0;
$insurance_amount_total = 0;
$grand_total_for_treatment = 0;
// ids of the ordered drugs
$drug_ids = explode(",", $prescription->drugs);
// quantities of the ordered drugs
$drug_quantities = explode(",", $prescription->quantities_dispensed);
for ($i = 0; $i < count($drug_ids); $i++){
if(get_name($drug_ids[$i], "id", "name", "drugs") != "N/A"){
// get insurance status for drug
$drug_insurance_status = get_name($drug_ids[$i], "id", "insurance_coverage", "drugs");
// insurance flag
$is_insured = 0;
$insurance_amount = 0;
// get insurance status for drug
$drug_insurance_status = get_name($drug_ids[$i], "id", "insurance_coverage", "drugs");
// check if the patient category is attached to a price list
$price_list_id = is_patient_category_attached_to_price_list($prescription->patient_id);
if ($price_list_id) {
$treatment_amount = get_price_list_category_price($price_list_id, 3, $drug_ids[$i]);
} else {
// check if drug and patient is eligible for insurance
if($drug_insurance_status == 1 && patient_insurance_status($prescription->patient_id) == 1){
$treatment_amount = get_name($drug_ids[$i], "id", "insured_price", "drugs");
$insurance_amount = get_name($drug_ids[$i], "id", "non_insured_price", "drugs") - $treatment_amount;
$is_insured = 1;
} else {
$treatment_amount = get_name($drug_ids[$i], "id", "non_insured_price", "drugs");
}
}
if(isset($drug_quantities[$i]) && $drug_quantities[$i] != ""){
$treatment_subtotal = $drug_quantities[$i] * $treatment_amount;
$insurance_amount *= $drug_quantities[$i];
} else {
$treatment_subtotal = 0;
}
// add amounts to totals
$treatment_amount_total += $treatment_amount;
$insurance_amount_total += $insurance_amount;
$grand_total_for_treatment += $treatment_subtotal;
}
}
@endphp
<tr>
<td>{{ streamline_date_time_short($prescription->created_at) }}</td>
<td>{{ get_name($prescription->patient_id, 'id', 'number', 'patients') }}</td>
<td>{!! insurance_flag($prescription->patient_id) !!}</td>
<td>{{ isset($categories[get_name($prescription->patient_id, 'id', 'category_id', 'patients')]) ? $categories[get_name($prescription->patient_id, 'id', 'category_id', 'patients')] : "" }}</td>
<td>{!! ($prescription->inpatient_bill_generated == 1) ? "<label class='label label-success'>Added to Inpatient Bill</label>" : "<label class='label label-danger'>Not Paid</label>" !!}</td>
<td>
{{ ugandan_shillings($grand_total_for_treatment) }}
</td>
<td>
@if($prescription->tta == 1)
{{ get_ward_name($prescription->patient_id, $prescription->episode_id) }}
@else
<label class="label label-info" style='font-size: x-small'>OPD</label>
@endif
</td>
<td>{{ get_full_name($prescription->created_by, 'id', 'first_name', 'last_name', 'users') }}</td>
<td>
@if(is_dispense_unpaid_prescription_enabled($prescription->patient_id))
<form action="{{ url('view_dispensing_details') }}" method="post">
{{ csrf_field() }}
<input value="{{ $prescription->id }}" type="hidden" name="treatment_id"/>
<input value="{{ $prescription->patient_id }}" type="hidden" name="patient_id"/>
<input value="{{ $prescription->episode_id }}" type="hidden" name="episode_id"/>
<button type="submit" class="btn btn-success btn-rounded btn-sm">{{ __('pharmacy.dispense') }}</button>
</form>
@else
@if($prescription->payment_status == 1 || $prescription->inpatient_bill_generated == 1)
<form action="{{ url('view_dispensing_details') }}" method="post">
{{ csrf_field() }}
<input value="{{ $prescription->id }}" type="hidden" name="treatment_id"/>
<input value="{{ $prescription->patient_id }}" type="hidden" name="patient_id"/>
<input value="{{ $prescription->episode_id }}" type="hidden" name="episode_id"/>
<button type="submit" class="btn btn-success btn-rounded btn-sm">{{ __('pharmacy.dispense') }}</button>
</form>
@else
<button class="btn btn-success btn-rounded btn-sm" disabled>{{ __('pharmacy.dispense') }}</button>
@endif
@endif
</td>
</tr>
@endforeach
@else
<tr>
<td class="text-center" style="color: red" colspan="8">{{ __('pharmacy.no_incoming_prescriptions') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
<div id="paid_dispensed" class="tab-pane">
<div class="table-responsive">
<table class="table table-striped color-bordered-table success-bordered-table table-bordered">
<thead>
<tr>
<th>{{ __('pharmacy.date') }}</th>
<th>{{ __('pharmacy.patient_number') }}</th>
<th>{{ __('pharmacy.patient_name') }}</th>
<th>{{ __('pharmacy.patient_category') }}</th>
<th>{{ __('pharmacy.payment') }}</th>
<th>{{ __('pharmacy.amount') }}</th>
<th>{{ __('pharmacy.ward') }}</th>
<th>{{ __('pharmacy.prescribed_by') }}</th>
<th>{{ __('pharmacy.actions') }}</th>
</tr>
</thead>
<tbody>
@if(count($confirmed_paid_prescriptions) > 0)
@foreach($confirmed_paid_prescriptions as $prescription)
@php
$treatment_amount = 0;
$treatment_amount_total = 0;
$insurance_amount = 0;
$insurance_amount_total = 0;
$grand_total_for_treatment = 0;
// ids of the ordered drugs
$drug_ids = explode(",", $prescription->drugs);
// quantities of the ordered drugs
$drug_quantities = explode(",", $prescription->quantities_dispensed);
for ($i = 0; $i < count($drug_ids); $i++){
if(get_name($drug_ids[$i], "id", "name", "drugs") != "N/A"){
// get insurance status for drug
$drug_insurance_status = get_name($drug_ids[$i], "id", "insurance_coverage", "drugs");
// insurance flag
$is_insured = 0;
$insurance_amount = 0;
// get insurance status for drug
$drug_insurance_status = get_name($drug_ids[$i], "id", "insurance_coverage", "drugs");
// check if the patient category is attached to a price list
$price_list_id = is_patient_category_attached_to_price_list($prescription->patient_id);
if ($price_list_id) {
$treatment_amount = get_price_list_category_price($price_list_id, 3, $drug_ids[$i]);
} else {
// check if drug and patient is eligible for insurance
if($drug_insurance_status == 1 && patient_insurance_status($prescription->patient_id) == 1){
$treatment_amount = get_name($drug_ids[$i], "id", "insured_price", "drugs");
$insurance_amount = get_name($drug_ids[$i], "id", "non_insured_price", "drugs") - $treatment_amount;
$is_insured = 1;
} else {
$treatment_amount = get_name($drug_ids[$i], "id", "non_insured_price", "drugs");
}
}
if(isset($drug_quantities[$i]) && $drug_quantities[$i] != ""){
$treatment_subtotal = $drug_quantities[$i] * $treatment_amount;
$insurance_amount *= $drug_quantities[$i];
} else {
$treatment_subtotal = 0;
}
// add amounts to totals
$treatment_amount_total += $treatment_amount;
$insurance_amount_total += $insurance_amount;
$grand_total_for_treatment += $treatment_subtotal;
}
}
@endphp
<tr>
<td>{{ streamline_date_time_short($prescription->created_at) }}</td>
<td>{{ get_name($prescription->patient_id, 'id', 'number', 'patients') }}</td>
<td>{!! insurance_flag($prescription->patient_id) !!}</td>
<td>{{ isset($categories[get_name($prescription->patient_id, 'id', 'category_id', 'patients')]) ? $categories[get_name($prescription->patient_id, 'id', 'category_id', 'patients')] : "" }}</td>
<td>{!! $prescription->payment_status == 1 ? "<label class='label label-success'>Paid</label>" : "<label class='label label-danger'>Not Paid</label>" !!}</td>
<td>
{{ ugandan_shillings($grand_total_for_treatment) }}
</td>
<td>
@if($prescription->tta == 1)
{{ get_ward_name($prescription->patient_id, $prescription->episode_id) }}
@else
<label class="label label-info" style='font-size: x-small'>OPD</label>
@endif
</td>
<td>{{ get_full_name($prescription->created_by, 'id', 'first_name', 'last_name', 'users') }}</td>
<td>
<form action="{{ url('dispensed_details_review') }}" method="post">
{{ csrf_field() }}
<input value="{{ $prescription->id }}" type="hidden" name="treatment_id">
<input value="{{ $prescription->patient_id }}" type="hidden" name="patient_id">
<input value="{{ $prescription->episode_id }}" type="hidden" name="episode_id">
<button type="submit" class="btn btn-info btn-rounded btn-sm">{{ __('pharmacy.view') }}</button>
</form>
</td>
</tr>
@endforeach
@else
<tr>
<td class="text-center" style="color: red" colspan="8">{{ __('pharmacy.no_incoming_prescriptions') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
<div id="unpaid_dispensed" class="tab-pane">
<div class="table-responsive">
<table class="table table-striped color-bordered-table success-bordered-table table-bordered">
<thead>
<tr>
<th>{{ __('pharmacy.date') }}</th>
<th>{{ __('pharmacy.patient_number') }}</th>
<th>{{ __('pharmacy.patient_name') }}</th>
<th>{{ __('pharmacy.patient_category') }}</th>
<th>{{ __('pharmacy.payment') }}</th>
<th>{{ __('pharmacy.amount') }}</th>
<th>{{ __('pharmacy.ward') }}</th>
<th>{{ __('pharmacy.prescribed_by') }}</th>
<th>{{ __('pharmacy.actions') }}</th>
</tr>
</thead>
<tbody>
@if(count($confirmed_unpaid_prescriptions) > 0)
@foreach($confirmed_unpaid_prescriptions as $prescription)
@php
$treatment_amount = 0;
$treatment_amount_total = 0;
$insurance_amount = 0;
$insurance_amount_total = 0;
$grand_total_for_treatment = 0;
// ids of the ordered drugs
$drug_ids = explode(",", $prescription->drugs);
// quantities of the ordered drugs
$drug_quantities = explode(",", $prescription->quantities_dispensed);
for ($i = 0; $i < count($drug_ids); $i++){
if(get_name($drug_ids[$i], "id", "name", "drugs") != "N/A"){
// get insurance status for drug
$drug_insurance_status = get_name($drug_ids[$i], "id", "insurance_coverage", "drugs");
// insurance flag
$is_insured = 0;
$insurance_amount = 0;
// get insurance status for drug
$drug_insurance_status = get_name($drug_ids[$i], "id", "insurance_coverage", "drugs");
// check if the patient category is attached to a price list
$price_list_id = is_patient_category_attached_to_price_list($prescription->patient_id);
if ($price_list_id) {
$treatment_amount = get_price_list_category_price($price_list_id, 3, $drug_ids[$i]);
} else {
// check if drug and patient is eligible for insurance
if($drug_insurance_status == 1 && patient_insurance_status($prescription->patient_id) == 1){
$treatment_amount = get_name($drug_ids[$i], "id", "insured_price", "drugs");
$insurance_amount = get_name($drug_ids[$i], "id", "non_insured_price", "drugs") - $treatment_amount;
$is_insured = 1;
} else {
$treatment_amount = get_name($drug_ids[$i], "id", "non_insured_price", "drugs");
}
}
if(isset($drug_quantities[$i]) && $drug_quantities[$i] != ""){
$treatment_subtotal = $drug_quantities[$i] * $treatment_amount;
$insurance_amount *= $drug_quantities[$i];
} else {
$treatment_subtotal = 0;
}
// add amounts to totals
$treatment_amount_total += $treatment_amount;
$insurance_amount_total += $insurance_amount;
$grand_total_for_treatment += $treatment_subtotal;
}
}
@endphp
<tr>
<td>{{ streamline_date_time_short($prescription->created_at) }}</td>
<td>{{ get_name($prescription->patient_id, 'id', 'number', 'patients') }}</td>
<td>{!! insurance_flag($prescription->patient_id) !!}</td>
<td>{{ isset($categories[get_name($prescription->patient_id, 'id', 'category_id', 'patients')]) ? $categories[get_name($prescription->patient_id, 'id', 'category_id', 'patients')] : "" }}</td>
<td>{!! $prescription->payment_status == 1 ? "<label class='label label-success'>Paid</label>" : "<label class='label label-danger'>Not Paid</label>" !!}</td>
<td>
{{ ugandan_shillings($grand_total_for_treatment) }}
</td>
<td>
@if($prescription->tta == 1)
{{ get_ward_name($prescription->patient_id, $prescription->episode_id) }}
@else
<label class="label label-info" style='font-size: x-small'>OPD</label>
@endif
</td>
<td>{{ get_full_name($prescription->created_by, 'id', 'first_name', 'last_name', 'users') }}</td>
<td>
<form action="{{ url('dispensed_details_review') }}" method="post">
{{ csrf_field() }}
<input value="{{ $prescription->id }}" type="hidden" name="treatment_id">
<input value="{{ $prescription->patient_id }}" type="hidden" name="patient_id">
<input value="{{ $prescription->episode_id }}" type="hidden" name="episode_id">
<button type="submit" class="btn btn-info btn-rounded btn-sm">{{ __('pharmacy.view') }}</button>
</form>
</td>
</tr>
@endforeach
@else
<tr>
<td class="text-center" style="color: red" colspan="8">{{ __('pharmacy.no_incoming_prescriptions') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.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>
$('#patient_number').change(function () {
let id = $('#patient_number').val();
$('#patient_id').val(id);
});
$('#patient_number').select2({
placeholder: 'Search by patient details (names and number)',
ajax: {
url: '/patients/search_patient_by_name_number',
dataType: 'json',
delay: 250,
processResults: function (data) {
return {
results: $.map(data, function (item) {
return {
text: item.first_name + " " + item.last_name + " (" + item.number + ")",
id: item.id
}
})
};
},
cache: true
}
});
$('#dates').change(function (e) {
if($(this).val() === "custom_date"){
$("#eDate").hide();
$("#sDate").show();
}else if($(this).val() === "custom_date_range"){
$("#sDate").show();
$("#eDate").show();
}else{
$("#eDate").hide();
$("#sDate").hide();
}
});
$('#end_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
$('#start_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
$('.table').DataTable({
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
],
"aoColumnDefs": [{
"aTargets": [2,3],
"defaultContent": "",
}],
"pageLength": 25
});
$('#staff_member').select2({
placeholder: "-- select --"
});
$('#staff_member_accountant').select2({
placeholder: "-- select --"
});
</script>
@endpush
@push('styles')
<style type="text/css">
.nav-tabs .nav-item.show .nav-link, .nav-tabs .nav-link.active {
background-color: #a8b5b1;
border-color: #ddd #ddd #fff;
}
.nav-tabs .nav-item.show .nav-link, .nav-tabs .nav-link:hover {
background-color: #a8b5b1;
}
.nav-tabs > li.active > a, .nav-tabs > li.active > a:hover, .nav-tabs > li.active > a:focus {
color: #555;
background-color: #a8b5b1;
}
</style>
@endpush
@@ -0,0 +1,188 @@
<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" type="image/png" sizes="16x16" href="{{ base_path('public/uploads/streamline/color/streamline_icon-02.png') }}">
<title>{{ config('app.name', 'ITEM REQUISITION PRINTOUT - Stre@mline') }}</title>
<!-- Bootstrap Core CSS -->
<link href="{{ base_path('public/bootstrap/css/bootstrap.min.css') }}" rel="stylesheet">
<style style="text-css">
body{
font-size: 0.8em;
}
/*thead, tfoot { display: table-row-group }*/
thead {
display: table-header-group;
}
tfoot {
display: table-row-group;
}
tr {
page-break-before: always;
page-break-after: always;
page-break-inside: avoid;
}
</style>
</head>
<body>
<div class="container-fluid">
@include('layouts.header_pdf_print')
<h5 class="heading" style="text-align: center;"><strong>{{get_quotation_type_name($requisition_model->quotation_type_id)}} {{ __('pharmacy.request_from_requisition') }}{{ get_requisition_origin($requisition_model->requisition_origin) }} <?php echo "#" . sprintf('%04u', $requisition_id) ?></strong></h5>
<div class="row">
<div class="col">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-12">
<div class="row">
<div>
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th style="width:11%;">{{ __('pharmacy.number') }}</th>
<th style="width:50%;">{{ __('pharmacy.item_name') }}</th>
<th style="width:10%;">{{ __('pharmacy.quantity') }}</th>
@if($requisition_model->quotation_type_id ==1 || $requisition_model->quotation_type_id ==5) <th style="width:20%;">{{ __('pharmacy.units') }}</th>@endif
<th style="width:11%;">{{ __('pharmacy.cost_value') }}</th>
</tr>
</thead>
<tbody>
@php
$counter = 1;
$grand_total = 0;
$requisition_type_id = $requisition_model->quotation_type_id;
$item_array = explode(",", $requisition_model->drug_id);
$quantity_array = explode(",", $requisition_model->quantity_requested);
@endphp
@for($i = 0; $i < count($quantity_array) ; $i++)
@if(isset($quantity_array[$i]) && $quantity_array[$i] != "" && isset($item_array[$i]))
<tr>
<td>{{ $counter }}. </td>
<!-- 1-drug 2-sundry 3-dental 4-radiology 5-Lab -->
@if($requisition_type_id == 1)
<td>{{ get_name($item_array[$i], 'id', 'name', 'drugs') }}</td>
@php
$drug_form = get_name($item_array[$i], 'id', 'form_id', 'drugs');
$cost_price = get_name($item_array[$i], 'id', 'cost_price', 'drugs');
$drug_form_name = get_name($drug_form,'id','name','drug_forms');
if ($drug_form_name == 'N/A') $drug_form_name =null;
@endphp
@elseif($requisition_type_id == 2)
<td>{{ get_name($item_array[$i], 'id', 'name','sundries') }}</td>
@php
$drug_form = get_name($item_array[$i], 'id', 'package_unit_id', 'sundries');
$cost_price = get_name($item_array[$i], 'id', 'cost_price', 'sundries');
@endphp
@elseif($requisition_type_id == 3)
<td>{{ get_name($item_array[$i], 'id', 'name','dentals') }}</td>
@php
$cost_price = get_name($item_array[$i], 'id', 'cost_price', 'dentals');
$drug_form = null;
@endphp
@elseif($requisition_type_id == 4)
<td>{{ get_name($item_array[$i], 'id', 'name','radiologies') }}</td>
@php
$cost_price = get_name($item_array[$i], 'id', 'cost_price', 'radiologies');
$drug_form = get_name($item_array[$i], 'id', 'unit_id', 'radiologies');
@endphp
@elseif($requisition_type_id == 5)
<td>{{ get_name($item_array[$i], 'id', 'name','labs') }}</td>
@php
$cost_price = get_name($item_array[$i], 'id', 'cost_price', 'labs');
$drug_form = get_name($item_array[$i], 'id', 'form_id', 'labs');
$drug_form_name=get_name($drug_form, 'id','name','lab_forms');
if ($drug_form_name == 'N/A') $drug_form_name =null;
@endphp
@elseif($requisition_type_id == 6)
<td>{{ get_name($item_array[$i], 'id', 'name','general_items') }}</td>
@php
$cost_price = get_name($item_array[$i], 'id', 'cost_price', 'general_items');
$drug_form = null;
@endphp
@elseif($requisition_type_id == 7)
<td>{{ get_name($item_array[$i], 'id', 'name','eye_glasses') }}</td>
@php
$cost_price = get_name($item_array[$i], 'id', 'cost_price', 'eye_glasses');
$drug_form = null;
@endphp
@endif
<td>{{ $quantity_array[$i] }}</td>
@if($requisition_type_id ==1 || $requisition_type_id ==5 )
<td>{{ $drug_form_name }}</td>
@endif
<td>
@php
if (track_items_using_batches()){
$item_sub_total =get_unit_cost_from_store_batch($item_array[$i],$requisition_type_id,$quantity_array[$i],'store_stock');
}else{
$quantity = (isset($quantity_array[$i]) && is_numeric($quantity_array[$i])) ? $quantity_array[$i] : 0;
$item_cost = is_numeric($cost_price) ? $cost_price : 0;
$item_sub_total = $quantity * $item_cost;
}
$grand_total += $item_sub_total;
@endphp
{{ ugandan_shillings($item_sub_total) }}
</td>
</tr>
@php $counter++; @endphp
@endif
@endfor
</tbody>
<tfoot>
<tr>
<td colspan="2"></td>
@if($requisition_type_id ==1 || $requisition_model->quotation_type_id ==5) <td ></td>@endif
<td>Total</td>
<td>{{ ugandan_shillings($grand_total) }}</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-3">
<strong>{{ __('pharmacy.requisitioned_by') }}:</strong><br><br>
<strong>{{ get_full_name($requisition_model->created_by, "id", "first_name", "last_name", "users") }}</strong><br><br>
<small>{{ streamline_date_time_short($requisition_model->created_at) }}</small><br><br>
.......................................
</div>
<div class="col-3">
</div>
<div class="col-3">
</div>
<div class="col-3">
<strong>{{ __('pharmacy.received_by') }}:</strong><br><br>
.......................................
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
@@ -0,0 +1,740 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
<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/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
@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">{{ __('pharmacy.pharmacy_optical_stock_reconciliation') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('home.dashboard') }}</a></li>
<li><a href="{{ route('stores.index') }}">{{ __('stores.stores') }}</a></li>
<li class="active">{{ __('pharmacy.pharmacy_optical_stock_reconciliation') }}</li>
</ol>
</div>
</div>
<!--Flash messages at the top -->
@include('flash::message')
<div class="white-box">
{{ Form::open(['route' => 'pharmacy.optical_stock_reconciliation', 'method' => 'ANY', 'role' => 'search']) }}
<div class="row">
<div class="col-md-6">
<div class="form-group" id="drug_names">
{{ Form::select('search_items_ids[]',$optic_dropdown,'',['id'=>'drug_ids', 'multiple'=>true, 'class' => 'form-control col-sm-8 drug_ids']) }}
</div>
</div>
<div class="col-md-6">
<button type="submit" class="btn btn-info"><span class="glyphicon glyphicon-search"></span>{{ __('pharmacy.select_items_to_reconcile') }}</button>
</div>
</div>
{{ Form::close() }}
</div>
<div class="white-box">
<form action="{{ url('store_pharmacy_optical_stock_count') }}" method="POST" name="pharmacy_stock_form" id="pharmacy_stock_form">
{{ csrf_field() }}
<div class="row">
<div class="col-sm-12">
<div class="col-sm-6 hidden_input" style="display: none;">
<div class="alert alert-info">
<strong>The reconciliation fields are arranged in the following order:</strong>
<button type="button" class="close" data-dismiss="alert">×</button>
<span>
<div class="row hidden_input" style="border: 2px solid #cbd1da">
<div class="col-sm-12 hidden_input" style="display: none;">
Batch Number
</div>
<div class="col-sm-12 hidden_input" style="display: none;">
Batch Unit Cost
</div>
<div class="col-sm-12 hidden_input" style="display: none;">
Batch Quantity
</div>
<div class="col-sm-12 hidden_input" style="display: none;">
Batch Expiry Date
</div>
</div>
</span>
</div>
</div>
<p class="text-muted m-b-30">{{ __('stores.export_data_to_csv_excel_pdf') }}</p>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>{{ __('stores.drug_name') }}</th>
<th>{{ __('pharmacy.pharmacy_system_stock') }}</th>
@if(track_items_using_batches())
<td>{{ __('stores.batch_details_and_others') }}</td>
@endif
<th>{{ __('pharmacy.pharmacy_physical_stock') }}</th>
<th>{{ __('stores.difference') }}</th>
<th>{{ __('stores.variance_in_stock') }}</th>
{{-- <th>{{ __('stores.reason_for_difference') }}</th> --}}
<th>{{ __('stores.selling_price') }}</th>
<th class="hidden_input" style="display: none;">{{ __('stores.is_it_initial_stock') }}</th>
</tr>
</thead>
<tfoot>
<tr>
<th>{{ __('stores.drug_name') }}</th>
<th>{{ __('pharmacy.pharmacy_system_stock') }}</th>
@if(track_items_using_batches())
<td>{{ __('stores.batch_details_and_others') }}</td>
@endif
<th>{{ __('pharmacy.pharmacy_physical_stock') }}</th>
<th>{{ __('stores.difference') }}</th>
<th>{{ __('stores.variance_in_stock') }}</th>
{{-- <th>{{ __('stores.reason_for_difference') }}</th> --}}
<th>{{ __('stores.selling_price') }}</th>
<th class="hidden_input" style="display: none;">{{ __('stores.is_it_initial_stock') }}</th>
</tr>
</tfoot>
<tbody>
<tr class="hidden_input" style="display: none;">
<td></td>
<td></td>
@if(track_items_using_batches())
<td></td>
@endif
<td></td>
<td></td>
<td></td>
{{-- <td></td> --}}
<td>
<b>{{ __('stores.select_all') }}</b>
</td>
<td>
<input type="checkbox" id="select_all_as_initial_stock" name="select_all_as_initial_stock">
</td>
</tr>
@foreach($optics as $drug)
@php
$drug_pharmacy_stock = 0;
$batch_records = \Streamline\Models\ItemBatchWatcher::where(['item_type' => 7, 'item_id' => $drug->id])->where('pharmacy_stock', '>', 0)->get();
if (count($batch_records) > 0) {
foreach ($batch_records as $batch_record) {
$drug_pharmacy_stock += $batch_record->pharmacy_stock;
}
}
@endphp
<tr>
<td>
@if($drug->insurance_coverage == 1)
<span style="color: green;"> {{ $drug->name }} </span>
@else
<span style="color: orange;"> {{ $drug->name }} </span>
@endif
</td>
<td>
<div>
{{ $drug_pharmacy_stock }}
<div class="hidden_input" style="display: none;">
<input type="hidden" name="drug_id[]" value="{{ $drug->id }}">
<input type="hidden" class="form-control" id="cost_price_{{ $drug->id }}" name="cost_price[]" value="{{ $drug->cost_price }}">
</div>
<input type="hidden" name="system_stock[]" class="form-control" id="system_stock_{{ $drug->id }}" value="{{ $drug_pharmacy_stock }}">
</div>
</td>
@if(track_items_using_batches())
<td id="div_to_append_{{ $drug->id }}">
@if(count($batch_records) > 0)
@foreach($batch_records as $record)
<div class="row" style="border: 2px solid #cbd1da; margin-bottom: 2px;" id="div_for_{{ $drug->id }}_{{ $record->batch_number }}">
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px;">
{{ Form::hidden('item_batch_watcher_id[]', $record->id, ['class' => 'batch_record_id_class_'.$record->id]) }}
{{ Form::hidden('batch_drug_id[]', $drug->id, ['class' => 'batch_id_class_'.$drug->id]) }}
{{ Form::hidden('batch_quotation_id[]', $record->id) }}
<input type="hidden" name="" value="{{ $record->pharmacy_stock }}" id="batch_quantity_{{ $record->id }}">
<input type="hidden" name="" value="0" class="batch_variance_balance_{{ $drug->id }}" id="variance_batch_cost_{{ $record->id }}">
<div class="shown_input">
<b>{{ __('stores.batch') }}:</b> <span id="shown_batch_{{ $record->batch_number }}">{{ $record->batch_number }}</span>
</div>
<div class="hidden_input" style="display: none;">
{{ Form::text('batch_number[]', $record->batch_number, ['class' => 'form-control batch_number_'.$drug->id, 'readonly' => 'true']) }}
</div>
</div>
<div class="col-sm-12" style="padding: 0px;">
<div class="shown_input">
<b>{{ __('stores.quantity') }}:</b><font color="blue">{{ $record->pharmacy_stock }}</font> <br/>
@if(Auth::user()->can('remove-batch-during-stock-reconciliation'))
{{-- <small>
@php
$batch_no = $record->batch_number;
$drug_id = $drug->id;
@endphp
<a href="#" style="color: red;" onclick="deleteBatch({{ $drug_id }}, '{{ $batch_no }}')">Remove batch</a>
</small> --}}
@endif
@if(Auth::user()->can('edit-batch-during-stock-reconciliation'))
<small>
@php
$batch_no = $record->batch_number;
$drug_id = $drug->id;
@endphp
<a href="#" id="{{ $batch_no }}" style="color: red;" onclick="editBatch({{$record->id}},{{ $drug_id }}, $(this).attr('id'))">{{ __('stores.edit_batch') }}</a>
</small>
@endif
</div>
</div>
<div class="col-sm-12 shown_input" style="word-wrap:break-word;padding: 0px;">
<b>{{ __('stores.unit_cost') }}: </b>{{ $record->cost_price }}
</div>
<div class="hidden_input" style="display: none;">
<span style="display:flex;width:25rem;">
@if(Auth::user()->can('edit-unit-cost-during-pharmacy-opticals-stock-reconciliation'))
{{ Form::text('batch_unit_cost[]', $record->cost_price, ['class' => 'form-control batch_unit_cost batch_unit_cost_'.$drug->id.'','id'=>'batch_unit_cost_'.$record->id.'']) }}
@else
{{ Form::text('batch_unit_cost[]', $record->cost_price, ['class' => 'form-control batch_unit_cost batch_unit_cost_'.$drug->id.'','id'=>'batch_unit_cost_'.$record->id.'','readonly']) }}
@endif
{{ getCurrencyCode() }}
</span>
</div>
<div class="hidden_input" style="display: none;">
<span style="display:flex;width:25rem;">
<input type="number" name="batch_quantity_balance[]" value="{{ $record->pharmacy_stock }}" class="form-control batch_qty batch_quantity_balance_{{ $drug->id }}" id="batch_quantity_balance_{{ $record->id }}">
QTY
</span>
</div>
<div class="col-sm-12" style="padding: 0px;">
<div class="shown_input">
<b>{{ __('stores.expiry_date') }}:</b> <span>{{ $record->expiry_date }}</span>
</div>
<div class="hidden_input" style="display: none;">
<div class="input-group">
<input type="text" name="expiry_date[]" value="{{ $record->expiry_date }}" autocomplete="off" class="form-control expiry_date_input">
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-12 hidden_input" style="display: none; padding:0px;">
<div class="" id="drug_names">
{{ Form::select('reconcile_reason[]',$reasons,'',['id'=>'reason_'.$record->id, 'class' => 'form-control col-sm-8 reasons reason_'.$drug->id]) }}
</div>
</div>
</div>
@endforeach
@else
<div class="row" style="border: 2px solid #cbd1da">
<div class="col-sm-12" style="padding: 0px;">
{{ Form::hidden('item_batch_watcher_id[]', 0) }}
{{ Form::hidden('batch_drug_id[]', $drug->id) }}
{{ Form::hidden('batch_quotation_id[]', 0) }}
<div class="shown_input">
<!-- kk -->
</div>
<div class="hidden_input" style="display: none;">
{{ Form::text('batch_number[]', '', ['class' => 'form-control col-sm-12 new_batch_number_'.$drug->id, 'placeholder' => 'Batch']) }}
</div>
</div>
<div class="col-sm-12" style="padding: 0px;">
<div class="hidden_input" style="display: none;">
<span style="display:flex;width:25rem;">
{{ Form::text('batch_unit_cost[]', 0, ['class' => 'form-control new_batch_unit_cost_'.$drug->id.'', 'placeholder' => 'Unit cost']) }}
{{ getCurrencyCode() }}
</span>
</div>
</div>
<div class="col-sm-12" style="padding: 0px;">
<div class="hidden_input" style="display: none;">
<span style="display:flex;width:22rem;">
<input type="number" name="batch_quantity_balance[]" class="form-control col-md-12 new_batch_qty new_batch_quantity_balance_{{ $drug->id }}" placeholder="Quantity">
QTY
</span>
</div>
</div>
<div class="col-sm-12" style="padding: 0px;">
<div class="hidden_input" style="display: none;">
<div class="input-group">
<input type="text" name="expiry_date[]" autocomplete="off" placeholder="Expiry date" class="form-control col-md-12 expiry_date_input">
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-12 hidden_input" style="display: none; padding:0px;">
<div class="" id="drug_names">
{{ Form::select('reconcile_reason[]',$reasons,'',['id'=>'reconcile_reason', 'class' => 'form-control col-sm-8 reasons new_reason_'.$drug->id]) }}
</div>
</div>
</div>
@endif
<div class="row show_on_edit" style="display: none;" id="add_batch_{{ $drug->id }}"><a href="#">{{ __('stores.add_batch_small') }}<div>
</td>
@endif
<td>
<div class="shown_input" id="shown_input_{{ $drug->id }}">
{{ $drug_pharmacy_stock == 0 ? $drug_pharmacy_stock : $drug_pharmacy_stock }}
</div>
<div class="hidden_input" style="display: none;">
<input type="number" name="physical_stock[]" readonly class="form-control" id="physical_stock_{{ $drug->id }}" value="{{ $drug_pharmacy_stock == 0 ? $drug_pharmacy_stock : $drug_pharmacy_stock }}" onblur="calculateDifference({{ $drug->id }},{{ $drug->cost_price}}, {{ $drug->non_insured_price}},{{ $drug_pharmacy_stock == 0 ? $drug_pharmacy_stock : $drug_pharmacy_stock}});">
</div>
</td>
<td>
<input type="text" name="difference[]" class="form-control" id="difference_in_stock_{{ $drug->id }}" readonly>
</td>
<td>
<div id="difference_in_cost_value_{{ $drug->id }}">
</div>
<input type="hidden" name="difference_in_cost_value[]" class="form-control" id="difference_in_cost_value_input_{{ $drug->id }}">
</td>
{{-- <td>
<textarea class="hidden_input" style="display: none;" name="reason_for_difference[]" class="form-control"></textarea>
</td> --}}
<td>
<div>
{{ ugandan_shillings($drug->non_insured_price) }}
</div>
</td>
<td class="hidden_input" style="display: none;">
@if(is_null($drug->pharmacy_opening_stock))
<input type="checkbox" name="is_initial_stock[]" class="initial_stock_checkboxes" value="{{ $drug->id }}">
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="form-group row">
<div class="col-sm-12"><br><hr></div>
<div class="col-sm-3">
<div class="input-group">
<input type="text" name="reconciliation_date" placeholder="Reconciliation date" class="form-control col-sm-12" id="reconciliation_date" autocomplete="off" required>
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
<div class="col-sm-3">
<div style="float: right; padding-top: 5px; font-size: 14px;">
{{ Form::label('account_id', __('stores.general_comment')) }}
</div>
</div>
<div class="col-sm-6">
{{ Form::textarea('general_comment','',['class' => 'form-control', 'placeholder' => __('pharmacy.add_general_comment'), 'rows' => 4]) }}
</div>
<div class="col-sm-12">
<hr>
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">×</button>
<span>
<strong>{{ __('pharmacy.note') }}:</strong>
{{ __('pharmacy.stock_differences_are_reflected_in') }} <b>{{ $stock_adjustment_chart_of_account->name }}</b> {{ __('pharmacy.if_it_is_not_opening_stock') }}. {!! __('pharmacy.if_it_is_the_opening_stock_then_the_affected_account') !!}
</span>
</div>
</div>
</div>
</div>
<div class="col-sm-1">
<div style="float: right; position: absolute; bottom: 0;">
<button class="btn btn-default" id="cancel_edit" style="display: none;">{{ __('stores.cancel') }}</button>
<button class="btn btn-success" id="edit_stock" style="margin-bottom: 0px;">{{ __('stores.edit_stock') }}</button>
<!-- <input type="submit" name="save_stock" value="{{ __('stores.save_for_later') }}" class="btn btn-success btn-lg" id="save_stock" style="display: none;"><br><br> -->
<input type="submit" name="reconcile_stock" value="{{ __('stores.reconcile') }}" class="btn btn-success btn-lg" id="reconcile_stock" style="display: none;">
</div>
</div>
</div>
</form>
</div>
<div class="modal fade" id="editBatchModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="exampleModalLabel1"><br><br>{{ __('stores.edit_batch') }}</h4>
</div>
<div class="modal-body">
{{ Form::hidden('batch_record_id', '', ['class' => 'form-control', 'id' => 'batch_record_id',]) }}
{{ Form::hidden('original_drug_id', '', ['class' => 'form-control', 'id' => 'original_drug_id',]) }}
{{ Form::text('original_batch_number', '', ['class' => 'form-control', 'id' => 'original_batch_number', 'readonly']) }}
<br><br>
{{ Form::text('new_batch_number_edit', '', ['class' => 'form-control', 'id' => 'new_batch_number_edit', 'placeholder' => __('stores.new_batch_number')]) }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ __('triage.cancel') }}</button>
<a class="btn btn-success" id="submitNewBatchNumber">{{ __('stores.submit') }}</a>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.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/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
],
drawCallback: function( settings ) {
console.log('DataTables has redrawn the table' );
showHiddenInputs();
}
});
$('.reasons').select2({
placeholder: "Select Reason for difference",
width: '250px'
});
$('.drug_ids').select2({
placeholder: "Select"
});
$('#edit_stock').click(function(e){
e.preventDefault();
$('.hidden_input,#save_stock,#reconcile_stock,.show_on_edit').show();
$('.shown_input').hide();
$(this).hide();
});
function showHiddenInputs(){
if($('#edit_stock').css('display') == 'none'){
$('.hidden_input,#save_stock,#reconcile_stock').show();
$('.shown_input').hide();
$(this).hide();
}
}
// $('body').delegate('#edit_stock', 'click', function (e) {
// e.preventDefault();
// $('.hidden_input,#save_stock,#reconcile_stock').show();
// $('.shown_input').hide();
// $(this).hide();
// });
var created_at = {!! json_encode(calculate_back_date()) !!}
$('#reconciliation_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy',
startDate: new Date(created_at),
endDate:new Date(),
readOnly: true
});
$('.expiry_date_input').datepicker({
autoclose: true,
todayHighlight: true,
format: 'yyyy-mm-dd',
});
$(document).on("change keyup", ".batch_qty, .new_batch_qty, .batch_quantity_balance, .new_batch_quantity_balance, .new_batch_unit_cost", function () {
var id = /\d+(?=\D*$)/.exec($(this).attr('class')) || [];
var id_unit_cost = /\d+(?=\D*$)/.exec($(this).attr('id')) || [];
if (id.length > 0) id = id[0];
if (id_unit_cost.length > 0) id_unit_cost = id_unit_cost[0];
var total_quantity = 0;
var variance_cost_per_batch = 0;
var original_stock_batch = parseFloat($('#batch_quantity_' + id_unit_cost).val()) || 0;
var unit_cost = parseFloat($('#batch_unit_cost_' + id_unit_cost).val()) || 0;
// Calculate for existing batches
$(".batch_quantity_balance_" + id).each(function () {
var batch_qty = parseInt($(this).val()) || 0;
total_quantity += batch_qty;
});
// Calculate variance for existing batches
$("#batch_quantity_balance_" + id_unit_cost).each(function () {
var batch_qty = parseInt($(this).val()) || 0;
var variance_per_batch = batch_qty - original_stock_batch;
var variance_cost_batch = unit_cost * variance_per_batch;
$('#variance_batch_cost_' + id_unit_cost).val(variance_cost_batch);
//add required to reason of varianc_cost batch is not o
if(variance_cost_batch != 0){
$('#reason_'+id_unit_cost).attr('required', true);
}else{ $('#reason_'+id_unit_cost).removeAttr('required');}
});
// Calculate for new batches
var unit_costs = [];
$('.new_batch_unit_cost_' + id).each(function () {
unit_costs.push(parseFloat($(this).val()) || 0); // Ensure it's a float, default to 0 if not a number
});
$(".new_batch_quantity_balance_" + id).each(function (index) {
var batch_qty = parseInt($(this).val()) || 0;
var unit_cost = unit_costs[index] || 0; // Use corresponding unit cost
var variance = batch_qty * unit_cost;
total_quantity += batch_qty;
variance_cost_per_batch += variance;
if (variance !=0){
$('.new_reason_'+id).attr('required',true);
}else{ $('.new_reason_'+id).removeAttr('required');}
});
$(".batch_variance_balance_"+id).each(function () {
var batch_cost = parseInt($(this).val());
variance_cost_per_batch += batch_cost;
});
// Update the total quantities and variance costs
$("#shown_input_" + id).text(total_quantity);
$("#physical_stock_" + id).val(total_quantity);
$("#difference_in_cost_value_input_" + id).val(variance_cost_per_batch);
$("#difference_in_cost_value_" + id).html(variance_cost_per_batch + " Ugx");
// Call the calculateDifference function
var drug_cost = parseFloat($("#cost_price_" + id).val()) || 0;
var drug_price = parseFloat($("#non_insured_price_" + id).val()) || 0;
var drug_system_stock = parseInt($("#system_stock_" + id).val()) || 0;
calculateDifference(id, drug_cost, drug_price, drug_system_stock);
});
$(document).on("change keyup",".batch_unit_cost",function(){
var id = /\d+(?=\D*$)/.exec($(this).attr('class')) || [];
var id_unit_cost = /\d+(?=\D*$)/.exec($(this).attr('id')) || [];
if (id.length > 0) id = id[0];
if (id_unit_cost.length > 0) id_unit_cost = id_unit_cost[0];
var total_quantity = 0;
var variance_cost_per_batch = 0;
var original_stock_batch = parseFloat($('#batch_quantity_' + id_unit_cost).val()) || 0;
var unit_cost = parseFloat($('#batch_unit_cost_' + id_unit_cost).val()) || 0;
// Calculate for existing batches
$(".batch_quantity_balance_" + id).each(function () {
var batch_qty = parseInt($(this).val()) || 0;
total_quantity += batch_qty;
});
// Calculate variance for existing batches
$("#batch_quantity_balance_" + id_unit_cost).each(function () {
var batch_qty = parseInt($(this).val()) || 0;
var variance_cost_batch = unit_cost * batch_qty;
$('#variance_batch_cost_' + id_unit_cost).val(variance_cost_batch);
});
$(".batch_variance_balance_"+id).each(function () {
var batch_cost = parseInt($(this).val());
variance_cost_per_batch += batch_cost;
});
// Update the total quantities and variance costs
$("#shown_input_" + id).text(total_quantity);
$("#physical_stock_" + id).val(total_quantity);
$("#difference_in_cost_value_input_" + id).val(variance_cost_per_batch);
$("#difference_in_cost_value_" + id).html(variance_cost_per_batch + " Ugx");
// Call the calculateDifference function
var drug_cost = parseFloat($("#cost_price_" + id).val()) || 0;
var drug_price = parseFloat($("#non_insured_price_" + id).val()) || 0;
var drug_system_stock = parseInt($("#system_stock_" + id).val()) || 0;
calculateDifference(id, drug_cost, drug_price, drug_system_stock);
})
$('#select_all_as_initial_stock').change(function() {
if (this.checked === true) {
$(".initial_stock_checkboxes").each(function() {
this.checked = true;
});
} else {
$(".initial_stock_checkboxes").each(function() {
this.checked = false;
});
}
});
$('#reconcile_stock').click(function(e){
var empty_compulsory_fields = [];
$(".initial_stock_checkboxes").each(function () {
if (this.checked === false) {
not_initial_stocks_selects = $(this).text();
empty_compulsory_fields.push(not_initial_stocks_selects);
$(this).css('border','1px solid #F08080');
}
});
/* check if the array containing empty compulsory fields is not empty then return false */
if (empty_compulsory_fields.length != 0 && $("#account_id").val() === "") {
alert("<?php echo __('stores.please_select_account') ?>");
$("#account_id").focus();
$("#account_id").css('border','1px solid #F08080');
e.preventDefault();
return false;
}
});
function calculateDifference(drugId,drugCost,drugPrice,stockQuantity) {
var systemStockValue = $("#system_stock_" + drugId).val();
var physicalStockValue = $("#physical_stock_" + drugId).val();
var difference = physicalStockValue - systemStockValue;
var differenceInCostValue = difference * drugCost;
var salesInMoneyValue = systemStockValue * drugPrice;
$("#difference_in_stock_" + drugId).val(difference);
calculateShrinkage(drugId,salesInMoneyValue,physicalStockValue,differenceInCostValue);
}
function calculateShrinkage(drugId,systemStockMoneyValue,physicalStockMoneyValue,differenceInCostValue) {
var shrinkage = systemStockMoneyValue - physicalStockMoneyValue;
systemStockMoneyValue = parseInt(systemStockMoneyValue, 10);
var shrinkagePercentage = 0;
if (systemStockMoneyValue === 0) {
shrinkagePercentage = 0;
} else {
shrinkagePercentage = differenceInCostValue/systemStockMoneyValue * 100;
}
$("#shrinkage_" + drugId).html(shrinkagePercentage.toFixed(2));
$("#shrinkage_input_" + drugId).val(shrinkagePercentage.toFixed(2));//fill hidden input with value
}
$("[id^='add_batch_']").on("click", function (e) {
e.preventDefault();
var id = /\d+(?=\D*$)/.exec($(this).attr('id'));
console.log("clicked div to append == " + id);
var code= {!! json_encode(getCurrencyCode()) !!}
$("#div_to_append_"+id).prepend(`
<div class='row appended_div_row' style='border: 2px solid #cbd1da'>
<div class='col-sm-12' style='padding: 0px;'>
<input type='hidden' name='item_batch_watcher_id[]' value='0'/>
<input type='hidden' name='batch_quotation_id[]' value='0'/>
<input type='hidden' name='batch_drug_id[]' value='${id}'>
<input type="hidden" name="" value="0" class="batch_variance_balance_${id}" id="new_variance_batch_cost">
<div class='hidden_input'>
<input type='text' name='batch_number[]' class='form-control col-sm-12 new_batch_number_${id}' placeholder='Batch'>
</div>
</div>
<div class='col-sm-12' style='padding: 0px;'>
<div class='hidden_input'>
<span style="display:flex;width:22rem;">
<input type='number' name='batch_unit_cost[]' value='0' class='form-control col-md-12 new_batch_unit_cost new_batch_unit_cost_${id}' placeholder='Unit cost'>
${code}
</span>
</div>
</div>
<div class='col-sm-12' style='padding: 0px;'>
<div class='hidden_input'> <span style="display:flex;width:22rem;"><input type='number' name='batch_quantity_balance[]' class='form-control col-md-12 new_batch_qty new_batch_quantity_balance_${id}' placeholder='Quantity'>
QTY</span>
</div>
</div>
<div class='col-sm-12' style='padding: 0px;'>
<div class='hidden_input'>
<div class='input-group'>
<input type='text' name='expiry_date[]' autocomplete='off' placeholder='Expiry date' class='form-control col-md-12 expiry_date_input'>
<span class='input-group-addon'><i class='icon-calender'></i></span>
</div>
</div>
</div>
<div class="col-md-12" style="padding:0px;">
<div class="" id="drug_names">
{{ Form::select('reconcile_reason[]',$reasons,'',['id'=>'reconcile_reason', 'class' => 'form-control col-sm-8 reasons new_reason_${id}']) }}
</div>
</div>
</div>`);
generalSelect2Set(id);
});
$("[id^='div_to_append_']").on("focus", ".expiry_date_input", function (e) {
$(this).datepicker({
autoclose: true,
todayHighlight: true,
format: 'yyyy-mm-dd'
});
});
function generalSelect2Set(id) {
$('.new_reason_'+id).select2({
width: "250px",
placeholder: "Select Reason for difference",
});
}
function deleteBatch(drugId, batchNumber){
event.preventDefault();
console.log("drug id ====== " + drugId);
console.log("batch number ======= " + batchNumber);
var r = confirm("Are you sure you want to remove this batch?. Note that this will reduce the stock of this drug");
if (r == true) {
console.log("removing drug batch");
$.ajax({
method: 'POST',
url: '/remove_item_batch',
data: {'item_id' : drugId, 'batch_number': batchNumber, 'item_type': 7},
success: function(response){
if(response == 1){
//alert('batch ' + batchNumber +' has been succeffully removed');
$("#div_for_"+drugId+"_"+batchNumber).hide();
} else if(response == 0){
alert('system could not find the batch');
}
},
error: function(jqXHR, textStatus, errorThrown) {
alert(JSON.stringify(jqXHR));
console.log(JSON.stringify(jqXHR));
}
});
} else {
return false;
}
}
function editBatch(batchRecordId, drugId, batchNumber){
console.log(batchNumber);
event.preventDefault();
console.log("drug id ====== " + drugId);
console.log("batch number ======= " + batchNumber);
$("#original_drug_id").val(drugId);
$("#batch_record_id").val(batchRecordId);
$("#original_batch_number").val(batchNumber);
$("#editBatchModal").modal("show");
}
$("#submitNewBatchNumber").click(function(e){
let drugId = $("#original_drug_id").val();
let originalBatchRecordId = $("#batch_record_id").val();
let originalBatchNumber = $("#original_batch_number").val();
let newBatchNumberEdit = $("#new_batch_number_edit").val();
console.log("drugId=="+drugId+" originalBatchNumber=="+originalBatchNumber+" newBatchEdit=="+newBatchNumberEdit);
$.ajax({
method: 'POST',
url: '/editing_item_batch_number',
data: {'item_id' : drugId, 'original_batch_record_id': originalBatchRecordId, 'original_batch_number': originalBatchNumber, 'new_batch_number_edit': newBatchNumberEdit, 'item_type': 7},
success: function(response){
if(response == 1){
alert('batch ' + originalBatchNumber +' has been successfully edited');
$("#shown_batch_"+originalBatchNumber).html(newBatchNumberEdit);
$("#editBatchModal").modal("hide");
$("#"+originalBatchNumber).attr("id",newBatchNumberEdit);
$("#new_batch_number_edit").val("");
} else if(response == 0){
alert('system could not complete batch edit the batch');
}
},
error: function(jqXHR, textStatus, errorThrown) {
alert(JSON.stringify(jqXHR));
console.log(JSON.stringify(jqXHR));
}
});
});
</script>
@endpush
@@ -0,0 +1,190 @@
@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" />
@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">{{ __('pharmacy.pharmacy_opticals_stock_sheet') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="/pharmacy">{{ __('pharmacy.incoming_prescriptions') }}</a></li>
<li class="active">{{ __('pharmacy.pharmacy_opticals_stock_sheet') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<!--Flash messages at the top -->
@include('flash::message')
<div class="white-box">
<div class="row">
<div class="col-sm-12">
<form action="{{ url('update_pharmacy_sundries_stock_sheet') }}" method="POST" name="stock_form" id="stock_form">
{{ csrf_field() }}
<p class="text-muted m-b-30">{{ __('pharmacy.export_data_to_copy_csv_pdf') }}</p>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th style="width: 60%">{{ __('pharmacy.sundry_name') }}</th>
@if(track_items_using_batches()) <th class="shown_input">{{ __('stores.batch_details') }}</th>@endif
<th style="width: 20%">{{ __('pharmacy.pharmacy_stock') }}</th>
<th style="width: 20%">{{ __('pharmacy.cost_value') }}</th>
<th style="width: 20%">{{ __('pharmacy.selling_price') }}</th>
<th style="width: 20%">{{ __('pharmacy.sale_value') }}</th>
</tr>
</thead>
<tfoot>
<tr>
<th style="width: 20%">{{ __('pharmacy.sundry_name') }}</th>
@if(track_items_using_batches())<th style="width: 20%" class="shown_input">{{ __('stores.batch_details') }}</th>@endif
<th>{{ __('pharmacy.pharmacy_stock') }}</th>
<th style="width: 20%">{{ __('pharmacy.cost_value') }}</th>
<th style="width: 20%">{{ __('pharmacy.selling_price') }}</th>
<th style="width: 20%">{{ __('pharmacy.sale_value') }}</th>
</tr>
</tfoot>
<tbody>
@foreach($opticals as $sundry)
<tr>
<td>
@if($sundry->insurance == 1)
<span style="color: green;"> {{ $sundry->name }} </span>
@else
<span style="color: orange;"> {{ $sundry->name }} </span>
@endif
</td>
@if(track_items_using_batches())
<td>
@forelse($sundry->batches as $record)
<div class="row" style="background-color: #e1e1ef; border-radius: 5px 5px; border: 2px #c4b7b7 solid; margin-bottom: 2px;">
<div class="col-sm-12 shown_input" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.batch') }}: </b>{{ $record->batch_number }}
</div>
<div class="col-sm-12 shown_input" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.quantity') }}: </b>{{ $record->pharmacy_stock }}<br>
<b>{{ __('stores.expiry_date') }}: </b>{{ streamline_date_plain($record->expiry_date) }}
</div>
<div class="col-sm-12 shown_input" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.unit_cost') }}: </b>{{ $record->cost_price }}
</div>
<div class="col-sm-12" style="padding: 0px;">
{{ Form::hidden('item_batch_watcher_id[]', 0) }}
{{ Form::hidden('batch_drug_id[]', $record->id) }}
{{ Form::hidden('batch_item_id[]', $record->item_id) }}
<div class="shown_input">
<!-- kk -->
</div>
<div class="hidden_input" style="display: none;">
{{ Form::text('batch_number[]', $record->batch_number, ['readonly'=>'true','class' => 'form-control col-sm-12 new_batch_number_'.$sundry->id, 'placeholder' => 'Batch']) }}
</div>
</div>
<div class="col-sm-12" style="padding: 0px;">
<div class="hidden_input" style="display: none;">
<input type="number" name="batch_unit_cost[]" value="{{ $record->cost_price }}" class="form-control batch_qty batch_unit_cost_{{ $sundry->id }}">
</div>
</div>
<div class="col-sm-12" style="padding: 0px;">
<div class="shown_input">
</div>
<div class="hidden_input" style="display: none;">
<input type="number" name="batch_quantity_balance[]" value="{{ $record->pharmacy_stock }}" class="form-control batch_qty batch_quantity_balance_{{ $sundry->id }}">
</div>
</div>
<div class="col-sm-12" style="padding: 0px;">
<div class="hidden_input" style="display: none;">
<div class="input-group">
<input type="text" name="expiry_date[]" value="{{ $record->expiry_date }}" autocomplete="off" class="form-control expiry_date_input">
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
@empty
@endforelse
</td>
@endif
<td>
<div class="shown_input">
{{ $sundry->total_stock }}
</div>
<div class="hidden_input" style="display: none;">
<input type="hidden" name="sundry_id[]" value="{{ $sundry->id }}">
<input type="text" name="quantity[]" class="form-control" value="{{ $sundry->total_stock }}" readonly>
</div>
</td>
<td>
<div class="shown_input">
{{ ugandan_shillings($sundry->item_cost_value) }}
</div>
</td>
<td>
<div class="shown_input">
{{ ugandan_shillings($sundry->non_insured_price) }}
</div>
</td>
<td>
<div class="shown_input">
{{ ugandan_shillings($sundry->total_stock * $sundry->non_insured_price) }}
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<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>
$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
});
$('#edit_stock').click(function(e){
e.preventDefault();
$('.hidden_input,#save_stock').show();
$('.shown_input').hide();
$(this).hide();
});
$('.paginate_button').click(function(e){
e.preventDefault();
$('.hidden_input,#save_stock').hide();
$('#edit_stock').show();
});
</script>
@endpush
@@ -0,0 +1,188 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.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" />
@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">{{ __('layout.optical_stock_reconciliation_report') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li class="active">{{ __('layout.optical_stock_reconciliation_report') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="panel panel-default">
<div class="panel-body">
{{ Form::open(['method'=>'post','route' => 'pharmacy.opticals_stock_reconciliation_report']) }}
<br/>
<h3>{{ __('pharmacy.select_a_date_range') }}</h3>
<br/>
<div class="form-group">
<select class="form-control compulsory required" name="dates" id="dates" required>
<option value="">-select-</option>
<option value="today">{{ __('pharmacy.today') }}</option>
<option value="yesterday">{{ __('pharmacy.yesterday') }}</option>
<option value="custom_date">{{ __('pharmacy.custom_date') }}</option>
<option value="custom_date_range">{{ __('pharmacy.date_range') }}</option>
</select>
</div>
<div id="sDate" style="display: none;">
<div class="form-group">
{{ Form::label('start_date', __('pharmacy.date_on')) }}
<div class="input-group">
{{ Form::text('start_date', '', ['class'=>'form-control required compulsory', 'readonly', 'id'=>'start_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div id="eDate" style="display: none;">
<div class="form-group">
{{ Form::label('end_date', __('pharmacy.end_date')) }}
<div class="input-group">
{{ Form::text('end_date', '', ['class'=>'form-control required compulsory', 'readonly', 'id'=>'end_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="form-group">
{{ Form::submit(__('pharmacy.submit'), ['class'=>'btn btn-success pull-right']) }}
</div>
{{ Form::close() }}
</div>
</div>
</div>
<!-- <div class="col-xs-1"></div> -->
<div class="col-md-9">
<div class="row">
<div class="panel panel-default col-md-12">
<div class="panel-body panel-primary">
<br/>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th style="width: 10px">{{ __('pharmacy.date') }}</th>
<th>{{ __('pharmacy.staff_in_charge') }}</th>
<th>{{ __('pharmacy.reconciliation_id') }}</th>
<th>{{ __('pharmacy.total_variance') }}</th>
<th>{{ __('pharmacy.general_comment') }}</th>
<th>{{ __('pharmacy.action') }}</th>
</tr>
@php
$counter = 0;
@endphp
</thead>
<tbody>
@if(count($reconciled_stocks) > 0)
@foreach($reconciled_stocks as $record)
<tr>
<td>{{ streamline_date($record->created_at) }}</td>
<td>{{ get_full_name($record->created_by, 'id', 'first_name', 'last_name', 'users') }}</td>
<td>{{ sprintf("%04u", $record->stock_count_identifier) }}</td>
<td>{{ ugandan_shillings($record->total) }}</td>
<td>{{ $record->general_comment }}</td>
<td>
{{ Form::open(['method'=>'post','route' => 'pharmacy.opticals_stock_reconciliation_report_details']) }}
{{ Form::hidden('stock_count_identifier', $record->stock_count_identifier) }}
{{ Form::submit('Details', ['class'=>'btn btn-success']) }}
{{ Form::close() }}
</td>
</tr>
@php
$counter++;
@endphp
@endforeach
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script>
$('#dates').change(function (e) {
if($(this).val() === "custom_date"){
$("#eDate").hide();
$("#sDate").show();
}else if($(this).val() === "custom_date_range"){
$("#sDate").show();
$("#eDate").show();
}else{
$("#eDate").hide();
$("#sDate").hide();
}
});
</script>
<script type="text/javascript">
jQuery('#custom_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
</script>
<script type="text/javascript">
jQuery('#end_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
</script>
<script type="text/javascript">
jQuery('#start_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
</script>
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<script>
$('#staff_member').select2({
placeholder: "-- select --"
});
</script>
@endpush
@@ -0,0 +1,163 @@
@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/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
@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">{{ __('pharmacy.opticals_stock_reconciliation_report_details') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="{{ route('pharmacy.opticals_stock_reconciliation_report') }}">{{ __('layout.optical_stock_reconciliation_report') }}</a></li>
<li class="active">{{ __('pharmacy.opticals_stock_reconciliation_report_details') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<!--Flash messages at the top -->
@include('flash::message')
<div class="white-box">
<div class="row">
<div class="col-sm-12">
<p class="text-muted m-b-30">{{ __('stores.export_data_to_csv_excel_pdf') }}</p>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>{{ __('stores.name') }}</th>
<th>{{ __('stores.system_stock') }}</th>
<th>{{ __('stores.physical_stock') }}</th>
<th>{{ __('stores.difference') }}</th>
<th>{{ __('stores.variance_in_stock') }}</th>
<th>{{ __('pharmacy.reconciled_by') }}</th>
<th>{{ __('pharmacy.performed_on') }}</th>
</tr>
</thead>
<tfoot>
<tr>
<th>{{ __('stores.name') }}</th>
<th>{{ __('stores.system_stock') }}</th>
<th>{{ __('stores.physical_stock') }}</th>
<th>{{ __('stores.difference') }}</th>
<th>{{ __('stores.variance_in_stock') }}</th>
<th>{{ __('pharmacy.reconciled_by') }}</th>
<th>{{ __('pharmacy.performed_on') }}</th>
</tr>
</tfoot>
<tbody>
@foreach($opticals_reconciled as $reconciliation_record)
@php
$sundry_name = get_name($reconciliation_record->item_id, "id", "name", "eye_glasses");
$insurance_coverage = get_name($reconciliation_record->item_id, "id", "insurance", "sundries");
@endphp
<tr>
<td>
@if($insurance_coverage == 1)
<span style="color: green;"> {{ $sundry_name }} </span>
@else
<span style="color: orange;"> {{ $sundry_name }} </span>
@endif
</td>
<td>
<div>
{{ $reconciliation_record->system_stock }}
</div>
@forelse($reconciliation_record->batches as $record)
<div class="row" style="background-color: #e1e1ef; border-radius: 5px 5px; border: 2px #c4b7b7 solid; margin-bottom: 2px;">
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.batch') }}: </b>{{ $record['original_batch_number'] }}
</div>
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.quantity') }}: </b>{{ $record['original_quantity'] }}<br>
</div>
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.unit_cost') }}: </b>{{ $record['original_unit_cost'] }}
</div>
</div>
@empty
@endforelse
</td>
<td>
<div>
{{ $reconciliation_record->physical_stock }}
</div>
@forelse($reconciliation_record->batches as $record)
<div class="row" style="background-color: #e1e1ef; border-radius: 5px 5px; border: 2px #c4b7b7 solid; margin-bottom: 2px;">
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.batch') }}: </b>{{ $record['batch_number'] }}
</div>
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.quantity') }}: </b>{{ $record['quantity'] }}<br>
</div>
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.unit_cost') }}: </b>{{ $record['unit_cost'] }}<br/>
<b>{{ __('stores.reason') }}: </b>{{ $record['reason'] }}
</div>
</div>
@empty
@endforelse
</td>
<td>
<div>
{{ $reconciliation_record->difference }}
</div>
</td>
<td>
<div>
{{ ugandan_shillings($reconciliation_record->variance) }}
</div>
</td>
<td>
<div>
{{ get_full_name($reconciliation_record->created_by, 'id', 'first_name', 'last_name', 'users') }}
</div>
</td>
<td>
<div>
{{ streamline_date($reconciliation_record->created_at) }}
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<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/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
});
</script>
@endpush
@@ -0,0 +1,209 @@
@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/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<style type="text/css" media="print" >
/*class for the element we dont want to print*/
.no-print{
display:none;
}
</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">{{ __('pharmacy.dispensing_receipt') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="{{ route('pharmacy.index') }}">{{ __('pharmacy.incoming_prescriptions') }}</a></li>
<li class="active">{{ __('pharmacy.dispensing_receipt') }}</li>
</ol>
</div>
</div>
<div class="white-box">
@if (!empty($episode_id))
<div class="row">
<div class="col-10"></div>
<div class="col-2" style="float:right;">
@if(Auth::user()->can('view-episode-summary'))
<a type="button" class="btn btn-primary" href="/patients/episode_summary/{{ $episode_id->id }}" target="_blank" id="patient_file">{{ __('patient_episode.episode_summary') }}</a>
@endif
</div>
</div> <br>
@endif
<div class="row" id="divToPrint">
<div class="col-md-3"></div>
<div class="col-md-5">
<p style="text-align: center; font-size: 0.8em">
<span style="font-weight: bolder; text-decoration: underline; display: block; font-family: monospace"><b>{{ $hospital_details->name }}</b></span>
<span style="font-weight: bolder; text-decoration: underline; display: block; font-family: monospace">{{ $hospital_details->address }}</span>
<span class="receipt-label"><b>{{ __('pharmacy.phone') }}:</b> {{ $hospital_details->phone_number }}</span><br>
<span class="receipt-label"><b>{{ __('pharmacy.email') }}:</b> {{ $hospital_details->email }}</span><br>
<span class="receipt-label"><b>{{ __('pharmacy.department') }}:</b> {{ __('pharmacy.pharmacy') }}</span><br>
<span class="receipt-label"><b>{{ __('pharmacy.date') }}:</b> {{ streamline_date($patient_dispensing->created_at) }}</span><br>
<span class="receipt-label"><b>{{ __('pharmacy.patient_name') }}:</b> {{ get_name($patient_dispensing->patient_id, 'id', 'first_name', 'patients') }} {{ get_name($patient_dispensing->patient_id, 'id', 'last_name', 'patients') }}</span><br>
<span class="receipt-label"><b>{{ __('pharmacy.patient_number') }}</b> : {{ get_name($patient_dispensing->patient_id, 'id', 'number', 'patients') }}</span><br>
</p>
@php
$drugs_array = explode(",", $patient_dispensing->drugs);
$dosage_array = explode(",", $patient_dispensing->dose);
$dosage2_array = explode(",", $patient_dispensing->dose2);
$frequency_array = explode(",", $patient_dispensing->drug_frequency);
$duration_array = explode(",", $patient_dispensing->duration);
$quantity_dispensed_array = explode(",", $patient_dispensing->quantity_dispensed);
$instruction_array = explode(",", $patient_dispensing->instructions);
// replace empty instructions with N/A
$instruction_array = array_map(function($value) {
return $value === "" ? 'N/A' : $value;
}, $instruction_array);
$department = ($patient_dispensing->tta == 1) ? "IN-PATIENT" : "OPD";
@endphp
@for ($x = 0; $x < count($drugs_array); $x++)
@php
$drug_form_id = get_name($drugs_array[$x], "id", "form_id", "drugs");
$drug_form_name = get_name($drug_form_id, "id", "name", "unit_of_measure");
$drug_unit_id = get_name($drugs_array[$x], "id", "unit_id", "drugs");
$drug_unit = get_name($drug_unit_id, "id", "name", "drug_units");
$drug_strength = get_name($drugs_array[$x], "id", "strength", "drugs");
@endphp
<table style="font-size: 0.8em; font-weight: normal; font-family: monospace">
<tr class="no-print">
<th></th>
<th></th>
<th width="10%"></th>
</tr>
<tr class="{{ $x }} no-print print-all">
<td>{{ __('pharmacy.drug') }}: </td>
<td>{{ get_name(isset($drugs_array[$x]) ? $drugs_array[$x]: "", 'id', 'name', 'drugs') }}</td>
<td class="no-print" style="font-size: 1em;">
<button id="{{ $x }}" class="btn float-right btn-sm btn-info waves-effect waves-light no-print print-btn">
<i class="fa fa-print m-r-5"></i> <span>{{ __('pharmacy.print') }}</span>
</button>
</td>
</tr>
<tr class="{{ $x }} no-print print-all">
<td>{{ __('pharmacy.take') }}: </td>
<td>
{{ isset($dosage_array[$x]) ? $dosage_array[$x]: 0 }} {{ isset($drug_unit) ? $drug_unit: 0 }}
@php
$treatment_dosage = (isset($dosage_array[$x]) && is_numeric($dosage_array[$x])) ? $dosage_array[$x]: 0;
$treatment_strength = isset($drug_strength) ? $drug_strength : 0
@endphp
({{ $treatment_dosage / $treatment_strength }} {{ $drug_form_name ?? "" }})
@if(!empty($dosage2_array[$x]))
| {{ isset($dosage2_array[$x]) ? $dosage2_array[$x]: "" }} {{ isset($drug_unit) ? $drug_unit: "" }}
@endif
{{ is_numeric(isset($frequency_array[$x]) ? $frequency_array[$x]: "") ? get_name(isset($frequency_array[$x]) ? $frequency_array[$x]: "", "id", "name", "dosage_frequencies") : (isset($frequency_array[$x]) ? $frequency_array[$x]: "") }}
</td>
</tr>
<tr class="{{ $x }} no-print print-all">
<td>{{ __('pharmacy.duration') }}: </td>
<td>{{ isset($duration_array[$x]) ? $duration_array[$x]: "" }}</td>
</tr>
<tr class="{{ $x }} no-print print-all">
<td>{{ __('pharmacy.instruction') }}: </td>
<td>{{ trim(isset($instruction_array[$x]) ? $instruction_array[$x]: "") }}</td>
</tr>
<tr class="{{ $x }} no-print print-all">
<td>Info{{ __('pharmacy.pharmacist') }}</td>
@if(get_name(isset($patient_dispensing->patient_id) ? $patient_dispensing->patient_id: "", 'id', 'language', 'patients') == "vern")
<td>{{ get_name(isset($drugs_array[$x]) ? $drugs_array[$x]: "", "id", "info_vernacular", "drugs") }}</td>
@else
<td>{{ get_name(isset($drugs_array[$x]) ? $drugs_array[$x]: "", "id", "info_english", "drugs") }}</td>
@endif
</tr>
<tr class=" no-print"><td colspan="2"><hr ></td></tr>
</table>
@endfor
<i style="font-size: 0.7em; float: left">{{ __('pharmacy.dispensed_by') }} : {{ auth()->user()->first_name }} {{ auth()->user()->last_name }}</i>
<i style="font-size: 0.6em; float: right">&copy; Stre@mline</i>
</div>
<div class="col-md-4 no-print">
<div style="float: right;">
<button class="btn btn-success print-all-drugs-receipts"> <span class="glyphicon glyphicon-print"></span> {{ __('pharmacy.print') }}</button><br>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script type="text/javascript">
// prepare for printing all drugs receipt
$(document).ready(function () {
$(".print-all-drugs-receipts").click(function () {
var id = $(this).attr("id");
// remove no-print attribute from all for the selected drugs
$(".print-all").each(function () {
$(this).removeClass("no-print");
});
// print the whole document
print_drug_receipt();
// add no-print attribute to all for the seleceted drugs
$(".print-all").each(function () {
$(this).addClass("no-print");
});
});
// prepare for printing single drug receipt
$(".print-btn").click(function () {
var id = $(this).attr("id");
// remove no-print attribute from all for the selected drugs
$("." + id).each(function () {
$(this).removeClass("no-print");
});
// print the whole document
print_drug_receipt();
// add no-print attribute to all for the seleceted drugs
$("." + id).each(function () {
$(this).addClass("no-print");
});
});
});
// print for a single drug receipt
function print_drug_receipt() {
let myDiv = document.getElementById('divToPrint');
let newWindow = window.open('', 'SecondWindow', 'toolbar=0,stat=0');
newWindow.document.write("<html><body " +
"class='' " +
" onload='window.print()'>" +
myDiv.innerHTML +
"</body></html>");
newWindow.document.close();
return false;
}
</script>
@endpush
@@ -0,0 +1,253 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-6 col-md-7 col-sm-7 col-xs-12">
<h4 class="page-title">{{ __('pharmacy.dispensation_report_drugs') }}</h4>
</div>
<div class="col-lg-6 col-sm-5 col-md-5 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li class="active">{{ __('pharmacy.dispensation_report') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('pharmacy::pharmacy.dispensation_menu')
</div>
</div>
<div class="row">
<div class="col-sm-12">
<!--Flash messages at the top -->
@include('flash::message')
@foreach ($errors->all() as $error)
<div>{{ $error }}</div>
@endforeach
<div class="panel">
<div class="panel-heading" style="display: none;">{{ __('pharmacy.ward_dispensing_chart') }}</div>
<div class="panel-body">
{{ Form::open(['route' => 'pharmacy.pharmacy_dispensation_report_drugs', 'method' => 'ANY', 'role' => 'search']) }}
<div class="row">
<div class="col-md-3">
<div class="form-group">
{{ Form::label('drug_id', __('pharmacy.drug')) }}
{{ Form::select('drug_id', $drugs_selection_array, '', ['class' => 'form-control', 'id' => 'drugs_select']) }}
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-3">
<div class="form-group" id="searchby">
{{ Form::label('search_by', __('pharmacy.search_by')) }}
{{ Form::select('search_by', ['3'=>__('pharmacy.all_records'),'0'=>__('pharmacy.last_24_hours'),'1'=>__('pharmacy.custom_date'),'2'=>__('pharmacy.date_range')], '', ['class' => 'form-control','id'=>'search_by', 'required']) }}
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-3" style="display: none;" id="date_search">
<div class="form-group" id="reg_date" style="padding-top: 23px;">
<div class="input-group">
{{ Form::text('reg_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'datepicker-autoclose']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-3" style="display: none;" id="date_range_search">
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{ Form::label('start_date', __('pharmacy.from')) }}
<div class="input-group">
{{ Form::text('start_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-1']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group" id="reg_date">
{{ Form::label('end_date', __('pharmacy.to')) }}
<div class="input-group">
{{ Form::text('end_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-2']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group" style="padding-top: 5px;"><br>
{{ Form::button(__('pharmacy.submit'),['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10', 'id'=>'select_patient']) }}
</div>
</div>
</div>
{{ Form::close() }}
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="white-box">
<div><h3 style="color: blue">{{ $search_text }}</h3></div>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table dataTable no-footer">
<thead>
<tr>
<th>#</th>
<th>{{ __('pharmacy.drug') }}</th>
<th>{{ __('pharmacy.dispensed_quantity_opd') }}</th>
<th>{{ __('pharmacy.dispensed_quantity_ward') }}</th>
<th>{{ __('pharmacy.dispensed_total') }}</th>
<th>{{ __('pharmacy.action') }}</th>
</tr>
</thead>
<tbody>
@php $counter = 1; @endphp
@if(count($drugs_qty_associative_array) > 0)
@foreach($drugs_qty_associative_array as $drug_id => $quantity_dispensed)
<tr>
<td>{{ $counter }}</td>
<td>{{ get_name($drug_id, "id", "name", "drugs") }}</td>
<td>{{ isset($opd_drugs_dispensed_with_qty_array[$drug_id]) ? $opd_drugs_dispensed_with_qty_array[$drug_id] : 0 }}</td>
<td>{{ isset($ipd_drugs_dispensed_with_qty_array[$drug_id]) ? $ipd_drugs_dispensed_with_qty_array[$drug_id] : 0 }}</td>
<td>{{ $quantity_dispensed }}</td>
<td>
{{ Form::open(['route' => 'pharmacy.dispensation_report_details']) }}
{{ Form::hidden('details_drug_id', $drug_id) }}
{{ Form::hidden('details_search_by', $request->search_by) }}
{{ Form::hidden('details_reg_date', $request->reg_date) }}
{{ Form::hidden('details_start_date', $request->start_date) }}
{{ Form::hidden('details_end_date', $request->end_date) }}
{{ Form::submit('Details', ['class' => 'btn btn-success btn-rounded']) }}
{{ Form::close() }}
</td>
</tr>
@php $counter++; @endphp
@endforeach
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<!-- data time picker dependency -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<!-- -->
<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 type="text/javascript">
$(document).ready(function() {
$('#datepicker-autoclose,#datepicker-autoclose-1,#datepicker-autoclose-2').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy'
});
$('#search_by').change(function () {
if ($(this).val() == 1) {
$('#date_search').show();
$('#date_range_search').hide();
}
else if ($(this).val() == 2) {
$('#date_range_search').show();
$('#date_search').hide();
}
else {
$('#date_search,#date_range_search').hide();
}
});
$('#drugs_select').select2({
placeholder: "Select drugs"
});
$('.select2-selection.select2-selection--single').css('height','calc(3.85rem)');
$('.select2-selection.select2-selection--single').css('padding-top','5px');
//$('.select2-selection.select2-selection--single').css('border-left', '3px solid #F08080');/*add compulsory class*/
$('.select2-selection.select2-selection--single.sec_d').css('border-left', '3px solid #aaa');
$('.select2-selection__arrow').css('top','3px');
$(".remove").on("click", function () {
$(this).parent().parent().remove();
});
$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy',
{
extend: 'csv',
message: 'DISPENSED DRUGS REPORT - STREAMLINE'
},
{
extend: 'excel',
message: 'DISPENSED DRUGS REPORT - STREAMLINE',
exportOptions: {
columns: [ 0, 1, 2, 3, 4 ]
},
sheetName: 'DISPENSED DRUGS REPORT - STREAMLINE'
},
{
extend: 'pdf',
message: 'DISPENSED DRUGS REPORT - STREAMLINE',
orientation: 'landscape',
pageSize: 'LETTER',
exportOptions: {
columns: [ 0, 1, 2, 3, 4 ]
},
customize: function(doc) {
doc.defaultStyle.fontSize = 10;
}
},
{
extend: 'print',
message: 'DISPENSED DRUGS REPORT - STREAMLINE',
exportOptions: {
columns: [ 0, 1, 2, 3, 4 ]
},
customize: function (win) {
$(win.document.body)
.css('font-size', '10pt')
.css('background', '#fff')
.prepend(
'<img src="<?php echo asset('uploads/logo/logo-sm.png'); ?>" style="position:absolute; top:0; right:0;" />'
);
$(win.document.body).find('table')
.addClass('compact')
.css('font-size', 'inherit');
}
}
]
});
});
</script>
@endpush
@@ -0,0 +1,265 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-6 col-md-7 col-sm-7 col-xs-12">
<h4 class="page-title">{{ __('pharmacy.dispensation_report_patients') }}</h4>
</div>
<div class="col-lg-6 col-sm-5 col-md-5 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li class="active">{{ __('pharmacy.dispensation_report') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('pharmacy::pharmacy.dispensation_menu')
</div>
</div>
<div class="row">
<div class="col-sm-12">
<!--Flash messages at the top -->
@include('flash::message')
@foreach ($errors->all() as $error)
<div>{{ $error }}</div>
@endforeach
<div class="panel">
<div class="panel-heading" style="display: none;">{{ __('pharmacy.ward_dispensing_chart') }}</div>
<div class="panel-body">
{{ Form::open(['route' => 'pharmacy.pharmacy_dispensation_report_patients', 'method' => 'ANY', 'role' => 'search']) }}
<div class="row">
<div class="col-md-3">
<div class="form-group" id="searchby">
{{ Form::label('search_by', __('pharmacy.search_by')) }}
{{ Form::select('search_by', ['0'=>__('pharmacy.last_24_hours'),'1'=>__('pharmacy.custom_date'),'2'=>__('pharmacy.date_range')], '', ['class' => 'form-control','id'=>'search_by', 'required']) }}
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-3" style="display: none;" id="date_search">
<div class="form-group" id="reg_date" style="padding-top: 23px;">
<div class="input-group">
{{ Form::text('reg_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'datepicker-autoclose']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-3" style="display: none;" id="date_range_search">
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{ Form::label('start_date', __('pharmacy.from')) }}
<div class="input-group">
{{ Form::text('start_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-1']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group" id="reg_date">
{{ Form::label('end_date', __('pharmacy.to')) }}
<div class="input-group">
{{ Form::text('end_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-2']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group" style="padding-top: 5px;"><br>
{{ Form::button(__('pharmacy.submit'),['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10', 'id'=>'select_patient']) }}
</div>
</div>
</div>
{{ Form::close() }}
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="white-box">
<div><h3 style="color: blue">{{ $search_text }}</h3></div>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table dataTable no-footer">
<thead>
<tr>
<th>#</th>
<th>{{ __('pharmacy.patient_name') }}</th>
<th>{{ __('pharmacy.drugs_dispensed') }}</th>
<th>{{ __('pharmacy.drugs_quantities') }}</th>
<th>{{ __('pharmacy.time_dispensed') }}</th>
<th>{{ __('pharmacy.dispensed_by') }}</th>
<th></th>
</tr>
</thead>
<tbody>
@php $counter = 1; @endphp
@if(count($dispensations) > 0)
@foreach($dispensations as $dispensation)
<tr>
<td>{{ $counter }}</td>
<td>
{{ get_full_name($dispensation->patient_id, 'id', 'first_name', 'last_name', 'patients') }}
({{ get_name($dispensation->patient_id, 'id', 'number', 'patients') }})
</td>
@php
$drugs = explode(",", $dispensation->drugs);
$quantities = explode(",", $dispensation->quantity_dispensed);
@endphp
<td>
<ul>
@foreach($drugs as $drug)
<li>{{ get_name($drug, 'id', 'name', 'drugs') }}</li>
@endforeach
</ul>
</td>
<td>
<ul>
@foreach($quantities as $quantity)
<li>{{ $quantity }}</li>
@endforeach
</ul>
</td>
<td>{{ streamline_date_time($dispensation->created_at) }}</td>
<td>{{ get_full_name($dispensation->created_by, 'id', 'first_name', 'last_name', 'users') }}</td>
<td>
@if(get_name($dispensation->treatment_id, 'id', 'payment_status', 'treatments') == 0)
<a class="btn btn-danger btn-sm btn-rounded" href="/pharmacy/cancel_dispensation/{{ $dispensation->id }}">{{ __('pharmacy.cancel_dispensation') }}</a>
@else
<a class="btn btn-danger btn-sm btn-rounded" href="" onclick="alert('This treatment was already paid for. Please cancel the payment receipt from finance before cancelling this dispensation'); return false;">{{ __('pharmacy.dispensed_by') }}</a>
@endif
</td>
</tr>
@php $counter++; @endphp
@endforeach
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<!-- data time picker dependency -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<!-- -->
<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 type="text/javascript">
$(document).ready(function() {
$('#datepicker-autoclose,#datepicker-autoclose-1,#datepicker-autoclose-2').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy'
});
$('#search_by').change(function () {
if ($(this).val() == 1) {
$('#date_search').show();
$('#date_range_search').hide();
}
else if ($(this).val() == 2) {
$('#date_range_search').show();
$('#date_search').hide();
}
else {
$('#date_search,#date_range_search').hide();
}
});
$('#drugs_select').select2({
placeholder: "Select drugs"
});
$('.select2-selection.select2-selection--single').css('height','calc(3.85rem)');
$('.select2-selection.select2-selection--single').css('padding-top','5px');
//$('.select2-selection.select2-selection--single').css('border-left', '3px solid #F08080');/*add compulsory class*/
$('.select2-selection.select2-selection--single.sec_d').css('border-left', '3px solid #aaa');
$('.select2-selection__arrow').css('top','3px');
$(".remove").on("click", function () {
$(this).parent().parent().remove();
});
$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy',
{
extend: 'csv',
message: 'DISPENSED DRUGS REPORT - STREAMLINE'
},
{
extend: 'excel',
message: 'DISPENSED DRUGS REPORT - STREAMLINE',
exportOptions: {
columns: [ 0, 1, 2, 3, 4 ]
},
sheetName: 'DISPENSED DRUGS REPORT - STREAMLINE'
},
{
extend: 'pdf',
message: 'DISPENSED DRUGS REPORT - STREAMLINE',
orientation: 'landscape',
pageSize: 'LETTER',
exportOptions: {
columns: [ 0, 1, 2, 3, 4 ]
},
customize: function(doc) {
doc.defaultStyle.fontSize = 10;
}
},
{
extend: 'print',
message: 'DISPENSED DRUGS REPORT - STREAMLINE',
exportOptions: {
columns: [ 0, 1, 2, 3, 4 ]
},
customize: function (win) {
$(win.document.body)
.css('font-size', '10pt')
.css('background', '#fff')
.prepend(
'<img src="<?php echo asset('uploads/logo/logo-sm.png'); ?>" style="position:absolute; top:0; right:0;" />'
);
$(win.document.body).find('table')
.addClass('compact')
.css('font-size', 'inherit');
}
}
]
});
});
</script>
@endpush
@@ -0,0 +1,144 @@
@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/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
@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">{{ __('pharmacy.previous_requisitions') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="{{ route('pharmacy.index') }}">{{ __('pharmacy.pharmacist') }}</a></li>
<li class="active">{{ __('pharmacy.previous_requisitions') }} </li>
</ol>
</div>
</div>
@include('flash::message')
<div class="row">
<div class="col-sm-12">
<div class="white-box">
<div class="row">
<div class="col-sm-3 form-group">
{{ Form::open(['method' => 'post', 'route'=>'pharmacy.previous_requisitions'])}}
{{ Form::label('quotation_type', __('pharmacy.requisition_type')) }}
{{ Form::select('quotation_type', $quotation_type_options , null, ['class'=>'form-control compulsory', 'required']) }}
<br>
<strong>{{ __('pharmacy.requisitioned_between') }}</strong><br>
{{ Form::label('start_date',__('pharmacy.start')) }}
<div class="input-group">
{{ Form::text('start_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'datepicker-autoclose1']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
<br>
{{ Form::label('end_date',__('pharmacy.end')) }}
<div class="input-group">
{{ Form::text('end_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'datepicker-autoclose2']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
<div class="help-block with-errors"></div>
{{ Form::button(__('pharmacy.search'),['type'=>'submit','class'=>'btn btn-success btn-rounded waves-effect waves-light m-r-10']) }}
{{ Form::close() }}
</div>
<div class="col-sm-9" style="padding-top: 25px;">
<div class="label label-warning"> {!! $display ?? '' !!}</div> <br>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table table-striped table-hover">
<thead>
<tr>
<th style="width: 30%;">{{ __('pharmacy.requisition_number') }}</th>
<th style="width: 30%">{{ __('pharmacy.quantity') }}</th>
<th style="width: 20%">{{ __('pharmacy.date_requested') }}</th>
<th></th>
</tr>
</thead>
<tbody>
@if(!is_null($results))
@foreach($results as $result)
<tr>
<td># {{ sprintf('%04u', $result->id) }}</td>
<td>
<?php
$drug_id_array = explode(",", $result->quantity_requested);
?>
{{ count($drug_id_array) }} {{ __('pharmacy.items') }}
</td>
<td>
{{ streamline_date(get_name($result->id, "id", "created_at", "requisitions")) }}
</td>
<td>
@if($result->issue_status == 1)
<form name="bill_form" action="{{ url('previous_issued_items_details') }}" method="post">
{{ csrf_field() }}
<input type="hidden" name="requisition_id" value="{{ $result->id }}"/>
<input type="hidden" name="item_type" value="{{ $result->quotation_type_id }}">
<button type="submit" name="add_bill_button" class="btn btn-sm btn-rounded btn-info">
<i class="fa fa-info-circle"></i>
<span style="margin-left: 10px;">{{ __('labs.details') }}</span>
</button>
</form>
@else
@if( $result->approval_status != 1)
<form name="quotation_form" action="{{ url('edit_previous_requisition') }}" method="post">
{{ csrf_field() }}
<input type="hidden" name="requisition_id" value="{{ $result->id }}"/>
<input type="hidden" name="item_type" value="{{ $result->quotation_type_id }}">
<button type="submit" name="previous_quotation_edit_button" class="btn btn-rounded btn-warning"><i class="fa fa-pencil"></i> {{ __('pharmacy.edit_requisition') }}</button>
</form>
@else
<a class="btn btn-success btn-rounded" href="/print_requisition_receipt/{{ $result->id }}"><i class="fa fa-eye"></i> {{ __('pharmacy.view') }}</a>
@endif
@endif
</td>
</tr>
@endforeach
@else
<td colspan="7"><span style="color: red;">{{ __('pharmacy.please_search_records') }}</span></td>
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<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>
<!-- data time piker dependency -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<!-- -->
<script>
$('#datepicker-autoclose1,#datepicker-autoclose2').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy',
setDate: new Date(),
readOnly: true
});
</script>
@endpush
@@ -0,0 +1,175 @@
@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/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
@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">{{ __('pharmacy.dispensing_receipt') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="{{ route('pharmacy.index') }}">{{ __('pharmacy.incoming_prescriptions') }}</a></li>
<li class="active">{{ __('pharmacy.dispensing_receipt') }}</li>
</ol>
</div>
</div>
@include('flash::message')
<div class="row">
<div class="col-sm-12">
<div class="white-box" id="divToPrint">
<style type="text/css" media="print" >
/*class for the element we dont want to print*/
.no-print{
display:none;
}
</style>
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-5">
@for ($x = 0; $x < count($protocol_drug_ids_arr); $x++)
@php
$drug_details = \Illuminate\Support\Facades\DB::table('drugs')->where('id', $protocol_drug_ids_arr[$x])->first();
$patient_details = \Illuminate\Support\Facades\DB::table('patients')->where('id', $protocol_patient_id_arr[$x])->first();
$drug_form_id = $drug_details->form_id;
$drug_form_name = get_name($drug_form_id, "id", "name", "unit_of_measure");
$drug_unit_id = $drug_details->unit_id;
$drug_unit = get_name($drug_unit_id, "id", "name", "drug_units");
$drug_strength = $drug_details->strength;
@endphp
<h6 class="{{ $x }} no-print print-all">
{{ $patient_details->first_name }} {{ $patient_details->last_name }} ({{ $patient_details->number }})
<br><br>
{{ $wards[$protocol_ward_id_arr[$x]] ?? '' }}
</h6>
<table style="font-size: 0.8em; font-weight: normal; font-family: monospace">
<tr class="no-print">
<th></th>
<th></th>
<th width="10%"></th>
</tr>
<tr class="{{ $x }} no-print print-all">
<td>{{ __('pharmacy.drug') }}: </td>
<td>{{ $drug_details->name }}</td>
<td class="no-print" style="font-size: 1em;">
<button id="{{ $x }}" class="btn float-right btn-sm btn-primary waves-effect waves-light no-print print-btn">
<i class="fa fa-print m-r-5"></i> <span>{{ __('pharmacy.print') }}</span>
</button>
</td>
</tr>
<tr class="{{ $x }} no-print print-all">
<td>Dose: </td>
<td>{{ $protocol_drug_dose_arr[$x] }} {!! $protocol_drug_dose_label_arr[$x] !!}</td>
</tr>
<tr class="{{ $x }} no-print print-all">
<td>Give: </td>
<td>{{ $protocol_dosage_to_dispense_arr[$x] }} {{ $drug_unit }}</td>
</tr>
<tr class="{{ $x }} no-print print-all">
<td>{{ __('pharmacy.instruction') }}: </td>
<td>{{ $protocol_instruction_arr[$x] }}</td>
</tr>
<tr class="{{ $x }} no-print print-all">
<td>Pharmacist Comment</td>
@if($patient_details->language == "vern")
<td>{{ $drug_details->info_vernacular }}</td>
@else
<td>{{ $drug_details->info_english }}</td>
@endif
</tr>
<tr class=" no-print"><td colspan="2"><hr ></td></tr>
</table>
@endfor
<i style="font-size: 0.7em; float: left">{{ __('pharmacy.dispensed_by') }} : {{ auth()->user()->first_name }} {{ auth()->user()->last_name }}</i>
<i style="font-size: 0.6em; float: right">&copy; Stre@mline</i>
</div>
<div class="col-md-4 no-print">
<div style="float: right;">
<button class="btn btn-primary btn-sm print-all-drugs-receipts">{{ __('pharmacy.print') }}</button><br>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script type="text/javascript">
// prepare for printing all drugs receipt
$(document).ready(function () {
$(".print-all-drugs-receipts").click(function () {
var id = $(this).attr("id");
// remove no-print attribute from all for the selected drugs
$(".print-all").each(function () {
$(this).removeClass("no-print");
});
// print the whole document
print_drug_receipt();
// add no-print attribute to all for the seleceted drugs
$(".print-all").each(function () {
$(this).addClass("no-print");
});
});
// prepare for printing single drug receipt
$(".print-btn").click(function () {
var id = $(this).attr("id");
// remove no-print attribute from all for the selected drugs
$("." + id).each(function () {
$(this).removeClass("no-print");
});
// print the whole document
print_drug_receipt();
// add no-print attribute to all for the seleceted drugs
$("." + id).each(function () {
$(this).addClass("no-print");
});
});
});
// print for a single drug receipt
function print_drug_receipt() {
let myDiv = document.getElementById('divToPrint');
let newWindow = window.open('', 'SecondWindow', 'toolbar=0,stat=0');
newWindow.document.write("<html><body " +
"class='' " +
" onload='window.print()'>" +
myDiv.innerHTML +
"</body></html>");
newWindow.document.close();
return false;
}
</script>
@endpush
@@ -0,0 +1,225 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/typeahead.js-master/dist/typehead-min.css') }}" rel="stylesheet">
<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/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
@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">{{ __('pharmacy.requisitions') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="{{ route('pharmacy.index') }}">{{ __('pharmacy.pharmacist') }}</a></li>
<li class="active">{{ __('pharmacy.requisitions') }}</li>
</ol>
</div>
</div>
@include('flash::message')
<div class="row">
<div class="col-sm-12">
<div class="white-box">
<div class="row">
@if(count($results) <= 0)
<div class="col-sm-3 form-group">
{{ Form::open(['method' => 'post', 'route'=>'pharmacy.requisition_for_drugs'])}}
{{ Form::label('quotation_type', __('pharmacy.requisition_type')) }}
{{ Form::select('quotation_type', $quotation_type_options , null, ['class'=>'form-control compulsory', 'required']) }} <br>
{{ Form::button(__('pharmacy.submit_requisition_type'),['type'=>'submit','class'=>'btn btn-rounded btn-success waves-effect waves-light m-r-10']) }}
{{ Form::close() }}
</div>
@endif
<div class="col-sm-12">
@if(isset($item_type) && $item_type != 0)
{{ Form::open(['route' => 'pharmacy.drug_requisition_search', 'method' => 'ANY', 'role' => 'search']) }}
<div class="row">
<input type="hidden" name="item_type" value="{{ $item_type }}">
<div class="col-md-8">
<div class="form-group" id="drug_names">
{{ Form::select('drug_name[]',$names_array,'',['id'=>'item_ids', 'multiple'=>true, 'class' => 'form-control col-sm-8 item_ids']) }}
</div>
</div>
<div class="col-md-2">
<button type="submit" class="btn btn-rounded btn-info"><span class="glyphicon glyphicon-search"></span> {{ __('stores.select_items_to_requisition') }}</button>
</div>
</div>
@if(isset($criteria) && isset($resultCount))
<p>
{{ __('pharmacy.search_criteria') }} : <code>{{ $criteria }}</code> &nbsp;&nbsp;&nbsp;{{ __('pharmacy.total_results') }} : <code>{{ $resultCount }}</code> &nbsp;&nbsp;&nbsp;<a href="{{ route('drugs.index') }}">{{ __('pharmacy.clear_search') }}</a>
</p>
@endif
{{ Form::close() }}
@endif
{{ Form::open(['method' => 'post', 'route'=>'pharmacy.store_requisition'])}}
<input type="hidden" name="item_type" value="{{ $item_type }}">
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table table-striped table-hover">
<thead>
<tr>
<th style="width: 5%">#</th>
<th style="width: 30%">{{ __('pharmacy.item_name') }}</th>
<th style="width: 20%">{{ __('pharmacy.store_stock') }}</th>
<th style="width: 20%">{{ __('pharmacy.pharmacy_stock') }}</th>
<th style="width: 30%">{{ __('pharmacy.quantity_requested') }}</th>
</tr>
</thead>
<tbody>
@if(count($results) > 0)
@php $count = 0; @endphp
@foreach($results as $result)
@php
$count++;
$drug_store_stock = $drug_pharmacy_stock = 0;
$store_batch_records =track_batch_stock($item_type,$result->id,'store_stock');
$pharmacy_batch_records =track_batch_stock($item_type,$result->id,'pharmacy_stock');
@endphp
<tr>
<td>{{ $count }}</td>
<td>
{{ $result->name }}
<input type="hidden" name="drug_id[]" value="{{ $result->id }}">
</td>
<td>
@if(count($store_batch_records) > 0)
@foreach($store_batch_records as $record)
<div class="row" style="background-color: #e1e1ef; border-radius: 5px 5px; border: 2px #c4b7b7 solid; margin-bottom: 2px; margin-right: 2px;">
<div class="col-sm-6" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.batch') }}: </b>{{ $record->batch_number }}
</div>
<div class="col-sm-6" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.quantity') }}: </b>{{ $record->store_stock }}<br>
@php
$drug_store_stock += $record->store_stock;
@endphp
<b>{{ __('stores.expiry_date') }}: </b>{{ streamline_date_plain($record->expiry_date) }}
</div>
</div>
@endforeach
@endif
Total Stock: {{ $drug_store_stock }}
</td>
<td>
@if(count($pharmacy_batch_records) > 0)
@foreach($pharmacy_batch_records as $record)
<div class="row" style="background-color: #e1e1ef; border-radius: 5px 5px; border: 2px #c4b7b7 solid; margin-bottom: 2px;">
<div class="col-sm-6" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.batch') }}: </b>{{ $record->batch_number }}
</div>
<div class="col-sm-6" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.quantity') }}: </b>{{ $record->pharmacy_stock }}<br>
@php
$drug_pharmacy_stock += $record->pharmacy_stock;
@endphp
<b>{{ __('stores.expiry_date') }}: </b>{{ streamline_date_plain($record->expiry_date) }}
</div>
</div>
@endforeach
@endif
Total : {{ $drug_pharmacy_stock }}
</td>
<td>
<input type="number" name="quantity[]" min="0" class="form-control col-sm-12 compulsory">
</td>
</tr>
@endforeach
@else
<td colspan="3"><span style="color: red;">{{ __('pharmacy.please_search_records') }}</span></td>
@endif
</tbody>
</table>
</div>
</div>
@if(count($results) > 0 )
<div class="row">
<div class="col-md-6">
{{ Form::button(__('pharmacy.save_for_later'),['type'=>'submit','name'=>'save_for_later','value'=>'1','class'=>' btn btn-default waves-effect waves-light ']) }}
</div>
<div class="col-md-3">
{{ Form::button(__('pharmacy.complete_request'),['type'=>'submit','name'=>'complete_request','value'=>'1','class'=>' btn btn-success waves-effect waves-light ']) }}
</div>
{{ Form::close() }}
<div class="col-md-5">
</div>
</div>
@endif
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<!-- Typehead Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/typeahead.js-master/dist/typeahead.bundle.min.js') }}"></script>
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset('elite/bower_components/select2/select2.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>
<!-- data time piker dependency -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<!-- -->
<script type="text/javascript">
$('.item_ids').select2({
placeholder: "Select"
});
var substringMatcher = function (strs) {
return function findMatches(q, cb) {
var matches, substringRegex;
// an array that will be populated with substring matches
matches = [];
// regex used to determine if a string contains the substring `q`
substrRegex = new RegExp(q, 'i');
// iterate through the pool of strings and for any string that
// contains the substring `q`, add it to the `matches` array
$.each(strs, function (i, str) {
if (substrRegex.test(str)) {
matches.push(str);
}
});
cb(matches);
};
};
$('#drug_names .typeahead').typeahead(
{
hint: true,
highlight: true,
minLength: 1
},
{
name: 'drug_names',
source: substringMatcher(<?php echo json_encode($names_array); ?>)
}
);
$('#datepicker-autoclose1,#datepicker-autoclose2').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy',
setDate: new Date(),
readOnly: true
});
</script>
@endpush
@@ -0,0 +1,212 @@
@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/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
@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">{{ __('pharmacy.print_requisition') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li class="active">{{ __('pharmacy.requisition_receipt') }} </li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('flash::message')
<div style="float: right;">
<br>
<a href="/item_requisition_print/{{$requisition_id}}/{{$requisition_model->quotation_type_id}}" target="_blank" class="btn btn-rounded" style="background-color: #03C03C; color: white;">
<i class="fa fa-print"></i><span style="margin-left: 10px;">PDF {{ __('stores.print') }}</span>
</a>
</div>
</div>
</div><br>
<div class="row">
<div class="col-sm-12">
<div class="white-box">
<div id="printableContent">
<div class="row">
<div class="col-sm-12"><center>{{ __('pharmacy.date') }} : {{ streamline_date($requisition_model->created_at) }}</center></div>
<div class="col-sm-9">
<address class="margin-none">
<strong>{{ $hospital_details->name }}</strong><br/>
{{ $hospital_details->address }}<br/>
{{ get_name($hospital_details->district, "id", "name", "districts") }}<br/>
<a href="#">{{ $hospital_details->email }}</a><br/>
{{ $hospital_details->phone_number }}<br/>
</address>
</div>
<div class="col-sm-12">
<strong>{{get_quotation_type_name($requisition_model->quotation_type_id)}} {{ __('pharmacy.request_from_requisition') }} {{ get_requisition_origin($requisition_model->requisition_origin) }}: <?php echo "#" . sprintf('%04u', $requisition_id) ?></strong>
<div class="white-box">
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('pharmacy.number') }}</th>
<th>{{ __('pharmacy.item_name') }}</th>
<th>{{ __('pharmacy.quantity') }}</th>
@if($requisition_model->quotation_type_id ==1 || $requisition_model->quotation_type_id ==5) <th>{{ __('pharmacy.units') }}</th>@endif
<th>{{ __('pharmacy.cost_value') }}</th>
</tr>
</thead>
<tbody>
@php
$counter = 1;
$grand_total = 0;
$requisiton_details = $requisition_model;
$requisition_type_id = $requisition_model->quotation_type_id;
$item_array = explode(",", $requisiton_details->drug_id);
$quantity_array = explode(",", $requisiton_details->quantity_requested);
@endphp
@for($i = 0; $i < count($quantity_array) ; $i++)
@if(isset($quantity_array[$i]) && $quantity_array[$i] != "" && isset($item_array[$i]))
<tr>
<td>{{ $counter }}. </td>
<!-- 1-drug 2-sundry 3-dental 4-radiology 5-Lab -->
@if($requisition_type_id == 1)
<td>{{ get_name($item_array[$i], 'id', 'name', 'drugs') }}</td>
@php
$cost_price = get_name($item_array[$i], 'id', 'cost_price', 'drugs');
$drug_form = get_name($item_array[$i], 'id', 'form_id', 'drugs');
$drug_form_name = get_name($drug_form,'id','name','drug_forms');
if ($drug_form_name == 'N/A') $drug_form_name =null;
@endphp
@elseif($requisition_type_id == 2)
<td>{{ get_name($item_array[$i], 'id', 'name','sundries') }}</td>
@php
$cost_price = get_name($item_array[$i], 'id', 'cost_price', 'sundries');
$drug_form = get_name($item_array[$i], 'id', 'package_unit_id', 'sundries');
@endphp
@elseif($requisition_type_id == 3)
<td>{{ get_name($item_array[$i], 'id', 'name','dentals') }}</td>
@php
$cost_price = get_name($item_array[$i], 'id', 'cost_price', 'dentals');
$drug_form = null;
@endphp
@elseif($requisition_type_id == 4)
<td>{{ get_name($item_array[$i], 'id', 'name','radiologies') }}</td>
@php
$cost_price = get_name($item_array[$i], 'id', 'cost_price', 'radiologies');
$drug_form = get_name($item_array[$i], 'id', 'form_id', 'radiologies');
@endphp
@elseif($requisition_type_id == 5)
<td>{{ get_name($item_array[$i], 'id', 'name','labs') }}</td>
@php
$cost_price = get_name($item_array[$i], 'id', 'cost_price', 'labs');
$drug_form = get_name($item_array[$i], 'id', 'form_id', 'labs');
$drug_form_name=get_name($drug_form, 'id','name','lab_forms');
if ($drug_form_name == 'N/A') $drug_form_name =null;
@endphp
@elseif($requisition_type_id == 6)
<td>{{ get_name($item_array[$i], 'id', 'name','general_items') }}</td>
@php
$cost_price = get_name($item_array[$i], 'id', 'cost_price', 'general_items');
$drug_form = null;
@endphp
@elseif($requisition_type_id == 7)
<td>{{ get_name($item_array[$i], 'id', 'name','eye_glasses') }}</td>
@php
$cost_price = get_name($item_array[$i], 'id', 'buying_price', 'eye_glasses');
$drug_form = null;
@endphp
@endif
<td>{{ $quantity_array[$i] }}</td>
@if($requisition_type_id ==1 || $requisition_type_id ==5 )<td>{{ $drug_form_name }}</td>@endif
<td>
@php
if (track_items_using_batches()){
$item_sub_total =get_unit_cost_from_store_batch($item_array[$i],$requisition_type_id,$quantity_array[$i],'store_stock');
}else{
$quantity = (isset($quantity_array[$i]) && is_numeric($quantity_array[$i])) ? $quantity_array[$i] : 0;
$item_cost = is_numeric($cost_price) ? $cost_price : 0;
$item_sub_total = $quantity * $item_cost;
}
$grand_total += $item_sub_total;
@endphp
{{ ugandan_shillings($item_sub_total) }}
</td>
</tr>
@php $counter++; @endphp
@endif
@endfor
</tbody>
<tfoot>
<tr>
<td colspan="2"></td>
@if($requisition_type_id ==1 || $requisition_model->quotation_type_id ==5) <td ></td>@endif
<td>{{ __('pharmacy.total') }}</td>
<td>{{ ugandan_shillings($grand_total) }}</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<div class="col-sm-6">
<strong>{{ __('pharmacy.requisitioned_by') }}:</strong><br><br>
<strong>{{ get_full_name($requisition_model->created_by, "id", "first_name", "last_name", "users") }}</strong><br><br>
<small>{{ streamline_date_time_short($requisition_model->created_at) }}</small><br><br>
.......................................
</div>
<div class="col-sm-6">
<strong>{{ __('pharmacy.received_by') }}:</strong><br><br>
.......................................
</div>
<div class="col-sm-12">
<br>
<i><small>{{ get_full_name(auth()->user()->id, "id", "first_name", "last_name", "users") .' '.streamline_date_time(date('Y-m-d')) }}</small></i>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script type="text/javascript">
function printElementContent(elem,title){
var mywindow = window.open('', 'PRINT', 'height=400,width=600');
var css = '<link href="elite/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">';
mywindow.document.write('<html><head><title></title>');
mywindow.document.write('</head><body >');
mywindow.document.write(css);
mywindow.document.write('<center><h3>' + title + '</h3></center>');
mywindow.document.write(document.getElementById(elem).innerHTML);
mywindow.document.write('</body></html>');
mywindow.document.close(); // necessary for IE >= 10
//mywindow.focus(); // necessary for IE >= 10*/
setTimeout(function () {
mywindow.focus();
mywindow.print();
mywindow.remove();
}, 500);
return true;
}
//$("#printPurchaseOrderReceipt").click(function(e){
// printElementContent('printableContent','Requisition receipt');
//});
</script>
@endpush
@@ -0,0 +1,357 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
<style>
.modal_diagnosis {
position: fixed;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
</style>
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-6 col-md-7 col-sm-7 col-xs-12">
<h4 class="page-title">{{ __('pharmacy.ward_dispensing_chart') }}</h4>
</div>
<div class="col-lg-6 col-sm-5 col-md-5 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li class="active">{{ __('pharmacy.ward_dispensing_chart') }}</li>
</ol>
</div>
</div>
@include('pharmacy::pharmacy.ward_dispensing_menu')
<div class="row">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-12">
<div class="panel">
<div class="panel-heading" style="display: none;">{{ __('pharmacy.ward_dispensing_chart') }}</div>
<div class="panel-body">
{{ Form::open(['route' => 'pharmacy.return_drugs_per_chart', 'class' => 'typeahead', 'method' => 'ANY', 'role' => 'search']) }}
{{ Form::hidden('patient_id', 0, ['id' => 'patient_id']) }}
<div class="row">
<div class="col">
<div class="form-group">
{{ Form::label('ward_id', __('pharmacy.wards')) }}
{{ Form::select('ward_id', $wards, '', ['class' => 'form-control compulsory', 'required']) }}
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col">
<div class="form-group" id="searchby">
{{ Form::label('search_by', __('pharmacy.admission_date')) }}
{{ Form::select('search_by', ['3'=>__('pharmacy.all_records'),'0'=>__('pharmacy.last_24_hours'),'1'=>__('pharmacy.custom_date'),'2'=>__('pharmacy.date_range')], '', ['class' => 'form-control','id'=>'search_by', 'required']) }}
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col" style="display: none;" id="date_search">
<div class="form-group" id="reg_date" style="padding-top: 23px;">
<div class="input-group">
{{ Form::text('reg_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'datepicker-autoclose']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col" style="display: none;" id="date_range_search">
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{ Form::label('start_date', __('pharmacy.from')) }}
<div class="input-group">
{{ Form::text('start_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-1']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group" id="reg_date">
{{ Form::label('end_date', __('pharmacy.to')) }}
<div class="input-group">
{{ Form::text('end_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-2']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
</div>
<div class="col">
{{ Form::label('search_patient', __('pharmacy.search_by_patient')) }}
<div class="input-group">
<select class="form-control" name="patient_number" id="patient_number">
<option value="0"> </option>
@foreach ($patients as $patient)
<option value="{{ $patient->id }}"> {{ $patient->first_name }} {{ $patient->last_name }} ( {{ $patient->number }} )</option>
@endforeach
</select>
</div>
</div>
<div class="col">
<div class="form-group" style="padding-top: 5px;"><br>
{{ Form::button(__('pharmacy.submit'),['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10', 'id'=>'select_patient']) }}
</div>
</div>
</div>
<br>
@if(count($inpatients) > 0)
<h3><code>{{ __('pharmacy.ward') }}: {{ ($ward_id == 0 ? 'All wards' : get_name($ward_id, 'id', 'name', 'wards')) }}</code></h3>
@endif
@include('flash::message')
{{ Form::close() }}
</div>
</div>
@if(count($inpatients) > 0)
<div class="panel">
{{ Form::open(['route' => 'pharmacy.store_returned_drugs_per_chart', 'class' => 'typeahead', 'method' => 'ANY', "id"=>"return_drugs_chart"]) }}
<div class="panel-body">
<div class="row">
<div class="col-sm-12">
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table table-bordered">
<thead>
<tr>
<th>{{ __('pharmacy.patient_name') }}</th>
<th>{{ __('pharmacy.ward') }}</th>
<th>{{ __('pharmacy.date_of_admission') }}</th>
<th>{{ __('pharmacy.drugs') }}</th>
<th>{{ __('pharmacy.date_given') }}</th>
<th>{{ __('pharmacy.quantity_given') }}</th>
<th>{{ __('pharmacy.quantity_to_return') }}</th>
@if(count($inpatients[0]->batch_items) > 0) <th>{{ __('pharmacy.batch_to_return') }}</th>@endif
</tr>
</thead>
<tbody>
@if(count($inpatients) > 0)
@php $counter=0 @endphp
@foreach($inpatients as $in_patient)
<?php
//get the quantity given so far of this particular treatment
// $ward_treatment = \Streamline\Models\WardTreatmentDispensation::where(['patient_id' => $in_patient->patient_id, 'episode_id' => $in_patient->episode_id])->get();
?>
@if(count($in_patient->ward_treatment) > 0)
<tr>
<td rowspan="{{ count($in_patient->ward_treatment) }}">
{{ get_full_name($in_patient->patient_id, "id", "first_name", "last_name", "patients") }}
({{ get_name($in_patient->patient_id, "id", "number", "patients") }})
</td>
<td rowspan="{{ count($in_patient->ward_treatment) }}">
{{ get_name($in_patient->ward_id, "id", "name", "wards") }}
</td>
<td rowspan="{{ count($in_patient->ward_treatment) }}">
{{ streamline_date($in_patient->created_at) }}
</td>
<td>
{{ Form::hidden('patient_id[]',$in_patient->ward_treatment[0]->patient_id) }}
{{ Form::hidden('episode_id[]',$in_patient->ward_treatment[0]->episode_id) }}
{{ Form::hidden('inpatient_info_id[]',$in_patient->id) }}
{{ Form::hidden('drug_id[]', $in_patient->ward_treatment[0]->drug_id) }}
{{ Form::hidden('ward_treatment_dispensations_id[]', $in_patient->ward_treatment[0]->id) }}
{{ Form::hidden('ward_treatment_batch_id[]', $in_patient->ward_treatment[0]->batch_id) }}
{{ get_name($in_patient->ward_treatment[0]->drug_id, "id", "name", "drugs") }}
</td>
<td>
{{ streamline_date_time($in_patient->ward_treatment[0]->created_at) }} by {{ ucwords(get_full_name($in_patient->ward_treatment[0]->created_by, 'id', 'first_name', 'last_name', 'users')) }}
</td>
<td>
{{ Form::number('quantity_dispensed[]', $in_patient->ward_treatment[0]->quantity_given, ['class' => 'form-control', 'readonly']) }}
</td>
<td>
{{ Form::number('quantity_to_return[]', 0, ['class' => 'form-control batch_qty qty_'.$counter,'id'=>'batch_quantity_'.$counter]) }}
</td>
@if((count($in_patient->batch_items[0]??[]) > 0))
<td>
@php
$option_batches = "<option value=''>-select-</option>";
foreach ($in_patient->batch_items[0] as $value) {
$batch = get_batch_by_id($value);
$option_batches .= "<option value='$batch->id'>". $batch->batch_number." (Expiry Date: ".streamline_date_plain($batch->expiry_date).")</option>";
}
@endphp
<select name="batch_id[]" class="form-control batch_0" id="batch_0">
@php echo $option_batches; @endphp
</select>
</td>
@else
<td>{{ Form::hidden('batch_id[]',null,['id'=>'null'.$counter]) }}</td>
@endif
</tr>
@for($i = 1; $i < count($in_patient->ward_treatment); $i++)
@php $counter++ @endphp
{{ Form::hidden('patient_id[]',$in_patient->ward_treatment[$i]->patient_id) }}
{{ Form::hidden('episode_id[]',$in_patient->ward_treatment[$i]->episode_id) }}
{{ Form::hidden('drug_id[]', $in_patient->ward_treatment[$i]->drug_id) }}
{{ Form::hidden('ward_treatment_dispensations_id[]', $in_patient->ward_treatment[$i]->id) }}
{{ Form::hidden('ward_treatment_batch_id[]', $in_patient->ward_treatment[$i]->batch_id) }}
<tr>
<td>
{{ get_name($in_patient->ward_treatment[$i]->drug_id, "id", "name", "drugs") }}
</td>
<td>
{{ streamline_date_time($in_patient->ward_treatment[$i]->created_at) }} by {{ ucwords(get_full_name($in_patient->ward_treatment[$i]->created_by, 'id', 'first_name', 'last_name', 'users')) }}
</td>
<td>
{{ Form::number('quantity_dispensed[]', $in_patient->ward_treatment[$i]->quantity_given, ['class' => 'form-control', 'readonly']) }}
</td>
<td>
{{ Form::number('quantity_to_return[]', 0, ['class' => 'form-control batch_qty qty_'.$counter,'id'=>'batch_quantity_'.$counter]) }}
</td>
@if((count($in_patient->batch_items[$i]??[]) > 0))
<td>
@php
$option_batches = "<option value=''>-select-</option>";
foreach ($in_patient->batch_items[$i] as $value) {
$batch = get_batch_by_id($value);
$option_batches .= "<option value='$batch->id'>". $batch->batch_number." (Expiry Date: ".streamline_date_plain($batch->expiry_date).")</option>";
}
@endphp
<select name="batch_id[]" class="form-control batch_{{ $counter }}" id="batch_{{$counter}}" >
@php echo $option_batches; @endphp
</select>
</td>
@else
<td>{{ Form::hidden('batch_id[]',null,['id'=>'null'.$counter]) }}</td>
@endif
</tr>
@endfor
@php $counter++ @endphp
@endif
@endforeach
@endif
</tbody>
</table>
</div>
{{ Form::button(__('pharmacy.return_drugs'),['type'=>'button','class'=>'btn btn-success waves-effect waves-light m-r-10','id'=>'submit-drugs']) }}
</div>
</div>
</div>
{{ Form::close() }}
</div>
@endif
</div>
</div>
</div>
</div>
</div>
<div class="modal fade modal_diagnosis " id="confirm_return_modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
<div class="modal-dialog" style="max-width: 60%;" role="document">
<div class="modal-content">
<div class="modal-body form-group">
<h4 class="modal-title" id="exampleModalLabel1">{{ __('pharmacy.confirm_return_drug') }}</h4>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default mr-auto" data-dismiss="modal">{{ __('triage.cancel') }}</button>
<a class="btn btn-success" id="return_drugs">{{ __('pharmacy.return_drugs') }}</a>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<!-- data time picker dependency -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<!-- add datatables -->
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
<script type="text/javascript">
$('#patient_number').change(function () {
let id = $('#patient_number').val();
$('#patient_id').val(id);
});
$('#patient_number').select2({
placeholder: 'Search by patient details (names and number)',
});
$(document).ready(function() {
$('#datepicker-autoclose,#datepicker-autoclose-1,#datepicker-autoclose-2').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy'
});
$('#submit-drugs').click(function(){
$('#confirm_return_modal').modal('toggle');
});
$('#return_drugs').click(function(){
let isValid = true;
let firstEmptyField = null;
// Check each required field in the form
$('#return_drugs_chart').find(':input[required]').each(function() {
if (!$(this).val()) {
isValid = false;
if (firstEmptyField === null) {
firstEmptyField = $(this); // Save the first empty field
}
} else {
}
});
// Focus on the first empty field if there are any missing fields
if (!isValid) {
$('#confirm_return_modal').modal('hide');
firstEmptyField.focus();
alert("Please fill in all required fields.");
} else {
$('#return_drugs_chart').submit();
}
})
$('#search_by').change(function () {
if ($(this).val() == 1) {
$('#date_search').show();
$('#date_range_search').hide();
}
else if ($(this).val() == 2) {
$('#date_range_search').show();
$('#date_search').hide();
}
else {
$('#date_search,#date_range_search').hide();
}
});
$(document).on("change keyup", ".batch_qty, .new_batch_qty", function () {
var id = /\d+(?=\D*$)/.exec($(this).attr('class')) || [];
var value = $(this).val();
if (id.length > 0) id = id[0];
console.log(id);
if(value != 0){
$('#batch_'+id).attr('required', true);
}else{ $('#batch_'+id).removeAttr('required');}
});
$('.select2-selection.select2-selection--single').css('height','calc(3.85rem)');
$('.select2-selection.select2-selection--single').css('padding-top','5px');
//$('.select2-selection.select2-selection--single').css('border-left', '3px solid #F08080');/*add compulsory class*/
$('.select2-selection.select2-selection--single.sec_d').css('border-left', '3px solid #aaa');
$('.select2-selection__arrow').css('top','3px');
});
</script>
@endpush
@@ -0,0 +1,130 @@
@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/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
<h4 class="page-title">{{ __('pharmacy.saved_for_requisition') }}</h4>
</div>
<div class="col-lg-8 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="{{ route('pharmacy.index') }}">{{ __('pharmacy.pharmacist') }}</a></li>
<li class="active">{{ __('pharmacy.saved_for_requisition') }}</li>
</ol>
</div>
</div>
@include('flash::message')
<div class="row">
<div class="col-sm-12">
<div class="white-box">
<div class="row">
@if(is_object($results) || is_array($results))
<div class="col-sm-12">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th style="width: 30%">{{ __('pharmacy.requisition_number') }}</th>
<th style="width: 30%">{{ __('stores.number_of_items') }}</th>
<th style="width: 30%">{{ __('pharmacy.date_started') }}</th>
<th style="width: 30%">{{ __('stores.requisitioned_by') }}</th>
<th style="width: 5%"></th>
<th style="width: 5%"></th>
</tr>
</thead>
<tfoot>
<tr>
<th style="width: 30%">{{ __('pharmacy.requisition_number') }}</th>
<th style="width: 30%">{{ __('stores.number_of_items') }}</th>
<th style="width: 30%">{{ __('pharmacy.date_started') }}</th>
<th style="width: 30%">{{ __('stores.requisitioned_by') }}</th>
<th style="width: 5%"></th>
<th style="width: 5%"></th>
</tr>
</tfoot>
<tbody>
@foreach($results as $result)
@php $quantity_explode = explode(",", $result->quantity_requested); @endphp
<tr>
<td># {{ sprintf('%04u', $result->id) }}</td>
<td>{{ count(array_filter($quantity_explode)) }}</td>
<td>{{ streamline_date_time($result->created_at) }}</td>
<td>{{ get_full_name($result->created_by, "id", "first_name", "last_name", "users") }}</td>
<td>
<form name="form" action="{{ url('edit_temporary_requisition') }}" method="post">
{{ csrf_field() }}
<input type="hidden" name="item_type" value="{{ $quotation_type }}">
<input type="hidden" name="requisition_id" id="requisition_id" value="{{ $result->id }}"/>
<button type="submit" name="issue_button" class="btn btn-success btn-sm">{{ __('pharmacy.resume_requisition') }}</button>
</form>
</td>
<td>
@if(Auth::user()->can('delete-store-requisition')) <a class="btn btn-danger btn-sm" href="pharmacy/delete_temporary_requisition/{{ $result->id }}">{{ __('pharmacy.cancel_requisition') }}</a> @endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
@else
<div class="col-sm-3 form-group">
{{ Form::open(['method' => 'post', 'route'=>'pharmacy.select_temporary_requisition'])}}
{{ Form::label('quotation_type', __('pharmacy.requisition_type')) }}
{{ Form::select('quotation_type', $quotation_type_options , null, ['class'=>'form-control compulsory', 'required']) }}
<div class="help-block with-errors"></div>
</div>
<div class="col-sm-3 form-group" style="padding-top: 28px;">
{{ Form::button(__('pharmacy.view_saved_for_later'),['type'=>'submit','class'=>'btn btn-info btn-rounded waves-effect waves-light m-r-10']) }}
</div>
{{ Form::close() }}
@endif
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<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>
<!-- data time piker dependency -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<!-- -->
<script type="text/javascript">
$('.table').DataTable({
dom: 'Bfrtip',
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
});
</script>
@endpush
@push('styles')
<!-- <style type="text/css">
th,td{
border-left: 1px solid #dddddd;
}
tr{
border-right: 1px solid #dddddd;
}
</style> -->
@endpush
@@ -0,0 +1,183 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@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">{{ __('pharmacy.pharmacy_stock_sheet') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="/pharmacy">{{ __('pharmacy.incoming_prescriptions') }}</a></li>
<li class="active">{{ __('pharmacy.pharmacy_stock_sheet') }}</li>
</ol>
</div>
</div>
@include('flash::message')
<div class="white-box">
@php
$total_cost_value = 0;
@endphp
<hr>
<div class="table-responsive">
<table class="table success-table table-sm table-striped table-hover">
<thead>
<tr>
<th style="width: 30%">{{ __('pharmacy.item_name') }}</th>
@if(track_items_using_batches())<th class="shown_input">{{ __('stores.batch_details') }}</th>@endif
<th style="width: 15%">{{ __('pharmacy.pharmacy_stock') }}</th>
<th style="width: 15%">{{ __('pharmacy.cost_value') }}</th>
<th style="width: 15%">{{ __('pharmacy.selling_price') }}</th>
<th style="width: 15%">{{ __('pharmacy.sale_value') }}</th>
</tr>
</thead>
<tfoot>
<tr>
<th style="width: 30%">{{ __('pharmacy.item_name') }}</th>
@if(track_items_using_batches())<th class="shown_input">{{ __('stores.batch_details') }}</th>@endif
<th style="width: 15%">{{ __('pharmacy.pharmacy_stock') }}</th>
<th style="width: 15%">{{ __('pharmacy.cost_value') }}</th>
<th style="width: 15%">{{ __('pharmacy.selling_price') }}</th>
<th style="width: 15%">{{ __('pharmacy.sale_value') }}</th>
</tr>
</tfoot>
<tbody>
@php $cost_value = 0; $sale_value = 0; @endphp
@foreach($drugs as $drug)
<tr>
<td>
@if($drug->insurance_coverage == 1)
<span style="color: green;"> {{ $drug->name }} </span>
@else
<span style="color: orange;"> {{ $drug->name }} </span>
@endif
</td>
@php
$drug_pharmacy_stock = 0;
$item_cost_value = 0;
@endphp
@if(track_items_using_batches())
<td id="div_to_append_{{ $drug->id }}">
@php
$batch_records = \Streamline\Models\ItemBatchWatcher::where(['item_type' => 1, 'item_id' => $drug->id])->where('pharmacy_stock', '!=', 0)->get();
@endphp
@if(count($batch_records) > 0)
@foreach($batch_records as $record)
<div class="row" style="background-color: #e1e1ef; border-radius: 5px 5px; border: 2px #c4b7b7 solid; margin-bottom: 2px;">
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.batch') }}: </b>{{ $record->batch_number }}
</div>
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.quantity') }}: </b>{{ $record->pharmacy_stock }}<br>
@php
$drug_pharmacy_stock += $record->pharmacy_stock;
@endphp
<b>{{ __('stores.expiry_date') }}: </b>{{ $record->expiry_date }}
</div>
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.unit_cost') }}: </b>{{ $record->cost_price }}
</div>
</div>
@php
$item_cost_value += $record->cost_price * $record->pharmacy_stock;
@endphp
@endforeach
@endif
<div class="row show_on_edit" style="display: none;" id="add_batch_{{ $drug->id }}"><a href="#">{{ __('stores.add_batch_small') }}<div>
</td>
@endif
<td>
<div class="shown_input">
{{ $drug_pharmacy_stock }}
</div>
<div class="hidden_input" style="display: none;">
<input type="hidden" name="drug_id[]" value="{{ $drug->id }}">
<input type="text" name="quantity[]" class="form-control" value="{{ $drug_pharmacy_stock }}" readonly>
</div>
</td>
<td>{{ ugandan_shillings($item_cost_value) }}</td>
<td>{{ ugandan_shillings($drug->non_insured_price) }}</td>
<td>{{ ugandan_shillings($drug->non_insured_price * $drug_pharmacy_stock) }}</td>
@php
$total_cost_value += $item_cost_value;
$sale_value += ($drug->non_insured_price * $drug_pharmacy_stock);
@endphp
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
<td></td>
@if(track_items_using_batches())<td>{{ __('stores.batch_details') }}</td>@endif
<td class="shown_input"></td>
<td>{{ ugandan_shillings($total_cost_value) }}</td>
<td></td>
<td>{{ ugandan_shillings($sale_value) }}</td>
</tr>
</tfoot>
</table>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.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>
$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
],
drawCallback: function( settings ) {
console.log('DataTables has redrawn the table' );
showActivateDates();
}
});
function showActivateDates(){
$('.date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'yyyy-mm-dd',
});
}
$('#edit_stock').click(function(e){
e.preventDefault();
$('.hidden_input, #cancel_edit,#save_stock, .expiry_date_input').show();
$('.shown_input, .expiry_date').hide();
$(this).hide();
});
/* $('.date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'yyyy-mm-dd'
}); */
</script>
@endpush
@@ -0,0 +1,637 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
<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/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
@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">{{ __('layout.sundries_stock_reconciliation') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('home.dashboard') }}</a></li>
<li><a href="{{ route('stores.index') }}">{{ __('stores.stores') }}</a></li>
<li class="active">{{ __('layout.sundries_stock_reconciliation') }}</li>
</ol>
</div>
</div>
<!--Flash messages at the top -->
@include('flash::message')
<div class="white-box">
{{ Form::open(['route' => 'pharmacy.sundries_stock_reconciliation', 'method' => 'ANY', 'role' => 'search']) }}
<div class="row">
<div class="col-md-6">
<div class="form-group" id="sundry_names">
{{ Form::select('search_items_ids[]',$sundries_dropdown,'',['id'=>'sundry_ids', 'multiple'=>true, 'class' => 'form-control col-sm-8 sundry_ids']) }}
</div>
</div>
<div class="col-md-6">
<button type="submit" class="btn btn-info"><span class="glyphicon glyphicon-search"></span> Select items to reconcile</button>
</div>
</div>
{{ Form::close() }}
</div>
<div class="white-box">
<form action="{{ url('store_pharmacy_sundries_stock_count') }}" method="POST" name="pharmacy_stock_form" id="pharmacy_stock_form">
{{ csrf_field() }}
<div class="row">
<div class="col-sm-12">
<p class="text-muted m-b-30">{{ __('stores.export_data_to_csv_excel_pdf') }}</p>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>{{ __('stores.sundry_name') }}</th>
<td>{{ __('stores.batch_details_and_others') }}</td>
<th>{{ __('pharmacy.pharmacy_system_stock') }}</th>
<th>{{ __('pharmacy.pharmacy_physical_stock') }}</th>
<th>{{ __('stores.difference') }}</th>
<th class="hidden_input" style="display: none;">{{ __('pharmacy.expiry_date') }}</th>
<th>{{ __('stores.variance_in_stock') }}</th>
<th>{{ __('stores.reason_for_difference') }}</th>
<th>{{ __('stores.selling_price') }}</th>
<th class="hidden_input" style="display: none;">{{ __('stores.is_it_initial_stock') }}</th>
</tr>
</thead>
<tfoot>
<tr>
<th>{{ __('stores.sundry_name') }}</th>
<td>{{ __('stores.batch_details_and_others') }}</td>
<th>{{ __('pharmacy.pharmacy_system_stock') }}</th>
<th>{{ __('pharmacy.pharmacy_physical_stock') }}</th>
<th>{{ __('stores.difference') }}</th>
<th class="hidden_input" style="display: none;">{{ __('pharmacy.expiry_date') }}</th>
<th>{{ __('stores.variance_in_stock') }}</th>
<th>{{ __('stores.reason_for_difference') }}</th>
<th>{{ __('stores.selling_price') }}</th>
<th class="hidden_input" style="display: none;">{{ __('stores.is_it_initial_stock') }}</th>
</tr>
</tfoot>
<tbody>
<tr class="hidden_input" style="display: none;">
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td class="hidden_input" style="display: none;"></td>
<td>
<b>{{ __('stores.select_all') }}</b>
</td>
<td>
<input type="checkbox" id="select_all_as_initial_stock" name="select_all_as_initial_stock">
</td>
</tr>
@foreach($sundries as $sundry)
@php
$sundry_pharmacy_stock = 0;
$batch_records = \Streamline\Models\ItemBatchWatcher::where(['item_type' => 2, 'item_id' => $sundry->id])->where('pharmacy_stock', '!=', 0)->get();
if (count($batch_records) > 0) {
foreach ($batch_records as $batch_record) {
$sundry_pharmacy_stock += $batch_record->pharmacy_stock;
}
}
@endphp
<tr>
<td>
@if($sundry->insurance_coverage == 1)
<span style="color: green;"> {{ $sundry->name }} </span>
@else
<span style="color: orange;"> {{ $sundry->name }} </span>
@endif
</td>
<td id="div_to_append_{{ $sundry->id }}">
@if(count($batch_records) > 0)
@foreach($batch_records as $record)
<div class="row" style="border: 2px solid #cbd1da; margin-bottom: 2px;" id="div_for_{{ $sundry->id }}_{{ $record->batch_number }}">
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px;">
{{ Form::hidden('item_batch_watcher_id[]', $record->id) }}
{{ Form::hidden('batch_sundry_id[]', $sundry->id, ['class' => 'batch_id_class_'.$sundry->id]) }}
<input type="hidden" name="" value="{{ $record->pharmacy_stock }}" id="batch_quantity_{{ $record->id }}">
<input type="hidden" name="" value="0" class="batch_variance_balance_{{ $sundry->id }}" id="variance_batch_cost_{{ $record->id }}">
<div class="shown_input">
<b>{{ __('stores.batch') }}:</b> <span id="shown_batch_{{ $record->batch_number }}">{{ $record->batch_number }}</span>
</div>
<div class="hidden_input" style="display: none;">
{{ Form::text('batch_number[]', $record->batch_number, ['class' => 'form-control batch_number_'.$sundry->id, 'readonly' => 'true']) }}
</div>
</div>
<div class="col-sm-12 shown_input" style="word-wrap:break-word;padding: 0px;">
<b>{{ __('stores.unit_cost') }}: </b>{{ $record->cost_price }}
</div>
<div class="col-sm-12" style="padding: 0px;">
<div class="shown_input">
<b>{{ __('stores.quantity') }}:</b><font color="blue">{{ $record->pharmacy_stock }}</font> <br/>
@if(Auth::user()->can('remove-batch-during-stock-reconciliation'))
{{-- <small>
@php
$batch_no = $record->batch_number;
$sundry_id = $sundry->id;
@endphp
<a href="#" style="color: red;" onclick="deleteBatch({{ $sundry_id }}, '{{ $batch_no }}')">Remove batch</a>
</small> --}}
@endif
@if(Auth::user()->can('edit-batch-during-stock-reconciliation'))
<small>
@php
$batch_no = $record->batch_number;
$sundry_id = $sundry->id;
@endphp
<a href="#" id="{{ $batch_no }}" style="color: red;" onclick="editBatch({{ $sundry_id }}, $(this).attr('id'))">{{ __('stores.edit_batch') }}</a>
</small>
@endif
</div>
<div class="hidden_input" style="display: none;">
<span style="display:flex;width:25rem;">
@if(Auth::user()->can('edit-unit-cost-during-pharmacy-sundries-stock-reconciliation'))
{{ Form::text('batch_unit_cost[]', $record->cost_price, ['class' => 'form-control batch_unit_cost_'.$sundry->id.'','id'=>'batch_unit_cost_'.$record->id.'']) }}
@else
{{ Form::text('batch_unit_cost[]', $record->cost_price, ['class' => 'form-control batch_unit_cost_'.$sundry->id.'','id'=>'batch_unit_cost_'.$record->id.'','readonly']) }}
@endif
{{ getCurrencyCode() }}
</span>
</div>
<div class="hidden_input" style="display: none;">
<span style="display:flex;width:25rem;">
<input type="number" name="batch_quantity_balance[]" value="{{ $record->pharmacy_stock }}" class="form-control batch_qty batch_quantity_balance_{{ $sundry->id }}" id="batch_quantity_balance_{{ $record->id }}">
QTY
</span>
</div>
</div>
<div class="col-sm-12" style="padding: 0px;">
<div class="shown_input">
<b>{{ __('stores.expiry_date') }}:</b> <span>{{ $record->expiry_date }}</span>
</div>
<div class="hidden_input" style="display: none;">
<div class="input-group">
<input type="text" name="expiry_date[]" value="{{ $record->expiry_date }}" autocomplete="off" class="form-control expiry_date_input">
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
@endforeach
@else
<div class="row" style="border: 2px solid #cbd1da">
<div class="col-sm-12" style="padding: 0px;">
{{ Form::hidden('item_batch_watcher_id[]', 0) }}
{{ Form::hidden('batch_sundry_id[]', $sundry->id) }}
<div class="shown_input">
<!-- kk -->
</div>
<div class="hidden_input" style="display: none;">
{{ Form::text('batch_number[]', '', ['class' => 'form-control col-sm-12 new_batch_number_'.$sundry->id, 'placeholder' => 'Batch']) }}
</div>
</div>
<div class="col-sm-12" style="padding: 0px;">
<div class="hidden_input" style="display: none;">
<span style="display:flex;width:25rem;">
{{ Form::text('batch_unit_cost[]', 0, ['class' => 'form-control new_batch_unit_cost_'.$sundry->id.'', 'placeholder' => 'Unit cost']) }}
{{ getCurrencyCode() }}
</span>
</div>
</div>
<div class="col-sm-12" style="padding: 0px;">
<div class="shown_input">
<!-- kk -->
</div>
<div class="hidden_input" style="display: none;">
<span style="display:flex;width:22rem;">
<input type="number" name="batch_quantity_balance[]" class="form-control col-md-12 new_batch_qty new_batch_quantity_balance_{{ $sundry->id }}" placeholder="Quantity">
QTY
</span>
</div>
</div>
<div class="col-sm-12" style="padding: 0px;">
<div class="hidden_input" style="display: none;">
<div class="input-group">
<input type="text" name="expiry_date[]" autocomplete="off" placeholder="Expiry date" class="form-control col-md-12 expiry_date_input">
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
@endif
<div class="row show_on_edit" style="display: none;" id="add_batch_{{ $sundry->id }}"><a href="#">{{ __('stores.add_batch_small') }}<div>
</td>
<td>
<div>
{{ $sundry_pharmacy_stock }}
<div class="hidden_input" style="display: none;">
<input type="hidden" name="sundry_id[]" value="{{ $sundry->id }}">
<input type="hidden" class="form-control" id="cost_price_{{ $sundry->id }}" name="cost_price[]" value="{{ $sundry->cost_price }}">
</div>
<input type="hidden" name="system_stock[]" class="form-control" id="system_stock_{{ $sundry->id }}" value="{{ $sundry_pharmacy_stock }}">
</div>
</td>
<td>
<div class="shown_input" id="shown_input_{{ $sundry->id }}">
{{ $sundry_pharmacy_stock }}
</div>
<div class="hidden_input" style="display: none;">
<input type="number" name="physical_stock[]" class="form-control" id="physical_stock_{{ $sundry->id }}" value="{{ $sundry_pharmacy_stock }}" onblur="calculateDifference({{ $sundry->id }},{{ $sundry->cost_price}}, {{ $sundry->non_insured_price}},{{ $sundry_pharmacy_stock}});" readonly>
</div>
</td>
<td>
<input type="text" name="difference[]" class="form-control" id="difference_in_stock_{{ $sundry->id }}" readonly>
</td>
<td class="hidden_input" style="display: none;">
{{-- <input type="text" name="expiry_date[]" value="{{ $sundry->expiry_date }}" class="form-control col-md-12 expiry_date_input" readonly> --}}
</td>
<td>
<div id="difference_in_cost_value_{{ $sundry->id }}">
</div>
<input type="hidden" name="difference_in_cost_value[]" class="form-control" id="difference_in_cost_value_input_{{ $sundry->id }}">
</td>
<td>
<textarea class="hidden_input" style="display: none;" name="reason_for_difference[]" class="form-control"></textarea>
</td>
<td>
<div>
{{ ugandan_shillings($sundry->non_insured_price) }}
</div>
</td>
<td class="hidden_input" style="display: none;">
@if(is_null($sundry->pharmacy_opening_stock))
<input type="checkbox" name="is_initial_stock[]" class="initial_stock_checkboxes" value="{{ $sundry->id }}">
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
<div class="form-group row">
<div class="col-sm-12"><br><hr></div>
<div class="col-sm-3">
<div class="input-group">
<input type="text" name="reconciliation_date" placeholder="Reconciliation date" class="form-control col-sm-12" id="reconciliation_date" autocomplete="off" required>
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
<div class="col-sm-3">
<div style="float: right; padding-top: 5px; font-size: 14px;">
{{ Form::label('account_id', __('stores.general_comment')) }}
</div>
</div>
{{-- <div class="col-sm-3">
{{ Form::text('account_id', $stock_adjustment_chart_of_account->name, ['class' => 'form-control', 'id' => 'account_id']) }}
<div class="help-block with-errors"></div>
</div> --}}
<div class="col-sm-6">
{{ Form::textarea('general_comment','',['class' => 'form-control', 'placeholder' => __('pharmacy.add_general_comment'), 'rows' => 4]) }}
</div>
<div class="col-sm-12">
<hr>
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">×</button>
<span>
<strong>{{ __('pharmacy.note') }}:</strong>
{{ __('pharmacy.stock_differences_are_reflected_in') }} <b>{{ $stock_adjustment_chart_of_account->name }}</b> {{ __('pharmacy.if_it_is_not_opening_stock') }}. {!! __('pharmacy.if_it_is_the_opening_stock_then_the_affected_account') !!}
</span>
</div>
</div>
{{-- <div class="col-sm-4">
<div style="float: right; padding-top: 5px; font-size: 16px;">
{{ Form::label('account_id', __('stores.select_chart_of_account_affected')) }}
</div>
</div>
<div class="col-sm-4">
{{ Form::select('account_id', $chart_of_accounts, null, ['class' => 'form-control', 'id' => 'account_id']) }}
<div class="help-block with-errors"></div>
</div>
<div class="col-sm-4">
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">×</button>
<span>
This is the account that will be affected by the variances incase it is not the intial stock take of the sundry
</span>
</div>
</div> --}}
</div>
</div>
<div class="col-sm-1">
<div style="float: right; position: absolute; bottom: 0;">
<button class="btn btn-default" id="cancel_edit" style="display: none;">{{ __('stores.cancel') }}</button>
<button class="btn btn-success" id="edit_stock" style="margin-bottom: 0px;">{{ __('stores.edit_stock') }}</button>
<!-- <input type="submit" name="save_stock" value="{{ __('stores.save_for_later') }}" class="btn btn-success btn-lg" id="save_stock" style="display: none;"><br><br> -->
<input type="submit" name="reconcile_stock" value="{{ __('stores.reconcile') }}" class="btn btn-success btn-lg" id="reconcile_stock" style="display: none;">
</div>
</div>
</div>
</form>
</div>
<div class="modal fade" id="editBatchModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="exampleModalLabel1"><br><br>{{ __('stores.edit_batch') }}</h4>
</div>
<div class="modal-body">
{{ Form::hidden('batch_record_id', '', ['class' => 'form-control', 'id' => 'batch_record_id',]) }}
{{ Form::hidden('original_drug_id', '', ['class' => 'form-control', 'id' => 'original_drug_id',]) }}
{{ Form::text('original_batch_number', '', ['class' => 'form-control', 'id' => 'original_batch_number', 'readonly']) }}
<br><br>
{{ Form::text('new_batch_number_edit', '', ['class' => 'form-control', 'id' => 'new_batch_number_edit', 'placeholder' => __('stores.new_batch_number')]) }}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ __('triage.cancel') }}</button>
<a class="btn btn-success" id="submitNewBatchNumber">{{ __('stores.submit') }}</a>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.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/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
],
drawCallback: function( settings ) {
console.log('DataTables has redrawn the table' );
showHiddenInputs();
}
});
$('.sundry_ids').select2({
placeholder: "Select"
});
$('#edit_stock').click(function(e){
e.preventDefault();
$('.hidden_input,#save_stock,#reconcile_stock,.show_on_edit').show();
$('.shown_input').hide();
$(this).hide();
});
function editBatch(batchRecordId, drugId, batchNumber){
console.log(batchNumber);
event.preventDefault();
console.log("drug id ====== " + drugId);
console.log("batch number ======= " + batchNumber);
$("#original_drug_id").val(drugId);
$("#batch_record_id").val(batchRecordId);
$("#original_batch_number").val(batchNumber);
$("#editBatchModal").modal("show");
}
function showHiddenInputs(){
if($('#edit_stock').css('display') == 'none'){
$('.hidden_input,#save_stock,#reconcile_stock,.show_on_edit').show();
$('.shown_input').hide();
$(this).hide();
}
}
// $('body').delegate('#edit_stock', 'click', function (e) {
// e.preventDefault();
// $('.hidden_input,#save_stock,#reconcile_stock').show();
// $('.shown_input').hide();
// $(this).hide();
// });
var created_at = {!! json_encode(calculate_back_date()) !!}
$('#reconciliation_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy',
startDate: new Date(created_at),
endDate:new Date(),
readOnly: true
});
$('.expiry_date_input').datepicker({
autoclose: true,
todayHighlight: true,
format: 'yyyy-mm-dd',
});
$(document).on("change keyup", ".batch_qty, .new_batch_qty, .batch_quantity_balance, .new_batch_quantity_balance, .batch_unit_cost, .new_batch_unit_cost", function () {
var id = /\d+(?=\D*$)/.exec($(this).attr('class')) || [];
var id_unit_cost = /\d+(?=\D*$)/.exec($(this).attr('id')) || [];
if (id.length > 0) id = id[0];
if (id_unit_cost.length > 0) id_unit_cost = id_unit_cost[0];
var total_quantity = 0;
var variance_cost_per_batch = 0;
var original_stock_batch = parseFloat($('#batch_quantity_' + id_unit_cost).val()) || 0;
var unit_cost = parseFloat($('#batch_unit_cost_' + id_unit_cost).val()) || 0;
// Calculate for existing batches
$(".batch_quantity_balance_" + id).each(function () {
var batch_qty = parseInt($(this).val()) || 0;
total_quantity += batch_qty;
});
// Calculate variance for existing batches
$("#batch_quantity_balance_" + id_unit_cost).each(function () {
var batch_qty = parseInt($(this).val()) || 0;
var variance_per_batch = batch_qty - original_stock_batch;
var variance_cost_batch = unit_cost * variance_per_batch;
$('#variance_batch_cost_' + id_unit_cost).val(variance_cost_batch);
});
// Calculate for new batches
var unit_costs = [];
$('.new_batch_unit_cost_' + id).each(function () {
unit_costs.push(parseFloat($(this).val()) || 0); // Ensure it's a float, default to 0 if not a number
});
$(".new_batch_quantity_balance_" + id).each(function (index) {
var batch_qty = parseInt($(this).val()) || 0;
var unit_cost = unit_costs[index] || 0; // Use corresponding unit cost
var variance = batch_qty * unit_cost;
total_quantity += batch_qty;
variance_cost_per_batch += variance;
});
$(".batch_variance_balance_"+id).each(function () {
var batch_cost = parseInt($(this).val());
variance_cost_per_batch += batch_cost;
});
// Update the total quantities and variance costs
$("#shown_input_" + id).text(total_quantity);
$("#physical_stock_" + id).val(total_quantity);
$("#difference_in_cost_value_input_" + id).val(variance_cost_per_batch);
$("#difference_in_cost_value_" + id).html(variance_cost_per_batch + " Ugx");
// Call the calculateDifference function
var drug_cost = parseFloat($("#cost_price_" + id).val()) || 0;
var drug_price = parseFloat($("#non_insured_price_" + id).val()) || 0;
var drug_system_stock = parseInt($("#system_stock_" + id).val()) || 0;
calculateDifference(id, drug_cost, drug_price, drug_system_stock);
});
$('#select_all_as_initial_stock').change(function() {
if (this.checked === true) {
$(".initial_stock_checkboxes").each(function() {
this.checked = true;
});
} else {
$(".initial_stock_checkboxes").each(function() {
this.checked = false;
});
}
});
$('#reconcile_stock').click(function(e){
var empty_compulsory_fields = [];
$(".initial_stock_checkboxes").each(function () {
if (this.checked === false) {
not_initial_stocks_selects = $(this).text();
empty_compulsory_fields.push(not_initial_stocks_selects);
$(this).css('border','1px solid #F08080');
}
});
/* check if the array containing empty compulsory fields is not empty then return false */
if (empty_compulsory_fields.length != 0 && $("#account_id").val() === "") {
alert("<?php echo __('stores.please_select_account') ?>");
$("#account_id").focus();
$("#account_id").css('border','1px solid #F08080');
e.preventDefault();
return false;
}
});
$("#submitNewBatchNumber").click(function(e){
let drugId = $("#original_drug_id").val();
let originalBatchRecordId = $("#batch_record_id").val();
let originalBatchNumber = $("#original_batch_number").val();
let newBatchNumberEdit = $("#new_batch_number_edit").val();
console.log("drugId=="+drugId+" originalBatchNumber=="+originalBatchNumber+" newBatchEdit=="+newBatchNumberEdit);
$.ajax({
method: 'POST',
url: '/editing_item_batch_number',
data: {'item_id' : drugId, 'original_batch_record_id': originalBatchRecordId, 'original_batch_number': originalBatchNumber, 'new_batch_number_edit': newBatchNumberEdit, 'item_type': 1},
success: function(response){
if(response == 1){
alert('batch ' + originalBatchNumber +' has been successfully edited');
$("#shown_batch_"+originalBatchNumber).html(newBatchNumberEdit);
$("#editBatchModal").modal("hide");
$("#"+originalBatchNumber).attr("id",newBatchNumberEdit);
$("#new_batch_number_edit").val("");
} else if(response == 0){
alert('system could not complete batch edit the batch');
}
},
error: function(jqXHR, textStatus, errorThrown) {
alert(JSON.stringify(jqXHR));
console.log(JSON.stringify(jqXHR));
}
});
});
function calculateDifference(sundryId,sundryCost,sundryPrice,stockQuantity) {
var systemStockValue = $("#system_stock_" + sundryId).val();
var physicalStockValue = $("#physical_stock_" + sundryId).val();
var difference = physicalStockValue - systemStockValue;
var differenceInCostValue = difference * sundryCost;
var salesInMoneyValue = systemStockValue * sundryPrice;
$("#difference_in_stock_" + sundryId).val(difference);
// $("#difference_in_cost_value_" + sundryId).html(differenceInCostValue + " Ugx");
// $("#difference_in_cost_value_input_" + sundryId).val(differenceInCostValue);
calculateShrinkage(sundryId,salesInMoneyValue,physicalStockValue,differenceInCostValue);
}
function calculateShrinkage(sundryId,systemStockMoneyValue,physicalStockMoneyValue,differenceInCostValue) {
var shrinkage = systemStockMoneyValue - physicalStockMoneyValue;
systemStockMoneyValue = parseInt(systemStockMoneyValue, 10);
var shrinkagePercentage = 0;
if (systemStockMoneyValue === 0) {
shrinkagePercentage = 0;
} else {
shrinkagePercentage = differenceInCostValue/systemStockMoneyValue * 100;
}
$("#shrinkage_" + sundryId).html(shrinkagePercentage.toFixed(2));
$("#shrinkage_input_" + sundryId).val(shrinkagePercentage.toFixed(2));//fill hidden input with value
}
$("[id^='add_batch_']").on("click", function (e) {
e.preventDefault();
var id = /\d+(?=\D*$)/.exec($(this).attr('id'));
console.log("clicked div to append == " + id);
var code= {!! json_encode(getCurrencyCode()) !!}
$("#div_to_append_"+id).prepend(`
<div class='row appended_div_row' style='border: 2px solid #cbd1da'>
<div class='col-sm-12' style='padding: 0px;'>
<input type='hidden' name='item_batch_watcher_id[]' value='0'/>
<input type='hidden' name='batch_quotation_id[]' value='0'/>
<input type='hidden' name='batch_sundry_id[]' value='${id}'>
<input type='hidden' name='is_initial_stock[]' value='${id}'>
<input type="hidden" name="" value="0" class="batch_variance_balance_${id}" id="new_variance_batch_cost">
<div class='hidden_input'>
<input type='text' name='batch_number[]' class='form-control col-sm-12 new_batch_number_${id}' placeholder='Batch'>
</div>
</div>
<div class='col-sm-12' style='padding: 0px;'>
<div class='hidden_input'>
<span style="display:flex;width:22rem;">
<input type='number' name='batch_unit_cost[]' value='0' class='form-control col-md-12 new_batch_unit_cost new_batch_unit_cost_${id}' placeholder='Unit cost'>
${code}
</span>
</div>
</div>
<div class='col-sm-12' style='padding: 0px;'>
<div class='hidden_input'> <span style="display:flex;width:22rem;"><input type='number' name='batch_quantity_balance[]' class='form-control col-md-12 new_batch_qty new_batch_quantity_balance_${id}' placeholder='Quantity'>
QTY</span>
</div>
</div>
<div class='col-sm-12' style='padding: 0px;'>
<div class='hidden_input'>
<div class='input-group'>
<input type='text' name='expiry_date[]' autocomplete='off' placeholder='Expiry date' class='form-control col-md-12 expiry_date_input'>
<span class='input-group-addon'><i class='icon-calender'></i></span>
</div>
</div>
</div>
</div>`);
});
$("[id^='div_to_append_']").on("focus", ".expiry_date_input", function (e) {
$(this).datepicker({
autoclose: true,
todayHighlight: true,
format: 'yyyy-mm-dd'
});
});
</script>
@endpush
@@ -0,0 +1,185 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<!-- <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" />
@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">{{ __('layout.sundries_stock_reconciliation_report') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li class="active">{{ __('layout.sundries_stock_reconciliation_report') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="panel panel-default">
<div class="panel-body">
{{ Form::open(['method'=>'post','route' => 'pharmacy.sundries_stock_reconciliation_report']) }}
<br/>
<h3>{{ __('pharmacy.select_a_date_range') }}</h3>
<br/>
<div class="form-group">
<select class="form-control compulsory required" name="dates" id="dates" required>
<option value="">-select-</option>
<option value="today">{{ __('pharmacy.today') }}</option>
<option value="yesterday">{{ __('pharmacy.yesterday') }}</option>
<option value="custom_date">{{ __('pharmacy.custom_date') }}</option>
<option value="custom_date_range">{{ __('pharmacy.date_range') }}</option>
</select>
</div>
<div id="sDate" style="display: none;">
<div class="form-group">
{{ Form::label('start_date', __('pharmacy.date_on')) }}
<div class="input-group">
{{ Form::text('start_date', '', ['class'=>'form-control required compulsory', 'readonly', 'id'=>'start_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div id="eDate" style="display: none;">
<div class="form-group">
{{ Form::label('end_date', __('pharmacy.end_date')) }}
<div class="input-group">
{{ Form::text('end_date', '', ['class'=>'form-control required compulsory', 'readonly', 'id'=>'end_date']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="form-group">
{{ Form::submit(__('pharmacy.submit'), ['class'=>'btn btn-success pull-right']) }}
</div>
{{ Form::close() }}
</div>
</div>
</div>
<!-- <div class="col-xs-1"></div> -->
<div class="col-md-9">
<div class="row">
<div class="panel panel-default col-md-12">
<div class="panel-body panel-primary">
<br/>
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('pharmacy.date') }}</th>
<th>{{ __('pharmacy.staff_in_charge') }}</th>
<th>{{ __('pharmacy.reconciliation_id') }}</th>
<th>{{ __('pharmacy.action') }}</th>
</tr>
@php
$counter = 0;
@endphp
</thead>
<tbody>
@if(count($reconciled_stocks) > 0)
@foreach($reconciled_stocks as $record)
<tr>
<td>{{ streamline_date($record->created_at) }}</td>
<td>{{ get_full_name($record->created_by, 'id', 'first_name', 'last_name', 'users') }}</td>
<td>{{ sprintf("%04u", $record->stock_count_identifier) }}</td>
<td>
{{ Form::open(['method'=>'post','route' => 'pharmacy.sundries_stock_reconciliation_report_details']) }}
{{ Form::hidden('stock_count_identifier', $record->stock_count_identifier) }}
{{ Form::submit('Details', ['class'=>'btn btn-success']) }}
{{ Form::close() }}
</td>
</tr>
@php
$counter++;
@endphp
@endforeach
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script>
$('#dates').change(function (e) {
if($(this).val() === "custom_date"){
$("#eDate").hide();
$("#sDate").show();
}else if($(this).val() === "custom_date_range"){
$("#sDate").show();
$("#eDate").show();
}else{
$("#eDate").hide();
$("#sDate").hide();
}
});
</script>
<script type="text/javascript">
jQuery('#custom_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
</script>
<script type="text/javascript">
jQuery('#end_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
</script>
<script type="text/javascript">
jQuery('#start_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
</script>
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<script>
$('#staff_member').select2({
placeholder: "-- select --"
});
</script>
@endpush
@@ -0,0 +1,130 @@
@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/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
@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">{{ __('pharmacy.sundries_stock_reconciliation_report_details') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="{{ route('pharmacy.sundries_stock_reconciliation_report') }}">{{ __('pharmacy.pharmacy_sundries_stock_reconciliation_report') }}</a></li>
<li class="active">{{ __('pharmacy.sundries_stock_reconciliation_report_details') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<!--Flash messages at the top -->
@include('flash::message')
<div class="white-box">
<div class="row">
<div class="col-sm-12">
<p class="text-muted m-b-30">{{ __('stores.export_data_to_csv_excel_pdf') }}</p>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>{{ __('stores.sundry_name') }}</th>
<th>{{ __('stores.system_stock') }}</th>
<th>{{ __('stores.physical_stock') }}</th>
<th>{{ __('stores.difference') }}</th>
<th>{{ __('stores.reason_for_difference') }}</th>
<th>{{ __('pharmacy.reconciled_by') }}</th>
<th>{{ __('pharmacy.performed_on') }}</th>
</tr>
</thead>
<tfoot>
<tr>
<th>{{ __('stores.sundry_name') }}</th>
<th>{{ __('stores.system_stock') }}</th>
<th>{{ __('stores.physical_stock') }}</th>
<th>{{ __('stores.difference') }}</th>
<th>{{ __('stores.reason_for_difference') }}</th>
<th>{{ __('pharmacy.reconciled_by') }}</th>
<th>{{ __('pharmacy.performed_on') }}</th>
</tr>
</tfoot>
<tbody>
@foreach($sundries_reconciled as $reconciliation_record)
@php
$sundry_name = get_name($reconciliation_record->sundry_id, "id", "name", "sundries");
$insurance_coverage = get_name($reconciliation_record->sundry_id, "id", "insurance", "sundries");
@endphp
<tr>
<td>
@if($insurance_coverage == 1)
<span style="color: green;"> {{ $sundry_name }} </span>
@else
<span style="color: orange;"> {{ $sundry_name }} </span>
@endif
</td>
<td>
<div>
{{ $reconciliation_record->system_stock }}
</div>
</td>
<td>
<div>
{{ $reconciliation_record->physical_stock }}
</div>
</td>
<td>
<div>
{{ $reconciliation_record->difference }}
</div>
</td>
<td>
<div>
{{ $reconciliation_record->reason_for_difference }}
</div>
</td>
<td>
<div>
{{ get_full_name($reconciliation_record->created_by, 'id', 'first_name', 'last_name', 'users') }}
</div>
</td>
<td>
<div>
{{ streamline_date($reconciliation_record->created_at) }}
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<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/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
});
</script>
@endpush
@@ -0,0 +1,186 @@
@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" />
@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">{{ __('pharmacy.pharmacy_sundries_stock_sheet') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="/pharmacy">{{ __('pharmacy.incoming_prescriptions') }}</a></li>
<li class="active">{{ __('pharmacy.pharmacy_sundries_stock_sheet') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<!--Flash messages at the top -->
@include('flash::message')
<div class="white-box">
<div class="row">
<div class="col-sm-12">
<form action="{{ url('update_pharmacy_sundries_stock_sheet') }}" method="POST" name="stock_form" id="stock_form">
{{ csrf_field() }}
<p class="text-muted m-b-30">{{ __('pharmacy.export_data_to_copy_csv_pdf') }}</p>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th style="width: 60%">{{ __('pharmacy.sundry_name') }}</th>
@if(track_items_using_batches()) <th class="shown_input">{{ __('stores.batch_details') }}</th>@endif
<th style="width: 20%">{{ __('pharmacy.pharmacy_stock') }}</th>
<th style="width: 20%">{{ __('pharmacy.cost_value') }}</th>
<th style="width: 20%">{{ __('pharmacy.selling_price') }}</th>
<th style="width: 20%">{{ __('pharmacy.sale_value') }}</th>
{{-- <th style="width: 20%">{{ __('pharmacy.expiry_date') }}</th> --}}
</tr>
</thead>
<tfoot>
<tr>
<th style="width: 20%">{{ __('pharmacy.sundry_name') }}</th>
@if(track_items_using_batches())<th style="width: 20%" class="shown_input">{{ __('stores.batch_details') }}</th>@endif
<th>{{ __('pharmacy.pharmacy_stock') }}</th>
<th style="width: 20%">{{ __('pharmacy.cost_value') }}</th>
<th style="width: 20%">{{ __('pharmacy.selling_price') }}</th>
<th style="width: 20%">{{ __('pharmacy.sale_value') }}</th>
{{-- <th>{{ __('pharmacy.expiry_date') }}</th> --}}
</tr>
</tfoot>
<tbody>
@foreach($sundries as $sundry)
<tr>
<td>
@if($sundry->insurance == 1)
<span style="color: green;"> {{ $sundry->name }} </span>
@else
<span style="color: orange;"> {{ $sundry->name }} </span>
@endif
</td>
@if(track_items_using_batches())
<td id="div_to_append_{{ $sundry->id }}">
@php
$batch_records = track_batch_stock(2,$sundry->id,'pharmacy_stock');
// \Streamline\Models\ItemBatchWatcher::where(['item_type' => 2, 'item_id' => $sundry->id])->where('pharmacy_stock', '!=', 0)->get();
$sundry_pharmacy_stock = $item_cost_value = 0;
@endphp
@if(count($batch_records) > 0)
@foreach($batch_records as $record)
<div class="row" style="background-color: #e1e1ef; border-radius: 5px 5px; border: 2px #c4b7b7 solid; margin-bottom: 2px;">
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.batch') }}: </b>{{ $record->batch_number }}
</div>
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.quantity') }}: </b>{{ $record->pharmacy_stock }}<br>
@php
$sundry_pharmacy_stock += $record->pharmacy_stock;
@endphp
<b>{{ __('stores.expiry_date') }}: </b>{{ $record->expiry_date }}
</div>
<div class="col-sm-12" style="word-wrap: break-word; padding: 0px; font-size: 10px">
<b>{{ __('stores.unit_cost') }}: </b>{{ $record->cost_price }}
</div>
</div>
@php
$item_cost_value += $record->cost_price * $record->pharmacy_stock;
@endphp
@endforeach
@endif
<div class="row show_on_edit" style="display: none;" id="add_batch_{{ $sundry->id }}"><a href="#">{{ __('stores.add_batch_small') }}<div>
</td>
@endif
<td>
<div class="shown_input">
{{ $sundry_pharmacy_stock }}
</div>
<div class="hidden_input" style="display: none;">
<input type="hidden" name="sundry_id[]" value="{{ $sundry->id }}">
<input type="text" name="quantity[]" class="form-control" value="{{ $sundry_pharmacy_stock }}" readonly>
</div>
</td>
<td>
<div class="shown_input">
{{ ugandan_shillings($item_cost_value) }}
</div>
</td>
<td>
<div class="shown_input">
{{ ugandan_shillings($sundry->non_insured_price) }}
</div>
</td>
<td>
<div class="shown_input">
{{ ugandan_shillings($sundry_pharmacy_stock * $sundry->non_insured_price) }}
</div>
</td>
{{-- <td>
<div class="">
{{ streamline_date($sundry->expiry_date) }}
</div>
<div class="" style="display: none;">
</div>
</td> --}}
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
{{-- <div class="col-sm-2">
<div style="margin-top: 10%; float: right;">
<button class="btn btn-default" id="cancel_edit" style="display: none;">{{ __('pharmacy.cancel') }}</button>
<button class="btn btn-success pull-right" id="edit_stock">{{ __('pharmacy.edit_stock') }}</button>
<input type="submit" value="Save stock" class="btn btn-success" id="save_stock" style="display: none;">
</div>
</form>
</div> --}}
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<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>
$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
});
$('#edit_stock').click(function(e){
e.preventDefault();
$('.hidden_input,#save_stock').show();
$('.shown_input').hide();
$(this).hide();
});
$('.paginate_button').click(function(e){
e.preventDefault();
$('.hidden_input,#save_stock').hide();
$('#edit_stock').show();
});
</script>
@endpush
@@ -0,0 +1,174 @@
@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/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<h4 class="page-title">{{ __('pharmacy.cancalled_treatments') }}</h4>
</div>
<div class="col-lg-6 col-sm-6 col-md-6 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}"><i class="fa fa-home"></i> {{ __('investigations.dashboard') }}</a></li>
</ol>
</div>
</div>
{{ Form::open(['route' => 'pharmacy.view_cancelled_prescriptions', 'method' => 'ANY']) }}
<div class="white-box">
<div class="row">
<div class="col-md-3">
<div class="form-group" id="searchby">
{{ Form::label('search_by', __('investigations.date')) }}
{{ Form::select('search_by', ['0'=>'Last 24 hours','1'=>'Custom Date','2'=>'Custom Range'], '', ['class' => 'form-control','id'=>'search_by', 'required']) }}
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-3" style="display: none;" id="date_search">
<div class="form-group" id="reg_date" style="padding-top: 23px;">
<div class="input-group">
{{ Form::text('reg_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'datepicker-autoclose']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-3" style="display: none;" id="date_range_search">
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{ Form::label('start_date', __('investigations.from')) }}
<div class="input-group">
{{ Form::text('start_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-1']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group" id="reg_date">
{{ Form::label('end_date', __('investigations.to')) }}
<div class="input-group">
{{ Form::text('end_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-2']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group" style="padding-top: 5px;"><br>
{{ Form::button(__('investigations.submit'),['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10', 'id'=>'select_patient']) }}
</div>
</div>
<div class="col-md-3">
<h4>{{ __('pharmacy.search_date') }}: <code>{{ $date_search }}</code></h4>
</div>
</div>
</div>
{{ Form::close() }}
<div class="row">
<div class="col-sm-12">
@include('flash::message')
<div class="white-box" style="border-radius: 5px;">
<div class="table-responsive">
<table class="table table-hover color-bordered-table success-bordered-table table-striped">
<thead>
<tr>
<th>{{ __('pharmacy.date_cancelled') }}</th>
<th>{{ __('investigations.patient_names') }}</th>
<th>{{ __('pharmacy.drugs_ordered') }}</th>
<th>{{ __('investigations.action') }}</th>
<th></th>
</tr>
</thead>
<tbody>
@if(count($prescriptions) > 0)
@foreach($prescriptions as $prescription)
@php
$drug_ids = explode(",", $prescription->drugs);
$quantites = explode(",", $prescription->quantities_dispensed);
@endphp
<tr>
<td>{{ streamline_date_time($prescription->deleted_at) }}</td>
<td>{{ get_full_name($prescription->patient_id, 'id', 'first_name', 'last_name', 'patients') }} ({{ get_name($prescription->patient_id, 'id', 'number', 'patients') }})</td>
<td>
<ol>
@for($i=0; $i < count($drug_ids); $i++)
<li>{{ get_name($drug_ids[$i], 'id', 'name', 'drugs') }}</li>
@endfor
</ol>
</td>
<td>
<a class="btn btn-warning btn-rounded btn-small" href="/pharmacy/restore_deleted_ordered_treatments/{{ $prescription->id }}">{{ __('pharmacy.restore_prescription') }}</a>
</td>
<td>
<a href="/patient_episodes/set_patient_id/{{ $prescription->patient_id }}" class="btn btn-info btn-rounded">{{ __('investigations.select_patient') }}</a>
</td>
</tr>
@endforeach
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<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>
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script>
$('.table').DataTable({
dom: 'Bfrtip',
//order: [ [0, 'desc'] ],
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
],
'pageLength' : 50,
});
$('#datepicker-autoclose,#datepicker-autoclose-1,#datepicker-autoclose-2').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
$('#search_by').change(function () {
if ($(this).val() == 1) {
$('#date_search').show();
$('#date_range_search').hide();
}
else if ($(this).val() == 2) {
$('#date_range_search').show();
$('#date_search').hide();
}
else {
$('#date_search,#date_range_search').hide();
}
});
</script>
@endpush
@@ -0,0 +1,174 @@
@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/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<h4 class="page-title">{{ __('pharmacy.cancelled_progressive_treatments') }}</h4>
</div>
<div class="col-lg-6 col-sm-6 col-md-6 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}"><i class="fa fa-home"></i> {{ __('investigations.dashboard') }}</a></li>
</ol>
</div>
</div>
{{ Form::open(['route' => 'pharmacy.view_cancelled_progressive_prescriptions', 'method' => 'ANY']) }}
<div class="white-box">
<div class="row">
<div class="col-md-3">
<div class="form-group" id="searchby">
{{ Form::label('search_by', __('investigations.date')) }}
{{ Form::select('search_by', ['0'=>'Last 24 hours','1'=>'Custom Date','2'=>'Custom Range'], '', ['class' => 'form-control','id'=>'search_by', 'required']) }}
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-3" style="display: none;" id="date_search">
<div class="form-group" id="reg_date" style="padding-top: 23px;">
<div class="input-group">
{{ Form::text('reg_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'datepicker-autoclose']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-3" style="display: none;" id="date_range_search">
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{ Form::label('start_date', __('investigations.from')) }}
<div class="input-group">
{{ Form::text('start_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-1']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group" id="reg_date">
{{ Form::label('end_date', __('investigations.to')) }}
<div class="input-group">
{{ Form::text('end_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-2']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group" style="padding-top: 5px;"><br>
{{ Form::button(__('investigations.submit'),['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10', 'id'=>'select_patient']) }}
</div>
</div>
<div class="col-md-3">
<h4>{{ __('pharmacy.search_date') }}: <code>{{ $date_search }}</code></h4>
</div>
</div>
</div>
{{ Form::close() }}
<div class="row">
<div class="col-sm-12">
@include('flash::message')
<div class="white-box" style="border-radius: 5px;">
<div class="table-responsive">
<table class="table table-hover color-bordered-table success-bordered-table table-striped">
<thead>
<tr>
<th>{{ __('pharmacy.date_cancelled') }}</th>
<th>{{ __('investigations.patient_names') }}</th>
<th>{{ __('pharmacy.drugs_ordered') }}</th>
<th>{{ __('investigations.action') }}</th>
<th></th>
</tr>
</thead>
<tbody>
@if(count($prescriptions) > 0)
@foreach($prescriptions as $prescription)
@php
$drug_ids = explode(",", $prescription->drugs);
$quantites = explode(",", $prescription->quantities_to_dispense);
@endphp
<tr>
<td>{{ streamline_date_time($prescription->deleted_at) }}</td>
<td>{{ get_full_name($prescription->patient_id, 'id', 'first_name', 'last_name', 'patients') }} ({{ get_name($prescription->patient_id, 'id', 'number', 'patients') }})</td>
<td>
<ol>
@for($i=0; $i < count($drug_ids); $i++)
<li>{{ get_name($drug_ids[$i], 'id', 'name', 'drugs') }}</li>
@endfor
</ol>
</td>
<td>
<a class="btn btn-warning btn-rounded btn-small" href="/pharmacy/restore_deleted_progressive_prescriptions/{{ $prescription->id }}">{{ __('pharmacy.restore_prescription') }}</a>
</td>
<td>
<a href="/patient_episodes/set_patient_id/{{ $prescription->patient_id }}" class="btn btn-info btn-rounded">{{ __('investigations.select_patient') }}</a>
</td>
</tr>
@endforeach
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<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>
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script>
$('.table').DataTable({
dom: 'Bfrtip',
//order: [ [0, 'desc'] ],
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
],
'pageLength' : 50,
});
$('#datepicker-autoclose,#datepicker-autoclose-1,#datepicker-autoclose-2').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
$('#search_by').change(function () {
if ($(this).val() == 1) {
$('#date_search').show();
$('#date_range_search').hide();
}
else if ($(this).val() == 2) {
$('#date_range_search').show();
$('#date_search').hide();
}
else {
$('#date_search,#date_range_search').hide();
}
});
</script>
@endpush
@@ -0,0 +1,661 @@
@extends('layouts.main')
@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">{{ __('pharmacy.dispensing_details') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li><a href="{{ route('pharmacy.index') }}">{{ __('pharmacy.incoming_prescriptions') }}</a></li>
<li class="active">{{ __('pharmacy.dispensing_details') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('patients::allergies.header')
<br>
</div>
</div>
@php
$option_batches = "<option value=''>-select-</option>";
@endphp
@if( Auth::user()->can('view-previous-patient-prescriptions'))
@if(count($previous_treatments) > 0)
<div class="white-box" style="padding-top: 2px;">
<h3>{{ __('prescriptions.previous_prescriptions') }}</h3>
<div class="table-responsive">
<table class="table table-striped color-bordered-table success-bordered-table">
<thead>
<tr>
<th>{{ __('prescriptions.date') }}</th>
<th>{{ __('prescriptions.clinic') }}</th>
<th>{{ __('prescriptions.primary_diagnosis') }}</th>
<th>{{ __('prescriptions.other_diagnoses') }}</th>
<th>{{ __('prescriptions.prescribed_by') }}</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach($previous_treatments as $past_treatment)
@php
$past_drug_ids_array = explode(",", $past_treatment->drugs);
$past_dosage_array = explode(",", $past_treatment->doses);
$past_quantities_array = explode(",", $past_treatment->quantities_dispensed);
$past_frequencies_array = explode(",", $past_treatment->frequencies);
$past_durations_array = explode(",", $past_treatment->durations);
$past_instructions_array = explode(",", $past_treatment->instructions);
@endphp
<tr>
<td>
{{ streamline_date_time($past_treatment->created_at) }}
<br>
@if(check_if_episode_is_a_followup($past_treatment->episode_id))
<small style="color: green"><br>({{ __('patient_episode.review_from') }} {{ streamline_date(get_name(get_name($past_treatment->episode_id, 'id', 'parent_episode_id', 'patient_episodes'), 'id', 'created_at', 'patient_episodes')) }})</small>
@endif
</td>
<td>
{{ get_name(get_name($past_treatment->episode_id, 'id', 'clinic_id', 'patient_episodes'), "id", "name", "clinics") }}
</td>
<td>
{{ get_name(get_name($past_treatment->episode_id, 'episode_id', 'primary_diagnosis', 'consultations'), 'id', 'name', 'diagnoses') }}
</td>
<td></td>
<td>{{ get_full_name($past_treatment->created_by, "id", "first_name", "last_name", "users") }}</td>
<td>
<a class="btn btn-rounded btn-xs btn-default-bluish" onclick="past_episode_row_details({{ $past_treatment->id }})">{{ __('prescriptions.view_details') }}</a>
</td>
</tr>
<tr class="past_episode_row" id="past_episode_row{{ $past_treatment->id }}" style="display: none">
<td colspan="6">
<div class="row">
<div class="col-md-12">
<div class="table-responsive">
<table class="table table-striped table-bordered">
<thead>
<tr>
<td><b>{{ __('prescriptions.drug') }}</b></td>
<td><b>{{ __('prescriptions.dosage') }}</b></td>
<td><b>{{ __('prescriptions.duration_in_days') }}</b></td>
<td><b>{{ __('prescriptions.quantity') }}</b></td>
<td><b>{{ __('prescriptions.instruction') }}</b></td>
</tr>
</thead>
<tbody>
@for ($w = 0; $w < count($past_drug_ids_array); $w++)
@php
$past_drug_unit_id = isset($past_drug_ids_array[$w]) ? get_name($past_drug_ids_array[$w], 'id', 'unit_id', 'drugs') : 0;
$past_frequency_name = isset($past_frequencies_array[$w]) ? get_name($past_frequencies_array[$w], 'id', 'name', 'dosage_frequencies') : "";
$past_unit = get_name($past_drug_unit_id, 'id', 'name', 'drug_units');
$past_unit = $past_unit=="N/A"?"":$past_unit;
$past_drug_unit = "<small>" . $past_unit . "</small>";
@endphp
<tr>
<td>
{{ get_name($past_drug_ids_array[$w], "id", "name", "drugs") }}
</td>
<td>
{{ $past_dosage_array[$w] ?? "" }} {!! $past_drug_unit !!} &nbsp;&nbsp; {{ $past_frequency_name }}
</td>
<td>
{{ isset($past_durations_array[$w]) ? $past_durations_array[$w] : "" }}
</td>
<td>
{{ isset($past_quantities_array[$w]) ? $past_quantities_array[$w]:"" }}
</td>
<td>
{{ isset($past_instructions_array[$w]) ? $past_instructions_array[$w] : "" }}
</td>
</tr>
@endfor
<tr>
<td>
<b>{{ __('prescriptions.order_comments') }}</b>
</td>
<td colspan="2">
{!! $past_treatment->order_comments == 1 !!}
</td>
<td>
<b>{{ __('prescriptions.dispensation_status') }}</b>
</td>
<td>
{!! $past_treatment->dispense_status == 1 ? "<span style='color: green'>Dispensed</span>" : "<span style='color: red'>Not dispensed</span>" !!}
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@if(Auth::user()->can('view-patients-home'))
<a href="/patient_episodes/set_patient_id/{{ $patient->id }}" class="btn btn-rounded btn-primary btn-sm"><i class="fa fa-hand-pointer-o"></i> <strong>{{ __('prescriptions.patient_home') }}</strong></a>
@endif
</div>
@endif
@endif
<div class="row">
<div class="col-sm-12">
<div class="white-box">
@include('flash::message')
@php $is_any_drug_out_of_stock = $is_any_drug_purchased_else_where = false; $out_stocked_drugs = []; @endphp
<div class="row">
@if( Auth::user()->can('view-patient-diagnosis-at-pharmacy'))
@if(is_eye_module_enabled() && is_patient_in_eye_clinic($treatment->episode_id))
@php
$right_eye_diagnoses = explode(',',get_name($treatment->episode_id, 'episode_id', 'right_eye_diagnosis', 'eye_clinic_main_exam'));
$left_eye_diagnoses = explode(',',get_name($treatment->episode_id, 'episode_id', 'left_eye_diagnosis', 'eye_clinic_main_exam'));
@endphp
<div class="col-md-12">
<h4>Diagnosis</h4>
<table class="table table-striped table-bordered">
<tbody>
<tr>
<td><b>{{ __('patient_episode.left_eye_diagnosis') }}</b></td>
<td>
@if(count($left_eye_diagnoses) > 0)
<ol>
@for($x = 0; $x < count($left_eye_diagnoses); $x++)
<li>{{ isset($left_eye_diagnoses[$x]) ? get_name($left_eye_diagnoses[$x], 'id', 'name', 'diagnoses') : 'N/A' }}</li>
@endfor
</ol>
@else
No Diagnosis
@endif
</td>
<td><b>{{ __('patient_episode.right_eye_diagnosis') }}</b></td>
<td>
@if(count($right_eye_diagnoses) > 0)
<ol>
@for($x = 0; $x < count($right_eye_diagnoses); $x++)
<li>{{ isset($right_eye_diagnoses[$x]) ? get_name($right_eye_diagnoses[$x], 'id', 'name', 'diagnoses') : 'N/A' }}</li>
@endfor
</ol>
@else
No Diagnosis
@endif
</td>
</tr>
</tbody>
</table>
<hr>
</div>
@else
<div class="col-md-12">
<div class="table-responsive">
<table class="table success-table table-sm table-striped table-hover">
<tbody>
@php
$primary_diagnosis = "";
$secondary_diagnosis_array = [];
if ($treatment) {
$consultation = \Streamline\Models\Consultation::where('episode_id', $treatment->episode_id)->first();
if ($consultation) {
$primary_diagnosis = is_null($consultation->primary_diagnosis) ? "" : get_name($consultation->primary_diagnosis, 'id', 'name', 'diagnoses');
$other_diagnoses_array = unserialize($consultation->other_diagnoses);
if (is_array($other_diagnoses_array)) {
for ($i=0; $i < count($other_diagnoses_array) ; $i++) {
$secondary_diagnosis_array[] = get_name($other_diagnoses_array[$i], 'id', 'name', 'diagnoses');
}
}
}
}
@endphp
<tr>
<th><strong>{{ __('pharmacy.primary_diagnosis') }} :</strong></th>
<td>{{ $primary_diagnosis }}</td>
</tr>
<tr>
<th><strong>{{ __('pharmacy.secondary_diagnosis') }} :</strong></th>
<td>
<ul>
@for ($i = 0; $i < count($secondary_diagnosis_array); $i++)
<li>{{ $secondary_diagnosis_array[$i] }}</li>
@endfor
</ul>
</td>
</tr>
</tbody>
</table>
</div>
</div>
@endif
@endif
<div class="col-sm-12">
<form id="form" action="{{ url('dispense_prescription') }}" method="post">
{{ csrf_field() }}
<div class="table-responsive">
<table class="table success-table table-sm table-striped table-hover" id="dispensation_details_table">
<thead>
<tr>
<th>#</th>
@if(is_eye_module_enabled() && is_patient_in_eye_clinic($treatment->episode_id))<th style="width: 5%">{{ __('pharmacy.eye') }}</th>@endif
<th style="width: 25%">{{ __('pharmacy.drug_name') }}</th>
<th style="width: 10%">{{ __('pharmacy.dose') }}</th>
<th style="width: 10%">{{ __('pharmacy.frequency') }}</th>
<th style="width: 10%">{{ __('pharmacy.duration') }}</th>
<th style="width: 7%">{{ __('pharmacy.quantity') }}</th>
<th style="width: 8%">{{ __('pharmacy.amount') }}</th>
<th style="width: 25%">{{ __('pharmacy.instructions') }}</th>
<th width="5%">{{ __('pharmacy.to_be_purcharsed_elsewhere') }}</th>
</tr>
</thead>
<tbody>
<input type="hidden" id="batch_required_checker" value=""/>
@if($treatment)
@php
$total_amount_to_pay = 0;
$drug_explode = explode(",", $treatment->drugs);
$dose_explode = explode(",", $treatment->doses);
$dose2_explode = explode(",", $treatment->dose2);
$drug_frequency_explode = explode(",", $treatment->frequencies);
$instruction_explode = explode(",", $treatment->instruction);
$duration_explode = explode(",", $treatment->durations);
//$long_term_explode = explode(",", $treatment_row['Long_Term']);
$dispense_explode = explode(",", $treatment->dispensed);
//$form_explode = explode(",", $treatment_row['Form']);
$quantity_to_dispense = explode(",", $treatment->quantities_dispensed);
$purchased_elsewhere = is_null($treatment->purchased_elsewhere) ? [] : explode(",", $treatment->purchased_elsewhere);
$eye_explode = explode(',', $treatment->eye);
@endphp
<tr>
<td @if(is_eye_module_enabled() && is_patient_in_eye_clinic($treatment->episode_id)) colspan="10" @else colspan="9" @endif>
<h4>{{ __('pharmacy.prescribed_on') }} {{ streamline_date_time($treatment->created_at) }} {{ __('pharmacy.by') }} <span style="color: blue">{{ isset($treatment) ? get_full_name($treatment->created_by, 'id', 'first_name', 'last_name', 'users'): "" }}</span> ({{ isset($treatment) ? get_name($treatment->created_by, 'id', 'phone', 'users') : "" }})</h4>
</td>
</tr>
<input type="hidden" value="{{ $treatment->id }}" name="treatment_id" id="treatment_id" />
<input type="hidden" value="{{ $treatment->tta }}" name="tta" />
<input type="hidden" value="{{ $treatment->patient_id }}" name="patient_id">
@for ($x = 0; $x < count($drug_explode); $x++)
@php
$auto_deductable_batches_array = get_lab_batches_to_use_based_on_needed_quantity($drug_explode[$x], $item_type = 1, $quantity_to_dispense[$x],'pharmacy_stock');
@endphp
<tr>
<td>{{ $x+1 }}.</td>
@if(is_eye_module_enabled() && is_patient_in_eye_clinic($treatment->episode_id))
<td>
@if(isset($eye_explode[$x]))
@if($eye_explode[$x] == 0)
Left
@elseif($eye_explode[$x] == 1)
Right
@else
Both
@endif
@endif
</td>
@endif
<td>
<input type="hidden" name="drug_id[]" value="{{ $drug_explode[$x] }}">
@if(get_name($drug_explode[$x], 'id', 'insurance_coverage', 'drugs') == 1)
<input type="text" readonly style="color: green" step="0.01" name="drug_name[]" class="form-control col-sm-12" value="{{ get_name($drug_explode[$x], 'id', 'name', 'drugs') }}">
@else
<input type="text" readonly style="color: orange" step="0.01" name="drug_name[]" class="form-control col-sm-12" value="{{ get_name($drug_explode[$x], 'id', 'name', 'drugs') }}">
@endif
@if (count($auto_deductable_batches_array) > 0)
@foreach ($auto_deductable_batches_array as $deductable_batch => $quantity)
<label class="label label-info">
Batch
@php
$drug_details = \Streamline\Models\Drug::withTrashed()->find($drug_explode[$x]);
/* ************** */
//usable batches for this drug
$usable_batches_array = null;
$usable_batches_array = DB::table('item_batch_watcher')->where(['item_id' => $drug_explode[$x], 'item_type' => 1])->where(function ($query) {
$query->where('pharmacy_stock', '>', 0)
/* ->orWhere('store_stock', '>', 0) */;
})->get();
$facade_batches_options = [];
$option_batches = "<option value=''>-select-</option>";
foreach ($usable_batches_array as $item_batch) {
$option_batches .= "<option value='$item_batch->id'>". $item_batch->batch_number." (Expiry Date: ".$item_batch->expiry_date.")</option>";
$facade_batches_options[$item_batch->id] = $item_batch->batch_number." (Expiry Date: ".$item_batch->expiry_date.")";
}
$facade_batches_options = ["--Select--", ""] + $facade_batches_options;
/* ****************** */
@endphp
<input type="hidden" name="batch_drug_id[]" value="{{ $drug_explode[$x] }}">
{{ Form::select('batch_dispensed_from[]', $facade_batches_options, $deductable_batch, ['class' => 'batch_dispensed_from bth_drug_'.$drug_explode[$x], 'style' => 'color: black; font-size: 14px;', 'required']) }}
<input type='number' step='0.01' value='{{$quantity}}' required name='batch_quantity_to_dispense[]' style='padding: 1px 5px; height: 20px; color:#2c2a2a; font-size: 14px' placeholder='Qty picked from this batch' class='required_btch_qty dynamic-batch-qty_{{$drug_explode[$x]}} all-batch-'>
</label>
@endforeach
@else
<label class="label label-info">
Batch
@php
/* ******* usable batches for this drug ******* */
$usable_batches_array = DB::table('item_batch_watcher')->where(['item_id' => $drug_explode[$x], 'item_type' => 1])->where(function ($query) {
$query->where('pharmacy_stock', '>', 0)
/* ->orWhere('store_stock', '>', 0) */;
})->get();
$facade_batches_options = [];
$option_batches = "<option value=''>-select-</option>";
foreach ($usable_batches_array as $item_batch) {
$option_batches .= "<option value='$item_batch->id'>". $item_batch->batch_number." (Expiry Date: ".$item_batch->expiry_date.")</option>";
$facade_batches_options[$item_batch->id] = $item_batch->batch_number." (Expiry Date: ".$item_batch->expiry_date.")";
}
$facade_batches_options = ["--Select--", ""] + $facade_batches_options;
/* ****************** */
@endphp
<input type="hidden" name="batch_drug_id[]" value="{{ $drug_explode[$x] }}">
{{ Form::select('batch_dispensed_from[]', $facade_batches_options, null, ['class' => 'batch_dispensed_from bth_drug_'.$drug_explode[$x], 'style' => 'color: black; font-size: 14px;', 'required']) }}
<input type='number' step='0.01' value='' required name='batch_quantity_to_dispense[]' style='padding: 1px 5px; height: 20px; color: #2c2a2a; font-size: 14px;' placeholder='Qty picked from this batch' class='required_btch_qty dynamic-batch-qty_{{$drug_explode[$x]}} all-batch-'>
</label>
@endif
<label class="label label-info" id="batch_dropdown_{{$drug_explode[$x]}}"></label>
</td>
<td>
@php
$form_id = isset($drug_explode[$x]) ? get_name($drug_explode[$x], 'id', 'form_id', 'drugs') : "";
$unit_id = isset($drug_explode[$x]) ? get_name($drug_explode[$x], 'id', 'unit_id', 'drugs') : "";
$form_name = isset($form_id) ? get_name($form_id, 'id', 'name', 'drug_forms') : "";
$unit_name = isset($unit_id) ? get_name($unit_id, 'id', 'name', 'drug_units') : "";
@endphp
<input type="text" readonly class="form-control col-sm-12" value="{{ isset($dose_explode[$x]) ? $dose_explode[$x] : "" }} {{ $unit_name }}">
{{ Form::hidden('dose[]', isset($dose_explode[$x]) ? $dose_explode[$x] : "") }}
<label class="label label-primary add_batch" id="add_batch_{{$drug_explode[$x]}}">Add batch</label>
</td>
@if (!empty($dose2_explode[$x]))
@php
$form_id2 = isset($drug_explode[$x]) ? get_name($dose2_explode[$x], 'id', 'form_id', 'drugs') : "";
$form_name2 = isset($drug_explode[$x]) ? get_name($form_id2, 'id', 'name', 'drug_units') : "";
@endphp
<input type="hidden" readonly class="form-control col-sm-12" value="{{ isset($dose2_explode[$x]) ? $dose2_explode[$x] : "" }} {{ $form_name2 }}">
{{ Form::hidden('dose2[]', isset($dose2_explode[$x]) ? $dose2_explode[$x] : "") }}
@endif
<td>
<input type="text" readonly step="0.01" name="frequency[]" class="form-control col-sm-12" value="{{ get_name( isset($drug_frequency_explode[$x]) ? $drug_frequency_explode[$x] : "", 'id', 'name', 'dosage_frequencies') }}">
</td>
<td>
<input type="text" readonly step="0.01" name="duration[]" class="form-control col-sm-12" value="{{ isset($duration_explode[$x]) ? $duration_explode[$x] : "" }}">
</td>
<td>
<input type="text" readonly step="0.01" name="quantity_to_dispense[]" class="form-control col-sm-12" value="{{ isset($quantity_to_dispense[$x]) ? $quantity_to_dispense[$x] : ""}}">
@php
//$pharmacy_stock = get_name($drug_explode[$x], 'id', 'pharmacy_stock', 'drugs');
$pharmacy_stock = \Streamline\Models\ItemBatchWatcher::where(['item_type' => 1, 'item_id' => $drug_explode[$x]])->sum('pharmacy_stock');
@endphp
{{-- @if(count($auto_deductable_batches_array) < 1)
<input type='hidden' step='0.01' required name='batch_quantity_to_dispense[]' value='{{$quantity_to_dispense[$x]}}' class='col-sm-12 preloaded-default'>
@endif --}}
{{-- @foreach ($auto_deductable_batches_array as $deductable_batch => $quantity)
<input type='number' step='0.01' value='{{$quantity}}' required name='batch_quantity_to_dispense[]' style="height: 14px" placeholder='Qty picked from this batch' class='col-sm-12 dynamic-batch-qty_{{$drug_explode[$x]}} all-batch-'>
@endforeach --}}
<span id="this_batch_quantity_{{$drug_explode[$x]}}"></span>
@if(isset($quantity_to_dispense[$x]) && ($pharmacy_stock - $quantity_to_dispense[$x]) < 0 && !($treatment->payment_status == 1 && get_inventory_reduction_point() == 2))
@php $is_any_drug_out_of_stock = true; $out_stocked_drugs[] = $drug_explode[$x]; @endphp
<label class="label label-danger dispensables_{{$drug_explode[$x]}}">Only {{ $pharmacy_stock }} dispensable units in stock</label>
@endif
</td>
<td>
@php
$treatment_amount = 0;
$treatment_subtotal = 0;
if(get_name($drug_explode[$x], "id", "name", "drugs") != "N/A"){
$price_list_id = is_patient_category_attached_to_price_list($patient_id);
if(patient_insurance_status($patient_id) == 1){
$item_insurance_details = get_item_insurance_pricing($patient_id, $drug_explode[$x], 4, true, 0);
$treatment_amount = $item_insurance_details[2];
} else {
if ($price_list_id) {
$treatment_amount = get_price_list_category_price($price_list_id, 3, $drug_explode[$x]);
} else {
$treatment_amount = get_name($drug_explode[$x], "id", "non_insured_price", "drugs");
}
}
if(isset($quantity_to_dispense[$x]) && $quantity_to_dispense[$x] != ""){
$treatment_subtotal = $quantity_to_dispense[$x] * $treatment_amount;
}
}
if(!(isset($purchased_elsewhere[$x]) && $purchased_elsewhere[$x] == 1)){
$total_amount_to_pay += $treatment_subtotal;
} else {
$is_any_drug_purchased_else_where = true;
}
@endphp
{{ ugandan_shillings($treatment_subtotal) }}
<span id="this_batch_amount_{{$drug_explode[$x]}}"></span>
</td>
<td>
<textarea name="instructions[]" readonly class="form-control col-sm-12">{{ isset($instruction_explode[$x]) ? $instruction_explode[$x] : "" }}</textarea>
</td>
<td><input type="checkbox" class="else_chx" id="{{$drug_explode[$x]}}" name="purchased_elsewhere[]" value="{{ $drug_explode[$x] }}" @if(isset($purchased_elsewhere[$x]) && $purchased_elsewhere[$x] == 1) checked @endif @if($treatment->payment_status == 1) disabled @endif/></td>
</tr>
@endfor
<tr>
<td @if(is_eye_module_enabled() && is_patient_in_eye_clinic($treatment->episode_id)) colspan="6" @else colspan="5" @endif></td>
<td><h5>{{ __('pharmacy.total') }}</h5></td>
<td>{{ ugandan_shillings($total_amount_to_pay) }}</td>
<td colspan="2"></td>
</tr>
@else
<tr><td @if(is_eye_module_enabled() && is_patient_in_eye_clinic($treatment->episode_id)) colspan="10" @else colspan="9" @endif>{{ __('pharmacy.no_records') }}</td></tr>
@endif
</tbody>
</table>
</div>
@if(isset($treatment->order_comments))
<hr>
{{ Form::label('order_comments', __('pharmacy.treatment_order_comments')) }}
<textarea name="order_comments" rows="6" readonly class="form-control">{{ $treatment->order_comments }}</textarea>
<br><br>
@endif
<div class="control-group">
@if($treatment->payment_status == 0)
<a class="btn btn-warning btn-rounded btn-small" href="alter_prescriptions/{{ $treatment->id }}/ {{ $treatment->patient_id }}">{{ __('pharmacy.alter')}}</a>&nbsp;
@else
<a class="btn btn-warning btn-rounded btn-small" href="#" onclick="alert('Treatment has already been paid for. Please cancel the receipt before altering')">{{ __('pharmacy.alter')}}</a>&nbsp;
@endif
@if($is_any_drug_out_of_stock && !can_dispense_out_of_stock_drugs() && !$is_any_drug_purchased_else_where)
<h2><label class="label label-danger">Some drugs are out of stock. Dispensation has been disabled</label></h2>
@else
<button type="submit" class="btn btn-success btn-rounded btn-small" name="complete" id="complete_button" style="display: none;" value="complete">{{ __('pharmacy.complete') }}</button>
<a class="btn btn-success btn-small btn-rounded" onclick="return submitDispense();" id="confirm_button">{{ __('pharmacy.confirm_dispensing') }}</a>
@endif
@if(Auth::user()->can('view-patients-home') && empty($previous_treatments))
<a href="/patient_episodes/set_patient_id/{{ $patient->id }}" class="btn btn-rounded btn-primary"><i class="fa fa-hand-pointer-o"></i> <strong>{{ __('prescriptions.patient_home') }}</strong></a>
@endif
</div>
</form>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script>
function submitDispense() {
//check if purchased elsewhere is ticked
const puchasedElsewhereArray = [];
$(".else_chx").each(function () {
if($(this).is(':checked')){
var else_where_drug = $(this).val();
$(".bth_drug_"+else_where_drug).removeAttr("required");
$(".dynamic-batch-qty_"+else_where_drug).removeAttr("required");
$("#batch_required_checker").val("true");
console.log("out of stock but purchased elsewhere ==> "+else_where_drug);
puchasedElsewhereArray.push(else_where_drug);
}
});
//check if the out of stock drugs are purachased elsewhere and remove required attr
var out_stocked_drugs_array = {!! json_encode($out_stocked_drugs) !!};
for (let x = 0; x < out_stocked_drugs_array.length; x++) {
if($.inArray(out_stocked_drugs_array[x], puchasedElsewhereArray) !== -1){
console.log("out of stock but purchased elsewhere ==> "+out_stocked_drugs_array[x]);
} else {
$("#batch_required_checker").val("");
console.log("out of stock but not not not purchased elsewhere ==> "+out_stocked_drugs_array[x]);
}
}
//check if required batches are filled
var empty_compulsory_fields = [];
$(".batch_dispensed_from").each(function () {
if ($('option:selected',this).attr('value') == "" || $('option:selected',this).attr('value') == null || $('option:selected',this).attr('value') == 0) {
var textname = $(this).attr('name');
empty_compulsory_fields.push(textname);
$(this).css('border','1px solid #F08080');
}
});
$(".required_btch_qty").each(function () {
if ($(this).val() == "" || $(this).val() == null) {
var textname = $(this).attr('name');
empty_compulsory_fields.push(textname);
$(this).css('border','1px solid #F08080');
}
});
/* check if the array containing empty compulsory fields is not empty then return false */
if (empty_compulsory_fields.length != 0 && $("#batch_required_checker").val() == "") {
alert("Please make sure you specify the batches and quantities from which the drugs are being dispensed from");
return false;
}
// begin checking to ensure there is enough quantity dispensed
let drug_id = $("input[name='drug_id[]']" ).map(function(){
return this.value;
}).get();
let purchased_elsewhere = $("input[name='purchased_elsewhere[]']" ).map(function(){
if (this.checked) {
return 1;
} else {
return 0;
}
}).get();
let treatment_id = $('#treatment_id').val();
let quantity_dispensed = $("input[name='quantity_to_dispense[]']" ).map(function(){
return this.value;
}).get();
$.ajax({
url: '/check_dispensed_drugs_quantity',
data: {'drug_id_array[]':drug_id, 'quantity_dispensed_array[]':quantity_dispensed,
'purchased_elsewhere':purchased_elsewhere, 'treatment_id':treatment_id},
success: function(response){
if (response[2] !== "0") {
alert(response[1]);
}
// return without displaying the submit buttons
if (response[2] === "2") {
return;
}
$("#confirm_button").hide();
$("#complete_button").show();
}
});
}
let current_past_episode = 0;
function past_episode_row_details(id) {
$('.past_episode_row').hide();
if (current_past_episode !== id) {
$('#past_episode_row' + id).show();
current_past_episode = id;
} else {
current_past_episode = 0;
}
}
let all_batches_count = 0;
$(".add_batch").click(function (e) {
e.preventDefault();
let drug_id = /\d+(?=\D*$)/.exec($(this).attr('id'));
//console.log("add batch for drug =="+drug_id);
$(".dispensables_"+drug_id).hide();
//count current dynamically added batch qty boxes
let batch_current_fields = 0;
$(".dynamic-batch-qty_"+drug_id).each(function () {
batch_current_fields++;
});
if (batch_current_fields == 0) {
//first remove the preloaded one
$(".preloaded-default").remove();
//$("#this_batch_quantity_"+drug_id).append("<input type='text' step='0.01' required name='batch_quantity_to_dispense[]' placeholder='Qty picked from this batch' class='col-sm-12 dynamic-batch-qty_"+drug_id+" all-batch-"+all_batches_count+"'>");
//$("#this_batch_amount_"+drug_id).append("<div><br><br><label class='label label-danger remove_batch undeletable' id='all-batch-"+all_batches_count+"'>Remove</label></div>");
all_batches_count++;
}
/* $("#this_batch_quantity_"+drug_id).append("<br><br><input type='text' step='0.01' required name='batch_quantity_to_dispense[]' placeholder='Qty picked from this batch' class='col-sm-12 dynamic-batch-qty_"+drug_id+" all-batch-"+all_batches_count+"'>"); */
$("#batch_dropdown_"+drug_id).append("<br><br><span class='all-batch-"+all_batches_count+"'>&nbsp;&nbsp;<input type='hidden' name='batch_drug_id[]' value='"+drug_id+"'>Batch <select class='batch_dispensed_from' style='color: black; font-size: 14px;' required name='batch_dispensed_from[]'><?php echo $option_batches; ?></select><input type='text' step='0.01' required name='batch_quantity_to_dispense[]' placeholder='Qty picked from this batch' class='dynamic-batch-qty_"+drug_id+" all-batch-"+all_batches_count+" required_btch_qty' style='padding: 1px 5px; height: 20px; color:#2c2a2a; font-size: 14px'><label class='label label-danger remove_batch' id='all-batch-"+all_batches_count+"'>Remove</label></span>");
/* $("#this_batch_amount_"+drug_id).append("<div><br><label class='label label-danger remove_batch' id='all-batch-"+all_batches_count+"'>Remove</label></div>"); */
all_batches_count++;
});
$("#dispensation_details_table").on("click", ".remove_batch", function (e) {
e.preventDefault();
let batch_count = /\d+(?=\D*$)/.exec($(this).attr('id'));
//if class is "undeletable", proceed to remove
$(".all-batch-"+batch_count).remove();
$(this).remove();
});
$(".else_chx").change(function(){
let drug_id = /\d+(?=\D*$)/.exec($(this).attr('id'));
console.log("purchased elsewhere ==> "+drug_id);
$(".bth_drug_"+drug_id).removeAttr("required");
$(".dynamic-batch-qty_"+drug_id).removeAttr("required");
$("#batch_required_checker").val("true")
})
</script>
@endpush
@@ -0,0 +1,174 @@
@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/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
<h4 class="page-title">{{ __('pharmacy.cancel_treatment')}}</h4>
</div>
<div class="col-lg-6 col-sm-6 col-md-6 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}"><i class="fa fa-home"></i> {{ __('investigations.dashboard') }}</a></li>
</ol>
</div>
</div>
{{ Form::open(['route' => 'pharmacy.view_prescriptions_to_cancel', 'method' => 'ANY']) }}
<div class="white-box">
<div class="row">
<div class="col-md-3">
<div class="form-group" id="searchby">
{{ Form::label('search_by', __('investigations.date')) }}
{{ Form::select('search_by', ['0'=>'Last 24 hours','1'=>'Custom Date','2'=>'Custom Range'], '', ['class' => 'form-control','id'=>'search_by', 'required']) }}
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-3" style="display: none;" id="date_search">
<div class="form-group" id="reg_date" style="padding-top: 23px;">
<div class="input-group">
{{ Form::text('reg_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'datepicker-autoclose']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-3" style="display: none;" id="date_range_search">
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{ Form::label('start_date', __('investigations.from')) }}
<div class="input-group">
{{ Form::text('start_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-1']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group" id="reg_date">
{{ Form::label('end_date', __('investigations.to')) }}
<div class="input-group">
{{ Form::text('end_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-2']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group" style="padding-top: 5px;"><br>
{{ Form::button(__('investigations.submit'),['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10', 'id'=>'select_patient']) }}
</div>
</div>
<div class="col-md-3">
<h4>{{ __('pharmacy.search_date') }}: <code>{{ $date_search }}</code></h4>
</div>
</div>
</div>
{{ Form::close() }}
<div class="row">
<div class="col-sm-12">
@include('flash::message')
<div class="white-box" style="border-radius: 5px;">
<div class="table-responsive">
<table class="table table-hover color-bordered-table success-bordered-table table-striped">
<thead>
<tr>
<th>{{ __('investigations.date') }}</th>
<th>{{ __('investigations.patient_names') }}</th>
<th>{{ __('pharmacy.drugs_ordered') }}</th>
<th>{{ __('investigations.action') }}</th>
<th></th>
</tr>
</thead>
<tbody>
@if(count($prescriptions) > 0)
@foreach($prescriptions as $prescription)
@php
$drug_ids = explode(",", $prescription->drugs);
$quantites = explode(",", $prescription->quantities_dispensed);
@endphp
<tr>
<td>{{ streamline_date_time($prescription->created_at) }}</td>
<td>{{ get_full_name($prescription->patient_id, 'id', 'first_name', 'last_name', 'patients') }} ({{ get_name($prescription->patient_id, 'id', 'number', 'patients') }})</td>
<td>
<ol>
@for($i=0; $i < count($drug_ids); $i++)
<li>{{ get_name($drug_ids[$i], 'id', 'name', 'drugs') }}</li>
@endfor
</ol>
</td>
<td>
<a class="btn btn-danger btn-rounded btn-small" href="/pharmacy/cancel_prescriptions/{{ $prescription->id }}">{{ __('pharmacy.cancel_prescription') }}</a>
</td>
<td>
<a href="/patient_episodes/set_patient_id/{{ $prescription->patient_id }}" class="btn btn-info btn-rounded">{{ __('investigations.select_patient') }}</a>
</td>
</tr>
@endforeach
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<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>
<!-- Date Picker Plugin JavaScript -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script>
$('.table').DataTable({
dom: 'Bfrtip',
//order: [ [0, 'desc'] ],
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
],
'pageLength' : 50,
});
$('#datepicker-autoclose,#datepicker-autoclose-1,#datepicker-autoclose-2').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
$('#search_by').change(function () {
if ($(this).val() == 1) {
$('#date_search').show();
$('#date_range_search').hide();
}
else if ($(this).val() == 2) {
$('#date_range_search').show();
$('#date_search').hide();
}
else {
$('#date_search,#date_range_search').hide();
}
});
</script>
@endpush
@@ -0,0 +1,141 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-6 col-md-7 col-sm-7 col-xs-12">
<h4 class="page-title">{{ __('pharmacy.view_ward_dispensing') }}</h4>
</div>
<div class="col-lg-6 col-sm-5 col-md-5 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li class="active">{{ __('pharmacy.view_ward_dispensing') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="white-box">
<div class="row">
{{ Form::open(['route' => 'pharmacy.view_ward_dispensing' , 'data-toggle' => 'validator']) }}
<div class="col-md-1"></div>
<div class="col-md-3">
<div class="form-group">
{{ Form::label('ward', __('pharmacy.select_ward')) }}
{{ Form::select('ward',$wards,'',['id'=>'prescription-drugs','class' => 'form-control compulsory', 'required']) }}
</div>
</div>
<div class="col-md-3">
<div class="form-group">
{{ Form::label('start_date',__('pharmacy.date_from')) }}
{{ Form::text('start_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'start_date']) }}
</div>
</div>
<div class="col-md-3">
<div class="form-group">
{{ Form::label('end_date',__('pharmacy.date_to')) }}
{{ Form::text('end_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'end_date']) }}
</div>
</div>
<div class="col-md-2">
<br>
{{ Form::button(__('pharmacy.search'),['type'=>'submit','class'=>'btn btn-rounded btn-success waves-effect waves-light m-r-10']) }}
</div>
{{ Form::close() }}
</div>
</div>
</div>
</div>
@if($search_complete)
<div class="row">
<div class="col-md-12">
<div class="white-box">
<h4 style="color: #0060BF; font-weight: bolder;">{{ get_name($ward_id, 'id', 'name', 'wards') }}: {{ streamline_date($start_date) }} {{ __('pharmacy.to') }} {{ streamline_date($end_date) }}</h4>
<div class="table-responsive">
<table class="table success-table table-sm table-striped table-hover">
<thead>
<tr>
<th>{{ __('pharmacy.date') }}</th>
<th>{{ __('pharmacy.drug_name') }}</th>
<th>{{ __('pharmacy.quantity_returned') }}</th>
<th>{{ __('pharmacy.quantity_dispensed') }}</th>
<th>{{ __('pharmacy.units') }}</th>
<th>{{ __('pharmacy.comments') }}</th>
<th>{{ __('pharmacy.received_by') }}</th>
</tr>
</thead>
<tbody>
@if(count($ward_dispensing) > 0)
@foreach($ward_dispensing as $record)
@php
$drug_ids_array = explode(",", $record->drug_id);
$quantity_returned_array = explode(",", $record->quantity_returned);
$quantity_dispensed_array = explode(",", $record->quantity_dispensed);
$comments_array = explode(",", $record->comment);
@endphp
<tr>
<td rowspan="{{ count($drug_ids_array) }}">{{ streamline_date($record->dispensation_date) }}</td>
<td>{{ get_name($drug_ids_array[0], 'id', 'name', 'drugs') }}</td>
<td>{{ $quantity_returned_array[0] }}</td>
<td>{{ $quantity_dispensed_array[0] }}</td>
<td>{{ get_name(get_name($drug_ids_array[0], 'id', 'unit_id', 'drugs'), 'id', 'name', 'unit_of_measure') }}</td>
<td>{{ $comments_array[0] }}</td>
<td>{{ get_full_name($record->received_by, 'id', 'first_name', 'last_name', 'users') }}</td>
</tr>
@for($i = 1; $i < count($drug_ids_array); $i++)
<tr>
<td>{{ get_name($drug_ids_array[$i], 'id', 'name', 'drugs') }}</td>
<td>{{ $quantity_returned_array[$i] }}</td>
<td>{{ $quantity_dispensed_array[$i] }}</td>
<td>{{ get_name(get_name($drug_ids_array[$i], 'id', 'unit_id', 'drugs'), 'id', 'name', 'unit_of_measure') }}</td>
<td>{{ $comments_array[$i] }}</td>
<td>{{ get_full_name($record->received_by, 'id', 'first_name', 'last_name', 'users') }}</td>
</tr>
@endfor
@endforeach
@else
<tr>
<td colspan="6" class="text-center">{{ __('pharmacy.no_records_for_search') }}</td>
</tr>
@endif
</tbody>
</table>
</div>
{{ $ward_dispensing->links() }}
</div>
</div>
</div>
@endif
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#start_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
$('#end_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd-mm-yyyy'
});
});
</script>
@endpush
@@ -0,0 +1,164 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-6 col-md-7 col-sm-7 col-xs-12">
<h4 class="page-title">{{ __('pharmacy.incoming_ward_chart') }}</h4>
</div>
<div class="col-lg-6 col-sm-5 col-md-5 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li class="active">{{ __('pharmacy.incoming_ward_chart') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('flash::message')
@foreach ($errors->all() as $error)
<div>{{ $error }}</div>
@endforeach
</div>
</div>
@include('pharmacy::pharmacy.ward_dispensing_menu')
<div class="white-box">
@php
$count = 1;
@endphp
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table table-bordered">
<thead>
<tr>
<th>#</th>
<th>{{ __('pharmacy.drugs') }}</th>
<th>{{ __('pharmacy.quantity') }}</th>
<th>{{ __('pharmacy.comments') }}</th>
<th>{{ __('pharmacy.received_by') }}</th>
<th>{{ __('pharmacy.date') }}</th>
</tr>
</thead>
<tbody>
@if($chart_approval_record)
@php
$drug_ids_array = explode(",", $chart_approval_record->drug_ids);
$quantities_array = explode(",", $chart_approval_record->quantity_dispensed);
$comments_array = explode(",", $chart_approval_record->comments);
@endphp
@for($i=0; $i < count($drug_ids_array); $i++)
<tr>
<td>
{{ $count }}
</td>
<td>
{{ get_name($drug_ids_array[$i], "id", "name", "drugs") }}
</td>
<td>
{{ $quantities_array[$i] }}
</td>
<td>
{{ $comments_array[$i] }}
</td>
<td>
{{ get_full_name($chart_approval_record->received_by, "id", "first_name", "last_name", "users") }}
</td>
<td>
{{ streamline_date_time($chart_approval_record->created_at) }}
</td>
</tr>
@php $count++; @endphp
@endfor
@endif
</tbody>
</table>
</div>
<hr>
@if(!is_null($chart_approval_record->cancer_protocol_order_id))
<a class="btn btn-sm btn-success" href="/print_ward_chart_report_details/{{ $chart_approval_record->id }}">Print Details</a>
@endif
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<!-- data time picker dependency -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<!-- add datatables -->
<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/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>
<!-- validator -->
<script src="{{ asset('elite/js/validator.js') }}"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#datepicker-autoclose,#datepicker-autoclose-1,#datepicker-autoclose-2').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy'
});
$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy',
{ extend: 'csv',
message: 'WARD DISPENSING PER CHART REPORT'
},
{ extend: 'excel',
message: 'WARD DISPENSING PER CHART REPORT',
exportOptions: {
columns: [ 0, 1, 2, 4, 5 ]
},
sheetName: 'WARD DISPENSING PER CHART REPORT ON STREAMLINE'
},
{ extend: 'pdf',
message: 'WARD DISPENSING PER CHART REPORT',
orientation: 'landscape',
pageSize: 'LETTER',
exportOptions: {
columns: [ 0, 1, 2, 4, 5 ]
},
customize: function(doc) {
doc.defaultStyle.fontSize = 10;
}
},
{ extend: 'print',
message: 'WARD DISPENSING PER CHART REPORT',
exportOptions: {
columns: [ 0, 1, 2, 4, 5 ]
},
customize: function (win) {
$(win.document.body)
.css('font-size', '10pt')
.css('background', '#fff')
.prepend(
'<img src="<?php echo asset('uploads/logo/logo-sm.png'); ?>" style="position:absolute; top:0; right:0;" />'
);
$(win.document.body).find('table')
.addClass('compact')
.css('font-size', 'inherit');
}
}
]
});
});
</script>
@endpush
@@ -0,0 +1,224 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-6 col-md-7 col-sm-7 col-xs-12">
<h4 class="page-title">{{ __('pharmacy.view_ward_dispensing') }}</h4>
</div>
<div class="col-lg-6 col-sm-5 col-md-5 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li class="active">{{ __('pharmacy.view_ward_dispensing') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
</div>
</div>
<div class="row">
<div class="col-sm-12">
<!--Flash messages at the top -->
@include('flash::message')
@foreach ($errors->all() as $error)
<div>{{ $error }}</div>
@endforeach
<div class="white-box">
<div class="pull-right">
<a href="{{ route('pharmacy.view_ward_dispensing') }}" class="btn btn-rounded btn-primary">{{ __('pharmacy.view_ward_dispensing') }}</a>
</div>
<br><br><br>
<div class="row">
<div class="col-sm-8">
{{ Form::open(['route' => 'pharmacy.ward_dispensing' , 'data-toggle' => 'validator']) }}
<div class="form-group">
{{ Form::label('drugs', __('pharmacy.select_drugs_ward_dispensing')) }}
{{ Form::select('drugs_to_dispense[]',$drugs,'',['id'=>'prescription-drugs','multiple'=>true,'class' => 'form-control col-sm-8 compulsory prescription-drugs']) }}
</div>
<div class="submit-button">
{{ Form::button(__('pharmacy.confirm_drugs'),['type'=>'submit','class'=>'btn btn-rounded btn-success waves-effect waves-light m-r-10','style'=>'padding: .6rem 1.2rem;']) }}
</div>
{{ Form::close() }}
</div>
<div class="col-sm-4">
@if(isset($drugs_to_dispense_collection))
{{ Form::open(['route' => 'pharmacy.store' , 'data-toggle' => 'validator']) }}
<div class="form-group">
{{ Form::label('ward', __('pharmacy.ward_allocation')) }}
{{ Form::select('ward',$wards,'',['id'=>'prescription-drugs','class' => 'form-control col-sm-8 compulsory ward_allocation','required']) }}
</div>
<div class="form-group">
{{ Form::label('received_by', __('pharmacy.received_by')) }}
{{ Form::select('received_by',$staff_array,'',['id'=>'staff_array','class' => 'form-control col-sm-8 compulsory','required']) }}
</div>
{{ Form::label('dispensation_date',__('pharmacy.date')) }}
<div class="input-group">
{{ Form::text('dispensation_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'datepicker-autoclose']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
@endif
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="white-box">
<div class="table-responsive">
<table class="table success-table table-sm table-striped table-hover">
<thead>
<tr>
<th style="width: 5%;">#</th>
<th style="width: 20%;">{{ __('pharmacy.drug') }}</th>
<th style="width: 20%;">{{ __('pharmacy.balance_on_ward') }}</th>
<th style="width: 20%;">{{ __('pharmacy.dispensed') }}</th>
<th style="width: 10%;">{{ __('pharmacy.total') }}</th>
<th style="width: 10%;">{{ __('pharmacy.stock') }}</th>
<th style="width: 15%;">{{ __('pharmacy.comment') }}</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2" style="background-color: #FFE6E6; font-weight: bolder; text-decoration: underline;border: 1px solid #ddd;">{{ __('pharmacy.selected') }}</td>
<td colspan="5" style="border: 1px solid #ddd;"></td>
</tr>
@php $count = 1; @endphp
@if(isset($drugs_to_dispense_collection) && count($drugs_to_dispense_collection) > 0)
@foreach($drugs_to_dispense_collection as $drug)
<tr id="my_row{{ $drug->id }}" class="to_remove">
<td style="padding: 2px;border: 1px solid #ddd;">
@if ($drug->pharmacy_stock > 0 )
<a class="remove" href="#" style="color: maroon">x</a>&nbsp;{{ $count }}
<input type="hidden" name="drug_id[]" value="{{$drug->id}}">
@endif
</td>
<td style="padding: 2px;border: 1px solid #ddd;">
@php
$insurance_color = ($drug->insurance_coverage == 'Yes') ? "green" : "orange";
@endphp
@if ($drug->pharmacy_stock <= 0)
<span class="badge badge-danger">{{ __('pharmacy.out_of_stock') }}</span>
@endif
<span style="color:{{$insurance_color}}"> {{$drug->name}}</span>
<?php
$pharm_comment = trim($drug->pharmacy_comment);
if (!empty($pharm_comment)):
echo "<div style='padding: 1px; margin: 6px 1px 0px 1px; font-size: smaller' class='alert alert-info span12 margin-none well'>" . $pharm_comment . "</div>";
endif;
/*the reference area code was here put it doesn't exist in the drugs table as was the case in the inventory_items*/
?>
</td>
<td style="padding: 2px;border: 1px solid #ddd;">
<input type='number' value="0" name='quantity_returned[]' id="quantity_returned{{$drug->id}}" class="form-control">
</td>
<td style="padding: 2px;border: 1px solid #ddd;">
<input type='number' style="margin-bottom: 0px;" name='quantity_dispensed[]' id="quantity_dispensed{{$drug->id}}" class="form-control compulsory" max="{{ $drug->pharmacy_stock }}" required/>
</td>
<td style="padding: 2px;border: 1px solid #ddd;">
<input type='number' style="margin-bottom: 0px;" name='total[]' id="total{{$drug->id}}" class="form-control" readonly />
</td>
<td class="center" style="padding: 2px;border: 1px solid #ddd;">
<input type="text" readonly name="stock[]" id="stock{{$drug->id}}" class="form-control" value="{{ $drug->pharmacy_stock }}" >
</td>
<td style="padding: 2px;border: 1px solid #ddd;">
<textarea name="pharmacy_comment[]" id="pharmacy_comment{{$drug->id}}" class="form-control"></textarea>
</td>
</tr>
@php $count++; @endphp
@endforeach
@else
<tr class="warning"><td class="center" colspan="8" style="border: 1px solid #ddd;">{{ __('pharmacy.no_drug_search_yet') }}</td></tr>
@endif
</tbody>
</table>
@if(isset($drugs_to_dispense_collection))
<input type="submit" name="submit_dispense" onclick="return submitDispense();" class = "btn btn-rounded btn-success pull-right" value="Dispense to ward"/>
@endif
{{ Form::close() }}
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<!-- data time picker dependency -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<!-- -->
<script src="{{ asset('elite/js/validator.js') }}"></script>
<script type="text/javascript">
function submitDispense(){
// begin checking to ensure there is enough quantity dispensed
let drug_id = $("input[name='drug_id[]']" ).map(function(){
return this.value;
}).get();
let quantity_dispensed = $("input[name='quantity_dispensed[]']" ).map(function(){
return this.value;
}).get();
$.ajax({
url: '/check_dispensed_drugs_quantity',
data: {'drug_id_array[]':drug_id, 'quantity_dispensed_array[]':quantity_dispensed},
success: function(response){
if (response[0] === "1") {
alert(response[1]);
return false;
} else {
//
}
}
});
}
$(document).ready(function() {
$('#datepicker-autoclose').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy',
setDate: new Date(),
readOnly: true
});
$('.prescription-drugs,#staff_array,.ward_allocation').select2({
placeholder: "Select drugs"
});
$('.select2-selection.select2-selection--single').css('height','calc(3.85rem)');
$('.select2-selection.select2-selection--single').css('padding-top','5px');
$('.select2-selection.select2-selection--single').css('border-left', '3px solid #F08080');/*add compulsory class*/
$('.select2-selection.select2-selection--single.sec_d').css('border-left', '3px solid #aaa');
$('.select2-selection__arrow').css('top','3px');
$("input[id^='quantity_returned']").each(function () {
var id = parseInt(this.id.replace("quantity_returned", ""), 10);
$("#quantity_returned" + id + ",#quantity_dispensed" + id + ",#total" + id).change(function () {
var quantity_returned = $("#quantity_returned" + id).val();
var quantity_dispensed = $("#quantity_dispensed" + id).val();
var total_dispensed = parseFloat(quantity_returned) + parseFloat(quantity_dispensed);
$("#total" + id).val(total_dispensed);
});
});
$(".remove").on("click", function () {
$(this).parent().parent().remove();
});
});
</script>
@endpush
@@ -0,0 +1,17 @@
<div class="panel panel-default">
<div class="panel-body">
<a href="{{ url('ward_dispensing_per_chart') }}" class="nav-item btn btn-default ti-plus"> {{ __('pharmacy.ward_dispensing_per_chart_request') }}</a>
@if( Auth::user()->can('view-incoming-ward-dispensing-per-chart'))
<a href="{{ url('incoming_ward_charts') }}" class="nav-item btn btn-success ti-pencil"> {{ __('pharmacy.incoming_ward_charts_requests') }}</a>
@endif
@if( Auth::user()->can('approve-ward-dispensings-per-chart'))
<a href="{{ url('ward_dispensing_per_chart_report') }}" class="nav-item btn btn-primary ti-book"> {{ __('pharmacy.ward_dispensing_per_chart_report') }}</a>
@endif
@if( Auth::user()->can('return-drugs-per-chart'))
<a href="{{ url('return_drugs_per_chart') }}" class="nav-item btn btn-info ti-book"> {{ __('pharmacy.return_drugs_per_chart') }}</a>
@endif
</div>
</div>
@@ -0,0 +1,639 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-6 col-md-7 col-sm-7 col-xs-12">
<h4 class="page-title">{{ __('pharmacy.ward_dispensing_chart') }}</h4>
</div>
<div class="col-lg-6 col-sm-5 col-md-5 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li class="active">{{ __('pharmacy.ward_dispensing_chart') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('flash::message')
@foreach ($errors->all() as $error)
<div>{{ $error }}</div>
@endforeach
</div>
</div>
@include('pharmacy::pharmacy.ward_dispensing_menu')
@php $count = 1; @endphp
<div class="row">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-12">
<div class="panel">
<div class="panel-heading" style="display: none;">{{ __('pharmacy.ward_dispensing_chart') }}</div>
<div class="panel-body">
{{ Form::open(['route' => 'pharmacy.ward_dispensing_per_chart', 'class' => 'typeahead', 'method' => 'ANY', 'role' => 'search']) }}
{{ Form::hidden('patient_id', 0, ['id' => 'patient_id']) }}
<div class="row">
<div class="col-md-3">
<div class="form-group">
{{ Form::label('ward_id', __('pharmacy.wards')) }}
{{ Form::select('ward_id', $wards, '', ['class' => 'form-control compulsory', 'required']) }}
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-3">
<div class="form-group" id="searchby">
{{ Form::label('search_by', __('pharmacy.admission_date')) }}
{{ Form::select('search_by', ['3'=>__('pharmacy.all_records'),'0'=>__('pharmacy.last_24_hours'),'1'=>__('pharmacy.custom_date'),'2'=>__('pharmacy.date_range')], '', ['class' => 'form-control','id'=>'search_by', 'required']) }}
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-3" style="display: none;" id="date_search">
<div class="form-group" id="reg_date" style="padding-top: 23px;">
<div class="input-group">
{{ Form::text('reg_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'datepicker-autoclose']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-3" style="display: none;" id="date_range_search">
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{ Form::label('start_date', __('pharmacy.from')) }}
<div class="input-group">
{{ Form::text('start_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-1']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group" id="reg_date">
{{ Form::label('end_date', __('pharmacy.to')) }}
<div class="input-group">
{{ Form::text('end_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-2']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3">
{{ Form::label('search_patient', 'Search By Patient') }}
<div class="input-group">
<select class="form-control" name="patient_number" id="patient_number"></select>
</div>
</div>
<div class="col-md-3">
<div class="form-group" style="padding-top: 5px;"><br>
{{ Form::button(__('pharmacy.submit'),['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10', 'id'=>'select_patient']) }}
</div>
</div>
</div>
<br>
@if($search_text !== 0)
<h3>{{ $search_text }}</h3>
@endif
{{ Form::close() }}
</div>
</div>
@if(count($inpatients) > 0)
<div class="panel">
{{ Form::open(['route' => 'pharmacy.store_ward_dispensing_per_chart', 'class' => 'typeahead', 'method' => 'ANY']) }}
<input type="hidden" name="chart_ward_id" value="{{ $ward_id }}">
<div class="panel-body">
<div class="row">
<div class="col-sm-12">
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table table-bordered">
<thead>
<tr>
<th>#</th>
<th>{{ __('pharmacy.patient_name') }}</th>
<th>{{ __('pharmacy.ward') }}</th>
<th>{{ __('pharmacy.date_of_admission') }}</th>
<th>{{ __('pharmacy.drugs_given_so_far') }}</th>
<th width="30%">{{ __('pharmacy.drug_and_qty_given') }}</th>
<th width="10%">{{ __('pharmacy.action') }}</th>
</tr>
</thead>
<tbody>
@if(count($inpatients) > 0)
@foreach($inpatients as $in_patient)
@php
$original_ward_presc = \Streamline\Models\WardTreatment::where(['patient_id' => $in_patient->patient_id, 'episode_id' => $in_patient->episode_id])->get();
$stopped_ward_drugs_array = [];
foreach ($original_ward_presc as $presc_record) {
$stopped_drugs_array = is_null($presc_record->stopped_drugs) ? [] : explode(",", $presc_record->stopped_drugs);
$stopped_ward_drugs_array = array_merge($stopped_ward_drugs_array, $stopped_drugs_array);
}
@endphp
<tr>
<td>
{{ $count }}
</td>
<td>
{{ ucwords(strtolower(get_full_name($in_patient->patient_id, "id", "first_name", "last_name", "patients"))) }}
({{ get_name($in_patient->patient_id, "id", "number", "patients") }})
</td>
<td>
{{ get_name($in_patient->ward_id, "id", "name", "wards") }}
</td>
<td>
{{ streamline_date($in_patient->created_at) }}
</td>
<td>
@php $ward_quantities_given_option2 = DB::table('ward_treatment_dispensations')->where(['patient_id' => $in_patient->patient_id, 'episode_id' => $in_patient->episode_id])->groupBy('drug_id')->selectRaw('*, sum(quantity_given) as quantity_given')->get(); @endphp
@if(count($ward_quantities_given_option2) > 0)
<table class='table table-bordered table-striped'>
<tr>
<th style='color: black' class='text-center'> {{ __('pharmacy.drug_name') }} </th>
<th style='color: black' class='text-center'> {{ __('pharmacy.date') }} </th>
<th style='color: black' class='text-center'> {{ __('pharmacy.quantity') }} </th>
</tr>
@php
$dispensation_details = \Streamline\Models\WardTreatmentDispensation::where(['patient_id' => $in_patient->patient_id, 'episode_id' => $in_patient->episode_id, 'drug_id' => $ward_quantities_given_option2[0]->drug_id])->get();
@endphp
<tr>
<td>{{ get_name($ward_quantities_given_option2[0]->drug_id, "id", "name", "drugs") }}</td>
<td>{{ streamline_date_time($dispensation_details[0]->created_at) }}</td>
<td>{{ $dispensation_details[0]->quantity_given }}</td>
</tr>
@if(count($ward_quantities_given_option2) > 1)
<tr>
<td colspan="3"><a class="btn btn-info btn-block" onclick="display_drugs_given_so_far({{ $in_patient->patient_id }}, {{ $in_patient->episode_id }}, {{ $count }})">{{ __('pharmacy.view_more') }}</a></td>
</tr>
@endif
</table>
@endif
</td>
<td>
<h3><label class="label label-warning">DRUGS</label></h3>
<input type="hidden" id="patient_id_{{ $count }}" value="{{ $in_patient->patient_id }}" />
<input type="hidden" id="episode_id_{{ $count }}" value="{{ $in_patient->episode_id }}" />
<input type="hidden" id="inpatient_info_id_{{ $count }}" value="{{ $in_patient->id }}" />
<input type="hidden" id="ward_id_{{ $count }}" value="{{ $in_patient->ward_id }}" />
<div class="form-group" id="drugs_given_row_{{ $count }}">
@if(count($ward_quantities_given_option2) > 0)
@foreach($ward_quantities_given_option2 as $patient_record)
<div class="row">
<div class="col-sm-8">
<select name="dispensed_drugs[]" id="prescription_drugs_{{ $count }}" onchange="showStockLevel(this)" class="form-control prescription_drugs to_preload_{{$patient_record->patient_id}}_{{$patient_record->drug_id}}">{!! $drugs_dropdown !!}</select>
<div id='stock_span_{{ $count }}'></div>
</div>
<div class="col-sm-3">
@if (in_array($patient_record->drug_id, $stopped_ward_drugs_array))
<input type="number" name="quantity_dispensed[]" class="form-control" placeholder="Quantity Given" style="padding-left: 5px;padding-right:5px;" step=".01" min="0.01" readonly/>
@else
<input type="number" name="quantity_dispensed[]" class="form-control" placeholder="Quantity Given" style="padding-left: 5px;padding-right:5px;" step=".01" min="0.01"/>
@endif
</div>
<div class="col-sm-1"></div>
<input type="hidden" name="patient_id[]" value="{{ $in_patient->patient_id }}" />
<input type="hidden" name="episode_id[]" value="{{ $in_patient->episode_id }}" />
<input type="hidden" name="inpatient_info_id[]" value="{{ $in_patient->id }}" />
<input type="hidden" name="ward_id[]" value="{{ $in_patient->ward_id }}" />
</div>
<br>
<script>
document.querySelector('.to_preload_{{ $patient_record->patient_id }}_{{ $patient_record->drug_id }} option[value="{{$patient_record->drug_id}}"]').selected = true;
</script>
@endforeach
@endif
</div>
<label class="label label-primary" id="add_drug_row_{{ $count }}">{{ __('pharmacy.add_drug_small') }}</label>
@php
$ordered_cancer_protocols = \Illuminate\Support\Facades\DB::table('ordered_cancer_protocols')
->whereNull('deleted_at')->where('protocol_status', 0)->where('inpatient_id', $in_patient->id)->get();
@endphp
@if(count($ordered_cancer_protocols) > 0)
<hr>
<h3><label class="label label-warning">PROTOCOLS</label></h3>
@foreach($ordered_cancer_protocols as $ordered_cancer_protocol)
<div class="row">
<div class="col-md-8">
<h4 id="prescribed_protocols_{{ $ordered_cancer_protocol->protocol_id }}_{{ $count }}">{{ $cancer_protocols[$ordered_cancer_protocol->protocol_id] }}</h4>
</div>
<div class="col-md-4">
<a href="#prescribed_protocols_row_{{ $ordered_cancer_protocol->protocol_id }}_{{ $count }}" onclick="view_prescribed_protocols_details({{ $count }}, 1, {{ $ordered_cancer_protocol->protocol_id }})">View Details</a>
</div>
</div>
<hr>
@endforeach
@endif
</td>
<td>
<a href="/patient_episodes/set_patient_id/{{ $in_patient->patient_id }}" class="btn btn-info btn-rounded btn-sm">{{ __('investigations.select_patient') }}</a>
<br><br>
<a href="/select_inpatient_sheet/{{ $in_patient->patient_id }}/{{ $in_patient->episode_id }}" class="btn btn-default btn-rounded btn-sm">{{ __('pharmacy.go_to_inpatient_sheet') }}</a>
<br><br>
<button class="btn btn-primary btn-sm btn-rounded viewPrescription" value="{{ $in_patient->patient_id }}_{{ $in_patient->episode_id }}">
{{ __('pharmacy.view_ward_prescription') }}
</button>
</td>
</tr>
@foreach($ordered_cancer_protocols as $ordered_cancer_protocol)
<tr class="prescribed_protocols_row" id="prescribed_protocols_row_{{ $ordered_cancer_protocol->protocol_id }}_{{ $count }}" style="display: none">
<td colspan="6">{!! get_prescribed_protocol_html($in_patient->id, $ordered_cancer_protocol->protocol_id) !!}</td>
<td><a href="#prescribed_protocols_{{ $ordered_cancer_protocol->protocol_id }}_{{ $count }}" onclick="view_prescribed_protocols_details({{ $count }}, 2, {{ $ordered_cancer_protocol->protocol_id }})" class="btn btn-danger">Hide Details</a></td>
</tr>
@endforeach
@php $count++; @endphp
@endforeach
@endif
</tbody>
</table>
</div>
<button type="submit" class="btn btn-success btn-rounded" id="submitChart" name="submit_chart" value="submit_chart">
{{ __('pharmacy.submit_chart') }}
</button>
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">×</button>
<span>
- {{ __('pharmacy.click') }} <b>{{ __('pharmacy.submit_chart') }}</b> {{ __('pharmacy.to_confirm_dispensations_for_approval') }}.<br>
<!-- - Click <b>Save For Later</b> to save the charts so that you can resume editing it at a later time. -->
</span>
</div>
</div>
</div>
</div>
{{ Form::close() }}
</div>
@endif
</div>
</div>
</div>
</div>
<div class="modal" id="showPatientPrescriptionModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">{{ __('pharmacy.details') }}</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-12">
<table class="success-table table-sm table-striped table-hover">
<thead>
<tr>
<th>#</th>
<th style="width: 25%">{{ __('pharmacy.drug_name') }}</th>
<th style="width: 15%">{{ __('pharmacy.dose') }}</th>
<th style="width: 15%">{{ __('pharmacy.frequency') }}</th>
<th style="width: 10%">{{ __('pharmacy.duration') }}</th>
<th style="width: 8%">{{ __('pharmacy.quantity') }}</th>
<th style="width: 25%">{{ __('pharmacy.instructions') }}</th>
</tr>
</thead>
<tbody id="show_patient_prescriptions">
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal" id="modal_view_drugs_given_so_far" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title text-center"><b>{{ __('pharmacy.drugs_given_so_far') }}</b></h4>
</div>
<div class="modal-body">
<div class="table-responsive" id="modal_table"></div>
<input type="hidden" name="current_count" id="current_count" />
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ __('pharmacy.close') }}</button>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<!-- data time picker dependency -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<!-- add datatables -->
<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/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>
<!-- validator -->
<script src="{{ asset('elite/js/validator.js') }}"></script>
<script type="text/javascript">
var x1 = <?php echo $count; ?>;
function display_drugs_given_so_far(patient_id, episode_id, current_count) {
$('#current_count').val(current_count);
$.ajax({
method: 'GET',
url: '/patient_drugs_given_so_far/' + patient_id + "/" + episode_id,
success: function(response){
let responseArray = JSON.parse(response);
$("#modal_table").html(responseArray["html"]);
$("#modal_view_drugs_given_so_far").modal('show');
}
});
}
function submitDispense(){
// begin checking to ensure there is enough quantity dispensed
let drug_id = $("input[name='drug_id[]']" ).map(function(){
return this.value;
}).get();
let quantity_dispensed = $("input[name='quantity_dispensed[]']" ).map(function(){
return this.value;
}).get();
$.ajax({
url: '/check_dispensed_drugs_quantity',
data: {'drug_id_array[]':drug_id, 'quantity_dispensed_array[]':quantity_dispensed},
success: function(response){
if (response[0] === "1") {
alert(response[1]);
return false;
} else {
//
}
}
});
}
function view_prescribed_protocols_details(id, value, order_id) {
$('.prescribed_protocols_row').hide();
if(value == 1) {
$('#prescribed_protocols_row_' + order_id + '_' + id).show();
} else {
$('#prescribed_protocols_row_' + order_id + '_' + id).hide();
}
}
function protocol_drug_selection(value, id) {
if ($(value).is(':checked')) {
$('#' + id + 'is_drug_selected').val(1);
$('.' + id + 'class').css("background", "#FFFF99");
} else {
$('#' + id + 'is_drug_selected').val(0);
$('.' + id + 'class').css("background", "transparent");
}
}
$(document).ready(function() {
$('#datepicker-autoclose,#datepicker-autoclose-1,#datepicker-autoclose-2').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy'
});
$('#search_by').change(function () {
if ($(this).val() == 1) {
$('#date_search').show();
$('#date_range_search').hide();
}
else if ($(this).val() == 2) {
$('#date_range_search').show();
$('#date_search').hide();
}
else {
$('#date_search,#date_range_search').hide();
}
});
$('.prescription_drugs, .prescribed_protocols').select2();
$('.select2-selection.select2-selection--single').css('height','calc(3.85rem)');
$('.select2-selection.select2-selection--single').css('padding-top','5px');
//$('.select2-selection.select2-selection--single').css('border-left', '3px solid #F08080');/*add compulsory class*/
$('.select2-selection.select2-selection--single.sec_d').css('border-left', '3px solid #aaa');
$('.select2-selection__arrow').css('top','3px');
$("input[id^='quantity_returned']").each(function () {
var id = parseInt(this.id.replace("quantity_returned", ""), 10);
$("#quantity_returned" + id + ",#quantity_dispensed" + id + ",#total" + id).change(function () {
var quantity_returned = $("#quantity_returned" + id).val();
var quantity_dispensed = $("#quantity_dispensed" + id).val();
var total_dispensed = parseFloat(quantity_returned) + parseFloat(quantity_dispensed);
$("#total" + id).val(total_dispensed);
});
});
$(".remove").on("click", function () {
$(this).parent().parent().remove();
});
$("[id^='add_drug_row_']").on("click", function (e) {
//get the id by filtering to get only the digit from "id" attribute
var id = /\d+(?=\D*$)/.exec($(this).attr('id'));
e.preventDefault();
add_drug_row(id);
});
$(wrapper).on("click", ".remove_field", function (e) {
e.preventDefault();
$(this).parent('div').parent('div').parent('div').remove();
});
$("#wrapper").on("click", ".remove_field", function (e) {
e.preventDefault();
$(this).parent('div').remove();
x1--;
});
/*$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy',
{ extend: 'csv',
message: 'WARD DISPENSING PER CHART'
},
{ extend: 'excel',
message: 'WARD DISPENSING PER CHART',
exportOptions: {
columns: [ 0, 1, 2, 4, 5 ]
},
sheetName: 'WARD DISPENSING PER CHART ON STREAMLINE'
},
{ extend: 'pdf',
message: 'WARD DISPENSING PER CHART',
orientation: 'landscape',
pageSize: 'LETTER',
exportOptions: {
columns: [ 0, 1, 2, 4, 5 ]
},
customize: function(doc) {
doc.defaultStyle.fontSize = 10;
}
},
{ extend: 'print',
message: 'WARD DISPENSING PER CHART',
exportOptions: {
columns: [ 0, 1, 2, 4, 5 ]
},
customize: function (win) {
$(win.document.body)
.css('font-size', '10pt')
.css('background', '#fff')
.prepend(
'<img src="<?php echo asset('uploads/logo/logo-sm.png'); ?>" style="position:absolute; top:0; right:0;" />'
);
$(win.document.body).find('table')
.addClass('compact')
.css('font-size', 'inherit');
}
}
]
});*/
$('.viewPrescription').click(function(e){
e.preventDefault();
var patientId = "";
var episodeId = "";
var patientIdAttachedWithEpisodeIdString = $(this).val();
var patient_episode_array = patientIdAttachedWithEpisodeIdString.split("_");
patientId = patient_episode_array[0];
episodeId = patient_episode_array[1];
$("#showPatientPrescriptionModal").modal("show");
$.ajax({
type: "POST",
url: "/view_ward_patient_prescriptions",
data: {
patient_id: patientId,
episode_id: episodeId
},
cache: false,
success: function (response) {
$('#show_patient_prescriptions').html(response);
}
});
});
$('#patient_number').change(function () {
let id = $('#patient_number').val();
$('#patient_id').val(id);
});
$('#patient_number').select2({
placeholder: 'Search by patient details (names and number)',
ajax: {
url: '/patients/search_patient_by_name_number',
dataType: 'json',
delay: 250,
processResults: function (data) {
return {
results: $.map(data, function (item) {
return {
text: item.first_name + " " + item.last_name + " (" + item.number + ")",
id: item.id
}
})
};
},
cache: true
}
});
});
function add_to_current_order(drug_id) {
let current_count = $('#current_count').val();
add_drug_row(current_count);
$('#prescription_drugs' + x1).select2().val(drug_id).trigger('change');
alert("Drug has been added to current order");
}
function add_drug_row(id) {
x1++;
let new_id = "prescription_drugs_" + x1;
let html = '<div><div class="row">';
html += '<div class="col-md-8"><select name="dispensed_drugs[]" onchange="showStockLevel(this)" id="' + new_id + '" class="form-control"><?php echo $drugs_dropdown ?></select><br><div id="stock_span_'+x1+'"></div></div>';
html += '<div class="col-md-3"><input type="number" name="quantity_dispensed[]" class="form-control" placeholder="Quantity Given" style="padding-left: 5px;padding-right:5px;" step=".01" min="0.01"/></div>';
html += '<div class="col-md-1"><button class="remove_field btn btn-sm btn-rounded btn-danger" style="color: white;"><i class="fa fa-trash"></i></button></div>';
html += '<input type="hidden" name="patient_id[]" value="' + $('#patient_id_' + id).val() + '" />';
html += '<input type="hidden" name="episode_id[]" value="' + $('#episode_id_' + id).val() + '" />';
html += '<input type="hidden" name="inpatient_info_id[]" value="' + $('#inpatient_info_id_' + id).val() + '" />';
html += '<input type="hidden" name="ward_id[]" value="' + $('#ward_id_' + id).val() + '" />';
html += '</div><br></div>'; // extra div to include the <br> and take it away when removed
$("#drugs_given_row_" + id).append(html);
select2set(new_id);
}
function select2set(id) {
$('#'+id).select2();
}
function showStockLevel(data){
let element_id = data.id.split('_');
let drug_id = data.value;
$.ajax({
type: 'get',
url: '/drugs/get_drug_store_stock/' + drug_id,
success: function(response){
$('#stock_span_' + element_id[2]).html(response);
}
});
}
function recalculate_quantity(value, id, strength, pack) {
let dosage = $(value).val();
alert((dosage / strength) / pack);
let quantity_to_dispense = Math.ceil((dosage / strength) / pack);
$('#protocol_quantity_to_dispense_' + id).val(quantity_to_dispense);
}
</script>
@endpush
@@ -0,0 +1,270 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/select2/select2.min.css') }}" rel="stylesheet" />
<link href="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.css') }}" rel="stylesheet" type="text/css" />
<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" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-6 col-md-7 col-sm-7 col-xs-12">
<h4 class="page-title">{{ __('pharmacy.incoming_ward_chart') }}</h4>
</div>
<div class="col-lg-6 col-sm-5 col-md-5 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('pharmacy.dashboard') }}</a></li>
<li class="active">{{ __('pharmacy.incoming_ward_chart') }}</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('flash::message')
@foreach ($errors->all() as $error)
<div>{{ $error }}</div>
@endforeach
</div>
</div>
@include('pharmacy::pharmacy.ward_dispensing_menu')
<div class="row">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-12">
<div class="panel">
<div class="panel-heading" style="display: none;">{{ __('pharmacy.ward_dispensing_chart') }}</div>
<div class="panel-body">
{{ Form::open(['route' => 'pharmacy.ward_dispensing_per_chart_report', 'class' => 'typeahead', 'method' => 'ANY', 'role' => 'search']) }}
<div class="row">
<div class="col-md-3">
<div class="form-group">
{{ Form::label('ward_id', __('pharmacy.wards')) }}
{{ Form::select('ward_id', $wards, '', ['class' => 'form-control compulsory', 'required']) }}
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-3">
<div class="form-group" id="searchby">
{{ Form::label('search_by', __('pharmacy.admission_date')) }}
{{ Form::select('search_by', ['3'=>__('pharmacy.all_records'),'0'=>__('pharmacy.last_24_hours'),'1'=>__('pharmacy.custom_date'),'2'=>__('pharmacy.date_range')], '', ['class' => 'form-control','id'=>'search_by', 'required']) }}
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-3" style="display: none;" id="date_search">
<div class="form-group" id="reg_date" style="padding-top: 23px;">
<div class="input-group">
{{ Form::text('reg_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'datepicker-autoclose']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-3" style="display: none;" id="date_range_search">
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{ Form::label('start_date', __('pharmacy.from')) }}
<div class="input-group">
{{ Form::text('start_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-1']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
<div class="col-md-6">
<div class="form-group" id="reg_date">
{{ Form::label('end_date', __('pharmacy.to')) }}
<div class="input-group">
{{ Form::text('end_date','',['class' => 'form-control compulsory','readonly','id'=>'datepicker-autoclose-2']) }}
<span class="input-group-addon"><i class="icon-calender"></i></span>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3">
<div class="form-group" style="padding-top: 5px;"><br>
{{ Form::button(__('pharmacy.submit'),['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10', 'id'=>'select_patient']) }}
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-md-6">
{{ __('pharmacy.showing_results_from') }} :
<br><h3 style="color: #0060BF; font-weight: bolder;"> {{ is_null($ward_id) ? __('pharmacy.show_patients_all_wards') : ($ward_id == 0 ? 'All wards' : get_name($ward_id, 'id', 'name', 'wards')) }} {!! is_null($search_by) ? '<b>in the last 24 hours</b>' : '' !!} </h3>
</div>
</div>
{{ Form::close() }}
</div>
</div>
<div class="panel">
<div class="panel-body">
<div class="row">
<div class="col-sm-12">
@php
$count = 1;
@endphp
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table table-bordered">
<thead>
<tr>
<th>#</th>
<th>Date chart was submitted</th>
<th>Date chart was approved and dispensed</th>
<th>Ward</th>
<th>Requested By</th>
<th>Approved By</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@if(count($ward_chart_approvals) > 0)
@foreach($ward_chart_approvals as $approval_record)
<tr>
<td>
{{ $count }}
</td>
<td>
{{ streamline_date_time($approval_record->incoming_chart->created_at) }}
</td>
<td>
{{ streamline_date_time($approval_record->created_at) }}
</td>
<td>
{{ get_name($approval_record->ward_id, "id", "name", "wards") == "N/A" ? "All wards" : get_name($approval_record->ward_id, "id", "name", "wards") }}
</td>
<td>
{{ is_null($approval_record->incoming_chart->updated_by) ? get_full_name($approval_record->incoming_chart->created_by, "id", "first_name", "last_name", "users") : get_full_name($approval_record->incoming_chart->updated_by, "id", "first_name", "last_name", "users") }}
</td>
<td>
{{ get_full_name($approval_record->created_by, "id", "first_name", "last_name", "users") }}
</td>
<td>
{{ Form::open(['url' => 'ward_chart_report_details'])}}
{{ Form::hidden('approval_id', $approval_record->id)}}
<button type="submit" class="btn btn-success">Details</button>
{{ Form::close() }}
</td>
</tr>
@php $count++; @endphp
@endforeach
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<!-- data time picker dependency -->
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<!-- add datatables -->
<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/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>
<!-- validator -->
<script src="{{ asset('elite/js/validator.js') }}"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#datepicker-autoclose,#datepicker-autoclose-1,#datepicker-autoclose-2').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy'
});
$('#search_by').change(function () {
if ($(this).val() == 1) {
$('#date_search').show();
$('#date_range_search').hide();
}
else if ($(this).val() == 2) {
$('#date_range_search').show();
$('#date_search').hide();
}
else {
$('#date_search,#date_range_search').hide();
}
});
$('.prescription-drugs').select2({
placeholder: "Select Drug"
});
$('.select2-selection.select2-selection--single').css('height','calc(3.85rem)');
$('.select2-selection.select2-selection--single').css('padding-top','5px');
//$('.select2-selection.select2-selection--single').css('border-left', '3px solid #F08080');/*add compulsory class*/
$('.select2-selection.select2-selection--single.sec_d').css('border-left', '3px solid #aaa');
$('.select2-selection__arrow').css('top','3px');
$(".remove").on("click", function () {
$(this).parent().parent().remove();
});
$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy',
{ extend: 'csv',
message: 'WARD DISPENSING PER CHART REPORT'
},
{ extend: 'excel',
message: 'WARD DISPENSING PER CHART REPORT',
exportOptions: {
columns: [ 0, 1, 2, 4, 5 ]
},
sheetName: 'WARD DISPENSING PER CHART REPORT ON STREAMLINE'
},
{ extend: 'pdf',
message: 'WARD DISPENSING PER CHART REPORT',
orientation: 'landscape',
pageSize: 'LETTER',
exportOptions: {
columns: [ 0, 1, 2, 4, 5 ]
},
customize: function(doc) {
doc.defaultStyle.fontSize = 10;
}
},
{ extend: 'print',
message: 'WARD DISPENSING PER CHART REPORT',
exportOptions: {
columns: [ 0, 1, 2, 4, 5 ]
},
customize: function (win) {
$(win.document.body)
.css('font-size', '10pt')
.css('background', '#fff')
.prepend(
'<img src="<?php echo asset('uploads/logo/logo-sm.png'); ?>" style="position:absolute; top:0; right:0;" />'
);
$(win.document.body).find('table')
.addClass('compact')
.css('font-size', 'inherit');
}
}
]
});
});
</script>
@endpush