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

(-)a/C4/Circulation.pm (+46 lines)
Lines 2516-2521 sub GetOpenIssue { Link Here
2516
2516
2517
}
2517
}
2518
2518
2519
=head2 GetItemIssues
2520
2521
  $issues = &GetItemIssues($itemnumber, $history);
2522
2523
Returns patrons that have issued a book
2524
2525
C<$itemnumber> is the itemnumber
2526
C<$history> is false if you just want the current "issuer" (if any)
2527
and true if you want issues history from old_issues also.
2528
2529
Returns reference to an array of hashes
2530
2531
=cut
2532
2533
sub GetItemIssues {
2534
    my ( $itemnumber, $history ) = @_;
2535
    my $today = DateTime->now( time_zome => C4::Context->tz);  # get today date
2536
    $today->truncate( to => 'minute' );
2537
    my $sql = "SELECT * FROM issues
2538
              JOIN borrowers USING (borrowernumber)
2539
              JOIN items     USING (itemnumber)
2540
              WHERE issues.itemnumber = ? ";
2541
    if ($history) {
2542
        $sql .= "UNION ALL
2543
                 SELECT * FROM old_issues
2544
                 LEFT JOIN borrowers USING (borrowernumber)
2545
                 JOIN items USING (itemnumber)
2546
                 WHERE old_issues.itemnumber = ? ";
2547
    }
2548
    $sql .= "ORDER BY date_due DESC";
2549
    my $sth = C4::Context->dbh->prepare($sql);
2550
    if ($history) {
2551
        $sth->execute($itemnumber, $itemnumber);
2552
    } else {
2553
        $sth->execute($itemnumber);
2554
    }
2555
    my $results = $sth->fetchall_arrayref({});
2556
    foreach (@$results) {
2557
        my $date_due = dt_from_string($_->{date_due},'sql');
2558
        $date_due->truncate( to => 'minute' );
2559
2560
        $_->{overdue} = (DateTime->compare($date_due, $today) == -1) ? 1 : 0;
2561
    }
2562
    return $results;
2563
}
2564
2519
=head2 GetBiblioIssues
2565
=head2 GetBiblioIssues
2520
2566
2521
  $issues = GetBiblioIssues($biblionumber);
2567
  $issues = GetBiblioIssues($biblionumber);
(-)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 283-288 if ($barcode) { Link Here
283
    my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials });
283
    my $descriptions = Koha::AuthorisedValues->get_description_by_koha_field({frameworkcode => '', kohafield =>'items.materials', authorised_value => $materials });
284
    $materials = $descriptions->{lib} // '';
284
    $materials = $descriptions->{lib} // '';
285
285
286
    my $issue = GetItemIssue($itemnumber);
287
286
    $template->param(
288
    $template->param(
287
        title            => $biblio->{'title'},
289
        title            => $biblio->{'title'},
288
        homebranch       => $biblio->{'homebranch'},
290
        homebranch       => $biblio->{'homebranch'},
Lines 296-301 if ($barcode) { Link Here
296
        biblionumber     => $biblio->{'biblionumber'},
298
        biblionumber     => $biblio->{'biblionumber'},
297
        borrower         => $borrower,
299
        borrower         => $borrower,
298
        additional_materials => $materials,
300
        additional_materials => $materials,
301
        issue            => $issue,
299
    );
302
    );
300
303
301
    my %input = (
304
    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 1745-1750 CREATE TABLE `issues` ( -- information related to check outs or issues Link Here
1745
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
1745
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
1746
  `issuedate` datetime default NULL, -- date the item was checked out or issued
1746
  `issuedate` datetime default NULL, -- date the item was checked out or issued
1747
  `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
1747
  `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
1748
  `note` mediumtext default NULL, -- issue note text
1749
  `notedate` datetime default NULL, -- datetime of issue note (yyyy-mm-dd hh:mm::ss)
1748
  PRIMARY KEY (`issue_id`),
1750
  PRIMARY KEY (`issue_id`),
1749
  UNIQUE KEY `itemnumber` (`itemnumber`),
1751
  UNIQUE KEY `itemnumber` (`itemnumber`),
1750
  KEY `issuesborridx` (`borrowernumber`),
1752
  KEY `issuesborridx` (`borrowernumber`),
Lines 1774-1779 CREATE TABLE `old_issues` ( -- lists items that were checked out and have been r Link Here
1774
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
1776
  `timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, -- the date and time this record was last touched
1775
  `issuedate` datetime default NULL, -- date the item was checked out or issued
1777
  `issuedate` datetime default NULL, -- date the item was checked out or issued
1776
  `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
1778
  `onsite_checkout` int(1) NOT NULL default 0, -- in house use flag
1779
  `note` mediumtext default NULL, -- issue note text
1780
  `notedate` datetime default NULL, -- datetime of issue note (yyyy-mm-dd hh:mm::ss)
1777
  PRIMARY KEY (`issue_id`),
1781
  PRIMARY KEY (`issue_id`),
1778
  KEY `old_issuesborridx` (`borrowernumber`),
1782
  KEY `old_issuesborridx` (`borrowernumber`),
1779
  KEY `old_issuesitemidx` (`itemnumber`),
1783
  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 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 | $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 / +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
                    if ( data.patronnote != null ) {
71
                        $('.patron_note_' + data.itemnumber).html("Patron note: " + data.patronnote);
72
                    }
70
                } else {
73
                } else {
71
                    content = CIRCULATION_NOT_RETURNED;
74
                    content = CIRCULATION_NOT_RETURNED;
72
                    $(id).parent().parent().addClass('warn');
75
                    $(id).parent().parent().addClass('warn');
Lines 213-225 $(document).ready(function() { Link Here
213
                            due += "<span class='dmg'>" + oObj.damaged + "</span>";
216
                            due += "<span class='dmg'>" + oObj.damaged + "</span>";
214
                        }
217
                        }
215
218
219
                        var patron_note = " <span class='patron_note_" + oObj.itemnumber + "'></span>";
220
                        due +="<br>" + patron_note;
216
221
217
                        return due;
222
                        return due;
218
                    }
223
                    }
219
                },
224
                },
220
                {
225
                {
221
                    "mDataProp": function ( oObj ) {
226
                    "mDataProp": function ( oObj ) {
222
                        title = "<span class='strong'><a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber="
227
                        title = "<span id='title_" + oObj.itemnumber + "' class='strong'><a href='/cgi-bin/koha/catalogue/detail.pl?biblionumber="
223
                              + oObj.biblionumber
228
                              + oObj.biblionumber
224
                              + "'>"
229
                              + "'>"
225
                              + oObj.title;
230
                              + oObj.title;
Lines 243-249 $(document).ready(function() { Link Here
243
                            if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) {
248
                            if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) {
244
                                span_class = "circ-hlt";
249
                                span_class = "circ-hlt";
245
                            }
250
                            }
246
                            title += " - <span class='" + span_class + "'>" + oObj.itemnotes + "</span>"
251
                            title += " - <span class='" + span_class + "'>" + oObj.itemnotes + "</span>";
247
                        }
252
                        }
248
253
249
                        if ( oObj.itemnotes_nonpublic ) {
254
                        if ( oObj.itemnotes_nonpublic ) {
Lines 251-257 $(document).ready(function() { Link Here
251
                            if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) {
256
                            if ( $.datepicker.formatDate('yy-mm-dd', new Date(oObj.issuedate) ) == ymd ) {
252
                                span_class = "circ-hlt";
257
                                span_class = "circ-hlt";
253
                            }
258
                            }
254
                            title += " - <span class='" + span_class + "'>" + oObj.itemnotes_nonpublic + "</span>"
259
                            title += " - <span class='" + span_class + "'>" + oObj.itemnotes_nonpublic + "</span>";
255
                        }
260
                        }
256
261
257
                        var onsite_checkout = '';
262
                        var onsite_checkout = '';
Lines 269-275 $(document).ready(function() { Link Here
269
                              + "'>"
274
                              + "'>"
270
                              + oObj.barcode
275
                              + oObj.barcode
271
                              + "</a>"
276
                              + "</a>"
272
                              + onsite_checkout;
277
                              + onsite_checkout
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 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 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 ( Koha.Preference('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 ( Koha.Preference('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 ( Koha.Preference('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 (+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 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
265
$template->param( ISSUES       => \@issuedat );
267
$template->param( ISSUES       => \@issuedat );
266
$template->param( issues_count => $count );
268
$template->param( issues_count => $count );
267
$template->param( canrenew     => $canrenew );
269
$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