my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials });
$materials = $descriptions->{lib} // $materials;
+ my $issue = GetItemIssue($itemnumber);
+
$template->param(
title => $biblio->{'title'},
homebranch => $biblio->{'homebranch'},
biblionumber => $biblio->{'biblionumber'},
borrower => $borrower,
additional_materials => $materials,
+ issue => $issue,
);
my %input = (
--- /dev/null
+ALTER IGNORE TABLE issues ADD `note` mediumtext default NULL AFTER `onsite_checkout`;
+ALTER IGNORE TABLE issues ADD `notedate` datetime default NULL AFTER `note`;
+ALTER IGNORE TABLE old_issues ADD `note` mediumtext default NULL AFTER `onsite_checkout`;
+ALTER IGNORE TABLE old_issues ADD `notedate` datetime default NULL AFTER `note`;
--- /dev/null
+INSERT IGNORE INTO letter (`module`, `code`, `branchcode`, `name`, `is_html`, `title`, `content`, `message_transport_type`) VALUES ('circulation', 'PATRON_NOTE', '', 'Patron note on item', '0', 'Patron issue note', '<<borrowers.firstname>> <<borrowers.surname>> has added a note to the item <<biblio.item>> - <<biblio.author>> (<<biblio.biblionumber>>).','email');
--- /dev/null
+INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`,`type`) VALUES ('AllowIssueNotes', '0', NULL, 'Allow patrons to submit notes about checked out items.','YesNo');
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
`issuedate` datetime default NULL, -- date the item was checked out or issued
`onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
+ `note` mediumtext default NULL, -- issue note text
+ `notedate` datetime default NULL, -- datetime of issue note (yyyy-mm-dd hh:mm::ss)
PRIMARY KEY (`issue_id`),
UNIQUE KEY `itemnumber` (`itemnumber`),
KEY `issuesborridx` (`borrowernumber`),
`timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
`issuedate` datetime default NULL, -- date the item was checked out or issued
`onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
+ `note` mediumtext default NULL, -- issue note text
+ `notedate` datetime default NULL, -- datetime of issue note (yyyy-mm-dd hh:mm::ss)
PRIMARY KEY (`issue_id`),
KEY `old_issuesborridx` (`borrowernumber`),
KEY `old_issuesitemidx` (`itemnumber`),
('AllowHoldPolicyOverride','0',NULL,'Allow staff to override hold policies when placing holds','YesNo'),
('AllowHoldsOnDamagedItems','1','','Allow hold requests to be placed on damaged items','YesNo'),
('AllowHoldsOnPatronsPossessions','1',NULL,'Allow holds on records that patron have items of it','YesNo'),
+('AllowIssueNotes', '0', NULL, 'Allow patrons to submit notes about checked out items.','YesNo'),
('AllowItemsOnHoldCheckout','0','','Do not generate RESERVE_WAITING and RESERVED warning when checking out items reserved to someone else. This allows self checkouts for those items.','YesNo'),
('AllowItemsOnHoldCheckoutSCO','0','','Do not generate RESERVE_WAITING and RESERVED warning in the SCO module when checking out items reserved to someone else. This allows self checkouts for those items.','YesNo'),
('AllowMultipleCovers','0','1','Allow multiple cover images to be attached to each bibliographic record.','YesNo'),
yes: Show
no: "Do not show"
- all items in the "Checked-in items" list, even items that were not checked out.
+ -
+ - pref: AllowIssueNotes
+ choices:
+ yes: Allow
+ no: "Don't allow"
+ - patrons to submit notes about checked out items.
Checkout Policy:
-
</div>
[% END %]
+<!-- Patron has added an issue note -->
+[% IF ( issue.note) %]
+ <div class="dialog message">
+ <h1>Patron note</h1>
+ <p>[% issue.notedate | $KohaDates %]</p>
+ <p><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% itembiblionumber %]"> [% title |html %]</a> [% author %]</p>
+ <p>[% issue.note %]</p>
+ </div>
+[% END %]
+
<!-- Patron has fines -->
[% IF ( fines ) %]
<div class="dialog alert">
content = CIRCULATION_RETURNED;
$(id).parent().parent().addClass('ok');
$('#date_due_' + data.itemnumber).html(CIRCULATION_RETURNED);
+ if ( data.patronnote != null ) {
+ $('.patron_note_' + data.itemnumber).html("Patron note: " + data.patronnote);
+ }
} else {
content = CIRCULATION_NOT_RETURNED;
$(id).parent().parent().addClass('warn');
due += "<span class='dmg'>" + oObj.damaged + "</span>";
}
+ var patron_note = " <span class='patron_note_" + oObj.itemnumber + "'></span>";
+ due +="<br>" + patron_note;
return due;
}
},
{
"mDataProp": function ( oObj ) {
- title = "<span class='strong'><a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber="
+ title = "<span id='title_" + oObj.itemnumber + "' class='strong'><a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber="
+ oObj.biblionumber
+ "'>"
+ oObj.title;
if ( oObj.itemnotes ) {
var span_class = "text-muted";
- title += " - <span class='" + span_class + "'>" + oObj.itemnotes + "</span>"
+ if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) {
+ span_class = "circ-hlt";
+ }
+ title += " - <span class='" + span_class + "'>" + oObj.itemnotes + "</span>";
}
if ( oObj.itemnotes_nonpublic ) {
var span_class = "text-danger";
- title += " - <span class='" + span_class + "'>" + oObj.itemnotes_nonpublic + "</span>"
+ if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) {
+ span_class = "circ-hlt";
+ }
+ title += " - <span class='" + span_class + "'>" + oObj.itemnotes_nonpublic + "</span>";
}
var onsite_checkout = '';
+ "'>"
+ oObj.barcode
+ "</a>"
- + onsite_checkout;
+ + onsite_checkout
return title;
},
--- /dev/null
+[% USE Koha %]
+[% USE KohaDates %]
+[% USE Branches %]
+[% INCLUDE 'doc-head-open.inc' %]
+<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog › Your library home</title>
+[% INCLUDE 'doc-head-close.inc' %]
+[% BLOCK cssinclude %][% END %]
+</head>
+[% INCLUDE 'bodytag.inc' bodyid='opac-issue-note' %]
+[% INCLUDE 'masthead.inc' %]
+
+<div class="main">
+ <ul class="breadcrumb">
+ <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">›</span></li>
+ <li><a href="/cgi-bin/koha/opac-user.pl">[% firstname %] [% surname %]</a><span class="divider">›</span></li>
+ <li><a href="#">Editing issue note for [% ISSUE.title %] - [% ISSUE.author %]</a></li>
+ </ul>
+
+ <div class="container-fluid">
+ <div class="row-fluid">
+ <div class="span2">
+ <div id="navigation">
+ [% INCLUDE 'navigation.inc' IsPatronPage=1 %]
+ </div>
+ </div>
+ <div class="span10">
+ <div id="issuenote" class="maincontent">
+ <h3>Editing issue note for [% title %] [% author %]</h3>
+ [% IF not(Koha.Preference("AllowIssueNotes")) %]
+ Issue notes have not been enabled. Please contact the library.
+ [% ELSE %]
+ <form id="issue-note" action="/cgi-bin/koha/opac-issue-note.pl" method="post">
+ <fieldset>
+ <label for="note" class="required">Note:</label>
+ <input type="text" name="note" value="[% note %]">
+ <input type="hidden" name="borrowernumber" value="[% borrowernumber %]">
+ <input type="hidden" name="itemnumber" value="[% itemnumber %]">
+ <input type="hidden" name="issue_id" value="[% issue_id %]">
+ <input type="hidden" name="action" value="issuenote">
+ </fieldset>
+ <fieldset class="action">
+ <input type="submit" value="Submit note" class="btn btn-default btn-sm"><a href="/cgi-bin/koha/opac-user.pl" class="cancel">Cancel</a>
+ </fieldset>
+ </form> <!-- issue-note -->
+ [% END %]
+ </div> <!-- issuenote -->
+ </div> <!-- span10 -->
+ </div> <!-- row-fluid -->
+ </div> <!-- container-fluid -->
+
+</div> <!-- main -->
+
+[% INCLUDE 'opac-bottom.inc' %]
+[% BLOCK jsinclude %][% END %]
</div>
[% END # / IF patron_flagged %]
+ <div class="alert alert-info" id="notesaved" style="display:none;"></div>
+
[% SET OPACMySummaryNote = Koha.Preference('OPACMySummaryNote') %]
[% IF OPACMySummaryNote %][% OPACMySummaryNote %][% END %]
[% IF ( OPACMySummaryHTML ) %]
<th class="nosort">Links</th>
[% END %]
+ [% IF ( Koha.Preference('AllowIssueNotes') ) %]
+ <th class="nosort">Note</th>
+ [% END %]
</tr>
</thead>
<tbody>
[% IF ( OPACMySummaryHTML ) %]
<td class="links">[% ISSUE.MySummaryHTML %]</td>
[% END %]
+ [% IF ( Koha.Preference('AllowIssueNotes') ) %]
+ <td class="note">
+ <input type="text" name="note" data-issue_id="[% ISSUE.issue_id %]" data-origvalue="[% ISSUE.note %]" value="[% ISSUE.note %]" readonly>
+ <a class="btn" name="js_submitnote" id="save_[% ISSUE.issue_id %]" style="display:none;">Submit note</a>
+ <a class="btn" name="nonjs_submitnote" href="/cgi-bin/koha/opac-issue-note.pl?issue_id=[% ISSUE.issue_id | url %]">Edit / Create note</a>
+ </td>
+ [% END %]
</tr>
[% END # /FOREACH ISSUES %]
</tbody>
[% END %]
[% END %]
+ [% IF ( Koha.Preference('AllowIssueNotes') ) %]
+
+ /* If JS enabled, show button, otherwise show link to redirect to a page where note can be submitted */
+ $("a[name='nonjs_submitnote']").hide();
+
+ $("input[name='note']").prop('readonly', false);
+ $("input[name='note']").keyup(function(e){
+ /* prevent submitting of renewselected form */
+ if(e.which == 13)
+ e.preventDefault();
+
+ var $btn_save = $('#save_'+$(this).data('issue_id'));
+ var origvalue = $(this).data('origvalue');
+ var value = $(this).val();
+
+ if(origvalue != value) {
+ if(origvalue != "")
+ $btn_save.text('Submit changes');
+ else
+ $btn_save.text('Submit note');
+ $btn_save.show();
+ } else {
+ $btn_save.hide();
+ }
+ });
+
+ $("a[name='js_submitnote']").click(function(e){
+ var $self = $(this);
+ var title = $(this).parent().siblings('.title').html();
+ var $noteinput = $(this).siblings('input[name="note"]').first();
+
+ var ajaxData = {
+ 'action': 'issuenote',
+ 'issue_id': $noteinput.data('issue_id'),
+ 'note': $noteinput.val(),
+ };
+
+ $.ajax({
+ url: '/cgi-bin/koha/svc/patron_notes/',
+ type: 'POST',
+ dataType: 'json',
+ data: ajaxData,
+ })
+ .done(function(data) {
+ var message = "";
+ if(data.status == 'saved') {
+ $("#notesaved").removeClass("alert-error");
+ $("#notesaved").addClass("alert-info");
+ $noteinput.data('origvalue', data.note);
+ $noteinput.val(data.note);
+ message = "<p>Your note about " + title + " has been saved and sent to the library.</p>";
+ $self.hide();
+ } else if(data.status == 'removed') {
+ $("#notesaved").removeClass("alert-error");
+ $("#notesaved").addClass("alert-info");
+ $noteinput.data('origvalue', "");
+ $noteinput.val("");
+ message = "<p>Your note about " + title + " was removed.</p>";
+ $self.hide();
+ } else {
+ $("#notesaved").removeClass("alert-info");
+ $("#notesaved").addClass("alert-error");
+ message = "<p>Your note about " + title + " could not be saved.</p>" +
+ "<p style=\"font-weight:bold;\">" + data.error + "</p>";
+ }
+
+ message += "<p style=\"font-style:italic;\">" + data.note + "</p>";
+ $("#notesaved").html(message);
+ })
+ .fail(function(data) {
+ $("#notesaved").removeClass("alert-info");
+ $("#notesaved").addClass("alert-error");
+ var message = "<p>Your note about " + title + " could not be saved.</p>" +
+ "<p style=\"font-weight:bold;\">Ajax request has failed.</p>";
+ $("#notesaved").html(message);
+ })
+ .always(function() {
+ $("#notesaved").show();
+ });
+ });
+ [% END %]
+
$( ".suspend-until" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
if ( $('#opac-user-clubs').length ) {
--- /dev/null
+#!/usr/bin/perl
+
+# Copyright 2016 Aleisha Amohia <aleisha@catalyst.net.nz>
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
+
+use Modern::Perl;
+
+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::Letters;
+use Koha::Checkouts;
+use Koha::DateUtils;
+
+my $query = new CGI;
+
+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 );
+$template->param(
+ firstname => $member->{'firstname'},
+ surname => $member->{'surname'},
+ borrowernumber => $borrowernumber,
+);
+
+my $issue_id = $query->param('issue_id');
+my $issue = Koha::Checkouts->find( $issue_id );
+my $itemnumber = $issue->itemnumber;
+my $biblio = GetBiblioFromItemNumber($itemnumber);
+$template->param(
+ issue_id => $issue_id,
+ 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') ) {
+ 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 ($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',
+ branchcode => $branch,
+ tables => {
+ 'biblio' => $biblio->{biblionumber},
+ 'borrowers' => $member->{borrowernumber},
+ },
+ );
+ C4::Message->enqueue($letter, $member, 'email');
+ }
+ }
+ print $query->redirect("/cgi-bin/koha/opac-user.pl");
+}
+
+output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
use C4::Biblio;
use C4::Items;
use C4::Letters;
+use Koha::Libraries;
use Koha::DateUtils;
use Koha::Holds;
use Koha::Database;
}
my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
$canrenew = 0 if ($overduesblockrenewing ne 'allow' and $overdues_count == $count);
+
$template->param( ISSUES => \@issuedat );
$template->param( issues_count => $count );
$template->param( canrenew => $canrenew );
--- /dev/null
+#!/usr/bin/perl
+
+# This file is part of Koha.
+#
+# Copyright 2014 BibLibre
+#
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
+
+use Modern::Perl;
+
+use C4::Service;
+use C4::Auth qw /check_cookie_auth/;
+use C4::Letters;
+use CGI;
+use C4::Output qw(:DEFAULT :ajax);
+use C4::Scrubber;
+use C4::Circulation;
+use C4::Members;
+use C4::Biblio;
+use Koha::Checkouts;
+use Koha::DateUtils;
+
+=head1 NAME
+
+svc/patron_notes - Web service for setting patron notes on items
+
+=head1 DESCRIPTION
+
+=cut
+
+# AJAX requests
+my $is_ajax = is_ajax();
+my $query = new CGI;
+my ( $auth_status, $sessionID ) = check_cookie_auth( $query->cookie('CGISESSID'), {} );
+if ( $auth_status ne "ok" ) {
+ exit 0;
+}
+if ($is_ajax) {
+ my $action = $query->param('action');
+
+ # Issue Note
+ if ( $action eq 'issuenote' && C4::Context->preference('AllowIssueNotes') ) {
+ my $scrubber = C4::Scrubber->new();
+ my $note = $query->param('note');
+ my $issue_id = $query->param('issue_id');
+ my $clean_note = $scrubber->scrub($note);
+ my $status = "saved";
+ my $error = "";
+ my ($member, $issue);
+
+ my ( $template, $borrowernumber, $cookie ) = C4::Auth::get_template_and_user({
+ template_name => "opac-user.tt",
+ query => $query,
+ type => "opac",
+ authnotrequired => 1,
+ });
+
+ # verify issue_id
+ if ( $issue_id =~ /\d+/ ) {
+ $member = GetMember(borrowernumber => $borrowernumber);
+ $issue = Koha::Checkouts->find($issue_id);
+ if ( $issue->borrowernumber != $borrowernumber ) {
+ $status = "fail";
+ $error = "Invalid issue id!";
+ }
+ } else {
+ $status = "fail";
+ $error = "Invalid issue id!";
+ }
+
+ if ( (not $error) && $issue->set({ notedate => dt_from_string(), note => $clean_note })->store ) {
+ if($clean_note) { # only send email if note not empty
+ my $branch = Koha::Libraries->find( $issue->branchcode );
+ my $biblio = GetBiblioFromItemNumber($issue->itemnumber);
+ my $letter = C4::Letters::GetPreparedLetter (
+ module => 'circulation',
+ letter_code => 'PATRON_NOTE',
+ branchcode => $branch,
+ tables => {
+ 'biblio' => $biblio->{biblionumber},
+ 'borrowers' => $member->{borrowernumber},
+ },
+ );
+ C4::Message->enqueue($letter, $member, 'email');
+ } else { # note empty, i.e removed
+ $status = "removed";
+ }
+ } else {
+ $status = "fail";
+ $error = "Perhaps the item has already been checked in?";
+ }
+
+ my $response = "{\"status\": \"$status\", \"note\": \"$clean_note\", \"issue_id\": \"$issue_id\", \"error\": \"$error\"}";
+ output_with_http_headers($query, undef, $response, 'js');
+ exit;
+ } # END Issue Note
+}
#!/usr/bin/perl
-# Copyright 2014 ByWater Solutions
+# Copyright 2016 Aleisha Amohia <aleisha@catalyst.net.nz>
#
# This file is part of Koha.
#
ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} );
}
+my $dbh = C4::Context->dbh;
+my $query = "SELECT note FROM issues WHERE itemnumber = ?";
+my $sth = $dbh->prepare($query);
+$sth->execute($itemnumber);
+my $issue = $sth->fetchrow_hashref;
+my $patronnote = $issue->{note};
+$data->{patronnote} = $patronnote;
+
( $data->{returned} ) = AddReturn( $barcode, $branchcode, $exempt_fine );
print to_json($data);