resolved conflicts

This commit is contained in:
2025-03-31 03:46:05 +03:00
6454 changed files with 1520539 additions and 9 deletions
@@ -0,0 +1,169 @@
@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">Incoming ward requests</h4>
</div>
<div class="col-lg-6 col-sm-5 col-md-5 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">Dashboard</a></li>
<li class="active">Incoming ward requests</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('flash::message')
</div>
</div>
<div class="row">
<div class="col-sm-12">
{{ Form::open(['route' => 'ward_item_request.incoming_ward_requests' , 'data-toggle' => 'validator']) }}
<div class="white-box">
<div class="row">
<div class="col-md-3">
<div class="form-group">
{{ Form::label('ward_id', 'Wards') }}
{{ Form::select('ward_id', $wards, '', ['class' => 'form-control']) }}
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-2">
<div class="form-group">
{{ Form::label('item_type', 'Item type') }}
{{ Form::select('item_type',[''=>'--Select--', '1' => 'Drugs', '2' => 'Sundries', '3' => 'General Items'],'',['class' => 'form-control compulsory', 'required']) }}
</div>
</div>
<div class="col-md-2">
<div class="form-group">
{{ Form::label('start_date','Date From') }}
{{ Form::text('start_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'start_date']) }}
</div>
</div>
<div class="col-md-2">
<div class="form-group">
{{ Form::label('end_date','Date To') }}
{{ Form::text('end_date','',['class' => 'form-control compulsory', 'required','readonly','id'=>'end_date']) }}
</div>
</div>
<div class="col-md-3">
<br>
{{ Form::button('Search',['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10']) }}
</div>
</div>
</div>
{{ Form::close() }}
</div>
</div>
@if($search_complete || !is_null($ward_item_requests))
<div class="row">
<div class="col-md-12">
<div class="white-box">
@if($search_complete)
<h4 style="color: #0060BF; font-weight: bolder;">{{ streamline_date($start_date) }} to {{ streamline_date($end_date) }}</h4>
@else
<h4 style="color: #0060BF; font-weight: bolder;">Item requests in the last 24 hours</h4>
@endif
<div class="table-responsive">
<table class="table table-bordered color-bordered-table success-bordered-table">
<thead>
<tr>
<th>Date</th>
<th>Ward</th>
<th>Items</th>
<th>Requested by</th>
<th>Approval status</th>
<th></th>
</tr>
</thead>
<tbody>
@if(count($ward_item_requests) > 0)
@foreach($ward_item_requests as $record)
@php
$item_type = $record->item_type;
$item_ids_array = explode(",", $record->item_ids);
$item_quantities_array = explode(",", $record->item_quantities);
@endphp
<tr>
<td>
{{ streamline_date($record->created_at) }}
</td>
<td>{{ get_name($record->ward_id, 'id', 'name', 'wards') }}</td>
<td>
{{ count($item_ids_array) }}
@if($record->item_type == "1") Drugs
@elseif($record->item_type == "2") Sundries
@else General Items
@endif
</td>
<td>
{{ get_full_name($record->created_by, 'id', 'first_name', 'last_name', 'users') }}
</td>
<td>{!! $record->approved_status == 1 ? "<font style='color: green'>Approved</font>" : "<font style='color: red'>Not approved</font>"!!}</td>
<td>
{{ Form::open(['route' => 'ward_item_request.ward_item_request_details']) }}
{{ Form::hidden('ward_item_request_id',$record->id) }}
@if($record->dispensation_status == 1 && $record->approved_status == 1)
<button class="btn btn-default" disabled>Items dispensed &nbsp;</button>
<a class="btn btn-success" href="print_ward_item_request_details/{{ $record->id }}">View Details &nbsp;</a>
@elseif($record->approved_status == 1)
@if( Auth::user()->can('dispense-ward-request'))
<button type="submit" class="btn btn-success">Dispense Items &nbsp;</button>
@else
<button class="btn btn-success" disabled>Dispense Request</button>
@endif
@else
@if( Auth::user()->can('approve-ward-request'))
<button type="submit" class="btn btn-info">Approve Request</button>
@else
<button class="btn btn-info" disabled>Approve Request</button>
@endif
@endif
{{ Form::close() }}
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="6" class="text-center">No records available for this search query</td>
</tr>
@endif
</tbody>
</table>
</div>
</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: 'yyyy/mm/dd',
orientation: 'bottom'
});
$('#end_date').datepicker({
autoclose: true,
todayHighlight: true,
format: 'yyyy/mm/dd',
orientation: 'bottom'
});
});
</script>
@endpush
@@ -0,0 +1,165 @@
<!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="{{ asset('uploads/streamline/color/streamline_icon-02.png') }}">
<title>{{ config('app.name', 'Stre@mline') }}</title>
<!-- Bootstrap Core CSS -->
<link href="{{ asset('bootstrap/css/bootstrap.min.css') }}" rel="stylesheet">
<style>
body{
/*font-size: 1.2em;*/
}
thead {
/*display: table-header-group;*/
}
tfoot {
/*display: table-row-group;*/
}
tr {
page-break-inside: avoid;
}
</style>
</head>
<body>
<div class="container-fluid">
@include('layouts.header_pdf_print')
<h5 class="heading" style="text-align: center;">Ward request items receipt</h5>
<h5 class="heading" style="text-align: center; color: #0060BF; font-weight: bolder;">Request from <strong>{{ get_name($ward_request_record->ward_id, "id", "name", "wards") }}</strong> on {{ streamline_date($ward_request_record->created_at) }}</h5>
@php
$item_ids_array = explode(",", $ward_request_record->item_ids_issued_out);
$item_quantities_array = explode(",", $ward_request_record->item_quantities);
if($ward_request_record->approved_status == "1"){
$items_on_request_array = explode(",", $ward_request_record->item_ids);
$balance_returned_array = explode(",", $ward_request_record->balance_returned);
$quantity_approved_array = explode(",", $ward_request_record->item_quantities_approved);
$quantity_issued_out_array = explode(",", $ward_request_record->quantity_issued_out);
/* do this to create an ass array of items to balance returned */
$item_with_requests_associative_array = [];
$item_with_balance_associative_array = [];
for ($c=0; $c < count($items_on_request_array) ; $c++) {
$item_with_requests_associative_array[$items_on_request_array[$c]] = $item_quantities_array[$c];
$item_with_balance_associative_array[$items_on_request_array[$c]] = $balance_returned_array[$c];
}
/* ***** */
}
$total_items_cost = 0;
@endphp
<table class="table table-light table-sm table-borderless">
<thead>
<tr>
<th>No.</th>
<th>
@if($ward_request_record->item_type == "1")
Drug
@elseif($ward_request_record->item_type == "2")
Sundry
@else
General Item
@endif
</th>
<th>Balance returned</th>
<th>Quantity requested</th>
<th>Quantity issued</th>
<th>Unit cost</th>
<th>Amount</th>
</tr>
</thead>
<tbody>
@for($i=0; $i < count($item_ids_array); $i++)
<tr>
<td>
{{ $i + 1 }}
</td>
<td>
@if($ward_request_record->item_type == "1")
{{ get_name($item_ids_array[$i], "id", "name", "drugs") }}
@elseif($ward_request_record->item_type == "2")
{{ get_name($item_ids_array[$i], "id", "name", "sundries") }}
@else
{{ get_name($item_ids_array[$i], "id", "name", "general_items") }}
@endif
</td>
<td>
{{ $item_with_balance_associative_array[$item_ids_array[$i]] ?? "" }}
</td>
<td>
{{ $item_with_requests_associative_array[$item_ids_array[$i]] ?? "" }}
</td>
<td>
{{ $quantity_issued_out_array[$i] }}
</td>
<td>
@if($ward_request_record->item_type == 1)
{{ ugandan_shillings_with_decimals(get_name($item_ids_array[$i], "id", "cost_price", "drugs")) }}
@elseif($ward_request_record->item_type == 2)
{{ ugandan_shillings_with_decimals(get_name($item_ids_array[$i], "id", "cost_price", "sundries")) }}
@elseif($ward_request_record->item_type == 3)
{{ ugandan_shillings_with_decimals(get_name($item_ids_array[$i], "id", "cost_price", "general_items")) }}
@endif
</td>
<td>
@if($ward_request_record->item_type == 1)
@php
$total_items_cost += $quantity_issued_out_array[$i] * get_name($item_ids_array[$i], "id", "cost_price", "drugs");
@endphp
{{ ugandan_shillings_with_decimals($quantity_issued_out_array[$i] * get_name($item_ids_array[$i], "id", "cost_price", "drugs")) }}
@elseif($ward_request_record->item_type == 2)
@php
$total_items_cost += $quantity_issued_out_array[$i] * get_name($item_ids_array[$i], "id", "cost_price", "sundries");
@endphp
{{ ugandan_shillings_with_decimals($quantity_issued_out_array[$i] * get_name($item_ids_array[$i], "id", "cost_price", "sundries")) }}
@elseif($ward_request_record->item_type == 3)
@php
$total_items_cost += $quantity_issued_out_array[$i] * get_name($item_ids_array[$i], "id", "cost_price", "general_items");
@endphp
{{ ugandan_shillings_with_decimals($quantity_issued_out_array[$i] * get_name($item_ids_array[$i], "id", "cost_price", "general_items")) }}
@endif
</td>
</tr>
@endfor
</tbody>
</table>
<br>
<strong>COMMENT:</strong><br>{{ $ward_request_record->comment }}
<br>
<div class="row">
<div class="col">
<strong>RECEIVED BY:</strong><br> {{ get_full_name($ward_request_record->received_by, 'id', 'first_name', 'last_name', 'users') }}
</div>
<div class="col">
<strong>ISSUED BY:</strong><br> {{ get_full_name($ward_request_record->dispensed_by, 'id', 'first_name', 'last_name', 'users') }}
</div>
<div class="col">
<strong>DISPENSED ON:</strong><br>{{ streamline_date($ward_request_record->dispensed_on) }}
</div>
<div class="col">
<strong>APPROVED BY:</strong><br>{{ get_full_name($ward_request_record->approved_by, 'id', 'first_name', 'last_name', 'users') }}
</div>
</div>
</div>
</body>
</html>
@@ -0,0 +1,181 @@
@extends('layouts.main')
@push('styles')
@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">Ward request items receipt</h4>
</div>
<div class="col-lg-6 col-sm-5 col-md-5 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">Dashboard</a></li>
<li><a href="{{ url('incoming_ward_requests') }}">Incoming ward requests</a></li>
<li class="active">Ward request items receipt</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('flash::message')
<div style="float:right;"><a class="btn btn-success glyphicon glyphicon-print" href="/print_ward_item_request_details_pdf/{{ $ward_request_record->id }}" target="_blank"> Print</a></div><br><br>
</div>
</div>
<div class="row">
<div class="col-sm-12" id="divToPrint">
<div class="white-box">
@php
$item_ids_array = explode(",", $ward_request_record->item_ids_issued_out);
$item_quantities_array = explode(",", $ward_request_record->item_quantities);
if($ward_request_record->approved_status == "1"){
$items_on_request_array = explode(",", $ward_request_record->item_ids);
$balance_returned_array = explode(",", $ward_request_record->balance_returned);
$quantity_approved_array = explode(",", $ward_request_record->item_quantities_approved);
$quantity_issued_out_array = explode(",", $ward_request_record->quantity_issued_out);
/* do this to create an ass array of items to balance returned */
$item_with_requests_associative_array = [];
$item_with_balance_associative_array = [];
for ($c=0; $c < count($items_on_request_array) ; $c++) {
$item_with_requests_associative_array[$items_on_request_array[$c]] = $item_quantities_array[$c];
$item_with_balance_associative_array[$items_on_request_array[$c]] = $balance_returned_array[$c];
}
/* ***** */
}
$hospital_information = \Streamline\Models\HospitalInformation::first();
@endphp
<p style="text-align: center; font-size: 1em">
<span style="font-weight: bolder; text-decoration: underline; display: block; font-family: monospace"><b>{{ $hospital_information->name }}</b></span>
<span style="font-weight: bolder; text-decoration: underline; display: block; font-family: monospace">{{ $hospital_information->address }}</span>
<span class="receipt-label"><b>Tel:</b> {{ $hospital_information->phone_number }}</span><br>
<span class="receipt-label"><b>Email:</b> {{ $hospital_information->email }}</span><br>
<span class="receipt-label"><b>Department:</b> {{ get_name($ward_request_record->ward_id, "id", "name", "wards") }}</span><br>
<span class="receipt-label"><b>Authorized by:</b> {{ get_full_name($ward_request_record->approved_by, 'id', 'first_name', 'last_name', 'users') }}</span><br>
</p>
@php
$total_items_cost = 0;
@endphp
<div class="table-responsive">
<table class="table table-bordered color-bordered-table success-bordered-table">
<thead>
<tr>
<th style="text-align: left;">No.</th>
<th style="text-align: left;">
@if($ward_request_record->item_type == "1")
Drug
@elseif($ward_request_record->item_type == "2")
Sundry
@else
General Item
@endif
</th>
<th style="text-align: left;">Balance returned</th>
<th style="text-align: left;">Quantity requested</th>
<th style="text-align: left;">Quantity issued</th>
<th style="text-align: left;">Unit cost</th>
<th style="text-align: left;">Amount</th>
</tr>
</thead>
<tbody>
@for($i=0; $i < count($item_ids_array); $i++)
<tr>
<td style="text-align: left;">
{{ $i + 1 }}
</td>
<td style="text-align: left;">
@if($ward_request_record->item_type == "1")
{{ get_name($item_ids_array[$i], "id", "name", "drugs") }}
@elseif($ward_request_record->item_type == "2")
{{ get_name($item_ids_array[$i], "id", "name", "sundries") }}
@else
{{ get_name($item_ids_array[$i], "id", "name", "general_items") }}
@endif
</td>
<td style="text-align: left;">
{{ $item_with_balance_associative_array[$item_ids_array[$i]] ?? "" }}
</td>
<td style="text-align: left;">
{{ $item_with_requests_associative_array[$item_ids_array[$i]] ?? "" }}
</td>
<td style="text-align: left;">
{{ $quantity_issued_out_array[$i] }}
</td>
<td style="text-align: left;">
@if($ward_request_record->item_type == 1)
{{ ugandan_shillings_with_decimals(get_name($item_ids_array[$i], "id", "cost_price", "drugs")) }}
@elseif($ward_request_record->item_type == 2)
{{ ugandan_shillings_with_decimals(get_name($item_ids_array[$i], "id", "cost_price", "sundries")) }}
@elseif($ward_request_record->item_type == 3)
{{ ugandan_shillings_with_decimals(get_name($item_ids_array[$i], "id", "cost_price", "general_items")) }}
@endif
</td>
<td style="text-align: left;">
@if($ward_request_record->item_type == 1)
@php
$total_items_cost += $quantity_issued_out_array[$i] * get_name($item_ids_array[$i], "id", "cost_price", "drugs");
@endphp
{{ ugandan_shillings_with_decimals($quantity_issued_out_array[$i] * get_name($item_ids_array[$i], "id", "cost_price", "drugs")) }}
@elseif($ward_request_record->item_type == 2)
@php
$total_items_cost += $quantity_issued_out_array[$i] * get_name($item_ids_array[$i], "id", "cost_price", "sundries");
@endphp
{{ ugandan_shillings_with_decimals($quantity_issued_out_array[$i] * get_name($item_ids_array[$i], "id", "cost_price", "sundries")) }}
@elseif($ward_request_record->item_type == 3)
@php
$total_items_cost += $quantity_issued_out_array[$i] * get_name($item_ids_array[$i], "id", "cost_price", "general_items");
@endphp
{{ ugandan_shillings_with_decimals($quantity_issued_out_array[$i] * get_name($item_ids_array[$i], "id", "cost_price", "general_items")) }}
@endif
</td>
</tr>
@endfor
</tbody>
<tfoot>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td><strong>Total</strong></td>
<td><strong>{{ ugandan_shillings_with_decimals($total_items_cost) }}</strong></td>
</tr>
</tfoot>
</table>
</div>
<div class="row">
<div class="col-sm-12">
<strong>COMMENT:</strong><br>{{ $ward_request_record->comment }}
</div>
<br><br>
<div class="col-sm-3">
<strong>RECEIVED BY:</strong><br> {{ get_full_name($ward_request_record->received_by, 'id', 'first_name', 'last_name', 'users') }}
</div>
<div class="col-sm-3">
<strong>ISSUED BY:</strong><br> {{ get_full_name($ward_request_record->dispensed_by, 'id', 'first_name', 'last_name', 'users') }}
</div>
<div class="col-sm-3">
<strong>DISPENSED ON:</strong><br>{{ streamline_date($ward_request_record->dispensed_on) }}
</div>
<div class="col-sm-3">
<strong>APPROVED BY:</strong><br>{{ get_full_name($ward_request_record->approved_by, 'id', 'first_name', 'last_name', 'users') }}
</div>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
@endpush
@@ -0,0 +1,453 @@
@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">Ward request</h4>
</div>
<div class="col-lg-6 col-sm-5 col-md-5 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">Dashboard</a></li>
<li class="active">Ward request</li>
</ol>
</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">
<h4 style="color: blue;">Request for ward items</h4>
<div class="row">
<div class="col-sm-4">
{{ Form::open(['route' => 'ward_item_request.ward_item_requests' , 'data-toggle' => 'validator']) }}
<div class="form-group">
{{ Form::label('ward', 'SELECT WARD') }}
{{ Form::select('ward',$wards,'',['id'=>'prescription-drugs','class' => 'form-control col-sm-8 compulsory ward_allocation']) }}
</div>
<div class="form-group">
{{ Form::label('item_type', 'ITEM TYPE') }}
{{ Form::select('item_type',['1' => 'Drugs', '2' => 'Sundries', '3' => 'General Items'],'',['id'=>'item_type','class' => 'form-control col-sm-8 compulsory']) }}
</div>
</div>
<div class="col-sm-8">
<div class="form-group" id="drugs_dropdown">
{{ Form::label('drugs', 'SELECT DRUGS') }}
{{ Form::select('drugs_requested[]', $drugs,'',['id'=>'prescription-drugs', 'multiple'=>true, 'class' => 'form-control prescription-drugs']) }}
</div>
<div class="form-group" style="display: none;" id="sundries_dropdown">
{{ Form::label('sundries', 'SELECT SUNDRIES') }}
{{ Form::select('sundries_requested[]',$sundries,'',['id'=>'prescription-sundries','multiple'=>true,'class' => 'form-control prescription-sundries']) }}
</div>
<div class="form-group" style="display: none;" id="general_items_dropdown">
{{ Form::label('general_items', 'SELECT GENERAL ITEMS') }}
{{ Form::select('general_items_requested[]',$general_items,'',['id'=>'prescription-general_items','multiple'=>true,'class' => 'form-control prescription-general_items']) }}
</div>
<div class="submit-button">
{{ Form::button('Confirm',['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10 confirmSelection','style'=>'padding: .6rem 1.2rem;']) }}
</div>
{{ Form::close() }}
</div>
</div>
</div>
</div>
</div>
@if(isset($drugs_requested) || isset($sundries_requested) || isset($general_items_requested))
<div class="white-box">
{{ Form::open(['route' => 'ward_item_request.store_ward_item_requests' , 'data-toggle' => 'validator']) }}
<div class="row">
<div class="col-sm-2">
<font color="blue">
<strong>{{ !is_null($ward_id) ? get_name($ward_id, "id", "name", "wards") : ""}}</strong> requests
</font>
</div>
<div class="col-sm-10">
<div class="table-responsive">
<table class="table color-bordered-table success-bordered-table">
<thead>
<tr>
<th>#</th>
<th>Items</th>
@if($item_type == "1" || $item_type == "2") <th>Pharmacy Stock</th> @endif
<th>Store stock</th>
<th>Last Dispensation to <strong>{{ !is_null($ward_id) ? get_name($ward_id, "id", "name", "wards") : ""}}</strong></th>
<th>Balance on ward</th>
<th>Quantity To Be Returned To Pharmacy</th>
<th>Quantity requested</th>
</tr>
</thead>
<tbody>
@if(isset($drugs_requested))
@for($i=0; $i < count($drugs_requested); $i++)
@php
$batch_records = \Streamline\Models\ItemBatchWatcher::where(['item_type' => 1, 'item_id' => $drugs_requested[$i]])->where(function ($query) {
$query->where('pharmacy_stock', '>', 0)
->orWhere('store_stock', '>', 0);
})->get();
$drug_pharmacy_stock = $drug_store_stock = 0;
if (count($batch_records) > 0) {
foreach ($batch_records as $record) {
$drug_store_stock += $record->store_stock;
$drug_pharmacy_stock += $record->pharmacy_stock;
}
}
@endphp
<tr>
<td>
{{ $i + 1 }}
</td>
<td>
<?php $item_unit_cost = DB::table('drugs')->where('id', $drugs_requested[$i])->pluck('cost_price')->first(); ?>
{{ $item_type == "1" ? get_name($drugs_requested[$i], "id", "name", "drugs") : ""}}
<input type="hidden" name="ward_id" value="{{ $ward_id }}">
<input type="hidden" name="item_type" value="{{ $item_type }}">
<input type="hidden" name="item_id[]" value="{{ $drugs_requested[$i] }}">
<input type="hidden" name="item_unit_cost[]" value="{{ $item_unit_cost }}"/>
</td>
<td>
{{ $item_type == "1" ? $drug_pharmacy_stock : "" }}
</td>
<td>
{{ $item_type == "1" ? $drug_store_stock : "" }}
</td>
<td>
{{-- last quantity given and when it was given --}}
@php
$last_dispensation_details_array = last_item_dispensation_to_ward($drugs_requested[$i], 1, $ward_id);
$last_qty_taken = $last_dispensation_details_array[0];
$date_taken = $last_dispensation_details_array[1];
$drug_form_name = "";
$drug_form_id = get_name($drugs_requested[$i], "id", "form_id", "drugs");
$drug_form_name = get_name($drug_form_id, "id", "name", "unit_of_measure");
@endphp
{{ $last_qty_taken }} {{ $drug_form_name }}
{!! is_null($date_taken) ? "" : "<br><br>Taken on: <b>".streamline_date($date_taken)."</b>" !!}
</td>
<td>
<input type="number" name="balance_returned[]" value="0" class="form-control" step=".01">
</td>
<td>
<input type="number" name="balance_on_ward_during_request[]" value="0" class="form-control" step=".01">
</td>
<td>
<input type="number" name="quantity_requested[]" class="form-control" step=".01">
</td>
</tr>
@endfor
@elseif(isset($sundries_requested))
@for($i=0; $i < count($sundries_requested); $i++)
@php
$batch_records = \Streamline\Models\ItemBatchWatcher::where(['item_type' => 2, 'item_id' => $sundries_requested[$i]])->where(function ($query) {
$query->where('pharmacy_stock', '>', 0)
->orWhere('store_stock', '>', 0);
})->get();
$sundry_pharmacy_stock = $sundry_store_stock = 0;
if (count($batch_records) > 0) {
foreach ($batch_records as $record) {
$sundry_store_stock += $record->store_stock;
$sundry_pharmacy_stock += $record->pharmacy_stock;
}
}
@endphp
<tr>
<td>
{{ $i + 1 }}
</td>
<td>
<?php $item_unit_cost = DB::table('sundries')->where('id', $sundries_requested[$i])->pluck('cost_price')->first(); ?>
{{ $item_type == "2" ? get_name($sundries_requested[$i], "id", "name", "sundries") : ""}}
<input type="hidden" name="ward_id" value="{{ $ward_id }}">
<input type="hidden" name="item_type" value="{{ $item_type }}">
<input type="hidden" name="item_id[]" value="{{ $sundries_requested[$i] }}">
<input type="hidden" name="item_unit_cost[]" value="{{ $item_unit_cost }}"/>
</td>
<td>
{{ $sundry_pharmacy_stock }}
</td>
<td>
{{ $sundry_store_stock }}
</td>
<td>
{{-- last quantity given and when it was given --}}
@php
$last_dispensation_details_array = last_item_dispensation_to_ward($sundries_requested[$i], 2, $ward_id);
$last_qty_taken = $last_dispensation_details_array[0];
$date_taken = $last_dispensation_details_array[1];
@endphp
{{ $last_qty_taken }}
{!! is_null($date_taken) ? "" : "<br><br>Taken on: <b>".streamline_date($date_taken)."</b>" !!}
</td>
<td>
<input type="number" name="balance_returned[]" value="0" class="form-control" step=".01">
</td>
<td>
<input type="number" name="balance_on_ward_during_request[]" value="0" class="form-control" step=".01">
</td>
<td>
<input type="number" name="quantity_requested[]" class="form-control" step=".01">
</td>
</tr>
@endfor
@elseif(isset($general_items_requested))
@for($i=0; $i < count($general_items_requested); $i++)
<tr>
<td>
{{ $i + 1 }}
</td>
<td>
<?php $item_unit_cost = DB::table('general_items')->where('id', $general_items_requested[$i])->pluck('cost_price')->first(); ?>
{{ $item_type == "3" ? get_name($general_items_requested[$i], "id", "name", "general_items") : "" }}
<input type="hidden" name="ward_id" value="{{ $ward_id }}">
<input type="hidden" name="item_type" value="{{ $item_type }}">
<input type="hidden" name="item_id[]" value="{{ $general_items_requested[$i] }}">
<input type="hidden" name="item_unit_cost[]" value="{{ $item_unit_cost }}"/>
</td>
{{-- <td>
{{ $item_type == "3" ? get_name($general_items_requested[$i], "id", "pharmacy_stock", "general_items") : ""}}
</td> --}}
<td>
{{ $item_type == "3" ? get_name($general_items_requested[$i], "id", "store_stock", "general_items") : ""}}
</td>
<td>
{{-- last quantity given and when it was given --}}
</td>
<td>
<input type="number" name="balance_on_ward_during_request[]" value="0" class="form-control" step=".01">
</td>
<td>
<input type="number" name="balance_returned[]" value="0" class="form-control" step=".01">
</td>
<td>
<input type="number" name="quantity_requested[]" class="form-control" step=".01">
</td>
</tr>
@endfor
@endif
</tbody>
</table>
<div class="comments-section">
<br>
{{ Form::label('order_comment', 'Order Comment', ['style' => 'font-size: bolder; font-weight: 600']) }}
{{ Form::textarea('order_comment',null,['class'=>'form-control', 'rows' => 5, 'cols' => 20]) }}
<br>
</div>
<input type="submit" name="submit_dispense" class = "btn btn-success pull-right" value="Submit Request"/>
{{ Form::close() }}
</div>
</div>
</div>
</div>
@else
<div class="white-box">
<h4>List of all wards' requests</h4>
<div class="table-responsive">
<table id="allItemRequests" class="table table-bordered color-bordered-table success-bordered-table">
<thead>
<tr>
<th>Date</th>
<th>Ward</th>
<th>Quantity</th>
<th>Requested by</th>
<th>Approval status</th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
@if(count($all_ward_item_requests) > 0)
@foreach($all_ward_item_requests as $record)
@php
$item_type = $record->item_type;
$item_ids_array = explode(",", $record->item_ids);
$item_quantities_array = explode(",", $record->item_quantities);
@endphp
<tr>
<td>
{{ streamline_date($record->created_at) }}
</td>
<td>{{ get_name($record->ward_id, 'id', 'name', 'wards') }}</td>
<td>
{{ count($item_ids_array) }}
@if ($record->item_type == 1)
Drugs
@elseif($record->item_type == 2)
Sundries
@elseif($record->item_type == 3)
General Items
@endif
</td>
<td>
{{ get_full_name($record->created_by, 'id', 'first_name', 'last_name', 'users') }}
</td>
<td>
@if($record->dispensation_status == 1)
<font style='color: green'>Dispensed</font>
@elseif($record->approved_status == 1)
<font style='color: blue'>Approved</font>
@else
<font style='color: red'>Not approved</font>
@endif
</td>
<td>
{{ Form::open(['route' => 'ward_item_request.show_ward_item_request_details' , 'data-toggle' => 'validator']) }}
{{ Form::hidden('ward_request_id', $record->id)}}
{{ Form::button('Details',['type'=>'submit','class'=>'btn btn-success btn-rounded waves-effect waves-light m-r-10']) }}
{{ Form::close() }}
</td>
<td>
@if( Auth::user()->can('edit-ward-item-request'))
@if($record->dispensation_status != 1 && $record->approved_status != 1)
{{ Form::open(['route' => 'ward_item_request.edit' , 'data-toggle' => 'validator']) }}
{{ Form::hidden('ward_request_id', $record->id)}}
{{ Form::button('Edit Request',['type'=>'submit','class'=>'btn btn-warning btn-rounded waves-effect waves-light m-r-10']) }}
{{ Form::close() }}
@endif
@endif
</td>
<td>
@if( Auth::user()->can('delete-ward-item-request'))
{{ Form::open(['route' => 'ward_item_request.delete' , 'data-toggle' => 'validator']) }}
{{ Form::hidden('ward_request_id', $record->id)}}
{{ Form::button('Delete',['type'=>'submit','class'=>'btn btn-danger btn-rounded waves-effect waves-light m-r-10']) }}
{{ Form::close() }}
@endif
</td>
</tr>
@endforeach
@endif
</tbody>
</table>
</div>
</div>
@endif
@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/tables/js/buttons.colVis.min.js') }}"></script>
<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">
$(document).ready(function() {
$('#allItemRequests').DataTable({
order: [ 1, "asc" ],
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy',
{ extend: 'csv',
message: 'LIST OF WARD ITEM REQUESTS'
},
{ extend: 'excel',
message: 'LIST OF WARD ITEM REQUESTS',
sheetName: 'LIST OF WARD ITEM REQUESTS ON STREAMLINE'
},
{ extend: 'pdf',
message: 'LIST OF WARD ITEM REQUESTS',
orientation: 'landscape',
pageSize: 'LETTER'
}
]
});
$('#datepicker-autoclose').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy',
setDate: new Date(),
readOnly: true
});
$('.prescription-drugs,.ward_allocation,.prescription-sundries,.prescription-general_items').select2({
placeholder: "Select",
width: "100%"
});
$('.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');//compulsory class css
$('.select2-selection.select2-selection--single.sec_d').css('border-left', '3px solid #aaa');
$('.select2-selection__arrow').css('top','3px');
$("#item_type").change(function(e) {
var item_id = $(this).val();
if (item_id == 2) {
$("#drugs_dropdown").hide();
$("#sundries_dropdown").show();
$("#general_items_dropdown").hide();
} else if(item_id == 3){
$("#general_items_dropdown").show();
$("#drugs_dropdown").hide();
$("#sundries_dropdown").hide();
}
else {
$("#drugs_dropdown").show();
$("#sundries_dropdown").hide();
$("#general_items_dropdown").hide();
}
});
$(".remove").on("click", function () {
$(this).parent().parent().remove();
});
$(".confirmSelection").click(function (e) { // make sure that all compulsory fields have been filled out
var empty_compulsory_fields = [];
$(".compulsory").each(function () {
if ($(this).val() == "") {
var textname = $(this).attr('name');
$(this).focus();
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) {
alert("Please fill in all compulsory fields");
console.log(empty_compulsory_fields);
e.preventDefault();
return false;
}
});
});
</script>
@endpush
@@ -0,0 +1,525 @@
@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">Ward request 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') }}">Dashboard</a></li>
<li><a href="{{ url('incoming_ward_requests') }}">Incoming ward requests</a></li>
<li class="active">Ward request details</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('flash::message')
</div>
</div>
<div class="row">
<div class="col-md-2 offset-10 text-right">
<button class="btn btn-primary glyphicon glyphicon-print" id="print_agreement"> Print
</button>
</div>
</div><br>
<div class="row" id="divToPrint">
<div class="col-sm-12">
<div class="white-box">
<h4 style="color: #0060BF; font-weight: bolder;">Request from <strong>{{ get_name($ward_request_details->ward_id, "id", "name", "wards") }}</strong> on {{ streamline_date($ward_request_details->created_at) }}</h4>
@php
$item_ids_array = explode(",", $ward_request_details->item_ids);
$item_quantities_array = explode(",", $ward_request_details->item_quantities);
$balance_during_request_array = explode("," , $ward_request_details->balance_on_ward_during_request);
$balance_returned_array = explode(",", $ward_request_details->balance_returned);
if($ward_request_details->approved_status == "1"){
$quantity_approved_array = explode(",", $ward_request_details->item_quantities_approved);
}
$ward_id = $ward_request_details->ward_id;
@endphp
{{ Form::open(['route' => 'ward_item_request.store_ward_item_request_details', 'data-toggle' => 'validator']) }}
<div class="table-responsive">
<table class="table table-bordered color-bordered-table success-bordered-table">
<thead>
<tr>
<th>#</th>
<th>
@if($ward_request_details->item_type == "1")
Drug
@elseif($ward_request_details->item_type == "2")
Sundry
@else
General Item
@endif
</th>
@if($ward_request_details->item_type == "1" || $ward_request_details->item_type == "2")
<th>Pharmacy Stock</th>
@endif
<th>Store stock</th>
<th>Quantity requested</th>
<th>Balance on ward</th>
<th>Quantity To Be Returned To Pharmacy</th>
<th>Last dispensation to <strong>{{ !is_null($ward_id) ? get_name($ward_id, "id", "name", "wards") : ""}}</strong>
</th>
<th>Quantity approved</th>
@if($ward_request_details->approved_status == "1")
<th>Quantity issued</th>
<th>Batch Number <span style="color:blue"> ({{ batch_tracking_method()}})</span></th>
@endif
</tr>
</thead>
<tbody>
@for($i=0; $i < count($item_ids_array); $i++)
@php
$item_type = $ward_request_details->item_type == 3 ? 6 : $ward_request_details->item_type; //change item_type to 6 if its general item since okellogum used 3 instead of 6
$item_batches_records = \DB::table('item_batch_watcher')->where(['item_id' => $item_ids_array[$i], 'item_type' => $item_type])->where(function ($query) {
$query->where('pharmacy_stock', '>', 0)
->orWhere('store_stock', '>', 0);
})->get();
$facade_batches_options = [];
$option_batches = "<option value=''>-select-</option>";
foreach ($item_batches_records 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;
//$needed_batches_from_pharm_array = get_pharmacy_batches_to_use_based_on_needed_quantity($item_ids_array[$i], $item_type, $quantity_approved_array[$i]??0);
$needed_batches_from_pharm_array = get_pharmacy_batch_watcher_ids_to_use_based_on_needed_quantity($item_ids_array[$i], $item_type, $quantity_approved_array[$i]??0);
$needed_batches_from_store_array = get_stores_batch_watcher_ids_to_use_based_on_needed_quantity($item_ids_array[$i], $item_type, $quantity_approved_array[$i]??0);
$default_batches_to_use = $ward_request_details->item_type == "1" ? $needed_batches_from_pharm_array : $needed_batches_from_store_array;
@endphp
@if (count($default_batches_to_use) > 0)
@foreach ($default_batches_to_use as $batch_to_dispense => $batch_qty_to_dispense)
<tr id="row_item_id_{{$item_ids_array[$i]}}">
<td>
{{ $i + 1 }}
</td>
<td>
@if($ward_request_details->item_type == "1")
{{ get_name($item_ids_array[$i], "id", "name", "drugs") }}
@php $item_name = get_name($item_ids_array[$i], "id", "name", "drugs"); @endphp
@elseif($ward_request_details->item_type == "2")
{{ get_name($item_ids_array[$i], "id", "name", "sundries") }}
@php $item_name = get_name($item_ids_array[$i], "id", "name", "sundries"); @endphp
@else
{{ get_name($item_ids_array[$i], "id", "name", "general_items") }}
@php $item_name = get_name($item_ids_array[$i], "id", "name", "general_items"); @endphp
@endif
{{ Form::hidden('item_name[]', $item_name, ['id' => 'item_name_'. $item_ids_array[$i], 'class' => 'item_name_'.$item_ids_array[$i]]) }}
</td>
@if($ward_request_details->item_type == "1" || $ward_request_details->item_type == "2")
<td>
@php
$batch_records = (new Streamline\Services\ItemsStockService())->getItemQuantityByArray($item_ids_array[$i], $item_type);
$item_pharmacy_stock = $batch_records[1];
$item_store_stock = $batch_records[0];
@endphp
{{ $item_pharmacy_stock }}
</td>
@endif
<td>
@if($ward_request_details->item_type == "1")
{{-- {{ get_name($item_ids_array[$i], "id", "store_stock", "drugs")}} --}}
{{ $item_store_stock }}
@elseif($ward_request_details->item_type == "2")
{{-- {{ get_name($item_ids_array[$i], "id", "store_stock", "sundries") }} --}}
{{ $item_store_stock }}
@else
{{ get_name($item_ids_array[$i], "id", "store_stock", "general_items")}}
@endif
</td>
<td>
{{ $item_quantities_array[$i] }}
<input type="hidden" name="ward_request_id" value="{{ $ward_request_details->id }}">
<input type="hidden" name="item_ids[]" value="{{ $item_ids_array[$i] }}">
</td>
<td>
@if($ward_request_details->approved_status == "1")
<input type="number" name="balance_returned[]" class="form-control" value="{{ $balance_returned_array[$i] }}" step=".01" readonly>
@else
<input type="number" name="balance_returned[]" class="form-control" value="{{ $balance_returned_array[$i]}}" step=".01">
@endif
</td>
<td>
@if($ward_request_details->approved_status == "1")
<input type="number" name="balance_on_ward_during_request[]" class="form-control" value="{{ $balance_during_request_array[$i] }}" step=".01" readonly>
@else
<input type="number" name="balance_on_ward_during_request[]" class="form-control" value="{{ $balance_during_request_array[$i]}}" step=".01">
@endif
</td>
<td>
{{-- last quantity given and when it was given --}}
@php
$last_dispensation_details_array = last_item_dispensation_to_ward($item_ids_array[$i], $ward_request_details->item_type, $ward_id);
$last_qty_taken = $last_dispensation_details_array[0];
$date_taken = $last_dispensation_details_array[1];
$drug_form_name = "";
if ($ward_request_details->item_type ==1) {
$drug_form_id = get_name($item_ids_array[$i], "id", "form_id", "drugs");
$drug_form_name = get_name($drug_form_id, "id", "name", "unit_of_measure");
}
@endphp
{{ $last_qty_taken }} {{ $drug_form_name }}
{!! is_null($date_taken) ? "" : "<br><br>Taken on: <b style='color:blue'>".streamline_date($date_taken)."</b>" !!}
</td>
<td>
@if($ward_request_details->approved_status == "1")
<input type="number" name="quantity_approved[]" class="form-control item_qty_approved_{{$item_ids_array[$i]}}" value="{{ $quantity_approved_array[$i] }}" step=".01" readonly>
@else
<input type="number" name="quantity_approved[]" class="form-control" value="{{ $item_quantities_array[$i] }}" step=".01">
@endif
</td>
@if($ward_request_details->approved_status == "1")
<td>
@if($ward_request_details->approved_status == "1")
<input type="number" name="quantity_issued_out[]" class="form-control item_qty_issued_{{$item_ids_array[$i]}}" value="{{ $batch_qty_to_dispense }}" step=".01">
@else
<div style="display: none;">
<input type="number" name="quantity_issued_out[]" class="form-control" value="{{ $item_quantities_array[$i] }}" step=".01">
</div>
@endif
</td>
<td>
{{ Form::select('dispensed_from_batch[]', $facade_batches_options, $batch_to_dispense, ['class' => 'form-control compulsory batchScan', 'required'])}}
<a href="#" id="addNewBatch_{{$item_ids_array[$i]}}">{{ __('stores.add_batch_small') }}</a>
&nbsp; &nbsp;
<a href="#" id="removeBatch_{{$item_ids_array[$i]}}" style="color: tomato">{{ __('stores.remove_small') }}</a>
</td>
@else
<input type="hidden" name="quantity_issued_out[]" class="form-control" value="{{ $item_quantities_array[$i] }}" step=".01">
@endif
</tr>
@endforeach
@else
<tr id="row_item_id_{{$item_ids_array[$i]}}">
<td>
{{ $i + 1 }}
</td>
<td>
@if($ward_request_details->item_type == "1")
{{ get_name($item_ids_array[$i], "id", "name", "drugs") }}
@php $item_name = get_name($item_ids_array[$i], "id", "name", "drugs"); @endphp
@elseif($ward_request_details->item_type == "2")
{{ get_name($item_ids_array[$i], "id", "name", "sundries") }}
@php $item_name = get_name($item_ids_array[$i], "id", "name", "sundries"); @endphp
@else
{{ get_name($item_ids_array[$i], "id", "name", "general_items") }}
@php $item_name = get_name($item_ids_array[$i], "id", "name", "general_items"); @endphp
@endif
{{ Form::hidden('item_name[]', $item_name, ['id' => 'item_name_'. $item_ids_array[$i], 'class' => 'item_name_'.$item_ids_array[$i]]) }}
</td>
@if($ward_request_details->item_type == "1" || $ward_request_details->item_type == "2")
<td>
@php
$batch_records = (new Streamline\Services\ItemsStockService())->getItemQuantityByArray($item_ids_array[$i], $item_type);
$item_pharmacy_stock = $batch_records[1];
$item_store_stock = $batch_records[0];
@endphp
{{ $item_pharmacy_stock }}
</td>
@endif
<td>
@if($ward_request_details->item_type == "1")
{{-- {{ get_name($item_ids_array[$i], "id", "store_stock", "drugs")}} --}}
{{ $item_store_stock }}
@elseif($ward_request_details->item_type == "2")
{{-- {{ get_name($item_ids_array[$i], "id", "store_stock", "sundries") }} --}}
{{ $item_store_stock }}
@else
{{ get_name($item_ids_array[$i], "id", "store_stock", "general_items")}}
@endif
</td>
<td>
{{ $item_quantities_array[$i] }}
<input type="hidden" name="ward_request_id" value="{{ $ward_request_details->id }}">
<input type="hidden" name="item_ids[]" value="{{ $item_ids_array[$i] }}">
</td>
<td>
@if($ward_request_details->approved_status == "1")
<input type="number" name="balance_returned[]" class="form-control" value="{{ $balance_returned_array[$i] }}" step=".01" readonly>
@else
<input type="number" name="balance_returned[]" class="form-control" value="{{ $balance_returned_array[$i]}}" step=".01">
@endif
</td>
<td>
@if($ward_request_details->approved_status == "1")
<input type="number" name="balance_on_ward_during_request[]" class="form-control" value="{{ $balance_during_request_array[$i] }}" step=".01" readonly>
@else
<input type="number" name="balance_on_ward_during_request[]" class="form-control" value="{{ $balance_during_request_array[$i]}}" step=".01">
@endif
</td>
<td>
{{-- last quantity given and when it was given --}}
@php
$last_dispensation_details_array = last_item_dispensation_to_ward($item_ids_array[$i], $ward_request_details->item_type, $ward_id);
$last_qty_taken = $last_dispensation_details_array[0];
$date_taken = $last_dispensation_details_array[1];
$drug_form_name = "";
if ($ward_request_details->item_type ==1) {
$drug_form_id = get_name($item_ids_array[$i], "id", "form_id", "drugs");
$drug_form_name = get_name($drug_form_id, "id", "name", "unit_of_measure");
}
@endphp
{{ $last_qty_taken }} {{ $drug_form_name }}
{!! is_null($date_taken) ? "" : "<br><br>Taken on: <b style='color:blue'>".streamline_date($date_taken)."</b>" !!}
</td>
<td>
@if($ward_request_details->approved_status == "1")
<input type="number" name="quantity_approved[]" class="form-control item_qty_approved_{{$item_ids_array[$i]}}" value="{{ $quantity_approved_array[$i] }}" step=".01" readonly>
@else
<input type="number" name="quantity_approved[]" class="form-control" value="{{ $item_quantities_array[$i] }}" step=".01">
@endif
</td>
@if($ward_request_details->approved_status == "1")
<td>
@if($ward_request_details->approved_status == "1")
<input type="number" name="quantity_issued_out[]" class="form-control item_qty_issued_{{$item_ids_array[$i]}}" value="{{ $quantity_approved_array[$i] }}" step=".01">
@else
<div style="display: none;">
<input type="number" name="quantity_issued_out[]" class="form-control" value="{{ $item_quantities_array[$i] }}" step=".01">
</div>
@endif
</td>
<?php
$batch_in_use = null;
$auto_deductable_batches_array = get_stores_batch_watcher_ids_to_use_based_on_needed_quantity($item_ids_array[$i], $ward_request_details->item_type, $item_quantities_array[$i]);
if($ward_request_details->item_type == "1"){
$drug_details = \Streamline\Models\Drug::withTrashed()->find($item_ids_array[$i]);
}elseif($ward_request_details->item_type == "2"){
$sundry_details = \Streamline\Models\Sundry::withTrashed()->find($item_ids_array[$i]);
}
?>
@if (batch_tracking_method() == "manual")
<td>
<select name="dispensed_from_batch[]" class="form-control compulsory batchScan" id="batch_scan_id_{{ $item_ids_array[$i] }}" required>
@php echo $option_batches; @endphp
</select>
<a href="#" id="addNewBatch_{{$item_ids_array[$i]}}">{{ __('stores.add_batch_small') }}</a>
</td>
@else
<td>
{{-- @if (count($auto_deductable_batches_array) > 0)
@foreach ($auto_deductable_batches_array as $deductable_batch => $quantity)
{{ Form::select('dispensed_from_batch[]', $facade_batches_options, $deductable_batch, ['class' => 'form-control compulsory batchScan']) }}
@endforeach
@else --}}
{{ Form::select('dispensed_from_batch[]', $facade_batches_options, "", ['class' => 'form-control compulsory batchScan', 'required']) }}
{{-- @endif --}}
<a href="#" id="addNewBatch_{{$item_ids_array[$i]}}">{{ __('stores.add_batch_small') }}</a>
&nbsp;&nbsp;
<a href="#" id="removeBatch_{{$item_ids_array[$i]}}" style="color: tomato">{{ __('stores.remove_small') }}</a>
</td>
@endif
@else
<input type="hidden" name="quantity_issued_out[]" class="form-control" value="{{ $item_quantities_array[$i] }}" step=".01">
@endif
</tr>
@endif
@endfor
</tbody>
</table>
</div>
@if (!is_null($ward_request_details->order_comment))
<div class="comments-section">
<br>
{{ Form::label('order_comment', 'Order Comment', ['style' => 'font-size: bolder; font-weight: 600']) }}
{{ Form::textarea('order_comment',$ward_request_details->order_comment,['class'=>'form-control', 'rows' => 5, 'cols' => 20, 'readonly']) }}
<br>
</div>
@endif
</div>
</div>
<div class="col-sm-12">
<div class="white-box">
<div class="row">
@if($ward_request_details->approved_status == "1")
<div class="col-sm-3">
<div class="form-group">
{{ Form::label('received_by', 'RECEIVED BY') }}
{{ 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">
{{ Form::label('received_from', 'RECEIVED FROM') }}
{{ Form::select('received_from', ['1' => 'Pharmacy', '2' => 'Stores'], $ward_request_details->item_type == "1" ? 1 : 2, ['class' => 'form-control col-sm-8 compulsory receivedFromOption','required']) }}
</div>
</div>
<div class="col-sm-3">
{{ Form::label('dispensation_date','DISPENSED ON') }}
<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>
</div>
<div class="col-sm-3">
Approved by <font style="color: blue; font-weight: bolder;">
<strong>{{ get_full_name($ward_request_details->approved_by, 'id', 'first_name', 'last_name', 'users') }}</strong></font>
</div>
@else
<div class="col-sm-12">
<div class="form-group">
{{ Form::label('comment', 'COMMENT') }}
{{ Form::textarea('comment', '', ['class' => 'form-control col-sm-8']) }}
</div>
</div>
@endif
<div class="col-sm-12">
@if($ward_request_details->approved_status == "1")
<input type="submit" name="dispense" class="btn btn-success pull-right dispenseBtn" value="Dispense to ward"/>
@else
<input type="submit" name="approve" class="btn btn-success pull-right" value="Approve"/>
@endif
{{ Form::close() }}
</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 type="text/javascript">
function printElementContent(elem,title){
var mywindow = window.open('', 'PRINT', 'height=400,width=600');
var css = '';
css += '<link href="elite/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">';
css += '<style type="text/css">div{display:block;}';
css += '.row {margin-right: -7.5px; margin-left: -7.5px;display: flex;flex-wrap: wrap;}';
css += '.col-sm-2 {padding-left: 7.5px;padding-right: 7.5px;-webkit-box-flex: 0;flex: 0 0 16.666667%;max-width: 16.666667%;}';
css += '.col-sm-4 {padding-left: 7.5px; padding-right: 7.5px; -webkit-box-flex: 0;flex: 0 0 33.333333%; max-width: 33.333333%; position: relative; width: 100%; min-height: 1px;}</style>';
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();
}, 500);
return true;
}
$(document).ready(function() {
$('#datepicker-autoclose').datepicker({
format:'mm/dd/yyyy',
endDate: new Date(),
autoclose: true,
todayHighlight: true,
}).datepicker("setDate",'now');
$('#received_by').select2({
placeholder: "Select"
});
$('.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');
$("#print_agreement").click(function(e){
printElementContent('divToPrint','Approve Ward Item Request');
});
$(".dispenseBtn").click(function(e){
//check if received from stores and ask the batch numbers
if($(".receivedFromOption").val() == 2){
var empty_compulsory_fields = [];
$(".batchNumbers").each(function () {
if ($(this).val() == "") {
var textname = $(this).attr('name');
$(this).focus();
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) {
alert("<?php echo __('triage.compulsory_fields_warning') ?>");
console.log(empty_compulsory_fields);
e.preventDefault();
return false;
}
}
});
$(".batchScan").select2({
width: "100%"
});
$('.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();
let item_qty_issued = $(".item_qty_issued_"+id).val();
let item_qty_approved = $(".item_qty_approved_"+id).val();
e.preventDefault();
//create another <tr> that we are going to append to
$("<tr><td></td><td>"+item_name+"</td><td></td><td></td><td><input type='hidden' name='item_name[]' value='"+item_name+"'/><input type='hidden' name='ward_request_id' value='1'><input type='hidden' name='item_ids[]' value='"+id+"'></td><td><input type='number' name='balance_returned[]' class='form-control' value='0' step='.01' readonly=''></td><td><input type='number' name='balance_on_ward_during_request[]' class='form-control' value='0' step='.01' readonly=''></td><td></td><td><input type='number' name='quantity_approved[]' class='form-control' value='"+item_qty_approved+"' step='.01' readonly=''></td><td><input type='number' name='quantity_issued_out[]' class='form-control' value='' step='.01'></td><td><select class='form-control compulsory batchScan' name='dispensed_from_batch[]' required>@php echo $option_batches; @endphp</select></td></tr>").insertAfter( $("#row_item_id_"+id) );
generalSelect2Set('batchScan');
});
$('.table').on('click', '[id^="removeBatch"]', function (e) {
e.preventDefault();
console.log("this been clicked")
$(this).parent('td').parent('tr').remove();
});
function generalSelect2Set(id) {
$('.'+id).select2({
width: "100%"
});
}
})
</script>
@endpush
@@ -0,0 +1,332 @@
@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">Ward request edit</h4>
</div>
<div class="col-lg-6 col-sm-5 col-md-5 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">Dashboard</a></li>
<li><a href="{{ url('ward_item_requests')}}">Ward requests</a></li>
<li class="active">Ward request edit</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>
</div>
@php
$item_ids_array = explode(",", $ward_request_details->item_ids);
$item_quantities_array = explode(",", $ward_request_details->item_quantities);
$balance_during_request_array = explode("," , $ward_request_details->balance_on_ward_during_request);
$balance_returned_array = explode(",", $ward_request_details->balance_returned);
if($ward_request_details->approved_status == "1"){
$quantity_approved_array = explode(",", $ward_request_details->item_quantities_approved);
}
@endphp
<div class="row">
<div class="col-sm-12">
<div class="white-box">
{{ Form::open(['route' => 'ward_item_request.edit_ward_item_request_search', 'method' => 'ANY', 'role' => 'search']) }}
<div class="row">
<div class="col-md-6">
<div class="form-group" id="drug_names">
<input type="hidden" name="ward_request_id" value="{{ $ward_request_details->id }}">
<input type="hidden" name="item_type" value="{{ $ward_request_details->item_type }}">
@if($ward_request_details->item_type == 1)
@php
$drugs = \Streamline\Models\Drug::where('available', 1)->orderby('name')->pluck('name', 'id');
@endphp
{{ Form::select('items_ids[]',$drugs,$search_status ? $selected_item_ids_array : $item_ids_array,['id'=>'drug_ids', 'multiple'=>true, 'class' => 'form-control col-sm-8 drug_ids']) }}
@elseif($ward_request_details->item_type == 2)
@php
$sundries = \Streamline\Models\Sundry::where('available', 1)->orderby('name')->pluck('name', 'id');
@endphp
{{ Form::select('items_ids[]',$sundries,$search_status ? $selected_item_ids_array : $item_ids_array,['id'=>'sundry_ids', 'multiple'=>true, 'class' => 'form-control col-sm-8 sundry_ids']) }}
@elseif($ward_request_details->item_type == 3)
@php
$general_items = \Streamline\Models\GeneralItem::orderBy('name')->pluck('name', 'id');
@endphp
{{ Form::select('items_ids[]',$general_items,$search_status ? $selected_item_ids_array : $item_ids_array,['id'=>'general_item_ids', 'multiple'=>true, 'class' => 'form-control col-sm-8 general_item_ids']) }}
@endif
</div>
</div>
<div class="col-md-6">
<button type="submit" class="btn btn-info"><span class="glyphicon glyphicon-search"></span> Select items to request</button>
</div>
<div class="col-sm-12">
<div class="alert alert-info">
<button type="button" class="close" data-dismiss="alert">×</button>
<span>
- <b>Note: </b>You can add more items by searching from them from the above search box<br>
</span>
</div>
</div>
</div>
@if(isset($criteria) && isset($resultCount))
<p>
{{ __('stores.search_criteria') }} <code>{{ $criteria }}</code> &nbsp;&nbsp;&nbsp;{{ __('stores.total_results') }} <code>{{ $resultCount }}</code> &nbsp;&nbsp;&nbsp;<a href="{{ route('drugs.index') }}">{{ __('stores.clear_search') }}</a>
</p>
@endif
{{ Form::close() }}
</div>
</div>
<div class="col-sm-12">
<div class="white-box">
{{ Form::open(['route' => 'ward_item_request.update_ward_item_requests' , 'data-toggle' => 'validator']) }}
<div class="row">
<input type="hidden" name="ward_request_id" value="{{ $ward_request_details->id }}">
<input type="hidden" name="item_type" value="{{ $ward_request_details->item_type }}">
<div class="table-responsive">
<table class="table table-bordered color-bordered-table success-bordered-table">
<thead>
<tr>
<th>#</th>
<th>
@if($ward_request_details->item_type == "1") Drug
@elseif($ward_request_details->item_type == "2") Sundry
@else General Item
@endif
</th>
<th>Store stock</th>
<th>Quantity To Be Returned To Pharmacy</th>
<th>Balance on ward</th>
<th>Quantity requested</th>
</tr>
</thead>
<tbody>
@if ($search_status)
@for($i=0; $i < count($selected_item_ids_array); $i++)
<tr>
<td>
{{ $i + 1 }}
</td>
<td>
@if($ward_request_details->item_type == "1")
{{ get_name($selected_item_ids_array[$i], "id", "name", "drugs") }}
@php
$item_unit_cost = DB::table('drugs')->where('id', $selected_item_ids_array[$i])->pluck('cost_price')->first();
@endphp
@elseif($ward_request_details->item_type == "2")
{{ get_name($selected_item_ids_array[$i], "id", "name", "sundries") }}
@php
$item_unit_cost = DB::table('sundries')->where('id', $selected_item_ids_array[$i])->pluck('cost_price')->first();
@endphp
@else
{{ get_name($selected_item_ids_array[$i], "id", "name", "general_items") }}
@php
$item_unit_cost = DB::table('general_items')->where('id', $selected_item_ids_array[$i])->pluck('cost_price')->first();
@endphp
@endif
</td>
<td>
@if($ward_request_details->item_type == "1")
{{ get_name($selected_item_ids_array[$i], "id", "store_stock", "drugs") }}
@elseif($ward_request_details->item_type == "2")
{{ get_name($selected_item_ids_array[$i], "id", "store_stock", "sundries") }}
@else
{{ get_name($selected_item_ids_array[$i], "id", "store_stock", "general_items") }}
@endif
</td>
<td>
<input type="number" name="balance_returned[]" class="form-control">
</td>
<td>
<input type="number" name="balance_on_ward_during_request[]" class="form-control">
</td>
<td>
<input type="hidden" name="item_ids[]" value="{{ $selected_item_ids_array[$i] }}">
<input type="hidden" name="item_unit_cost[]" value="{{ $item_unit_cost }}"/>
<input type="number" name="item_quantities[]" class="form-control" value="">
</td>
</tr>
@endfor
@else
@for($i=0; $i < count($item_ids_array); $i++)
<tr>
<td>
{{ $i + 1 }}
</td>
<td>
@if($ward_request_details->item_type == "1")
{{ get_name($item_ids_array[$i], "id", "name", "drugs") }}
@php
$item_unit_cost = DB::table('drugs')->where('id', $item_ids_array[$i])->pluck('cost_price')->first();
@endphp
@elseif($ward_request_details->item_type == "2")
{{ get_name($item_ids_array[$i], "id", "name", "sundries") }}
@php
$item_unit_cost = DB::table('sundries')->where('id', $item_ids_array[$i])->pluck('cost_price')->first();
@endphp
@else
{{ get_name($item_ids_array[$i], "id", "name", "general_items") }}
@php
$item_unit_cost = DB::table('general_items')->where('id', $item_ids_array[$i])->pluck('cost_price')->first();
@endphp
@endif
</td>
<td>
@if($ward_request_details->item_type == "1")
{{ get_name($item_ids_array[$i], "id", "store_stock", "drugs") }}
@elseif($ward_request_details->item_type == "2")
{{ get_name($item_ids_array[$i], "id", "store_stock", "sundries") }}
@else
{{ get_name($item_ids_array[$i], "id", "store_stock", "general_items") }}
@endif
</td>
<td>
@if($ward_request_details->approved_status == "1")
<input type="number" name="balance_returned[]" class="form-control" value="{{ $balance_returned_array[$i] }}" readonly>
@else
<input type="number" name="balance_returned[]" class="form-control" value="{{ $balance_returned_array[$i] }}">
@endif
</td>
<td>
@if($ward_request_details->approved_status == "1")
<input type="number" name="balance_on_ward_during_request[]" class="form-control" value="{{ $balance_during_request_array[$i] }}" readonly>
@else
<input type="number" name="balance_on_ward_during_request[]" class="form-control" value="{{ $balance_during_request_array[$i] }}">
@endif
</td>
<td>
<input type="hidden" name="item_ids[]" value="{{ $item_ids_array[$i] }}">
<input type="hidden" name="item_unit_cost[]" value="{{ $item_unit_cost }}"/>
<input type="number" name="item_quantities[]" class="form-control" value="{{ $item_quantities_array[$i] }}">
</td>
</tr>
@endfor
@endif
</tbody>
</table>
</div>
</div>
Requested by <font color="blue">{{ get_full_name($ward_request_details->created_by, "id", "first_name", "last_name", "users") }}</font>
{{ Form::submit('Update Request', ['class' => 'btn btn-success', 'style' => 'float: right;']) }}
{{ Form::close() }}
</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/tables/js/buttons.colVis.min.js') }}"></script>
<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">
$(document).ready(function() {
$('#allItemRequests').DataTable({
order: [ 1, "asc" ],
dom: 'Bfrtip',
buttons: [
'copy',
{ extend: 'csv',
message: 'LIST OF WARD ITEM REQUESTS'
},
{ extend: 'excel',
message: 'LIST OF WARD ITEM REQUESTS',
sheetName: 'LIST OF WARD ITEM REQUESTS ON STREAMLINE'
},
{ extend: 'pdf',
message: 'LIST OF WARD ITEM REQUESTS',
orientation: 'landscape',
pageSize: 'LETTER'
}
]
});
$('#datepicker-autoclose').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy',
setDate: new Date(),
readOnly: true
});
$('.prescription-drugs,.ward_allocation,.prescription-sundries').select2({
placeholder: "Select"
});
$('.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');//compulsory class css
$('.select2-selection.select2-selection--single.sec_d').css('border-left', '3px solid #aaa');
$('.select2-selection__arrow').css('top','3px');
$("#item_type").change(function(e) {
var item_id = $(this).val();
if (item_id == 2) {
$("#drugs_dropdown").hide();
$("#sundries_dropdown").show();
} else {
$("#drugs_dropdown").show();
$("#sundries_dropdown").hide();
}
});
$('.drug_ids,.sundry_ids,.general_item_ids').select2({
placeholder: "Select"
});
$(".remove").on("click", function () {
$(this).parent().parent().remove();
});
$(".confirmSelection").click(function (e) { // make sure that all compulsory fields have been filled out
var empty_compulsory_fields = [];
$(".compulsory").each(function () {
if ($(this).val() == "") {
var textname = $(this).attr('name');
$(this).focus();
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) {
alert("Please fill in all compulsory fields");
console.log(empty_compulsory_fields);
e.preventDefault();
return false;
}
});
});
</script>
@endpush
@@ -0,0 +1,207 @@
@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">Ward request 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') }}">Dashboard</a></li>
<li><a href="{{ url('ward_item_requests')}}">Ward requests</a></li>
<li class="active">Ward request details</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>
</div>
@php
$item_ids_array = explode(",", $ward_request_details->item_ids);
$item_quantities_array = explode(",", $ward_request_details->item_quantities);
$balance_during_request_array = explode("," , $ward_request_details->balance_on_ward_during_request);
if($ward_request_details->approved_status == "1"){
$balance_returned_array = explode(",", $ward_request_details->balance_returned);
$quantity_approved_array = explode(",", $ward_request_details->item_quantities_approved);
}
@endphp
<div class="row">
<div class="col-sm-12">
<div class="white-box">
<div class="table-responsive">
<table class="table table-bordered color-bordered-table success-bordered-table">
<thead>
<tr>
<th>#</th>
<th>
@if($ward_request_details->item_type == "1") Drug
@elseif($ward_request_details->item_type == "2") Sundry
@else General Item
@endif
</th>
<th>Quantity requested</th>
<th>Balance returned from ward</th>
@if($ward_request_details->approved_status == "1")
<th>Quantity given</th>
@endif
</tr>
</thead>
<tbody>
@for($i=0; $i < count($item_ids_array); $i++)
<tr>
<td>
{{ $i + 1 }}
</td>
<td>
@if($ward_request_details->item_type == "1")
{{ get_name($item_ids_array[$i], "id", "name", "drugs") }}
@elseif($ward_request_details->item_type == "2")
{{ get_name($item_ids_array[$i], "id", "name", "sundries") }}
@else
{{ get_name($item_ids_array[$i], "id", "name", "general_items") }}
@endif
</td>
<td>
{{ $item_quantities_array[$i] }}
<input type="hidden" name="ward_request_id" value="{{ $ward_request_details->id }}">
<input type="hidden" name="item_ids[]" value="{{ $item_ids_array[$i] }}">
</td>
<td>
@if($ward_request_details->approved_status == "1")
<input type="number" name="balance_returned[]" class="form-control" value="{{ $balance_returned_array[$i] }}" readonly>
@else
<input type="number" name="balance_returned[]" class="form-control" value="{{ $balance_during_request_array[$i] }}" readonly>
@endif
</td>
@if($ward_request_details->approved_status == "1")
<td>
@if($ward_request_details->approved_status == "1")
<input type="number" name="quantity_approved[]" class="form-control" value="{{ $quantity_approved_array[$i] }}" readonly>
@else
<input type="number" name="quantity_approved[]" class="form-control" value="{{ $item_quantities_array[$i] }}" readonly>
@endif
</td>
@endif
</tr>
@endfor
</tbody>
</table>
</div>
Requested by <font color="blue">{{ get_full_name($ward_request_details->created_by, "id", "first_name", "last_name", "users") }}</font>
</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/tables/js/buttons.colVis.min.js') }}"></script>
<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">
$(document).ready(function() {
$('#allItemRequests').DataTable({
order: [ 1, "asc" ],
dom: 'Bfrtip',
buttons: [
'copy',
{ extend: 'csv',
message: 'LIST OF WARD ITEM REQUESTS'
},
{ extend: 'excel',
message: 'LIST OF WARD ITEM REQUESTS',
sheetName: 'LIST OF WARD ITEM REQUESTS ON STREAMLINE'
},
{ extend: 'pdf',
message: 'LIST OF WARD ITEM REQUESTS',
orientation: 'landscape',
pageSize: 'LETTER'
}
]
});
$('#datepicker-autoclose').datepicker({
autoclose: true,
todayHighlight: true,
format: 'dd/mm/yyyy',
setDate: new Date(),
readOnly: true
});
$('.prescription-drugs,.ward_allocation,.prescription-sundries').select2({
placeholder: "Select"
});
$('.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');//compulsory class css
$('.select2-selection.select2-selection--single.sec_d').css('border-left', '3px solid #aaa');
$('.select2-selection__arrow').css('top','3px');
$("#item_type").change(function(e) {
var item_id = $(this).val();
if (item_id == 2) {
$("#drugs_dropdown").hide();
$("#sundries_dropdown").show();
} else {
$("#drugs_dropdown").show();
$("#sundries_dropdown").hide();
}
});
$(".remove").on("click", function () {
$(this).parent().parent().remove();
});
$(".confirmSelection").click(function (e) { // make sure that all compulsory fields have been filled out
var empty_compulsory_fields = [];
$(".compulsory").each(function () {
if ($(this).val() == "") {
var textname = $(this).attr('name');
$(this).focus();
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) {
alert("Please fill in all compulsory fields");
console.log(empty_compulsory_fields);
e.preventDefault();
return false;
}
});
});
</script>
@endpush