-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82a9b7d
commit 97f43a0
Showing
33 changed files
with
1,335 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ public function __construct($menu) | |
{ | ||
$this->menu = $menu; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ public function __construct($bill) | |
{ | ||
$this->bill = $bill; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ public function __construct($bill) | |
{ | ||
$this->bill = $bill; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ public function __construct($company) | |
{ | ||
$this->company = $company; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ public function __construct($menu) | |
{ | ||
$this->menu = $menu; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ public function __construct($invoice) | |
{ | ||
$this->invoice = $invoice; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ public function __construct($invoice) | |
{ | ||
$this->invoice = $invoice; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ public function __construct($invoice) | |
{ | ||
$this->invoice = $invoice; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,4 @@ public function __construct($alias, $company_id) | |
$this->alias = $alias; | ||
$this->company_id = $company_id; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,4 @@ public function __construct($alias, $old, $new) | |
$this->old = $old; | ||
$this->new = $new; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Wizard; | ||
|
||
use Illuminate\Routing\Controller; | ||
use App\Models\Common\Company; | ||
|
||
class Companies extends Controller | ||
{ | ||
/** | ||
* Show the form for creating a new resource. | ||
* | ||
* @return Response | ||
*/ | ||
public function edit() | ||
{ | ||
if (setting(setting('general.wizard', false))) { | ||
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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
|
||
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; | ||
use App\Models\Setting\Currency; | ||
|
||
class Currencies extends Controller | ||
{ | ||
/** | ||
* Show the form for editing the specified resource. | ||
* | ||
* @param Currency $currency | ||
* | ||
* @return Response | ||
*/ | ||
public function edit(Currency $currency) | ||
{ | ||
// 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; | ||
} | ||
|
||
// 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'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Wizard; | ||
|
||
use Illuminate\Routing\Controller; | ||
use App\Models\Common\Company; | ||
|
||
class Finish extends Controller | ||
{ | ||
/** | ||
* Show the form for creating a new resource. | ||
* | ||
* @return Response | ||
*/ | ||
public function edit() | ||
{ | ||
if (setting(setting('general.wizard', false))) { | ||
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'); | ||
} | ||
} |
Oops, something went wrong.