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

(-)a/Koha/Schema/Result/Issue.pm (-2 / +9 lines)
Lines 112-117 __PACKAGE__->table("issues"); Link Here
112
  datetime_undef_if_invalid: 1
112
  datetime_undef_if_invalid: 1
113
  is_nullable: 1
113
  is_nullable: 1
114
114
115
=head2 noteseen
116
117
  data_type: 'integer'
118
  is_nullable: 1
119
115
=cut
120
=cut
116
121
117
__PACKAGE__->add_columns(
122
__PACKAGE__->add_columns(
Lines 170-175 __PACKAGE__->add_columns( Link Here
170
    datetime_undef_if_invalid => 1,
175
    datetime_undef_if_invalid => 1,
171
    is_nullable => 1,
176
    is_nullable => 1,
172
  },
177
  },
178
  "noteseen",
179
  { data_type => "integer", is_nullable => 1 },
173
);
180
);
174
181
175
=head1 PRIMARY KEY
182
=head1 PRIMARY KEY
Lines 241-248 __PACKAGE__->belongs_to( Link Here
241
);
248
);
242
249
243
250
244
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-12-01 02:20:55
251
# Created by DBIx::Class::Schema::Loader v0.07042 @ 2016-12-12 02:41:09
245
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:a7FCuypwxtuE6oJjEnRJRg
252
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ZF/YAX9BT1WrgCLUsXSqXQ
246
253
247
__PACKAGE__->belongs_to(
254
__PACKAGE__->belongs_to(
248
    "borrower",
255
    "borrower",
(-)a/circ/checkout-notes.pl (+71 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::Context;
24
use C4::Output;
25
use C4::Auth;
26
use Koha::Checkouts;
27
28
my $query = new CGI;
29
30
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
31
    {
32
        template_name   => "circ/checkout-notes.tt",
33
        query           => $query,
34
        type            => "intranet",
35
        authnotrequired => 0,
36
        flagsrequired   => { circulation => "manage_checkout_notes" },
37
    }
38
);
39
40
my $schema = Koha::Database->new()->schema();
41
my @notes = $schema->resultset('Issue')->search({ 'me.note' => { '!=', undef } }, { prefetch => [ 'borrower', { item => 'biblionumber' } ] });
42
$template->param(
43
    notes     => \@notes,
44
);
45
46
my $action;
47
foreach (qw( seen notseen )) {
48
    $action = $_ if ( $query->param("mark_selected-$_") );
49
}
50
$action ||= 'none';
51
52
my @issue_ids = $query->multi_param('issue_ids');
53
54
if ( $action eq 'seen' ) {
55
    foreach my $issue_id ( @issue_ids ) {
56
        my $issue = Koha::Checkouts->find($issue_id);
57
        $issue->set({ noteseen => 1 })->store;
58
    }
59
} elsif ( $action eq 'notseen' ) {
60
    foreach my $issue_id ( @issue_ids ) {
61
        my $issue = Koha::Checkouts->find($issue_id);
62
        $issue->set({ noteseen => 0 })->store;
63
    }
64
}
65
66
$template->param(
67
    selected_count => scalar(@issue_ids),
68
    action         => $action,
69
);
70
71
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/circ/circulation-home.pl (+3 lines)
Lines 22-27 use C4::Auth; Link Here
22
use C4::Output;
22
use C4::Output;
23
use C4::Context;
23
use C4::Context;
24
use Koha::BiblioFrameworks;
24
use Koha::BiblioFrameworks;
25
use Koha::Checkouts;
25
26
26
my $query = new CGI;
27
my $query = new CGI;
27
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user(
28
my ($template, $loggedinuser, $cookie, $flags) = get_template_and_user(
Lines 41-45 $template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find( 'FA' ) Link Here
41
$template->param( display_transfer => 1 ) if ( ($flags->{'superlibrarian'} == 1) || (C4::Context->preference("IndependentBranches") == 0) );
42
$template->param( display_transfer => 1 ) if ( ($flags->{'superlibrarian'} == 1) || (C4::Context->preference("IndependentBranches") == 0) );
42
$template->{'VARS'}->{'AllowOfflineCirculation'} = C4::Context->preference('AllowOfflineCirculation');
43
$template->{'VARS'}->{'AllowOfflineCirculation'} = C4::Context->preference('AllowOfflineCirculation');
43
44
45
my $pending_checkout_notes = Koha::Checkouts->search({ noteseen => 0 })->count;
46
$template->param( pending_checkout_notes => $pending_checkout_notes );
44
47
45
output_html_with_http_headers $query, $cookie, $template->output;
48
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/installer/data/mysql/atomicupdate/bug-17698_add-noteseen-column-to-issues.sql (+13 lines)
Line 0 Link Here
1
$DBversion = 'XXX';
2
if( CheckVersion( $DBversion ) ) {
3
    unless( column_exists( 'issues', 'noteseen' ) ) {
4
        $dbh->do(q|ALTER TABLE issues ADD noteseen int(1) default NULL AFTER notedate|);
5
    }
6
7
    unless( column_exists( 'old_issues', 'noteseen' ) ) {
8
        $dbh->do(q|ALTER TABLE old_issues ADD noteseen int(1) default NULL AFTER notedate|);
9
    }
10
11
    SetVersion( $DBversion );
12
    print "Upgrade to $DBversion done (Bug 17698: Add column issues.noteseen and old_issues.noteseen)\n";
13
}
(-)a/installer/data/mysql/atomicupdate/bug-17698_add-permission-to-manage-issue-notes.sql (+1 lines)
Line 0 Link Here
1
INSERT INTO permissions (module_bit, code, description) VALUES ( 1, 'manage_checkout_notes', 'Mark checkout notes as seen/not seen');
(-)a/installer/data/mysql/kohastructure.sql (+1 lines)
Lines 1778-1783 CREATE TABLE `old_issues` ( -- lists items that were checked out and have been r Link Here
1778
  `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
1779
  `note` mediumtext default NULL, -- issue note text
1780
  `notedate` datetime default NULL, -- datetime of issue note (yyyy-mm-dd hh:mm::ss)
1780
  `notedate` datetime default NULL, -- datetime of issue note (yyyy-mm-dd hh:mm::ss)
1781
  `noteseen` int(1) default NULL, -- describes whether issue note has been seen 1, not been seen 0 or doesn't exist null
1781
  PRIMARY KEY (`issue_id`),
1782
  PRIMARY KEY (`issue_id`),
1782
  KEY `old_issuesborridx` (`borrowernumber`),
1783
  KEY `old_issuesborridx` (`borrowernumber`),
1783
  KEY `old_issuesitemidx` (`itemnumber`),
1784
  KEY `old_issuesitemidx` (`itemnumber`),
(-)a/installer/data/mysql/userpermissions.sql (+1 lines)
Lines 5-10 INSERT INTO permissions (module_bit, code, description) VALUES Link Here
5
   ( 1, 'force_checkout', 'Force checkout if a limitation exists'),
5
   ( 1, 'force_checkout', 'Force checkout if a limitation exists'),
6
   ( 1, 'manage_restrictions', 'Manage restrictions for accounts'),
6
   ( 1, 'manage_restrictions', 'Manage restrictions for accounts'),
7
   ( 1, 'self_checkout', 'Perform self checkout at the OPAC. It should be used for the patron matching the AutoSelfCheckID'),
7
   ( 1, 'self_checkout', 'Perform self checkout at the OPAC. It should be used for the patron matching the AutoSelfCheckID'),
8
   ( 1, 'manage_checkout_notes', 'Mark checkout notes as seen/not seen'),
8
   ( 3, 'parameters_remaining_permissions', 'Remaining system parameters permissions'),
9
   ( 3, 'parameters_remaining_permissions', 'Remaining system parameters permissions'),
9
   ( 3, 'manage_circ_rules', 'Manage circulation rules'),
10
   ( 3, 'manage_circ_rules', 'Manage circulation rules'),
10
   ( 6, 'place_holds', 'Place holds for patrons'),
11
   ( 6, 'place_holds', 'Place holds for patrons'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/permissions.inc (+1 lines)
Lines 30-35 Link Here
30
    [%- CASE 'overdues_report' -%]<span>Execute overdue items report</span>
30
    [%- CASE 'overdues_report' -%]<span>Execute overdue items report</span>
31
    [%- CASE 'override_renewals' -%]<span>Override blocked renewals</span>
31
    [%- CASE 'override_renewals' -%]<span>Override blocked renewals</span>
32
    [%- CASE 'self_checkout' -%]<span>Perform self checkout at the OPAC. It should be used for the patron matching the AutoSelfCheckID</span>
32
    [%- CASE 'self_checkout' -%]<span>Perform self checkout at the OPAC. It should be used for the patron matching the AutoSelfCheckID</span>
33
    [%- CASE 'manage_checkout_notes' -%]<span>Mark checkout notes as seen/notseen</span>
33
    [%- CASE 'manage_circ_rules' -%]<span>manage circulation rules</span>
34
    [%- CASE 'manage_circ_rules' -%]<span>manage circulation rules</span>
34
    [%- CASE 'parameters_remaining_permissions' -%]<span>Remaining system parameters permissions</span>
35
    [%- CASE 'parameters_remaining_permissions' -%]<span>Remaining system parameters permissions</span>
35
    [%- CASE 'modify_holds_priority' -%]<span>Modify holds priority</span>
36
    [%- CASE 'modify_holds_priority' -%]<span>Modify holds priority</span>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/checkout-notes.tt (+165 lines)
Line 0 Link Here
1
[% USE Koha %]
2
[% USE KohaDates %]
3
[% USE Branches %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Home &rsaquo; Circulation &rsaquo; Issue Notes</title>
6
[% INCLUDE 'doc-head-close.inc' %]
7
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
8
[% INCLUDE 'datatables.inc' %]
9
<script type="text/javascript">
10
//<![CDATA[
11
    $(document).ready(function(){
12
        $("#notestable").dataTable($.extend(true, {}, dataTablesDefaults, {
13
            "aoColumnDefs": [
14
                { "aTargets": [ 0, -1 ], "bSearchable": false, "bSortable": false },
15
            ],
16
            "sPaginationType": "four_button"
17
        }));
18
19
        $(".SelectAll").on("click", function(){
20
            $("input[name='issue_ids'][type='checkbox']").prop("checked", true);
21
            $(".btn-sm").prop("disabled", false);
22
        });
23
24
        $(".ClearAll").on("click", function(){
25
            $("input[name='issue_ids'][type='checkbox']").prop("checked", false);
26
            $(".btn-sm").prop("disabled", true);
27
        });
28
29
        $("#error").hide();
30
31
        $("input[type='checkbox']").click(function(event){
32
            if ( $("input[type='checkbox']").is(":checked") ) {
33
                $(".btn-sm").prop("disabled", false);
34
            } else {
35
                $(".btn-sm").prop("disabled", true);
36
            }
37
        });
38
39
        $(".btn-xs").click(function(event){
40
            event.preventDefault(); // prevent form submission
41
            var $action = $(this).attr("name");
42
            var $issue_id = $(this).data('issue_id');
43
            var ajaxData = {
44
                'action': $action,
45
                'issue_id': $issue_id,
46
            };
47
48
            $.ajax({
49
                url: '/cgi-bin/koha/svc/checkout_notes/',
50
                type: 'POST',
51
                dataType: 'json',
52
                data: ajaxData,
53
            })
54
55
            .done(function(data){
56
                if (data.status == 'success'){
57
                    if ( $action == 'notseen' ){
58
                        $("#status_" + $issue_id).text("Not seen");
59
                        $(event.target).siblings(".seen").prop("disabled", false);
60
                        $(event.target).prop("disabled", true);
61
                    } else {
62
                        $("#status_" + $issue_id).text("Seen");
63
                        $(event.target).siblings(".notseen").prop("disabled", false);
64
                        $(event.target).prop("disabled", true);
65
                    }
66
                } else {
67
                    $("#error").text(_("Unable to change status of note."));
68
                    $("#error").show();
69
                }
70
            });
71
        });
72
    });
73
//]]>
74
</script>
75
[% INCLUDE 'calendar.inc' %]
76
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
77
</head>
78
[% INCLUDE 'header.inc' %]
79
[% INCLUDE 'circ-search.inc' %]
80
<div id="breadcrumbs">
81
    <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
82
    <a href="/cgi-bin/koha/circ/circulation-home.pl">Circulation</a> &rsaquo;
83
    Checkout notes
84
</div>
85
86
<div id="doc" class="yui-t7"> <!-- <div id="doc3" class="yui-t2" -->
87
    <div id="bd">
88
        <div id="yui-main">
89
90
            <h1>Checkout notes</h1>
91
92
            <div class="dialog alert" id="error"></div>
93
94
            [% IF ( selected_count ) %]
95
                <div class="dialog message">
96
                    [% IF ( action == 'seen' ) %]
97
                        [% selected_count %] note(s) marked as seen.
98
                    [% ELSIF ( action == 'notseen' ) %]
99
                        [% selected_count %] note(s) marked as not seen.
100
                    [% ELSE %]
101
                        Failed to change the status of [% selected_count %] item(s).
102
                    [% END %]
103
                </div>
104
                <a href="/cgi-bin/koha/circ/checkout-notes.pl" class="btn btn-default btn-sm"><i class="fa fa-left"></i> Return to checkout notes</a>
105
            [% ELSE %]
106
107
            [% IF ( notes ) %]
108
109
            <fieldset class="action">
110
                <a class="SelectAll"><i class="fa fa-check"></i> Select all</a> | <a class="ClearAll"><i class="fa fa-remove"></i> Clear all</a>
111
            </fieldset>
112
113
            <form id="mark_selected" method="post" action="/cgi-bin/koha/circ/checkout-notes.pl">
114
115
            <table id="notestable">
116
                <thead>
117
                    <tr>
118
                        <th>&nbsp;</th>
119
                        <th>Title</th>
120
                        <th>Note</th>
121
                        <th>Date</th>
122
                        <th>Set by</th>
123
                        <th>Status</th>
124
                        <th>Actions</th>
125
                    </tr>
126
                </thead>
127
                <tbody>
128
                [% FOREACH note IN notes %]
129
                    <tr>
130
                        <td><input type="checkbox" name="issue_ids" value="[% note.issue_id %]"></td>
131
                        <td>[% note.item.biblionumber.title %] - [% note.item.biblionumber.author %] (<a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% note.item.biblionumber.biblionumber %]">[% note.item.barcode %]</a>)</td>
132
                        <td>[% note.note %]</td>
133
                        <td>[% note.notedate | $KohaDates %]</td>
134
                        <td>[% note.borrower.firstname %] [% note.borrower.surname %] (<a href="/cgi-bin/koha/circ/circulation.pl?borrowernumber=[% note.borrower.borrowernumber %]">[% note.borrower.cardnumber %]</a>)</td>
135
                        <td>[% IF ( note.noteseen == 0 ) %]
136
                            <span id="status_[% note.issue_id %]">Not seen</span>
137
                        [% ELSIF ( note.noteseen == 1 ) %]
138
                            <span id="status_[% note.issue_id %]">Seen</span>
139
                        [% END %]</td>
140
                        <td class="actions">[% IF ( note.noteseen == 1 ) %]
141
                            <button name="seen" data-issue_id="[% note.issue_id %]" class="seen btn btn-default btn-xs" disabled="disabled"><i class="fa fa-eye"></i> Mark seen</button> <button name="notseen" data-issue_id="[% note.issue_id %]" class="notseen btn btn-default btn-xs"><i class="fa fa-eye-slash"></i> Mark not seen</button>
142
                        [% ELSIF ( note.noteseen == 0 ) %]
143
                            <button name="seen" data-issue_id="[% note.issue_id %]" class="seen btn btn-default btn-xs"><i class="fa fa-eye"></i> Mark seen</button> <button name="notseen" data-issue_id="[% note.issue_id %]" class="notseen btn btn-default btn-xs" disabled="disabled"><i class="fa fa-eye-slash"></i> Mark not seen</button>
144
                        [% END %]</td>
145
                    </tr>
146
                [% END %]
147
                </tbody>
148
            </table>
149
150
            <fieldset class="action">
151
                <button type="submit" class="btn btn-default btn-sm" name="mark_selected-seen" value="seen" disabled="disabled"><i class="fa fa-eye"></i> Mark seen</button>
152
                <button type="submit" class="btn btn-default btn-sm" name="mark_selected-notseen" value="notseen" disabled="disabled"><i class="fa fa-eye-slash"></i> Mark not seen</button>
153
            </fieldset>
154
155
            </form>
156
157
            [% END %] <!-- notes -->
158
159
            [% END %] <!-- selected_count -->
160
161
        </div> <!-- yui-main -->
162
    </div> <!-- bd -->
163
</div> <!-- doc3 -->
164
165
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation-home.tt (+1 lines)
Lines 30-35 Link Here
30
		<li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=FA">Fast cataloging</a></li>
30
		<li><a href="/cgi-bin/koha/cataloguing/addbiblio.pl?frameworkcode=FA">Fast cataloging</a></li>
31
	    [% END %]
31
	    [% END %]
32
	[% END %]
32
	[% END %]
33
        [% IF ( Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes ) %]<li><a href="/cgi-bin/koha/circ/checkout-notes.pl">Checkout notes</a> [% IF ( pending_checkout_notes ) %]<span class="number_box"><a href="/cgi-bin/koha/circ/checkout-notes.pl">[% pending_checkout_notes %]</a></span>[% END %]</li>[% END %]
33
	</ul>
34
	</ul>
34
	</div>
35
	</div>
35
36
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt (+7 lines)
Lines 162-167 Link Here
162
                    </div>
162
                    </div>
163
                    [% END %]
163
                    [% END %]
164
164
165
                    [% IF Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes && pending_checkout_notes %]
166
                    <div class="pending-info" id="checkout_notes_pending">
167
                        <a href="/cgi-bin/koha/circ/checkout-notes.pl">Checkout notes pending</a>:
168
                        <span class="pending-number-link">[% pending_checkout_notes %]</span>
169
                    </div>
170
                    [% END %]
171
165
                </div>
172
                </div>
166
173
167
            [% END %]
174
            [% END %]
(-)a/mainpage.pl (+3 lines)
Lines 31-36 use Koha::Patron::Modifications; Link Here
31
use Koha::Patron::Discharge;
31
use Koha::Patron::Discharge;
32
use Koha::Reviews;
32
use Koha::Reviews;
33
use Koha::ArticleRequests;
33
use Koha::ArticleRequests;
34
use Koha::Checkouts;
34
35
35
my $query = new CGI;
36
my $query = new CGI;
36
37
Lines 74-79 my $pending_article_requests = Koha::ArticleRequests->count( Link Here
74
        $branch ? ( branchcode => $branch ) : (),
75
        $branch ? ( branchcode => $branch ) : (),
75
    }
76
    }
76
);
77
);
78
my $pending_checkout_notes = Koha::Checkouts->search({ noteseen => 0 })->count;
77
79
78
$template->param(
80
$template->param(
79
    pendingcomments                => $pendingcomments,
81
    pendingcomments                => $pendingcomments,
Lines 82-87 $template->param( Link Here
82
    pending_borrower_modifications => $pending_borrower_modifications,
84
    pending_borrower_modifications => $pending_borrower_modifications,
83
    pending_discharge_requests     => $pending_discharge_requests,
85
    pending_discharge_requests     => $pending_discharge_requests,
84
    pending_article_requests       => $pending_article_requests,
86
    pending_article_requests       => $pending_article_requests,
87
    pending_checkout_notes         => $pending_checkout_notes,
85
);
88
);
86
89
87
#
90
#
(-)a/opac/opac-issue-note.pl (-1 / +1 lines)
Lines 67-73 if ( $action eq 'issuenote' && C4::Context->preference('AllowCheckoutNotes') ) { Link Here
67
    my $note = $query->param('note');
67
    my $note = $query->param('note');
68
    my $scrubber = C4::Scrubber->new();
68
    my $scrubber = C4::Scrubber->new();
69
    my $clean_note = $scrubber->scrub($note);
69
    my $clean_note = $scrubber->scrub($note);
70
    if ( $issue->set({ notedate => dt_from_string(), note => $clean_note })->store ) {
70
    if ( $issue->set({ notedate => dt_from_string(), note => $clean_note, noteseen => 0 })->store ) {
71
        if ($clean_note) { # only send email if note not empty
71
        if ($clean_note) { # only send email if note not empty
72
            my $branch = Koha::Libraries->find( $issue->branchcode );
72
            my $branch = Koha::Libraries->find( $issue->branchcode );
73
            my $letter = C4::Letters::GetPreparedLetter (
73
            my $letter = C4::Letters::GetPreparedLetter (
(-)a/opac/svc/patron_notes (-1 / +1 lines)
Lines 76-82 if ($is_ajax) { Link Here
76
        }
76
        }
77
77
78
        if ( $issue ) {
78
        if ( $issue ) {
79
            $issue->set({ notedate => dt_from_string(), note => $clean_note })->store;
79
            $issue->set({ notedate => dt_from_string(), note => $clean_note, noteseen => 0 })->store;
80
            if($clean_note) { # only send email if note not empty
80
            if($clean_note) { # only send email if note not empty
81
                my $branch = Koha::Libraries->find( $issue->branchcode );
81
                my $branch = Koha::Libraries->find( $issue->branchcode );
82
                my $biblio = GetBiblioFromItemNumber($issue->itemnumber);
82
                my $biblio = GetBiblioFromItemNumber($issue->itemnumber);
(-)a/svc/checkout_notes (-1 / +63 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Copyright 2017 Aleisha Amohia <aleisha@catalyst.net.nz>
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 JSON qw( to_json );
23
use CGI;
24
use C4::Service;
25
use C4::Auth qw /check_cookie_auth/;
26
use C4::Output qw(:DEFAULT :ajax);
27
use Koha::Checkouts;
28
29
=head1 NAME
30
31
svc/issue_notes - Web service for managing patron notes set on issues
32
33
=head1 DESCRIPTION
34
35
=cut
36
37
# AJAX requests
38
my $is_ajax = is_ajax();
39
my $query = new CGI;
40
my ( $auth_status, $sessionID ) = check_cookie_auth( $query->cookie('CGISESSID'), { circulate => 'manage_checkout_notes' } );
41
if ( $auth_status ne "ok" ) {
42
    exit 0;
43
}
44
if ($is_ajax) {
45
    my $issue_id = $query->param('issue_id');
46
    my $issue = Koha::Checkouts->find($issue_id);
47
    my $action = $query->param('action');
48
    my $status = 'success';
49
    if ($action eq 'seen'){
50
        $issue->set({ noteseen => 1 })->store;
51
        if ( $issue->noteseen != 1 ) {
52
            $status = 'failure';
53
        }
54
    } elsif ($action eq 'notseen'){
55
        $issue->set({ noteseen => 0 })->store;
56
        if ( $issue->noteseen != 0 ) {
57
            $status = 'failure';
58
        }
59
    }
60
    my $json = to_json ( { status => $status } );
61
    output_with_http_headers $query, undef, $json, 'js';
62
    exit;
63
}

Return to bug 17698