View | Details | Raw Unified | Return to bug 14224
Collapse All | Expand All

(-)a/Koha/Schema/Result/Issue.pm (+19 lines)
Lines 95-100 __PACKAGE__->table("issues"); Link Here
95
  default_value: 0
95
  default_value: 0
96
  is_nullable: 0
96
  is_nullable: 0
97
97
98
=head2 note
99
100
  data_type: 'mediumtext'
101
  is_nullable: 1
102
103
=head2 notedate
104
105
  data_type: 'datetime'
106
  datetime_undef_if_invalid: 1
107
  is_nullable: 1
108
98
=cut
109
=cut
99
110
100
__PACKAGE__->add_columns(
111
__PACKAGE__->add_columns(
Lines 143-148 __PACKAGE__->add_columns( Link Here
143
  },
154
  },
144
  "onsite_checkout",
155
  "onsite_checkout",
145
  { data_type => "integer", default_value => 0, is_nullable => 0 },
156
  { data_type => "integer", default_value => 0, is_nullable => 0 },
157
  "note",
158
  { data_type => "mediumtext", is_nullable => 1 },
159
  "notedate",
160
  {
161
    data_type => "datetime",
162
    datetime_undef_if_invalid => 1,
163
    is_nullable => 1,
164
  },
146
);
165
);
147
166
148
=head1 PRIMARY KEY
167
=head1 PRIMARY KEY
(-)a/circ/returns.pl (+3 lines)
Lines 284-289 if ($barcode) { Link Here
284
    my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials });
284
    my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials });
285
    $materials = $descriptions->{lib} // '';
285
    $materials = $descriptions->{lib} // '';
286
286
287
    my $issue = GetItemIssue($itemnumber);
288
287
    $template->param(
289
    $template->param(
288
        title            => $biblio->{'title'},
290
        title            => $biblio->{'title'},
289
        homebranch       => $biblio->{'homebranch'},
291
        homebranch       => $biblio->{'homebranch'},
Lines 297-302 if ($barcode) { Link Here
297
        biblionumber     => $biblio->{'biblionumber'},
299
        biblionumber     => $biblio->{'biblionumber'},
298
        borrower         => $borrower,
300
        borrower         => $borrower,
299
        additional_materials => $materials,
301
        additional_materials => $materials,
302
        issue            => $issue,
300
    );
303
    );
301
304
302
    my %input = (
305
    my %input = (
(-)a/installer/data/mysql/atomicupdate/bug_14224-add_new_issue_columns.sql (+4 lines)
Line 0 Link Here
1
ALTER IGNORE TABLE issues ADD `note` mediumtext default NULL AFTER `onsite_checkout`;
2
ALTER IGNORE TABLE issues ADD `notedate` datetime default NULL AFTER `note`;
3
ALTER IGNORE TABLE old_issues ADD `note` mediumtext default NULL AFTER `onsite_checkout`;
4
ALTER IGNORE TABLE old_issues ADD `notedate` datetime default NULL AFTER `note`;
(-)a/installer/data/mysql/atomicupdate/bug_14224-add_patron_notice_to_letters.sql (+1 lines)
Line 0 Link Here
1
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');
(-)a/installer/data/mysql/atomicupdate/bug_14224-issue_notes_syspref.sql (+1 lines)
Line 0 Link Here
1
INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`,`type`) VALUES ('AllowIssueNotes', '0', NULL, 'Allow patrons to submit notes about checked out items.','YesNo');
(-)a/installer/data/mysql/kohastructure.sql (+4 lines)
Lines 1753-1758 CREATE TABLE `issues` ( -- information related to check outs or issues Link Here
1753
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
1753
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
1754
  `issuedate` datetime default NULL, -- date the item was checked out or issued
1754
  `issuedate` datetime default NULL, -- date the item was checked out or issued
1755
  `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
1755
  `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
1756
  `note` mediumtext default NULL, -- issue note text
1757
  `notedate` datetime default NULL, -- datetime of issue note (yyyy-mm-dd hh:mm::ss)
1756
  PRIMARY KEY (`issue_id`),
1758
  PRIMARY KEY (`issue_id`),
1757
  UNIQUE KEY `itemnumber` (`itemnumber`),
1759
  UNIQUE KEY `itemnumber` (`itemnumber`),
1758
  KEY `issuesborridx` (`borrowernumber`),
1760
  KEY `issuesborridx` (`borrowernumber`),
Lines 1781-1786 CREATE TABLE `old_issues` ( -- lists items that were checked out and have been r Link Here
1781
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
1783
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
1782
  `issuedate` datetime default NULL, -- date the item was checked out or issued
1784
  `issuedate` datetime default NULL, -- date the item was checked out or issued
1783
  `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
1785
  `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
1786
  `note` mediumtext default NULL, -- issue note text
1787
  `notedate` datetime default NULL, -- datetime of issue note (yyyy-mm-dd hh:mm::ss)
1784
  PRIMARY KEY (`issue_id`),
1788
  PRIMARY KEY (`issue_id`),
1785
  KEY `old_issuesborridx` (`borrowernumber`),
1789
  KEY `old_issuesborridx` (`borrowernumber`),
1786
  KEY `old_issuesitemidx` (`itemnumber`),
1790
  KEY `old_issuesitemidx` (`itemnumber`),
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 22-27 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
22
('AllowHoldPolicyOverride','0',NULL,'Allow staff to override hold policies when placing holds','YesNo'),
22
('AllowHoldPolicyOverride','0',NULL,'Allow staff to override hold policies when placing holds','YesNo'),
23
('AllowHoldsOnDamagedItems','1','','Allow hold requests to be placed on damaged items','YesNo'),
23
('AllowHoldsOnDamagedItems','1','','Allow hold requests to be placed on damaged items','YesNo'),
24
('AllowHoldsOnPatronsPossessions','1',NULL,'Allow holds on records that patron have items of it','YesNo'),
24
('AllowHoldsOnPatronsPossessions','1',NULL,'Allow holds on records that patron have items of it','YesNo'),
25
('AllowIssueNotes', '0', NULL, 'Allow patrons to submit notes about checked out items.','YesNo'),
25
('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'),
26
('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'),
26
('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'),
27
('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'),
27
('AllowMultipleCovers','0','1','Allow multiple cover images to be attached to each bibliographic record.','YesNo'),
28
('AllowMultipleCovers','0','1','Allow multiple cover images to be attached to each bibliographic record.','YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref (+6 lines)
Lines 144-149 Circulation: Link Here
144
                  yes: Show
144
                  yes: Show
145
                  no: "Do not show"
145
                  no: "Do not show"
146
            - all items in the "Checked-in items" list, even items that were not checked out.
146
            - all items in the "Checked-in items" list, even items that were not checked out.
147
        -
148
            - pref: AllowIssueNotes
149
              choices:
150
                  yes: Allow
151
                  no: "Don't allow"
152
            - patrons to submit notes about checked out items.
147
153
148
    Checkout Policy:
154
    Checkout Policy:
149
        -
155
        -
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt (+10 lines)
Lines 183-188 $(document).ready(function () { Link Here
183
</div>
183
</div>
184
[% END %]
184
[% END %]
185
185
186
<!-- Patron has added an issue note -->
187
[% IF ( issue.note) %]
188
    <div class="dialog message">
189
        <h1>Patron note</h1>
190
        <p>[% issue.notedate | $KohaDates %]</p>
191
        <p><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% itembiblionumber %]"> [% title |html %]</a> [% author %]</p>
192
        <p>[% issue.note %]</p>
193
    </div>
194
[% END %]
195
186
<!-- Patron has fines -->
196
<!-- Patron has fines -->
187
[% IF ( fines ) %]
197
[% IF ( fines ) %]
188
    <div class="dialog alert">
198
    <div class="dialog alert">
(-)a/koha-tmpl/intranet-tmpl/prog/js/checkouts.js (-4 / +15 lines)
Lines 77-82 $(document).ready(function() { Link Here
77
                    content = CIRCULATION_RETURNED;
77
                    content = CIRCULATION_RETURNED;
78
                    $(id).parent().parent().addClass('ok');
78
                    $(id).parent().parent().addClass('ok');
79
                    $('#date_due_' + data.itemnumber).html(CIRCULATION_RETURNED);
79
                    $('#date_due_' + data.itemnumber).html(CIRCULATION_RETURNED);
80
                    if ( data.patronnote != null ) {
81
                        $('.patron_note_' + data.itemnumber).html("Patron note: " + data.patronnote);
82
                    }
80
                } else {
83
                } else {
81
                    content = CIRCULATION_NOT_RETURNED;
84
                    content = CIRCULATION_NOT_RETURNED;
82
                    $(id).parent().parent().addClass('warn');
85
                    $(id).parent().parent().addClass('warn');
Lines 223-235 $(document).ready(function() { Link Here
223
                            due += "<span class='dmg'>" + oObj.damaged + "</span>";
226
                            due += "<span class='dmg'>" + oObj.damaged + "</span>";
224
                        }
227
                        }
225
228
229
                        var patron_note = " <span class='patron_note_" + oObj.itemnumber + "'></span>";
230
                        due +="<br>" + patron_note;
226
231
227
                        return due;
232
                        return due;
228
                    }
233
                    }
229
                },
234
                },
230
                {
235
                {
231
                    "mDataProp": function ( oObj ) {
236
                    "mDataProp": function ( oObj ) {
232
                        title = "<span class='strong'><a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber="
237
                        title = "<span id='title_" + oObj.itemnumber + "' class='strong'><a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber="
233
                              + oObj.biblionumber
238
                              + oObj.biblionumber
234
                              + "'>"
239
                              + "'>"
235
                              + oObj.title;
240
                              + oObj.title;
Lines 250-261 $(document).ready(function() { Link Here
250
255
251
                        if ( oObj.itemnotes ) {
256
                        if ( oObj.itemnotes ) {
252
                            var span_class = "text-muted";
257
                            var span_class = "text-muted";
253
                            title += " - <span class='" + span_class + "'>" + oObj.itemnotes + "</span>"
258
                            if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) {
259
                                span_class = "circ-hlt";
260
                            }
261
                            title += " - <span class='" + span_class + "'>" + oObj.itemnotes + "</span>";
254
                        }
262
                        }
255
263
256
                        if ( oObj.itemnotes_nonpublic ) {
264
                        if ( oObj.itemnotes_nonpublic ) {
257
                            var span_class = "text-danger";
265
                            var span_class = "text-danger";
258
                            title += " - <span class='" + span_class + "'>" + oObj.itemnotes_nonpublic + "</span>"
266
                            if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) {
267
                                span_class = "circ-hlt";
268
                            }
269
                            title += " - <span class='" + span_class + "'>" + oObj.itemnotes_nonpublic + "</span>";
259
                        }
270
                        }
260
271
261
                        var onsite_checkout = '';
272
                        var onsite_checkout = '';
Lines 273-279 $(document).ready(function() { Link Here
273
                              + "'>"
284
                              + "'>"
274
                              + oObj.barcode
285
                              + oObj.barcode
275
                              + "</a>"
286
                              + "</a>"
276
                              + onsite_checkout;
287
                              + onsite_checkout
277
288
278
                        return title;
289
                        return title;
279
                    },
290
                    },
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-issue-note.tt (+54 lines)
Line 0 Link Here
1
[% USE Koha %]
2
[% USE KohaDates %]
3
[% USE Branches %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha online[% END %] catalog &rsaquo; Your library home</title>
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% BLOCK cssinclude %][% END %]
8
</head>
9
[% INCLUDE 'bodytag.inc' bodyid='opac-issue-note' %]
10
[% INCLUDE 'masthead.inc' %]
11
12
<div class="main">
13
    <ul class="breadcrumb">
14
        <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
15
        <li><a href="/cgi-bin/koha/opac-user.pl">[% firstname %] [% surname %]</a><span class="divider">&rsaquo;</span></li>
16
        <li><a href="#">Editing issue note for [% ISSUE.title %] - [% ISSUE.author %]</a></li>
17
    </ul>
18
19
    <div class="container-fluid">
20
        <div class="row-fluid">
21
            <div class="span2">
22
                <div id="navigation">
23
                    [% INCLUDE 'navigation.inc' IsPatronPage=1 %]
24
                </div>
25
            </div>
26
            <div class="span10">
27
                <div id="issuenote" class="maincontent">
28
                    <h3>Editing issue note for [% title %] [% author %]</h3>
29
                        [% IF not(Koha.Preference("AllowIssueNotes")) %]
30
                            Issue notes have not been enabled. Please contact the library.
31
                        [% ELSE %]
32
                            <form id="issue-note" action="/cgi-bin/koha/opac-issue-note.pl" method="post">
33
                                <fieldset>
34
                                    <label for="note" class="required">Note:</label>
35
                                    <input type="text" name="note" value="[% note %]">
36
                                    <input type="hidden" name="borrowernumber" value="[% borrowernumber %]">
37
                                    <input type="hidden" name="itemnumber" value="[% itemnumber %]">
38
                                    <input type="hidden" name="issue_id" value="[% issue_id %]">
39
                                    <input type="hidden" name="action" value="issuenote">
40
                                </fieldset>
41
                                <fieldset class="action">
42
                                    <input type="submit" value="Submit note" class="btn btn-default btn-sm"><a href="/cgi-bin/koha/opac-user.pl" class="cancel">Cancel</a>
43
                                </fieldset>
44
                            </form> <!-- issue-note -->
45
                        [% END %]
46
                </div> <!-- issuenote -->
47
            </div> <!-- span10 -->
48
        </div> <!-- row-fluid -->
49
    </div> <!-- container-fluid -->
50
51
</div> <!-- main -->
52
53
[% INCLUDE 'opac-bottom.inc' %]
54
[% BLOCK jsinclude %][% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (+94 lines)
Lines 120-125 Using this account is not recommended because some parts of Koha will not functi Link Here
120
                        </div>
120
                        </div>
121
                    [% END # / IF patron_flagged %]
121
                    [% END # / IF patron_flagged %]
122
122
123
                    <div class="alert alert-info" id="notesaved" style="display:none;"></div>
124
123
                    [% SET OPACMySummaryNote = Koha.Preference('OPACMySummaryNote') %]
125
                    [% SET OPACMySummaryNote = Koha.Preference('OPACMySummaryNote') %]
124
                    [% IF OPACMySummaryNote %][% OPACMySummaryNote %][% END %]
126
                    [% IF OPACMySummaryNote %][% OPACMySummaryNote %][% END %]
125
127
Lines 171-176 Using this account is not recommended because some parts of Koha will not functi Link Here
171
                                                [% IF ( OPACMySummaryHTML ) %]
173
                                                [% IF ( OPACMySummaryHTML ) %]
172
                                                    <th class="nosort">Links</th>
174
                                                    <th class="nosort">Links</th>
173
                                                [% END %]
175
                                                [% END %]
176
                                                [% IF ( Koha.Preference('AllowIssueNotes') ) %]
177
                                                    <th class="nosort">Note</th>
178
                                                [% END %]
174
                                            </tr>
179
                                            </tr>
175
                                        </thead>
180
                                        </thead>
176
                                        <tbody>
181
                                        <tbody>
Lines 290-295 Using this account is not recommended because some parts of Koha will not functi Link Here
290
                                                [% IF ( OPACMySummaryHTML ) %]
295
                                                [% IF ( OPACMySummaryHTML ) %]
291
                                                    <td class="links">[% ISSUE.MySummaryHTML %]</td>
296
                                                    <td class="links">[% ISSUE.MySummaryHTML %]</td>
292
                                                [% END %]
297
                                                [% END %]
298
                                                [% IF ( Koha.Preference('AllowIssueNotes') ) %]
299
                                                    <td class="note">
300
                                                        <input type="text" name="note" data-issue_id="[% ISSUE.issue_id %]" data-origvalue="[% ISSUE.note %]" value="[% ISSUE.note %]" readonly>
301
                                                        <a class="btn" name="js_submitnote" id="save_[% ISSUE.issue_id %]" style="display:none;">Submit note</a>
302
                                                        <a class="btn" name="nonjs_submitnote" href="/cgi-bin/koha/opac-issue-note.pl?issue_id=[% ISSUE.issue_id | url %]">Edit / Create note</a>
303
                                                    </td>
304
                                                [% END %]
293
                                            </tr>
305
                                            </tr>
294
                                        [% END # /FOREACH ISSUES %]
306
                                        [% END # /FOREACH ISSUES %]
295
                                    </tbody>
307
                                    </tbody>
Lines 894-899 Using this account is not recommended because some parts of Koha will not functi Link Here
894
                [% END %]
906
                [% END %]
895
            [% END %]
907
            [% END %]
896
908
909
            [% IF ( Koha.Preference('AllowIssueNotes') ) %]
910
911
                /* If JS enabled, show button, otherwise show link to redirect to a page where note can be submitted */
912
                $("a[name='nonjs_submitnote']").hide();
913
914
                $("input[name='note']").prop('readonly', false);
915
                $("input[name='note']").keyup(function(e){
916
                    /* prevent submitting of renewselected form */
917
                    if(e.which == 13)
918
                        e.preventDefault();
919
920
                    var $btn_save = $('#save_'+$(this).data('issue_id'));
921
                    var origvalue = $(this).data('origvalue');
922
                    var value = $(this).val();
923
924
                    if(origvalue != value) {
925
                        if(origvalue != "")
926
                            $btn_save.text('Submit changes');
927
                        else
928
                            $btn_save.text('Submit note');
929
                        $btn_save.show();
930
                    } else {
931
                        $btn_save.hide();
932
                    }
933
                });
934
935
                $("a[name='js_submitnote']").click(function(e){
936
                    var $self = $(this);
937
                    var title = $(this).parent().siblings('.title').html();
938
                    var $noteinput = $(this).siblings('input[name="note"]').first();
939
940
                    var ajaxData = {
941
                        'action': 'issuenote',
942
                        'issue_id': $noteinput.data('issue_id'),
943
                        'note': $noteinput.val(),
944
                    };
945
946
                    $.ajax({
947
                        url: '/cgi-bin/koha/svc/patron_notes/',
948
                        type: 'POST',
949
                        dataType: 'json',
950
                        data: ajaxData,
951
                    })
952
                    .done(function(data) {
953
                        var message = "";
954
                        if(data.status == 'saved') {
955
                            $("#notesaved").removeClass("alert-error");
956
                            $("#notesaved").addClass("alert-info");
957
                            $noteinput.data('origvalue', data.note);
958
                            $noteinput.val(data.note);
959
                            message = "<p>Your note about " + title + " has been saved and sent to the library.</p>";
960
                            $self.hide();
961
                        } else if(data.status == 'removed') {
962
                            $("#notesaved").removeClass("alert-error");
963
                            $("#notesaved").addClass("alert-info");
964
                            $noteinput.data('origvalue', "");
965
                            $noteinput.val("");
966
                            message = "<p>Your note about " + title + " was removed.</p>";
967
                            $self.hide();
968
                        } else {
969
                            $("#notesaved").removeClass("alert-info");
970
                            $("#notesaved").addClass("alert-error");
971
                            message = "<p>Your note about " + title + " could not be saved.</p>" +
972
                                      "<p style=\"font-weight:bold;\">" + data.error + "</p>";
973
                        }
974
975
                        message += "<p style=\"font-style:italic;\">" + data.note + "</p>";
976
                        $("#notesaved").html(message);
977
                    })
978
                    .fail(function(data) {
979
                        $("#notesaved").removeClass("alert-info");
980
                        $("#notesaved").addClass("alert-error");
981
                        var message = "<p>Your note about " + title + " could not be saved.</p>" +
982
                                      "<p style=\"font-weight:bold;\">Ajax request has failed.</p>";
983
                        $("#notesaved").html(message);
984
                    })
985
                    .always(function() {
986
                        $("#notesaved").show();
987
                    });
988
                });
989
            [% END %]
990
897
            $( ".suspend-until" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
991
            $( ".suspend-until" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
898
        });
992
        });
899
        //]]>
993
        //]]>
(-)a/opac/opac-issue-note.pl (+88 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# Copyright 2016 Aleisha Amohia <aleisha@catalyst.net.nz>
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use CGI qw ( -utf8 );
23
use C4::Koha;
24
use C4::Context;
25
use C4::Scrubber;
26
use C4::Members;
27
use C4::Output;
28
use C4::Auth;
29
use C4::Biblio;
30
use C4::Letters;
31
use Koha::Checkouts;
32
use Koha::DateUtils;
33
34
my $query = new CGI;
35
36
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
37
    {
38
        template_name   => "opac-issue-note.tt",
39
        query           => $query,
40
        type            => "opac",
41
        authnotrequired => 0,
42
        debug           => 1,
43
    }
44
);
45
46
my $member = C4::Members::GetMember( borrowernumber => $borrowernumber );
47
$template->param(
48
    firstname      => $member->{'firstname'},
49
    surname        => $member->{'surname'},
50
    borrowernumber => $borrowernumber,
51
);
52
53
my $issue_id = $query->param('issue_id');
54
my $issue = Koha::Checkouts->find( $issue_id );
55
my $itemnumber = $issue->itemnumber;
56
my $biblio = GetBiblioFromItemNumber($itemnumber);
57
$template->param(
58
    issue_id   => $issue_id,
59
    title      => $biblio->{'title'},
60
    author     => $biblio->{'author'},
61
    note       => $issue->note,
62
    itemnumber => $issue->itemnumber,
63
);
64
65
my $action = $query->param('action') || "";
66
if ( $action eq 'issuenote' && C4::Context->preference('AllowIssueNotes') ) {
67
    my $note = $query->param('note');
68
    my $scrubber = C4::Scrubber->new();
69
    my $clean_note = $scrubber->scrub($note);
70
    if ( $issue->set({ notedate => dt_from_string(), note => $clean_note })->store ) {
71
        if ($clean_note) { # only send email if note not empty
72
            my $branch = Koha::Libraries->find( $issue->branchcode );
73
            my $letter = C4::Letters::GetPreparedLetter (
74
                module => 'circulation',
75
                letter_code => 'PATRON_NOTE',
76
                branchcode => $branch,
77
                tables => {
78
                    'biblio' => $biblio->{biblionumber},
79
                    'borrowers' => $member->{borrowernumber},
80
                },
81
            );
82
            C4::Message->enqueue($letter, $member, 'email');
83
        }
84
    }
85
    print $query->redirect("/cgi-bin/koha/opac-user.pl");
86
}
87
88
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
(-)a/opac/opac-user.pl (+2 lines)
Lines 33-38 use C4::Output; Link Here
33
use C4::Biblio;
33
use C4::Biblio;
34
use C4::Items;
34
use C4::Items;
35
use C4::Letters;
35
use C4::Letters;
36
use Koha::Libraries;
36
use Koha::DateUtils;
37
use Koha::DateUtils;
37
use Koha::Holds;
38
use Koha::Holds;
38
use Koha::Database;
39
use Koha::Database;
Lines 264-269 if ($issues){ Link Here
264
}
265
}
265
my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
266
my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
266
$canrenew = 0 if ($overduesblockrenewing ne 'allow' and $overdues_count == $count);
267
$canrenew = 0 if ($overduesblockrenewing ne 'allow' and $overdues_count == $count);
268
267
$template->param( ISSUES       => \@issuedat );
269
$template->param( ISSUES       => \@issuedat );
268
$template->param( issues_count => $count );
270
$template->param( issues_count => $count );
269
$template->param( canrenew     => $canrenew );
271
$template->param( canrenew     => $canrenew );
(-)a/opac/svc/patron_notes (+108 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Copyright 2014 BibLibre
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use C4::Service;
23
use C4::Auth qw /check_cookie_auth/;
24
use C4::Letters;
25
use CGI;
26
use C4::Output qw(:DEFAULT :ajax);
27
use C4::Scrubber;
28
use C4::Circulation;
29
use C4::Members;
30
use C4::Biblio;
31
use Koha::Checkouts;
32
use Koha::DateUtils;
33
34
=head1 NAME
35
36
svc/patron_notes - Web service for setting patron notes on items
37
38
=head1 DESCRIPTION
39
40
=cut
41
42
# AJAX requests
43
my $is_ajax = is_ajax();
44
my $query = new CGI;
45
my ( $auth_status, $sessionID ) = check_cookie_auth( $query->cookie('CGISESSID'), {} );
46
if ( $auth_status ne "ok" ) {
47
    exit 0;
48
}
49
if ($is_ajax) {
50
    my $action = $query->param('action');
51
52
    # Issue Note
53
    if ( $action eq 'issuenote' && C4::Context->preference('AllowIssueNotes') ) {
54
        my $scrubber = C4::Scrubber->new();
55
        my $note = $query->param('note');
56
        my $issue_id = $query->param('issue_id');
57
        my $clean_note = $scrubber->scrub($note);
58
        my $status = "saved";
59
        my $error = "";
60
        my ($member, $issue);
61
62
        my ( $template, $borrowernumber, $cookie ) = C4::Auth::get_template_and_user({
63
            template_name   => "opac-user.tt",
64
            query           => $query,
65
            type            => "opac",
66
            authnotrequired => 1,
67
        });
68
69
        # verify issue_id
70
        if ( $issue_id =~ /\d+/ ) {
71
            $member = GetMember(borrowernumber => $borrowernumber);
72
            $issue = Koha::Checkouts->find($issue_id);
73
            if ( $issue->borrowernumber != $borrowernumber ) {
74
                $status = "fail";
75
                $error = "Invalid issue id!";
76
            }
77
        } else {
78
            $status = "fail";
79
            $error = "Invalid issue id!";
80
        }
81
82
        if ( (not $error) && $issue->set({ notedate => dt_from_string(), note => $clean_note })->store ) {
83
            if($clean_note) { # only send email if note not empty
84
                my $branch = Koha::Libraries->find( $issue->branchcode );
85
                my $biblio = GetBiblioFromItemNumber($issue->itemnumber);
86
                my $letter = C4::Letters::GetPreparedLetter (
87
                    module => 'circulation',
88
                    letter_code => 'PATRON_NOTE',
89
                    branchcode => $branch,
90
                    tables => {
91
                        'biblio' => $biblio->{biblionumber},
92
                        'borrowers' => $member->{borrowernumber},
93
                    },
94
                );
95
                C4::Message->enqueue($letter, $member, 'email');
96
            } else { # note empty, i.e removed
97
                $status = "removed";
98
            }
99
        } else {
100
            $status = "fail";
101
            $error = "Perhaps the item has already been checked in?";
102
        }
103
104
        my $response = "{\"status\": \"$status\", \"note\": \"$clean_note\", \"issue_id\": \"$issue_id\", \"error\": \"$error\"}";
105
        output_with_http_headers($query, undef, $response, 'js');
106
        exit;
107
    } # END Issue Note
108
}
(-)a/svc/checkin (-2 / +9 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
2
3
# Copyright 2014 ByWater Solutions
3
# Copyright 2016 Aleisha Amohia <aleisha@catalyst.net.nz>
4
#
4
#
5
# This file is part of Koha.
5
# This file is part of Koha.
6
#
6
#
Lines 72-77 if ( C4::Context->preference("ReturnToShelvingCart") ) { Link Here
72
    ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} );
72
    ModItem( $item, $item->{'biblionumber'}, $item->{'itemnumber'} );
73
}
73
}
74
74
75
my $dbh = C4::Context->dbh;
76
my $query = "SELECT note FROM issues WHERE itemnumber = ?";
77
my $sth = $dbh->prepare($query);
78
$sth->execute($itemnumber);
79
my $issue = $sth->fetchrow_hashref;
80
my $patronnote = $issue->{note};
81
$data->{patronnote} = $patronnote;
82
75
( $data->{returned} ) = AddReturn( $barcode, $branchcode, $exempt_fine );
83
( $data->{returned} ) = AddReturn( $barcode, $branchcode, $exempt_fine );
76
84
77
print to_json($data);
85
print to_json($data);
78
- 

Return to bug 14224