diff --git a/app/Http/Controllers/Wizard/Companies.php b/app/Http/Controllers/Wizard/Companies.php index 3bf3254b8..b4f34ee11 100644 --- a/app/Http/Controllers/Wizard/Companies.php +++ b/app/Http/Controllers/Wizard/Companies.php @@ -78,21 +78,4 @@ class Companies extends Controller return redirect('wizard/currencies'); } - - /** - * Update the specified resource in storage. - * - * @param Request $request - * - * @return Response - */ - public function skip() - { - setting()->set('general.wizard', true); - - // Save all settings - setting()->save(); - - return redirect('/'); - } } diff --git a/app/Http/Controllers/Wizard/Currencies.php b/app/Http/Controllers/Wizard/Currencies.php index f69c210a2..bd4a06b35 100644 --- a/app/Http/Controllers/Wizard/Currencies.php +++ b/app/Http/Controllers/Wizard/Currencies.php @@ -16,7 +16,7 @@ class Currencies extends Controller * * @return Response */ - public function edit() + public function index() { if (setting('general.wizard', false)) { return redirect('/'); @@ -24,7 +24,30 @@ class Currencies extends Controller $currencies = Currency::all(); - return view('wizard.currencies.edit', compact('currencies')); + return view('wizard.currencies.index', compact('currencies')); + } + + /** + * Show the form for editing the specified resource. + * + * @param Currency $currency + * + * @return Response + */ + public function edit(Currency $currency) + { + if (setting('general.wizard', false)) { + return redirect('/'); + } + + $html = view('wizard.currencies.edit', compact('currency'))->render(); + + return response()->json([ + 'success' => true, + 'error' => false, + 'message' => 'null', + 'html' => $html, + ]); } /** @@ -80,4 +103,117 @@ class Currencies extends Controller return redirect('settings/currencies/' . $currency->id . '/edit'); } } + + /** + * Enable the specified resource. + * + * @param Currency $currency + * + * @return Response + */ + public function enable(Currency $currency) + { + $currency->enabled = 1; + $currency->save(); + + $message = trans('messages.success.enabled', ['type' => trans_choice('general.currencies', 1)]); + + return response()->json([ + 'success' => true, + 'error' => false, + 'message' => $message, + 'data' => $currency, + ]); + } + + /** + * Disable the specified resource. + * + * @param Currency $currency + * + * @return Response + */ + public function disable(Currency $currency) + { + $relationships = $this->countRelationships($currency, [ + 'accounts' => 'accounts', + 'customers' => 'customers', + 'invoices' => 'invoices', + 'revenues' => 'revenues', + 'bills' => 'bills', + 'payments' => 'payments', + ]); + + if ($currency->code == setting('general.default_currency')) { + $relationships[] = strtolower(trans_choice('general.companies', 1)); + } + + if (empty($relationships)) { + $currency->enabled = 0; + $currency->save(); + + $message = trans('messages.success.disabled', ['type' => trans_choice('general.currencies', 1)]); + + return response()->json([ + 'success' => true, + 'error' => false, + 'message' => $message, + 'data' => $currency, + ]); + } else { + $message = trans('messages.warning.disabled', ['name' => $currency->name, 'text' => implode(', ', $relationships)]); + + return response()->json([ + 'success' => false, + 'error' => true, + 'message' => $message, + 'data' => $currency, + ]); + } + } + + /** + * Remove the specified resource from storage. + * + * @param Currency $currency + * + * @return Response + */ + public function destroy(Currency $currency) + { + $relationships = $this->countRelationships($currency, [ + 'accounts' => 'accounts', + 'customers' => 'customers', + 'invoices' => 'invoices', + 'revenues' => 'revenues', + 'bills' => 'bills', + 'payments' => 'payments', + ]); + + if ($currency->code == setting('general.default_currency')) { + $relationships[] = strtolower(trans_choice('general.companies', 1)); + } + + if (empty($relationships)) { + $currency->delete(); + + $message = trans('messages.success.deleted', ['type' => trans_choice('general.currencies', 1)]); + + return response()->json([ + 'success' => true, + 'error' => false, + 'message' => $message, + 'data' => $currency, + ]); + } else { + $message = trans('messages.warning.deleted', ['name' => $currency->name, 'text' => implode(', ', $relationships)]); + + return response()->json([ + 'success' => false, + 'error' => true, + 'message' => $message, + 'data' => $currency, + ]); + } + } } diff --git a/app/Http/Controllers/Wizard/Finish.php b/app/Http/Controllers/Wizard/Finish.php index 3f1d73d1f..25a9727fb 100644 --- a/app/Http/Controllers/Wizard/Finish.php +++ b/app/Http/Controllers/Wizard/Finish.php @@ -3,10 +3,13 @@ namespace App\Http\Controllers\Wizard; use Illuminate\Routing\Controller; -use App\Models\Common\Company; +use App\Traits\Modules; +use App\Models\Module\Module; class Finish extends Controller { + use Modules; + /** * Show the form for creating a new resource. * @@ -23,6 +26,14 @@ class Finish extends Controller // Save all settings setting()->save(); - return view('wizard.finish.index', compact('')); + $data = [ + 'query' => [ + 'limit' => 4 + ] + ]; + + $modules = $this->getFeaturedModules($data); + + return view('wizard.finish.index', compact('modules')); } } diff --git a/app/Http/Controllers/Wizard/Taxes.php b/app/Http/Controllers/Wizard/Taxes.php index d567a3f6c..86dd44d88 100644 --- a/app/Http/Controllers/Wizard/Taxes.php +++ b/app/Http/Controllers/Wizard/Taxes.php @@ -15,7 +15,25 @@ class Taxes extends Controller * * @return Response */ - public function edit() + public function index() + { + if (setting(setting('general.wizard', false))) { + return redirect('/'); + } + + $taxes = Tax::all(); + + return view('wizard.taxes.index', compact('taxes')); + } + + /** + * Show the form for editing the specified resource. + * + * @param Tax $tax + * + * @return Response + */ + public function edit(Tax $tax) { if (setting(setting('general.wizard', false))) { return redirect('/'); @@ -58,4 +76,103 @@ class Taxes extends Controller return redirect('settings/taxes/' . $tax->id . '/edit'); } } + + /** + * Enable the specified resource. + * + * @param Tax $tax + * + * @return Response + */ + public function enable(Tax $tax) + { + $tax->enabled = 1; + $tax->save(); + + $message = trans('messages.success.enabled', ['type' => trans_choice('general.tax_rates', 1)]); + + return response()->json([ + 'success' => true, + 'error' => false, + 'message' => $message, + 'data' => $tax, + ]); + } + + /** + * Disable the specified resource. + * + * @param Tax $tax + * + * @return Response + */ + public function disable(Tax $tax) + { + $relationships = $this->countRelationships($tax, [ + 'items' => 'items', + 'invoice_items' => 'invoices', + 'bill_items' => 'bills', + ]); + + if (empty($relationships)) { + $tax->enabled = 0; + $tax->save(); + + $message = trans('messages.success.disabled', ['type' => trans_choice('general.tax_rates', 1)]); + + return response()->json([ + 'success' => true, + 'error' => false, + 'message' => $message, + 'data' => $tax, + ]); + } else { + $message = trans('messages.warning.disabled', ['name' => $tax->name, 'text' => implode(', ', $relationships)]); + + return response()->json([ + 'success' => false, + 'error' => true, + 'message' => $message, + 'data' => $tax, + ]); + } + } + + /** + * Remove the specified resource from storage. + * + * @param Tax $tax + * + * @return Response + */ + public function destroy(Tax $tax) + { + $relationships = $this->countRelationships($tax, [ + 'items' => 'items', + 'invoice_items' => 'invoices', + 'bill_items' => 'bills', + ]); + + if (empty($relationships)) { + $tax->delete(); + + $message = trans('messages.success.deleted', ['type' => trans_choice('general.taxes', 1)]); + + return response()->json([ + 'success' => true, + 'error' => false, + 'message' => $message, + 'data' => $tax, + ]); + } else { + $message = trans('messages.warning.deleted', ['name' => $tax->name, 'text' => implode(', ', $relationships)]); + + return response()->json([ + 'success' => false, + 'error' => true, + 'message' => $message, + 'data' => $tax, + ]); + } + } } diff --git a/app/Traits/Modules.php b/app/Traits/Modules.php index 5076ecf1c..977c2a49f 100644 --- a/app/Traits/Modules.php +++ b/app/Traits/Modules.php @@ -200,6 +200,17 @@ trait Modules return []; } + public function getFeaturedModules($data = []) + { + $response = $this->getRemote('apps/featured', 'GET', $data); + + if ($response && ($response->getStatusCode() == 200)) { + return json_decode($response->getBody())->data; + } + + return []; + } + public function getCoreVersion() { $data['query'] = Info::all(); diff --git a/resources/lang/en-GB/general.php b/resources/lang/en-GB/general.php index ab1ca05b3..3459271b0 100644 --- a/resources/lang/en-GB/general.php +++ b/resources/lang/en-GB/general.php @@ -109,6 +109,7 @@ return [ 'disable' => 'Disable', 'select_all' => 'Select All', 'unselect_all' => 'Unselect All', + 'go_to' => 'Go to :name', 'title' => [ 'new' => 'New :type', 'edit' => 'Edit :type', diff --git a/resources/lang/en-GB/modules.php b/resources/lang/en-GB/modules.php index 80a0bbd44..3a2a9a373 100644 --- a/resources/lang/en-GB/modules.php +++ b/resources/lang/en-GB/modules.php @@ -16,6 +16,8 @@ return [ 'no_apps' => 'There are no apps in this category, yet.', 'developer' => 'Are you a developer? Here you can learn how to create an app and start selling today!', + 'recommended_apps' => 'Recommended Apps', + 'about' => 'About', 'added' => 'Added', diff --git a/resources/views/layouts/wizard.blade.php b/resources/views/layouts/wizard.blade.php index 39bb46c2d..3249fe754 100644 --- a/resources/views/layouts/wizard.blade.php +++ b/resources/views/layouts/wizard.blade.php @@ -6,11 +6,7 @@
- @include('partials.wizard.header') - @include('partials.wizard.content') - - @include('partials.wizard.footer')
@stack('body_end') diff --git a/resources/views/partials/wizard/footer.blade.php b/resources/views/partials/wizard/footer.blade.php deleted file mode 100644 index 91daf239b..000000000 --- a/resources/views/partials/wizard/footer.blade.php +++ /dev/null @@ -1,10 +0,0 @@ -@stack('footer_start') - - - -@stack('footer_end') diff --git a/resources/views/partials/wizard/header.blade.php b/resources/views/partials/wizard/header.blade.php deleted file mode 100644 index b31d72258..000000000 --- a/resources/views/partials/wizard/header.blade.php +++ /dev/null @@ -1,85 +0,0 @@ -@stack('header_start') - -
- - - - -
- -@stack('header_end') diff --git a/resources/views/wizard/companies/edit.blade.php b/resources/views/wizard/companies/edit.blade.php index d2fa4a0af..7ef0812d5 100644 --- a/resources/views/wizard/companies/edit.blade.php +++ b/resources/views/wizard/companies/edit.blade.php @@ -67,7 +67,7 @@
{!! Form::button('  ' . trans('general.save'), ['type' => 'submit', 'class' => 'btn btn-success button-submit', 'data-loading-text' => trans('general.loading')]) !!} -  {{ trans('general.skip') }} +  {{ trans('general.skip') }}
diff --git a/resources/views/wizard/currencies/edit.blade.php b/resources/views/wizard/currencies/edit.blade.php index defec5157..1a7343eca 100644 --- a/resources/views/wizard/currencies/edit.blade.php +++ b/resources/views/wizard/currencies/edit.blade.php @@ -1,116 +1,38 @@ -@extends('layouts.wizard') - -@section('title', trans('general.wizard')) - -@section('content') - -
-
-
-
-
- 1 -

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

-
-
- 2 -

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

-
-
- -

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

-
-
- -

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

-
-
+ + {{ $item->name }} + {{ $item->code }} + {{ $item->rate }} + + @if ($item->enabled) + {{ trans('general.enabled') }} + @else + {{ trans('general.disabled') }} + @endif + + +
+ +
-
-
- -
-
-

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

-
- - -
-
- - - - - - - - - - - - @foreach($currencies as $item) - - - - - - - - @endforeach - - - - -
@sortablelink('name', trans('general.name'))@sortablelink('rate', trans('currencies.rate')){{ trans('general.actions') }}
{{ $item->name }}{{ $item->rate }} -
- - -
-
-  {{ trans('general.add_new') }} -
-
-
- - - - -
-@endsection - -@push('scripts') - -@endpush + + \ No newline at end of file diff --git a/resources/views/wizard/currencies/index.blade.php b/resources/views/wizard/currencies/index.blade.php new file mode 100644 index 000000000..ad76cc1e5 --- /dev/null +++ b/resources/views/wizard/currencies/index.blade.php @@ -0,0 +1,206 @@ +@extends('layouts.wizard') + +@section('title', trans('general.wizard')) + +@section('content') + +
+
+
+
+
+ 1 +

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

+
+
+ 2 +

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

+
+
+ +

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

+
+
+ +

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

+
+
+
+
+
+ +
+
+

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

+  {{ trans('general.add_new') }} +
+ + +
+
+ + + + + + + + + + + + @foreach($currencies as $item) + + + + + + + + @endforeach + +
@sortablelink('name', trans('general.name'))@sortablelink('rate', trans('currencies.rate')){{ trans('general.actions') }}
{{ $item->name }}{{ $item->rate }} +
+ + +
+
+
+
+ + + + +
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/wizard/finish/index.blade.php b/resources/views/wizard/finish/index.blade.php index 0f7947512..fc3e9a26b 100644 --- a/resources/views/wizard/finish/index.blade.php +++ b/resources/views/wizard/finish/index.blade.php @@ -29,11 +29,53 @@
-
+
+ +
+
+
+
+

{{ trans('modules.recommended_apps') }}

+
+ + @if ($modules) + @foreach ($modules->data as $module) + @include('partials.modules.item') + @endforeach +
+ +
+ @else +
+
+

+ {{ trans('modules.no_apps') }} +

+

+ {!! trans('modules.developer') !!} +

+
+ +
+ @endif +
@endsection +@push('css') + +@endpush + @push('scripts') +@endpush diff --git a/routes/web.php b/routes/web.php index 9e67f631a..2a55780b8 100644 --- a/routes/web.php +++ b/routes/web.php @@ -9,18 +9,25 @@ Route::group(['middleware' => 'language'], function () { Route::group(['middleware' => 'permission:read-admin-panel'], function () { Route::group(['prefix' => 'wizard'], function () { - Route::get('/', 'Wizard\Companies@edit'); - Route::get('skip', 'Wizard\Companies@skip'); - Route::get('companies', 'Wizard\Companies@edit'); - Route::patch('companies', 'Wizard\Companies@update'); + Route::get('/', 'Wizard\Companies@edit')->name('wizard.index'); + Route::get('companies', 'Wizard\Companies@edit')->name('wizard.companies.edit'); + Route::patch('companies', 'Wizard\Companies@update')->name('wizard.companies.update'); - Route::get('currencies', 'Wizard\Currencies@edit'); - Route::post('currencies', 'Wizard\Currencies@update'); + Route::get('currencies', 'Wizard\Currencies@index')->name('wizard.currencies.index'); + 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}/disable', 'Wizard\Currencies@disable')->name('wizard.currencies.disable'); + Route::get('currencies/{currency}/delete', 'Wizard\Currencies@destroy')->name('wizard.currencies.delete'); + Route::post('currencies/{currency}', 'Wizard\Currencies@update')->name('wizard.currencies.index'); - Route::get('taxes', 'Wizard\Taxes@edit'); - Route::post('taxes', 'Wizard\Taxes@update'); + Route::get('taxes', 'Wizard\Taxes@index')->name('wizard.taxes.index'); + 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}/disable', 'Wizard\Taxes@disable')->name('wizard.taxes.disable'); + Route::get('taxes/{tax}/delete', 'Wizard\Taxes@destroy')->name('wizard.taxes.delete'); + Route::post('taxes/{tax}', 'Wizard\Taxes@update')->name('wizard.taxes.index'); - Route::get('finish', 'Wizard\Finish@index'); + Route::get('finish', 'Wizard\Finish@index')->name('wizard.finish.index'); }); });