Skip to content

Commit

Permalink
'Wizard edited for spa'
Browse files Browse the repository at this point in the history
  • Loading branch information
brkcvn committed May 20, 2021
1 parent cdfe846 commit 79f91ea
Show file tree
Hide file tree
Showing 25 changed files with 1,857 additions and 532 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/Wizard/Companies.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function edit()
{
$company = Company::find(company_id());

return view('wizard.companies.edit', compact('company'));
return $this->response('wizard.companies.edit', compact('company'));
}

/**
Expand Down
29 changes: 16 additions & 13 deletions app/Http/Controllers/Wizard/Currencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function index()
$codes[$key] = $key;
}

return view('wizard.currencies.index', compact('currencies', 'codes'));
return $this->response('wizard.currencies.index', compact('currencies', 'codes'));
}

/**
Expand All @@ -58,19 +58,21 @@ public function store(Request $request)
{
$response = $this->ajaxDispatch(new CreateCurrency($request));

$response['redirect'] = route('wizard.currencies.index');
//$response['redirect'] = route('wizard.currencies.index');

if ($response['success']) {

$message = trans('messages.success.added', ['type' => trans_choice('general.currencies', 1)]);

flash($message)->success();
//flash($message)->success();
} else {
$message = $response['message'];

flash($message)->error()->important();
//flash($message)->error()->important();
}

$response['message'] = $message;

return response()->json($response);
}

Expand All @@ -86,18 +88,20 @@ public function update(Currency $currency, Request $request)
{
$response = $this->ajaxDispatch(new UpdateCurrency($currency, $request));

$response['redirect'] = route('wizard.currencies.index');
// $response['redirect'] = route('wizard.currencies.index');

if ($response['success']) {
$message = trans('messages.success.updated', ['type' => $currency->name]);

flash($message)->success();
// flash($message)->success();
} else {
$message = $response['message'];

flash($message)->error()->important();
// flash($message)->error()->important();
}

$response['message'] = $message;

return response()->json($response);
}

Expand All @@ -110,20 +114,19 @@ public function update(Currency $currency, Request $request)
*/
public function destroy(Currency $currency)
{
$response = $this->ajaxDispatch(new DeleteCurrency($currency));
$currency_id = $currency->id;

$response['redirect'] = route('wizard.currencies.index');
$response = $this->ajaxDispatch(new DeleteCurrency($currency));

if ($response['success']) {
$message = trans('messages.success.deleted', ['type' => $currency->name]);

flash($message)->success();
} else {
$message = $response['message'];

flash($message)->error()->important();
}

$response['currency_id'] = $currency_id;
$response['message'] = $message;

return response()->json($response);
}
}
140 changes: 140 additions & 0 deletions app/Http/Controllers/Wizard/Data.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<?php

namespace App\Http\Controllers\Wizard;

use App\Abstracts\Http\Controller;

use Akaunting\Money\Currency as MoneyCurrency;
use App\Models\Setting\Currency;
use App\Models\Setting\Tax;
use App\Traits\Modules;
use App\Models\Common\Company;

class Data extends Controller
{
use Modules;

/**
* Instantiate a new controller instance.
*/
public function __construct()
{
// Add CRUD permission check
$this->middleware('permission:create-common-companies')->only('create', 'store', 'duplicate', 'import');
$this->middleware('permission:read-common-companies')->only('index', 'show', 'edit', 'export');
$this->middleware('permission:update-common-companies')->only('update', 'enable', 'disable');
$this->middleware('permission:delete-common-companies')->only('destroy');
}

/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function index()
{
$translations = [
'companies' => [
'title' => trans_choice('general.companies', 1),
'api_key' => trans('modules.api_key'),
'form_enter' => trans('general.form.enter'),
'get_api_key' => trans('modules.get_api_key'),
'tax_number' => trans('general.tax_number'),
'financial_start' => trans('settings.localisation.financial_start'),
'address' => trans('settings.company.address'),
'logo' => trans('settings.company.logo'),
'skip' => trans('general.skip'),
'save' => trans('general.save'),
],

'currencies' => [
'title' => trans_choice('general.currencies', 2),
'add_new' => trans('general.add_new'),
'name' => trans('general.name'),
'code' => trans('currencies.code'),
'rate' => trans('currencies.rate'),
'enabled' => trans('general.enabled'),
'actions' => trans('general.actions') ,
'yes' => trans('general.yes'),
'no' => trans('general.no'),
'edit' => trans('general.edit'),
'delete' => trans('general.delete'),
'save' => trans('general.save'),
'precision' => trans('currencies.precision'),
'symbol' => trans('currencies.symbol.symbol'),
'position' => trans('currencies.symbol.position'),
'decimal_mark' => trans('currencies.decimal_mark'),
'thousands_separator' => trans('currencies.thousands_separator'),
'previous' => trans('pagination.previous'),
'next' => trans('pagination.next'),
'delete_confirm' => trans('general.delete_confirm'),
'cancel' => trans('general.cancel'),
],

'taxes' => [
'title' => trans_choice('general.taxes', 2),
'add_new' => trans('general.add_new'),
'name' => trans('general.name'),
'rate_percent' => trans('taxes.rate_percent'),
'enabled' => trans('general.enabled'),
'actions' => trans('general.actions'),
'yes' => trans('general.yes'),
'no' => trans('general.no'),
'edit' => trans('general.edit'),
'delete' => trans('general.delete'),
'name' => trans('general.name'),
'rate' => trans('currencies.rate'),
'enabled' => trans('general.enabled'),
'save' => trans('general.save'),
'previous' => trans('pagination.previous'),
'next' => trans('pagination.next'),
'cancel' => trans('general.cancel'),
],

'finish' => [
'title' => trans_choice('general.finish', 1),
'recommended_apps' => trans('modules.recommended_apps'),
'no_apps' => trans('modules.no_apps'),
'developer' => trans('modules.developer'),
'previous' => trans('pagination.previous'),
'go_to_dashboard' => trans('general.go_to_dashboard'),
]
];

$currencies = Currency::collect();

// Prepare codes
$codes = [];
$money_currencies = MoneyCurrency::getCurrencies();

foreach ($money_currencies as $key => $item) {
$codes[$key] = $key;
}

$taxes = Tax::collect();

$data = [
'query' => [
'limit' => 4
]
];

$modules = $this->getFeaturedModules($data);

$company = Company::find(company_id());

return response()->json([
'success' => true,
'errors' => false,
'message' => 'Get languages text..',
'data' => [
'currencies' => $currencies,
'currency_codes' => $codes,
'taxes' => $taxes,
'modules' => $modules,
'translations' => $translations,
'companies' => $company,
],
]);
}
}
19 changes: 17 additions & 2 deletions app/Http/Controllers/Wizard/Finish.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Controllers\Wizard;

use Illuminate\Routing\Controller;
use App\Abstracts\Http\Controller;
use App\Traits\Modules;

class Finish extends Controller
Expand Down Expand Up @@ -38,6 +38,21 @@ public function index()

$modules = $this->getFeaturedModules($data);

return view('wizard.finish.index', compact('modules'));
return $this->response('wizard.finish.index', compact('modules'));
}

/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function update()
{
setting()->set('wizard.completed', 1);

// Save all settings
setting()->save();

return response()->json([]);
}
}
27 changes: 17 additions & 10 deletions app/Http/Controllers/Wizard/Taxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function index()
{
$taxes = Tax::collect();

return view('wizard.taxes.index', compact('taxes'));
return $this->response('wizard.taxes.index', compact('taxes'));
}

/**
Expand All @@ -46,17 +46,18 @@ public function store(Request $request)
{
$response = $this->ajaxDispatch(new CreateTax($request));

$response['redirect'] = route('wizard.taxes.index');
// $response['redirect'] = route('wizard.taxes.index');

if ($response['success']) {
$message = trans('messages.success.added', ['type' => trans_choice('general.taxes', 1)]);

flash($message)->success();
// flash($message)->success();
} else {
$message = $response['message'];

flash($message)->error()->important();
// flash($message)->error()->important();
}
$response['message'] = $message;

return response()->json($response);
}
Expand All @@ -73,18 +74,20 @@ public function update(Tax $tax, Request $request)
{
$response = $this->ajaxDispatch(new UpdateTax($tax, $request));

$response['redirect'] = route('wizard.taxes.index');
// $response['redirect'] = route('wizard.taxes.index');

if ($response['success']) {
$message = trans('messages.success.updated', ['type' => $tax->name]);

flash($message)->success();
// flash($message)->success();
} else {
$message = $response['message'];

flash($message)->error()->important();
// flash($message)->error()->important();
}

$response['message'] = $message;

return response()->json($response);
}

Expand All @@ -97,19 +100,23 @@ public function update(Tax $tax, Request $request)
*/
public function destroy(Tax $tax)
{
$tax_id = $tax->id;

$response = $this->ajaxDispatch(new DeleteTax($tax));

$response['redirect'] = route('wizard.taxes.index');
// $response['redirect'] = route('wizard.taxes.index');

if ($response['success']) {
$message = trans('messages.success.deleted', ['type' => $tax->name]);

flash($message)->success();
// flash($message)->success();
} else {
$message = $response['message'];

flash($message)->error()->important();
// flash($message)->error()->important();
}
$response['tax_id'] = $tax_id;
$response['message'] = $message;

return response()->json($response);
}
Expand Down

0 comments on commit 79f91ea

Please sign in to comment.