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 @@ +
@sortablelink('name', trans('general.name')) | -@sortablelink('rate', trans('taxes.rate_percent')) | - -{{ trans('general.actions') }} | -|
---|---|---|---|
{{ $item->name }} | -{{ $item->rate }} | -- @if ($item->enabled) - {{ trans('general.enabled') }} - @else - {{ trans('general.disabled') }} - @endif - | -
-
-
-
-
- |
-
- | - -