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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/masthead-sco-self.inc (+35 lines)
Line 0 Link Here
1
[% USE Koha %]
2
[% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %]
3
<!-- <div id="wrap"> -->
4
    <div class="navbar navbar-inverse navbar-static-top navbar-black">
5
        <div class="navbar-inner navbar-black">
6
            <div class="container-fluid navbar-black">
7
                <a class="brand" href="/cgi-bin/koha/sco/sco-main.pl"><img src="[% interface %]/[% theme %]/images/koha-logo-navbar.png" alt=""></a>
8
                <div id="checkouthelp">
9
                    <ul class="nav pull-right">
10
                        <li><a href="/cgi-bin/koha/sco/help.pl"><i class="icon help"></i> Help</a></li>
11
                    </ul>
12
                </div>
13
14
                [% IF ( opaclanguagesdisplay ) %]
15
                    <div id="members">
16
                        <ul class="nav pull-right">
17
                            [% INCLUDE 'masthead-langmenu.inc' %]
18
                        </ul>
19
                    </div> <!-- /members -->
20
                [% END # / IF opaclanguagedisplay %]
21
22
            </div> <!-- /container-fluid -->
23
        </div> <!-- /navbar-inner -->
24
    </div> <!-- /navbar -->
25
<!-- </div> -->
26
27
    [% IF ( opacheader ) %]
28
        <div class="container-fluid">
29
            <div class="row-fluid">
30
                <div id="opacheader">
31
                   [% opacheader %]
32
                </div>
33
            </div>
34
        </div>
35
    [% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/help.tt (-1 / +1 lines)
Lines 17-23 Link Here
17
</script>
17
</script>
18
</head>
18
</head>
19
<body id="sco_help" class="sco">
19
<body id="sco_help" class="sco">
20
    [% INCLUDE 'masthead-sco.inc' %]
20
[% INCLUDE 'masthead-sco-self.inc' %]
21
21
22
    <div class="main">
22
    <div class="main">
23
        <div class="container-fluid">
23
        <div class="container-fluid">
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt (-22 / +86 lines)
Lines 35-43 Link Here
35
[% Asset.js('js/i18n.js') | $raw %]
35
[% Asset.js('js/i18n.js') | $raw %]
36
</head>
36
</head>
37
<body id="sco_main" class="sco" onload="dofocus();" onunload="mungeHistory();">
37
<body id="sco_main" class="sco" onload="dofocus();" onunload="mungeHistory();">
38
    [% INCLUDE 'masthead-sco.inc' %]
38
[% INCLUDE 'masthead-sco.inc' %]
39
39
40
    <div class="main">
40
   <div class="main">
41
        <div class="container-fluid">
41
        <div class="container-fluid">
42
            <div class="row">
42
            <div class="row">
43
                [% IF ( display_patron_image ) %]
43
                [% IF ( display_patron_image ) %]
Lines 401-432 Link Here
401
                        </div>
401
                        </div>
402
                    </div>
402
                    </div>
403
                        [% ELSE # IF validuser %]
403
                        [% ELSE # IF validuser %]
404
                            <div class="sco_entry" >
404
                        <div class="row">
405
                            <div class="sco_entry col-5" >
406
                            <h4>Check out</h4>
405
                                <form id="mainform" action="/cgi-bin/koha/sco/sco-main.pl" name="mainform" method="post">
407
                                <form id="mainform" action="/cgi-bin/koha/sco/sco-main.pl" name="mainform" method="post">
406
                                    <fieldset>
408
                                    <fieldset>
407
                                        [% IF ( Koha.Preference('SelfCheckoutByLogin') ) %]
409
                                        [% IF ( Koha.Preference('SelfCheckoutByLogin') ) %]
408
                                            <legend>Log in to your account</legend>
410
                                            <div class="row mb-2">
409
                                            <label for="patronlogin">Login:</label>
411
                                                <div class="col-3">
410
                                            <input type="text" id="patronlogin" class="focus noEnterSubmit" size="20" name="patronlogin" autocomplete="off"/>
412
                                                    <label for="patronlogin">Username:</label>
411
                                            <label for="patronpw">Password:</label>
412
                                            <input type="password" id="patronpw" size="20" name="patronpw" autocomplete="off"/>
413
                                            <fieldset class="action">
414
                                                <button type="submit" class="btn btn-primary">Log in</button>
415
                                            </fieldset>
416
                                        [% ELSE %]
417
                                            <div class="form-row">
418
                                                <div class="col-auto">
419
                                                    <label for="patronid">Please enter your card number:</label>
420
                                                </div>
413
                                                </div>
414
                                                <div class="col-5">
415
                                                    <input type="text" id="patronlogin" class="form-control focus noEnterSubmit" size="20" name="patronlogin" autocomplete="off"/>
416
                                                </div>
417
                                            </div>
418
                                            <div class="row mb-2">
421
                                                <div class="col-3">
419
                                                <div class="col-3">
422
                                                    <input type="text" id="patronid" class="form-control focus" size="20" name="patronid" autocomplete="off" />
420
                                                    <label for="patronpw">Password:</label>
421
                                                </div>
422
                                                <div class="col-5">
423
                                                    <input type="password" id="patronpw" class="form-control" size="20" name="patronpw" autocomplete="off"/>
423
                                                </div>
424
                                                </div>
424
                                                <div class="col-auto">
425
                                            </div>
425
                                                    <button type="submit" class="btn btn-primary">Submit</button>
426
                                            <div class="row justify-content-end">
427
                                                <div class="col-6">
428
                                                    <fieldset class="action">
429
                                                    <button type="submit" class="btn btn-primary">Log in</button>
430
                                                    </fieldset>
426
                                                </div>
431
                                                </div>
427
                                            </div> <!-- /.form-row -->
432
                                            </div>
433
                                        [% ELSE %]
434
                                        <div class="row">
435
                                            <div class="col-auto">
436
                                                <label for="patronid">Please enter your card number:</label>
437
                                            </div>
438
                                            <div class="col-4">
439
                                                <input type="text" id="patronid" class="form-control focus" size="20" name="patronid" autocomplete="off" />
440
                                            </div>
441
                                            <div class="col">
442
                                                <button type="submit" class="btn btn-primary">Submit</button>
443
                                            </div>
444
                                        </div>
428
                                        [% END %]
445
                                        [% END %]
429
430
                                        [% FOREACH INPUT IN INPUTS %]
446
                                        [% FOREACH INPUT IN INPUTS %]
431
                                            <input type="hidden" name="[% INPUT.name | html %]" value="[% INPUT.value | html %]">
447
                                            <input type="hidden" name="[% INPUT.name | html %]" value="[% INPUT.value | html %]">
432
                                        [% END %]
448
                                        [% END %]
Lines 434-446 Link Here
434
                                    </fieldset>
450
                                    </fieldset>
435
                                </form>
451
                                </form>
436
                            </div> <!-- / .sco_entry -->
452
                            </div> <!-- / .sco_entry -->
453
                            <div class="sco_entry col" >
454
                                <form id="barcodeform" action="/cgi-bin/koha/sco/sco-main.pl" name="barcodeform" method="post">
455
                                    <fieldset>
456
                                    <div class="row">
457
                                        <div class="col">
458
                                            <h4>Check in</h4>
459
                                        </div>
460
                                    </div>
461
                                        <div class="row">
462
                                            <div class="col-auto">
463
                                                <label for="uibarcode">Please enter barcode:</label>
464
                                            </div>
465
                                            <div class="col-3">
466
                                                [% IF ( checkinmessage ) %]
467
                                                    <input type="text" id="uibarcode"  class="form-control focus" name="uibarcode" autocomplete="off" />
468
                                                [% ELSE %]
469
                                                    <input type="text" id="uibarcode" class="form-control" name="uibarcode" autocomplete="off" />
470
                                                [% END %]
471
                                            </div>
472
                                            <div class="col">
473
                                                <button type="submit" class="btn btn-primary">Submit</button>
474
                                            </div>
475
                                        </div>
476
                                        [% FOREACH INPUT IN INPUTS %]
477
                                        <input type="hidden" name="[% INPUT.name |html %]" value="[% INPUT.value |html %]">
478
                                        [% END %]
479
                                        <input type="hidden" name="op" value="checkin" />
480
                                    </fieldset>
481
                                </form>
482
                            </div> <!-- / .sco_entry -->
483
                        </div> <!-- / .row -->
437
                        [% END # / IF validuser %]
484
                        [% END # / IF validuser %]
438
                    [% END # / UNLESS ( hide_main %]
485
                    [% END # / UNLESS ( hide_main %]
486
                    <b>[% checkinmessage %]</b>
439
                    [% IF ( Koha.Preference('SCOMainUserBlock' ) ) %]<div id="scomainuserblock">[% Koha.Preference('SCOMainUserBlock' ) | $raw %]</div>[% END %]
487
                    [% IF ( Koha.Preference('SCOMainUserBlock' ) ) %]<div id="scomainuserblock">[% Koha.Preference('SCOMainUserBlock' ) | $raw %]</div>[% END %]
440
                </div> <!-- / .span12 -->
488
                </div> <!-- / .span12 -->
441
            </div> <!-- / .row -->
489
            </div> <!-- / .row -->
442
        </div> <!-- / .container-fluid -->
490
        </div> <!-- / .container-fluid -->
443
    </div> <!-- / .main -->
491
      </div> <!-- / .main -->
444
    <span id="audio-alert"></span>
492
    <span id="audio-alert"></span>
445
493
446
[% INCLUDE 'opac-bottom.inc' %]
494
[% INCLUDE 'opac-bottom.inc' %]
Lines 502-508 Link Here
502
550
503
        $(document).ready(function() {
551
        $(document).ready(function() {
504
            dofocus();
552
            dofocus();
505
            [% IF ( patronid ) %]sco_init();[% END %]
553
            [% IF ( patronid || uibarcode ) %]sco_init();[% END %]
506
            $("#loanTable").dataTable($.extend(true, {}, dataTablesDefaults, {
554
            $("#loanTable").dataTable($.extend(true, {}, dataTablesDefaults, {
507
                "dom": "t",
555
                "dom": "t",
508
                "order": [ 0 ],
556
                "order": [ 0 ],
Lines 513-518 Link Here
513
                ]
561
                ]
514
            }));
562
            }));
515
563
564
516
            $("#logout_form").on("click", function(e){
565
            $("#logout_form").on("click", function(e){
517
                e.preventDefault(e);
566
                e.preventDefault(e);
518
                clearTimeout(mainTimeout);
567
                clearTimeout(mainTimeout);
Lines 529-535 Link Here
529
                [% ELSE %]
578
                [% ELSE %]
530
                    location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
579
                    location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
531
                [% END %]
580
                [% END %]
581
                return true;
582
            });
532
583
584
            $("#logout_form_vara").on("click", function() {
585
                clearTimeout(mainTimeout);
586
                [% IF Koha.Preference('SelfCheckReceiptPrompt') %]
587
                var confirmStart = Date.now();
588
                if(confirm(_("Would you like to print a receipt?"))){
589
                    if ( (Date.now() - confirmStart) < [% SelfCheckTimeout %] ) {
590
                        window.open("/cgi-bin/koha/sco/printslip.pl?borrowernumber=[% borrowernumber %]&amp;print=qslip");
591
                    }
592
                    else {
593
                        alert(_("Timeout while waiting for print confirmation"));
594
                    }
595
                }
596
                [% END %]
533
                return true;
597
                return true;
534
            });
598
            });
535
    });
599
    });
(-)a/opac/sco/sco-main.pl (-8 / +76 lines)
Lines 33-42 use Modern::Perl; Link Here
33
use CGI qw ( -utf8 );
33
use CGI qw ( -utf8 );
34
34
35
use C4::Auth qw( in_iprange get_template_and_user checkpw );
35
use C4::Auth qw( in_iprange get_template_and_user checkpw );
36
use C4::Circulation qw( barcodedecode AddReturn CanBookBeIssued AddIssue CanBookBeRenewed AddRenewal );
36
use C4::Circulation qw( barcodedecode AddReturn CanBookBeIssued AddIssue CanBookBeRenewed AddRenewal updateWrongTransfer );
37
use C4::Reserves;
37
use C4::Reserves qw( ModReserveAffect );
38
use C4::Output qw( output_html_with_http_headers );
38
use C4::Output qw( output_html_with_http_headers );
39
use C4::Members;
39
use C4::Members;
40
use C4::Biblio qw( GetBiblioData );
41
use C4::Items qw( ModItemTransfer );
40
use Koha::DateUtils qw( dt_from_string );
42
use Koha::DateUtils qw( dt_from_string );
41
use Koha::Acquisition::Currencies;
43
use Koha::Acquisition::Currencies;
42
use Koha::Items;
44
use Koha::Items;
Lines 45-50 use Koha::Patron::Images; Link Here
45
use Koha::Patron::Messages;
47
use Koha::Patron::Messages;
46
use Koha::Plugins;
48
use Koha::Plugins;
47
use Koha::Token;
49
use Koha::Token;
50
use Koha::Calendar;
48
51
49
my $query = CGI->new;
52
my $query = CGI->new;
50
53
Lines 73-81 $query->param(-name=>'sco_user_login',-values=>[1]); Link Here
73
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
76
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
74
    {
77
    {
75
        template_name   => "sco/sco-main.tt",
78
        template_name   => "sco/sco-main.tt",
79
        authnotrequired => 0,
76
        flagsrequired   => { self_check => "self_checkout_module" },
80
        flagsrequired   => { self_check => "self_checkout_module" },
77
        query           => $query,
81
        query           => $query,
78
        type            => "opac",
82
        type            => "opac",
83
        debug => 1,
79
    }
84
    }
80
);
85
);
81
86
Lines 93-105 if (defined C4::Context->preference('SCOAllowCheckin')) { Link Here
93
}
98
}
94
99
95
my $issuerid = $loggedinuser;
100
my $issuerid = $loggedinuser;
96
my ($op, $patronlogin, $patronpw, $barcode, $confirmed, $newissues) = (
101
my ($op, $patronlogin, $patronpw, $barcode, $confirmed, $newissues, $uibarcode, $checkinmessage) = (
97
    $query->param("op")         || '',
102
    $query->param("op")         || '',
98
    $query->param("patronlogin")|| '',
103
    $query->param("patronlogin")|| '',
99
    $query->param("patronpw")   || '',
104
    $query->param("patronpw")   || '',
100
    $query->param("barcode")    || '',
105
    $query->param("barcode")    || '',
101
    $query->param("confirmed")  || '',
106
    $query->param("confirmed")  || '',
102
    $query->param("newissues")  || '',
107
    $query->param("newissues")  || '',
108
    $query->param("uibarcode")  || '',
109
    $query->param("checkinmessage") || undef,
103
);
110
);
104
111
105
my $jwt = $query->cookie('JWT');
112
my $jwt = $query->cookie('JWT');
Lines 115-120 my @newissueslist = split /,/, $newissues; Link Here
115
my $issuenoconfirm = 1; #don't need to confirm on issue.
122
my $issuenoconfirm = 1; #don't need to confirm on issue.
116
my $issuer   = Koha::Patrons->find( $issuerid )->unblessed;
123
my $issuer   = Koha::Patrons->find( $issuerid )->unblessed;
117
124
125
my $checkinitem;
126
my $checkinbranchcode;
127
my $userenv = C4::Context->userenv;
128
my $userenv_branch = $userenv->{'branch'} // '';
129
my $daysmode = Koha::CirculationRules->get_effective_daysmode(
130
    {
131
        branchcode   => $userenv_branch,
132
    }
133
);
134
my $calendar    = Koha::Calendar->new( branchcode => $userenv_branch, days_mode => $daysmode );
135
my $today       = DateTime->now( time_zone => C4::Context->tz());
136
118
my $patronid = $jwt ? Koha::Token->new->decode_jwt({ token => $jwt }) : undef;
137
my $patronid = $jwt ? Koha::Token->new->decode_jwt({ token => $jwt }) : undef;
119
unless ( $patronid ) {
138
unless ( $patronid ) {
120
    if ( C4::Context->preference('SelfCheckoutByLogin') ) {
139
    if ( C4::Context->preference('SelfCheckoutByLogin') ) {
Lines 139-145 my $branch = $issuer->{branchcode}; Link Here
139
my $confirm_required = 0;
158
my $confirm_required = 0;
140
my $return_only = 0;
159
my $return_only = 0;
141
160
142
if ( $patron && $op eq "returnbook" && $allowselfcheckreturns ) {
161
if ( ( $op eq "checkin" && $uibarcode ) || $patron && $op eq "returnbook" && $allowselfcheckreturns ) {
143
    my $success = 1;
162
    my $success = 1;
144
163
145
164
Lines 152-167 if ( $patron && $op eq "returnbook" && $allowselfcheckreturns ) { Link Here
152
        }
171
        }
153
    }
172
    }
154
173
155
    if ($success) {
174
    if ($success && ( $op ne "checkin" && !$uibarcode )) {
156
        # Patron cannot checkin an item they don't own
175
        # Patron cannot checkin an item they don't own
157
        $success = 0
176
        $success = 0
158
          unless $patron->checkouts->find( { itemnumber => $item->itemnumber } );
177
          unless $patron->checkouts->find( { itemnumber => $item->itemnumber } );
159
    }
178
    }
160
179
161
    if ( $success ) {
180
    $uibarcode =~ s/^\s+|\s+$//g;
162
        ($success) = AddReturn( $barcode, $branch )
181
    $checkinitem = Koha::Items->find({ barcode => $uibarcode });
182
    if( !$checkinitem ){
183
        $checkinmessage = "Item not found.";
184
    }
185
    my $tobranch = $checkinitem->homebranch;
186
187
    my ($return_success,$messages,$issueinformation,$borrower) = AddReturn($uibarcode,$branch,undef,$today) unless !$success;
188
189
    my $needstransfer = $messages->{'NeedsTransfer'};
190
    if($messages->{'ResFound'}) {
191
        my $reserve = $messages->{'ResFound'};
192
        my $reserve_id = $reserve->{'reserve_id'};
193
        my $resborrower = $reserve->{'borrowernumber'};
194
        my $diffBranchReturned = $reserve->{'branchcode'};
195
        my $itemnumber = $checkinitem->itemnumber;
196
        my $diffBranchSend = ($branch ne $diffBranchReturned) ? $diffBranchReturned : undef;
197
        if($diffBranchSend) {
198
            ModReserveAffect( $itemnumber, $resborrower, $diffBranchSend, $reserve_id);
199
            ModItemTransfer($itemnumber,$branch,$diffBranchReturned, 'ResFound');
200
        }
201
        else {
202
            my $settransit = C4::Context->preference('RequireSCCheckInBeforeNotifyingPickups') ? 1 : 0;
203
            ModReserveAffect( $itemnumber, $resborrower, $settransit, $reserve_id);
204
        }
205
        $borrower = Koha::Patrons->find({ cardnumber => $patronid });
206
    }
207
    else {
208
         if($needstransfer) {
209
             ModItemTransfer($checkinitem->itemnumber, $branch, $tobranch, 'NeedsTransfer');
210
         }
211
    }
212
213
    if($messages->{'WrongTransfer'}) {
214
       updateWrongTransfer($checkinitem->itemnumber,$tobranch,$branch);
215
    }
216
217
    my $biblio = Koha::Biblios->find({ biblionumber => $checkinitem->biblionumber });
218
    if ( $biblio && ( $success || $return_success )) {
219
        $checkinmessage = "Returned ".$biblio->title;
220
    }
221
222
    if ( $issuer ) {
223
        $checkinbranchcode = $issuer->{branchcode};
224
        #home branch of item
225
        if ($checkinbranchcode) {
226
            my $checkinlibrary = Koha::Libraries->find( $checkinbranchcode );
227
            $checkinmessage.=", ".$checkinlibrary->branchname;
228
        }
163
    }
229
    }
164
230
231
    $template->param(checkinmessage => $checkinmessage || undef);
232
    $template->param(SelfCheckTimeout => 10000); #don't show returns long
233
    $template->param(uibarcode => $uibarcode);
165
    $template->param( returned => $success );
234
    $template->param( returned => $success );
166
}
235
}
167
elsif ( $patron && ( $op eq 'checkout' ) ) {
236
elsif ( $patron && ( $op eq 'checkout' ) ) {
168
- 

Return to bug 22322