Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
There's a giant mix brewing between "old" code, bad code and not implemented exceptions. I suspect the next change will be to cut out all old stuff, throw a lot of NotImplementedExceptions and get going.
Sander Dorigo78d034d3669a
diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.phpindex 2397451853..f05d11623a 100644--- a/app/controllers/AccountController.php+++ b/app/controllers/AccountController.php@@ -32,21 +32,21 @@ class AccountController extends BaseControllerbreak;case 'asset':$subTitleIcon = 'fa-money';- $subTitle = 'Asset accounts';+ $subTitle = 'Asset accounts';break;case 'expense':$subTitleIcon = 'fa-shopping-cart';- $subTitle = 'Expense accounts';+ $subTitle = 'Expense accounts';break;case 'revenue':$subTitleIcon = 'fa-download';- $subTitle = 'Revenue accounts';+ $subTitle = 'Revenue accounts';break;}return View::make('accounts.index')- ->with('what', $what)- ->with(compact('subTitleIcon'))- ->with(compact('subTitle'));+ ->with('what', $what)+ ->with(compact('subTitleIcon'))+ ->with(compact('subTitle'));}@@ -68,9 +68,9 @@ class AccountController extends BaseController}return View::make('accounts.create')- ->with('subTitle', 'Create a new ' . $what . ' account')- ->with('what', $what)- ->with(compact('subTitleIcon'));+ ->with('subTitle', 'Create a new ' . $what . ' account')+ ->with('what', $what)+ ->with(compact('subTitleIcon'));}/**@@ -194,13 +194,10 @@ class AccountController extends BaseController}return View::make('accounts.edit')- ->with('account', $account)- ->with('openingBalance', $openingBalance)- ->with(compact('subTitleIcon'))- ->with('subTitle', 'Edit ' . strtolower(- $account->accountType->type- ) . ' "' . $account->name . '"'- );+ ->with('account', $account)+ ->with('openingBalance', $openingBalance)+ ->with(compact('subTitleIcon'))+ ->with('subTitle', 'Edit ' . strtolower($account->accountType->type) . ' "' . $account->name . '"');}/**@@ -227,9 +224,9 @@ class AccountController extends BaseController//$data = $this->_accounts->show($account, 40);return View::make('accounts.show')- ->with('account', $account)- ->with('subTitle', 'Details for ' . strtolower($account->accountType->type) . ' "' . $account->name . '"')- ->with(compact('subTitleIcon'));+ ->with('account', $account)+ ->with('subTitle', 'Details for ' . strtolower($account->accountType->type) . ' "' . $account->name . '"')+ ->with(compact('subTitleIcon'));}/**@@ -327,7 +324,7 @@ class AccountController extends BaseControllerif ($data['post_submit_action'] == 'create_another') {return Redirect::route('accounts.edit', $account->id);} else {- return Redirect::route('accounts.index',$data['what']);+ return Redirect::route('accounts.index', $data['what']);}case 'validate_only':$messageBags = $acct->validate($data);diff --git a/app/controllers/BudgetController.php b/app/controllers/BudgetController.phpindex ae8d0b123e..02a108a14e 100644--- a/app/controllers/BudgetController.php+++ b/app/controllers/BudgetController.php@@ -22,8 +22,8 @@ class BudgetController extends BaseController*/public function postUpdateIncome(){- /** @var \Firefly\Helper\Preferences\PreferencesHelperInterface $preferences */- $preferences = App::make('Firefly\Helper\Preferences\PreferencesHelperInterface');+ /** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */+ $preferences = App::make('FireflyIII\Shared\Preferences\PreferencesInterface');$date = Session::get('start');$value = intval(Input::get('amount'));@@ -72,11 +72,14 @@ class BudgetController extends BaseController}+ /**+ * @return $this+ */public function index(){- /** @var \Firefly\Helper\Preferences\PreferencesHelperInterface $preferences */- $preferences = App::make('Firefly\Helper\Preferences\PreferencesHelperInterface');+ /** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */+ $preferences = App::make('FireflyIII\Shared\Preferences\PreferencesInterface');$date = Session::get('start');/** @var \FireflyIII\Database\Budget $repos */@@ -133,8 +136,8 @@ class BudgetController extends BaseControllerpublic function updateIncome(){$date = Session::get('start');- /** @var \Firefly\Helper\Preferences\PreferencesHelperInterface $preferences */- $preferences = App::make('Firefly\Helper\Preferences\PreferencesHelperInterface');+ /** @var \FireflyIII\Shared\Preferences\PreferencesInterface $preferences */+ $preferences = App::make('FireflyIII\Shared\Preferences\PreferencesInterface');$budgetAmount = $preferences->get('budgetIncomeTotal' . $date->format('FY'), 1000);return View::make('budgets.income')->with('amount', $budgetAmount)->with('date', $date);}diff --git a/app/controllers/GoogleTableController.php b/app/controllers/GoogleTableController.phpindex 05ec289c46..555440e380 100644--- a/app/controllers/GoogleTableController.php+++ b/app/controllers/GoogleTableController.php@@ -171,6 +171,51 @@ class GoogleTableController extends BaseController}+ public function recurringList()+ {+ /** @var \Grumpydictator\Gchart\GChart $chart */+ $chart = App::make('gchart');+ $chart->addColumn('ID', 'number');+ $chart->addColumn('ID_Edit', 'string');+ $chart->addColumn('ID_Delete', 'string');+ $chart->addColumn('Name_URL', 'string');+ $chart->addColumn('Name', 'string');++ /** @var \FireflyIII\Database\RecurringTransaction $repository */+ $repository = App::make('FireflyIII\Database\RecurringTransaction');++ $set = $repository->get();++ /** @var \RecurringTransaction $entry */+ foreach ($set as $entry) {+ $row = [+ $entry->id,+ route('recurring.edit', $entry->id),+ route('recurring.delete', $entry->id),+ route('recurring.show', $entry->id),+ $entry->name+ ];+ $chart->addRowArray($row);++ }+++ /*+ * <th>name</th>+ <th>match</th>+ <th>amount_min</th>+ <th>amount_max</th>+ <th>date</th>+ <th>active</th>+ <th>automatch</th>+ <th>repeat_freq</th>+ <th>id</th>++ */+ $chart->generate();+ return Response::json($chart->getData());+ }+/*** @param Account $account*/diff --git a/app/controllers/HomeController.php b/app/controllers/HomeController.phpindex 4bf3ee667b..56d61564ef 100644--- a/app/controllers/HomeController.php+++ b/app/controllers/HomeController.php@@ -9,40 +9,44 @@ use FireflyIII\Shared\Preferences\PreferencesInterface as Prefs;class HomeController extends BaseController{protected $_preferences;- protected $_journal;/**- * @param PHI $preferences+ * @param Prefs $preferences*/public function __construct(Prefs $preferences){$this->_preferences = $preferences;}- /*- *+ /**+ * @return \Illuminate\Http\RedirectResponse*/public function sessionPrev(){- /** @var \Firefly\Helper\Toolkit\ToolkitInterface $toolkit */- $toolkit = App::make('Firefly\Helper\Toolkit\ToolkitInterface');- $toolkit->prev();+ /** @var \FireflyIII\Shared\Toolkit\Navigation $navigation */+ $navigation = App::make('FireflyIII\Shared\Toolkit\Navigation');+ $navigation->prev();return Redirect::back();//return Redirect::route('index');}- /*- *+ /**+ * @return \Illuminate\Http\RedirectResponse*/public function sessionNext(){- /** @var \Firefly\Helper\Toolkit\ToolkitInterface $toolkit */- $toolkit = App::make('Firefly\Helper\Toolkit\ToolkitInterface');- $toolkit->next();+ /** @var \FireflyIII\Shared\Toolkit\Navigation $navigation */+ $navigation = App::make('FireflyIII\Shared\Toolkit\Navigation');+ $navigation->next();return Redirect::back();//return Redirect::route('index');}+ /**+ * @param $range+ *+ * @return \Illuminate\Http\RedirectResponse+ */public function rangeJump($range){diff --git a/app/controllers/ProfileController.php b/app/controllers/ProfileController.phpindex 6692e02872..ebfbc437cd 100644--- a/app/controllers/ProfileController.php+++ b/app/controllers/ProfileController.php@@ -1,31 +1,18 @@<?php-use Firefly\Storage\User\UserRepositoryInterface as URI;-/*** Class ProfileController*/class ProfileController extends BaseController{- /**- * @param URI $user- */- public function __construct(URI $user)- {- $this->user = $user;- }-/*** @return \Illuminate\View\View**/public function index(){- return View::make('profile.index')- ->with('title', 'Profile')- ->with('subTitle', Auth::user()->email)- ->with('mainTitleIcon', 'fa-user');+ return View::make('profile.index')->with('title', 'Profile')->with('subTitle', Auth::user()->email)->with('mainTitleIcon', 'fa-user');}/**@@ -33,10 +20,9 @@ class ProfileController extends BaseController*/public function changePassword(){- return View::make('profile.change-password')- ->with('title', Auth::user()->email)- ->with('subTitle', 'Change your password')- ->with('mainTitleIcon', 'fa-user');+ return View::make('profile.change-password')->with('title', Auth::user()->email)->with('subTitle', 'Change your password')->with(+ 'mainTitleIcon', 'fa-user'+ );}/**@@ -70,8 +56,9 @@ class ProfileController extends BaseController}// update the user with the new password.- /** @noinspection PhpParamsInspection */- $this->user->updatePassword(Auth::user(), Input::get('new1'));+ /** @var \FireflyIII\Database\User $repository */+ $repository = \App::make('FireflyIII\Database\User');+ $repository->updatePassword(Auth::user(), Input::get('new1'));Session::flash('success', 'Password changed!');diff --git a/app/controllers/RecurringController.php b/app/controllers/RecurringController.phpindex db60b34004..b780a4822b 100644--- a/app/controllers/RecurringController.php+++ b/app/controllers/RecurringController.php@@ -1,8 +1,6 @@<?php-use Firefly\Exception\FireflyException;-use Firefly\Storage\RecurringTransaction\RecurringTransactionRepositoryInterface as RTR;-use Firefly\Helper\Controllers\RecurringInterface as RI;+use FireflyIII\Exception\FireflyException;/*** Class RecurringController@@ -11,17 +9,8 @@ use Firefly\Helper\Controllers\RecurringInterface as RI;*/class RecurringController extends BaseController{- protected $_repository;- protected $_helper;-- /**- * @param RTR $repository- * @param RI $helper- */- public function __construct(RTR $repository, RI $helper)+ public function __construct(){- $this->_repository = $repository;- $this->_helper = $helper;View::share('title', 'Recurring transactions');View::share('mainTitleIcon', 'fa-rotate-right');@@ -59,7 +48,11 @@ class RecurringController extends BaseControllerpublic function destroy(RecurringTransaction $recurringTransaction){//Event::fire('recurring.destroy', [$recurringTransaction]);- $result = $this->_repository->destroy($recurringTransaction);++ /** @var \FireflyIII\Database\RecurringTransaction $repository */+ $repository = App::make('FireflyIII\Database\RecurringTransaction');++ $result = $repository->destroy($recurringTransaction);if ($result === true) {Session::flash('success', 'The recurring transaction was deleted.');} else {@@ -113,127 +106,19 @@ class RecurringController extends BaseControllerSession::flash('warning', 'Inactive recurring transactions cannot be scanned.');return Redirect::back();}- // do something!- /** @var \Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface $repo */- $repo = App::make('Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface');- $set = $repo->get();-- /** @var TransactionJournal $journal */- foreach ($set as $journal) {- Event::fire('recurring.rescan', [$recurringTransaction, $journal]);- }+ throw new NotImplementedException;Session::flash('success', 'Rescanned everything.');return Redirect::back();--}public function store(){- $data = Input::except(['_token', 'post_submit_action']);- switch (Input::get('post_submit_action')) {- default:- throw new FireflyException('Method ' . Input::get('post_submit_action') . ' not implemented yet.');- break;- case 'store':- case 'create_another':- /*- * Try to store:- */- $messageBag = $this->_repository->store($data);-- /*- * Failure!- */- if ($messageBag->count() > 0) {- Session::flash('error', 'Could not save recurring transaction: ' . $messageBag->first());- return Redirect::route('recurring.create')->withInput()->withErrors($messageBag);- }-- /*- * Success!- */- Session::flash('success', 'Recurring transaction "' . e(Input::get('name')) . '" saved!');-- /*- * Redirect to original location or back to the form.- */- if (Input::get('post_submit_action') == 'create_another') {- return Redirect::route('recurring.create')->withInput();- } else {- return Redirect::route('recurring.index');- }- break;- case 'validate_only':- $messageBags = $this->_helper->validate($data);-- Session::flash('warnings', $messageBags['warnings']);- Session::flash('successes', $messageBags['successes']);- Session::flash('errors', $messageBags['errors']);- return Redirect::route('recurring.create')->withInput();- break;- }+ throw new NotImplementedException;}public function update(RecurringTransaction $recurringTransaction){- $data = Input::except(['_token', 'post_submit_action']);- switch (Input::get('post_submit_action')) {- case 'update':- case 'return_to_edit':- $messageBag = $this->_repository->update($recurringTransaction, $data);- if ($messageBag->count() == 0) {- // has been saved, return to index:- Session::flash('success', 'Recurring transaction updated!');-- if (Input::get('post_submit_action') == 'return_to_edit') {- return Redirect::route('recurring.edit', $recurringTransaction->id)->withInput();- } else {- return Redirect::route('recurring.index');- }- } else {- Session::flash('error', 'Could not update recurring transaction: ' . $messageBag->first());-- return Redirect::route('transactions.edit', $recurringTransaction->id)->withInput()- ->withErrors($messageBag);- }--- break;- case 'validate_only':- $data = Input::all();- $data['id'] = $recurringTransaction->id;- $messageBags = $this->_helper->validate($data);-- Session::flash('warnings', $messageBags['warnings']);- Session::flash('successes', $messageBags['successes']);- Session::flash('errors', $messageBags['errors']);- return Redirect::route('recurring.edit', $recurringTransaction->id)->withInput();-- break;- // update- default:- throw new FireflyException('Method ' . Input::get('post_submit_action') . ' not implemented yet.');- break;- }---// /** @var \RecurringTransaction $recurringTransaction */-// $recurringTransaction = $this->_repository->update($recurringTransaction, Input::all());-// if ($recurringTransaction->errors()->count() == 0) {-// Session::flash('success', 'The recurring transaction has been updated.');-// //Event::fire('recurring.update', [$recurringTransaction]);-//-// return Redirect::route('recurring.index');-// } else {-// Session::flash(-// 'error', 'Could not update the recurring transaction: ' . $recurringTransaction->errors()->first()-// );-//-// return Redirect::route('recurring.edit', $recurringTransaction->id)->withInput()->withErrors(-// $recurringTransaction->errors()-// );-// }+ throw new NotImplementedException;}}\ No newline at end of filediff --git a/app/controllers/SearchController.php b/app/controllers/SearchController.phpindex 205933400b..49fe5ff1af 100644--- a/app/controllers/SearchController.php+++ b/app/controllers/SearchController.php@@ -1,25 +1,17 @@<?php--use Firefly\Helper\Controllers\SearchInterface as SI;+use FireflyIII\Exception\NotImplementedException;/*** Class SearchController*/class SearchController extends BaseController{- protected $_helper;-- public function __construct(SI $helper)- {- $this->_helper = $helper;-- }-/*** Results always come in the form of an array [results, count, fullCount]*/public function index(){+ throw new NotImplementedException;$subTitle = null;$rawQuery = null;$result = [];diff --git a/app/controllers/TransactionController.php b/app/controllers/TransactionController.phpindex e3ed758ed3..0f9fe231c1 100644--- a/app/controllers/TransactionController.php+++ b/app/controllers/TransactionController.php@@ -1,33 +1,22 @@<?php-use Firefly\Exception\FireflyException;-use Firefly\Helper\Controllers\TransactionInterface as TI;-use Firefly\Storage\TransactionJournal\TransactionJournalRepositoryInterface as TJRI;+use FireflyIII\Exception\FireflyException;use Illuminate\Support\MessageBag;/*** Class TransactionController*- * @SuppressWarnings(PHPMD.CamelCasePropertyName)- **/class TransactionController extends BaseController{- protected $_helper;- protected $_repository;-/*** Construct a new transaction controller with two of the most often used helpers.*- * @param TJRI $repository- * @param TI $helper*/- public function __construct(TJRI $repository, TI $helper)+ public function __construct(){- $this->_repository = $repository;- $this->_helper = $helper;View::share('title', 'Transactions');View::share('mainTitleIcon', 'fa-repeat');}@@ -41,6 +30,7 @@ class TransactionController extends BaseController*/public function create($what = 'deposit'){+ throw new NotImplementedException;/** The repositories we need:*/@@ -110,6 +100,7 @@ class TransactionController extends BaseController*/public function destroy(TransactionJournal $transactionJournal){+ throw new NotImplementedException;$type = $transactionJournal->transactionType->type;$transactionJournal->delete();@@ -135,6 +126,7 @@ class TransactionController extends BaseController*/public function edit(TransactionJournal $journal){+ throw new NotImplementedException;/** All the repositories we need:*/@@ -268,6 +260,7 @@ class TransactionController extends BaseController*/public function store($what){+ throw new NotImplementedException;/** Collect data to process:*/@@ -334,6 +327,7 @@ class TransactionController extends BaseController*/public function update(TransactionJournal $journal){+ throw new NotImplementedException;switch (Input::get('post_submit_action')) {case 'update':case 'return_to_edit':diff --git a/app/lib/FireflyIII/Database/Ifaces/RecurringTransactionInterface.php b/app/lib/FireflyIII/Database/Ifaces/RecurringTransactionInterface.phpnew file mode 100644index 0000000000..1669902ab1--- /dev/null+++ b/app/lib/FireflyIII/Database/Ifaces/RecurringTransactionInterface.php@@ -0,0 +1,14 @@+<?php++namespace FireflyIII\Database\Ifaces;++use Illuminate\Support\Collection;++/**+ * Interface AccountInterface+ *+ * @package FireflyIII\Database+ */+interface RecurringTransactionInterface+{+}\ No newline at end of filediff --git a/app/lib/FireflyIII/Database/RecurringTransaction.php b/app/lib/FireflyIII/Database/RecurringTransaction.phpnew file mode 100644index 0000000000..8dc570c49f--- /dev/null+++ b/app/lib/FireflyIII/Database/RecurringTransaction.php@@ -0,0 +1,139 @@+<?php++namespace FireflyIII\Database;++use Carbon\Carbon;+use FireflyIII\Database\Ifaces\RecurringTransactionInterface;+use FireflyIII\Database\Ifaces\CommonDatabaseCalls;+use FireflyIII\Database\Ifaces\CUD;+use FireflyIII\Exception\NotImplementedException;+use Illuminate\Support\MessageBag;+use LaravelBook\Ardent\Ardent;+use Illuminate\Support\Collection;++/**+ * Class Account+ *+ * @package FireflyIII\Database+ */+class RecurringTransaction implements CUD, CommonDatabaseCalls, RecurringTransactionInterface+{+ use SwitchUser;++ /**+ *+ */+ public function __construct()+ {+ $this->setUser(\Auth::user());+ }++ /**+ * @param Ardent $model+ *+ * @return bool+ */+ public function destroy(Ardent $model)+ {+ // TODO: Implement destroy() method.+ throw new NotImplementedException;+ }++ /**+ * Validates a model. Returns an array containing MessageBags+ * errors/warnings/successes.+ *+ * @param Ardent $model+ *+ * @return array+ */+ public function validateObject(Ardent $model)+ {+ // TODO: Implement validateObject() method.+ throw new NotImplementedException;+ }++ /**+ * Validates an array. Returns an array containing MessageBags+ * errors/warnings/successes.+ *+ * @param array $model+ *+ * @return array+ */+ public function validate(array $model)+ {+ // TODO: Implement validate() method.+ throw new NotImplementedException;+ }++ /**+ * @param array $data+ *+ * @return Ardent+ */+ public function store(array $data)+ {+ // TODO: Implement store() method.+ throw new NotImplementedException;+ }++ /**+ * @param Ardent $model+ * @param array $data+ *+ * @return bool+ */+ public function update(Ardent $model, array $data)+ {+ // TODO: Implement update() method.+ throw new NotImplementedException;+ }++ /**+ * Returns an object with id $id.+ *+ * @param int $id+ *+ * @return Ardent+ */+ public function find($id)+ {+ // TODO: Implement find() method.+ throw new NotImplementedException;+ }++ /**+ * Returns all objects.+ *+ * @return Collection+ */+ public function get()+ {+ return $this->getUser()->recurringtransactions()->get();+ }++ /**+ * @param array $ids+ *+ * @return Collection+ */+ public function getByIds(array $ids)+ {+ // TODO: Implement getByIds() method.+ throw new NotImplementedException;+ }++ /**+ * Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.+ *+ * @param $what+ *+ * @return \AccountType|null+ */+ public function findByWhat($what)+ {+ // TODO: Implement findByWhat() method.+ throw new NotImplementedException;+ }+}\ No newline at end of filediff --git a/app/lib/FireflyIII/Database/User.php b/app/lib/FireflyIII/Database/User.phpindex 591b204991..f72a26d415 100644--- a/app/lib/FireflyIII/Database/User.php+++ b/app/lib/FireflyIII/Database/User.php@@ -5,6 +5,7 @@ namespace FireflyIII\Database;/*** Class User+ ** @package FireflyIII\Database*/class User@@ -12,14 +13,15 @@ class User/*** @param array $data+ ** @return bool|\User*/public function register(array $data){- $user = new \User;- $user->email = isset($data['email']) ? $data['email'] : null;+ $user = new \User;+ $user->email = isset($data['email']) ? $data['email'] : null;$user->migrated = 0;- $user->reset = \Str::random(32);+ $user->reset = \Str::random(32);$user->password = \Hash::make(\Str::random(12));if (!$user->save()) {@@ -34,6 +36,20 @@ class User}+ /**+ * @param \User $user+ * @param $password+ *+ * @return bool+ */+ public function updatePassword(\User $user, $password)+ {+ $user->password = $password;+ $user->forceSave();++ return true;+ }+/*** @param $mail*diff --git a/app/lib/FireflyIII/Shared/Toolkit/Filter.php b/app/lib/FireflyIII/Shared/Toolkit/Filter.phpindex c0cc51834e..b3cb70686c 100644--- a/app/lib/FireflyIII/Shared/Toolkit/Filter.php+++ b/app/lib/FireflyIII/Shared/Toolkit/Filter.php@@ -24,7 +24,7 @@ class Filter** @return string*/- protected function setSessionRangeValue()+ public function setSessionRangeValue(){if (!is_null(\Session::get('range'))) {$range = \Session::get('range');@@ -221,7 +221,7 @@ class Filter* @return Carbon* @throws FireflyException*/- protected function previous($range, Carbon $date)+ public function previous($range, Carbon $date){switch ($range) {default:@@ -262,7 +262,7 @@ class Filter* @return Carbon* @throws FireflyException*/- protected function next($range, Carbon $date)+ public function next($range, Carbon $date){switch ($range) {case '1D':diff --git a/app/lib/FireflyIII/Shared/Toolkit/Navigation.php b/app/lib/FireflyIII/Shared/Toolkit/Navigation.phpnew file mode 100644index 0000000000..f4f40e9117--- /dev/null+++ b/app/lib/FireflyIII/Shared/Toolkit/Navigation.php@@ -0,0 +1,64 @@+<?php++namespace FireflyIII\Shared\Toolkit;++/**+ * Class Navigation+ *+ * @package FireflyIII\Shared\Toolkit+ */+class Navigation+{+ /**+ * @return bool+ * @throws \Firefly\Exception\FireflyException+ */+ public function next()+ {+ /*+ * Get the start date and the range from the session+ */++ $filter = new Filter;++ $range = $filter->setSessionRangeValue();+ $start = \Session::get('start');++ /*+ * Add some period to $start.+ */+ $next = $filter->next($range, clone $start);++ /*+ * Save in session:+ */+ \Session::put('start', $next);+ return true;+ }++ /**+ * @return bool+ * @throws \Firefly\Exception\FireflyException+ */+ public function prev()+ {+ /*+ * Get the start date and the range from the session+ */+ $filter = new Filter;++ $range = $filter->setSessionRangeValue();+ $start = \Session::get('start');++ /*+ * Substract some period to $start.+ */+ $prev = $filter->previous($range, clone $start);++ /*+ * Save in session:+ */+ \Session::put('start', $prev);+ return true;+ }+}\ No newline at end of filediff --git a/app/routes.php b/app/routes.phpindex b846454ab1..983c2f318d 100644--- a/app/routes.php+++ b/app/routes.php@@ -163,6 +163,7 @@ Route::group(Route::get('/table/account/{account}/transactions', ['uses' => 'GoogleTableController@transactionsByAccount']);Route::get('/table/accounts/{what}', ['uses' => 'GoogleTableController@accountList']);Route::get('/table/categories', ['uses' => 'GoogleTableController@categoryList']);+ Route::get('/table/recurring', ['uses' => 'GoogleTableController@recurringList']);// google table for components (categories + budgets)Route::get('/table/component/{component}/{limitrepetition}/transactions', ['uses' => 'GoogleTableController@transactionsByComponent']);diff --git a/app/views/recurring/index.blade.php b/app/views/recurring/index.blade.phpindex ac3831d090..ddfbf6f309 100644--- a/app/views/recurring/index.blade.php+++ b/app/views/recurring/index.blade.php@@ -7,35 +7,21 @@<i class="fa {{$mainTitleIcon}}"></i> {{{$title}}}</div><div class="panel-body">- <table class="table table-striped" id="recurringTable">- <thead>- <tr>- <th>name</th>- <th>match</th>- <th>amount_min</th>- <th>amount_max</th>- <th>date</th>- <th>active</th>- <th>automatch</th>- <th>repeat_freq</th>- <th>id</th>- </tr>- </thead>- </table>+ <div id="recurring-table"></div></div></div></div></div>@stop@section('scripts')-<script type="text/javascript">-var URL = '{{route('json.recurring')}}';-</script>-{{HTML::script('assets/javascript/typeahead/bootstrap3-typeahead.min.js')}}-{{HTML::script('assets/javascript/datatables/jquery.dataTables.min.js')}}-{{HTML::script('assets/javascript/datatables/dataTables.bootstrap.js')}}++<!-- load the libraries and scripts necessary for Google Charts: -->+<script type="text/javascript" src="https://www.google.com/jsapi"></script>+{{HTML::script('assets/javascript/firefly/gcharts.options.js')}}+{{HTML::script('assets/javascript/firefly/gcharts.js')}}+++<script src="assets/javascript/firefly/accounts.js"></script>+{{HTML::script('assets/javascript/firefly/recurring.js')}}-@stop-@section('styles')-{{HTML::style('assets/stylesheets/datatables/dataTables.bootstrap.css')}}@stop\ No newline at end of filediff --git a/public/assets/javascript/firefly/recurring.js b/public/assets/javascript/firefly/recurring.jsindex 06aacad3f4..11b33573d7 100644--- a/public/assets/javascript/firefly/recurring.js+++ b/public/assets/javascript/firefly/recurring.js@@ -1,204 +1,7 @@$(document).ready(function () {- if ($('#recurringTable').length > 0) {- $('#recurringTable').DataTable(- {- serverSide: true,- ajax: URL,- paging: true,- processing: true,- order: [],- "lengthMenu": [[50, 100, 250, -1], [50, 100, 250, "All"]],- columns: [- {- name: 'name',- data: 'name',- searchable: true,- title: 'Name',- render: function (data) {- return '<a href="' + data.url + '" title="' + data.name + '">' + data.name + '</a>';- }- },- {- name: 'match',- data: 'match',- searchable: true,- title: 'Matches on',- render: function (data) {- var str = '';- for (x in data) {- str += '<span class="label label-info">' + data[x] + '</span> ';- }- return str;//return '<a href="' + data.url + '" title="' + data.name + '">' + data.name + '</a>';- }- },- {- name: 'amount_min',- data: 'amount_min',- searchable: false,- title: '→',- render: function (data) {- return '<span class="text-info">\u20AC ' + data.toFixed(2) + '</span>';- }- },- {- name: 'amount_max',- data: 'amount_max',- searchable: false,- title: '←',- render: function (data) {- return '<span class="text-info">\u20AC ' + data.toFixed(2) + '</span>';- }- },- {- name: 'date',- data: 'date',- title: 'Expected on',- searchable: false- },-- {- name: 'active',- data: 'active',- searchable: false,- sortable: false,- render: function (data) {- if (data == 1) {- return '<i class="fa fa-check fa-faw"></i>';- } else {- return '<i class="fa fa-remove fa-faw"></i>';- }- },- title: 'Is active?'- },- {- name: 'automatch',- data: 'automatch',- sortable: false,- searchable: false,- render: function (data) {- if (data == 1) {- return '<i class="fa fa-check fa-faw"></i>';- } else {- return '<i class="fa fa-remove fa-faw"></i>';- }- },- title: 'Automatch?'- },- {- name: 'repeat_freq',- data: 'repeat_freq',- searchable: false,- sortable: false,- title: 'Repeat frequency'- },- {- name: 'id',- data: 'id',- searchable: false,- sortable: false,- title: '',- render: function (data, type, full, meta) {- return '<div class="btn-group btn-group-xs">' +- '<a class="btn btn-default btn-xs" href="' + data.edit + '">' +- '<span class="glyphicon glyphicon-pencil"</a>' +- '<a class="btn btn-danger btn-xs" href="' + data.delete + '">' +- '<span class="glyphicon glyphicon-trash"</a>' +- '</a></div>';- }- }- ]- }- );- }- if ($('#transactionTable').length > 0) {- $('#transactionTable').DataTable(- {- serverSide: true,- ajax: URL,- paging: true,- processing: true,- order: [],- "lengthMenu": [[50, 100, 250, -1], [50, 100, 250, "All"]],- columns: [- {- name: 'date',- data: 'date',- searchable: false- },- {- name: 'description',- data: 'description',- render: function (data, type, full, meta) {- icon = 'glyphicon-arrow-left';-- return '<span class="glyphicon ' + icon + '"></span> ' +- '<a href="' + data.url + '" title="' + data.description + '">' + data.description + '</a>';- }- },- {- name: 'amount',- data: 'amount',- 'title': 'Amount (\u20AC)',- searchable: false,- render: function (data, type, full, meta) {- return '<span class="text-danger">\u20AC ' + data.toFixed(2) + '</span>';- }- },- {- name: 'from',- data: 'from',- searchable: false,- render: function (data, type, full, meta) {- return '<a href="' + data.url + '" title="' + data.name + '">' + data.name + '</a>';- }- },- {- name: 'to',- data: 'to',- searchable: false,- render: function (data, type, full, meta) {- return '<a href="' + data.url + '" title="' + data.name + '">' + data.name + '</a>';- }- },- {- name: 'components',- data: 'components',- searchable: true,- sortable: false,- title: '',- render: function (data, type, full, meta) {- var html = '';- if (data.budget_id > 0) {- html += '<a href="' + data.budget_url + '" title="' + data.budget_name + '"><i class="fa fa-tasks fa-fw"></i></a> ';- }- if (data.category_id > 0) {- html += '<a href="' + data.category_url + '" title="' + data.category_name + '"><i class="fa fa-bar-chart fa-fw"></i></a> ';- }- if (data.recurring_id > 0) {- html += '<a href="' + data.recurring_url + '" title="' + data.recurring_name + '"><i class="fa fa-rotate-right fa-fw"></i></a> ';- }- return html;- }- },- {- name: 'id',- data: 'id',- searchable: false,- sortable: false,- title: '',- render: function (data, type, full, meta) {- return '<div class="btn-group btn-group-xs">' +- '<a class="btn btn-default btn-xs" href="' + data.edit + '">' +- '<span class="glyphicon glyphicon-pencil"</a>' +- '<a class="btn btn-danger btn-xs" href="' + data.delete + '">' +- '<span class="glyphicon glyphicon-trash"</a>' +- '</a></div>';- }- }- ]- }- );- }+ if (typeof(googleTable) == 'function') {+ googleTable('table/recurring','recurring-table');+ }});\ No newline at end of file