Wizard Taxes step finish
This commit is contained in:
parent
5f00757142
commit
618ff1ccc8
@ -35,6 +35,10 @@ class Currencies extends Controller
|
|||||||
*/
|
*/
|
||||||
public function create()
|
public function create()
|
||||||
{
|
{
|
||||||
|
if (setting(setting('general.wizard', false))) {
|
||||||
|
return redirect('/');
|
||||||
|
}
|
||||||
|
|
||||||
// Get current currencies
|
// Get current currencies
|
||||||
$current = Currency::pluck('code')->toArray();
|
$current = Currency::pluck('code')->toArray();
|
||||||
|
|
||||||
|
@ -11,8 +11,6 @@ class Taxes extends Controller
|
|||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
* @param Tax $tax
|
|
||||||
*
|
|
||||||
* @return Response
|
* @return Response
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
@ -26,6 +24,48 @@ class Taxes extends Controller
|
|||||||
return view('wizard.taxes.index', compact('taxes'));
|
return view('wizard.taxes.index', compact('taxes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form for creating a new resource.
|
||||||
|
*
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
if (setting(setting('general.wizard', false))) {
|
||||||
|
return redirect('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
$html = view('wizard.taxes.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)
|
||||||
|
{
|
||||||
|
$tax = Tax::create($request->all());
|
||||||
|
|
||||||
|
$message = trans('messages.success.added', ['type' => trans_choice('general.tax_rates', 1)]);
|
||||||
|
|
||||||
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
|
'error' => false,
|
||||||
|
'message' => $message,
|
||||||
|
'data' => $tax,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Show the form for editing the specified resource.
|
* Show the form for editing the specified resource.
|
||||||
*
|
*
|
||||||
@ -39,9 +79,9 @@ class Taxes extends Controller
|
|||||||
return redirect('/');
|
return redirect('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
$taxes = Tax::all();
|
$item = $tax;
|
||||||
|
|
||||||
return view('wizard.taxes.edit', compact('taxes'));
|
return view('wizard.taxes.edit', compact('item'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,15 +105,21 @@ class Taxes extends Controller
|
|||||||
|
|
||||||
$message = trans('messages.success.updated', ['type' => trans_choice('general.tax_rates', 1)]);
|
$message = trans('messages.success.updated', ['type' => trans_choice('general.tax_rates', 1)]);
|
||||||
|
|
||||||
flash($message)->success();
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
return redirect('settings/taxes');
|
'error' => false,
|
||||||
|
'message' => $message,
|
||||||
|
'data' => $tax,
|
||||||
|
]);
|
||||||
} else {
|
} else {
|
||||||
$message = trans('messages.warning.disabled', ['name' => $tax->name, 'text' => implode(', ', $relationships)]);
|
$message = trans('messages.warning.disabled', ['name' => $tax->name, 'text' => implode(', ', $relationships)]);
|
||||||
|
|
||||||
flash($message)->warning();
|
return response()->json([
|
||||||
|
'success' => true,
|
||||||
return redirect('settings/taxes/' . $tax->id . '/edit');
|
'error' => false,
|
||||||
|
'message' => $message,
|
||||||
|
'data' => $tax,
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@
|
|||||||
url: '{{ url("wizard/currencies") }}',
|
url: '{{ url("wizard/currencies") }}',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
dataType: 'JSON',
|
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(),
|
data: $('#tbl-currencies input[type=\'number\'], #tbl-currencies input[type=\'text\'], #tbl-currencies input[type=\'radio\'], #tbl-currencies input[type=\'hidden\'], #tbl-currencies textarea, #tbl-currencies select').serialize(),
|
||||||
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
$('.currency-submit').html('<span class="fa fa-save"></span>');
|
$('.currency-submit').html('<span class="fa fa-save"></span>');
|
||||||
@ -245,7 +245,7 @@
|
|||||||
url: data_href,
|
url: data_href,
|
||||||
type: 'PATCH',
|
type: 'PATCH',
|
||||||
dataType: 'JSON',
|
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(),
|
data: $('#tbl-currencies input[type=\'number\'], #tbl-currencies input[type=\'text\'], #tbl-currencies input[type=\'radio\'], #tbl-currencies input[type=\'hidden\'], #tbl-currencies textarea, #tbl-currencies select').serialize(),
|
||||||
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
$('.currency-updated').html('<span class="fa fa-save"></span>');
|
$('.currency-updated').html('<span class="fa fa-save"></span>');
|
||||||
|
14
resources/views/wizard/taxes/create.blade.php
Normal file
14
resources/views/wizard/taxes/create.blade.php
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<tr id="tax-create">
|
||||||
|
<td>
|
||||||
|
{{ Form::textGroup('name', trans('general.name'), 'id-card-o', ['required' => 'required'], null, '') }}
|
||||||
|
</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 tax-enabled-radio-group') }}
|
||||||
|
</td>
|
||||||
|
<td class="text-center">
|
||||||
|
{!! Form::button('<span class="fa fa-save"></span>', ['type' => 'button', 'class' => 'btn btn-success tax-submit', 'data-loading-text' => trans('general.loading'), 'data-href' => url('wizard/taxes'), 'style' => 'padding: 9px 14px; margin-top: 10px;']) !!}
|
||||||
|
</td>
|
||||||
|
</tr>
|
@ -1,115 +1,14 @@
|
|||||||
@extends('layouts.wizard')
|
<tr id="tax-edit">
|
||||||
|
<td>
|
||||||
@section('title', trans('general.wizard'))
|
{{ Form::textGroup('name', trans('general.name'), 'id-card-o', ['required' => 'required'], $item->name, '') }}
|
||||||
|
</td>
|
||||||
@section('content')
|
<td>
|
||||||
<!-- Default box -->
|
{{ Form::textGroup('rate', trans('currencies.rate'), 'money', ['required' => 'required'], $item->rate, '') }}
|
||||||
<div class="box box-solid">
|
</td>
|
||||||
<div class="box-body">
|
<td class="hidden-xs">
|
||||||
<div class="stepwizard">
|
{{ Form::radioGroup('enabled', trans('general.enabled'), trans('general.yes'), trans('general.no'), [], 'col-md-12') }}
|
||||||
<div class="stepwizard-row setup-panel">
|
</td>
|
||||||
<div class="stepwizard-step col-xs-3">
|
<td class="text-center">
|
||||||
<a href="{{ url('wizard/companies') }}" type="button" class="btn btn-default btn-circle">1</a>
|
{!! Form::button('<span class="fa fa-save"></span>', ['type' => 'button', 'class' => 'btn btn-success tax-updated', 'data-loading-text' => trans('general.loading'), 'data-href' => url('wizard/taxes/' . $item->id), 'style' => 'padding: 9px 14px; margin-top: 10px;']) !!}
|
||||||
<p><small>{{ trans_choice('general.companies', 1) }}</small></p>
|
</td>
|
||||||
</div>
|
</tr>
|
||||||
<div class="stepwizard-step col-xs-3">
|
|
||||||
<a href="{{ url('wizard/currencies') }}" type="button" class="btn btn-default btn-circle">2</a>
|
|
||||||
<p><small>{{ trans_choice('general.currencies', 2) }}</small></p>
|
|
||||||
</div>
|
|
||||||
<div class="stepwizard-step col-xs-3">
|
|
||||||
<a href="#step-3" type="button" class="btn btn-success btn-circle">3</a>
|
|
||||||
<p><small>{{ trans_choice('general.taxes', 2) }}</small></p>
|
|
||||||
</div>
|
|
||||||
<div class="stepwizard-step col-xs-3">
|
|
||||||
<button type="button" class="btn btn-default btn-circle" disabled="disabled">4</button>
|
|
||||||
<p><small>{{ trans_choice('general.finish', 1) }}</small></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="box box-success">
|
|
||||||
<div class="box-header with-border">
|
|
||||||
<h3 class="box-title">{{ trans_choice('general.taxes', 1) }}</h3>
|
|
||||||
</div>
|
|
||||||
<!-- /.box-header -->
|
|
||||||
|
|
||||||
<div class="box-body">
|
|
||||||
<div class="table table-responsive">
|
|
||||||
<table class="table table-striped table-hover" id="tbl-taxes">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th class="col-md-5">@sortablelink('name', trans('general.name'))</th>
|
|
||||||
<th class="col-md-5">@sortablelink('rate', trans('taxes.rate_percent'))</th>
|
|
||||||
<th class="col-md-1 hidden-xs">@sortablelink('enabled', trans_choice('general.statuses', 1))</th>
|
|
||||||
<th class="col-md-1 text-center">{{ trans('general.actions') }}</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach($taxes as $item)
|
|
||||||
<tr>
|
|
||||||
<td><a href="{{ url('settings/taxes/' . $item->id . '/edit') }}">{{ $item->name }}</a></td>
|
|
||||||
<td>{{ $item->rate }}</td>
|
|
||||||
<td class="hidden-xs">
|
|
||||||
@if ($item->enabled)
|
|
||||||
<span class="label label-success">{{ trans('general.enabled') }}</span>
|
|
||||||
@else
|
|
||||||
<span class="label label-danger">{{ trans('general.disabled') }}</span>
|
|
||||||
@endif
|
|
||||||
</td>
|
|
||||||
<td class="text-center">
|
|
||||||
<div class="btn-group">
|
|
||||||
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" data-toggle-position="left" aria-expanded="false">
|
|
||||||
<i class="fa fa-ellipsis-h"></i>
|
|
||||||
</button>
|
|
||||||
<ul class="dropdown-menu dropdown-menu-right">
|
|
||||||
<li><a href="{{ url('settings/taxes/' . $item->id . '/edit') }}">{{ trans('general.edit') }}</a></li>
|
|
||||||
@if ($item->enabled)
|
|
||||||
<li><a href="{{ route('taxes.disable', $item->id) }}">{{ trans('general.disable') }}</a></li>
|
|
||||||
@else
|
|
||||||
<li><a href="{{ route('taxes.enable', $item->id) }}">{{ trans('general.enable') }}</a></li>
|
|
||||||
@endif
|
|
||||||
@permission('delete-settings-taxes')
|
|
||||||
<li class="divider"></li>
|
|
||||||
<li>{!! Form::deleteLink($item, 'settings/taxes', 'tax_rates') !!}</li>
|
|
||||||
@endpermission
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
@endforeach
|
|
||||||
<tr>
|
|
||||||
<td colspan="4" class="text-right">
|
|
||||||
<span class="new-button"><a href="{{ url('settings/taxes/create') }}" class="btn btn-success btn-sm"><span class="fa fa-plus"></span> {{ trans('general.add_new') }}</a></span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- /.box-body -->
|
|
||||||
|
|
||||||
<div class="box-footer">
|
|
||||||
<div class="col-md-12">
|
|
||||||
<div class="form-group no-margin">
|
|
||||||
{!! Form::button('<span class="fa fa-save"></span> ' . trans('general.save'), ['type' => 'submit', 'class' => 'btn btn-success button-submit', 'data-loading-text' => trans('general.loading')]) !!}
|
|
||||||
<a href="{{ url('wizard/skip') }}" class="btn btn-default"><span class="fa fa-share"></span> {{ trans('general.skip') }}</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- /.box-footer -->
|
|
||||||
|
|
||||||
</div>
|
|
||||||
@endsection
|
|
||||||
|
|
||||||
@push('scripts')
|
|
||||||
<script type="text/javascript">
|
|
||||||
var text_yes = '{{ trans('general.yes') }}';
|
|
||||||
var text_no = '{{ trans('general.no') }}';
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
|
||||||
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
@endpush
|
|
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
<h3 class="box-title">{{ trans_choice('general.taxes', 1) }}</h3>
|
<h3 class="box-title">{{ trans_choice('general.taxes', 1) }}</h3>
|
||||||
<span class="new-button"><a href="{{ url('settings/taxes/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/taxes/create') }}" class="btn btn-success btn-sm tax-create"><span class="fa fa-plus"></span> {{ trans('general.add_new') }}</a></span>
|
||||||
</div>
|
</div>
|
||||||
<!-- /.box-header -->
|
<!-- /.box-header -->
|
||||||
|
|
||||||
@ -44,15 +44,15 @@
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="col-md-5">@sortablelink('name', trans('general.name'))</th>
|
<th class="col-md-5">@sortablelink('name', trans('general.name'))</th>
|
||||||
<th class="col-md-5">@sortablelink('rate', trans('taxes.rate_percent'))</th>
|
<th class="col-md-4">@sortablelink('rate', trans('taxes.rate_percent'))</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($taxes as $item)
|
@foreach($taxes as $item)
|
||||||
<tr id="tax-{{ $item->id }}" data-href="{{ url('wizard/taxes/' . $item->id . '/delete') }}">
|
<tr id="tax-{{ $item->id }}" data-href="{{ url('wizard/taxes/' . $item->id . '/delete') }}">
|
||||||
<td class="tax-name"><a href="javascript:void(0);" data-href="{{ url('wizard/taxes/' . $item->id . '/edit') }}" class="tax-edit">{{ $item->name }}</a></td>
|
<td class="tax-name"><a href="javascript:void(0);" data-id="{{ $item->id }}" data-href="{{ url('wizard/taxes/' . $item->id . '/edit') }}" class="tax-edit">{{ $item->name }}</a></td>
|
||||||
<td class="tax-rate">{{ $item->rate }}</td>
|
<td class="tax-rate">{{ $item->rate }}</td>
|
||||||
<td class="tax-status hidden-xs">
|
<td class="tax-status hidden-xs">
|
||||||
@if ($item->enabled)
|
@if ($item->enabled)
|
||||||
@ -109,7 +109,13 @@
|
|||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).on('click', '.tax-edit', function (e) {
|
var text_yes = '{{ trans('general.yes') }}';
|
||||||
|
var text_no = '{{ trans('general.no') }}';
|
||||||
|
|
||||||
|
$(document).on('click', '.tax-create', function (e) {
|
||||||
|
$('#tax-create').remove();
|
||||||
|
$('#tax-edit').remove();
|
||||||
|
|
||||||
data_href = $(this).data('href');
|
data_href = $(this).data('href');
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -118,7 +124,152 @@
|
|||||||
dataType: 'JSON',
|
dataType: 'JSON',
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
if (json['success']) {
|
if (json['success']) {
|
||||||
$('body').append(json['html']);
|
$('#tbl-taxes tbody').append(json['html']);
|
||||||
|
|
||||||
|
$("#code").select2({
|
||||||
|
placeholder: "{{ trans('general.form.select.field', ['field' => trans('taxes.code')]) }}"
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.tax-enabled-radio-group #enabled_1').trigger('click');
|
||||||
|
|
||||||
|
$('#name').focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '.tax-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/taxes") }}',
|
||||||
|
type: 'POST',
|
||||||
|
dataType: 'JSON',
|
||||||
|
data: $('#tbl-taxes input[type=\'number\'], #tbl-taxes input[type=\'text\'], #tbl-taxes input[type=\'radio\'], #tbl-taxes input[type=\'hidden\'], #tbl-taxes textarea, #tbl-taxes select').serialize(),
|
||||||
|
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
||||||
|
success: function(json) {
|
||||||
|
$('.tax-submit').html('<span class="fa fa-save"></span>');
|
||||||
|
|
||||||
|
if (json['success']) {
|
||||||
|
tax = json['data'];
|
||||||
|
$('#tax-create').remove();
|
||||||
|
$('#tax-edit').remove();
|
||||||
|
|
||||||
|
html = '<tr id="tax-' + tax.id + '" data-href="wizard/taxes/' + tax.id + '/delete">';
|
||||||
|
html += ' <td class="tax-name">';
|
||||||
|
html += ' <a href="javascript:void(0);" data-id="' + tax.id + '" data-href="wizard/taxes/' + tax.id + '/edit" class="tax-edit">' + tax.name + '</a>';
|
||||||
|
html += ' </td>';
|
||||||
|
html += ' <td class="tax-rate">' + tax.rate + '</td>';
|
||||||
|
html += ' <td class="tax-status hidden-xs">';
|
||||||
|
html += ' <span class="label label-success">Enabled</span>';
|
||||||
|
html += ' </td>';
|
||||||
|
html += ' <td class="tax-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="' + tax.id + '" data-href="wizard/taxes/' + tax.id + '/edit" class="tax-edit">{{ trans('general.edit') }}</a></li>';
|
||||||
|
html += ' <li><a href="javascript:void(0);" data-href="wizard/taxes/' + tax.id + '/disable" class="tax-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("#tax-' + tax.id + '", "{{ trans_choice('general.taxes', 2) }}", "{{ trans('general.delete_confirm', ['name' => '<strong>' . $item->name . '</strong>', 'type' => mb_strtolower(trans_choice('general.taxes', 1))]) }}", "{{ trans('general.cancel') }}", "{{ trans('general.delete') }}")">{{ trans('general.delete') }}</button>';
|
||||||
|
html += ' </li>';
|
||||||
|
html += ' </ul>';
|
||||||
|
html += ' </div>';
|
||||||
|
html += ' </td>';
|
||||||
|
html += '</tr>';
|
||||||
|
|
||||||
|
$('#tbl-taxes tbody').append(html);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(data){
|
||||||
|
$('.tax-submit').html('<span class="fa fa-save"></span>');
|
||||||
|
|
||||||
|
var errors = data.responseJSON;
|
||||||
|
|
||||||
|
if (typeof errors !== 'undefined') {
|
||||||
|
if (errors.name) {
|
||||||
|
$('#tbl-taxes #name').parent().after('<p class="help-block" style="color: #ca1313;">' + errors.name + '</p>');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errors.code) {
|
||||||
|
$('#tbl-taxes #code').parent().after('<p class="help-block" style="color: #ca1313;">' + errors.code + '</p>');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errors.rate) {
|
||||||
|
$('#tbl-taxes #rate').parent().after('<p class="help-block" style="color: #ca1313;">' + errors.rate + '</p>');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '.tax-edit', function (e) {
|
||||||
|
$('#tax-create').remove();
|
||||||
|
$('#tax-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']) {
|
||||||
|
$('#tax-' + data_id).after(json['html']);
|
||||||
|
|
||||||
|
$("#code").select2({
|
||||||
|
placeholder: "{{ trans('general.form.select.field', ['field' => trans('taxes.code')]) }}"
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.tax-enabled-radio-group #enabled_1').trigger();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).on('click', '.tax-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-taxes input[type=\'number\'], #tbl-taxes input[type=\'text\'], #tbl-taxes input[type=\'radio\'], #tbl-taxes input[type=\'hidden\'], #tbl-taxes textarea, #tbl-taxes select').serialize(),
|
||||||
|
headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' },
|
||||||
|
success: function(json) {
|
||||||
|
$('.tax-updated').html('<span class="fa fa-save"></span>');
|
||||||
|
|
||||||
|
if (json['success']) {
|
||||||
|
$('#tax-create').remove();
|
||||||
|
$('#tax-edit').remove();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(data){
|
||||||
|
$('.tax-updated').html('<span class="fa fa-save"></span>');
|
||||||
|
|
||||||
|
var errors = data.responseJSON;
|
||||||
|
|
||||||
|
if (typeof errors !== 'undefined') {
|
||||||
|
if (errors.name) {
|
||||||
|
$('#tbl-taxes #name').parent().after('<p class="help-block" style="color: #ca1313;">' + errors.name + '</p>');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errors.code) {
|
||||||
|
$('#tbl-taxes #code').parent().after('<p class="help-block" style="color: #ca1313;">' + errors.code + '</p>');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errors.rate) {
|
||||||
|
$('#tbl-taxes #rate').parent().after('<p class="help-block" style="color: #ca1313;">' + errors.rate + '</p>');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -158,7 +309,26 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function confirmTax(tr_id, title, message, button_cancel, button_delete) {
|
$(document).on('change', '#code', function (e) {
|
||||||
|
$.ajax({
|
||||||
|
url: '{{ url("settings/taxes/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) {
|
||||||
$('#confirm-modal').remove();
|
$('#confirm-modal').remove();
|
||||||
|
|
||||||
var html = '';
|
var html = '';
|
||||||
@ -176,7 +346,7 @@
|
|||||||
html += ' </div>';
|
html += ' </div>';
|
||||||
html += ' <div class="modal-footer">';
|
html += ' <div class="modal-footer">';
|
||||||
html += ' <div class="pull-left">';
|
html += ' <div class="pull-left">';
|
||||||
html += ' <button type="button" class="btn btn-danger" onclick="deleteTax(\'' + tr_id + '\');">' + button_delete + '</button>';
|
html += ' <button type="button" class="btn btn-danger" onclick="deleteCurrency(\'' + tr_id + '\');">' + button_delete + '</button>';
|
||||||
html += ' <button type="button" class="btn btn-default" data-dismiss="modal">' + button_cancel + '</button>';
|
html += ' <button type="button" class="btn btn-default" data-dismiss="modal">' + button_cancel + '</button>';
|
||||||
html += ' </div>';
|
html += ' </div>';
|
||||||
html += ' </div>';
|
html += ' </div>';
|
||||||
@ -189,7 +359,7 @@
|
|||||||
$('#confirm-modal').modal('show');
|
$('#confirm-modal').modal('show');
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteTax(tr_id) {
|
function deleteCurrency(tr_id) {
|
||||||
data_href = $(tr_id).data('href');
|
data_href = $(tr_id).data('href');
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user