diff --git a/app/Providers/ConfigServiceProvider.php b/app/Providers/ConfigServiceProvider.php index c4deebb1d1..77dd2eef93 100644 --- a/app/Providers/ConfigServiceProvider.php +++ b/app/Providers/ConfigServiceProvider.php @@ -161,7 +161,9 @@ class ConfigServiceProvider extends ServiceProvider ] ], 'Session', - 'Route' + 'Route', + 'Config', + 'ExpandedForm' ], /* diff --git a/app/Providers/FireflyServiceProvider.php b/app/Providers/FireflyServiceProvider.php index 844db98847..b9d5601eaa 100644 --- a/app/Providers/FireflyServiceProvider.php +++ b/app/Providers/FireflyServiceProvider.php @@ -9,7 +9,8 @@ use FireflyIII\Support\ExpandedForm; use FireflyIII\Support\Navigation; use FireflyIII\Support\Preferences; use FireflyIII\Support\Steam; -use FireflyIII\Support\TwigSupport; +use FireflyIII\Support\Twig\General; +use FireflyIII\Support\Twig\Journals; use FireflyIII\Validation\FireflyValidator; use Illuminate\Support\ServiceProvider; use Twig; @@ -36,7 +37,8 @@ class FireflyServiceProvider extends ServiceProvider $config = App::make('config'); Twig::addExtension(new Functions($config)); - Twig::addExtension(new TwigSupport); + Twig::addExtension(new General); + Twig::addExtension(new Journals); } public function register() diff --git a/app/Support/TwigSupport.php b/app/Support/Twig/General.php similarity index 54% rename from app/Support/TwigSupport.php rename to app/Support/Twig/General.php index 9e09690a3a..e80e327bdc 100644 --- a/app/Support/TwigSupport.php +++ b/app/Support/Twig/General.php @@ -1,8 +1,9 @@ format(App::make('steam')->balance($account)); - }, ['is_safe' => ['html']] - ); - $filters[] = new Twig_SimpleFilter( - 'activeRoute', function ($string) { - if (Route::getCurrentRoute()->getName() == $string) { - return 'active'; - } - - return ''; + return App::make('steam')->balance($account); } ); + + // should be a function but OK + $filters[] = new Twig_SimpleFilter( + 'getAccountRole', function ($name) { + return Config::get('firefly.accountRoles.' . $name); + } + ); + return $filters; } @@ -68,12 +71,34 @@ class TwigSupport extends Twig_Extension } ); + $functions[] = new Twig_SimpleFunction( 'env', function ($name, $default) { return env($name, $default); } ); + $functions[] = new Twig_SimpleFunction( + 'activeRoute', function ($context) { + $args = func_get_args(); + $route = $args[1]; + $what = isset($args[2]) ? $args[2] : false; + $activeWhat = isset($context['what']) ? $context['what'] : false; + // activeRoute + if (!($what === false)) { + if ($what == $activeWhat && Route::getCurrentRoute()->getName() == $route) { + return 'active because-active-what'; + } + } else { + if (Route::getCurrentRoute()->getName() == $route) { + return 'active because-route-matches'; + } + } + + return 'not-xxx-at-all'; + }, ['needs_context' => true] + ); + return $functions; @@ -84,7 +109,7 @@ class TwigSupport extends Twig_Extension */ public function getName() { - return 'FireflyIII\Support\TwigSupport'; + return 'FireflyIII\Support\Twig\General'; } } \ No newline at end of file diff --git a/app/Support/Twig/Journals.php b/app/Support/Twig/Journals.php new file mode 100644 index 0000000000..a8c2105832 --- /dev/null +++ b/app/Support/Twig/Journals.php @@ -0,0 +1,78 @@ +transactionType->type; + if ($type == 'Withdrawal') { + return ''; + } + if ($type == 'Deposit') { + return ''; + } + if ($type == 'Transfer') { + return ''; + } + if ($type == 'Opening balance') { + return ''; + } + + + }, ['is_safe' => ['html']] + ); + + return $filters; + } + + public function getFunctions() + { + $functions = []; + + $functions[] = new Twig_SimpleFunction( + 'invalidJournal', function (TransactionJournal $journal) { + if (!isset($journal->transactions[1]) || !isset($journal->transactions[0])) { + return true; + } + + return false; + } + ); + + $functions[] = new Twig_SimpleFunction( + 'relevantTags', function (TransactionJournal $journal) { + return 'TODO'.$journal->amount; + } + ); + + return $functions; + } + + /** + * Returns the name of the extension. + * + * @return string The extension name + */ + public function getName() + { + return 'FireflyIII\Support\Twig\Journals'; + } +} \ No newline at end of file diff --git a/public/js/sb-admin-2.js b/public/js/sb-admin-2.js index 5be2c883ad..469460fd16 100755 --- a/public/js/sb-admin-2.js +++ b/public/js/sb-admin-2.js @@ -29,8 +29,8 @@ $(function() { var url = window.location; var element = $('ul.nav a').filter(function() { return this.href == url || url.href.indexOf(this.href) == 0; - }).addClass('active').parent().parent().addClass('in').parent(); + }).parent().parent().addClass('in').parent();/*addClass('active')*/ if (element.is('li')) { - element.addClass('active'); + //element.addClass('active'); } }); diff --git a/resources/twig/accounts/create.twig b/resources/twig/accounts/create.twig new file mode 100644 index 0000000000..9439400236 --- /dev/null +++ b/resources/twig/accounts/create.twig @@ -0,0 +1,61 @@ +{% extends "./layout/default.twig" %} +{% block content %} + {{ Breadcrumbs.renderIfExists(Route.getCurrentRoute.getName, what) }} +
+--> +{% endblock %} \ No newline at end of file diff --git a/resources/twig/accounts/delete.twig b/resources/twig/accounts/delete.twig new file mode 100644 index 0000000000..f6ee597cdb --- /dev/null +++ b/resources/twig/accounts/delete.twig @@ -0,0 +1,36 @@ +{% extends "./layout/default.twig" %} +{% block content %} +{!! Breadcrumbs::renderIfExists(Route::getCurrentRoute()->getName(), $account) !!} +{!! Form::open(['class' => 'form-horizontal','id' => 'destroy','url' => route('accounts.destroy',$account->id)]) !!} ++ Are you sure that you want to delete the {{strtolower($account->accountType->type)}} "{{$account->name}}"? +
+ + @if($account->transactions()->count() > 0) ++ {{ucfirst($account->accountType->type)}} "{{{$account->name}}}" still has {{$account->transactions()->count()}} transaction(s) associated to it. These will be deleted as well. +
+ @endif + @if($account->piggyBanks()->count() > 0) ++ {{ucfirst($account->accountType->type)}} "{{{$account->name}}}" still has {{$account->piggyBanks()->count()}} piggy bank(s) associated to it. These will be deleted as well. +
+ @endif ++ + Cancel +
++ +
++ | Name | + {% if what == 'asset' %} +Role | + {% endif %} +Current balance | +Active | +Last activity | +Balance difference between {{ Session.get('start').format('jS F Y') }} and {{ Session.get('end').format('jS F Y') }} | +|
---|---|---|---|---|---|---|---|
+ + | +{{ account.name }} | + {% if what == "asset" %} ++ {% for entry in account.accountmeta %} + {% if entry.name == 'accountRole' %} + {{ entry.data|getAccountRole }} + {% endif %} + {% endfor %} + | + {% endif %} +{{ account|balance|formatAmount }} | ++ {% if account.active %} + + {% else %} + + {% endif %} + | + {% if account.lastActivityDate %} ++ {{ account.lastActivityDate.format('j F Y') }} + | + {% else %} ++ Never + | + {% endif %} ++ {{ (account.endBalance - account.startBalance)|formatAmount }} + | + +
+ | Description | +Amount | +Date | +From | +To | + + {% if not hideBudgets %} ++ {% endif %} + + + {% if not hideCategories %} + | + {% endif %} + + + {% if not hideBills %} + | + {% endif %} + | |
---|---|---|---|---|---|---|---|---|---|
+ + | ++ | {{ journal.description }} | +Invalid journal: Found {{journal.transactions.count() }} transaction(s) | +||||||
+ + | + ++ {{ journal|typeIcon }} + | ++ {{journal.description}} + | ++ {% if not hideTags %} + {{ relevantTags(journal) }} + {% else %} + {{ journal|formatJournal }} + {% endif %} + | ++ {{journal.date.format('j F Y')}} + | ++ {% if journal.transactions[0].account.accountType.type == 'Cash account' %} + (cash) + {% else %} + {{journal.transactions[0].account.name}} + {% endif %} + | ++ {% if journal.transactions[1].account.accountType.type == 'Cash account' %} + (cash) + {% else %} + {{journal.transactions[1].account.name}} + {% endif %} + | + + + {% if not hideBudgets %} ++ {% if journal.budgets[0] %} + {{journal.budgets[0].name}} + {% endif %} + | + {% endif %} + + + {% if not hideCategories %} ++ {% if journal.categories[0] %} + {{journal.categories[0].name}} + {% endif %} + | + {% endif %} + + + {% if not hideBills %} ++ {% if journal.bill %} + {{journal.bill.name}} + {% endif %} + | + {% endif %} +