Skip to content

Commit

Permalink
Wizard Currencies, Taxes, Finish pages changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Oct 24, 2018
1 parent 2ebe1e3 commit ac2ab26
Show file tree
Hide file tree
Showing 16 changed files with 791 additions and 247 deletions.
17 changes: 0 additions & 17 deletions app/Http/Controllers/Wizard/Companies.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,21 +78,4 @@ public function update(Request $request)

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('/');
}
}
140 changes: 138 additions & 2 deletions app/Http/Controllers/Wizard/Currencies.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,38 @@ class Currencies extends Controller
*
* @return Response
*/
public function edit()
public function index()
{
if (setting('general.wizard', false)) {
return redirect('/');
}

$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,
]);
}

/**
Expand Down Expand Up @@ -80,4 +103,117 @@ public function update(Currency $currency, Request $request)
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,
]);
}
}
}
15 changes: 13 additions & 2 deletions app/Http/Controllers/Wizard/Finish.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -23,6 +26,14 @@ public function index()
// 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'));
}
}
119 changes: 118 additions & 1 deletion app/Http/Controllers/Wizard/Taxes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('/');
Expand Down Expand Up @@ -58,4 +76,103 @@ public function update(Tax $tax, Request $request)
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,
]);
}
}
}
11 changes: 11 additions & 0 deletions app/Traits/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,17 @@ public function getSearchModules($data = [])
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();
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en-GB/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@
'disable' => 'Disable',
'select_all' => 'Select All',
'unselect_all' => 'Unselect All',
'go_to' => 'Go to :name',
'title' => [
'new' => 'New :type',
'edit' => 'Edit :type',
Expand Down
2 changes: 2 additions & 0 deletions resources/lang/en-GB/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
'no_apps' => 'There are no apps in this category, yet.',
'developer' => 'Are you a developer? <a href="https://akaunting.com/blog/akaunting-app-store" target="_blank">Here</a> you can learn how to create an app and start selling today!',

'recommended_apps' => 'Recommended Apps',

'about' => 'About',

'added' => 'Added',
Expand Down
4 changes: 0 additions & 4 deletions resources/views/layouts/wizard.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@

<!-- Site wrapper -->
<div class="wrapper">
@include('partials.wizard.header')

@include('partials.wizard.content')

@include('partials.wizard.footer')
</div>

@stack('body_end')
Expand Down

0 comments on commit ac2ab26

Please sign in to comment.