From a181cff0703a390b02973bf6dff9375922aea3e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Batuhan=20Ba=C5=9F?= Date: Sat, 20 Oct 2018 13:04:01 +0300 Subject: [PATCH 01/15] Some request values changed --- tests/Feature/Auth/PermissionsTest.php | 2 +- tests/Feature/Auth/RolesTest.php | 2 +- tests/Feature/Common/ItemsTest.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Feature/Auth/PermissionsTest.php b/tests/Feature/Auth/PermissionsTest.php index 876e77c6b..953907670 100644 --- a/tests/Feature/Auth/PermissionsTest.php +++ b/tests/Feature/Auth/PermissionsTest.php @@ -76,7 +76,7 @@ class PermissionsTest extends FeatureTestCase private function getPermissionRequest() { return [ - 'name' => $this->faker->text(5), + 'name' => $this->faker->name, 'display_name' => $this->faker->text(5), 'description' => $this->faker->text(5), ]; diff --git a/tests/Feature/Auth/RolesTest.php b/tests/Feature/Auth/RolesTest.php index d48e85b7d..7e3c24326 100644 --- a/tests/Feature/Auth/RolesTest.php +++ b/tests/Feature/Auth/RolesTest.php @@ -76,7 +76,7 @@ class RolesTest extends FeatureTestCase private function getRoleRequest() { return [ - 'name' => $this->faker->text(5), + 'name' => $this->faker->name, 'display_name' => $this->faker->text(5), 'description' => $this->faker->text(5), 'permissions' => Permission::take(10)->pluck('id')->toArray(), diff --git a/tests/Feature/Common/ItemsTest.php b/tests/Feature/Common/ItemsTest.php index 5ff8188c9..08db51c55 100644 --- a/tests/Feature/Common/ItemsTest.php +++ b/tests/Feature/Common/ItemsTest.php @@ -78,7 +78,7 @@ class ItemsTest extends FeatureTestCase return [ 'company_id' => $this->company->id, - 'name' => $this->faker->text(15), + 'name' => $this->faker->name, 'sku' => $this->faker->unique()->ean8, 'picture' => $picture, 'description' => $this->faker->text(100), From 867ca71767977e99307b858d67c0c0446bdb5967 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Batuhan=20Ba=C5=9F?= Date: Sat, 20 Oct 2018 16:12:21 +0300 Subject: [PATCH 02/15] Replace old request values --- tests/Feature/Auth/PermissionsTest.php | 2 +- tests/Feature/Common/ItemsTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Feature/Auth/PermissionsTest.php b/tests/Feature/Auth/PermissionsTest.php index 953907670..876e77c6b 100644 --- a/tests/Feature/Auth/PermissionsTest.php +++ b/tests/Feature/Auth/PermissionsTest.php @@ -76,7 +76,7 @@ class PermissionsTest extends FeatureTestCase private function getPermissionRequest() { return [ - 'name' => $this->faker->name, + 'name' => $this->faker->text(5), 'display_name' => $this->faker->text(5), 'description' => $this->faker->text(5), ]; diff --git a/tests/Feature/Common/ItemsTest.php b/tests/Feature/Common/ItemsTest.php index 08db51c55..a077355ca 100644 --- a/tests/Feature/Common/ItemsTest.php +++ b/tests/Feature/Common/ItemsTest.php @@ -78,7 +78,7 @@ class ItemsTest extends FeatureTestCase return [ 'company_id' => $this->company->id, - 'name' => $this->faker->name, + 'name' => $this->faker->text(5), 'sku' => $this->faker->unique()->ean8, 'picture' => $picture, 'description' => $this->faker->text(100), From 97f43a0930001a40c0656af8871ad5e5f8dcaf30 Mon Sep 17 00:00:00 2001 From: cuneytsenturk Date: Tue, 23 Oct 2018 18:47:55 +0300 Subject: [PATCH 03/15] Wizard files added --- app/Events/AdminMenuCreated.php | 2 +- app/Events/BillCreated.php | 2 +- app/Events/BillUpdated.php | 2 +- app/Events/CompanySwitched.php | 2 +- app/Events/CustomerMenuCreated.php | 2 +- app/Events/InvoiceCreated.php | 2 +- app/Events/InvoicePrinting.php | 2 +- app/Events/InvoiceUpdated.php | 2 +- app/Events/ModuleInstalled.php | 2 +- app/Events/UpdateFinished.php | 2 +- app/Http/Controllers/Auth/Login.php | 5 + app/Http/Controllers/Wizard/Companies.php | 73 ++++++++ app/Http/Controllers/Wizard/Currencies.php | 96 +++++++++++ app/Http/Controllers/Wizard/Finish.php | 73 ++++++++ app/Http/Controllers/Wizard/Taxes.php | 125 ++++++++++++++ app/Http/Kernel.php | 7 + app/Http/Middleware/AdminMenu.php | 2 +- app/Providers/ViewComposerServiceProvider.php | 2 +- app/Utilities/Installer.php | 2 +- public/css/app.css | 47 ++++- public/js/app.js | 4 +- resources/views/layouts/wizard.blade.php | 18 ++ .../views/partials/wizard/content.blade.php | 39 +++++ .../views/partials/wizard/footer.blade.php | 10 ++ .../views/partials/wizard/head.blade.php | 67 ++++++++ .../views/partials/wizard/header.blade.php | 85 ++++++++++ .../partials/wizard/pagination.blade.php | 16 ++ .../views/settings/settings/edit.blade.php | 2 + .../views/wizard/companies/edit.blade.php | 160 ++++++++++++++++++ .../views/wizard/currencies/edit.blade.php | 160 ++++++++++++++++++ resources/views/wizard/finish/edit.blade.php | 160 ++++++++++++++++++ resources/views/wizard/taxes/edit.blade.php | 160 ++++++++++++++++++ routes/web.php | 17 ++ 33 files changed, 1335 insertions(+), 15 deletions(-) create mode 100644 app/Http/Controllers/Wizard/Companies.php create mode 100644 app/Http/Controllers/Wizard/Currencies.php create mode 100644 app/Http/Controllers/Wizard/Finish.php create mode 100644 app/Http/Controllers/Wizard/Taxes.php create mode 100644 resources/views/layouts/wizard.blade.php create mode 100644 resources/views/partials/wizard/content.blade.php create mode 100644 resources/views/partials/wizard/footer.blade.php create mode 100644 resources/views/partials/wizard/head.blade.php create mode 100644 resources/views/partials/wizard/header.blade.php create mode 100644 resources/views/partials/wizard/pagination.blade.php create mode 100644 resources/views/wizard/companies/edit.blade.php create mode 100644 resources/views/wizard/currencies/edit.blade.php create mode 100644 resources/views/wizard/finish/edit.blade.php create mode 100644 resources/views/wizard/taxes/edit.blade.php diff --git a/app/Events/AdminMenuCreated.php b/app/Events/AdminMenuCreated.php index 9883abb09..764c931bf 100644 --- a/app/Events/AdminMenuCreated.php +++ b/app/Events/AdminMenuCreated.php @@ -15,4 +15,4 @@ class AdminMenuCreated { $this->menu = $menu; } -} \ No newline at end of file +} diff --git a/app/Events/BillCreated.php b/app/Events/BillCreated.php index fc4881a74..11b29cc1e 100644 --- a/app/Events/BillCreated.php +++ b/app/Events/BillCreated.php @@ -15,4 +15,4 @@ class BillCreated { $this->bill = $bill; } -} \ No newline at end of file +} diff --git a/app/Events/BillUpdated.php b/app/Events/BillUpdated.php index 21751e17a..563eb3254 100644 --- a/app/Events/BillUpdated.php +++ b/app/Events/BillUpdated.php @@ -15,4 +15,4 @@ class BillUpdated { $this->bill = $bill; } -} \ No newline at end of file +} diff --git a/app/Events/CompanySwitched.php b/app/Events/CompanySwitched.php index 3738c8dae..2a25ec4e0 100644 --- a/app/Events/CompanySwitched.php +++ b/app/Events/CompanySwitched.php @@ -15,4 +15,4 @@ class CompanySwitched { $this->company = $company; } -} \ No newline at end of file +} diff --git a/app/Events/CustomerMenuCreated.php b/app/Events/CustomerMenuCreated.php index 5766e1ba2..b7c6fcccc 100644 --- a/app/Events/CustomerMenuCreated.php +++ b/app/Events/CustomerMenuCreated.php @@ -15,4 +15,4 @@ class CustomerMenuCreated { $this->menu = $menu; } -} \ No newline at end of file +} diff --git a/app/Events/InvoiceCreated.php b/app/Events/InvoiceCreated.php index afa2e3c62..e6ab023a8 100644 --- a/app/Events/InvoiceCreated.php +++ b/app/Events/InvoiceCreated.php @@ -15,4 +15,4 @@ class InvoiceCreated { $this->invoice = $invoice; } -} \ No newline at end of file +} diff --git a/app/Events/InvoicePrinting.php b/app/Events/InvoicePrinting.php index f775b69dc..78fb14c7d 100644 --- a/app/Events/InvoicePrinting.php +++ b/app/Events/InvoicePrinting.php @@ -15,4 +15,4 @@ class InvoicePrinting { $this->invoice = $invoice; } -} \ No newline at end of file +} diff --git a/app/Events/InvoiceUpdated.php b/app/Events/InvoiceUpdated.php index d9d6fc3ee..2f4db58e3 100644 --- a/app/Events/InvoiceUpdated.php +++ b/app/Events/InvoiceUpdated.php @@ -15,4 +15,4 @@ class InvoiceUpdated { $this->invoice = $invoice; } -} \ No newline at end of file +} diff --git a/app/Events/ModuleInstalled.php b/app/Events/ModuleInstalled.php index b581eb539..3ce3ef2b0 100644 --- a/app/Events/ModuleInstalled.php +++ b/app/Events/ModuleInstalled.php @@ -19,4 +19,4 @@ class ModuleInstalled $this->alias = $alias; $this->company_id = $company_id; } -} \ No newline at end of file +} diff --git a/app/Events/UpdateFinished.php b/app/Events/UpdateFinished.php index d221c60fd..8af0b3177 100644 --- a/app/Events/UpdateFinished.php +++ b/app/Events/UpdateFinished.php @@ -23,4 +23,4 @@ class UpdateFinished $this->old = $old; $this->new = $new; } -} \ No newline at end of file +} diff --git a/app/Http/Controllers/Auth/Login.php b/app/Http/Controllers/Auth/Login.php index ea2aabbf8..68d3ca69d 100644 --- a/app/Http/Controllers/Auth/Login.php +++ b/app/Http/Controllers/Auth/Login.php @@ -79,6 +79,11 @@ class Login extends Controller return redirect($path); } + // Check wizard + if (!setting('general.wizard', false)) { + return redirect('wizard'); + } + return redirect('/'); } diff --git a/app/Http/Controllers/Wizard/Companies.php b/app/Http/Controllers/Wizard/Companies.php new file mode 100644 index 000000000..a9fdeaff2 --- /dev/null +++ b/app/Http/Controllers/Wizard/Companies.php @@ -0,0 +1,73 @@ +setSettings(); + + return view('wizard.companies.edit', compact('company', 'currencies')); + } + + /** + * Update the specified resource in storage. + * + * @param Company $company + * @param Request $request + * + * @return Response + */ + public function update(Company $company, Request $request) + { + // Update company + $company->update($request->input()); + + // Get the company settings + setting()->forgetAll(); + setting()->setExtraColumns(['company_id' => $company->id]); + setting()->load(true); + + // Update settings + setting()->set('general.company_name', $request->get('company_name')); + setting()->set('general.company_email', $request->get('company_email')); + setting()->set('general.company_address', $request->get('company_address')); + + if ($request->file('company_logo')) { + $company_logo = $this->getMedia($request->file('company_logo'), 'settings', $company->id); + + if ($company_logo) { + $company->attachMedia($company_logo, 'company_logo'); + + setting()->set('general.company_logo', $company_logo->id); + } + } + + setting()->set('general.default_payment_method', 'offlinepayment.cash.1'); + setting()->set('general.default_currency', $request->get('default_currency')); + + setting()->save(); + + // Redirect + $message = trans('messages.success.updated', ['type' => trans_choice('general.companies', 1)]); + + flash($message)->success(); + + return redirect('common/companies'); + } +} diff --git a/app/Http/Controllers/Wizard/Currencies.php b/app/Http/Controllers/Wizard/Currencies.php new file mode 100644 index 000000000..1b8cde9a5 --- /dev/null +++ b/app/Http/Controllers/Wizard/Currencies.php @@ -0,0 +1,96 @@ +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; + } + + // Set default currency + $currency->default_currency = ($currency->code == setting('general.default_currency')) ? 1 : 0; + + return view('settings.currencies.edit', compact('currency', 'codes')); + } + + /** + * Update the specified resource in storage. + * + * @param Currency $currency + * @param Request $request + * + * @return Response + */ + public function update(Currency $currency, Request $request) + { + // Check if we can disable or change the code + if (!$request['enabled'] || ($currency->code != $request['code'])) { + $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)) { + // Force the rate to be 1 for default currency + if ($request['default_currency']) { + $request['rate'] = '1'; + } + + $currency->update($request->all()); + + // Update default currency setting + if ($request['default_currency']) { + setting()->set('general.default_currency', $request['code']); + setting()->save(); + } + + $message = trans('messages.success.updated', ['type' => trans_choice('general.currencies', 1)]); + + flash($message)->success(); + + return redirect('settings/currencies'); + } else { + $message = trans('messages.warning.disabled', ['name' => $currency->name, 'text' => implode(', ', $relationships)]); + + flash($message)->warning(); + + return redirect('settings/currencies/' . $currency->id . '/edit'); + } + } +} diff --git a/app/Http/Controllers/Wizard/Finish.php b/app/Http/Controllers/Wizard/Finish.php new file mode 100644 index 000000000..1c474f59f --- /dev/null +++ b/app/Http/Controllers/Wizard/Finish.php @@ -0,0 +1,73 @@ +setSettings(); + + return view('wizard.companies.edit', compact('company', 'currencies')); + } + + /** + * Update the specified resource in storage. + * + * @param Company $company + * @param Request $request + * + * @return Response + */ + public function update(Company $company, Request $request) + { + // Update company + $company->update($request->input()); + + // Get the company settings + setting()->forgetAll(); + setting()->setExtraColumns(['company_id' => $company->id]); + setting()->load(true); + + // Update settings + setting()->set('general.company_name', $request->get('company_name')); + setting()->set('general.company_email', $request->get('company_email')); + setting()->set('general.company_address', $request->get('company_address')); + + if ($request->file('company_logo')) { + $company_logo = $this->getMedia($request->file('company_logo'), 'settings', $company->id); + + if ($company_logo) { + $company->attachMedia($company_logo, 'company_logo'); + + setting()->set('general.company_logo', $company_logo->id); + } + } + + setting()->set('general.default_payment_method', 'offlinepayment.cash.1'); + setting()->set('general.default_currency', $request->get('default_currency')); + + setting()->save(); + + // Redirect + $message = trans('messages.success.updated', ['type' => trans_choice('general.companies', 1)]); + + flash($message)->success(); + + return redirect('common/companies'); + } +} diff --git a/app/Http/Controllers/Wizard/Taxes.php b/app/Http/Controllers/Wizard/Taxes.php new file mode 100644 index 000000000..9f0bcb12a --- /dev/null +++ b/app/Http/Controllers/Wizard/Taxes.php @@ -0,0 +1,125 @@ +all()); + + $message = trans('messages.success.added', ['type' => trans_choice('general.tax_rates', 1)]); + + flash($message)->success(); + + return redirect('settings/taxes'); + } + + /** + * Show the form for editing the specified resource. + * + * @param Tax $tax + * + * @return Response + */ + public function edit(Tax $tax) + { + return view('settings.taxes.edit', compact('tax')); + } + + /** + * Update the specified resource in storage. + * + * @param Tax $tax + * @param Request $request + * + * @return Response + */ + public function update(Tax $tax, Request $request) + { + $relationships = $this->countRelationships($tax, [ + 'items' => 'items', + 'invoice_items' => 'invoices', + 'bill_items' => 'bills', + ]); + + if (empty($relationships) || $request['enabled']) { + $tax->update($request->all()); + + $message = trans('messages.success.updated', ['type' => trans_choice('general.tax_rates', 1)]); + + flash($message)->success(); + + return redirect('settings/taxes'); + } else { + $message = trans('messages.warning.disabled', ['name' => $tax->name, 'text' => implode(', ', $relationships)]); + + flash($message)->warning(); + + 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)]); + + flash($message)->success(); + + return redirect()->route('taxes.index'); + } + + /** + * 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)]); + + flash($message)->success(); + } else { + $message = trans('messages.warning.disabled', ['name' => $tax->name, 'text' => implode(', ', $relationships)]); + + flash($message)->warning(); + + return redirect()->route('taxes.index'); + } + + return redirect()->route('taxes.index'); + } +} diff --git a/app/Http/Kernel.php b/app/Http/Kernel.php index 7ce07c8a5..8f21fcc23 100644 --- a/app/Http/Kernel.php +++ b/app/Http/Kernel.php @@ -41,6 +41,13 @@ class Kernel extends HttpKernel 'company.currencies', ], + 'wizard' => [ + 'web', + 'language', + 'auth', + 'permission:read-admin-panel', + ], + 'admin' => [ 'web', 'language', diff --git a/app/Http/Middleware/AdminMenu.php b/app/Http/Middleware/AdminMenu.php index 817204b3c..2acf708a0 100644 --- a/app/Http/Middleware/AdminMenu.php +++ b/app/Http/Middleware/AdminMenu.php @@ -204,4 +204,4 @@ class AdminMenu return $next($request); } -} \ No newline at end of file +} diff --git a/app/Providers/ViewComposerServiceProvider.php b/app/Providers/ViewComposerServiceProvider.php index 7cd15d6ac..0e690522a 100644 --- a/app/Providers/ViewComposerServiceProvider.php +++ b/app/Providers/ViewComposerServiceProvider.php @@ -31,7 +31,7 @@ class ViewComposerServiceProvider extends ServiceProvider // Add notifications to header View::composer( - ['partials.admin.header', 'partials.customer.header'], 'App\Http\ViewComposers\Header' + ['partials.wizard.header', 'partials.admin.header', 'partials.customer.header'], 'App\Http\ViewComposers\Header' ); // Add limits to index diff --git a/app/Utilities/Installer.php b/app/Utilities/Installer.php index 5d6f8116f..5fbe6c244 100644 --- a/app/Utilities/Installer.php +++ b/app/Utilities/Installer.php @@ -157,7 +157,7 @@ class Installer try { DB::connection('install_test')->getPdo(); - } catch (\Exception $e) {; + } catch (\Exception $e) { return false; } diff --git a/public/css/app.css b/public/css/app.css index 0058aecdf..80692f1aa 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -772,4 +772,49 @@ input[type="number"] { #items .select2-search__field { padding-left: 15px; -} \ No newline at end of file +} + +.stepwizard-step p { + margin-top: 0px; + color:#666; +} +.stepwizard-row { + display: table-row; +} +.stepwizard { + display: table; + width: 100%; + position: relative; +} +.stepwizard-step button[disabled] { + /*opacity: 1 !important; + filter: alpha(opacity=100) !important;*/ +} +.stepwizard .btn.disabled, .stepwizard .btn[disabled], .stepwizard fieldset[disabled] .btn { + opacity:1 !important; + color:#bbb; +} +.stepwizard-row:before { + top: 14px; + bottom: 0; + position: absolute; + content:" "; + width: 100%; + height: 1px; + background-color: #ccc; + z-index: 0; +} +.stepwizard-step { + display: table-cell; + text-align: center; + position: relative; +} +.btn-circle { + width: 30px; + height: 30px; + text-align: center; + padding: 6px 0; + font-size: 12px; + line-height: 1.428571429; + border-radius: 15px; +} diff --git a/public/js/app.js b/public/js/app.js index f439f68c0..5b153e223 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -198,7 +198,9 @@ $(document).ready(function () { return true; }); - $('.input-group-invoice-text select').select2(); + if (document.getElementsByClassName('input-group-invoice-text').length) { + $('.input-group-invoice-text select').select2(); + } }); function confirmDelete(form_id, title, message, button_cancel, button_delete) { diff --git a/resources/views/layouts/wizard.blade.php b/resources/views/layouts/wizard.blade.php new file mode 100644 index 000000000..39bb46c2d --- /dev/null +++ b/resources/views/layouts/wizard.blade.php @@ -0,0 +1,18 @@ + + @include('partials.wizard.head') + + + @stack('body_start') + + +
+ @include('partials.wizard.header') + + @include('partials.wizard.content') + + @include('partials.wizard.footer') +
+ + @stack('body_end') + + diff --git a/resources/views/partials/wizard/content.blade.php b/resources/views/partials/wizard/content.blade.php new file mode 100644 index 000000000..654309016 --- /dev/null +++ b/resources/views/partials/wizard/content.blade.php @@ -0,0 +1,39 @@ +@stack('content_start') + + +
+ @stack('content_wrapper_start') + + +
+ @stack('content_header_start') + +

+ @yield('title') + @yield('new_button') +

+ + @stack('content_header_end') +
+ + +
+ @include('flash::message') + + @stack('content_content_start') + + @yield('content') + + @stack('content_content_end') +
+ + + @stack('content_wrapper_end') +
+ + + + +@stack('content_end') \ No newline at end of file diff --git a/resources/views/partials/wizard/footer.blade.php b/resources/views/partials/wizard/footer.blade.php new file mode 100644 index 000000000..9e7ddf297 --- /dev/null +++ b/resources/views/partials/wizard/footer.blade.php @@ -0,0 +1,10 @@ +@stack('footer_start') + + + +@stack('footer_end') diff --git a/resources/views/partials/wizard/head.blade.php b/resources/views/partials/wizard/head.blade.php new file mode 100644 index 000000000..95ceb8001 --- /dev/null +++ b/resources/views/partials/wizard/head.blade.php @@ -0,0 +1,67 @@ + + @stack('head_start') + + + + + + + @yield('title') - @setting('general.company_name') + + + + + + + + + + + @if (setting('general.admin_theme', 'skin-green-light') == 'skin-green-light') + + @else + + + @endif + + + + + + + + + @stack('css') + + @stack('stylesheet') + + + + + + + + + + + + + + + + + + + + + + + @stack('js') + + @stack('scripts') + + @stack('head_end') + diff --git a/resources/views/partials/wizard/header.blade.php b/resources/views/partials/wizard/header.blade.php new file mode 100644 index 000000000..b31d72258 --- /dev/null +++ b/resources/views/partials/wizard/header.blade.php @@ -0,0 +1,85 @@ +@stack('header_start') + +
+ + + + +
+ +@stack('header_end') diff --git a/resources/views/partials/wizard/pagination.blade.php b/resources/views/partials/wizard/pagination.blade.php new file mode 100644 index 000000000..395807023 --- /dev/null +++ b/resources/views/partials/wizard/pagination.blade.php @@ -0,0 +1,16 @@ +@stack('pagination_start') + +@if ($items->firstItem()) +
+ {{ trans('pagination.showing', ['first' => $items->firstItem(), 'last' => $items->lastItem(), 'total' => $items->total(), 'type' => strtolower(trans_choice('general.' . $type, 2))]) }} +
+
+ {!! $items->appends(request()->except('page'))->links() !!} +
+@else +
+ {{ trans('general.no_records') }} +
+@endif + +@stack('pagination_end') \ No newline at end of file diff --git a/resources/views/settings/settings/edit.blade.php b/resources/views/settings/settings/edit.blade.php index 8b8d99f91..37a5700bf 100644 --- a/resources/views/settings/settings/edit.blade.php +++ b/resources/views/settings/settings/edit.blade.php @@ -39,6 +39,8 @@ {{ Form::textareaGroup('company_address', trans('settings.company.address')) }} {{ Form::fileGroup('company_logo', trans('settings.company.logo')) }} + + {!! Form::hidden('wizard', null, ['id' => 'wizard']) !!}
diff --git a/resources/views/wizard/companies/edit.blade.php b/resources/views/wizard/companies/edit.blade.php new file mode 100644 index 000000000..317a6fbb3 --- /dev/null +++ b/resources/views/wizard/companies/edit.blade.php @@ -0,0 +1,160 @@ +@extends('layouts.wizard') + +@section('title', trans('general.wizard')) + +@section('content') + +
+ {!! Form::model($company, ['method' => 'PATCH', 'files' => true, 'url' => ['wizard/companies', $company->id], 'role' => 'form', 'class' => 'form-loading-button']) !!} +
+
+
+
+ 1 +

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

+
+
+ 2 +

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

+
+
+ 3 +

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

+
+
+ 4 +

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

+
+
+
+
+ +
+
+
+ {!! Form::label('sale_price', trans('modules.api_token'), ['class' => 'control-label']) !!} +
+ + {!! Form::text('api_token', setting('general.api_token', null), ['class' => 'form-control', 'required' => 'required', 'placeholder' => trans('general.form.enter', ['field' => trans('modules.api_token')])]) !!} +
+ {!! $errors->first('api_token', '

:message

') !!} +
+

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

+
+ + {{ Form::textGroup('company_tax_number', trans('general.tax_number'), 'percent', []) }} + + {{ Form::textGroup('company_phone', trans('settings.company.phone'), 'phone', []) }} + + {{ Form::textareaGroup('company_address', trans('settings.company.address')) }} + + {{ Form::fileGroup('company_logo', trans('settings.company.logo')) }} +
+ + + + + + {!! Form::close() !!} +
+@endsection + +@push('js') + +@endpush + +@push('css') + +@endpush + +@push('scripts') + +@endpush diff --git a/resources/views/wizard/currencies/edit.blade.php b/resources/views/wizard/currencies/edit.blade.php new file mode 100644 index 000000000..317a6fbb3 --- /dev/null +++ b/resources/views/wizard/currencies/edit.blade.php @@ -0,0 +1,160 @@ +@extends('layouts.wizard') + +@section('title', trans('general.wizard')) + +@section('content') + +
+ {!! Form::model($company, ['method' => 'PATCH', 'files' => true, 'url' => ['wizard/companies', $company->id], 'role' => 'form', 'class' => 'form-loading-button']) !!} +
+
+
+
+ 1 +

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

+
+
+ 2 +

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

+
+
+ 3 +

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

+
+
+ 4 +

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

+
+
+
+
+ +
+
+
+ {!! Form::label('sale_price', trans('modules.api_token'), ['class' => 'control-label']) !!} +
+ + {!! Form::text('api_token', setting('general.api_token', null), ['class' => 'form-control', 'required' => 'required', 'placeholder' => trans('general.form.enter', ['field' => trans('modules.api_token')])]) !!} +
+ {!! $errors->first('api_token', '

:message

') !!} +
+

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

+
+ + {{ Form::textGroup('company_tax_number', trans('general.tax_number'), 'percent', []) }} + + {{ Form::textGroup('company_phone', trans('settings.company.phone'), 'phone', []) }} + + {{ Form::textareaGroup('company_address', trans('settings.company.address')) }} + + {{ Form::fileGroup('company_logo', trans('settings.company.logo')) }} +
+ + + + + + {!! Form::close() !!} +
+@endsection + +@push('js') + +@endpush + +@push('css') + +@endpush + +@push('scripts') + +@endpush diff --git a/resources/views/wizard/finish/edit.blade.php b/resources/views/wizard/finish/edit.blade.php new file mode 100644 index 000000000..317a6fbb3 --- /dev/null +++ b/resources/views/wizard/finish/edit.blade.php @@ -0,0 +1,160 @@ +@extends('layouts.wizard') + +@section('title', trans('general.wizard')) + +@section('content') + +
+ {!! Form::model($company, ['method' => 'PATCH', 'files' => true, 'url' => ['wizard/companies', $company->id], 'role' => 'form', 'class' => 'form-loading-button']) !!} +
+
+
+
+ 1 +

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

+
+
+ 2 +

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

+
+
+ 3 +

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

+
+
+ 4 +

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

+
+
+
+
+ +
+
+
+ {!! Form::label('sale_price', trans('modules.api_token'), ['class' => 'control-label']) !!} +
+ + {!! Form::text('api_token', setting('general.api_token', null), ['class' => 'form-control', 'required' => 'required', 'placeholder' => trans('general.form.enter', ['field' => trans('modules.api_token')])]) !!} +
+ {!! $errors->first('api_token', '

:message

') !!} +
+

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

+
+ + {{ Form::textGroup('company_tax_number', trans('general.tax_number'), 'percent', []) }} + + {{ Form::textGroup('company_phone', trans('settings.company.phone'), 'phone', []) }} + + {{ Form::textareaGroup('company_address', trans('settings.company.address')) }} + + {{ Form::fileGroup('company_logo', trans('settings.company.logo')) }} +
+ + + + + + {!! Form::close() !!} +
+@endsection + +@push('js') + +@endpush + +@push('css') + +@endpush + +@push('scripts') + +@endpush diff --git a/resources/views/wizard/taxes/edit.blade.php b/resources/views/wizard/taxes/edit.blade.php new file mode 100644 index 000000000..317a6fbb3 --- /dev/null +++ b/resources/views/wizard/taxes/edit.blade.php @@ -0,0 +1,160 @@ +@extends('layouts.wizard') + +@section('title', trans('general.wizard')) + +@section('content') + +
+ {!! Form::model($company, ['method' => 'PATCH', 'files' => true, 'url' => ['wizard/companies', $company->id], 'role' => 'form', 'class' => 'form-loading-button']) !!} +
+
+
+
+ 1 +

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

+
+
+ 2 +

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

+
+
+ 3 +

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

+
+
+ 4 +

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

+
+
+
+
+ +
+
+
+ {!! Form::label('sale_price', trans('modules.api_token'), ['class' => 'control-label']) !!} +
+ + {!! Form::text('api_token', setting('general.api_token', null), ['class' => 'form-control', 'required' => 'required', 'placeholder' => trans('general.form.enter', ['field' => trans('modules.api_token')])]) !!} +
+ {!! $errors->first('api_token', '

:message

') !!} +
+

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

+
+ + {{ Form::textGroup('company_tax_number', trans('general.tax_number'), 'percent', []) }} + + {{ Form::textGroup('company_phone', trans('settings.company.phone'), 'phone', []) }} + + {{ Form::textareaGroup('company_address', trans('settings.company.address')) }} + + {{ Form::fileGroup('company_logo', trans('settings.company.logo')) }} +
+ + + + + + {!! Form::close() !!} +
+@endsection + +@push('js') + +@endpush + +@push('css') + +@endpush + +@push('scripts') + +@endpush diff --git a/routes/web.php b/routes/web.php index 127316e8c..a7e12bf81 100644 --- a/routes/web.php +++ b/routes/web.php @@ -7,6 +7,23 @@ Route::group(['middleware' => 'language'], function () { Route::get('{id}/download', 'Common\Uploads@download'); }); + Route::group(['middleware' => 'permission:read-admin-panel'], function () { + Route::group(['prefix' => 'wizard'], function () { + Route::get('/', 'Wizard\Companies@edit'); + Route::get('companies', 'Wizard\Companies@edit'); + Route::post('companies', 'Wizard\Companies@update'); + + Route::get('currencies', 'Wizard\Currencies@create'); + Route::post('language', 'Wizard\Currencies@store'); + + Route::get('taxes', 'Wizard\Taxes@create'); + Route::post('taxes', 'Wizard\Taxes@store'); + + Route::get('finish', 'Wizard\Finish@create'); + Route::post('finish', 'Wizard\Finish@store'); + }); + }); + Route::group(['middleware' => ['adminmenu', 'permission:read-admin-panel']], function () { Route::get('/', 'Common\Dashboard@index'); From 121f0b893eb3ca49e79fdd377d250eada69a9c38 Mon Sep 17 00:00:00 2001 From: cuneytsenturk Date: Tue, 23 Oct 2018 21:32:16 +0300 Subject: [PATCH 04/15] Wizard file updates --- public/css/app.css | 33 +++++++++++++------ .../views/partials/wizard/content.blade.php | 2 +- .../views/partials/wizard/footer.blade.php | 2 +- .../views/wizard/companies/edit.blade.php | 30 ++++++++++------- 4 files changed, 44 insertions(+), 23 deletions(-) diff --git a/public/css/app.css b/public/css/app.css index 80692f1aa..702c2ccb3 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -775,27 +775,34 @@ input[type="number"] { } .stepwizard-step p { - margin-top: 0px; + margin-top: 5px; + font-size: 16px; color:#666; } + .stepwizard-row { display: table-row; } + .stepwizard { display: table; width: 100%; position: relative; + margin-top: 20px; } + .stepwizard-step button[disabled] { /*opacity: 1 !important; filter: alpha(opacity=100) !important;*/ } + .stepwizard .btn.disabled, .stepwizard .btn[disabled], .stepwizard fieldset[disabled] .btn { opacity:1 !important; color:#bbb; } + .stepwizard-row:before { - top: 14px; + top: 26px; bottom: 0; position: absolute; content:" "; @@ -804,17 +811,23 @@ input[type="number"] { background-color: #ccc; z-index: 0; } + .stepwizard-step { display: table-cell; text-align: center; position: relative; } -.btn-circle { - width: 30px; - height: 30px; - text-align: center; - padding: 6px 0; - font-size: 12px; - line-height: 1.428571429; - border-radius: 15px; + +.btn-circle.btn-success { + color: #fff; +} + +.btn-circle { + width: 50px; + height: 50px; + text-align: center; + padding: 0px 0; + font-size: 30px; + line-height: 1.428571; + border-radius: 30px; } diff --git a/resources/views/partials/wizard/content.blade.php b/resources/views/partials/wizard/content.blade.php index 654309016..4abf0d968 100644 --- a/resources/views/partials/wizard/content.blade.php +++ b/resources/views/partials/wizard/content.blade.php @@ -1,7 +1,7 @@ @stack('content_start') -
+
@stack('content_wrapper_start') diff --git a/resources/views/partials/wizard/footer.blade.php b/resources/views/partials/wizard/footer.blade.php index 9e7ddf297..91daf239b 100644 --- a/resources/views/partials/wizard/footer.blade.php +++ b/resources/views/partials/wizard/footer.blade.php @@ -1,6 +1,6 @@ @stack('footer_start') -
+
diff --git a/resources/views/wizard/companies/edit.blade.php b/resources/views/wizard/companies/edit.blade.php index 317a6fbb3..7c68d40f6 100644 --- a/resources/views/wizard/companies/edit.blade.php +++ b/resources/views/wizard/companies/edit.blade.php @@ -4,9 +4,8 @@ @section('content') -
- {!! Form::model($company, ['method' => 'PATCH', 'files' => true, 'url' => ['wizard/companies', $company->id], 'role' => 'form', 'class' => 'form-loading-button']) !!} -
+
+
@@ -14,20 +13,26 @@

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

- 2 +

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

- 3 +

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

- 4 -

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

+ +

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

+
+
+ {!! Form::model($company, ['method' => 'PATCH', 'files' => true, 'url' => ['wizard/companies', $company->id], 'role' => 'form', 'class' => 'form-loading-button']) !!} +
+

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

+
@@ -42,6 +47,7 @@

{!! trans('modules.token_link') !!}

+
{{ Form::textGroup('company_tax_number', trans('general.tax_number'), 'percent', []) }} @@ -55,9 +61,12 @@ @@ -79,7 +88,6 @@ var text_no = '{{ trans('general.no') }}'; $(document).ready(function () { - var navListItems = $('div.setup-panel div a'), allWells = $('.setup-content'), allNextBtn = $('.nextBtn'); From 6039fcb5f16aa2dbc8c971101f2d46145d8c8ac5 Mon Sep 17 00:00:00 2001 From: cuneytsenturk Date: Wed, 24 Oct 2018 12:07:28 +0300 Subject: [PATCH 05/15] Wizard files permission and route, controller, view files added --- app/Http/Controllers/Common/Companies.php | 5 + app/Http/Controllers/Wizard/Companies.php | 82 +++++++---- app/Http/Controllers/Wizard/Currencies.php | 23 +-- app/Http/Controllers/Wizard/Finish.php | 52 +------ app/Http/Controllers/Wizard/Taxes.php | 76 +--------- app/Http/Requests/Wizard/Company.php | 30 ++++ app/Listeners/Updates/Version130.php | 102 ++++++++++++++ database/seeds/Roles.php | 4 + database/seeds/Settings.php | 3 +- public/css/app.css | 2 +- resources/lang/en-GB/general.php | 3 + .../views/wizard/companies/edit.blade.php | 53 +------ .../views/wizard/currencies/edit.blade.php | 131 +++--------------- resources/views/wizard/finish/index.blade.php | 73 ++++++++++ resources/views/wizard/taxes/edit.blade.php | 131 +++--------------- routes/web.php | 14 +- 16 files changed, 346 insertions(+), 438 deletions(-) create mode 100644 app/Http/Requests/Wizard/Company.php create mode 100644 resources/views/wizard/finish/index.blade.php diff --git a/app/Http/Controllers/Common/Companies.php b/app/Http/Controllers/Common/Companies.php index 9ed22afe0..1c8efba9e 100644 --- a/app/Http/Controllers/Common/Companies.php +++ b/app/Http/Controllers/Common/Companies.php @@ -264,6 +264,11 @@ class Companies extends Controller event(new CompanySwitched($company)); } + // Check wizard + if (!setting('general.wizard', false)) { + return redirect('wizard'); + } + return redirect('/'); } diff --git a/app/Http/Controllers/Wizard/Companies.php b/app/Http/Controllers/Wizard/Companies.php index a9fdeaff2..c929d655f 100644 --- a/app/Http/Controllers/Wizard/Companies.php +++ b/app/Http/Controllers/Wizard/Companies.php @@ -2,11 +2,15 @@ namespace App\Http\Controllers\Wizard; -use Illuminate\Routing\Controller; +use App\Http\Controllers\Controller; +use App\Http\Requests\Wizard\Company as Request; use App\Models\Common\Company; +use App\Traits\Uploads; class Companies extends Controller { + use Uploads; + /** * Show the form for creating a new resource. * @@ -14,15 +18,15 @@ class Companies extends Controller */ public function edit() { - if (setting(setting('general.wizard', false))) { - return redirect('/'); + if (setting('general.wizard', false)) { + //return redirect('/'); } $company = Company::find(session('company_id')); $company->setSettings(); - return view('wizard.companies.edit', compact('company', 'currencies')); + return view('wizard.companies.edit', compact('company')); } /** @@ -33,34 +37,43 @@ class Companies extends Controller * * @return Response */ - public function update(Company $company, Request $request) + public function update(Request $request) { - // Update company - $company->update($request->input()); + // Company + $company = Company::find(session('company_id')); - // Get the company settings - setting()->forgetAll(); - setting()->setExtraColumns(['company_id' => $company->id]); - setting()->load(true); + $fields = $request->all(); - // Update settings - setting()->set('general.company_name', $request->get('company_name')); - setting()->set('general.company_email', $request->get('company_email')); - setting()->set('general.company_address', $request->get('company_address')); + $skip_keys = ['company_id', '_method', '_token']; + $file_keys = ['company_logo', 'invoice_logo']; - if ($request->file('company_logo')) { - $company_logo = $this->getMedia($request->file('company_logo'), 'settings', $company->id); - - if ($company_logo) { - $company->attachMedia($company_logo, 'company_logo'); - - setting()->set('general.company_logo', $company_logo->id); + foreach ($fields as $key => $value) { + // Don't process unwanted keys + if (in_array($key, $skip_keys)) { + continue; } + + // Process file uploads + if (in_array($key, $file_keys)) { + // Upload attachment + if ($request->file($key)) { + $media = $this->getMedia($request->file($key), 'settings'); + + $company->attachMedia($media, $key); + + $value = $media->id; + } + + // Prevent reset + if (empty($value)) { + continue; + } + } + + setting()->set('general.' . $key, $value); } - setting()->set('general.default_payment_method', 'offlinepayment.cash.1'); - setting()->set('general.default_currency', $request->get('default_currency')); - + // Save all settings setting()->save(); // Redirect @@ -68,6 +81,23 @@ class Companies extends Controller flash($message)->success(); - return redirect('common/companies'); + 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 1b8cde9a5..24022e1c0 100644 --- a/app/Http/Controllers/Wizard/Currencies.php +++ b/app/Http/Controllers/Wizard/Currencies.php @@ -2,7 +2,6 @@ namespace App\Http\Controllers\Wizard; -use Akaunting\Money\Currency as MoneyCurrency; use App\Http\Controllers\Controller; use App\Http\Requests\Setting\Currency as Request; use App\Models\Banking\Account; @@ -17,27 +16,15 @@ class Currencies extends Controller * * @return Response */ - public function edit(Currency $currency) + public function edit() { - // 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; + if (setting('general.wizard', false)) { + //return redirect('/'); } - // Set default currency - $currency->default_currency = ($currency->code == setting('general.default_currency')) ? 1 : 0; + $currencies = Currency::all(); - return view('settings.currencies.edit', compact('currency', 'codes')); + return view('wizard.currencies.edit', compact('currencies')); } /** diff --git a/app/Http/Controllers/Wizard/Finish.php b/app/Http/Controllers/Wizard/Finish.php index 1c474f59f..859d91ce3 100644 --- a/app/Http/Controllers/Wizard/Finish.php +++ b/app/Http/Controllers/Wizard/Finish.php @@ -12,62 +12,16 @@ class Finish extends Controller * * @return Response */ - public function edit() + public function index() { if (setting(setting('general.wizard', false))) { - return redirect('/'); + //return redirect('/'); } $company = Company::find(session('company_id')); $company->setSettings(); - return view('wizard.companies.edit', compact('company', 'currencies')); - } - - /** - * Update the specified resource in storage. - * - * @param Company $company - * @param Request $request - * - * @return Response - */ - public function update(Company $company, Request $request) - { - // Update company - $company->update($request->input()); - - // Get the company settings - setting()->forgetAll(); - setting()->setExtraColumns(['company_id' => $company->id]); - setting()->load(true); - - // Update settings - setting()->set('general.company_name', $request->get('company_name')); - setting()->set('general.company_email', $request->get('company_email')); - setting()->set('general.company_address', $request->get('company_address')); - - if ($request->file('company_logo')) { - $company_logo = $this->getMedia($request->file('company_logo'), 'settings', $company->id); - - if ($company_logo) { - $company->attachMedia($company_logo, 'company_logo'); - - setting()->set('general.company_logo', $company_logo->id); - } - } - - setting()->set('general.default_payment_method', 'offlinepayment.cash.1'); - setting()->set('general.default_currency', $request->get('default_currency')); - - setting()->save(); - - // Redirect - $message = trans('messages.success.updated', ['type' => trans_choice('general.companies', 1)]); - - flash($message)->success(); - - return redirect('common/companies'); + return view('wizard.finish.index', compact('company', 'currencies')); } } diff --git a/app/Http/Controllers/Wizard/Taxes.php b/app/Http/Controllers/Wizard/Taxes.php index 9f0bcb12a..65dc7b3a6 100644 --- a/app/Http/Controllers/Wizard/Taxes.php +++ b/app/Http/Controllers/Wizard/Taxes.php @@ -8,24 +8,6 @@ use App\Models\Setting\Tax; class Taxes extends Controller { - /** - * Store a newly created resource in storage. - * - * @param Request $request - * - * @return Response - */ - public function store(Request $request) - { - Tax::create($request->all()); - - $message = trans('messages.success.added', ['type' => trans_choice('general.tax_rates', 1)]); - - flash($message)->success(); - - return redirect('settings/taxes'); - } - /** * Show the form for editing the specified resource. * @@ -33,9 +15,11 @@ class Taxes extends Controller * * @return Response */ - public function edit(Tax $tax) + public function edit() { - return view('settings.taxes.edit', compact('tax')); + $tax = []; + + return view('wizard.taxes.edit', compact('tax')); } /** @@ -70,56 +54,4 @@ 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)]); - - flash($message)->success(); - - return redirect()->route('taxes.index'); - } - - /** - * 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)]); - - flash($message)->success(); - } else { - $message = trans('messages.warning.disabled', ['name' => $tax->name, 'text' => implode(', ', $relationships)]); - - flash($message)->warning(); - - return redirect()->route('taxes.index'); - } - - return redirect()->route('taxes.index'); - } } diff --git a/app/Http/Requests/Wizard/Company.php b/app/Http/Requests/Wizard/Company.php new file mode 100644 index 000000000..114f6877f --- /dev/null +++ b/app/Http/Requests/Wizard/Company.php @@ -0,0 +1,30 @@ + 'mimes:' . setting('general.file_types') . '|between:0,' . setting('general.file_size') * 1024, + ]; + } +} diff --git a/app/Listeners/Updates/Version130.php b/app/Listeners/Updates/Version130.php index b6aa5bd1d..2d1d36b66 100644 --- a/app/Listeners/Updates/Version130.php +++ b/app/Listeners/Updates/Version130.php @@ -3,6 +3,8 @@ namespace App\Listeners\Updates; use App\Events\UpdateFinished; +use App\Models\Auth\Role; +use App\Models\Auth\Permission; use Artisan; class Version130 extends Listener @@ -24,10 +26,110 @@ class Version130 extends Listener return; } + $permissions = $this->getPermissions(); + + // Attach permission to roles + $roles = Role::all(); + + foreach ($roles as $role) { + $allowed = ['admin']; + + if (!in_array($role->name, $allowed)) { + continue; + } + + foreach ($permissions as $permission) { + $role->attachPermission($permission); + } + } + // Set new Item Reminder settings setting(['general.send_item_reminder' => '0']); setting(['general.schedule_item_stocks' => '3,5,7']); + setting(['general.wizard' => '0']); setting()->save(); } + + protected function getPermissions() + { + $permissions = []; + + // Create permissions + $permissions[] = Permission::firstOrCreate([ + 'name' => 'create-wizard-companies', + 'display_name' => 'Create Wizard Compaines', + 'description' => 'Create Wizard Compaines', + ]); + + $permissions[] = Permission::firstOrCreate([ + 'name' => 'create-wizard-currencies', + 'display_name' => 'Create Wizard Currencies', + 'description' => 'Create Wizard Currencies', + ]); + + $permissions[] = Permission::firstOrCreate([ + 'name' => 'create-wizard-taxes', + 'display_name' => 'Create Wizard Taxes', + 'description' => 'Create Wizard Taxes', + ]); + + $permissions[] = Permission::firstOrCreate([ + 'name' => 'create-wizard-finish', + 'display_name' => 'Create Wizard Finish', + 'description' => 'Create Wizard Finish', + ]); + + // Read permissions + $permissions[] = Permission::firstOrCreate([ + 'name' => 'read-wizard-companies', + 'display_name' => 'Read Wizard Compaines', + 'description' => 'Read Wizard Compaines', + ]); + + $permissions[] = Permission::firstOrCreate([ + 'name' => 'read-wizard-currencies', + 'display_name' => 'Read Wizard Currencies', + 'description' => 'Read Wizard Currencies', + ]); + + $permissions[] = Permission::firstOrCreate([ + 'name' => 'read-wizard-taxes', + 'display_name' => 'Read Wizard Taxes', + 'description' => 'Read Wizard Taxes', + ]); + + $permissions[] = Permission::firstOrCreate([ + 'name' => 'read-wizard-finish', + 'display_name' => 'Read Wizard Finish', + 'description' => 'Read Wizard Finish', + ]); + + // Update permissions + $permissions[] = Permission::firstOrCreate([ + 'name' => 'update-wizard-companies', + 'display_name' => 'Update Wizard Compaines', + 'description' => 'Update Wizard Compaines', + ]); + + $permissions[] = Permission::firstOrCreate([ + 'name' => 'update-wizard-currencies', + 'display_name' => 'Update Wizard Currencies', + 'description' => 'Update Wizard Currencies', + ]); + + $permissions[] = Permission::firstOrCreate([ + 'name' => 'update-wizard-taxes', + 'display_name' => 'Update Wizard Taxes', + 'description' => 'Update Wizard Taxes', + ]); + + $permissions[] = Permission::firstOrCreate([ + 'name' => 'update-wizard-finish', + 'display_name' => 'Update Wizard Finish', + 'description' => 'Update Wizard Finish', + ]); + + return $permissions; + } } diff --git a/database/seeds/Roles.php b/database/seeds/Roles.php index b6d1b93eb..71069bd0d 100644 --- a/database/seeds/Roles.php +++ b/database/seeds/Roles.php @@ -63,6 +63,10 @@ class Roles extends Seeder 'reports-income-expense-summary' => 'r', 'reports-profit-loss' => 'r', 'reports-tax-summary' => 'r', + 'wizard-companies' => 'c,r,u', + 'wizard-currencies' => 'c,r,u', + 'wizard-taxes' => 'c,r,u', + 'wizard-finish' => 'c,r,u', ], 'manager' => [ 'admin-panel' => 'r', diff --git a/database/seeds/Settings.php b/database/seeds/Settings.php index 1c530c9b5..1746965ab 100644 --- a/database/seeds/Settings.php +++ b/database/seeds/Settings.php @@ -51,7 +51,8 @@ class Settings extends Seeder 'general.session_lifetime' => '30', 'general.file_size' => '2', 'general.file_types' => 'pdf,jpeg,jpg,png', - 'offlinepayment.methods' => '[{"code":"offlinepayment.cash.1","name":"Cash","order":"1","description":null},{"code":"offlinepayment.bank_transfer.2","name":"Bank Transfer","order":"2","description":null}]', + 'general.wizard' => '0', + 'offlinepayment.methods' => '[{"code":"offlinepayment.cash.1","name":"Cash","order":"1","description":null},{"code":"offlinepayment.bank_transfer.2","name":"Bank Transfer","order":"2","description":null}]', ]); } } diff --git a/public/css/app.css b/public/css/app.css index 702c2ccb3..4374d6c64 100644 --- a/public/css/app.css +++ b/public/css/app.css @@ -826,7 +826,7 @@ input[type="number"] { width: 50px; height: 50px; text-align: center; - padding: 0px 0; + padding: 1px 0; font-size: 30px; line-height: 1.428571; border-radius: 30px; diff --git a/resources/lang/en-GB/general.php b/resources/lang/en-GB/general.php index daee66c9d..ab1ca05b3 100644 --- a/resources/lang/en-GB/general.php +++ b/resources/lang/en-GB/general.php @@ -102,6 +102,9 @@ return [ 'partially' => 'Partially', 'partially_paid' => 'Partially Paid', 'export' => 'Export', + 'finish' => 'Finish', + 'wizard' => 'Wizard', + 'skip' => 'Skip', 'enable' => 'Enable', 'disable' => 'Disable', 'select_all' => 'Select All', diff --git a/resources/views/wizard/companies/edit.blade.php b/resources/views/wizard/companies/edit.blade.php index 7c68d40f6..d2fa4a0af 100644 --- a/resources/views/wizard/companies/edit.blade.php +++ b/resources/views/wizard/companies/edit.blade.php @@ -28,11 +28,14 @@
+
- {!! Form::model($company, ['method' => 'PATCH', 'files' => true, 'url' => ['wizard/companies', $company->id], 'role' => 'form', 'class' => 'form-loading-button']) !!} + {!! Form::model($company, ['method' => 'PATCH', 'files' => true, 'url' => ['wizard/companies'], 'role' => 'form', 'class' => 'form-loading-button']) !!} +

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

+
@@ -64,7 +67,7 @@
{!! Form::button('  ' . trans('general.save'), ['type' => 'submit', 'class' => 'btn btn-success button-submit', 'data-loading-text' => trans('general.loading')]) !!} - {!! Form::button('  ' . trans('general.skip'), ['type' => 'button', 'class' => 'btn btn-default', 'data-loading-text' => trans('general.loading')]) !!} +  {{ trans('general.skip') }}
@@ -87,48 +90,6 @@ var text_yes = '{{ trans('general.yes') }}'; var text_no = '{{ trans('general.no') }}'; - $(document).ready(function () { - var navListItems = $('div.setup-panel div a'), - allWells = $('.setup-content'), - allNextBtn = $('.nextBtn'); - - allWells.hide(); - - navListItems.click(function (e) { - e.preventDefault(); - var $target = $($(this).attr('href')), - $item = $(this); - - if (!$item.hasClass('disabled')) { - navListItems.removeClass('btn-success').addClass('btn-default'); - $item.addClass('btn-success'); - allWells.hide(); - $target.show(); - $target.find('input:eq(0)').focus(); - } - }); - - allNextBtn.click(function () { - var curStep = $(this).closest(".setup-content"), - curStepBtn = curStep.attr("id"), - nextStepWizard = $('div.setup-panel div a[href="#' + curStepBtn + '"]').parent().next().children("a"), - curInputs = curStep.find("input[type='text'],input[type='url']"), - isValid = true; - - $(".form-group").removeClass("has-error"); - for (var i = 0; i < curInputs.length; i++) { - if (!curInputs[i].validity.valid) { - isValid = false; - $(curInputs[i]).closest(".form-group").addClass("has-error"); - } - } - - if (isValid) nextStepWizard.removeAttr('disabled').trigger('click'); - }); - - $('div.setup-panel div a.btn-success').trigger('click'); - }); - $(document).ready(function() { $('#company_logo').fancyfile({ text : '{{ trans('general.form.select.file') }}', @@ -142,7 +103,7 @@ @if($company->company_logo) company_logo_html = ''; - $('#company .fancy-file .fake-file').append(company_logo_html); + $('.form-group.col-md-6 .fancy-file .fake-file').append(company_logo_html); $(document).on('click', '#remove-company_logo', function (e) { confirmDelete("#company_logo-{!! $company->company_logo->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '' . $company->company_logo->basename . '', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); diff --git a/resources/views/wizard/currencies/edit.blade.php b/resources/views/wizard/currencies/edit.blade.php index 317a6fbb3..d6d12b4e7 100644 --- a/resources/views/wizard/currencies/edit.blade.php +++ b/resources/views/wizard/currencies/edit.blade.php @@ -4,60 +4,56 @@ @section('content') -
- {!! Form::model($company, ['method' => 'PATCH', 'files' => true, 'url' => ['wizard/companies', $company->id], 'role' => 'form', 'class' => 'form-loading-button']) !!} -
+
+
- 1 + 1

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

- 2 + 2

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

- 3 +

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

- 4 -

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

+ +

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

+
+ +
+ {!! Form::model([], ['method' => 'PATCH', 'files' => true, 'url' => ['wizard/currencies'], 'role' => 'form', 'class' => 'form-loading-button']) !!} + +
+

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

+
+
-
-
- {!! Form::label('sale_price', trans('modules.api_token'), ['class' => 'control-label']) !!} -
- - {!! Form::text('api_token', setting('general.api_token', null), ['class' => 'form-control', 'required' => 'required', 'placeholder' => trans('general.form.enter', ['field' => trans('modules.api_token')])]) !!} -
- {!! $errors->first('api_token', '

:message

') !!} -
-

- {!! trans('modules.token_link') !!} -

-
{{ Form::textGroup('company_tax_number', trans('general.tax_number'), 'percent', []) }} {{ Form::textGroup('company_phone', trans('settings.company.phone'), 'phone', []) }} {{ Form::textareaGroup('company_address', trans('settings.company.address')) }} - - {{ Form::fileGroup('company_logo', trans('settings.company.logo')) }}
@@ -65,96 +61,13 @@
@endsection -@push('js') - -@endpush - -@push('css') - -@endpush - @push('scripts') @endpush diff --git a/resources/views/wizard/finish/index.blade.php b/resources/views/wizard/finish/index.blade.php new file mode 100644 index 000000000..4398eb27b --- /dev/null +++ b/resources/views/wizard/finish/index.blade.php @@ -0,0 +1,73 @@ +@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) }}

+
+
+ 4 +

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

+
+
+
+
+
+ +
+ {!! Form::model([], ['method' => 'PATCH', 'files' => true, 'url' => ['wizard/taxes'], 'role' => 'form', 'class' => 'form-loading-button']) !!} + +
+

{{ trans('general.finish') }}

+
+ + +
+ + {{ Form::textGroup('company_tax_number', trans('general.tax_number'), 'percent', []) }} + + {{ Form::textGroup('company_phone', trans('settings.company.phone'), 'phone', []) }} + + {{ Form::textareaGroup('company_address', trans('settings.company.address')) }} +
+ + + + + + {!! Form::close() !!} +
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/wizard/taxes/edit.blade.php b/resources/views/wizard/taxes/edit.blade.php index 317a6fbb3..75e1d9caa 100644 --- a/resources/views/wizard/taxes/edit.blade.php +++ b/resources/views/wizard/taxes/edit.blade.php @@ -4,60 +4,56 @@ @section('content') -
- {!! Form::model($company, ['method' => 'PATCH', 'files' => true, 'url' => ['wizard/companies', $company->id], 'role' => 'form', 'class' => 'form-loading-button']) !!} -
+
+
- 1 + 1

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

- 2 + 2

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

- 3 + 3

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

- 4 -

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

+ +

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

+
+ +
+ {!! Form::model([], ['method' => 'PATCH', 'files' => true, 'url' => ['wizard/taxes'], 'role' => 'form', 'class' => 'form-loading-button']) !!} + +
+

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

+
+
-
-
- {!! Form::label('sale_price', trans('modules.api_token'), ['class' => 'control-label']) !!} -
- - {!! Form::text('api_token', setting('general.api_token', null), ['class' => 'form-control', 'required' => 'required', 'placeholder' => trans('general.form.enter', ['field' => trans('modules.api_token')])]) !!} -
- {!! $errors->first('api_token', '

:message

') !!} -
-

- {!! trans('modules.token_link') !!} -

-
{{ Form::textGroup('company_tax_number', trans('general.tax_number'), 'percent', []) }} {{ Form::textGroup('company_phone', trans('settings.company.phone'), 'phone', []) }} {{ Form::textareaGroup('company_address', trans('settings.company.address')) }} - - {{ Form::fileGroup('company_logo', trans('settings.company.logo')) }}
@@ -65,96 +61,13 @@
@endsection -@push('js') - -@endpush - -@push('css') - -@endpush - @push('scripts') @endpush diff --git a/routes/web.php b/routes/web.php index a7e12bf81..9e67f631a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -10,17 +10,17 @@ 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::post('companies', 'Wizard\Companies@update'); + Route::patch('companies', 'Wizard\Companies@update'); - Route::get('currencies', 'Wizard\Currencies@create'); - Route::post('language', 'Wizard\Currencies@store'); + Route::get('currencies', 'Wizard\Currencies@edit'); + Route::post('currencies', 'Wizard\Currencies@update'); - Route::get('taxes', 'Wizard\Taxes@create'); - Route::post('taxes', 'Wizard\Taxes@store'); + Route::get('taxes', 'Wizard\Taxes@edit'); + Route::post('taxes', 'Wizard\Taxes@update'); - Route::get('finish', 'Wizard\Finish@create'); - Route::post('finish', 'Wizard\Finish@store'); + Route::get('finish', 'Wizard\Finish@index'); }); }); From 2ebe1e34c3c86647556be90a8a87588307dd82ea Mon Sep 17 00:00:00 2001 From: cuneytsenturk Date: Wed, 24 Oct 2018 12:24:20 +0300 Subject: [PATCH 06/15] Wizard Currencies and Taxes edit page start --- app/Http/Controllers/Wizard/Companies.php | 7 +- app/Http/Controllers/Wizard/Currencies.php | 2 +- app/Http/Controllers/Wizard/Finish.php | 9 +- app/Http/Controllers/Wizard/Taxes.php | 8 +- .../views/wizard/currencies/edit.blade.php | 63 +++++-- resources/views/wizard/finish/edit.blade.php | 160 ------------------ resources/views/wizard/finish/index.blade.php | 27 --- resources/views/wizard/taxes/edit.blade.php | 60 ++++++- 8 files changed, 117 insertions(+), 219 deletions(-) delete mode 100644 resources/views/wizard/finish/edit.blade.php diff --git a/app/Http/Controllers/Wizard/Companies.php b/app/Http/Controllers/Wizard/Companies.php index c929d655f..3bf3254b8 100644 --- a/app/Http/Controllers/Wizard/Companies.php +++ b/app/Http/Controllers/Wizard/Companies.php @@ -19,7 +19,7 @@ class Companies extends Controller public function edit() { if (setting('general.wizard', false)) { - //return redirect('/'); + return redirect('/'); } $company = Company::find(session('company_id')); @@ -76,11 +76,6 @@ class Companies extends Controller // Save all settings setting()->save(); - // Redirect - $message = trans('messages.success.updated', ['type' => trans_choice('general.companies', 1)]); - - flash($message)->success(); - return redirect('wizard/currencies'); } diff --git a/app/Http/Controllers/Wizard/Currencies.php b/app/Http/Controllers/Wizard/Currencies.php index 24022e1c0..f69c210a2 100644 --- a/app/Http/Controllers/Wizard/Currencies.php +++ b/app/Http/Controllers/Wizard/Currencies.php @@ -19,7 +19,7 @@ class Currencies extends Controller public function edit() { if (setting('general.wizard', false)) { - //return redirect('/'); + return redirect('/'); } $currencies = Currency::all(); diff --git a/app/Http/Controllers/Wizard/Finish.php b/app/Http/Controllers/Wizard/Finish.php index 859d91ce3..3f1d73d1f 100644 --- a/app/Http/Controllers/Wizard/Finish.php +++ b/app/Http/Controllers/Wizard/Finish.php @@ -15,13 +15,14 @@ class Finish extends Controller public function index() { if (setting(setting('general.wizard', false))) { - //return redirect('/'); + return redirect('/'); } - $company = Company::find(session('company_id')); + setting()->set('general.wizard', true); - $company->setSettings(); + // Save all settings + setting()->save(); - return view('wizard.finish.index', compact('company', 'currencies')); + return view('wizard.finish.index', compact('')); } } diff --git a/app/Http/Controllers/Wizard/Taxes.php b/app/Http/Controllers/Wizard/Taxes.php index 65dc7b3a6..d567a3f6c 100644 --- a/app/Http/Controllers/Wizard/Taxes.php +++ b/app/Http/Controllers/Wizard/Taxes.php @@ -17,9 +17,13 @@ class Taxes extends Controller */ public function edit() { - $tax = []; + if (setting(setting('general.wizard', false))) { + return redirect('/'); + } - return view('wizard.taxes.edit', compact('tax')); + $taxes = Tax::all(); + + return view('wizard.taxes.edit', compact('taxes')); } /** diff --git a/resources/views/wizard/currencies/edit.blade.php b/resources/views/wizard/currencies/edit.blade.php index d6d12b4e7..defec5157 100644 --- a/resources/views/wizard/currencies/edit.blade.php +++ b/resources/views/wizard/currencies/edit.blade.php @@ -30,20 +30,65 @@
- {!! Form::model([], ['method' => 'PATCH', 'files' => true, 'url' => ['wizard/currencies'], 'role' => 'form', 'class' => 'form-loading-button']) !!} -

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

- - {{ Form::textGroup('company_tax_number', trans('general.tax_number'), 'percent', []) }} - - {{ Form::textGroup('company_phone', trans('settings.company.phone'), 'phone', []) }} - - {{ Form::textareaGroup('company_address', trans('settings.company.address')) }} +
+ + + + + + + + + + + + @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') }} +
+
@@ -56,8 +101,6 @@
- - {!! Form::close() !!}
@endsection diff --git a/resources/views/wizard/finish/edit.blade.php b/resources/views/wizard/finish/edit.blade.php deleted file mode 100644 index 317a6fbb3..000000000 --- a/resources/views/wizard/finish/edit.blade.php +++ /dev/null @@ -1,160 +0,0 @@ -@extends('layouts.wizard') - -@section('title', trans('general.wizard')) - -@section('content') - -
- {!! Form::model($company, ['method' => 'PATCH', 'files' => true, 'url' => ['wizard/companies', $company->id], 'role' => 'form', 'class' => 'form-loading-button']) !!} -
-
-
-
- 1 -

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

-
-
- 2 -

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

-
-
- 3 -

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

-
-
- 4 -

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

-
-
-
-
- -
-
-
- {!! Form::label('sale_price', trans('modules.api_token'), ['class' => 'control-label']) !!} -
- - {!! Form::text('api_token', setting('general.api_token', null), ['class' => 'form-control', 'required' => 'required', 'placeholder' => trans('general.form.enter', ['field' => trans('modules.api_token')])]) !!} -
- {!! $errors->first('api_token', '

:message

') !!} -
-

- {!! trans('modules.token_link') !!} -

-
- - {{ Form::textGroup('company_tax_number', trans('general.tax_number'), 'percent', []) }} - - {{ Form::textGroup('company_phone', trans('settings.company.phone'), 'phone', []) }} - - {{ Form::textareaGroup('company_address', trans('settings.company.address')) }} - - {{ Form::fileGroup('company_logo', trans('settings.company.logo')) }} -
- - - - - - {!! Form::close() !!} -
-@endsection - -@push('js') - -@endpush - -@push('css') - -@endpush - -@push('scripts') - -@endpush diff --git a/resources/views/wizard/finish/index.blade.php b/resources/views/wizard/finish/index.blade.php index 4398eb27b..0f7947512 100644 --- a/resources/views/wizard/finish/index.blade.php +++ b/resources/views/wizard/finish/index.blade.php @@ -30,34 +30,7 @@
- {!! Form::model([], ['method' => 'PATCH', 'files' => true, 'url' => ['wizard/taxes'], 'role' => 'form', 'class' => 'form-loading-button']) !!} -
-

{{ trans('general.finish') }}

-
- - -
- - {{ Form::textGroup('company_tax_number', trans('general.tax_number'), 'percent', []) }} - - {{ Form::textGroup('company_phone', trans('settings.company.phone'), 'phone', []) }} - - {{ Form::textareaGroup('company_address', trans('settings.company.address')) }} -
- - - - - - {!! Form::close() !!}
@endsection diff --git a/resources/views/wizard/taxes/edit.blade.php b/resources/views/wizard/taxes/edit.blade.php index 75e1d9caa..767439344 100644 --- a/resources/views/wizard/taxes/edit.blade.php +++ b/resources/views/wizard/taxes/edit.blade.php @@ -30,20 +30,63 @@
- {!! Form::model([], ['method' => 'PATCH', 'files' => true, 'url' => ['wizard/taxes'], 'role' => 'form', 'class' => 'form-loading-button']) !!} -

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

- - {{ Form::textGroup('company_tax_number', trans('general.tax_number'), 'percent', []) }} - - {{ Form::textGroup('company_phone', trans('settings.company.phone'), 'phone', []) }} - - {{ Form::textareaGroup('company_address', trans('settings.company.address')) }} +
+ + + + + + + + + + + @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') }} +
+
@@ -57,7 +100,6 @@
- {!! Form::close() !!}
@endsection From ac2ab267c8c24b334ce6f0f01136eb69cb0e1a4a Mon Sep 17 00:00:00 2001 From: cuneytsenturk Date: Wed, 24 Oct 2018 18:30:37 +0300 Subject: [PATCH 07/15] Wizard Currencies, Taxes, Finish pages changes --- app/Http/Controllers/Wizard/Companies.php | 17 -- app/Http/Controllers/Wizard/Currencies.php | 140 +++++++++++- app/Http/Controllers/Wizard/Finish.php | 15 +- app/Http/Controllers/Wizard/Taxes.php | 119 +++++++++- app/Traits/Modules.php | 11 + resources/lang/en-GB/general.php | 1 + resources/lang/en-GB/modules.php | 2 + resources/views/layouts/wizard.blade.php | 4 - .../views/partials/wizard/footer.blade.php | 10 - .../views/partials/wizard/header.blade.php | 85 -------- .../views/wizard/companies/edit.blade.php | 2 +- .../views/wizard/currencies/edit.blade.php | 152 ++++--------- .../views/wizard/currencies/index.blade.php | 206 ++++++++++++++++++ resources/views/wizard/finish/index.blade.php | 44 +++- resources/views/wizard/taxes/index.blade.php | 205 +++++++++++++++++ routes/web.php | 25 ++- 16 files changed, 791 insertions(+), 247 deletions(-) delete mode 100644 resources/views/partials/wizard/footer.blade.php delete mode 100644 resources/views/partials/wizard/header.blade.php create mode 100644 resources/views/wizard/currencies/index.blade.php create mode 100644 resources/views/wizard/taxes/index.blade.php 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'); }); }); From 70379839b763085caf3be715ea47740fa62a067a Mon Sep 17 00:00:00 2001 From: cuneytsenturk Date: Wed, 24 Oct 2018 19:36:21 +0300 Subject: [PATCH 08/15] Wizard skip loading added --- app/Listeners/Updates/Version130.php | 2 +- resources/views/layouts/wizard.blade.php | 6 ++++ .../views/partials/wizard/head.blade.php | 34 +++++++++++++++++++ .../views/wizard/companies/edit.blade.php | 4 ++- .../views/wizard/currencies/index.blade.php | 4 ++- resources/views/wizard/taxes/index.blade.php | 4 ++- 6 files changed, 50 insertions(+), 4 deletions(-) diff --git a/app/Listeners/Updates/Version130.php b/app/Listeners/Updates/Version130.php index 2d1d36b66..4696b1aaa 100644 --- a/app/Listeners/Updates/Version130.php +++ b/app/Listeners/Updates/Version130.php @@ -46,7 +46,7 @@ class Version130 extends Listener // Set new Item Reminder settings setting(['general.send_item_reminder' => '0']); setting(['general.schedule_item_stocks' => '3,5,7']); - setting(['general.wizard' => '0']); + setting(['general.wizard' => '1']); setting()->save(); } diff --git a/resources/views/layouts/wizard.blade.php b/resources/views/layouts/wizard.blade.php index 3249fe754..80bdc3f9a 100644 --- a/resources/views/layouts/wizard.blade.php +++ b/resources/views/layouts/wizard.blade.php @@ -10,5 +10,11 @@
@stack('body_end') + + diff --git a/resources/views/partials/wizard/head.blade.php b/resources/views/partials/wizard/head.blade.php index 95ceb8001..594a1c98c 100644 --- a/resources/views/partials/wizard/head.blade.php +++ b/resources/views/partials/wizard/head.blade.php @@ -34,6 +34,40 @@ @stack('css') @stack('stylesheet') + diff --git a/resources/views/wizard/companies/edit.blade.php b/resources/views/wizard/companies/edit.blade.php index 7ef0812d5..e1d9805d5 100644 --- a/resources/views/wizard/companies/edit.blade.php +++ b/resources/views/wizard/companies/edit.blade.php @@ -30,6 +30,8 @@
+
+ {!! Form::model($company, ['method' => 'PATCH', 'files' => true, 'url' => ['wizard/companies'], 'role' => 'form', 'class' => 'form-loading-button']) !!}
@@ -67,7 +69,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/index.blade.php b/resources/views/wizard/currencies/index.blade.php index ad76cc1e5..e6ef4001b 100644 --- a/resources/views/wizard/currencies/index.blade.php +++ b/resources/views/wizard/currencies/index.blade.php @@ -30,6 +30,8 @@
+
+

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

 {{ trans('general.add_new') }} @@ -98,7 +100,7 @@ diff --git a/resources/views/wizard/taxes/index.blade.php b/resources/views/wizard/taxes/index.blade.php index 62cd768e7..be51493e5 100644 --- a/resources/views/wizard/taxes/index.blade.php +++ b/resources/views/wizard/taxes/index.blade.php @@ -30,6 +30,8 @@
+
+

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

 {{ trans('general.add_new') }} @@ -96,7 +98,7 @@ From 5f00757142de1a3096fbef9813715692586273f4 Mon Sep 17 00:00:00 2001 From: cuneytsenturk Date: Thu, 25 Oct 2018 16:12:47 +0300 Subject: [PATCH 09/15] Wizard Currencies step finished --- app/Http/Controllers/Wizard/Currencies.php | 102 +++++++++- resources/views/layouts/wizard.blade.php | 2 +- .../views/wizard/currencies/create.blade.php | 30 +++ .../views/wizard/currencies/edit.blade.php | 60 +++--- .../views/wizard/currencies/index.blade.php | 185 +++++++++++++++++- routes/web.php | 8 +- 6 files changed, 337 insertions(+), 50 deletions(-) create mode 100644 resources/views/wizard/currencies/create.blade.php diff --git a/app/Http/Controllers/Wizard/Currencies.php b/app/Http/Controllers/Wizard/Currencies.php index bd4a06b35..eabad9e85 100644 --- a/app/Http/Controllers/Wizard/Currencies.php +++ b/app/Http/Controllers/Wizard/Currencies.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Wizard; +use Akaunting\Money\Currency as MoneyCurrency; use App\Http\Controllers\Controller; use App\Http\Requests\Setting\Currency as Request; use App\Models\Banking\Account; @@ -27,6 +28,70 @@ class Currencies extends Controller 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. * @@ -40,7 +105,24 @@ class Currencies extends Controller 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([ 'success' => true, @@ -92,15 +174,21 @@ class Currencies extends Controller $message = trans('messages.success.updated', ['type' => trans_choice('general.currencies', 1)]); - flash($message)->success(); - - return redirect('settings/currencies'); + return response()->json([ + 'success' => true, + 'error' => false, + 'message' => $message, + 'data' => $currency, + ]); } else { $message = trans('messages.warning.disabled', ['name' => $currency->name, 'text' => implode(', ', $relationships)]); - flash($message)->warning(); - - return redirect('settings/currencies/' . $currency->id . '/edit'); + return response()->json([ + 'success' => true, + 'error' => false, + 'message' => $message, + 'data' => $currency, + ]); } } diff --git a/resources/views/layouts/wizard.blade.php b/resources/views/layouts/wizard.blade.php index 80bdc3f9a..278b51d48 100644 --- a/resources/views/layouts/wizard.blade.php +++ b/resources/views/layouts/wizard.blade.php @@ -12,7 +12,7 @@ @stack('body_end') diff --git a/resources/views/wizard/currencies/create.blade.php b/resources/views/wizard/currencies/create.blade.php new file mode 100644 index 000000000..2dd871983 --- /dev/null +++ b/resources/views/wizard/currencies/create.blade.php @@ -0,0 +1,30 @@ + + + {{ Form::textGroup('name', trans('general.name'), 'id-card-o', ['required' => 'required'], null, '') }} + + + {{ Form::selectGroup('code', trans('currencies.code'), 'code', $codes, null, ['required' => 'required'], '') }} + + + {{ 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 currency-enabled-radio-group') }} + + + {!! Form::button('', ['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;']) !!} + + + {{ 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')) }} + + \ No newline at end of file diff --git a/resources/views/wizard/currencies/edit.blade.php b/resources/views/wizard/currencies/edit.blade.php index 1a7343eca..ad169fa8f 100644 --- a/resources/views/wizard/currencies/edit.blade.php +++ b/resources/views/wizard/currencies/edit.blade.php @@ -1,38 +1,32 @@ - - {{ $item->name }} - {{ $item->code }} - {{ $item->rate }} + + + {{ Form::textGroup('name', trans('general.name'), 'id-card-o', [], $item->name, '') }} + - @if ($item->enabled) - {{ trans('general.enabled') }} - @else - {{ trans('general.disabled') }} - @endif + {{ Form::selectGroup('code', trans('currencies.code'), 'code', $codes, $item->code, [], '') }} + + + {{ Form::textGroup('rate', trans('currencies.rate'), 'money', [], $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 currency-updated', 'data-loading-text' => trans('general.loading'), 'data-href' => url('wizard/currencies/' . $item->id), 'style' => 'padding: 9px 14px; margin-top: 10px;']) !!} + + + {{ Form::numberGroup('precision', trans('currencies.precision'), 'bullseye', [], $item->precision) }} + + {{ Form::textGroup('symbol', trans('currencies.symbol.symbol'), 'font', [], $item->symbol, '') }} + + {{ Form::selectGroup('symbol_first', trans('currencies.symbol.position'), 'text-width', ['1' => trans('currencies.symbol.before'), '0' => trans('currencies.symbol.after')], $item->symbol_first) }} + + {{ Form::textGroup('decimal_mark', trans('currencies.decimal_mark'), 'columns', [], $item->decimal_mark, '') }} + + {{ Form::textGroup('thousands_separator', trans('currencies.thousands_separator'), 'columns', [], $item->thousands_separator) }} + + {{ Form::radioGroup('default_currency', trans('currencies.default')) }} + + {{ Form::hidden('id', $item->id) }} \ No newline at end of file diff --git a/resources/views/wizard/currencies/index.blade.php b/resources/views/wizard/currencies/index.blade.php index e6ef4001b..1f1016ad1 100644 --- a/resources/views/wizard/currencies/index.blade.php +++ b/resources/views/wizard/currencies/index.blade.php @@ -34,7 +34,7 @@

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

-  {{ trans('general.add_new') }} +  {{ trans('general.add_new') }}
@@ -43,17 +43,17 @@ - + - + @foreach($currencies as $item) - + + + + + + \ 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 @@ - - + + @foreach($taxes as $item) - +
@sortablelink('name', trans('general.name'))@sortablelink('name', trans('general.name')) @sortablelink('rate', trans('currencies.rate')) {{ trans('general.actions') }}
{{ $item->name }}{{ $item->name }} {{ $item->rate }}
+ {{ 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::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;']) !!} +
@sortablelink('name', trans('general.name'))@sortablelink('rate', trans('taxes.rate_percent'))@sortablelink('rate', trans('taxes.rate_percent')) {{ trans('general.actions') }}
{{ $item->name }}{{ $item->name }} {{ $item->rate }}