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

(-)a/C4/Auth.pm (+29 lines)
Lines 207-212 sub get_template_and_user { Link Here
207
        }
207
        }
208
    }
208
    }
209
209
210
    # If the user logged in is the SCI user and they try to go out of the SCI module,
211
    # log the user out removing the CGISESSID cookie
212
    if ( $in->{type} eq 'opac' and $in->{template_name} !~ m|sci/| ) {
213
        if ( $user && C4::Context->preference('AutoSelfCheckID') && $user eq C4::Context->preference('AutoSelfCheckID') ) {
214
            $template = C4::Templates::gettemplate( 'opac-auth.tt', 'opac', $in->{query} );
215
            my $cookie = $in->{query}->cookie(
216
                -name     => 'CGISESSID',
217
                -value    => '',
218
                -expires  => '',
219
                -HttpOnly => 1,
220
            );
221
222
            $template->param(
223
                loginprompt => 1,
224
                script_name => get_script_name(),
225
            );
226
            print $in->{query}->header(
227
                {   type              => 'text/html',
228
                    charset           => 'utf-8',
229
                    cookie            => $cookie,
230
                    'X-Frame-Options' => 'SAMEORIGIN'
231
                }
232
              ),
233
            $template->output;
234
            safe_exit;
235
        }
236
    }
237
210
    my $borrowernumber;
238
    my $borrowernumber;
211
    if ($user) {
239
    if ($user) {
212
240
Lines 1266-1271 sub checkauth { Link Here
1266
    );
1294
    );
1267
1295
1268
    $template->param( SCO_login => 1 ) if ( $query->param('sco_user_login') );
1296
    $template->param( SCO_login => 1 ) if ( $query->param('sco_user_login') );
1297
    $template->param( SCI_login => 1 ) if ( $query->param('sci_user_login') );
1269
    $template->param( OpacPublic => C4::Context->preference("OpacPublic") );
1298
    $template->param( OpacPublic => C4::Context->preference("OpacPublic") );
1270
    $template->param( loginprompt => 1 ) unless $info{'nopermission'};
1299
    $template->param( loginprompt => 1 ) unless $info{'nopermission'};
1271
1300
(-)a/koha-tmpl/opac-tmpl/bootstrap/css/sco.css (+12 lines)
Lines 193-196 i.help { Link Here
193
.table .nosort.sorting {
193
.table .nosort.sorting {
194
    padding-right: 19px;
194
    padding-right: 19px;
195
    background: #EEEEEE none;
195
    background: #EEEEEE none;
196
}
197
198
#sci_logout {
199
    color: #E8583C;
200
}
201
202
#sci_checkin_button, #sci_refresh_button, #sci_append_button {
203
    margin-bottom: 10px;
204
}
205
206
#sci_refresh_button {
207
    color: rgb(51, 51, 51);
196
}
208
}
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-auth.tt (+4 lines)
Lines 31-36 Link Here
31
                                <p>Sorry, the system doesn't think you have permission to access this page. </p>
31
                                <p>Sorry, the system doesn't think you have permission to access this page. </p>
32
                                [% IF SCO_login %]
32
                                [% IF SCO_login %]
33
                                    <p><a href="/cgi-bin/koha/sco/sco-main.pl?logout.x=1">Log out and try again with a different user.</a></p>
33
                                    <p><a href="/cgi-bin/koha/sco/sco-main.pl?logout.x=1">Log out and try again with a different user.</a></p>
34
                                [% ELSIF SCI_login %]
35
                                    <p><a href="/cgi-bin/koha/sci/sci-main.pl?logout.x=1">Log out and try again with a different user.</a></p>
34
                                [% END %]
36
                                [% END %]
35
                            </div>
37
                            </div>
36
                        [% END %]
38
                        [% END %]
Lines 158-163 Link Here
158
160
159
                        [% IF SCO_login %]
161
                        [% IF SCO_login %]
160
                            <form action="/cgi-bin/koha/sco/sco-main.pl" name="auth" id="auth" method="post">
162
                            <form action="/cgi-bin/koha/sco/sco-main.pl" name="auth" id="auth" method="post">
163
                        [% ELSIF SCI_login %]
164
                            <form action="/cgi-bin/koha/sci/sci-main.pl" name="auth" id="auth" method="post">
161
                        [% ELSE %]
165
                        [% ELSE %]
162
                            <form action="[% script_name %]" name="auth" id="auth" method="post">
166
                            <form action="[% script_name %]" name="auth" id="auth" method="post">
163
                        [% END %]
167
                        [% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sci/sci-main.tt (+223 lines)
Line 0 Link Here
1
[%# Includes %]
2
[% USE Koha %]
3
[% USE KohaDates %]
4
[%# Helper template functions %]
5
[% BLOCK error_message %]
6
    [% IF messages.BadBarcode %]
7
        <span>(Barcode not found on the database)</span>
8
    [% ELSIF messages.DataCorrupted %]
9
        <span>(Data corruption detected. Contact your librarian)</span>
10
    [% ELSIF messages.Wrongbranch %]
11
        <span>(The item cannot be returned at this library)</span>
12
    [% ELSIF messages.withdrawn %]
13
        <span>(Item is withdrawn and check-in blocked by policy. Contact your librarian)</span>
14
    [% ELSIF messages.NotIssued %]
15
        <span>(The book is not currently on loan. Contact your librarian)</span>
16
    [% END %]
17
[% END %]
18
19
[% INCLUDE 'doc-head-open.inc' %]
20
21
<title>[% IF ( LibraryNameTitle ) %][% LibraryNameTitle %][% ELSE %]Koha [% END %] &rsaquo; Self check-in</title>
22
23
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
24
<meta name="generator" content="Koha [% Version %]" /> <!-- leave this for stats -->
25
26
[% IF ( Koha.Preference('OpacFavicon') ) %]
27
<link rel="shortcut icon" href="[% Koha.Preference('OpacFavicon') %]" type="image/x-icon" />
28
[% ELSE %]
29
<link rel="shortcut icon" href="[% interface %]/[% theme %]/images/favicon.ico" type="image/x-icon" />
30
[% END %]
31
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/lib/bootstrap/css/bootstrap.min.css" />
32
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/lib/jquery/jquery-ui.css" />
33
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/lib/font-awesome/css/font-awesome.min.css" />
34
<link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/sco.css" />
35
[% IF ( Koha.Preference('OPACUserCSS') ) %]<style type="text/css">[% Koha.Preference('OPACUserCSS') %]</style>[% END %]
36
[% IF ( Koha.Preference('SCOUserCSS') ) %]<style type="text/css">[% Koha.Preference('SCOUserCSS') %]</style>[% END %]
37
<!--[if lt IE 9]>
38
    <script src="[% interface %]/[% theme %]/lib/respond.min.js"></script>
39
<![endif]-->
40
<script type="text/javascript" src="[% interface %]/[% theme %]/lib/modernizr.min.js"></script>
41
</head>
42
<body id="sci_main" class="sci" onload="dofocus();" onunload="mungeHistory();">
43
44
[% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %]
45
<div id="wrap">
46
    <div class="navbar navbar-inverse navbar-static-top">
47
        <div class="navbar-inner">
48
            <div class="container-fluid">
49
                <a class="brand" href="/cgi-bin/koha/sci/sci-main.pl"><img src="[% interface %]/[% theme %]/images/koha-logo-navbar.png" alt=""></a>
50
                <div id="checkouthelp">
51
                    <ul class="nav pull-right">
52
                        <li><a href="/cgi-bin/koha/sco/help.pl"><i class="icon help"></i> Help</a></li>
53
                        <li><a id="sci_logout" href="/cgi-bin/koha/sci/sci-main.pl?logout.x=1" class="logout">Logout</a></li>
54
                    </ul>
55
                </div>
56
57
                [% IF Koha.Preference( 'opaclanguagesdisplay' ) %]
58
                    <div id="members">
59
                        <ul class="nav pull-right">
60
                            [% INCLUDE 'masthead-langmenu.inc' %]
61
                        </ul>
62
                    </div>
63
                [% END %]
64
65
            </div> <!-- /.container-fluid -->
66
        </div> <!-- /.navbar-inner -->
67
    </div> <!-- /.navbar -->
68
69
[% IF Koha.Preference( 'opacheader' ) %]
70
    <div class="container-fluid">
71
        <div class="row-fluid">
72
            <div id="opacheader">
73
                [% Koha.Preference( 'opacheader' ) %]
74
            </div>
75
        </div>
76
    </div>
77
[% END %]
78
79
    <div class="main">
80
        <div class="container-fluid">
81
            <div class="row-fluid">
82
                <div id="masthead">
83
                    <h1>[% LibraryName %] Self check-in</h1>
84
                [% IF ( nopermission ) %]
85
                    [%# This is what is displayed if user doesn't have permission %]
86
                    <div class="alert">
87
                        <h3>Access denied</h3>
88
                        <p>Sorry, this self check-in station has lost authentication. Please contact the administrator to resolve this problem.</p>
89
                    </div>
90
                [% ELSIF ( different_ip ) %]
91
                    [%# This is what is displayed if user doesn't have permission %]
92
                    <div class="alert">
93
                        <h3>Session lost</h3>
94
                        <p>You are accessing self check-in from a different IP address! Please log in again.</p>
95
                    </div>
96
                [% ELSIF ( checkins ) %]
97
                    [%# We have results from a check-in attempt %]
98
                    <div id="checkins" class="sci_results_list">
99
                        [% IF ( success && success.size > 0 || errors && errors.size > 0 ) %]
100
                            <h3>Results</h3>
101
                                <table id="sci_bcheckins_table" class="table table-bordered table-striped dataTable no-footer" style="font-size: initial;">
102
                                  <thead>
103
                                    <th>Barcode</th>
104
                                    <th>Status</th>
105
                                  </thead>
106
                                  <tbody>
107
                                [% FOREACH success_line IN success %]
108
                                    <tr><td>[% success_line.barcode %]</td><td>Checked in</td></tr>
109
                                [% END %]
110
                                [% FOREACH error IN errors %]
111
                                    <tr>
112
                                      <td>[% error.barcode %]</td>
113
                                      <td>Not checked in [% PROCESS error_message messages=error.messages %]</td>
114
                                    </tr>
115
                                [% END %]
116
                                  </tbody>
117
                                </table>
118
                                <div>
119
                                    <form method="post" action="#" id="finish_form">
120
                                        <button type="submit" class="btn"><i class="icon finish"></i> Finish</button>
121
                                    </form>
122
                                </div>
123
                        [% ELSE %]
124
                            <div class="alert">
125
                                <p>Your request included no check-ins.</p>
126
                            </div>
127
                        [% END %]
128
                    </div>
129
                [% ELSE %]
130
                    [%# Prompt for barcodes %]
131
                    <div id="new_checkins" class="sci_entry">
132
                        <form id="scan_form" name="scan_form"
133
                              method="post" action="/cgi-bin/koha/sci/sci-main.pl">
134
                            <fieldset>
135
                                <div>
136
                                  <label for="barcode_input">Scan the item or enter its barcode:</label>
137
                                  <input id="barcode_input" name="barcode_input" size="20" type="text" class="focus" autocomplete="off" />
138
                                  <button id="sci_append_button" type="submit" class="btn btn-default btn-sm">
139
                                    <i class="fa fa-plus" aria-hidden="true"></i> <span>Add</span>
140
                                  </button>
141
                                </div>
142
                                <div class="sci_input_append">
143
                                    <table id="sci_barcodes_table" class="table table-bordered table-striped dataTable no-footer" style="display: none; font-size: initial;">
144
                                      <thead>
145
                                        <th class="barcodes_column">Barcode</th>
146
                                      </thead>
147
                                      <tbody>
148
                                      </tbody>
149
                                    </table>
150
                                </div>
151
                                <input type="hidden" name="op" value="check_in" />
152
                                <div id="button_bar">
153
                                <button id="sci_checkin_button" type="submit" class="btn btn-default btn-sm" style="display: none;">
154
                                    <i class="fa fa-check-square-o" aria-hidden="true"></i><span> Check in</span>
155
                                </button>
156
                                <a href="/cgi-bin/koha/sci/sci-main.pl" class="btn btn-default btn-sm" role="button" style="display: none;" id="sci_refresh_button">
157
                                    <i class="fa fa-refresh" aria-hidden="true"></i> <span>Reset</span>
158
                                </a>
159
                                </div>
160
                            </fieldset>
161
                        </form>
162
                    </div> <!-- / #new_checkins -->
163
                [% END %]
164
                </div> <!-- / #masthead -->
165
            </div> <!-- / .row-fluid -->
166
        </div> <!-- / .container-fluid -->
167
168
        [% IF ( Koha.Preference('SCOMainUserBlock' ) ) %]
169
            <div id="scomainuserblock">[% Koha.Preference('SCOMainUserBlock' ) %]</div>
170
        [% END %]
171
    </div> <!-- / .main -->
172
    <span id="audio-alert"></span>
173
</body>
174
175
[% INCLUDE 'opac-bottom.inc' %]
176
[% BLOCK jsinclude %]
177
    [% INCLUDE 'datatables.inc' %]
178
    <script type="text/javascript">
179
180
        function mungeHistory() {
181
            // prevent back button from allowing form resubmission
182
            if (history && history.pushState) {
183
                history.replaceState(null, document.title, window.location.href);
184
            }
185
        }
186
187
        function dofocus() {
188
            $(".focus:last").select();
189
        }
190
191
        var barcodes = [];
192
193
        $(document).ready(function() {
194
            // Barcodes scanning table initially hidden
195
            $("#sci_barcodes_table").hide();
196
            // Control de 'append' button behaviour
197
            $("#sci_append_button").on('click',function( e ){
198
                // Make sure the form is not submitted by the button
199
                e.preventDefault();
200
                var barcode = $('#barcode_input').val();
201
                //var result  = validate_barcode( barcode );
202
                $('#sci_barcodes_table tbody').append(
203
                        '<tr stype="font-size: initial;"><td>' +
204
                            barcode +
205
                            '<input type="hidden" name="barcode" value="' + barcode + '" />' +
206
                        '</td></tr>' );
207
                // Make sure the table is now displayed
208
                $("#sci_barcodes_table").show();
209
                $('#sci_checkin_button').show();
210
                $('#sci_refresh_button').show();
211
                barcodes.push(barcode);
212
                // clean the input, reset the focus
213
                $('#barcode_input').val('');
214
                dofocus();
215
            });
216
217
            // set focus at the beginning
218
            dofocus();
219
        });
220
    </script>
221
222
    [% IF ( Koha.Preference('SCOUserJS') ) %]<script type="text/javascript">[% Koha.Preference('SCOUserJS') %]</script>[% END %]
223
[% END %]
(-)a/opac/sci/sci-main.pl (-1 / +96 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use CGI qw ( -utf8 );
21
22
use C4::Auth qw(get_template_and_user checkpw);
23
use C4::Circulation;
24
use C4::Output;
25
26
use List::MoreUtils qw( uniq );
27
use Try::Tiny;
28
29
my $cgi = new CGI;
30
31
# 404 if feature is disabled
32
unless ( C4::Context->preference('SelfCheckInModule') ) {
33
    print $cgi->redirect("/cgi-bin/koha/errors/404.pl");
34
    exit;
35
}
36
37
# Let Auth know this is a SCI context
38
$cgi->param( -name => 'sci_user_login', -values => [1] );
39
40
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
41
    {
42
        template_name   => "sci/sci-main.tt",
43
        authnotrequired => 0,
44
        flagsrequired   => { circulate => "self_checkout" },
45
        query           => $cgi,
46
        type            => "opac"
47
    }
48
);
49
50
my $op = $cgi->param('op') // '';
51
52
if ( $op eq 'check_in' ) {
53
    ## Get the barcodes, perform some basic validation
54
    # Remove empty ones
55
    my @barcodes = grep { $_ ne '' } $cgi->multi_param('barcode');
56
57
    # Remove duplicates
58
    @barcodes = uniq @barcodes;
59
60
    # Read the library we are logged in from userenv
61
    my $library = C4::Context->userenv->{'branch'};
62
    my @success;
63
    my @errors;
64
65
    # Return items
66
    foreach my $barcode (@barcodes) {
67
        try {
68
            my ( $success, $messages, $checkout, $patron ) =
69
              AddReturn( $barcode, $library );
70
            if ($success) {
71
                push @success,
72
                  {
73
                    barcode  => $barcode,
74
                    messages => $messages,
75
                    checkout => $checkout,
76
                    patron   => $patron
77
                  };
78
            }
79
            else {
80
                push @errors,
81
                  {
82
                    barcode  => $barcode,
83
                    messages => $messages,
84
                    checkout => $checkout,
85
                    patron   => $patron
86
                  };
87
            }
88
        }
89
        catch {
90
            push @errors, { barcode => $barcode, messages => 'unknown_error' };
91
        };
92
    }
93
    $template->param( success => \@success, errors => \@errors, checkins => 1 );
94
}
95
96
output_html_with_http_headers $cgi, $cookie, $template->output, undef, { force_no_caching => 1 };

Return to bug 15492