From db4adf399d9352f27a042915ea833499946516d0 Mon Sep 17 00:00:00 2001 From: James Cole Date: Tue, 28 Apr 2015 15:26:30 +0200 Subject: [PATCH] Cleaning up. --- app/Http/Controllers/AccountController.php | 1 + app/Http/Controllers/BillController.php | 1 + app/Http/Controllers/BudgetController.php | 11 ++-- app/Http/Controllers/CategoryController.php | 1 + app/Http/Controllers/Controller.php | 11 ++++ app/Http/Controllers/CurrencyController.php | 2 +- app/Http/Controllers/HelpController.php | 4 -- app/Http/Controllers/HomeController.php | 2 +- app/Http/Controllers/JsonController.php | 3 +- app/Http/Controllers/PiggyBankController.php | 1 + .../Controllers/PreferencesController.php | 2 +- app/Http/Controllers/ProfileController.php | 5 +- app/Http/Controllers/TagController.php | 11 ++-- .../Controllers/TransactionController.php | 3 +- resources/views/list/journals-full.blade.php | 64 +++++++++++-------- 15 files changed, 75 insertions(+), 47 deletions(-) diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index db387e39ad..3bd0736110 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -26,6 +26,7 @@ class AccountController extends Controller */ public function __construct() { + parent::__construct(); View::share('mainTitleIcon', 'fa-credit-card'); View::share('title', 'Accounts'); } diff --git a/app/Http/Controllers/BillController.php b/app/Http/Controllers/BillController.php index f509e1ddb5..ad1075ea8e 100644 --- a/app/Http/Controllers/BillController.php +++ b/app/Http/Controllers/BillController.php @@ -29,6 +29,7 @@ class BillController extends Controller */ public function __construct() { + parent::__construct(); View::share('title', 'Bills'); View::share('mainTitleIcon', 'fa-calendar-o'); } diff --git a/app/Http/Controllers/BudgetController.php b/app/Http/Controllers/BudgetController.php index 92078806b0..f72ec26884 100644 --- a/app/Http/Controllers/BudgetController.php +++ b/app/Http/Controllers/BudgetController.php @@ -29,8 +29,10 @@ class BudgetController extends Controller */ public function __construct() { + parent::__construct(); View::share('title', 'Budgets'); View::share('mainTitleIcon', 'fa-tasks'); + View::share('hideBudgets', true); } /** @@ -185,12 +187,11 @@ class BudgetController extends Controller return view('error')->with('message', 'Invalid selection.'); } - $hideBudget = true; // used in transaction list. - $journals = $repository->getJournals($budget, $repetition); - $limits = !is_null($repetition->id) ? [$repetition->budgetLimit] : $repository->getBudgetLimits($budget); - $subTitle = !is_null($repetition->id) ? e($budget->name) . ' in ' . $repetition->startdate->format('F Y') : e($budget->name); + $journals = $repository->getJournals($budget, $repetition); + $limits = !is_null($repetition->id) ? [$repetition->budgetLimit] : $repository->getBudgetLimits($budget); + $subTitle = !is_null($repetition->id) ? e($budget->name) . ' in ' . $repetition->startdate->format('F Y') : e($budget->name); - return view('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle', 'hideBudget')); + return view('budgets.show', compact('limits', 'budget', 'repetition', 'journals', 'subTitle')); } /** diff --git a/app/Http/Controllers/CategoryController.php b/app/Http/Controllers/CategoryController.php index 09b7b1370d..0225cdb0a1 100644 --- a/app/Http/Controllers/CategoryController.php +++ b/app/Http/Controllers/CategoryController.php @@ -26,6 +26,7 @@ class CategoryController extends Controller */ public function __construct() { + parent::__construct(); View::share('title', 'Categories'); View::share('mainTitleIcon', 'fa-bar-chart'); } diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index fb7b363590..1af8d4b562 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -3,6 +3,7 @@ use Illuminate\Foundation\Bus\DispatchesCommands; use Illuminate\Foundation\Validation\ValidatesRequests; use Illuminate\Routing\Controller as BaseController; +use View; /** * Class Controller @@ -14,4 +15,14 @@ abstract class Controller extends BaseController use DispatchesCommands, ValidatesRequests; + /** + * + */ + public function __construct() + { + View::share('hideBudgets', false); + View::share('hideCategories', false); + View::share('hideBills', false); + View::share('hideTags', false); + } } diff --git a/app/Http/Controllers/CurrencyController.php b/app/Http/Controllers/CurrencyController.php index c0b2fd4258..33e100ca6d 100644 --- a/app/Http/Controllers/CurrencyController.php +++ b/app/Http/Controllers/CurrencyController.php @@ -27,7 +27,7 @@ class CurrencyController extends Controller */ public function __construct() { - + parent::__construct(); View::share('title', 'Currencies'); View::share('mainTitleIcon', 'fa-usd'); } diff --git a/app/Http/Controllers/HelpController.php b/app/Http/Controllers/HelpController.php index 414e015944..d8072669a8 100644 --- a/app/Http/Controllers/HelpController.php +++ b/app/Http/Controllers/HelpController.php @@ -1,12 +1,8 @@ get(); + $list = $tagRepository->get(); $return = []; foreach ($list as $entry) { $return[] = $entry->tag; diff --git a/app/Http/Controllers/PiggyBankController.php b/app/Http/Controllers/PiggyBankController.php index 82960a5dc9..ffd878d59f 100644 --- a/app/Http/Controllers/PiggyBankController.php +++ b/app/Http/Controllers/PiggyBankController.php @@ -32,6 +32,7 @@ class PiggyBankController extends Controller */ public function __construct() { + parent::__construct(); View::share('title', 'Piggy banks'); View::share('mainTitleIcon', 'fa-sort-amount-asc'); } diff --git a/app/Http/Controllers/PreferencesController.php b/app/Http/Controllers/PreferencesController.php index 7df980e19f..84d2901104 100644 --- a/app/Http/Controllers/PreferencesController.php +++ b/app/Http/Controllers/PreferencesController.php @@ -20,7 +20,7 @@ class PreferencesController extends Controller */ public function __construct() { - + parent::__construct(); View::share('title', 'Preferences'); View::share('mainTitleIcon', 'fa-gear'); } diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 2c61ff4bdd..227ca9fbe4 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -49,7 +49,8 @@ class ProfileController extends Controller /** * */ - public function postDeleteAccount(DeleteAccountFormRequest $request) { + public function postDeleteAccount(DeleteAccountFormRequest $request) + { // old, new1, new2 if (!Hash::check($request->get('password'), Auth::user()->password)) { Session::flash('error', 'Invalid password!'); @@ -60,11 +61,11 @@ class ProfileController extends Controller // DELETE! Auth::user()->delete(); Session::flush(); + return Redirect::route('index'); } - /** * @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View */ diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.php index 2c0a46e271..990dd0a84d 100644 --- a/app/Http/Controllers/TagController.php +++ b/app/Http/Controllers/TagController.php @@ -10,11 +10,11 @@ use FireflyIII\Models\Tag; use FireflyIII\Repositories\Tag\TagRepositoryInterface; use Input; use Preferences; +use Redirect; use Response; use Session; -use View; use URL; -use Redirect; +use View; /** * Class TagController @@ -31,7 +31,7 @@ class TagController extends Controller */ public function __construct() { - + parent::__construct(); View::share('title', 'Tags'); View::share('mainTitleIcon', 'fa-tags'); $tagOptions = [ @@ -182,7 +182,7 @@ class TagController extends Controller ]; $repository->store($data); - Session::flash('success','The tag has been created!'); + Session::flash('success', 'The tag has been created!'); if (intval(Input::get('create_another')) === 1) { // set value so create routine will not overwrite URL: @@ -199,7 +199,8 @@ class TagController extends Controller /** * @param Tag $tag */ - public function update(Tag $tag, TagFormRequest $request, TagRepositoryInterface $repository) { + public function update(Tag $tag, TagFormRequest $request, TagRepositoryInterface $repository) + { if (Input::get('setTag') == 'true') { $latitude = strlen($request->get('latitude')) > 0 ? $request->get('latitude') : null; $longitude = strlen($request->get('longitude')) > 0 ? $request->get('longitude') : null; diff --git a/app/Http/Controllers/TransactionController.php b/app/Http/Controllers/TransactionController.php index 87051ad93a..dc777ba086 100644 --- a/app/Http/Controllers/TransactionController.php +++ b/app/Http/Controllers/TransactionController.php @@ -28,6 +28,7 @@ class TransactionController extends Controller */ public function __construct() { + parent::__construct(); View::share('title', 'Transactions'); View::share('mainTitleIcon', 'fa-repeat'); } @@ -162,7 +163,7 @@ class TransactionController extends Controller $preFilled['account_from_id'] = $transactions[1]->account->id; $preFilled['account_to_id'] = $transactions[0]->account->id; - Session::flash('preFilled',$preFilled); + Session::flash('preFilled', $preFilled); // put previous url in session if not redirect from store (not "return_to_edit"). if (Session::get('transactions.edit.fromUpdate') !== true) { diff --git a/resources/views/list/journals-full.blade.php b/resources/views/list/journals-full.blade.php index c44921e135..239e1b4642 100644 --- a/resources/views/list/journals-full.blade.php +++ b/resources/views/list/journals-full.blade.php @@ -9,13 +9,18 @@ Date From To - @if(!isset($hideBudget) || (isset($hideBudget) && $hideBudget=== false)) + {{-- Hide budgets? --}} + @if($hideBudgets) @endif - @if(!isset($hideCategory) || (isset($hideCategory) && $hideCategory=== false)) + + {{-- Hide categories? --}} + @if($hideCategories) @endif - @if(!isset($hideBill) || (isset($hideBill) && $hideBill=== false)) + + {{-- Hide bills? --}} + @if(!$hideBills) @endif @@ -29,7 +34,7 @@   {{{$journal->description}}} - Invalid journal: Found {{$journal->transactions()->count()}} transaction(s) + Invalid journal: Found {{$journal->transactions()->count()}} transaction(s) @else @@ -60,14 +65,17 @@ {{{$journal->description}}} - @if($journal->transactiontype->type == 'Withdrawal') + @if(!$hideTags) + {{-- If relevant, refer to tag instead of amount. --}} + + {!! Amount::formatJournal($journal) !!} + @else {!! Amount::formatJournal($journal) !!} - @endif - @if($journal->transactiontype->type == 'Deposit') - {!! Amount::formatJournal($journal) !!} - @endif - @if($journal->transactiontype->type == 'Transfer') - {{Amount::formatTransaction($journal->transactions[1],false)}} @endif @@ -87,7 +95,9 @@ {{{$journal->transactions[1]->account->name}}} @endif - @if(!isset($hideBudget) || (isset($hideBudget) && $hideBudget=== false)) + + {{-- Do NOT hide the budget? --}} + @if(!$hideBudgets) budgets[0]) ? $journal->budgets[0] : null; ?> @if($budget) @@ -95,20 +105,24 @@ @endif @endif - @if(!isset($hideCategory) || (isset($hideCategory) && $hideCategory=== false)) - - categories[0]) ? $journal->categories[0] : null; ?> - @if($category) - {{{$category->name}}} - @endif - + + {{-- Do NOT hide the category? --}} + @if(!$hideCategories) + + categories[0]) ? $journal->categories[0] : null; ?> + @if($category) + {{{$category->name}}} + @endif + @endif - @if(!isset($hideBill) || (isset($hideBill) && $hideBill=== false)) - - @if($journal->bill) - {{{$journal->bill->name}}} - @endif - + + {{-- Do NOT hide the bill? --}} + @if(!$hideBills) + + @if($journal->bill) + {{{$journal->bill->name}}} + @endif + @endif