diff --git a/app/Http/Controllers/Wizard/Currencies.php b/app/Http/Controllers/Wizard/Currencies.php index eabad9e85..8ae9e6591 100644 --- a/app/Http/Controllers/Wizard/Currencies.php +++ b/app/Http/Controllers/Wizard/Currencies.php @@ -35,6 +35,10 @@ class Currencies extends Controller */ public function create() { + if (setting(setting('general.wizard', false))) { + return redirect('/'); + } + // Get current currencies $current = Currency::pluck('code')->toArray(); diff --git a/app/Http/Controllers/Wizard/Taxes.php b/app/Http/Controllers/Wizard/Taxes.php index 86dd44d88..8d0ff82ab 100644 --- a/app/Http/Controllers/Wizard/Taxes.php +++ b/app/Http/Controllers/Wizard/Taxes.php @@ -11,8 +11,6 @@ class Taxes extends Controller /** * Show the form for editing the specified resource. * - * @param Tax $tax - * * @return Response */ public function index() @@ -26,6 +24,48 @@ class Taxes extends Controller 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. * @@ -39,9 +79,9 @@ class Taxes extends Controller 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)]); - flash($message)->success(); - - return redirect('settings/taxes'); + return response()->json([ + 'success' => true, + 'error' => false, + 'message' => $message, + 'data' => $tax, + ]); } else { $message = trans('messages.warning.disabled', ['name' => $tax->name, 'text' => implode(', ', $relationships)]); - flash($message)->warning(); - - return redirect('settings/taxes/' . $tax->id . '/edit'); + return response()->json([ + 'success' => true, + 'error' => false, + 'message' => $message, + 'data' => $tax, + ]); } } diff --git a/resources/views/wizard/currencies/index.blade.php b/resources/views/wizard/currencies/index.blade.php index 1f1016ad1..c0dd6a73b 100644 --- a/resources/views/wizard/currencies/index.blade.php +++ b/resources/views/wizard/currencies/index.blade.php @@ -149,7 +149,7 @@ 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(), + 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() }}' }, success: function(json) { $('.currency-submit').html(''); @@ -245,7 +245,7 @@ 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(), + 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() }}' }, success: function(json) { $('.currency-updated').html(''); diff --git a/resources/views/wizard/taxes/create.blade.php b/resources/views/wizard/taxes/create.blade.php new file mode 100644 index 000000000..893cf5658 --- /dev/null +++ b/resources/views/wizard/taxes/create.blade.php @@ -0,0 +1,14 @@ + + + {{ Form::textGroup('name', trans('general.name'), 'id-card-o', ['required' => 'required'], null, '') }} + + + {{ Form::textGroup('rate', trans('currencies.rate'), 'money', ['required' => 'required'], null, '') }} + + + {{ Form::radioGroup('enabled', trans('general.enabled'), trans('general.yes'), trans('general.no'), [], 'col-md-12 tax-enabled-radio-group') }} + + + {!! Form::button('', ['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;']) !!} + + \ No newline at end of file diff --git a/resources/views/wizard/taxes/edit.blade.php b/resources/views/wizard/taxes/edit.blade.php index 767439344..dda141058 100644 --- a/resources/views/wizard/taxes/edit.blade.php +++ b/resources/views/wizard/taxes/edit.blade.php @@ -1,115 +1,14 @@ -@extends('layouts.wizard') - -@section('title', trans('general.wizard')) - -@section('content') - -
-
-
-
-
- 1 -

{{ trans_choice('general.companies', 1) }}

-
-
- 2 -

{{ trans_choice('general.currencies', 2) }}

-
-
- 3 -

{{ trans_choice('general.taxes', 2) }}

-
-
- -

{{ trans_choice('general.finish', 1) }}

-
-
-
-
-
- -
-
-

{{ trans_choice('general.taxes', 1) }}

-
- - -
-
- - - - - - - - - - - @foreach($taxes as $item) - - - - - - - @endforeach - - - - -
@sortablelink('name', trans('general.name'))@sortablelink('rate', trans('taxes.rate_percent')){{ trans('general.actions') }}
{{ $item->name }}{{ $item->rate }} -
- - -
-
-  {{ trans('general.add_new') }} -
-
-
- - - - - -
-@endsection - -@push('scripts') - -@endpush + + + {{ Form::textGroup('name', trans('general.name'), 'id-card-o', ['required' => 'required'], $item->name, '') }} + + + {{ Form::textGroup('rate', trans('currencies.rate'), 'money', ['required' => 'required'], $item->rate, '') }} + + + {{ Form::radioGroup('enabled', trans('general.enabled'), trans('general.yes'), trans('general.no'), [], 'col-md-12') }} + + + {!! Form::button('', ['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;']) !!} + + \ No newline at end of file diff --git a/resources/views/wizard/taxes/index.blade.php b/resources/views/wizard/taxes/index.blade.php index be51493e5..41da4caa9 100644 --- a/resources/views/wizard/taxes/index.blade.php +++ b/resources/views/wizard/taxes/index.blade.php @@ -34,7 +34,7 @@

{{ trans_choice('general.taxes', 1) }}

-  {{ trans('general.add_new') }} +  {{ trans('general.add_new') }}
@@ -44,15 +44,15 @@ @sortablelink('name', trans('general.name')) - @sortablelink('rate', trans('taxes.rate_percent')) - @sortablelink('enabled', trans_choice('general.statuses', 1)) + @sortablelink('rate', trans('taxes.rate_percent')) + @sortablelink('enabled', trans_choice('general.statuses', 1)) {{ trans('general.actions') }} @foreach($taxes as $item) - {{ $item->name }} + {{ $item->name }} {{ $item->rate }} @if ($item->enabled) @@ -109,7 +109,13 @@ @push('scripts')