Bug 4037: Add item type filter to inventory tool
[koha-ffzg.git] / opac / opac-reportproblem.pl
index 0df2c73..293f282 100755 (executable)
@@ -28,8 +28,10 @@ use Koha::ProblemReport;
 use Koha::Libraries;
 use Koha::Patrons;
 use Koha::Util::Navigation;
+use URI::Escape;
+use Encode;
 
-my $input = new CGI;
+my $input = CGI->new;
 
 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
     {
@@ -46,17 +48,17 @@ if (   !C4::Context->preference('OPACReportProblem')
     print $input->redirect("/cgi-bin/koha/errors/404.pl");
 }
 
-my $problempage = C4::Context->preference('OPACBaseURL') . Koha::Util::Navigation::local_referer($input );
+my $referer = Koha::Util::Navigation::local_referer($input );
+$referer = Encode::decode_utf8 uri_unescape $referer,
 
 my $patron = Koha::Patrons->find($borrowernumber);
+my $library = $patron->library;
 my $username = $patron->userid;
-my $branchcode = $patron->branchcode;
-my $library = Koha::Libraries->find($branchcode);
 my @messages;
 
 $template->param(
     username    => $username,
-    problempage => $problempage,
+    problempage => $referer,
     library     => $library,
 );
 
@@ -66,6 +68,7 @@ if ( $op eq 'addreport' ) {
     my $subject = $input->param('subject');
     my $message = $input->param('message');
     my $problempage = $input->param('problempage');
+    $problempage = Encode::decode_utf8 uri_unescape $problempage;
     my $recipient = $input->param('recipient') || 'admin';
 
     try {
@@ -77,7 +80,7 @@ if ( $op eq 'addreport' ) {
                         title          => $subject,
                         content        => $message,
                         borrowernumber => $borrowernumber,
-                        branchcode     => $branchcode,
+                        branchcode     => $patron->branchcode,
                         username       => $username,
                         problempage    => $problempage,
                         recipient      => $recipient,
@@ -97,13 +100,13 @@ if ( $op eq 'addreport' ) {
                 my $transport = 'email';
                 my $reply_address = $patron->email || $patron->emailpro || $patron->B_email;
 
-                if ( $recipient eq 'library' and defined($library->get_effective_email) and $library->get_effective_email ne C4::Context->preference('KohaAdminEmailAddress') ) {
+                if ( $recipient eq 'library' and defined($library->inbound_email_address) and $library->inbound_email_address ne C4::Context->preference('KohaAdminEmailAddress') ) {
                     # the problem report is intended for a librarian and will be received at a library email address
                     C4::Letters::EnqueueLetter({
                         letter                 => $letter,
                         borrowernumber         => $borrowernumber,
                         message_transport_type => $transport,
-                        to_address             => $library->get_effective_email,
+                        to_address             => $library->inbound_email_address,
                         reply_address          => $reply_address,
                     });
                 } else {