Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Some new help functions, some cleanup.
James Colef6afb46f6fa5
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.phpindex 8c89dda1f8..3d442b503d 100644--- a/app/controllers/AccountController.php+++ b/app/controllers/AccountController.php@@ -229,13 +229,16 @@ class AccountController extends BaseControllercase 'Asset account':case 'Default account':$subTitleIcon = 'fa-money';+ $what = 'asset';break;case 'Expense account':case 'Beneficiary account':$subTitleIcon = 'fa-shopping-cart';+ $what = 'expense';break;case 'Revenue account':$subTitleIcon = 'fa-download';+ $what = 'revenue';break;}@@ -254,7 +257,7 @@ class AccountController extends BaseController}- return View::make('accounts.show', compact('account', 'view', 'subTitleIcon', 'journals'))->with('account', $account)->with(+ return View::make('accounts.show', compact('account', 'what', 'view', 'subTitleIcon', 'journals'))->with('account', $account)->with('subTitle', 'Details for ' . strtolower($account->accountType->type) . ' "' . $account->name . '"');}diff --git a/app/controllers/HelpController.php b/app/controllers/HelpController.phpnew file mode 100644index 0000000000..4fee5b9c3a--- /dev/null+++ b/app/controllers/HelpController.php@@ -0,0 +1,46 @@+<?php++class HelpController extends BaseController+{+ public function show($route)+ {+ // no valid route+ if (!Route::has($route)) {+ $helpText = '<p>There is no help for this route!</p>';+ $helpTitle = 'Help';++ return Response::json(['title' => $helpTitle, 'text' => $helpText]);+ }++ // content in cache+ if (Cache::has('help.' . $route . '.title') && Cache::has('help.' . $route . '.text')) {+ $helpText = Cache::get('help.' . $route . '.text');+ $helpTitle = Cache::get('help.' . $route . '.title');++ return Response::json(['title' => $helpTitle, 'text' => $helpText]);+ }++ // get the help-content from Github:+ $URL = 'https://raw.githubusercontent.com/JC5/firefly-iii-help/master/' . e($route) . '.md';+ try {+ $content = file_get_contents($URL);+ } catch (ErrorException $e) {+ $content = '<p>There is no help for this route.</p>';+ }+ if (strlen($content) > 0) {+ $helpText = \Michelf\Markdown::defaultTransform($content);+ $helpTitle = $route;++ Cache::put('help.' . $route . '.text', $helpText, 10080); // a week.+ Cache::put('help.' . $route . '.title', $helpTitle, 10080);++ return Response::json(['title' => $helpTitle, 'text' => $helpText]);+ }++ $helpText = '<p>There is no help for this route!</p>';+ $helpTitle = 'Help';++ return Response::json(['title' => $helpTitle, 'text' => $helpText]);++ }+}\ No newline at end of filediff --git a/app/routes.php b/app/routes.phpindex 3c10a8f1a5..52899b07cc 100644--- a/app/routes.php+++ b/app/routes.php@@ -23,6 +23,7 @@ Route::bind('user_id', Auth::user()->id)->first();}+return null;});@@ -34,6 +35,7 @@ Route::bind(return RecurringTransaction::where('id', $value)->where('user_id', Auth::user()->id)->first();}+return null;});@@ -43,6 +45,7 @@ Route::bind(return Budget::where('id', $value)->where('user_id', Auth::user()->id)->first();}+return null;});@@ -53,6 +56,7 @@ Route::bind(return Component::where('id', $value)->where('user_id', Auth::user()->id)->first();}+return null;});@@ -63,6 +67,7 @@ Route::bind(return Reminder::where('id', $value)->where('user_id', Auth::user()->id)->first();}+return null;});@@ -73,6 +78,7 @@ Route::bind(return Category::where('id', $value)->where('user_id', Auth::user()->id)->first();}+return null;});@@ -83,6 +89,7 @@ Route::bind(return TransactionJournal::where('id', $value)->where('user_id', Auth::user()->id)->first();}+return null;});@@ -95,6 +102,7 @@ Route::bind('components', 'components.id', '=', 'limits.component_id')->where('components.class', 'Budget')->where('components.user_id', Auth::user()->id)->first(['limit_repetitions.*']);}+return null;});@@ -104,10 +112,11 @@ Route::bind(if (Auth::check()) {return Piggybank::where('piggybanks.id', $value)- ->leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')- ->where('accounts.user_id', Auth::user()->id)- ->where('repeats',0)->first(['piggybanks.*']);+ ->leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')+ ->where('accounts.user_id', Auth::user()->id)+ ->where('repeats', 0)->first(['piggybanks.*']);}+return null;});@@ -119,8 +128,9 @@ Route::bind(where('piggybanks.id', $value)->leftJoin('accounts', 'accounts.id', '=', 'piggybanks.account_id')->where('accounts.user_id', Auth::user()->id)- ->where('repeats',1)->first(['piggybanks.*']);+ ->where('repeats', 1)->first(['piggybanks.*']);}+return null;});@@ -172,11 +182,14 @@ Route::group(Route::get('/chart/recurring/{recurring}', ['uses' => 'GoogleChartController@recurringOverview']);Route::get('/chart/reports/budgets/{year}', ['uses' => 'GoogleChartController@budgetsReportChart']);Route::get('/chart/budget/{budget}/{limitrepetition}', ['uses' => 'GoogleChartController@budgetLimitSpending']);- Route::get('/chart/piggyhistory/{piggybank}',['uses' => 'GoogleChartController@piggyBankHistory']);+ Route::get('/chart/piggyhistory/{piggybank}', ['uses' => 'GoogleChartController@piggyBankHistory']);// google chart for components (categories + budgets combined)Route::get('/chart/component/{component}/spending/{year}', ['uses' => 'GoogleChartController@componentsAndSpending']);+ // help controller+ Route::get('/help/{route}', ['uses' => 'HelpController@show', 'as' => 'help.show']);+// home controllerRoute::get('/', ['uses' => 'HomeController@index', 'as' => 'index']);Route::get('/flush', ['uses' => 'HomeController@flush', 'as' => 'flush']); # even though nothing is cached.@@ -224,10 +237,10 @@ Route::group(Route::get('/reports/unbalanced/{year}/{month}', ['uses' => 'ReportController@unbalanced', 'as' => 'reports.unbalanced']);// reminder controller- Route::get('/reminders/{reminder}',['uses' => 'ReminderController@show','as' => 'reminders.show']);- Route::get('/reminders/{reminder}/dismiss',['uses' => 'ReminderController@dismiss','as' => 'reminders.dismiss']);- Route::get('/reminders/{reminder}/notnow',['uses' => 'ReminderController@notnow','as' => 'reminders.notnow']);- Route::get('/reminders/{reminder}/act',['uses' => 'ReminderController@act','as' => 'reminders.act']);+ Route::get('/reminders/{reminder}', ['uses' => 'ReminderController@show', 'as' => 'reminders.show']);+ Route::get('/reminders/{reminder}/dismiss', ['uses' => 'ReminderController@dismiss', 'as' => 'reminders.dismiss']);+ Route::get('/reminders/{reminder}/notnow', ['uses' => 'ReminderController@notnow', 'as' => 'reminders.notnow']);+ Route::get('/reminders/{reminder}/act', ['uses' => 'ReminderController@act', 'as' => 'reminders.act']);// search controller:Route::get('/search', ['uses' => 'SearchController@index', 'as' => 'search']);diff --git a/app/views/accounts/index.blade.php b/app/views/accounts/index.blade.phpindex 54a5734050..c98c6e38b1 100644--- a/app/views/accounts/index.blade.php+++ b/app/views/accounts/index.blade.php@@ -1,5 +1,6 @@@extends('layouts.default')@section('content')+{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $what) }}<div class="row"><div class="col-lg-12 col-md-12 col-sm-12"><div class="panel panel-default">diff --git a/app/views/accounts/show.blade.php b/app/views/accounts/show.blade.phpindex 8fb7e70507..adc219990d 100644--- a/app/views/accounts/show.blade.php+++ b/app/views/accounts/show.blade.php@@ -1,5 +1,6 @@@extends('layouts.default')@section('content')+{{ Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $what, $account) }}<div class="row"><div class="col-lg-8 col-md-6 col-sm-12"><div class="panel panel-default">@@ -20,7 +21,6 @@</div><div class="panel-body"><p>- <!-- TODO clean up these methods and everything associated with them. -->@if($view == 'all')<a href="{{route('accounts.show',$account->id)}}/session" class="btn btn-default">Stick to date-range</a>@elsediff --git a/app/views/budgets/index.blade.php b/app/views/budgets/index.blade.phpindex b8e580300e..214adc82ec 100644--- a/app/views/budgets/index.blade.php+++ b/app/views/budgets/index.blade.php@@ -130,55 +130,6 @@</div></div>---@foreach($budgets as $budget)-{{---<div class="row">- <div class="col-lg-9 col-sm-8 col-md-8">- <div class="row">- <div class="col-lg-3 col-md-4 col-sm-4">- {{$budget->name}}- </div>- <div class="col-lg-7 col-md-4 col-sm-4">-- </div>- <div class="col-lg-2 col-md-4 col-sm-3">- <span id="budget-range-display-{{$budget->id}}" data-id="{{$budget->id}}"></span>- </div>- </div>- <div class="row">- <div class="col-lg-7 col-lg-offset-3 col-md-4 col-md-offset-4 col-sm-4 col-sm-offset-4">- @if($budget->pct > 0)- <!-- display a progress bar. -->- <div class="progress" id="budget-progress-{{$budget->id}}" data-spent="{{$budget->spent}}" data-amount="{{$budget->limit}}">-- </div>- @else- <!-- do NOT display a progress bar. -->- <div style="display:none;" class="progress" id="budget-progress-{{$budget->id}}" data-spent="{{$budget->spent}}" data-amount="{{$budget->limit}}">-- </div>- @endif- <!--- @if($budget->currentRep)- @if($budget->currentRep->amount <= $budget->spent)- Overspent on budget (budgeted: {{$budget->currentRep->amount}}, spent: {{$budget->spent}}).- @else- NOT overspent on budget (budgeted: {{$budget->currentRep->amount}}, spent: {{$budget->spent}}).-- @endif- @else- No limit.- @endif- -->- </div>- </div>- </div>-</div>---}}-@endforeach-<!-- DIALOG --><div class="modal fade" id="monthlyBudgetModal"></div><!-- /.modal -->diff --git a/app/views/help/show.blade.php b/app/views/help/show.blade.phpnew file mode 100644index 0000000000..e864585fd5--- /dev/null+++ b/app/views/help/show.blade.php@@ -0,0 +1,14 @@+<div class="modal-dialog">+ <div class="modal-content">+ <div class="modal-header">+ <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>+ <h4 class="modal-title" id="helpTitle">{{$helpTitle}}</h4>+ </div>+ <div class="modal-body" id="helpBody">+ {{$helpText}}+ </div>+ <div class="modal-footer">+ <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>+ </div>+ </div>+</div>diff --git a/app/views/index.blade.php b/app/views/index.blade.phpindex 9fc7e6766d..7ec4ff6bea 100644--- a/app/views/index.blade.php+++ b/app/views/index.blade.php@@ -1,6 +1,6 @@@extends('layouts.default')@section('content')-{{ Breadcrumbs::render('home') }}+{{ Breadcrumbs::renderIfExists() }}@if($count == 0)<div class="row"><div class="col-lg-12 col-md-12 col-sm-12">diff --git a/app/views/layouts/default.blade.php b/app/views/layouts/default.blade.phpindex 47878d1e04..2df8600ca6 100644--- a/app/views/layouts/default.blade.php+++ b/app/views/layouts/default.blade.php@@ -1,5 +1,6 @@<!DOCTYPE html><html lang="en">+<?php $r = Route::getCurrentRoute()->getName();?><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge">@@ -47,7 +48,7 @@{{$subTitle}}</small>@endif- <small class="pull-right"><a href="#"><i class="fa fa-question-circle"></i></a></small>+ <small class="pull-right"><a href="#" id="help" data-route="{{{Route::getCurrentRoute()->getName()}}}"><i data-route="{{{Route::getCurrentRoute()->getName()}}}" class="fa fa-question-circle"></i></a></small></h1></div>@@ -55,9 +56,26 @@</div>@include('partials.flashes')-@yield('content')+ <!-- this modal will contain the help-text -->+ <div class="modal fade" id="helpModal">+ <div class="modal-dialog">+ <div class="modal-content">+ <div class="modal-header">+ <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>+ <h4 class="modal-title" id="helpTitle">Please hold...</h4>+ </div>+ <div class="modal-body" id="helpBody">+ <i class="fa fa-refresh fa-spin"></i>+ </div>+ <div class="modal-footer">+ <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>+ </div>+ </div>+ </div>+ </div><!-- /.modal -->+</div></div>@@ -65,6 +83,7 @@{{HTML::script('assets/javascript/bootstrap/bootstrap.min.js')}}{{HTML::script('assets/javascript/metisMenu/jquery.metisMenu.min.js')}}{{HTML::script('assets/javascript/sb-admin/sb-admin-2.js')}}+{{HTML::script('assets/javascript/firefly/help.js')}}@yield('scripts')</body></html>\ No newline at end of filediff --git a/app/views/partials/menu.blade.php b/app/views/partials/menu.blade.phpindex 9eb70f8e36..c68c2251a5 100644--- a/app/views/partials/menu.blade.php+++ b/app/views/partials/menu.blade.php@@ -64,7 +64,6 @@<!-- /.dropdown --></ul><!-- /.navbar-top-links -->- <?php $r = Route::getCurrentRoute()->getName();?><div class="navbar-default sidebar" role="navigation"><div class="sidebar-nav navbar-collapse"><ul class="nav" id="side-menu">diff --git a/app/views/user/register.blade.php b/app/views/user/register.blade.phpindex 0b012cb628..c4cb0fb74a 100644--- a/app/views/user/register.blade.php+++ b/app/views/user/register.blade.php@@ -12,7 +12,7 @@All instructions will be sent to you.</p>{{Form::open(['id' => 'register'])}}- <div class="form-group">+ <div class="form-group"> <!-- {{App::environment()}} --><label for="inputEmail">Email address</label><input type="email" class="form-control" id="inputEmail" name="email" placeholder="Enter email"></div>diff --git a/public/assets/javascript/firefly/help.js b/public/assets/javascript/firefly/help.jsnew file mode 100644index 0000000000..b40c59479c--- /dev/null+++ b/public/assets/javascript/firefly/help.js@@ -0,0 +1,21 @@+$(function () {+ $('#help').click(showHelp);+});++function showHelp(e) {+ target = $(e.target);+ route = target.data('route');+ //+ $('#helpBody').html('<i class="fa fa-refresh fa-spin"></i>');+ $('#helpTitle').html('Please hold...');++ $('#helpModal').modal('show');+ $.getJSON('help/' + encodeURI(route)).success(function (data) {+ $('#helpBody').html(data.text);+ $('#helpTitle').html(data.title);+ }).fail(function () {+ $('#helpBody').html('<p class="text-danger">No help text could be found.</p>');+ $('#helpTitle').html('Sorry...');+ });+ return false;+}