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,83 @@
@extends('layouts.main')
@push('styles')
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
<h4 class="page-title">{{ __('clinical_data.add_opticals') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">Dashboard</a></li>
<li><a href="/opticals/">{{ __('clinical_data.opticals') }}</a></li>
<li class="active">Create</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('clinical_data::eye_glasses.menu')
</div>
</div>
<div class="row">
<div class="col-sm-12">
<!--Flash messages at the top -->
@include('flash::message')
<div class="white-box">
{{ Form::open(['route' => 'opticals.store' , 'data-toggle' => 'validator']) }}
<div class="form-group">
{{ Form::label('name', 'Name') }}
{{ Form::text('name', '', ['class' => 'form-control compulsory', 'required']) }}
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
{{ Form::label('price', 'Buying price') }}
{{ Form::number('price', '', ['class' => 'form-control compulsory', 'required']) }}
<div class="help-block with-errors"></div>
</div>
<div class="form-group non_insured_price_div">
{{ Form::label('non_insured_price', 'Cash Price') }}
{{ Form::number('non_insured_price', '', ['class' => 'form-control compulsory', 'required']) }}
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
{{ Form::label('account_id', 'Income Account') }}
{{ Form::select('account_id', $chart_of_accounts, null, ['class' => 'form-control compulsory', 'required']) }}
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
{{ Form::label('cost_of_goods_account', 'Cost of Goods Account') }}
{{ Form::select('cost_of_goods_account', $cost_of_goods_accounts, null, ['class' => 'form-control compulsory', 'required']) }}
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
{{ Form::label('inventory_account', 'Inventory Asset Account') }}
{{ Form::select('inventory_account', $inventory_asset_accounts, null, ['class' => 'form-control compulsory', 'required']) }}
<div class="help-block with-errors"></div>
</div>
{{ Form::button('Submit',['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10']) }}
{{ Form::button('Cancel',['type'=>'reset','class'=>'btn btn-default waves-effect waves-light']) }}
{{ Form::close() }}
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/js/validator.js') }}"></script>
<script type="text/javascript">
</script>
@endpush
@@ -0,0 +1,82 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('elite/bower_components/icheck/skins/all.css') }}" rel="stylesheet">
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
<h4 class="page-title">Edit</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">Dashboard</a></li>
<li><a href="/opticals/">Eye Glasses</a></li>
<li class="active">Edit</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('clinical_data::eye_glasses.menu')
</div>
</div>
@include('flash::message')
<div class="white-box">
{{ Form::model($eye_glass, ['method' => 'PUT', 'route' => ['opticals.update',$eye_glass], 'data-toggle' => 'validator']) }}
<div class="row">
<div class="col-md-6">
<div class="form-group">
{{ Form::label('name','Optical Item Name') }}
{{ Form::text('name',$eye_glass->name,['class' => 'form-control compulsory', 'required']) }}
</div>
<div class="form-group">
{{ Form::label('non_insured_price','Cash Price') }}
{{ Form::text('non_insured_price', $eye_glass->non_insured_price,['class' => 'form-control compulsory', 'required']) }}
</div>
<div class="form-group">
{{ Form::label('inventory_account', 'Inventory Asset Account') }}
{{ Form::select('inventory_account', $inventory_asset_accounts, $eye_glass->inventory_account, ['class' => 'form-control compulsory', 'required']) }}
<div class="help-block with-errors"></div>
</div>
</div>
<div class="col-md-6">
<div class="form-group">
{{ Form::label('buying_price','Optical Item Buying Price') }}
{{ Form::text('buying_price', $eye_glass->buying_price,['class' => 'form-control compulsory', 'required']) }}
</div>
<div class="form-group">
{{ Form::label('account_id', 'Income Account') }}
{{ Form::select('account_id', $chart_of_accounts, $eye_glass->account_id, ['class' => 'form-control compulsory', 'required']) }}
<div class="help-block with-errors"></div>
</div>
<div class="form-group">
{{ Form::label('cost_of_goods_account', 'Cost of Goods Account') }}
{{ Form::select('cost_of_goods_account', $cost_of_goods_accounts, $eye_glass->cost_of_goods_account, ['class' => 'form-control compulsory', 'required']) }}
<div class="help-block with-errors"></div>
</div>
</div>
</div>
{{ Form::button('Submit',['type'=>'submit','class'=>'btn btn-success waves-effect waves-light m-r-10']) }}
{{ Form::button('Cancel',['type'=>'reset','class'=>'btn btn-default waves-effect waves-light']) }}
{{ Form::close() }}
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/js/validator.js') }}"></script>
<!-- icheck -->
<script src="{{ asset('elite/bower_components/icheck/icheck.min.js') }}"></script>
<script src="{{ asset('elite/bower_components/icheck/icheck.init.js') }}"></script>
@endpush
@@ -0,0 +1,92 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('/elite/bower_components/datatables/jquery.dataTables.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('elite/tables/css/buttons.dataTables.min.css') }}" rel="stylesheet" type="text/css" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
<h4 class="page-title">Activate</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">Dashboard</a></li>
<li><a href="/eye_glasses/">{{ __('clinical_data.opticals') }}</a></li>
<li class="active">Activate</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('clinical_data::eye_glasses.menu')
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="white-box">
<p class="text-muted m-b-30">Export data to Copy, CSV, Excel, PDF & Print</p>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Price</th>
<th>Insurance Status</th>
<th>Account Name</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach($eye_glasses as $record)
<tr>
<td>{{ $record->name }}</td>
<td>{{ $record->buying_price }}</td>
<td>
@if ($record->insurance)
Yes
@else
No
@endif
</td>
<td>{{ $chart_of_accounts[$record->account_id] }}</td>
<td>
{{ Form::model($record->id ,['method' => 'POST', 'route' => ['eye_glasses.activate', $record->id]]) }}
<button type="submit" class="btn btn-warning" onclick="return confirm('Are you sure you want to activate?')"><i class="fa fa-check"></i> Activate</button>
{{ Form::close() }}
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/dataTables.buttons.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/buttons.flash.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/zip.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/pdfmake.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/vfs_fonts.js') }}"></script>
<script src="{{ asset('elite/tables/js/buttons.html5.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/buttons.print.min.js') }}"></script>
<script>
$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
});
</script>
@endpush
@@ -0,0 +1,107 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('/elite/bower_components/datatables/jquery.dataTables.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('elite/tables/css/buttons.dataTables.min.css') }}" rel="stylesheet" type="text/css" />
@endpush
@section('content')
<div class="row bg-title">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
<h4 class="page-title">{{ __('clinical_data.opticals') }}</h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">Dashboard</a></li>
<li class="active">View</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('clinical_data::eye_glasses.menu')
</div>
</div>
<div class="row">
<div class="col-sm-12">
<!--Flash messages at the top -->
@include('flash::message')
<div class="white-box">
<p class="text-muted m-b-30">Export data to Copy, CSV, Excel, PDF & Print</p>
<div class="table-responsive">
<table class="table table-striped color-bordered-table success-bordered-table">
<thead>
<tr>
<th>Name</th>
<th>Buying Price</th>
<th>Insurance Status</th>
<th>Non Insured Price</th>
<th>Insured Price</th>
<th>Account Name</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
@if(count($eye_glasses) > 0)
@foreach($eye_glasses as $record)
<tr>
<td>{{ $record['name'] }}</td>
<td>{{ ugandan_shillings($record['buying_price']) }}</td>
<td>
@if ($record['insurance'])
Yes
@else
No
@endif
</td>
<td>{{ ugandan_shillings($record['non_insured_price']) }}</td>
<td>{{ ugandan_shillings($record['insured_price']) }}</td>
<td>{{ $chart_of_accounts[$record['account_id']] }}</td>
<td>
<a href="/opticals/{{ $record['id'] }}/edit/" class="btn btn-info"><i class="fa fa-pencil"></i> Edit</a>
</td>
<td>
{{ Form::model($record['id'] ,['method' => 'DELETE', 'route' => ['opticals.destroy', $record['id']]]) }}
<button type="submit" class="btn btn-danger" onclick="return confirm('Are you sure you want to delete?')"><i class="fa fa-trash"></i> Delete</button>
{{ Form::close() }}
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="7" class="text-center">No records available</td>
</tr>
@endif
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/datatables/jquery.dataTables.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/dataTables.buttons.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/buttons.flash.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/zip.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/pdfmake.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/vfs_fonts.js') }}"></script>
<script src="{{ asset('elite/tables/js/buttons.html5.min.js') }}"></script>
<script src="{{ asset('elite/tables/js/buttons.print.min.js') }}"></script>
<script>
$('.table').DataTable({
dom: 'Bfrtip',
pageLength: 100,
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print'
]
});
</script>
@endpush
@@ -0,0 +1,7 @@
<div class="panel panel-default">
<div class="panel-body">
<a href="{{ route('opticals.create') }}" class="nav-item btn btn-success ti-plus"> {{ __('clinical_data.add_opticals') }}</a>
<a href="{{ route('opticals.index') }}" class="nav-item btn btn-warning ti-eye"> {{ __('clinical_data.view_opticals') }}</a>
<a href="{{ route('opticals.inactive') }}" class="nav-item btn btn-danger ti-pencil"> {{ __('clinical_data.inactive_opticals') }}</a>
</div>
</div>
@@ -0,0 +1,395 @@
@extends('layouts.main')
@push('styles')
<link href="{{ asset('/elite/bower_components/datatables/jquery.dataTables.min.css') }}" rel="stylesheet" type="text/css" />
<link href="{{ asset('elite/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">Order optical items for {{ $patient->last_name }} {{ __('sundries.for_episode') }}:<a>{{ streamline_date(get_name($episode_id, 'id', 'created_at', 'patient_episodes')) }}</h4>
</div>
<div class="col-lg-6 col-sm-5 col-md-5 col-xs-12">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">{{ __('sundries.dashboard') }}</a></li>
<li><a href="{{ route('patient_episodes.index') }}">{{ __('sundries.patient_home') }}</a></li>
<li class="active">Ordering Optical Items</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-sm-12">
@include('patients::allergies.header')
</div>
</div>
<br>
<div class="white-box">
<!--Flash messages at the top -->
@include('flash::message')
@foreach ($errors->all() as $error)
<div>{{ $error }}</div>
@endforeach
{{ Form::open(['route' => 'eye_glasses.submit_order']) }}
<div id='payments_items'>
<table class='table color-bordered-table success-bordered-table'>
<thead>
<tr>
<th>
<div class='row'>
<div class='col-3'>Optical Items</div>
<div class='col-2'>Quantity</div>
<div class='col-3'>Unit Cost</div>
<div class='col-3'>Total Cost</div>
<div class='col-1'></div>
</div>
</th>
</tr>
</thead>
@php
$patient_insurance_status = patient_insurance_status($patient_id);
$option_eye_glasses = "<option value=''>-select-</option>";
foreach ($eye_glasses as $key => $value){
$option_eye_glasses .= "<option value='$key'>$value</option>";
}
$counter = 0;
@endphp
{{ Form::hidden('patient_id', $patient_id, ['id' => 'patient_id']) }}
{{ Form::hidden('patient_insurance_status', $patient_insurance_status, ['id' => 'patient_insurance_status']) }}
<tbody class='input_fields_wrap'>
@if($ordered_eye_glasses)
<tr>
<td style='background-color: #FFE6E6; font-weight: bolder;'>
<u>Pending Optical Items</u>
@if(Auth::user()->can('cancel-ordered-eye-glasses') )
<b><a class="pull-right text-blue" onclick="cancelOrderedItems({{ $ordered_eye_glasses->id }})">Cancel all ordered optical items</a></b>
@endif
</td>
</tr>
{{ Form::hidden('order_id', $ordered_eye_glasses->id) }}
@php
$item_ids = explode(",", $ordered_eye_glasses->eye_glasses_id);
$item_quantities = explode(",", $ordered_eye_glasses->quantity);
@endphp
@for($i = 0; $i < count($item_ids); $i++)
<tr>
<td>
<div class='row'>
<div class='col-3'>
<div class='form-group'>
<div class='controls' id='optical_div_{{ $counter }}'>
{{ Form::select('optical_id[]', $eye_glasses, $item_ids[$i], ['class' => 'form-control compulsory required optical_id_class', 'id' => 'optical_id_' . $counter]) }}
</div>
</div>
</div>
<div class='col-2'>
<div class='form-group'>
<div class='controls'>
<input type='number' value='{{ $item_quantities[$i] }}' name='item_quantity[]' id='item_quantity_{{ $counter }}' class='form-control item_quantity compulsory' required/>
</div>
</div>
</div>
@php
// check if the patient category is attached to a price list
$price_list_id = is_patient_category_attached_to_price_list($patient_id);
if ($price_list_id){
$optical_cost = get_price_list_category_price($price_list_id, 7, $item_ids[$i]);
} else {
// check for insurance
if (get_name($item_ids[$i], 'id', 'insurance', 'eye_glasses') == 1 && patient_insurance_status($patient_id) == 1) {
$optical_cost = get_name($item_ids[$i], 'id', 'insured_price', 'eye_glasses');
} else {
$optical_cost = get_name($item_ids[$i], 'id', 'non_insured_price', 'eye_glasses');
}
}
@endphp
<div class='col-3'>
<div class='form-group'>
<div class='controls'>
<input type='number' value="{{ ($optical_cost) }}" name='item_unit_cost[]' id='item_unit_cost_{{ $counter }}' class='form-control item_unit_cost compulsory' readonly/>
</div>
</div>
</div>
<div class='col-3'>
<div class='form-group'>
<div class='controls'>
<input type='number' value="{{ ($item_quantities[$i] * $optical_cost) }}" name='item_total_cost[]' id='item_total_cost_{{ $counter }}' class='form-control item_total_cost compulsory' readonly/>
</div>
</div>
</div>
<div class='col-1'>
<div class='form-group' style='margin-top: 10px;'>
@if($counter == 0)
<a class='btn btn-sm btn-rounded btn-success add_item' style='color: white; margin-left: 25px;'><i class='fa fa-plus'></i></a>
@else
<a class='remove_field btn btn-sm btn-rounded btn-danger' style='color: white; margin-left: 25px;'><i class='fa fa-trash'></i></a>
@endif
</div>
</div>
</div>
</td>
</tr>
@php $counter++; @endphp
@endfor
@else
<tr>
<td>
<div class='row'>
<div class='col-3'>
<div class='form-group'>
<div class='controls' id='optical_div_{{ $counter }}'>
<select name='optical_id[]' id='optical_id_{{ $counter }}' class='form-control compulsory required optical_id_class'>@php echo $option_eye_glasses; @endphp</select>
</div>
</div>
<div id='drug_expired_div_{{ $counter }}' style='display: none'>
<span class='badge badge-danger'>{{ __('prescriptions.optical_is_expired') }}</span>&nbsp;&nbsp;
</div>
<div id='drug_out_of_stock_div_{{ $counter }}' style='display: none'>
<span class='badge badge-danger'>{{ __('prescriptions.out_of_stock') }}</span>
</div>
</div>
<div class='col-2'>
<div class='form-group'>
<div class='controls'>
<input type='number' value='1' name='item_quantity[]' id='item_quantity_{{ $counter }}' class='form-control item_quantity compulsory' required/>
</div>
</div>
</div>
<div class='col-3'>
<div class='form-group'>
<div class='controls'>
<input type='number' name='item_unit_cost[]' id='item_unit_cost_{{ $counter }}' class='form-control item_unit_cost compulsory' readonly/>
</div>
</div>
</div>
<div class='col-3'>
<div class='form-group'>
<div class='controls'>
<input type='number' name='item_total_cost[]' id='item_total_cost_{{ $counter }}' class='form-control item_total_cost compulsory' readonly/>
</div>
</div>
</div>
<div class='col-1'>
<div class='form-group' style='margin-top: 10px;'>
<a class='btn btn-sm btn-rounded btn-success add_item' style='color: white; margin-left: 25px;'><i class='fa fa-plus'></i></a>
</div>
</div>
</div>
</td>
</tr>
@endif
</tbody>
</table>
</div>
<div class='row'>
<div style="float: right;">
<h3>Total: <span id="itemGrandTotal"></span></h3>
</div>
</div>
<div class='row'>
<div class='col-md-9'>
</div>
<div class='col-md-3'>
<button class='btn btn-rounded btn-info pull-right' id='submit_button'>Save Optical Items</button>
</div>
</div>
{{ Form::close() }}
</div>
@endsection
@push('scripts')
<script src="{{ asset('elite/bower_components/select2/select2.min.js') }}"></script>
<script src="{{ asset('elite/bower_components/bootstrap-datepicker/bootstrap-datepicker.min.js') }}"></script>
<script src="{{ asset('elite/js/validator.js') }}"></script>
<script type="text/javascript">
var max_rows = 20;
var wrapper = $(".input_fields_wrap");
var add_button = $(".add_item");
var x = <?php echo $counter + 1; ?> // initial row count
add_button.click(function (e) { // on add input button click
e.preventDefault();
if (x < max_rows) {
$(wrapper).append("\
<tr>\
<td>\
<div class='row'>\
<div class='col-3'>\
<div class='form-group'>\
<div class='controls' id='optical_div_" + x + "'>\
<select name='optical_id[]' id='optical_id_" + x + "' class='form-control compulsory required optical_id_class' required>@php echo $option_eye_glasses; @endphp</select>\
</div>\
</div>\
</div>\
<div class='col-2'>\
<div class='form-group'>\
<div class='controls'>\
<input type='number' value='1' name='item_quantity[]' id='item_quantity_" + x + "' class='form-control item_quantity compulsory' required/>\
</div>\
</div>\
</div>\
<div class='col-3'>\
<div class='form-group'>\
<div class='controls'>\
<input type='number' name='item_unit_cost[]' id='item_unit_cost_" + x + "' class='form-control item_unit_cost compulsory' readonly/>\
</div>\
</div>\
</div>\
<div class='col-3'>\
<div class='form-group'>\
<div class='controls'>\
<input type='number' name='item_total_cost[]' id='item_total_cost_" + x + "' class='form-control item_total_cost compulsory' readonly/>\
</div>\
</div>\
</div>\
<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>");
generalSelect2Set('optical_id_'+x);
$("select.item_select").change(function(){
var id = /\d+(?=\D*$)/.exec($(this).attr('id'));
var name_selected = $(this).children("option:selected").val();
$("#name_" + id).val(parseInt(name_selected));
});
x++;
}
});
$(wrapper).on("click", ".remove_field", function (e) {
e.preventDefault();
$(this).parent('div').parent('div').parent('div').parent('td').parent('tr').remove();
});
$(".input_fields_wrap").on('change', ".optical_id_class", function () {
var id = /\d+(?=\D*$)/.exec($(this).attr('id'));
var item = $("#optical_id_" + id).val();
var patient_id = $('#patient_id').val();
let patient_insurance_status = $('#patient_insurance_status').val();
$.ajax({
url: '/get_optical_pricing',
data: {'patient_id':patient_id,'patient_insurance_status':patient_insurance_status, 'item':item},
dataType:'json',
success: function(response){
$("#item_unit_cost_"+id).val(response.selling_price);
$("#item_total_cost_"+id).val(response.selling_price);
$("#item_quantity_"+id).val(1);
if (response.total_stock == 1) {
$("#drug_out_of_stock_div_" + id).show();
} else {
$("#drug_out_of_stock_div_" + id).hide();
}
if (response.expiry == 1) {
$("#drug_expired_div_" + id).show();
} else {
$("#drug_expired_div_" + id).hide();
}
//loop through the prices
let auto_price_grand_total = 0;
$(".item_total_cost").each(function(){
auto_price_grand_total += parseInt($(this).val());
});
// recalculate the grand total
$("#itemGrandTotal").html(numberWithCommas(auto_price_grand_total) + " Ugx");
}
});
});
$(".optical_id_class").select2({
width: "100%"
});
$(".input_fields_wrap").on('change keyup', ".item_quantity", function () {
// make sure the lowest number is 1
if (+$(this).val() < 1) {
$(this).val(1);
}
// get the quantity and multiply against this for the total
var id = /\d+(?=\D*$)/.exec($(this).attr('id'));
let total_cost = +$('#item_unit_cost_' + id).val() * +$(this).val();
$('#item_total_cost_' + id).val(total_cost);
let auto_price_grand_total = 0;
$(".item_total_cost").each(function(){
auto_price_grand_total += +$(this).val();
});
// recalculate the grand total
$("#itemGrandTotal").html(numberWithCommas(auto_price_grand_total) + " Ugx");
});
$(".input_fields_wrap").on('change', ".item_unit_cost", function () {
// get the quantity and multiply against this for the total
var id = /\d+(?=\D*$)/.exec($(this).attr('id'));
let total_cost = +$('#item_quantity_' + id).val() * +$(this).val();
$('#item_total_cost_' + id).val(total_cost);
let auto_price_grand_total = 0;
$(".item_total_cost").each(function(){
auto_price_grand_total += +$(this).val();
});
// recalculate the grand total
$("#itemGrandTotal").html(numberWithCommas(auto_price_grand_total) + " Ugx");
});
function generalSelect2Set(id) {
$('#'+id).select2({
width: "100%"
});
}
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
function cancelOrderedItems(order_id) {
if (confirm("Are you sure you want to continue? This will cancel all unpaid orders")) {
$.ajax({
url: '/cancel_ordered_glasses/' + order_id,
success: function(response){
if (response == 1) {
alert("Optical items have been cancelled");
window.location.reload();
} else {
alert("Cancellation of optical items failed");
}
}
});
}
}
</script>
@endpush