From 78d034d3669a06d7288ce15e3880222a857a549c Mon Sep 17 00:00:00 2001 From: Sander Dorigo Date: Wed, 12 Nov 2014 10:54:53 +0100 Subject: [PATCH] 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. --- app/controllers/AccountController.php | 37 ++-- app/controllers/BudgetController.php | 15 +- app/controllers/GoogleTableController.php | 45 ++++ app/controllers/HomeController.php | 28 +-- app/controllers/ProfileController.php | 27 +-- app/controllers/RecurringController.php | 135 +----------- app/controllers/SearchController.php | 12 +- app/controllers/TransactionController.php | 20 +- .../Ifaces/RecurringTransactionInterface.php | 14 ++ .../Database/RecurringTransaction.php | 139 ++++++++++++ app/lib/FireflyIII/Database/User.php | 22 +- app/lib/FireflyIII/Shared/Toolkit/Filter.php | 6 +- .../FireflyIII/Shared/Toolkit/Navigation.php | 64 ++++++ app/routes.php | 1 + app/views/recurring/index.blade.php | 34 +-- public/assets/javascript/firefly/recurring.js | 203 +----------------- 16 files changed, 366 insertions(+), 436 deletions(-) create mode 100644 app/lib/FireflyIII/Database/Ifaces/RecurringTransactionInterface.php create mode 100644 app/lib/FireflyIII/Database/RecurringTransaction.php create mode 100644 app/lib/FireflyIII/Shared/Toolkit/Navigation.php diff --git a/app/controllers/AccountController.php b/app/controllers/AccountController.php index 2397451853..f05d11623a 100644 --- a/app/controllers/AccountController.php +++ b/app/controllers/AccountController.php @@ -32,21 +32,21 @@ class AccountController extends BaseController break; 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 BaseController if ($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.php index 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 BaseController public 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.php index 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); + + } + + + /* + * name + match + amount_min + amount_max + date + active + automatch + repeat_freq + id + + */ + $chart->generate(); + return Response::json($chart->getData()); + } + /** * @param Account $account */ diff --git a/app/controllers/HomeController.php b/app/controllers/HomeController.php index 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.php index 6692e02872..ebfbc437cd 100644 --- a/app/controllers/ProfileController.php +++ b/app/controllers/ProfileController.php @@ -1,31 +1,18 @@ 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.php index db60b34004..b780a4822b 100644 --- a/app/controllers/RecurringController.php +++ b/app/controllers/RecurringController.php @@ -1,8 +1,6 @@ _repository = $repository; - $this->_helper = $helper; View::share('title', 'Recurring transactions'); View::share('mainTitleIcon', 'fa-rotate-right'); @@ -59,7 +48,11 @@ class RecurringController extends BaseController public 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 BaseController Session::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 file diff --git a/app/controllers/SearchController.php b/app/controllers/SearchController.php index 205933400b..49fe5ff1af 100644 --- a/app/controllers/SearchController.php +++ b/app/controllers/SearchController.php @@ -1,25 +1,17 @@ _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.php index e3ed758ed3..0f9fe231c1 100644 --- a/app/controllers/TransactionController.php +++ b/app/controllers/TransactionController.php @@ -1,33 +1,22 @@ _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.php new file mode 100644 index 0000000000..1669902ab1 --- /dev/null +++ b/app/lib/FireflyIII/Database/Ifaces/RecurringTransactionInterface.php @@ -0,0 +1,14 @@ +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 file diff --git a/app/lib/FireflyIII/Database/User.php b/app/lib/FireflyIII/Database/User.php index 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.php index 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.php new file mode 100644 index 0000000000..f4f40e9117 --- /dev/null +++ b/app/lib/FireflyIII/Shared/Toolkit/Navigation.php @@ -0,0 +1,64 @@ +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 file diff --git a/app/routes.php b/app/routes.php index 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.php index ac3831d090..ddfbf6f309 100644 --- a/app/views/recurring/index.blade.php +++ b/app/views/recurring/index.blade.php @@ -7,35 +7,21 @@ {{{$title}}}
- - - - - - - - - - - - - - -
namematchamount_minamount_maxdateactiveautomatchrepeat_freqid
+
@stop @section('scripts') - -{{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')}} + + + +{{HTML::script('assets/javascript/firefly/gcharts.options.js')}} +{{HTML::script('assets/javascript/firefly/gcharts.js')}} + + + + {{HTML::script('assets/javascript/firefly/recurring.js')}} -@stop -@section('styles') -{{HTML::style('assets/stylesheets/datatables/dataTables.bootstrap.css')}} @stop \ No newline at end of file diff --git a/public/assets/javascript/firefly/recurring.js b/public/assets/javascript/firefly/recurring.js index 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 '' + data.name + ''; - } - }, - { - name: 'match', - data: 'match', - searchable: true, - title: 'Matches on', - render: function (data) { - var str = ''; - for (x in data) { - str += '' + data[x] + ' '; - } - return str;//return '' + data.name + ''; - } - }, - { - name: 'amount_min', - data: 'amount_min', - searchable: false, - title: '→', - render: function (data) { - return '\u20AC ' + data.toFixed(2) + ''; - } - }, - { - name: 'amount_max', - data: 'amount_max', - searchable: false, - title: '←', - render: function (data) { - return '\u20AC ' + data.toFixed(2) + ''; - } - }, - { - name: 'date', - data: 'date', - title: 'Expected on', - searchable: false - }, - - { - name: 'active', - data: 'active', - searchable: false, - sortable: false, - render: function (data) { - if (data == 1) { - return ''; - } else { - return ''; - } - }, - title: 'Is active?' - }, - { - name: 'automatch', - data: 'automatch', - sortable: false, - searchable: false, - render: function (data) { - if (data == 1) { - return ''; - } else { - return ''; - } - }, - 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 '
' + - '' + - '' + - '' + - '' + - '
'; - } - } - ] - } - ); - } - 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 ' ' + - '' + data.description + ''; - } - }, - { - name: 'amount', - data: 'amount', - 'title': 'Amount (\u20AC)', - searchable: false, - render: function (data, type, full, meta) { - return '\u20AC ' + data.toFixed(2) + ''; - } - }, - { - name: 'from', - data: 'from', - searchable: false, - render: function (data, type, full, meta) { - return '' + data.name + ''; - } - }, - { - name: 'to', - data: 'to', - searchable: false, - render: function (data, type, full, meta) { - return '' + data.name + ''; - } - }, - { - name: 'components', - data: 'components', - searchable: true, - sortable: false, - title: '', - render: function (data, type, full, meta) { - var html = ''; - if (data.budget_id > 0) { - html += ' '; - } - if (data.category_id > 0) { - html += ' '; - } - if (data.recurring_id > 0) { - html += ' '; - } - return html; - } - }, - { - name: 'id', - data: 'id', - searchable: false, - sortable: false, - title: '', - render: function (data, type, full, meta) { - return '
' + - '' + - '' + - '' + - '' + - '
'; - } - } - ] - } - ); - } + if (typeof(googleTable) == 'function') { + googleTable('table/recurring','recurring-table'); + } } ); \ No newline at end of file