Firefly III: a personal finances manager
PHP accountingbudgetbudgetingbudgetscash-flowcashflowcredit-carddockerexpensesfinancefinancesfinanciallinuxmoneypaycheckpersonal-financephpphp7
Update tag view
James Cole35aeb7e04ac3
diff --git a/app/Http/Controllers/TagController.php b/app/Http/Controllers/TagController.phpindex bdb3160ea7..93d8236629 100644--- a/app/Http/Controllers/TagController.php+++ b/app/Http/Controllers/TagController.php@@ -226,24 +226,71 @@ class TagController extends Controller** @return View*/- public function show(Request $request, JournalCollectorInterface $collector, Tag $tag, string $moment = '')+ public function show(Request $request, JournalCollectorInterface $collector, Tag $tag){- $range = Preferences::get('viewRange', '1M')->data;- $start = new Carbon;- $end = new Carbon;-- if (strlen($moment) > 0) {- try {- $start = new Carbon($moment);- $end = Navigation::endOfPeriod($start, $range);- } catch (Exception $e) {- $start = Navigation::startOfPeriod($this->repository->firstUseDate($tag), $range);- $end = Navigation::startOfPeriod($this->repository->lastUseDate($tag), $range);+ $start = clone session('start', Carbon::now()->startOfMonth());+ $end = clone session('end', Carbon::now()->endOfMonth());+ $subTitle = $tag->tag;+ $subTitleIcon = 'fa-tag';+ $page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));+ $pageSize = intval(Preferences::get('transactionPageSize', 50)->data);+ $periods = $this->getPeriodOverview($tag);++ // use collector:+ $collector->setAllAssetAccounts()+ ->setLimit($pageSize)->setPage($page)->setTag($tag)->withOpposingAccount()->disableInternalFilter()+ ->withBudgetInformation()->withCategoryInformation()->setRange($start, $end);+ $journals = $collector->getPaginatedJournals();+ $journals->setPath('tags/show/' . $tag->id);++ $sum = $journals->sum(+ function (Transaction $transaction) {+ return $transaction->transaction_amount;}- }- if (strlen($moment) === 0) {- $start = clone session('start', Carbon::now()->startOfMonth());- $end = clone session('end', Carbon::now()->endOfMonth());+ );++ return view('tags.show', compact('tag', 'periods', 'subTitle', 'subTitleIcon', 'journals', 'sum', 'start', 'end'));+ }++ /**+ * @param Request $request+ * @param JournalCollectorInterface $collector+ * @param Tag $tag+ *+ * @return View+ */+ public function showAll(Request $request, JournalCollectorInterface $collector, Tag $tag)+ {+ $subTitle = $tag->tag;+ $subTitleIcon = 'fa-tag';+ $page = intval($request->get('page')) === 0 ? 1 : intval($request->get('page'));+ $pageSize = intval(Preferences::get('transactionPageSize', 50)->data);+ $collector->setAllAssetAccounts()->setLimit($pageSize)->setPage($page)->setTag($tag)+ ->withOpposingAccount()->disableInternalFilter()+ ->withBudgetInformation()->withCategoryInformation();+ $journals = $collector->getPaginatedJournals();+ $journals->setPath('tags/show/' . $tag->id . '/all');++ $sum = $journals->sum(+ function (Transaction $transaction) {+ return $transaction->transaction_amount;+ }+ );++ return view('tags.show', compact('tag', 'subTitle', 'subTitleIcon', 'journals', 'sum', 'start', 'end'));++ }++ public function showByDate(Request $request, JournalCollectorInterface $collector, Tag $tag, string $date)+ {+ $range = Preferences::get('viewRange', '1M')->data;++ try {+ $start = new Carbon($date);+ $end = Navigation::endOfPeriod($start, $range);+ } catch (Exception $e) {+ $start = Navigation::startOfPeriod($this->repository->firstUseDate($tag), $range);+ $end = Navigation::startOfPeriod($this->repository->lastUseDate($tag), $range);}$subTitle = $tag->tag;@@ -254,7 +301,7 @@ class TagController extends Controller// use collector:$collector->setAllAssetAccounts()- ->setLimit($pageSize)->setPage($page)->setTag($tag)+ ->setLimit($pageSize)->setPage($page)->setTag($tag)->withOpposingAccount()->disableInternalFilter()->withBudgetInformation()->withCategoryInformation()->setRange($start, $end);$journals = $collector->getPaginatedJournals();$journals->setPath('tags/show/' . $tag->id);diff --git a/resources/views/tags/show.twig b/resources/views/tags/show.twigindex 720934948e..460247a426 100644--- a/resources/views/tags/show.twig+++ b/resources/views/tags/show.twig@@ -75,13 +75,15 @@</div></div></div>- <div class="row">- <div class="col-lg-offset-10 col-lg-2 col-md-offset-10 col-md-2 col-sm-12 col-xs-12">- <p class="small text-center"><a href="{{ route('tags.show',[tag.id,'all']) }}">{{ 'showEverything'|_ }}</a></p>+ {% if periods %}+ <div class="row">+ <div class="col-lg-offset-10 col-lg-2 col-md-offset-10 col-md-2 col-sm-12 col-xs-12">+ <p class="small text-center"><a href="{{ route('tags.show.all',[tag.id]) }}">{{ 'showEverything'|_ }}</a></p>+ </div></div>- </div>+ {% endif %}<div class="row">- <div class="col-lg-10 col-md-10 col-sm-12 col-xs-12">+ <div class="{% if periods %}col-lg-10 col-md-10 col-sm-12 col-xs-12{% else %}col-lg-12 col-md-12 col-sm-12 col-xs-12{% endif %}"><div class="box"><div class="box-header with-border"><h3 class="box-title">{{ 'transactions'|_ }}</h3>@@ -100,45 +102,82 @@</div></div><div class="box-body">++ {% if periods %}+ <p>+ <i class="fa fa-calendar" aria-hidden="true"></i>+ <a href="{{ route('tags.show.all', [tag.id]) }}">+ {{ 'show_all_no_filter'|_ }}+ </a>+ </p>+ {% else %}+ <p>+ <i class="fa fa-calendar" aria-hidden="true"></i>+ <a href="{{ route('tags.show', [tag.id]) }}">+ {{ 'show_the_current_period_and_overview'|_ }}+ </a>+ </p>+ {% endif %}+{% include 'list/journals-tasker' %}++ {% if periods %}+ <p>+ <i class="fa fa-calendar" aria-hidden="true"></i>+ <a href="{{ route('tags.show.all', [tag.id]) }}">+ {{ 'show_all_no_filter'|_ }}+ </a>+ </p>+ {% else %}+ <p>+ <i class="fa fa-calendar" aria-hidden="true"></i>+ <a href="{{ route('tags.show', [tag.id]) }}">+ {{ 'show_the_current_period_and_overview'|_ }}+ </a>+ </p>+ {% endif %}</div></div></div>- <div class="col-lg-2 col-md-2 col-sm-12 col-xs-12">- {% for period in periods %}- {% if period.spent != 0 or period.earned != 0 %}- <div class="box {% if period.date == start %}box-solid box-primary{% endif %}">- <div class="box-header with-border">- <h3 class="box-title"><a href="{{ route('tags.show',[tag.id, period.date_string]) }}">{{ period.date_name }}</a>- </h3>- </div>- <div class="box-body no-padding">- <table class="table table-hover">- {% if period.spent != 0 %}- <tr>- <td style="width:33%;">{{ 'spent'|_ }}</td>- <td style="text-align: right;">{{ period.spent|formatAmount }}</td>- </tr>- {% endif %}- {% if period.earned != 0 %}- <tr>- <td style="width:33%;">{{ 'earned'|_ }}</td>- <td style="text-align: right;">{{ period.earned|formatAmount }}</td>- </tr>- {% endif %}- </table>+ {% if periods %}+ <div class="col-lg-2 col-md-2 col-sm-12 col-xs-12">+ {% for period in periods %}+ {% if period.spent != 0 or period.earned != 0 %}+ <div class="box {% if period.date == start %}box-solid box-primary{% endif %}">+ <div class="box-header with-border">+ <h3 class="box-title"><a href="{{ route('tags.show.date',[tag.id, period.date_string]) }}">{{ period.date_name }}</a>+ </h3>+ </div>+ <div class="box-body no-padding">+ <table class="table table-hover">+ {% if period.spent != 0 %}+ <tr>+ <td style="width:33%;">{{ 'spent'|_ }}</td>+ <td style="text-align: right;">{{ period.spent|formatAmount }}</td>+ </tr>+ {% endif %}+ {% if period.earned != 0 %}+ <tr>+ <td style="width:33%;">{{ 'earned'|_ }}</td>+ <td style="text-align: right;">{{ period.earned|formatAmount }}</td>+ </tr>+ {% endif %}+ </table>+ </div></div>- </div>- {% endif %}+ {% endif %}- {% endfor %}- </div>+ {% endfor %}+ </div>+ {% endif %}</div>- <div class="row">- <div class="col-lg-offset-10 col-lg-2 col-md-offset-10 col-md-2 col-sm-12 col-xs-12">- <p class="small text-center"><a href="{{ route('tags.show',[tag.id,'all']) }}">{{ 'showEverything'|_ }}</a></p>+ {% if periods %}+ <div class="row">+ <div class="col-lg-offset-10 col-lg-2 col-md-offset-10 col-md-2 col-sm-12 col-xs-12">+ <p class="small text-center"><a href="{{ route('tags.show.all',[tag.id]) }}">{{ 'showEverything'|_ }}</a></p>+ </div></div>- </div>+ {% endif %}{% endblock %}{% block scripts %}diff --git a/routes/web.php b/routes/web.phpindex c446a58ff9..92a108e5fe 100755--- a/routes/web.php+++ b/routes/web.php@@ -601,7 +601,9 @@ Route::group(Route::get('', ['uses' => 'TagController@index', 'as' => 'index']);Route::get('create', ['uses' => 'TagController@create', 'as' => 'create']);- Route::get('show/{tag}/{date?}', ['uses' => 'TagController@show', 'as' => 'show']);+ Route::get('show/{tag}/all', ['uses' => 'TagController@showAll', 'as' => 'show.all']);+ Route::get('show/{tag}/{date}', ['uses' => 'TagController@showByDate', 'as' => 'show.date']);+ Route::get('show/{tag}', ['uses' => 'TagController@show', 'as' => 'show']);Route::get('edit/{tag}', ['uses' => 'TagController@edit', 'as' => 'edit']);Route::get('delete/{tag}', ['uses' => 'TagController@delete', 'as' => 'delete']);