| Path : /var/www/html/mini-moneyexchange/resources/views/moneyExchange/ |
|
B-Con CMD Config cPanel C-Rdp D-Log Info Jump Mass Ransom Symlink vHost Zone-H |
| Current File : //var/www/html/mini-moneyexchange/resources/views/moneyExchange/form.blade.php |
@extends('layouts.main')
@section('content')
<div class="page-wrapper" id="app">
<div class="page-breadcrumb">
<div class="row">
<div class="col-12 d-flex no-block align-items-center">
<h4 class="page-title">{{__('message.exchange money')}}</h4>
<div class="ms-auto text-end">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">
<a href="{{route('exchange-money.create')}}" class="btn btn-primary btn-sm">
<i class="fa fa-plus"></i>
{{{__('message.add new')}}}
</a>
</li>
</ol>
</nav>
</div>
</div>
</div>
</div>
<div class="container-fluid" style="padding-top: 0px;">
<div class="card">
<div class="card-body form wizard-content">
<form method="POST" action="{{route('exchange-money.store')}}" class="mt-5" enctype="multipart/form-data">
{{ csrf_field() }}
<input type="hidden" v-model="datas.money_exchange_list_id" name="money_exchange_list_id">
<section>
<div class="row" style="margin-top:20px;">
<div class="col-sm-4">
<label class="col-xs-12 col-sm-12 form-custom" style="text-align: right;padding-top:15px;">
{{__('message.received money')}}
</label>
</div>
<div class="col-sm-4">
<div class="input-group" style="background-color:#7f8cae !important">
<input type="number" class="form-control custom-form-control" required name="received_amount" v-model="datas.received_amount" step="0.01" min="0">
<span class="input-group-text" style="font-weight: bold;">
@{{datas.exchange_from_name}}
</span>
</div>
</div>
<div class="col-sm-4">
</div>
</div>
<div class="row" style="background-color: #919ec0;padding:20px 10px;">
<div class="col-sm-4">
<label class="col-xs-12 col-sm-12 form-custom" style="text-align: center;">
{{__('message.exchange from')}}
</label>
<div class="input-group" style="background-color:#7f8cae !important">
<input type="number" class="form-control custom-form-control" name="exchange_from_amount" v-model="datas.exchange_from_amount" step="0.01" @change="changeData('exchange_from_amount')" min="0" required>
<select class="btn btn-outline-secondary dropdown-toggle show" type="button" data-bs-toggle="dropdown" aria-expanded="true" name="exchange_from_id" v-model="datas.exchange_from_id" ref="exchange_from_id">
@foreach($currencies as $index =>$currency)
<option value="{{$currency->id}}" class="exchange_from_id_{{$currency->id}}" flage="/{{$currency->flage}}" sample_money="/{{$currency->sample_money}}">
{{$currency->name}}</option>
@endforeach
</select>
</div>
</div>
<div class="col-sm-4">
<label class="col-xs-12 col-sm-12 form-custom" style="text-align: center;">
{{__('message.exchange rate')}}
</label>
<div class="input-group" style="background-color:#7f8cae !important">
<?php
if(Auth::user()->role_id!=2){
if(Auth::user()->allow_to_change_exchange_rate) {
$canChangeRate = true;
}
else {
$canChangeRate = false;
}
}
else{
$canChangeRate = true;
}
?>
<input type="number" class="form-control custom-form-control" required step="0.01" name="exchange_rate" v-model="datas.exchange_rate" step="0.0001" @if(!$canChangeRate) readonly @endif>
<span class="input-group-text" style="font-weight: bold;">
@{{datas.exchange_from_name}}/@{{datas.exchange_to_name}}
</span>
</div>
</div>
<div class="col-sm-4">
<label class="col-xs-12 col-sm-12 form-custom" style="text-align: center;">
{{__('message.exchange to')}}
</label>
<div class="input-group" style="background-color:#7f8cae !important">
<input type="number" class="form-control custom-form-control" required name="exchange_to_amount" v-model="datas.exchange_to_amount" step="0.01" @change="changeData('exchange_to_amount')" min="0">
<select class="btn btn-outline-secondary dropdown-toggle show" type="button" data-bs-toggle="dropdown" aria-expanded="true" name="exchange_to_id" v-model="datas.exchange_to_id" ref="exchange_to_id">
@foreach($currencies as $index =>$currency)
<option value="{{$currency->id}}" class="exchange_to_id_{{$currency->id}}" flage="/{{$currency->flage}}" sample_money="/{{$currency->sample_money}}">{{$currency->name}}</option>
@endforeach
</select>
</div>
</div>
</div>
<div class="row" style="margin-top:20px;">
<div class="col-sm-4">
<label class="col-xs-12 col-sm-12 form-custom" style="text-align: right;padding-top:15px;">
<img :src="flage_from" style="width:70px;float: left;">
{{__('message.remain')}}
</label>
</div>
<div class="col-sm-4">
<div class="input-group" style="background-color:#7f8cae !important">
<input type="number" class="form-control custom-form-control" required name="remain" v-model="datas.remain" step="0.01" readonly="">
<span class="input-group-text" style="font-weight: bold;">
@{{datas.exchange_from_name}}
</span>
</div>
</div>
<div class="col-sm-4">
<img :src="flage_to" style="width:70px;float: right;">
</div>
</div>
<div class="text-center" style="margin-top:20px;">
<button class="btn btn-danger btn-sm" type="reset" style="padding:15px 20px;font-size: 20px;">
{{__('message.cancel')}}
</button>
<!-- <button type="submit" class="btn btn-primary btn-sm" style="padding:15px 20px;font-size: 20px;">
<i class="fa fa-save"></i>
{{__('message.save')}}
</button> -->
<button type="submit" class="btn btn-primary btn-sm" style="padding:15px 20px;font-size: 20px;">
<i class="fa fa-save"></i>
{{__('message.save')}} & {{__('message.print')}}
</button>
</div>
</section>
</form>
</div>
<div class="table-responsive">
<a href="{{route('transactions')}}">
<h3 style="text-align: center;margin-top:15px;color:#3e5569">{{__('message.last 5 transactions')}}</h3>
</a>
<table
id="zero_config"
class="table table-striped table-bordered">
<thead>
<tr>
<th>#</th>
<th>{{__('message.exchange from')}}/{{__('message.exchange to')}}</th>
<th>{{__('message.amount')}}</th>
<th>{{__('message.exchange rate')}}</th>
<th>{{__('message.exchange to')}}</th>
<!-- <th>{{__('message.fee')}}</th> -->
<th>{{__('message.received money')}}</th>
<th>{{__('message.remain')}}</th>
<th>{{__('message.created date')}}</th>
<th>{{__('message.action')}}</th>
</tr>
</thead>
<tbody>
<?php
?>
@foreach($transactions as $index => $transaction)
@if(isset($transaction->moneyExchangeList))
<?php
$currencyFrom= $transaction->moneyExchangeList->exchangeFromCurrency;
$currencyTo= $transaction->moneyExchangeList->exchangeToCurrency;
?>
<tr>
<td>{{$index+1}}</td>
<td style="font-weight: bold;">
{{$currencyFrom->currency_code??''}}/
{{$currencyTo->currency_code??''}}
</td>
<td class="credit">
{{number_format($transaction->amount,$currencyFrom->decimal_precision) }}
{{$currencyFrom->currency_code}}
</td>
<td class="credit blur">
<!-- {{$currencyTo->currency_code}} -->
{{number_format($transaction->exchange_rate,$currencyTo->decimal_precision) }}
</td>
<td class="credit">
{{number_format($transaction->amount_after_exchange,$currencyTo->decimal_precision) }}
{{$currencyTo->currency_code}}
</td>
<!-- <td class="credit">
{{number_format($transaction->fee,$currencyTo->decimal_precision) }}
{{$currencyTo->currency_code}}
</td> -->
<td class="credit blur">
{{number_format($transaction->received_amount,$currencyFrom->decimal_precision)}}
{{$currencyFrom->currency_code}}
</td>
<td class="credit blur">
{{number_format($transaction->remain,$currencyFrom->decimal_precision)}}
{{$currencyFrom->currency_code}}
</td>
<td title="{{$transaction->created_at}}">
{{ $transaction->created_at->format('d/m/Y H:i') }}
</td>
<td>
<button type="button" class="btn btn-primary btn-sm" onclick="printInvoice('{{$transaction->id}}')">
<i class="fa fa-print"></i>
{{__('message.print')}}
</button>
{{-- <form method="POST" action="{{route('transactions.destroy', $transaction)}}" style="display:inline">
<input name="_method" type="hidden" value="DELETE">
{{ csrf_field() }}
<button type="submit" class="btn btn-danger btn-sm" onclick="return confirm('{{ __('message.do you want to delete') }}?')">
<i class="fas fa-trash" style="color: #FFF;"></i>
</button>
</form> --}}
</td>
</tr>
@endif
@endforeach
</tbody>
</table>
</div>
</div>
</div>
</div>
@endsection
@section('scripts')
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/axios/0.21.1/axios.min.js" integrity="sha512-bZS47S7sPOxkjU/4Bt0zrhEtWx0y0CRkhEp8IckzK+ltifIIE9EMIMTuT/mEzoIMewUINruDBIR/jJnbguonqQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script type="text/javascript">
var app = new Vue({
el: '#app',
data: {
datas: {
exchange_from_id: 1,
exchange_from_name:'',
exchange_from_code:'',
exchange_to_id: 2,
exchange_to_name:'',
exchange_to_code:'',
exchange_from_amount: '',
exchange_to_amount: '',
received_amount :'',
remain: '',
// rate_list:{},
exchange_rate:'',
calculation:'',
money_exchange_list_id:'',
},
rates: [],
flage_from:'',
flage_to :''
},
beforeMount() {
var that = this;
axios.get('/api/current-money-exchange-rate').then(function (response) {
that.rates = response.data
that.changeData('exchange_from_id',that.datas.exchange_from_id,that.datas.exchange_from_id);
that.changeData('exchange_to_id',that.datas.exchange_from_id,that.datas.exchange_from_id);
}).catch(function (response) {
that.error = "Something went wrong";
console.log(response)
})
},
methods :{
formatCurrency: function(amount, currency_code){
if(currency_code=='KHR'){
return (_.round((amount/100))*100);
}
else if(currency_code=='THB'){
return (_.round(amount));
}
return _.round(amount,2);
},
changeData : function(var_that_changed, newVal=1, oldVal=2) {
that= this;
if(var_that_changed=='exchange_from_id'){
var temp = this.rates.data.filter(rate => {
return rate.exchange_from_id==that.datas.exchange_from_id && rate.exchange_to_id==that.datas.exchange_to_id;
})
if(temp.length){
that.datas.money_exchange_list_id = temp[0].money_exchange_list_id
that.datas.exchange_from_name = temp[0].exchange_from_name
that.datas.exchange_from_code = temp[0].exchange_from_code
that.datas.exchange_rate = temp[0].current_rate
that.datas.calculation = temp[0].calculation
}
this.changeRate(var_that_changed,oldVal);
setTimeout(() => {
this.flage_from= this.$refs.exchange_from_id.selectedOptions[0].getAttribute('flage');
this.flage_to= this.$refs.exchange_to_id.selectedOptions[0].getAttribute('flage');
}, 100);
}
else if(var_that_changed=='exchange_to_id') {
var temp = that.rates.data.filter(rate => {
return rate.exchange_from_id==that.datas.exchange_from_id && rate.exchange_to_id==that.datas.exchange_to_id;
})
if(temp.length){
that.datas.money_exchange_list_id = temp[0].money_exchange_list_id
that.datas.exchange_to_name = temp[0].exchange_to_name
that.datas.exchange_to_code = temp[0].exchange_to_code
that.datas.exchange_rate = temp[0].current_rate
that.datas.calculation = temp[0].calculation
}
this.changeRate(var_that_changed,oldVal);
setTimeout(() => {
this.flage_from= this.$refs.exchange_from_id.selectedOptions[0].getAttribute('flage');
this.flage_to= this.$refs.exchange_to_id.selectedOptions[0].getAttribute('flage');
}, 100);
}
else if(var_that_changed=='exchange_from_amount') {
if(that.datas.calculation=='x'){
// alert(that.datas.exchange_to_code);
// if(that.datas.exchange_to_code=='KHR'){
// that.datas.exchange_to_amount = _.round((_.round((that.datas.exchange_from_amount*that.datas.exchange_rate)/100,0)*100), 2);
// }
// else{
that.datas.exchange_to_amount = that.formatCurrency((that.datas.exchange_from_amount*that.datas.exchange_rate), that.datas.exchange_to_code);
// }
}
else{
that.datas.exchange_to_amount = that.formatCurrency((that.datas.exchange_from_amount/that.datas.exchange_rate),that.datas.exchange_to_code);
}
}
else if(var_that_changed=='exchange_to_amount') {
if(that.datas.calculation=='x'){
that.datas.exchange_from_amount = that.formatCurrency((that.datas.exchange_to_amount/that.datas.exchange_rate),that.datas.exchange_from_code);
}
else{
that.datas.exchange_from_amount = that.formatCurrency((that.datas.exchange_to_amount*that.datas.exchange_rate),that.datas.exchange_from_code);
}
}
else if(var_that_changed=='received_amount') {
if(that.datas.received_amount!=''){
that.datas.remain = that.formatCurrency((that.datas.received_amount-that.datas.exchange_from_amount), that.datas.exchange_to_code);
}
}
else if(var_that_changed=='exchange_rate') {
if(that.datas.calculation=='x'){
that.datas.exchange_to_amount = that.formatCurrency((that.datas.exchange_from_amount*that.datas.exchange_rate),that.datas.exchange_to_code);
}
else{
that.datas.exchange_to_amount = that.formatCurrency((that.datas.exchange_from_amount/that.datas.exchange_rate),that.datas.exchange_to_code);
}
}
// alert(that.datas.exchange_from_code+":"+that.datas.exchange_to_code)
if(that.datas.received_amount!=''){
that.datas.remain = that.formatCurrency((that.datas.received_amount-that.datas.exchange_from_amount),that.datas.exchange_from_code);
}
else {
that.datas.remain='';
}
},
changeRate : function(var_that_changed, oldVal) {
if(this.datas.exchange_from_id==this.datas.exchange_to_id){
if(var_that_changed=='exchange_from_id'){
this.datas.exchange_to_id = oldVal;
}
else {
this.datas.exchange_from_id = oldVal;
}
this.changeData(var_that_changed,this.datas.exchange_to_id, oldVal)
}
if(this.datas.exchange_from_amount!='' && this.datas.exchange_to_amount!='') {
if(that.datas.calculation=='x'){
that.datas.exchange_to_amount = that.formatCurrency((that.datas.exchange_from_amount*that.datas.exchange_rate),that.datas.exchange_to_code);
}
else{
that.datas.exchange_to_amount = that.formatCurrency((that.datas.exchange_from_amount/that.datas.exchange_rate), that.datas.exchange_to_code);
}
}
}
},
watch: {
'datas.exchange_from_id': function(newVal, oldVal) {
this.changeData('exchange_from_id', newVal, oldVal);
},
'datas.exchange_to_id': function(newVal, oldVal) {
this.changeData('exchange_to_id', newVal, oldVal);
},
// 'datas.exchange_from_amount': function(v) {
// this.changeData('exchange_from_amount', v);
// },
// 'datas.exchange_to_amount': function(v) {
// this.changeData('exchange_to_amount', v);
// },
'datas.received_amount': function(newVal, oldVal) {
this.changeData('received_amount', newVal, oldVal);
},
'datas.exchange_rate': function(newVal, oldVal) {
this.changeData('exchange_rate', newVal, oldVal);
}
}
})
</script>
<script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
<script type="text/javascript">
function printInvoice(transaction_id){
window.open("{{route('exchange-invoice')}}/"+transaction_id);
}
</script>
@if(isset($transaction_id) && $transaction_id!=null && isset($already_print) && $already_print==false)
<script type="text/javascript">
// window.open("{{route('exchange-invoice')}}/{{$transaction_id}}");
// window.location.href = "{{route('exchange-invoice')}}/{{$transaction_id}}";
window.onload = function() {
window.open("{{route('exchange-invoice')}}/{{$transaction_id}}");
}
</script>
@endif
@endsection
@section('meta')
<title>{{__('message.exchange money')}}</title>
@endsection