From cd6c0755887acc3927057efab9d5e39c4df3b46d Mon Sep 17 00:00:00 2001 From: Finn Date: Tue, 5 Sep 2017 12:27:37 +0100 Subject: [PATCH] View Transactions from a User on their page --- lib/Pear/LocalLoop/Controller/Admin/Users.pm | 12 +++++++++- templates/admin/users/read.html.ep | 25 ++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/lib/Pear/LocalLoop/Controller/Admin/Users.pm b/lib/Pear/LocalLoop/Controller/Admin/Users.pm index 803b68e..13905c6 100644 --- a/lib/Pear/LocalLoop/Controller/Admin/Users.pm +++ b/lib/Pear/LocalLoop/Controller/Admin/Users.pm @@ -33,7 +33,17 @@ sub read { my $id = $c->param('id'); if ( my $user = $c->user_result_set->find($id) ) { - $c->stash( user => $user ); + my $transactions = $user->entity->purchases->search( + undef, { + page => $c->param('page') || 1, + rows => 10, + order_by => { -desc => 'submitted_at' }, + }, + ); + $c->stash( + user => $user, + transactions => $transactions, + ); } else { $c->flash( error => 'No User found' ); $c->redirect_to( '/admin/users' ); diff --git a/templates/admin/users/read.html.ep b/templates/admin/users/read.html.ep index 149be12..37d7763 100644 --- a/templates/admin/users/read.html.ep +++ b/templates/admin/users/read.html.ep @@ -86,3 +86,28 @@ +
+

+ Transactions +

+ +