Wizard Currencies step finished
This commit is contained in:
parent
70379839b7
commit
5f00757142
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers\Wizard;
|
namespace App\Http\Controllers\Wizard;
|
||||||
|
|
||||||
|
use Akaunting\Money\Currency as MoneyCurrency;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests\Setting\Currency as Request;
|
use App\Http\Requests\Setting\Currency as Request;
|
||||||
use App\Models\Banking\Account;
|
use App\Models\Banking\Account;
|
||||||
@ -27,6 +28,70 @@ class Currencies extends Controller
|
|||||||
return view('wizard.currencies.index', compact('currencies'));
|
return view('wizard.currencies.index', compact('currencies'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
// Get current currencies
|
||||||
|
$current = Currency::pluck('code')->toArray();
|
||||||
|
|
||||||
|
// Prepare codes
|
||||||
|
$codes = array();
|
||||||
|
$currencies = MoneyCurrency::getCurrencies();
|
||||||
|
foreach ($currencies as $key => $item) {
|
||||||
|
// Don't show if already available
|
||||||
|
if (in_array($key, $current)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$codes[$key] = $key;
|
||||||
|
}
|
||||||
|
|
||||||
|
$html = view('wizard.currencies.create', compact('codes'))->render();
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'error' => false,
|
||||||
|
'message' => 'null',
|
||||||
|
'html' => $html,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store a newly created resource in storage.
|
||||||
|
*
|
||||||
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
// Force the rate to be 1 for default currency
|
||||||
|
if ($request['default_currency']) {
|
||||||
|
$request['rate'] = '1';
|
||||||
|
}
|
||||||
|
|
||||||
|
$currency = Currency::create($request->all());
|
||||||
|
|
||||||
|
// Update default currency setting
|
||||||
|
if ($request['default_currency']) {
|
||||||
|
setting()->set('general.default_currency', $request['code']);
|
||||||
|
setting()->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
$message = trans('messages.success.added', ['type' => trans_choice('general.currencies', 1)]);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'error' => false,
|
||||||
|
'message' => $message,
|
||||||
|
'data' => $currency,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
@ -40,7 +105,24 @@ class Currencies extends Controller
|
|||||||
return redirect('/');
|
return redirect('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = view('wizard.currencies.edit', compact('currency'))->render();
|
// Get current currencies
|
||||||
|
$current = Currency::pluck('code')->toArray();
|
||||||
|
|
||||||
|
// Prepare codes
|
||||||
|
$codes = array();
|
||||||
|
$currencies = MoneyCurrency::getCurrencies();
|
||||||
|
foreach ($currencies as $key => $item) {
|
||||||
|
// Don't show if already available
|
||||||
|
if (($key != $currency->code) && in_array($key, $current)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$codes[$key] = $key;
|
||||||
|
}
|
||||||
|
|
||||||
|
$item = $currency;
|
||||||
|
|
||||||
|
$html = view('wizard.currencies.edit', compact('item', 'codes'))->render();
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'success' => true,
|
'success' => true,
|
||||||
@ -92,15 +174,21 @@ class Currencies extends Controller
|
|||||||
|
|
||||||
$message = trans('messages.success.updated', ['type' => trans_choice('general.currencies', 1)]);
|
$message = trans('messages.success.updated', ['type' => trans_choice('general.currencies', 1)]);
|
||||||
|
|
||||||
flash($message)->success();
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
return redirect('settings/currencies');
|
'error' => false,
|
||||||
|
'message' => $message,
|
||||||
|
'data' => $currency,
|
||||||
|
]);
|
||||||
} else {
|
} else {
|
||||||
$message = trans('messages.warning.disabled', ['name' => $currency->name, 'text' => implode(', ', $relationships)]);
|
$message = trans('messages.warning.disabled', ['name' => $currency->name, 'text' => implode(', ', $relationships)]);
|
||||||
|
|
||||||
flash($message)->warning();
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
return redirect('settings/currencies/' . $currency->id . '/edit');
|
'error' => false,
|
||||||
|
'message' => $message,
|
||||||
|
'data' => $currency,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
@stack('body_end')
|
@stack('body_end')
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$('#wizard-skip').on('click', function() {
|
$('#wizard-skip, .stepwizard .btn.btn-default').on('click', function() {
|
||||||
$('#wizard-loading').html('<span class="wizard-loading-bar"><span class="wizard-loading-spin"><i class="fa fa-spinner fa-spin"></i></span></span>');
|
$('#wizard-loading').html('<span class="wizard-loading-bar"><span class="wizard-loading-spin"><i class="fa fa-spinner fa-spin"></i></span></span>');
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
30
resources/views/wizard/currencies/create.blade.php
Normal file
30
resources/views/wizard/currencies/create.blade.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<tr id="currency-create">
|
||||||
|
<td>
|
||||||
|
{{ Form::textGroup('name', trans('general.name'), 'id-card-o', ['required' => 'required'], null, '') }}
|
||||||
|
</td>
|
||||||
|
<td class="hidden-xs">
|
||||||
|
{{ Form::selectGroup('code', trans('currencies.code'), 'code', $codes, null, ['required' => 'required'], '') }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ Form::textGroup('rate', trans('currencies.rate'), 'money', ['required' => 'required'], null, '') }}
|
||||||
|
</td>
|
||||||
|
<td class="hidden-xs">
|
||||||
|
{{ Form::radioGroup('enabled', trans('general.enabled'), trans('general.yes'), trans('general.no'), [], 'col-md-12 currency-enabled-radio-group') }}
|
||||||
|
</td>
|
||||||
|
<td class="text-center">
|
||||||
|
{!! Form::button('<span class="fa fa-save"></span>', ['type' => 'button', 'class' => 'btn btn-success currency-submit', 'data-loading-text' => trans('general.loading'), 'data-href' => url('wizard/currencies/'), 'style' => 'padding: 9px 14px; margin-top: 10px;']) !!}
|
||||||
|
</td>
|
||||||
|
<td class="hidden">
|
||||||
|
{{ Form::numberGroup('precision', trans('currencies.precision'), 'bullseye') }}
|
||||||
|
|
||||||
|
{{ Form::textGroup('symbol', trans('currencies.symbol.symbol'), 'font') }}
|
||||||
|
|
||||||
|
{{ Form::selectGroup('symbol_first', trans('currencies.symbol.position'), 'text-width', ['1' => trans('currencies.symbol.before'), '0' => trans('currencies.symbol.after')]) }}
|
||||||
|
|
||||||
|
{{ Form::textGroup('decimal_mark', trans('currencies.decimal_mark'), 'columns') }}
|
||||||
|
|
||||||
|
{{ Form::textGroup('thousands_separator', trans('currencies.thousands_separator'), 'columns', []) }}
|
||||||
|
|
||||||
|
{{ Form::radioGroup('default_currency', trans('currencies.default')) }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
@ -1,38 +1,32 @@
|
|||||||
<tr>
|
<tr id="currency-edit">
|
||||||
<td><a href="javascript:void(0);" data-href="{{ url('wizard/currencies/' . $item->id . '/edit') }}" class="currency-edit">{{ $item->name }}</a></td>
|
<td>
|
||||||
<td class="hidden-xs">{{ $item->code }}</td>
|
{{ Form::textGroup('name', trans('general.name'), 'id-card-o', [], $item->name, '') }}
|
||||||
<td>{{ $item->rate }}</td>
|
</td>
|
||||||
<td class="hidden-xs">
|
<td class="hidden-xs">
|
||||||
@if ($item->enabled)
|
{{ Form::selectGroup('code', trans('currencies.code'), 'code', $codes, $item->code, [], '') }}
|
||||||
<span class="label label-success">{{ trans('general.enabled') }}</span>
|
</td>
|
||||||
@else
|
<td>
|
||||||
<span class="label label-danger">{{ trans('general.disabled') }}</span>
|
{{ Form::textGroup('rate', trans('currencies.rate'), 'money', [], $item->rate, '') }}
|
||||||
@endif
|
</td>
|
||||||
|
<td class="hidden-xs">
|
||||||
|
{{ Form::radioGroup('enabled', trans('general.enabled'), trans('general.yes'), trans('general.no'), [], 'col-md-12') }}
|
||||||
</td>
|
</td>
|
||||||
<td class="text-center">
|
<td class="text-center">
|
||||||
<div class="btn-group">
|
{!! Form::button('<span class="fa fa-save"></span>', ['type' => 'button', 'class' => 'btn btn-success currency-updated', 'data-loading-text' => trans('general.loading'), 'data-href' => url('wizard/currencies/' . $item->id), 'style' => 'padding: 9px 14px; margin-top: 10px;']) !!}
|
||||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" data-toggle-position="left" aria-expanded="false">
|
</td>
|
||||||
<i class="fa fa-ellipsis-h"></i>
|
<td class="hidden">
|
||||||
</button>
|
{{ Form::numberGroup('precision', trans('currencies.precision'), 'bullseye', [], $item->precision) }}
|
||||||
<ul class="dropdown-menu dropdown-menu-right">
|
|
||||||
<li><a href="javascript:void(0);" data-href="{{ url('wizard/currencies/' . $item->id . '/edit') }}" class="currency-edit">{{ trans('general.edit') }}</a></li>
|
{{ Form::textGroup('symbol', trans('currencies.symbol.symbol'), 'font', [], $item->symbol, '') }}
|
||||||
@if ($item->enabled)
|
|
||||||
<li><a href="javascript:void(0);" data-href="{{ url('wizard/currencies/' . $item->id . '/disable') }}" class="currency-disable">{{ trans('general.disable') }}</a></li>
|
{{ Form::selectGroup('symbol_first', trans('currencies.symbol.position'), 'text-width', ['1' => trans('currencies.symbol.before'), '0' => trans('currencies.symbol.after')], $item->symbol_first) }}
|
||||||
@else
|
|
||||||
<li><a href="javascript:void(0);" data-href="{{ url('wizard/currencies/' . $item->id . '/enable') }}" class="currency-enable">{{ trans('general.enable') }}</a></li>
|
{{ Form::textGroup('decimal_mark', trans('currencies.decimal_mark'), 'columns', [], $item->decimal_mark, '') }}
|
||||||
@endif
|
|
||||||
@permission('delete-settings-currencies')
|
{{ Form::textGroup('thousands_separator', trans('currencies.thousands_separator'), 'columns', [], $item->thousands_separator) }}
|
||||||
<li class="divider"></li>
|
|
||||||
<li>
|
{{ Form::radioGroup('default_currency', trans('currencies.default')) }}
|
||||||
{!! Form::button(trans('general.delete'), array(
|
|
||||||
'type' => 'button',
|
{{ Form::hidden('id', $item->id) }}
|
||||||
'class' => 'delete-link',
|
|
||||||
'title' => trans('general.delete'),
|
|
||||||
'onclick' => 'confirmDelete("' . '#currencies-' . $item->id . '", "' . trans_choice('general.currencies', 2) . '", "' . trans('general.delete_confirm', ['name' => '<strong>' . $item->name . '</strong>', 'type' => mb_strtolower(trans_choice('general.currencies', 1))]) . '", "' . trans('general.cancel') . '", "' . trans('general.delete') . '")'
|
|
||||||
)) !!}
|
|
||||||
</li>
|
|
||||||
@endpermission
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
<h3 class="box-title">{{ trans_choice('general.currencies', 1) }}</h3>
|
<h3 class="box-title">{{ trans_choice('general.currencies', 1) }}</h3>
|
||||||
<span class="new-button"><a href="{{ url('settings/currencies/create') }}" class="btn btn-success btn-sm"><span class="fa fa-plus"></span> {{ trans('general.add_new') }}</a></span>
|
<span class="new-button"><a href="javascript:void(0);" data-href="{{ url('wizard/currencies/create') }}" class="btn btn-success btn-sm currency-create"><span class="fa fa-plus"></span> {{ trans('general.add_new') }}</a></span>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.box-header -->
|
<!-- /.box-header -->
|
||||||
|
|
||||||
@ -43,17 +43,17 @@
|
|||||||
<table class="table table-striped table-hover" id="tbl-currencies">
|
<table class="table table-striped table-hover" id="tbl-currencies">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="col-md-5">@sortablelink('name', trans('general.name'))</th>
|
<th class="col-md-4">@sortablelink('name', trans('general.name'))</th>
|
||||||
<th class="col-md-3 hidden-xs">@sortablelink('code', trans('currencies.code'))</th>
|
<th class="col-md-3 hidden-xs">@sortablelink('code', trans('currencies.code'))</th>
|
||||||
<th class="col-md-2">@sortablelink('rate', trans('currencies.rate'))</th>
|
<th class="col-md-2">@sortablelink('rate', trans('currencies.rate'))</th>
|
||||||
<th class="col-md-1 hidden-xs">@sortablelink('enabled', trans_choice('general.statuses', 1))</th>
|
<th class="col-md-2 hidden-xs">@sortablelink('enabled', trans_choice('general.statuses', 1))</th>
|
||||||
<th class="col-md-1 text-center">{{ trans('general.actions') }}</th>
|
<th class="col-md-1 text-center">{{ trans('general.actions') }}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@foreach($currencies as $item)
|
@foreach($currencies as $item)
|
||||||
<tr id="currency-{{ $item->id }}" data-href="{{ url('wizard/currencies/' . $item->id . '/delete') }}">
|
<tr id="currency-{{ $item->id }}" data-href="{{ url('wizard/currencies/' . $item->id . '/delete') }}">
|
||||||
<td class="currency-name"><a href="javascript:void(0);" data-href="{{ url('wizard/currencies/' . $item->id . '/edit') }}" class="currency-edit">{{ $item->name }}</a></td>
|
<td class="currency-name"><a href="javascript:void(0);" data-id="{{ $item->id }}" data-href="{{ url('wizard/currencies/' . $item->id . '/edit') }}" class="currency-edit">{{ $item->name }}</a></td>
|
||||||
<td class="currency-code hidden-xs">{{ $item->code }}</td>
|
<td class="currency-code hidden-xs">{{ $item->code }}</td>
|
||||||
<td class="currency-rate">{{ $item->rate }}</td>
|
<td class="currency-rate">{{ $item->rate }}</td>
|
||||||
<td class="currency-status hidden-xs">
|
<td class="currency-status hidden-xs">
|
||||||
@ -69,7 +69,7 @@
|
|||||||
<i class="fa fa-ellipsis-h"></i>
|
<i class="fa fa-ellipsis-h"></i>
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu dropdown-menu-right">
|
<ul class="dropdown-menu dropdown-menu-right">
|
||||||
<li><a href="javascript:void(0);" data-href="{{ url('wizard/currencies/' . $item->id . '/edit') }}" class="currency-edit">{{ trans('general.edit') }}</a></li>
|
<li><a href="javascript:void(0);" data-id="{{ $item->id }}" data-href="{{ url('wizard/currencies/' . $item->id . '/edit') }}" class="currency-edit">{{ trans('general.edit') }}</a></li>
|
||||||
@if ($item->enabled)
|
@if ($item->enabled)
|
||||||
<li><a href="javascript:void(0);" data-href="{{ url('wizard/currencies/' . $item->id . '/disable') }}" class="currency-disable">{{ trans('general.disable') }}</a></li>
|
<li><a href="javascript:void(0);" data-href="{{ url('wizard/currencies/' . $item->id . '/disable') }}" class="currency-disable">{{ trans('general.disable') }}</a></li>
|
||||||
@else
|
@else
|
||||||
@ -110,7 +110,13 @@
|
|||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).on('click', '.currency-edit', function (e) {
|
var text_yes = '{{ trans('general.yes') }}';
|
||||||
|
var text_no = '{{ trans('general.no') }}';
|
||||||
|
|
||||||
|
$(document).on('click', '.currency-create', function (e) {
|
||||||
|
$('#currency-create').remove();
|
||||||
|
$('#currency-edit').remove();
|
||||||
|
|
||||||
data_href = $(this).data('href');
|
data_href = $(this).data('href');
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -119,7 +125,153 @@
|
|||||||
dataType: 'JSON',
|
dataType: 'JSON',
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
if (json['success']) {
|
if (json['success']) {
|
||||||
$('body').append(json['html']);
|
$('#tbl-currencies tbody').append(json['html']);
|
||||||
|
|
||||||
|
$("#code").select2({
|
||||||
|
placeholder: "{{ trans('general.form.select.field', ['field' => trans('currencies.code')]) }}"
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.currency-enabled-radio-group #enabled_1').trigger('click');
|
||||||
|
|
||||||
|
$('#name').focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '.currency-submit', function (e) {
|
||||||
|
$(this).html('<span class="fa fa-spinner fa-pulse"></span>');
|
||||||
|
$('.help-block').remove();
|
||||||
|
|
||||||
|
data_href = $(this).data('href');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '{{ url("wizard/currencies") }}',
|
||||||
|
type: 'POST',
|
||||||
|
dataType: 'JSON',
|
||||||
|
data: $('#tbl-currencies input[type=\'number\'], #tbl-currencies input[type=\'text\'], #tbl-currencies input[type=\'number\'], #tbl-currencies input[type=\'hidden\'], #tbl-currencies textarea, #tbl-currencies select').serialize(),
|
||||||
|
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
||||||
|
success: function(json) {
|
||||||
|
$('.currency-submit').html('<span class="fa fa-save"></span>');
|
||||||
|
|
||||||
|
if (json['success']) {
|
||||||
|
currency = json['data'];
|
||||||
|
$('#currency-create').remove();
|
||||||
|
$('#currency-edit').remove();
|
||||||
|
|
||||||
|
html = '<tr id="currency-' + currency.id + '" data-href="wizard/currencies/' + currency.id + '/delete">';
|
||||||
|
html += ' <td class="currency-name">';
|
||||||
|
html += ' <a href="javascript:void(0);" data-id="' + currency.id + '" data-href="wizard/currencies/' + currency.id + '/edit" class="currency-edit">' + currency.name + '</a>';
|
||||||
|
html += ' </td>';
|
||||||
|
html += ' <td class="currency-code hidden-xs">' + currency.code + '</td>';
|
||||||
|
html += ' <td class="currency-rate">' + currency.rate + '</td>';
|
||||||
|
html += ' <td class="currency-status hidden-xs">';
|
||||||
|
html += ' <span class="label label-success">Enabled</span>';
|
||||||
|
html += ' </td>';
|
||||||
|
html += ' <td class="currency-action text-center">';
|
||||||
|
html += ' <div class="btn-group">';
|
||||||
|
html += ' <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" data-toggle-position="left" aria-expanded="false">';
|
||||||
|
html += ' <i class="fa fa-ellipsis-h"></i>';
|
||||||
|
html += ' </button>';
|
||||||
|
html += ' <ul class="dropdown-menu dropdown-menu-right">';
|
||||||
|
html += ' <li><a href="javascript:void(0);" data-id="' + currency.id + '" data-href="wizard/currencies/' + currency.id + '/edit" class="currency-edit">{{ trans('general.edit') }}</a></li>';
|
||||||
|
html += ' <li><a href="javascript:void(0);" data-href="wizard/currencies/' + currency.id + '/disable" class="currency-disable">{{ trans('general.disable') }}</a></li>';
|
||||||
|
html += ' <li class="divider"></li>';
|
||||||
|
html += ' <li>';
|
||||||
|
html += ' <button type="button" class="delete-link" title="{{ trans('general.delete') }}" onclick="confirmCurrency("#currency-' + currency.id + '", "{{ trans_choice('general.currencies', 2) }}", "{{ trans('general.delete_confirm', ['name' => '<strong>' . $item->name . '</strong>', 'type' => mb_strtolower(trans_choice('general.currencies', 1))]) }}", "{{ trans('general.cancel') }}", "{{ trans('general.delete') }}")">{{ trans('general.delete') }}</button>';
|
||||||
|
html += ' </li>';
|
||||||
|
html += ' </ul>';
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' </td>';
|
||||||
|
html += '</tr>';
|
||||||
|
|
||||||
|
$('#tbl-currencies tbody').append(html);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(data){
|
||||||
|
$('.currency-submit').html('<span class="fa fa-save"></span>');
|
||||||
|
|
||||||
|
var errors = data.responseJSON;
|
||||||
|
|
||||||
|
if (typeof errors !== 'undefined') {
|
||||||
|
if (errors.name) {
|
||||||
|
$('#tbl-currencies #name').parent().after('<p class="help-block" style="color: #ca1313;">' + errors.name + '</p>');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errors.code) {
|
||||||
|
$('#tbl-currencies #code').parent().after('<p class="help-block" style="color: #ca1313;">' + errors.code + '</p>');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errors.rate) {
|
||||||
|
$('#tbl-currencies #rate').parent().after('<p class="help-block" style="color: #ca1313;">' + errors.rate + '</p>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '.currency-edit', function (e) {
|
||||||
|
$('#currency-create').remove();
|
||||||
|
$('#currency-edit').remove();
|
||||||
|
|
||||||
|
data_href = $(this).data('href');
|
||||||
|
data_id = $(this).data('id');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: data_href,
|
||||||
|
type: 'GET',
|
||||||
|
dataType: 'JSON',
|
||||||
|
success: function(json) {
|
||||||
|
if (json['success']) {
|
||||||
|
$('#currency-' + data_id).after(json['html']);
|
||||||
|
|
||||||
|
$("#code").select2({
|
||||||
|
placeholder: "{{ trans('general.form.select.field', ['field' => trans('currencies.code')]) }}"
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.currency-enabled-radio-group #enabled_1').trigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '.currency-updated', function (e) {
|
||||||
|
$(this).html('<span class="fa fa-spinner fa-pulse"></span>');
|
||||||
|
$('.help-block').remove();
|
||||||
|
|
||||||
|
data_href = $(this).data('href');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: data_href,
|
||||||
|
type: 'PATCH',
|
||||||
|
dataType: 'JSON',
|
||||||
|
data: $('#tbl-currencies input[type=\'number\'], #tbl-currencies input[type=\'text\'], #tbl-currencies input[type=\'number\'], #tbl-currencies input[type=\'hidden\'], #tbl-currencies textarea, #tbl-currencies select').serialize(),
|
||||||
|
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
||||||
|
success: function(json) {
|
||||||
|
$('.currency-updated').html('<span class="fa fa-save"></span>');
|
||||||
|
|
||||||
|
if (json['success']) {
|
||||||
|
$('#currency-create').remove();
|
||||||
|
$('#currency-edit').remove();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(data){
|
||||||
|
$('.currency-updated').html('<span class="fa fa-save"></span>');
|
||||||
|
|
||||||
|
var errors = data.responseJSON;
|
||||||
|
|
||||||
|
if (typeof errors !== 'undefined') {
|
||||||
|
if (errors.name) {
|
||||||
|
$('#tbl-currencies #name').parent().after('<p class="help-block" style="color: #ca1313;">' + errors.name + '</p>');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errors.code) {
|
||||||
|
$('#tbl-currencies #code').parent().after('<p class="help-block" style="color: #ca1313;">' + errors.code + '</p>');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errors.rate) {
|
||||||
|
$('#tbl-currencies #rate').parent().after('<p class="help-block" style="color: #ca1313;">' + errors.rate + '</p>');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -159,6 +311,25 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(document).on('change', '#code', function (e) {
|
||||||
|
$.ajax({
|
||||||
|
url: '{{ url("settings/currencies/config") }}',
|
||||||
|
type: 'GET',
|
||||||
|
dataType: 'JSON',
|
||||||
|
data: 'code=' + $(this).val(),
|
||||||
|
success: function(data) {
|
||||||
|
$('#precision').val(data.precision);
|
||||||
|
$('#symbol').val(data.symbol);
|
||||||
|
$('#symbol_first').val(data.symbol_first);
|
||||||
|
$('#decimal_mark').val(data.decimal_mark);
|
||||||
|
$('#thousands_separator').val(data.thousands_separator);
|
||||||
|
|
||||||
|
// This event Select2 Stylesheet
|
||||||
|
$('#symbol_first').trigger('change');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function confirmCurrency(tr_id, title, message, button_cancel, button_delete) {
|
function confirmCurrency(tr_id, title, message, button_cancel, button_delete) {
|
||||||
$('#confirm-modal').remove();
|
$('#confirm-modal').remove();
|
||||||
|
|
||||||
|
@ -14,18 +14,22 @@ Route::group(['middleware' => 'language'], function () {
|
|||||||
Route::patch('companies', 'Wizard\Companies@update')->name('wizard.companies.update');
|
Route::patch('companies', 'Wizard\Companies@update')->name('wizard.companies.update');
|
||||||
|
|
||||||
Route::get('currencies', 'Wizard\Currencies@index')->name('wizard.currencies.index');
|
Route::get('currencies', 'Wizard\Currencies@index')->name('wizard.currencies.index');
|
||||||
|
Route::get('currencies/create', 'Wizard\Currencies@create')->name('wizard.currencies.create');
|
||||||
Route::get('currencies/{currency}/edit', 'Wizard\Currencies@edit')->name('wizard.currencies.edit');
|
Route::get('currencies/{currency}/edit', 'Wizard\Currencies@edit')->name('wizard.currencies.edit');
|
||||||
Route::get('currencies/{currency}/enable', 'Wizard\Currencies@enable')->name('wizard.currencies.enable');
|
Route::get('currencies/{currency}/enable', 'Wizard\Currencies@enable')->name('wizard.currencies.enable');
|
||||||
Route::get('currencies/{currency}/disable', 'Wizard\Currencies@disable')->name('wizard.currencies.disable');
|
Route::get('currencies/{currency}/disable', 'Wizard\Currencies@disable')->name('wizard.currencies.disable');
|
||||||
Route::get('currencies/{currency}/delete', 'Wizard\Currencies@destroy')->name('wizard.currencies.delete');
|
Route::get('currencies/{currency}/delete', 'Wizard\Currencies@destroy')->name('wizard.currencies.delete');
|
||||||
Route::post('currencies/{currency}', 'Wizard\Currencies@update')->name('wizard.currencies.index');
|
Route::post('currencies', 'Wizard\Currencies@store')->name('wizard.currencies.store');
|
||||||
|
Route::patch('currencies/{currency}', 'Wizard\Currencies@update')->name('wizard.currencies.update');
|
||||||
|
|
||||||
Route::get('taxes', 'Wizard\Taxes@index')->name('wizard.taxes.index');
|
Route::get('taxes', 'Wizard\Taxes@index')->name('wizard.taxes.index');
|
||||||
|
Route::get('taxes/create', 'Wizard\Taxes@create')->name('wizard.taxes.create');
|
||||||
Route::get('taxes/{tax}/edit', 'Wizard\Taxes@edit')->name('wizard.taxes.edit');
|
Route::get('taxes/{tax}/edit', 'Wizard\Taxes@edit')->name('wizard.taxes.edit');
|
||||||
Route::get('taxes/{tax}/enable', 'Wizard\Taxes@enable')->name('wizard.taxes.enable');
|
Route::get('taxes/{tax}/enable', 'Wizard\Taxes@enable')->name('wizard.taxes.enable');
|
||||||
Route::get('taxes/{tax}/disable', 'Wizard\Taxes@disable')->name('wizard.taxes.disable');
|
Route::get('taxes/{tax}/disable', 'Wizard\Taxes@disable')->name('wizard.taxes.disable');
|
||||||
Route::get('taxes/{tax}/delete', 'Wizard\Taxes@destroy')->name('wizard.taxes.delete');
|
Route::get('taxes/{tax}/delete', 'Wizard\Taxes@destroy')->name('wizard.taxes.delete');
|
||||||
Route::post('taxes/{tax}', 'Wizard\Taxes@update')->name('wizard.taxes.index');
|
Route::post('taxes', 'Wizard\Taxes@store')->name('wizard.taxes.store');
|
||||||
|
Route::patch('taxes/{tax}', 'Wizard\Taxes@update')->name('wizard.taxes.upadate');
|
||||||
|
|
||||||
Route::get('finish', 'Wizard\Finish@index')->name('wizard.finish.index');
|
Route::get('finish', 'Wizard\Finish@index')->name('wizard.finish.index');
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user