use Modern::Perl;
use CGI qw ( -utf8 );
-use C4::Auth;
+use C4::Auth qw( get_template_and_user );
use C4::Context;
-use C4::Output;
+use C4::Output qw( output_and_exit_if_error output_and_exit output_html_with_http_headers );
use C4::Members;
-use C4::Members::Attributes qw(GetBorrowerAttributes);
-use C4::Suggestions;
+use C4::Suggestions qw( SearchSuggestion );
use Koha::Patrons;
-my $input = new CGI;
+my $input = CGI->new;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{ template_name => "members/purchase-suggestions.tt",
query => $input,
type => "intranet",
- authnotrequired => 0,
- flagsrequired => { borrowers => 1 },
- debug => 1,
+ flagsrequired => { suggestions => 'suggestions_manage' },
}
);
my $borrowernumber = $input->param('borrowernumber');
-my $patron = Koha::Patrons->find( $borrowernumber );
-unless ( $patron ) {
- print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber");
- exit;
-}
+my $logged_in_user = Koha::Patrons->find( $loggedinuser );
+my $patron = Koha::Patrons->find( $borrowernumber );
+output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } );
+
my $category = $patron->category;
-my $data = $patron->unblessed;
-$data->{description} = $category->description;
-$data->{category_type} = $category->category_type;
-foreach my $key ( keys %$data ) {
- $template->param( $key => $data->{$key} );
-}
$template->param(
+ patron => $patron,
suggestionsview => 1,
- categoryname => $data->{'description'},
- RoutingSerials => C4::Context->preference('RoutingSerials'),
);
-if (C4::Context->preference('ExtendedPatronAttributes')) {
- my $attributes = GetBorrowerAttributes($borrowernumber);
- $template->param(
- ExtendedPatronAttributes => 1,
- extendedattributes => $attributes
- );
-}
-
-$template->param( picture => 1 ) if $patron->image;
-
my $suggestions = SearchSuggestion( { suggestedby => $borrowernumber } );
$template->param( suggestions => $suggestions );