2021-07-02 04:35:43 +00:00
|
|
|
@extends('adminlte::layouts.app')
|
|
|
|
|
|
|
|
@section('htmlheader_title')
|
|
|
|
Payment
|
|
|
|
@endsection
|
|
|
|
@section('page_title')
|
|
|
|
Payment
|
|
|
|
@endsection
|
|
|
|
|
|
|
|
@section('contentheader_title')
|
|
|
|
Record Payment
|
|
|
|
@endsection
|
|
|
|
@section('contentheader_description')
|
|
|
|
@endsection
|
|
|
|
|
|
|
|
@section('main-content')
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-6">
|
|
|
|
|
|
|
|
<div class="card card-dark">
|
|
|
|
<div class="card-header">
|
|
|
|
<h1 class="card-title">Record Payment</h1>
|
|
|
|
@if(session()->has('success'))
|
|
|
|
<span class="ml-3 pt-0 pb-0 pr-1 pl-1 btn btn-outline-success"><small>{{ session()->get('success') }}</small></span>
|
|
|
|
@endif
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="card-body">
|
|
|
|
<form class="g-0 needs-validation" method="POST" role="form">
|
|
|
|
@csrf
|
|
|
|
|
|
|
|
<div class="row">
|
2021-10-01 04:59:04 +00:00
|
|
|
<!-- DATE RECEIVED -->
|
2021-07-02 04:35:43 +00:00
|
|
|
<div class="col-4">
|
|
|
|
<div class="form-group has-validation">
|
2021-07-23 07:25:26 +00:00
|
|
|
<label for="payment_date">Date Received</label>
|
2021-07-02 04:35:43 +00:00
|
|
|
<div class="input-group">
|
|
|
|
<div class="input-group-prepend">
|
|
|
|
<span class="input-group-text"><i class="fas fa-fw fa-calendar"></i></span>
|
|
|
|
</div>
|
2021-07-23 07:25:26 +00:00
|
|
|
<input type="date" class="form-control @error('payment_date') is-invalid @enderror" id="payment_date" name="payment_date" value="{{ old('payment_date',($o->exists ? $o->payment_date : \Carbon\Carbon::now())->format('Y-m-d')) }}" required>
|
2021-07-02 04:35:43 +00:00
|
|
|
<span class="invalid-feedback" role="alert">
|
2021-07-23 07:25:26 +00:00
|
|
|
@error('payment_date')
|
2021-07-02 04:35:43 +00:00
|
|
|
{{ $message }}
|
|
|
|
@else
|
|
|
|
Payment Date is required.
|
|
|
|
@enderror
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<span class="input-helper">Date Payment Received.</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2021-10-01 04:59:04 +00:00
|
|
|
<!-- AMOUNT -->
|
2021-07-23 07:25:26 +00:00
|
|
|
<div class="offset-4 col-4">
|
2021-07-02 04:35:43 +00:00
|
|
|
<div class="form-group has-validation">
|
|
|
|
<label for="total_amt">Amount</label>
|
|
|
|
<div class="input-group">
|
|
|
|
<div class="input-group-prepend">
|
|
|
|
<span class="input-group-text"><i class="fas fa-fw fa-dollar-sign"></i></span>
|
|
|
|
</div>
|
2021-09-28 00:09:56 +00:00
|
|
|
<input type="text" class="text-right form-control @error('total_amt') is-invalid @enderror" id="total_amt" name="total_amt" value="{{ number_format(old('total_amt',$o->exists ? $o->total_amt : 0),2) }}" required>
|
2021-07-02 04:35:43 +00:00
|
|
|
<span class="invalid-feedback" role="alert">
|
|
|
|
@error('total_amt')
|
|
|
|
{{ $message }}
|
|
|
|
@else
|
|
|
|
Payment Amount is required.
|
|
|
|
@enderror
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<span class="input-helper">Amount Received.</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="row">
|
2021-10-01 04:59:04 +00:00
|
|
|
<!-- METHOD -->
|
2021-07-02 04:35:43 +00:00
|
|
|
<div class="col-4">
|
|
|
|
<div class="form-group has-validation">
|
|
|
|
<label for="checkout_id">Payment Method</label>
|
|
|
|
<div class="input-group">
|
|
|
|
<div class="input-group-prepend">
|
|
|
|
<span class="input-group-text"><i class="fas fa-fw fa-dollar-sign"></i></span>
|
|
|
|
</div>
|
|
|
|
<select class="form-control @error('checkout_id') is-invalid @enderror" id="checkout_id" name="checkout_id" required>
|
|
|
|
<option value=""></option>
|
|
|
|
@foreach (\App\Models\Checkout::orderBy('name')->get() as $co)
|
|
|
|
<option value="{{ $co->id }}" {{ $co->id == old('checkout_id',$o->exists ? $o->checkout_id : NULL) ? 'selected' : '' }}>{{ $co->name }}</option>
|
|
|
|
@endforeach
|
|
|
|
</select>
|
|
|
|
<span class="invalid-feedback" role="alert">
|
|
|
|
@error('checkout_id')
|
|
|
|
{{ $message }}
|
|
|
|
@else
|
|
|
|
Payment Method is required.
|
|
|
|
@enderror
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<span class="input-helper">Payment Method.</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2021-10-01 04:59:04 +00:00
|
|
|
<!-- PAYMENT FEE -->
|
2021-07-23 07:25:26 +00:00
|
|
|
<div class="offset-4 col-4">
|
2021-07-02 04:35:43 +00:00
|
|
|
<div class="form-group has-validation">
|
|
|
|
<label for="fees_amt">Fee</label>
|
|
|
|
<div class="input-group">
|
|
|
|
<div class="input-group-prepend">
|
|
|
|
<span class="input-group-text"><i class="fas fa-fw fa-dollar-sign"></i></span>
|
|
|
|
</div>
|
2021-09-28 00:09:56 +00:00
|
|
|
<input type="text" class="text-right form-control @error('fees_amt') is-invalid @enderror" id="fees_amt" name="fees_amt" value="{{ number_format(old('fees_amt',$o->exists ? $o->fees_amt : 0),2) }}">
|
2021-07-02 04:35:43 +00:00
|
|
|
<span class="invalid-feedback" role="alert">
|
|
|
|
@error('fees_amt')
|
|
|
|
{{ $message }}
|
|
|
|
@else
|
2021-07-23 07:25:26 +00:00
|
|
|
Total Fees is required.
|
2021-07-02 04:35:43 +00:00
|
|
|
@enderror
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<span class="input-helper">Amount Received.</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="row">
|
2021-10-01 04:59:04 +00:00
|
|
|
<!-- ACCOUNT -->
|
2021-07-02 04:35:43 +00:00
|
|
|
<div class="col-6">
|
|
|
|
<div class="form-group has-validation">
|
|
|
|
<label for="account_id">Account</label>
|
|
|
|
<div class="input-group">
|
|
|
|
<div class="input-group-prepend">
|
|
|
|
<span class="input-group-text"><i class="fas fa-fw fa-user"></i></span>
|
|
|
|
</div>
|
|
|
|
<!-- @todo Only show active accounts or accounts with outstanding invoices -->
|
|
|
|
<select class="form-control @error('account_id') is-invalid @enderror" id="account_id" name="account_id" required>
|
|
|
|
<option value=""></option>
|
2021-10-01 04:59:04 +00:00
|
|
|
@foreach (\App\Models\Account::active()->with(['user'])->get()->sortBy('name') as $ao)
|
2021-07-02 04:35:43 +00:00
|
|
|
<option value="{{ $ao->id }}" {{ $ao->id == old('account_id',$o->exists ? $o->account_id : NULL) ? 'selected' : '' }}>{{ $ao->name }}</option>
|
|
|
|
@endforeach
|
|
|
|
</select>
|
|
|
|
|
|
|
|
<span class="invalid-feedback" role="alert">
|
|
|
|
@error('account_id')
|
2021-07-23 07:25:26 +00:00
|
|
|
{{ $message }}
|
2021-07-02 04:35:43 +00:00
|
|
|
@else
|
|
|
|
Account is required.
|
2021-07-23 07:25:26 +00:00
|
|
|
@enderror
|
2021-07-02 04:35:43 +00:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<span class="input-helper">Account to add payment to.</span>
|
|
|
|
<i class="fas fa-spinner d-none"></i>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-07-23 07:25:26 +00:00
|
|
|
|
2021-10-01 04:59:04 +00:00
|
|
|
<!-- BALANCE -->
|
2021-07-23 07:25:26 +00:00
|
|
|
<div class="offset-2 col-4">
|
|
|
|
<label for="fees_amt">Balance</label>
|
|
|
|
<div class="input-group">
|
|
|
|
<div class="input-group-prepend">
|
|
|
|
<span class="input-group-text"><i class="fas fa-fw fa-dollar-sign"></i></span>
|
|
|
|
</div>
|
2021-10-01 04:59:04 +00:00
|
|
|
<input type="text" class="text-right form-control @error('fees_amt') is-invalid @enderror" id="balance" value="{{ number_format($o->exists ? $o->balance : 0,2) }}" disabled>
|
2021-07-23 07:25:26 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-07-02 04:35:43 +00:00
|
|
|
</div>
|
|
|
|
|
2021-07-23 07:25:26 +00:00
|
|
|
<div class="row mt-3 mb-3">
|
|
|
|
<div class="col-12">
|
2021-07-02 04:35:43 +00:00
|
|
|
<div id="invoices"></div>
|
|
|
|
@error('invoices')
|
|
|
|
<span class="invalid-feedback d-block mt-2 mb-2" role="alert">
|
|
|
|
{{ $message }}
|
|
|
|
</span>
|
|
|
|
@enderror
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="row">
|
|
|
|
<div class="col-12">
|
|
|
|
<a href="{{ url('/home') }}" class="btn btn-danger">Cancel</a>
|
|
|
|
@can('wholesaler')
|
|
|
|
<button type="submit" name="submit" class="btn btn-success mr-0 float-right">@if ($site->exists)Save @else Add @endif</button>
|
|
|
|
@endcan
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
@endsection
|
|
|
|
|
|
|
|
@section('page-scripts')
|
2021-10-01 04:59:04 +00:00
|
|
|
@css('//cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css','select-css')
|
|
|
|
@js('//cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/js/select2.min.js','select-js')
|
|
|
|
@js('/select2/fix-autofocus.js','select-fix-js','select-js')
|
|
|
|
@css('/select2/fix-select-height.css','select-fix-css','select-css')
|
2021-07-02 04:35:43 +00:00
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
function populate(account,spinner) {
|
|
|
|
spinner.toggleClass('d-none').toggleClass('fa-spin');
|
|
|
|
|
|
|
|
$.ajax({
|
|
|
|
type: 'POST',
|
|
|
|
dataType: 'html',
|
|
|
|
cache: false,
|
|
|
|
url: '{{ url('api/r/invoices') }}'+'/'+account,
|
2021-10-01 04:59:04 +00:00
|
|
|
data: {pid:{{ $o->id ?: 'null' }}},
|
2021-07-02 04:35:43 +00:00
|
|
|
timeout: 2000,
|
|
|
|
error: function(x) {
|
|
|
|
spinner.toggleClass('d-none').toggleClass('fa-spin');
|
|
|
|
alert('Failed to submit');
|
|
|
|
},
|
|
|
|
success: function(data) {
|
|
|
|
spinner.toggleClass('d-none').toggleClass('fa-spin');
|
|
|
|
$("div[id=invoices]").empty().append(data);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-10-01 04:59:04 +00:00
|
|
|
function balance() {
|
|
|
|
var alloc = 0;
|
|
|
|
|
|
|
|
$('.invoice').each(function() {
|
|
|
|
alloc += $(this).val();
|
|
|
|
})
|
|
|
|
|
|
|
|
$('#balance').val(($('#total_amt').val()-alloc).toFixed(2))
|
|
|
|
}
|
|
|
|
|
2021-07-02 04:35:43 +00:00
|
|
|
$(document).ready(function() {
|
|
|
|
if ($('#account_id').val()) {
|
|
|
|
var spinner = $('#account_id').parent().parent().find('i.fas.fa-spinner');
|
|
|
|
|
|
|
|
populate($('#account_id').val(),spinner);
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#account_id').select2({
|
|
|
|
sorter: data => data.sort((a, b) => a.text.localeCompare(b.text)),
|
|
|
|
})
|
|
|
|
.on('change',function(e) {
|
|
|
|
if (! $(this).val()) {
|
|
|
|
$("div[id=invoices]").empty();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var spinner = $(this).parent().parent().find('i.fas.fa-spinner');
|
|
|
|
|
|
|
|
populate($(this).val(),spinner);
|
|
|
|
});
|
2021-10-01 04:59:04 +00:00
|
|
|
|
|
|
|
$('#total_amt').on('change',balance);
|
2021-07-02 04:35:43 +00:00
|
|
|
});
|
2021-10-01 04:59:04 +00:00
|
|
|
|
|
|
|
$(document).on('change','.invoice',balance);
|
2021-07-02 04:35:43 +00:00
|
|
|
</script>
|
|
|
|
@append
|