mirror of
https://gitlab.com/signalytic/client-external/streamline/streamline-emr.git
synced 2026-09-12 11:11:31 +00:00
updated streamline-setup v2
This commit is contained in:
+830
@@ -0,0 +1,830 @@
|
||||
@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-md-7">
|
||||
<h4>{{ __('payments.edit_bill') }}</h4>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<ol class="breadcrumb">
|
||||
<li><a href="{{ route('home') }}"><i class="fa fa-home"></i> {{ __('payments.home') }}</a></li>
|
||||
<li><a href="{{ route('finance') }}"><i class="fa fa-money"></i> {{ __('payments.finance_home') }}</a></li>
|
||||
<li class="active"><i class="fa fa-credit-card"></i> {{ __('payments.view_payments') }}</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@include('expenses::payments.menu')
|
||||
|
||||
@include('flash::message')
|
||||
|
||||
@php $back_date = \Streamline\Models\HospitalInformation::first()->pluck('back_date'); @endphp
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="white-box">
|
||||
|
||||
{{ Form::model($bill, ['method' => 'PATCH','route' => ['payments.update_bill', $bill->id]]) }}
|
||||
<div class="row">
|
||||
|
||||
<div class="col-md-3">
|
||||
<div class="form-group">
|
||||
<label>{{ __('payments.vendor') }}:</label>
|
||||
{{ Form::select('vendor', $suppliers, $bill->vendor, ['class' => 'form-control', 'id'=>'vendor']) }}
|
||||
<small><a href="#" data-toggle="modal" data-target="#addNewSupplier">{{ __('payments.add_vendor') }}</a></small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
<div id="sDate">
|
||||
<div class="form-group">
|
||||
{{ Form::label('start_date', __('finance.bill_date')) }}
|
||||
<div class="input-group">
|
||||
{{ Form::text('bill_date', \Carbon\Carbon::parse($bill->bill_date)->format('d-m-Y'), ['class'=>'form-control required compulsory', 'readonly', 'id'=>'bill_date']) }}
|
||||
<span class="input-group-addon"><i class="icon-calender"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
<div id="eDate">
|
||||
<div class="form-group">
|
||||
{{ Form::label('end_date', __('payments.bill_due_date')) }}
|
||||
<div class="input-group">
|
||||
{{ Form::text('bill_due_date', \Carbon\Carbon::parse($bill->bill_due_date)->format('d-m-Y'), ['class'=>'form-control required compulsory', 'readonly', 'id'=>'bill_due_date']) }}
|
||||
<span class="input-group-addon"><i class="icon-calender"></i></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-2">
|
||||
<div id="eDate">
|
||||
<div class="form-group">
|
||||
{{ Form::label('bill_number', __('payments.bill_number')) }}
|
||||
{{ Form::text('bill_number', $bill->bill_number, ['class'=>'form-control required compulsory', 'id'=>'bill_number']) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<hr/>
|
||||
@if(count($payments) > 0)
|
||||
<h4><b>Payments</b></h4>
|
||||
<div class="table-responsive">
|
||||
<br/>
|
||||
<table id="table" class="table color-bordered-table danger-bordered-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ __('payments.item') }}</th>
|
||||
<th>{{ __('payments.vendor') }}</th>
|
||||
<th>{{ __('payments.quantity') }}</th>
|
||||
<th>{{ __('payments.staff') }}</th>
|
||||
<th>{{ __('payments.date') }}</th>
|
||||
<th>{{ __('payments.unit_cost') }}</th>
|
||||
<th>{{ __('payments.amount') }}</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@php
|
||||
$total = 0;
|
||||
@endphp
|
||||
|
||||
@foreach($payments as $item)
|
||||
<tr>
|
||||
<td>
|
||||
@php
|
||||
$bill = \Streamline\Models\HospitalBill::find($item->bill_id);
|
||||
$items = explode(',', $bill->item_ids);
|
||||
$quantities = explode(',', $bill->item_quantities);
|
||||
@endphp
|
||||
@if($bill->bill_type == 'DRU')
|
||||
@for($x = 0; $x < count($items); $x++)
|
||||
{{ get_name($items[$x], 'id', 'name', 'drugs') }} <br/>
|
||||
@endfor
|
||||
@elseif($bill->bill_type == 'SUN')
|
||||
@for($x = 0; $x < count($items); $x++)
|
||||
{{ get_name($items[$x], 'id', 'name', 'sundries') }} <br/>
|
||||
@endfor
|
||||
@elseif($bill->bill_type == 'DEN')
|
||||
@for($x = 0; $x < count($items); $x++)
|
||||
{{ get_name($items[$x], 'id', 'name', 'dentals') }} <br/>
|
||||
@endfor
|
||||
@elseif($bill->bill_type == 'RAD')
|
||||
@for($x = 0; $x < count($items); $x++)
|
||||
{{ get_name($items[$x], 'id', 'name', 'radiologies') }} <br/>
|
||||
@endfor
|
||||
@elseif($bill->bill_type == 'LAB')
|
||||
@for($x = 0; $x < count($items); $x++)
|
||||
{{ get_name($items[$x], 'id', 'name', 'labs') }} <br/>
|
||||
@endfor
|
||||
@elseif($bill->bill_type == 'GEN')
|
||||
@for($x = 0; $x < count($items); $x++)
|
||||
{{ get_name($items[$x], 'id', 'name', 'general_items') }} <br/>
|
||||
@endfor
|
||||
@elseif($bill->bill_type == 'PAY')
|
||||
@for($x = 0; $x < count($items); $x++)
|
||||
{{ get_name($items[$x], 'id', 'name', 'payment_items') }} <br/>
|
||||
@endfor
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ get_name($item->vendor, 'id', 'name', 'suppliers') }}</td>
|
||||
<td>{{ get_full_name($item->created_by, 'id', 'first_name', 'last_name', 'users') }}</td>
|
||||
<td>{{ streamline_date_time_short($item->created_at) }}</td>
|
||||
<td>
|
||||
@for($x = 0; $x < count($items); $x++)
|
||||
{{ $quantities[$x]." units" }} <br/>
|
||||
@endfor
|
||||
</td>
|
||||
<td>
|
||||
@if($bill->bill_type == 'DRU')
|
||||
@for($x = 0; $x < count($items); $x++)
|
||||
{{ ugandan_shillings(get_name($items[$x], 'id', 'cost_price', 'drugs')) }} <br/>
|
||||
@endfor
|
||||
@elseif($bill->bill_type == 'SUN')
|
||||
@for($x = 0; $x < count($items); $x++)
|
||||
{{ ugandan_shillings(get_name($items[$x], 'id', 'cost_price', 'sundries')) }} <br/>
|
||||
@endfor
|
||||
@elseif($bill->bill_type == 'DEN')
|
||||
@for($x = 0; $x < count($items); $x++)
|
||||
{{ ugandan_shillings(get_name($items[$x], 'id', 'cost_price', 'dentals')) }} <br/>
|
||||
@endfor
|
||||
@elseif($bill->bill_type == 'RAD')
|
||||
@for($x = 0; $x < count($items); $x++)
|
||||
{{ ugandan_shillings(get_name($items[$x], 'id', 'cost_price', 'radiologies')) }} <br/>
|
||||
@endfor
|
||||
@elseif($bill->bill_type == 'LAB')
|
||||
@for($x = 0; $x < count($items); $x++)
|
||||
{{ ugandan_shillings(get_name($items[$x], 'id', 'cost_price', 'labs')) }} <br/>
|
||||
@endfor
|
||||
@elseif($bill->bill_type == 'GEN')
|
||||
@for($x = 0; $x < count($items); $x++)
|
||||
{{ ugandan_shillings(get_name($items[$x], 'id', 'unit_cost', 'general_items')) }} <br/>
|
||||
@endfor
|
||||
@elseif($bill->bill_type == 'PAY')
|
||||
@for($x = 0; $x < count($items); $x++)
|
||||
{{ ugandan_shillings(get_name($items[$x], 'id', 'unit_cost', 'payment_items')) }} <br/>
|
||||
@endfor
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ ugandan_shillings($item->amount) }}</td>
|
||||
</tr>
|
||||
@php
|
||||
$total += $item->amount;
|
||||
@endphp
|
||||
|
||||
@endforeach
|
||||
|
||||
</tbody>
|
||||
<tr>
|
||||
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td><strong>{{ __('payments.total') }}</strong></td>
|
||||
<td>{{ ugandan_shillings($total) }}</td>
|
||||
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
@endif
|
||||
|
||||
<br/>
|
||||
<table class="table color-bordered-table success-bordered-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<div class="row">
|
||||
<div class="col-2">{{ __('payments.item') }}</div>
|
||||
<div class="col-1">{{ __('payments.quantity') }}</div>
|
||||
<div class="col-2">{{ __('payments.unit_cost') }}</div>
|
||||
<div class="col-2">{{ __('payments.amount') }}</div>
|
||||
<div class="col-2">{{ __('payments.expense_account') }}</div>
|
||||
<div class="col-2">{{ __('payments.payable_account') }}</div>
|
||||
<div class="col-1">{{ __('payments.action') }}</div>
|
||||
</div>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@php
|
||||
$items = explode(',', $bill->item_ids);
|
||||
$item_quantity = explode(',', $bill->item_quantities);
|
||||
$item_subtotals = explode(',', $bill->item_subtotals);
|
||||
$expense_accounts = explode(',', $bill->item_accounts);
|
||||
$payable_accounts = explode(',', $bill->payable_account);
|
||||
//$item = explode(',', $bill->item_ids);
|
||||
@endphp
|
||||
<tbody class="input_fields_wrap" id="payments_items">
|
||||
|
||||
@for($i = 0; $i < count($items); $i++)
|
||||
<tr>
|
||||
<td>
|
||||
<div class="row">
|
||||
|
||||
<div class="col-2">
|
||||
<div class=" control-group">
|
||||
<div class="form-group">
|
||||
{{ Form::select('item_id[]', $payment_items, $items[$i], ['class' => 'form-control compulsory', 'id'=>"item_$i"]) }}
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- Item -->
|
||||
|
||||
@php
|
||||
$option_items = "<option value=''>-select-</option>";
|
||||
foreach ($option_items_array as $item){
|
||||
$option_items .= "<option value='$item->id'>$item->name</option>";
|
||||
}
|
||||
|
||||
$option_suppliers = "<option value=''>-select-</option>";
|
||||
foreach ($option_suppliers_array as $item){
|
||||
$option_suppliers .= "<option value='$item->id'>$item->name</option>";
|
||||
}
|
||||
$option_suppliers .= "<option value='N/A'>N/A</option>";
|
||||
@endphp
|
||||
|
||||
<div class='col-1'>
|
||||
<div class="form-group">
|
||||
<div class=''>
|
||||
{{ Form::number('quantity[]', (is_null($item_quantity[$i]) ? 1 : $item_quantity[$i]), ['class' => 'form-control compulsory qty', 'id'=>"quantity_$i"]) }}
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- Quantity -->
|
||||
|
||||
<div class="col-2">
|
||||
<div class="form-group">
|
||||
<div class="controls">
|
||||
{{ Form::number('unit_cost[]', ($item_subtotals[$i] / $item_quantity[$i]), ['class' => 'form-control compulsory unit_cost', 'id'=>"unit_cost_$i"]) }}
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- Unit Cost -->
|
||||
|
||||
<div class="col-2">
|
||||
<div class="form-group">
|
||||
<div class="controls">
|
||||
{{ Form::number('amount[]', $item_subtotals[$i], ['class' => 'form-control amount', 'id'=>"amount_$i"]) }}
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- Amount -->
|
||||
|
||||
<div class='col-2'>
|
||||
<div class="form-group">
|
||||
<div class=''>
|
||||
{{ Form::text('expense_acc_name[]', isset($chart_of_accounts[$expense_accounts[$i]]) ? $chart_of_accounts[$expense_accounts[$i]] : '', ['class' => 'form-control', 'id'=>"expense_acc_name_$i", 'readonly']) }}
|
||||
<input type='hidden' name='expense_acc_id[]' value="{{ $expense_accounts[$i] }}" id ="expense_acc_id_{{ $i }}">
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- Expense account -->
|
||||
|
||||
<div class='col-2'>
|
||||
<div class="form-group">
|
||||
<div class=''>
|
||||
{{ Form::text('payable_acc_name[]', $chart_of_accounts[$payable_accounts[$i]], ['class' => 'form-control', 'id'=>"payable_acc_name_$i", 'readonly']) }}
|
||||
<input type='hidden' name='payable_acc_id[]' value="{{ $payable_accounts[$i] }}" id ="payable_acc_id_{{ $i }}">
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- payable account -->
|
||||
|
||||
<div class="col-1">
|
||||
<div class="form-group" style="margin-top: 10px;">
|
||||
@if($i == 0)
|
||||
<button class="btn btn-sm btn-rounded btn-success add_item" style="color: white; margin-left: 25px;"><i class="fa fa-plus"></i></button>
|
||||
@else
|
||||
<button class="btn btn-sm btn-rounded btn-danger remove_field" style="color: white; margin-left: 25px;"><i class="fa fa-trash"></i></button>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endfor
|
||||
</tbody>
|
||||
</table>
|
||||
<br/>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="form-group">
|
||||
<label>{{ __('payments.bill_memo') }}</label>
|
||||
<textarea rows="7" class="form-control compulsory" name="bill_memo">{{ $bill->bill_memo }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="form-group-group">
|
||||
<label>{{ __('payments.total_amount') }}</label>
|
||||
<div class="controls">
|
||||
<input type="text" name="total_amount" id="total_amount" class="form-control compulsory" value="{{ $bill->total_amount }}" readonly='true'/>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<button class="btn btn-rounded btn-primary pull-right" name="bill_action" value="save">Update Bill</button>
|
||||
</div>
|
||||
</div>
|
||||
{{ Form::close() }}
|
||||
</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">{{ __('payments.add_new_supplier') }}</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
{{ Form::label('supplier_name', __('payments.supplier_name')) }}
|
||||
{{ Form::text('supplier_name', '', ['class'=>'form-control compulsory', 'required','id'=>'supplier_name']) }}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
{{ Form::label('supplier_company', __('payments.company')) }}
|
||||
{{ Form::text('supplier_company', '', ['class'=>'form-control compulsory', 'required','id'=>'supplier_company']) }}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
{{ Form::label('supplier_contact', __('payments.mobile_number')) }}
|
||||
{{ Form::text('supplier_contact', '', ['class'=>'form-control compulsory', 'data-mask'=>"0799 999 999", 'required','id'=>'supplier_contact']) }}
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
{{ Form::label('supplier_address', __('payments.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">{{ __('payments.close') }}</button>
|
||||
<button type="button" class="btn btn-success" data-dismiss="modal" id="saveNewSupplier">{{ __('payments.save_changes') }}</button>
|
||||
</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>
|
||||
|
||||
$('#saveNewSupplier').click(function(e){
|
||||
e.preventDefault();
|
||||
var supplier_name = $('#supplier_name').val();
|
||||
var supplier_company = $('#supplier_company').val();
|
||||
var supplier_contact = $('#supplier_contact').val();
|
||||
var supplier_address = $('#supplier_address').val();
|
||||
|
||||
let has_errors = false;
|
||||
let error_messages = "";
|
||||
|
||||
if(supplier_name === ''){
|
||||
error_messages += "Please fill in the supplier's name\n";
|
||||
has_errors = true;
|
||||
}
|
||||
|
||||
if(supplier_company === ''){
|
||||
error_messages += "Please fill in the supplier's company \n";
|
||||
has_errors = true;
|
||||
}
|
||||
|
||||
if(supplier_contact === ''){
|
||||
error_messages += "Please fill in the supplier's contact \n";
|
||||
has_errors = true;
|
||||
}
|
||||
|
||||
if(supplier_address === ''){
|
||||
error_messages += "Please fill in the supplier's address \n";
|
||||
has_errors = true;
|
||||
}
|
||||
if(has_errors){
|
||||
alert(error_messages);
|
||||
}else{
|
||||
$.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){
|
||||
//response = last inserted id
|
||||
$('#vendor').append($('<option>', {
|
||||
value: response,
|
||||
text: supplier_name
|
||||
}));
|
||||
$('#vendor').val(response);//preselect the newly added referral
|
||||
alert('new supplier has been added');
|
||||
},
|
||||
error: function(response){
|
||||
// console.log('there was an error');
|
||||
alert('There was an error, Contact IT.')
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
$("[id^='item_check_']").each(function () {
|
||||
var i = parseInt(this.id.substr(this.id.indexOf("_") + 1));
|
||||
});
|
||||
|
||||
$('#bill_term').on('change', function () {
|
||||
var date = $('#bill_date').datepicker("getDate"); //Get the Date object with actual date
|
||||
date.setDate(date.getDate() + parseInt($('#bill_term').val()));
|
||||
$("#bill_due_date").datepicker("setDate", date);
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/payments/get_bill_number",
|
||||
cache: false,
|
||||
success: function (result) {
|
||||
$('#bill_number').val(result);
|
||||
},
|
||||
error: function (error) {
|
||||
alert('There was an error while generating the bill number.')
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var max_fields = 1000; //maximum input boxes allowed
|
||||
var wrapper = $(".input_fields_wrap"); //Fields wrapper
|
||||
var add_button = $(".add_item"); //Add button ID
|
||||
|
||||
var x = 500; //initlal text box count
|
||||
|
||||
add_button.click(function (e) { //on add input button click
|
||||
e.preventDefault();
|
||||
if (x < max_fields) { //max input box allowed
|
||||
x++; //text box increment
|
||||
$(wrapper).append("\
|
||||
\ <tr>\
|
||||
<td>\
|
||||
<div class='row'>\n\
|
||||
\
|
||||
<div class='col-2'>\n\
|
||||
<div class='form-group'>" +
|
||||
"<div class='controls'>\n\
|
||||
<select name='item_id[]' id='item_" + x + "' class='form-control compulsory item_select'>" +
|
||||
|
||||
"<?php echo $option_items; ?>" +
|
||||
|
||||
"</select>\n\
|
||||
</div>\n\
|
||||
</div>\n\
|
||||
</div>\n\
|
||||
\n\
|
||||
<div class='col-1'>\n\
|
||||
<div>\n\
|
||||
<div class='form-group'>" +
|
||||
"<input type='text' name='quantity[]' value='1' id ='quantity_" + x + "' class='form-control compulsory qty'>\n\
|
||||
</div>\n\
|
||||
</div>\n\
|
||||
</div>\n\
|
||||
<div class='col-2'>\n\
|
||||
<div class='form-group'>\n\
|
||||
<input type='text' name='unit_cost[]' id='unit_cost_" + x + "' class='form-control compulsory' />\n\
|
||||
</div>\n\
|
||||
</div>\n\
|
||||
<div class='col-2'>\n\
|
||||
<div class='form-group'>" +
|
||||
"<div class='controls'>\n\
|
||||
<input type='text' name='amount[]' id='amount_" + x + "' class='form-control compulsory' />" +
|
||||
" \n\
|
||||
</div>\n\
|
||||
</div>\n\
|
||||
</div>\n\
|
||||
<div class='col-2'>\n\
|
||||
<div>\n\
|
||||
<div class='form-group'>\n\
|
||||
<input type='hidden' name='expense_acc_id[]' id ='expense_acc_id_" + x + "'>\n\
|
||||
<input type='text' name='expense_acc_name[]' id ='expense_acc_name_" + x + "' class='form-control compulsory' readonly='true'>\n\
|
||||
</div>\n\
|
||||
</div>\n\
|
||||
</div>\n\
|
||||
\
|
||||
<div class='col-2'>\n\
|
||||
<div>\n\
|
||||
<div class='form-group'>\n\
|
||||
<input type='hidden' name='payable_acc_id[]' id ='payable_acc_id_" + x + "'>\n\
|
||||
<input type='text' name='payable_acc_name[]' id ='payable_acc_name_" + x + "' class='form-control compulsory' readonly='true'>\n\
|
||||
</div>\n\
|
||||
</div>\n\
|
||||
</div>\n\
|
||||
\
|
||||
<div class=\"col-1\">\
|
||||
<div class=\"form-group\" style=\"margin-top: 10px;\">\
|
||||
<button class=\" remove_field btn btn-sm btn-rounded btn-danger\" style=\"color: white; margin-left: 25px;\"><i class=\"fa fa-trash\"></i></button>\
|
||||
</div>\
|
||||
</div>\
|
||||
</div> \
|
||||
</td>\
|
||||
</tr>"); //add input box
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$(wrapper).on("click", ".remove_field", function (e) { //user click on remove text
|
||||
e.preventDefault();
|
||||
$(this).parent('div').parent('div').parent('div').parent('td').parent('tr').remove();
|
||||
|
||||
var final_total = 0;
|
||||
var total_field = $("#total_amount");
|
||||
|
||||
$("[id^='amount_']").each(function () {
|
||||
final_total += Number($(this).val());
|
||||
});
|
||||
total_field.val(final_total);
|
||||
x--;
|
||||
});
|
||||
$(".input_fields_wrap").on('change', "select", function () {
|
||||
|
||||
var id = parseInt(this.id.substr(this.id.indexOf("_") + 1));
|
||||
|
||||
var item_id = $("#item_" + id).val();
|
||||
var quantity = $("#quantity_" + id).val(); console.log(item_id, quantity)
|
||||
var unit_cost = $("#unit_cost_" + id);
|
||||
var amount_field = $("#amount_" + id);
|
||||
var expense_acc_id = $("#expense_acc_id_" + id);
|
||||
var expense_acc_name = $("#expense_acc_name_" + id);
|
||||
var payable_acc_id = $("#payable_acc_id_" + id);
|
||||
var payable_acc_name = $("#payable_acc_name_" + id);
|
||||
var total_field = $("#total_amount");
|
||||
var final_total = 0;
|
||||
|
||||
if (item_id === "" || quantity === "") {
|
||||
alert("Item and quantity are required");
|
||||
amount_field.val("");
|
||||
return false;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/payments/get_expense_acc",
|
||||
data: {'item_id' : item_id },
|
||||
cache: false,
|
||||
success: function (result){
|
||||
if (result[0] != null) {
|
||||
expense_acc_id.val(result[0].id);
|
||||
expense_acc_name.val(result[0].name);
|
||||
}
|
||||
if (result[1] != null) {
|
||||
payable_acc_id.val(result[1].id);
|
||||
payable_acc_name.val(result[1].name);
|
||||
}
|
||||
// console.log(result);
|
||||
},
|
||||
error: function (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
|
||||
var dataString = "item_id=" + item_id + "&quantity=" + quantity;
|
||||
// console.log(dataString);
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/payments/total_price",
|
||||
data: dataString,
|
||||
cache: false,
|
||||
success: function (result) { //console.log(result);
|
||||
|
||||
unit_cost.val(result[1]);
|
||||
amount_field.val(result[0]);
|
||||
|
||||
$("[id^='amount_']").each(function () { //console.log(this.value);
|
||||
final_total += Number($(this).val());
|
||||
});
|
||||
total_field.val(final_total);
|
||||
},
|
||||
error: function (error) {
|
||||
console.log(error);
|
||||
//alert('Something Went Wrong, Please Contact Support.')
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$("#payments_items").focusout(function(e) {
|
||||
var total_amount = 0;
|
||||
$("[id^=amount]").each(function(){
|
||||
var auto_price = $(this).val();
|
||||
var auto_price_integer = parseInt(auto_price);
|
||||
total_amount += auto_price_integer;
|
||||
});
|
||||
if(total_amount == "NaN"){ total_amount = 0; }
|
||||
$("#total_amount").val(total_amount);
|
||||
});
|
||||
|
||||
$("[id^='quantity_']").change(function () {
|
||||
|
||||
var id = /\d+(?=\D*$)/.exec($(this).attr('id'));
|
||||
var quantity = this.value;
|
||||
var unit_cost = $("#quantity_" + id).val();
|
||||
|
||||
$('#amount_'+id).val(parseInt(quantity) * parseInt(unit_cost));
|
||||
});
|
||||
|
||||
$("[id^='unit_cost_']").change(function () {
|
||||
|
||||
var id = /\d+(?=\D*$)/.exec($(this).attr('id'));
|
||||
var quantity = $("#quantity_" + id).val();
|
||||
var unit_cost = this.value;
|
||||
|
||||
$('#unit_cost_'+id).val(parseInt(quantity) * parseInt(unit_cost));
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
// display the appropriate price of the service
|
||||
function show_service_price(item_id, prompt_div_id) {
|
||||
// get patient id
|
||||
let patient_id = $('#patient_id').val();
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: '/payments/get_payment_item_details',
|
||||
data: {'item_id' : item_id},
|
||||
|
||||
success: function(response){
|
||||
|
||||
// add amount to div
|
||||
$('#' + (prompt_div_id - 1000)).html(response);
|
||||
|
||||
// enable button for calculating
|
||||
$('#calculate_button').attr('disabled', false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// display the appropriate price of the service
|
||||
function show_acc_bal(bank_id) {
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: '/payments/get_account_balance',
|
||||
data: {'bank_id' : bank_id},
|
||||
|
||||
success: function(response){
|
||||
|
||||
var acc_bal = response[0].balance;
|
||||
var total_cost = $('#total_amount').val(); //console.log(total_cost > acc_bal)
|
||||
|
||||
$('#account_balance').val(acc_bal);
|
||||
$('#bank_id').val(response[0].id);
|
||||
|
||||
if(acc_bal <= 0){
|
||||
alert('Account Balance is Zero(0) UGX');
|
||||
$('.submit_btn').hide();
|
||||
}
|
||||
else
|
||||
if(total_cost > acc_bal){
|
||||
alert('Your Account Balance is low');
|
||||
$('.submit_btn').hide();
|
||||
}
|
||||
else{
|
||||
alert('Are you sure you want proceed with this payment ?');
|
||||
$('.submit_btn').show();
|
||||
}
|
||||
},
|
||||
error: function (error) {
|
||||
// console.log(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function calculate_values(){
|
||||
let total_amount = 0;
|
||||
|
||||
// calculate total amount
|
||||
$('.amt').each(function () {
|
||||
total_amount += parseInt(this.value);
|
||||
});
|
||||
// console.log(total_amount);
|
||||
// show total amount to pay
|
||||
$('#total').val(total_amount);
|
||||
|
||||
}
|
||||
|
||||
function change_amt (qty) {
|
||||
let px = $('.amt').val();
|
||||
var total_unit_cost = qty * px;
|
||||
// console.log(total_unit_cost);
|
||||
$('#amt').val(total_unit_cost);
|
||||
}
|
||||
|
||||
function bank_deposit(cashier_income_id, amount) {
|
||||
$('#deposit_amount').val(amount);
|
||||
$('#cashier_income_id').val(cashier_income_id);
|
||||
$('#banking_modal').modal('show');
|
||||
}
|
||||
|
||||
$('#confirm_deposit').click(function () {
|
||||
|
||||
var cashier_income_id = $('#cashier_income_id').val();
|
||||
var deposit_amount = $('#deposit_amount').val();
|
||||
var deposit_account = $('#deposit_account').val();
|
||||
var deposit_date = $('#deposit_date').val();
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: '/banking/quick_bank_deposit',
|
||||
data: {
|
||||
'cashier_income_id' : cashier_income_id,
|
||||
'deposit_amount' : deposit_amount,
|
||||
'deposit_account' : deposit_account,
|
||||
'deposit_date' : deposit_date,
|
||||
},
|
||||
|
||||
success: function(response){
|
||||
console.log(response);
|
||||
$('#banking_modal').modal('hide');
|
||||
$('#bank_' + cashier_income_id).hide();
|
||||
$('#div_' + cashier_income_id).append("<label class='label label-success'>BANKED</label>");
|
||||
},
|
||||
error: function (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function get_acc_bal(bank_id) {
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
url: '/banking/get_current_account_balance',
|
||||
data: {'bank_id' : bank_id},
|
||||
|
||||
success: function(response){
|
||||
var acc_bal = response[0].balance;
|
||||
var amount = $('#deposit_amount').val();
|
||||
$('#current_account_balance').val(acc_bal);
|
||||
$('#new_account_balance').val(acc_bal + parseInt(amount));
|
||||
},
|
||||
error: function (error) {
|
||||
console.log(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
</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">
|
||||
|
||||
jQuery('#end_date').datepicker({
|
||||
autoclose: true,
|
||||
todayHighlight: true,
|
||||
format: 'dd-mm-yyyy'
|
||||
});
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
let min_days = <?php echo $back_date[0]; ?>;
|
||||
var min_date = new Date();
|
||||
min_date.setDate(min_date.getDate()-min_days);
|
||||
jQuery('#bill_date').datepicker({
|
||||
autoclose: true,
|
||||
todayHighlight: true,
|
||||
endDate: new Date(),
|
||||
startDate: min_date,
|
||||
format: 'dd-mm-yyyy'
|
||||
});
|
||||
$('#bill_due_date').datepicker({
|
||||
autoclose: true,
|
||||
todayHighlight: true,
|
||||
startDate: new Date(),
|
||||
format: 'dd-mm-yyyy'
|
||||
});
|
||||
</script>
|
||||
|
||||
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
|
||||
|
||||
<script>
|
||||
$('#staff_member, #vendor, .item_select').select2({
|
||||
placeholder: "-select-"
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
Reference in New Issue
Block a user