X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=opac%2Fopac-issue-note.pl;h=b59e838b062715dd79d4a2436b8e4c5f1653234f;hb=6b137e75b98b7a91c8900322d3fa062d48ff2fe5;hp=de2d82bb82d74231194fb6992328db3f28160fae;hpb=0159908ca144bca599ed9a0ff51fd3f0ab2ad0ab;p=koha-ffzg.git diff --git a/opac/opac-issue-note.pl b/opac/opac-issue-note.pl index de2d82bb82..b59e838b06 100755 --- a/opac/opac-issue-note.pl +++ b/opac/opac-issue-note.pl @@ -23,63 +23,79 @@ use CGI qw ( -utf8 ); use C4::Koha; use C4::Context; use C4::Scrubber; -use C4::Members; -use C4::Output; -use C4::Auth; -use C4::Biblio; +use C4::Output qw( output_html_with_http_headers ); +use C4::Auth qw( get_template_and_user ); use C4::Letters; use Koha::Checkouts; -use Koha::DateUtils; +use Koha::DateUtils qw( dt_from_string ); +use Koha::Patrons; -my $query = new CGI; +my $query = CGI->new; my ( $template, $borrowernumber, $cookie ) = get_template_and_user( { template_name => "opac-issue-note.tt", query => $query, type => "opac", - authnotrequired => 0, - debug => 1, } ); -my $member = C4::Members::GetMember( borrowernumber => $borrowernumber ); +my $patron = Koha::Patrons->find( $borrowernumber ); $template->param( - firstname => $member->{'firstname'}, - surname => $member->{'surname'}, + firstname => $patron->firstname, + surname => $patron->surname, borrowernumber => $borrowernumber, ); my $issue_id = $query->param('issue_id'); -my $issue = Koha::Checkouts->find( $issue_id ); +my $issue = $patron->checkouts->find( $issue_id ); + +unless ( $issue ) { + # exit early + print $query->redirect("/cgi-bin/koha/opac-user.pl"); + exit; +} + my $itemnumber = $issue->itemnumber; -my $biblio = GetBiblioFromItemNumber($itemnumber); +my $biblio = $issue->item->biblio; $template->param( issue_id => $issue_id, - title => $biblio->{'title'}, - author => $biblio->{'author'}, + title => $biblio->title, + author => $biblio->author, note => $issue->note, itemnumber => $issue->itemnumber, ); my $action = $query->param('action') || ""; -if ( $action eq 'issuenote' && C4::Context->preference('AllowIssueNotes') ) { +if ( $action eq 'issuenote' && C4::Context->preference('AllowCheckoutNotes') && $issue ) { my $note = $query->param('note'); my $scrubber = C4::Scrubber->new(); my $clean_note = $scrubber->scrub($note); - if ( $issue->set({ notedate => dt_from_string(), note => $clean_note })->store ) { + + if ( $issue->set({ notedate => dt_from_string(), note => $clean_note, noteseen => 0 })->store ) { if ($clean_note) { # only send email if note not empty my $branch = Koha::Libraries->find( $issue->branchcode ); my $letter = C4::Letters::GetPreparedLetter ( module => 'circulation', - letter_code => 'PATRON_NOTE', + letter_code => 'CHECKOUT_NOTE', branchcode => $branch, + lang => $patron->lang, tables => { - 'biblio' => $biblio->{biblionumber}, - 'borrowers' => $member->{borrowernumber}, + 'biblio' => $biblio->biblionumber, + 'borrowers' => $borrowernumber, }, ); - C4::Message->enqueue($letter, $member, 'email'); + + my $to_address = $branch->inbound_email_address; + my $reply_address = $patron->email || $patron->emailpro || $patron->B_email; + + C4::Letters::EnqueueLetter({ + letter => $letter, + message_transport_type => 'email', + borrowernumber => $patron->borrowernumber, + to_address => $to_address, + reply_address => $reply_address, + }); } } print $query->redirect("/cgi-bin/koha/opac-user.pl");