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

(-)a/C4/Circulation.pm (-1 lines)
Lines 2511-2517 sub GetOpenIssue { Link Here
2511
=head2 GetIssues
2511
=head2 GetIssues
2512
2512
2513
    $issues = GetIssues({});    # return all issues!
2513
    $issues = GetIssues({});    # return all issues!
2514
    $issues = GetIssues({ borrowernumber => $borrowernumber, biblionumber => $biblionumber });
2515
2514
2516
Returns all pending issues that match given criteria.
2515
Returns all pending issues that match given criteria.
2517
Returns a arrayref or undef if an error occurs.
2516
Returns a arrayref or undef if an error occurs.
(-)a/Koha/Schema/Result/Issue.pm (-2 / +21 lines)
Lines 101-106 __PACKAGE__->table("issues"); Link Here
101
  default_value: 0
101
  default_value: 0
102
  is_nullable: 0
102
  is_nullable: 0
103
103
104
=head2 note
105
106
  data_type: 'mediumtext'
107
  is_nullable: 1
108
109
=head2 notedate
110
111
  data_type: 'datetime'
112
  datetime_undef_if_invalid: 1
113
  is_nullable: 1
114
104
=cut
115
=cut
105
116
106
__PACKAGE__->add_columns(
117
__PACKAGE__->add_columns(
Lines 151-156 __PACKAGE__->add_columns( Link Here
151
  },
162
  },
152
  "onsite_checkout",
163
  "onsite_checkout",
153
  { data_type => "integer", default_value => 0, is_nullable => 0 },
164
  { data_type => "integer", default_value => 0, is_nullable => 0 },
165
  "note",
166
  { data_type => "mediumtext", is_nullable => 1 },
167
  "notedate",
168
  {
169
    data_type => "datetime",
170
    datetime_undef_if_invalid => 1,
171
    is_nullable => 1,
172
  },
154
);
173
);
155
174
156
=head1 PRIMARY KEY
175
=head1 PRIMARY KEY
Lines 222-229 __PACKAGE__->belongs_to( Link Here
222
);
241
);
223
242
224
243
225
# Created by DBIx::Class::Schema::Loader v0.07039 @ 2015-11-04 12:00:58
244
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-12-01 02:20:55
226
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:kREecsHr6wZPiokS946BHw
245
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:a7FCuypwxtuE6oJjEnRJRg
227
246
228
__PACKAGE__->belongs_to(
247
__PACKAGE__->belongs_to(
229
    "borrower",
248
    "borrower",
(-)a/circ/returns.pl (+3 lines)
Lines 282-287 if ($barcode) { Link Here
282
    my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials });
282
    my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials });
283
    $materials = $descriptions->{lib} // '';
283
    $materials = $descriptions->{lib} // '';
284
284
285
    my $issue = GetItemIssue($itemnumber);
286
285
    $template->param(
287
    $template->param(
286
        title            => $biblio->{'title'},
288
        title            => $biblio->{'title'},
287
        homebranch       => $biblio->{'homebranch'},
289
        homebranch       => $biblio->{'homebranch'},
Lines 295-300 if ($barcode) { Link Here
295
        biblionumber     => $biblio->{'biblionumber'},
297
        biblionumber     => $biblio->{'biblionumber'},
296
        borrower         => $borrower,
298
        borrower         => $borrower,
297
        additional_materials => $materials,
299
        additional_materials => $materials,
300
        issue            => $issue,
298
    );
301
    );
299
302
300
    my %input = (
303
    my %input = (
(-)a/installer/data/mysql/atomicupdate/bug_14224-add_new_issue_columns.sql (+2 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`;
(-)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 (+30 lines)
Lines 841-846 CREATE TABLE `import_items` ( Link Here
841
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
841
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
842
842
843
--
843
--
844
-- Table structure for table `issues`
845
--
846
847
DROP TABLE IF EXISTS `issues`;
848
CREATE TABLE `issues` ( -- information related to check outs or issues
849
  `issue_id` int(11) NOT NULL AUTO_INCREMENT, -- primary key for issues table
850
  `borrowernumber` int(11), -- foreign key, linking this to the borrowers table for the patron this item was checked out to
851
  `itemnumber` int(11), -- foreign key, linking this to the items table for the item that was checked out
852
  `date_due` datetime default NULL, -- datetime the item is due (yyyy-mm-dd hh:mm::ss)
853
  `branchcode` varchar(10) default NULL, -- foreign key, linking to the branches table for the location the item was checked out
854
  `returndate` datetime default NULL, -- date the item was returned, will be NULL until moved to old_issues
855
  `lastreneweddate` datetime default NULL, -- date the item was last renewed
856
  `return` varchar(4) default NULL,
857
  `renewals` tinyint(4) default NULL, -- lists the number of times the item was renewed
858
  `auto_renew` BOOLEAN default FALSE, -- automatic renewal
859
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
860
  `issuedate` datetime default NULL, -- date the item was checked out or issued
861
  `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
862
  `note` mediumtext default NULL, -- issue note text
863
  `notedate` datetime default NULL, -- datetime of issue note (yyyy-mm-dd hh:mm::ss)
864
  PRIMARY KEY (`issue_id`),
865
  KEY `issuesborridx` (`borrowernumber`),
866
  KEY `itemnumber_idx` (`itemnumber`),
867
  KEY `branchcode_idx` (`branchcode`),
868
  KEY `bordate` (`borrowernumber`,`timestamp`),
869
  CONSTRAINT `issues_ibfk_1` FOREIGN KEY (`borrowernumber`) REFERENCES `borrowers` (`borrowernumber`) ON DELETE RESTRICT ON UPDATE CASCADE,
870
  CONSTRAINT `issues_ibfk_2` FOREIGN KEY (`itemnumber`) REFERENCES `items` (`itemnumber`) ON DELETE RESTRICT ON UPDATE CASCADE
871
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
872
873
--
844
-- Table structure for table `issuingrules`
874
-- Table structure for table `issuingrules`
845
--
875
--
846
876
(-)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 136-141 Circulation: Link Here
136
                  yes: Show
136
                  yes: Show
137
                  no: "Do not show"
137
                  no: "Do not show"
138
            - all items in the "Checked-in items" list, even items that were not checked out.
138
            - all items in the "Checked-in items" list, even items that were not checked out.
139
        -
140
            - pref: AllowIssueNotes
141
              choices:
142
                  yes: Allow
143
                  no: "Don't allow"
144
            - patrons to submit notes about checked out items.
139
145
140
    Checkout Policy:
146
    Checkout Policy:
141
        -
147
        -
(-)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 %]</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 / +9 lines)
Lines 67-72 $(document).ready(function() { Link Here
67
                    content = CIRCULATION_RETURNED;
67
                    content = CIRCULATION_RETURNED;
68
                    $(id).parent().parent().addClass('ok');
68
                    $(id).parent().parent().addClass('ok');
69
                    $('#date_due_' + data.itemnumber).html(CIRCULATION_RETURNED);
69
                    $('#date_due_' + data.itemnumber).html(CIRCULATION_RETURNED);
70
                    $('#patron_note_' + data.itemnumber).html("Patron note: " + data.patronnote);
70
                } else {
71
                } else {
71
                    content = CIRCULATION_NOT_RETURNED;
72
                    content = CIRCULATION_NOT_RETURNED;
72
                    $(id).parent().parent().addClass('warn');
73
                    $(id).parent().parent().addClass('warn');
Lines 219-225 $(document).ready(function() { Link Here
219
                },
220
                },
220
                {
221
                {
221
                    "mDataProp": function ( oObj ) {
222
                    "mDataProp": function ( oObj ) {
222
                        title = "<span class='strong'><a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber="
223
                        title = "<span id='title_" + oObj.itemnumber + "' class='strong'><a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber="
223
                              + oObj.biblionumber
224
                              + oObj.biblionumber
224
                              + "'>"
225
                              + "'>"
225
                              + oObj.title;
226
                              + oObj.title;
Lines 243-249 $(document).ready(function() { Link Here
243
                            if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) {
244
                            if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) {
244
                                span_class = "circ-hlt";
245
                                span_class = "circ-hlt";
245
                            }
246
                            }
246
                            title += " - <span class='" + span_class + "'>" + oObj.itemnotes + "</span>"
247
                            title += " - <span class='" + span_class + "'>" + oObj.itemnotes + "</span>";
247
                        }
248
                        }
248
249
249
                        if ( oObj.itemnotes_nonpublic ) {
250
                        if ( oObj.itemnotes_nonpublic ) {
Lines 251-257 $(document).ready(function() { Link Here
251
                            if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) {
252
                            if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) {
252
                                span_class = "circ-hlt";
253
                                span_class = "circ-hlt";
253
                            }
254
                            }
254
                            title += " - <span class='" + span_class + "'>" + oObj.itemnotes_nonpublic + "</span>"
255
                            title += " - <span class='" + span_class + "'>" + oObj.itemnotes_nonpublic + "</span>";
255
                        }
256
                        }
256
257
257
                        var onsite_checkout = '';
258
                        var onsite_checkout = '';
Lines 259-264 $(document).ready(function() { Link Here
259
                            onsite_checkout += " <span class='onsite_checkout'>(" + INHOUSE_USE + ")</span>";
260
                            onsite_checkout += " <span class='onsite_checkout'>(" + INHOUSE_USE + ")</span>";
260
                        }
261
                        }
261
262
263
                        var patron_note = " <span id='patron_note_" + oObj.itemnumber + "'></span>";
264
262
                        title += " "
265
                        title += " "
263
                              + "<a href='/cgi-bin/koha/catalogue/moredetail.pl?biblionumber="
266
                              + "<a href='/cgi-bin/koha/catalogue/moredetail.pl?biblionumber="
264
                              + oObj.biblionumber
267
                              + oObj.biblionumber
Lines 269-275 $(document).ready(function() { Link Here
269
                              + "'>"
272
                              + "'>"
270
                              + oObj.barcode
273
                              + oObj.barcode
271
                              + "</a>"
274
                              + "</a>"
272
                              + onsite_checkout;
275
                              + onsite_checkout
276
                              + "<br>"
277
                              + patron_note
273
278
274
                        return title;
279
                        return title;
275
                    },
280
                    },
(-)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"><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 165-170 Using this account is not recommended because some parts of Koha will not functi Link Here
165
                                                [% IF ( OPACMySummaryHTML ) %]
167
                                                [% IF ( OPACMySummaryHTML ) %]
166
                                                    <th class="nosort">Links</th>
168
                                                    <th class="nosort">Links</th>
167
                                                [% END %]
169
                                                [% END %]
170
                                                [% IF ( AllowIssueNotes ) %]
171
                                                    <th class="nosort">Note</th>
172
                                                [% END %]
168
                                            </tr>
173
                                            </tr>
169
                                        </thead>
174
                                        </thead>
170
                                        <tbody>
175
                                        <tbody>
Lines 283-288 Using this account is not recommended because some parts of Koha will not functi Link Here
283
                                                [% IF ( OPACMySummaryHTML ) %]
288
                                                [% IF ( OPACMySummaryHTML ) %]
284
                                                    <td class="links">[% ISSUE.MySummaryHTML %]</td>
289
                                                    <td class="links">[% ISSUE.MySummaryHTML %]</td>
285
                                                [% END %]
290
                                                [% END %]
291
                                                [% IF ( AllowIssueNotes ) %]
292
                                                    <td class="note">
293
                                                        <input type="text" name="note" data-issue_id="[% ISSUE.issue_id %]" data-origvalue="[% ISSUE.note %]" value="[% ISSUE.note %]" readonly>
294
                                                        <a class="btn" name="js_submitnote" id="save_[% ISSUE.issue_id %]" style="display:none;">Submit note</a>
295
                                                        <a class="btn" name="nonjs_submitnote" href="/cgi-bin/koha/opac-issue-note.pl?issue_id=[% ISSUE.issue_id | url %]">Edit / Create note</a>
296
                                                    </td>
297
                                                [% END %]
286
                                            </tr>
298
                                            </tr>
287
                                        [% END # /FOREACH ISSUES %]
299
                                        [% END # /FOREACH ISSUES %]
288
                                    </tbody>
300
                                    </tbody>
Lines 883-888 Using this account is not recommended because some parts of Koha will not functi Link Here
883
                [% END %]
895
                [% END %]
884
            [% END %]
896
            [% END %]
885
897
898
            [% IF ( AllowIssueNotes ) %]
899
900
                /* If JS enabled, show button, otherwise show link to redirect to a page where note can be submitted */
901
                $("a[name='nonjs_submitnote']").hide();
902
903
                $("input[name='note']").prop('readonly', false);
904
                $("input[name='note']").keyup(function(e){
905
                    /* prevent submitting of renewselected form */
906
                    if(e.which == 13)
907
                        e.preventDefault();
908
909
                    var $btn_save = $('#save_'+$(this).data('issue_id'));
910
                    var origvalue = $(this).data('origvalue');
911
                    var value = $(this).val();
912
913
                    if(origvalue != value) {
914
                        if(origvalue != "")
915
                            $btn_save.text('Submit changes');
916
                        else
917
                            $btn_save.text('Submit note');
918
                        $btn_save.show();
919
                    } else {
920
                        $btn_save.hide();
921
                    }
922
                });
923
924
                $("a[name='js_submitnote']").click(function(e){
925
                    var $self = $(this);
926
                    var title = $(this).parent().siblings('.title').html();
927
                    var $noteinput = $(this).siblings('input[name="note"]').first();
928
929
                    var ajaxData = {
930
                        'action': 'issuenote',
931
                        'issue_id': $noteinput.data('issue_id'),
932
                        'note': $noteinput.val(),
933
                    };
934
935
                    $.ajax({
936
                        url: '/cgi-bin/koha/svc/patron_notes/',
937
                        type: 'POST',
938
                        dataType: 'json',
939
                        data: ajaxData,
940
                    })
941
                    .done(function(data) {
942
                        var message = "";
943
                        if(data.status == 'saved') {
944
                            $("#notesaved").removeClass("alert-error");
945
                            $("#notesaved").addClass("alert-info");
946
                            $noteinput.data('origvalue', data.note);
947
                            $noteinput.val(data.note);
948
                            message = "<p>Your note about " + title + " has been saved and sent to the library.</p>";
949
                            $self.hide();
950
                        } else if(data.status == 'removed') {
951
                            $("#notesaved").removeClass("alert-error");
952
                            $("#notesaved").addClass("alert-info");
953
                            $noteinput.data('origvalue', "");
954
                            $noteinput.val("");
955
                            message = "<p>Your note about " + title + " was removed.</p>";
956
                            $self.hide();
957
                        } else {
958
                            $("#notesaved").removeClass("alert-info");
959
                            $("#notesaved").addClass("alert-error");
960
                            message = "<p>Your note about " + title + " could not be saved.</p>" +
961
                                      "<p style=\"font-weight:bold;\">" + data.error + "</p>";
962
                        }
963
964
                        message += "<p style=\"font-style:italic;\">" + data.note + "</p>";
965
                        $("#notesaved").html(message);
966
                    })
967
                    .fail(function(data) {
968
                        $("#notesaved").removeClass("alert-info");
969
                        $("#notesaved").addClass("alert-error");
970
                        var message = "<p>Your note about " + title + " could not be saved.</p>" +
971
                                      "<p style=\"font-weight:bold;\">Ajax request has failed.</p>";
972
                        $("#notesaved").html(message);
973
                    })
974
                    .always(function() {
975
                        $("#notesaved").show();
976
                    });
977
                });
978
            [% END %]
979
886
            $( ".suspend-until" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
980
            $( ".suspend-until" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
887
        });
981
        });
888
        //]]>
982
        //]]>
(-)a/opac/opac-issue-note.pl (+89 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::Issues;
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 $issueobj = Koha::Issues->find( $issue_id );
55
my $issue = $issueobj->unblessed;
56
my $itemnumber = $issue->{'itemnumber'};
57
my $biblio = GetBiblioFromItemNumber($itemnumber);
58
$template->param(
59
    issue_id   => $issue_id,
60
    title      => $biblio->{'title'},
61
    author     => $biblio->{'author'},
62
    note       => $issue->{'note'},
63
    itemnumber => $issue->{'itemnumber'},
64
);
65
66
my $action = $query->param('action') || "";
67
if ( $action eq 'issuenote' && C4::Context->preference('AllowIssueNotes') ) {
68
    my $note = $query->param('note');
69
    my $scrubber = C4::Scrubber->new();
70
    my $clean_note = $scrubber->scrub($note);
71
    if ( $issueobj->set({ notedate => dt_from_string(), note => $clean_note })->store ) {
72
        if ($clean_note) { # only send email if note not empty
73
            my $branch = Koha::Libraries->find( $issue->{branchcode} );
74
            my $letter = C4::Letters::GetPreparedLetter (
75
                module => 'circulation',
76
                letter_code => 'PATRON_NOTE',
77
                branchcode => $branch,
78
                tables => {
79
                    'biblio' => $biblio->{biblionumber},
80
                    'borrowers' => $member->{borrowernumber},
81
                },
82
            );
83
            C4::Message->enqueue($letter, $member, 'email');
84
        }
85
    }
86
    print $query->redirect("/cgi-bin/koha/opac-user.pl");
87
}
88
89
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
(-)a/opac/opac-user.pl (+3 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 262-267 if ($issues){ Link Here
262
}
263
}
263
my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
264
my $overduesblockrenewing = C4::Context->preference('OverduesBlockRenewing');
264
$canrenew = 0 if ($overduesblockrenewing ne 'allow' and $overdues_count == $count);
265
$canrenew = 0 if ($overduesblockrenewing ne 'allow' and $overdues_count == $count);
266
267
$template->param( AllowIssueNotes => C4::Context->preference('AllowIssueNotes') );
265
$template->param( ISSUES       => \@issuedat );
268
$template->param( ISSUES       => \@issuedat );
266
$template->param( issues_count => $count );
269
$template->param( issues_count => $count );
267
$template->param( canrenew     => $canrenew );
270
$template->param( canrenew     => $canrenew );
(-)a/opac/svc/patron_notes (+109 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::Issues;
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, $issueobj, $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
            $issueobj = Koha::Issues->find($issue_id);
73
            $issue = $issueobj->unblessed;
74
            if ( $issue->{'borrowernumber'} != $borrowernumber ) {
75
                $status = "fail";
76
                $error = "Invalid issue id!";
77
            }
78
        } else {
79
            $status = "fail";
80
            $error = "Invalid issue id!";
81
        }
82
83
        if ( (not $error) && $issueobj->set({ notedate => dt_from_string(), note => $clean_note })->store ) {
84
            if($clean_note) { # only send email if note not empty
85
                my $branch = Koha::Libraries->find( $issue->{branchcode} );
86
                my $biblio = GetBiblioFromItemNumber($issue->{'itemnumber'});
87
                my $letter = C4::Letters::GetPreparedLetter (
88
                    module => 'circulation',
89
                    letter_code => 'PATRON_NOTE',
90
                    branchcode => $branch,
91
                    tables => {
92
                        'biblio' => $biblio->{biblionumber},
93
                        'borrowers' => $member->{borrowernumber},
94
                    },
95
                );
96
                C4::Message->enqueue($letter, $member, 'email');
97
            } else { # note empty, i.e removed
98
                $status = "removed";
99
            }
100
        } else {
101
            $status = "fail";
102
            $error = "Perhaps the item has already been checked in?";
103
        }
104
105
        my $response = "{\"status\": \"$status\", \"note\": \"$clean_note\", \"issue_id\": \"$issue_id\", \"error\": \"$error\"}";
106
        output_with_http_headers($query, undef, $response, 'js');
107
        exit;
108
    } # END Issue Note
109
}
(-)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