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 32-38 Link Here
32
[% Asset.js('js/i18n.js') | $raw %]
32
[% Asset.js('js/i18n.js') | $raw %]
33
</head>
33
</head>
34
<body id="sco_help" class="sco">
34
<body id="sco_help" class="sco">
35
    [% INCLUDE 'masthead-sco.inc' %]
35
[% INCLUDE 'masthead-sco-self.inc' %]
36
36
37
    <div class="main">
37
    <div class="main">
38
        <div class="container-fluid">
38
        <div class="container-fluid">
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt (-21 / +85 lines)
Lines 45-51 Link Here
45
<body id="sco_main" class="sco">
45
<body id="sco_main" class="sco">
46
    [% INCLUDE 'masthead-sco.inc' %]
46
    [% INCLUDE 'masthead-sco.inc' %]
47
47
48
    <div class="main">
48
   <div class="main">
49
        <div class="container-fluid">
49
        <div class="container-fluid">
50
            <div class="row">
50
            <div class="row">
51
                [% IF ( display_patron_image ) %]
51
                [% IF ( display_patron_image ) %]
Lines 449-481 Link Here
449
                        </div>
449
                        </div>
450
                    </div>
450
                    </div>
451
                        [% ELSE # IF validuser %]
451
                        [% ELSE # IF validuser %]
452
                            <div class="sco_entry" >
452
                        <div class="row">
453
                            <div class="sco_entry col-5" >
454
                            <h4>Check out</h4>
453
                                <form id="mainform" action="/cgi-bin/koha/sco/sco-main.pl" name="mainform" method="post">
455
                                <form id="mainform" action="/cgi-bin/koha/sco/sco-main.pl" name="mainform" method="post">
454
                                    [% INCLUDE 'csrf-token.inc' %]
456
                                    [% INCLUDE 'csrf-token.inc' %]
455
                                    <fieldset>
457
                                    <fieldset>
456
                                        [% IF ( Koha.Preference('SelfCheckoutByLogin') ) %]
458
                                        [% IF ( Koha.Preference('SelfCheckoutByLogin') ) %]
457
                                            <legend>Log in to your account</legend>
459
                                            <div class="row mb-2">
458
                                            <label for="patronlogin">Login:</label>
460
                                                <div class="col-3">
459
                                            <input type="text" id="patronlogin" class="focus noEnterSubmit" size="20" name="patronlogin" autocomplete="off"/>
461
                                                    <label for="patronlogin">Username:</label>
460
                                            <label for="patronpw">Password:</label>
461
                                            <input type="password" id="patronpw" size="20" name="patronpw" autocomplete="off"/>
462
                                            <fieldset class="action">
463
                                                <button type="submit" class="btn btn-primary">Log in</button>
464
                                            </fieldset>
465
                                        [% ELSE %]
466
                                            <div class="form-row">
467
                                                <div class="col-auto">
468
                                                    <label for="patronid">Please enter your card number:</label>
469
                                                </div>
462
                                                </div>
463
                                                <div class="col-5">
464
                                                    <input type="text" id="patronlogin" class="form-control focus noEnterSubmit" size="20" name="patronlogin" autocomplete="off"/>
465
                                                </div>
466
                                            </div>
467
                                            <div class="row mb-2">
470
                                                <div class="col-3">
468
                                                <div class="col-3">
471
                                                    <input type="text" id="patronid" class="form-control focus" size="20" name="patronid" autocomplete="off" />
469
                                                    <label for="patronpw">Password:</label>
470
                                                </div>
471
                                                <div class="col-5">
472
                                                    <input type="password" id="patronpw" class="form-control" size="20" name="patronpw" autocomplete="off"/>
472
                                                </div>
473
                                                </div>
473
                                                <div class="col-auto">
474
                                            </div>
474
                                                    <button type="submit" class="btn btn-primary">Submit</button>
475
                                            <div class="row justify-content-end">
476
                                                <div class="col-6">
477
                                                    <fieldset class="action">
478
                                                    <button type="submit" class="btn btn-primary">Log in</button>
479
                                                    </fieldset>
475
                                                </div>
480
                                                </div>
476
                                            </div> <!-- /.form-row -->
481
                                            </div>
482
                                        [% ELSE %]
483
                                        <div class="row">
484
                                            <div class="col-auto">
485
                                                <label for="patronid">Please enter your card number:</label>
486
                                            </div>
487
                                            <div class="col-4">
488
                                                <input type="text" id="patronid" class="form-control focus" size="20" name="patronid" autocomplete="off" />
489
                                            </div>
490
                                            <div class="col">
491
                                                <button type="submit" class="btn btn-primary">Submit</button>
492
                                            </div>
493
                                        </div>
477
                                        [% END %]
494
                                        [% END %]
478
479
                                        [% FOREACH INPUT IN INPUTS %]
495
                                        [% FOREACH INPUT IN INPUTS %]
480
                                            <input type="hidden" name="[% INPUT.name | html %]" value="[% INPUT.value | html %]">
496
                                            <input type="hidden" name="[% INPUT.name | html %]" value="[% INPUT.value | html %]">
481
                                        [% END %]
497
                                        [% END %]
Lines 483-490 Link Here
483
                                    </fieldset>
499
                                    </fieldset>
484
                                </form>
500
                                </form>
485
                            </div> <!-- / .sco_entry -->
501
                            </div> <!-- / .sco_entry -->
502
                            <div class="sco_entry col" >
503
                                <form id="barcodeform" action="/cgi-bin/koha/sco/sco-main.pl" name="barcodeform" method="post">
504
                                    <fieldset>
505
                                    <div class="row">
506
                                        <div class="col">
507
                                            <h4>Check in</h4>
508
                                        </div>
509
                                    </div>
510
                                        <div class="row">
511
                                            <div class="col-auto">
512
                                                <label for="uibarcode">Please enter barcode:</label>
513
                                            </div>
514
                                            <div class="col-3">
515
                                                [% IF ( checkinmessage ) %]
516
                                                    <input type="text" id="uibarcode"  class="form-control focus" name="uibarcode" autocomplete="off" />
517
                                                [% ELSE %]
518
                                                    <input type="text" id="uibarcode" class="form-control" name="uibarcode" autocomplete="off" />
519
                                                [% END %]
520
                                            </div>
521
                                            <div class="col">
522
                                                <button type="submit" class="btn btn-primary">Submit</button>
523
                                            </div>
524
                                        </div>
525
                                        [% FOREACH INPUT IN INPUTS %]
526
                                        <input type="hidden" name="[% INPUT.name |html %]" value="[% INPUT.value |html %]">
527
                                        [% END %]
528
                                        <input type="hidden" name="op" value="checkin" />
529
                                    </fieldset>
530
                                </form>
531
                            </div> <!-- / .sco_entry -->
532
                        </div> <!-- / .row -->
486
                        [% END # / IF validuser %]
533
                        [% END # / IF validuser %]
487
                    [% END # / UNLESS ( hide_main %]
534
                    [% END # / UNLESS ( hide_main %]
535
                    <b>[% checkinmessage %]</b>
488
                    [% IF ( SCOMainUserBlock ) %]
536
                    [% IF ( SCOMainUserBlock ) %]
489
                        <div id="scomainuserblock">
537
                        <div id="scomainuserblock">
490
                            [% PROCESS koha_news_block news => SCOMainUserBlock %]
538
                            [% PROCESS koha_news_block news => SCOMainUserBlock %]
Lines 493-499 Link Here
493
                </div> <!-- / .span12 -->
541
                </div> <!-- / .span12 -->
494
            </div> <!-- / .row -->
542
            </div> <!-- / .row -->
495
        </div> <!-- / .container-fluid -->
543
        </div> <!-- / .container-fluid -->
496
    </div> <!-- / .main -->
544
      </div> <!-- / .main -->
497
    <span id="audio-alert"></span>
545
    <span id="audio-alert"></span>
498
546
499
[% INCLUDE 'opac-bottom.inc' %]
547
[% INCLUDE 'opac-bottom.inc' %]
Lines 562-568 Link Here
562
610
563
        $(document).ready(function() {
611
        $(document).ready(function() {
564
            dofocus();
612
            dofocus();
565
            [% IF ( patronid ) %]sco_init();[% END %]
613
            [% IF ( patronid || uibarcode ) %]sco_init();[% END %]
566
614
567
            var dTables = $("#loanTable, #holdst, #finestable");
615
            var dTables = $("#loanTable, #holdst, #finestable");
568
            dTables.each(function(){
616
            dTables.each(function(){
Lines 596-601 Link Here
596
                dataTables.DataTable().responsive.recalc();
644
                dataTables.DataTable().responsive.recalc();
597
            } );
645
            } );
598
646
647
599
            $("#logout_form").on("click", function(e){
648
            $("#logout_form").on("click", function(e){
600
                e.preventDefault(e);
649
                e.preventDefault(e);
601
                clearTimeout(mainTimeout);
650
                clearTimeout(mainTimeout);
Lines 613-619 Link Here
613
                [% ELSE %]
662
                [% ELSE %]
614
                    location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
663
                    location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
615
                [% END %]
664
                [% END %]
665
                return true;
666
            });
616
667
668
            $("#logout_form_vara").on("click", function() {
669
                clearTimeout(mainTimeout);
670
                [% IF Koha.Preference('SelfCheckReceiptPrompt') %]
671
                var confirmStart = Date.now();
672
                if(confirm(_("Would you like to print a receipt?"))){
673
                    if ( (Date.now() - confirmStart) < [% SelfCheckTimeout %] ) {
674
                        window.open("/cgi-bin/koha/sco/printslip.pl?borrowernumber=[% borrowernumber %]&amp;print=qslip");
675
                    }
676
                    else {
677
                        alert(_("Timeout while waiting for print confirmation"));
678
                    }
679
                }
680
                [% END %]
617
                return true;
681
                return true;
618
            });
682
            });
619
683
(-)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 46-51 use Koha::Patron::Messages; Link Here
46
use Koha::Plugins;
48
use Koha::Plugins;
47
use Koha::Token;
49
use Koha::Token;
48
use Koha::CookieManager;
50
use Koha::CookieManager;
51
use Koha::Calendar;
49
52
50
my $query = CGI->new;
53
my $query = CGI->new;
51
54
Lines 66-74 $query->param(-name=>'sco_user_login',-values=>[1]); Link Here
66
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
69
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
67
    {
70
    {
68
        template_name   => "sco/sco-main.tt",
71
        template_name   => "sco/sco-main.tt",
72
        authnotrequired => 0,
69
        flagsrequired   => { self_check => "self_checkout_module" },
73
        flagsrequired   => { self_check => "self_checkout_module" },
70
        query           => $query,
74
        query           => $query,
71
        type            => "opac",
75
        type            => "opac",
76
        debug => 1,
72
    }
77
    }
73
);
78
);
74
79
Lines 86-92 if (defined C4::Context->preference('SCOAllowCheckin')) { Link Here
86
}
91
}
87
92
88
my $issuerid = $loggedinuser;
93
my $issuerid = $loggedinuser;
89
my ( $op, $patronlogin, $patronpw, $barcode, $confirmed, $newissues, $load_checkouts ) = (
94
my ( $op, $patronlogin, $patronpw, $barcode, $confirmed, $newissues, $load_checkouts, $uibarcode, $checkinmessage ) = (
90
    $query->param("op")             || '',
95
    $query->param("op")             || '',
91
    $query->param("patronlogin")    || '',
96
    $query->param("patronlogin")    || '',
92
    $query->param("patronpw")       || '',
97
    $query->param("patronpw")       || '',
Lines 94-99 my ( $op, $patronlogin, $patronpw, $barcode, $confirmed, $newissues, $load_check Link Here
94
    $query->param("confirmed")      || '',
99
    $query->param("confirmed")      || '',
95
    $query->param("newissues")      || '',
100
    $query->param("newissues")      || '',
96
    $query->param("load_checkouts") || '',
101
    $query->param("load_checkouts") || '',
102
    $query->param("uibarcode")      || '',
103
    $query->param("checkinmessage") || undef,
97
);
104
);
98
105
99
my $jwt = $query->cookie('JWT');
106
my $jwt = $query->cookie('JWT');
Lines 110-115 my @newissueslist = split /,/, $newissues; Link Here
110
my $issuenoconfirm = 1; #don't need to confirm on issue.
117
my $issuenoconfirm = 1; #don't need to confirm on issue.
111
my $issuer   = Koha::Patrons->find( $issuerid )->unblessed;
118
my $issuer   = Koha::Patrons->find( $issuerid )->unblessed;
112
119
120
my $checkinitem;
121
my $checkinbranchcode;
122
my $userenv = C4::Context->userenv;
123
my $userenv_branch = $userenv->{'branch'} // '';
124
my $daysmode = Koha::CirculationRules->get_effective_daysmode(
125
    {
126
        branchcode   => $userenv_branch,
127
    }
128
);
129
my $calendar    = Koha::Calendar->new( branchcode => $userenv_branch, days_mode => $daysmode );
130
my $today       = DateTime->now( time_zone => C4::Context->tz());
131
113
my $patronid = $jwt ? Koha::Token->new->decode_jwt({ token => $jwt }) : undef;
132
my $patronid = $jwt ? Koha::Token->new->decode_jwt({ token => $jwt }) : undef;
114
unless ( $patronid ) {
133
unless ( $patronid ) {
115
    if ( C4::Context->preference('SelfCheckoutByLogin') ) {
134
    if ( C4::Context->preference('SelfCheckoutByLogin') ) {
Lines 134-140 my $branch = $issuer->{branchcode}; Link Here
134
my $confirm_required = 0;
153
my $confirm_required = 0;
135
my $return_only = 0;
154
my $return_only = 0;
136
155
137
if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) {
156
if ( ( $op eq "cud-checkin" && $uibarcode ) || $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) {
138
    my $success = 1;
157
    my $success = 1;
139
158
140
159
Lines 147-162 if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) { Link Here
147
        }
166
        }
148
    }
167
    }
149
168
150
    if ($success) {
169
    if ($success && ( $op ne "cud-checkin" && !$uibarcode )) {
151
        # Patron cannot checkin an item they don't own
170
        # Patron cannot checkin an item they don't own
152
        $success = 0
171
        $success = 0
153
          unless $patron->checkouts->find( { itemnumber => $item->itemnumber } );
172
          unless $patron->checkouts->find( { itemnumber => $item->itemnumber } );
154
    }
173
    }
155
174
156
    if ( $success ) {
175
    $uibarcode =~ s/^\s+|\s+$//g;
157
        ($success) = AddReturn( $barcode, $branch )
176
    $checkinitem = Koha::Items->find({ barcode => $uibarcode });
177
    if( !$checkinitem ){
178
        $checkinmessage = "Item not found.";
179
    }
180
    my $tobranch = $checkinitem->homebranch;
181
182
    my ($return_success,$messages,$issueinformation,$borrower) = AddReturn($uibarcode,$branch,undef,$today) unless !$success;
183
184
    my $needstransfer = $messages->{'NeedsTransfer'};
185
    if($messages->{'ResFound'}) {
186
        my $reserve = $messages->{'ResFound'};
187
        my $reserve_id = $reserve->{'reserve_id'};
188
        my $resborrower = $reserve->{'borrowernumber'};
189
        my $diffBranchReturned = $reserve->{'branchcode'};
190
        my $itemnumber = $checkinitem->itemnumber;
191
        my $diffBranchSend = ($branch ne $diffBranchReturned) ? $diffBranchReturned : undef;
192
        if($diffBranchSend) {
193
            ModReserveAffect( $itemnumber, $resborrower, $diffBranchSend, $reserve_id);
194
            ModItemTransfer($itemnumber,$branch,$diffBranchReturned, 'ResFound');
195
        }
196
        else {
197
            my $settransit = C4::Context->preference('RequireSCCheckInBeforeNotifyingPickups') ? 1 : 0;
198
            ModReserveAffect( $itemnumber, $resborrower, $settransit, $reserve_id);
199
        }
200
        $borrower = Koha::Patrons->find({ cardnumber => $patronid });
201
    }
202
    else {
203
         if($needstransfer) {
204
             ModItemTransfer($checkinitem->itemnumber, $branch, $tobranch, 'NeedsTransfer');
205
         }
206
    }
207
208
    if($messages->{'WrongTransfer'}) {
209
       updateWrongTransfer($checkinitem->itemnumber,$tobranch,$branch);
210
    }
211
212
    my $biblio = Koha::Biblios->find({ biblionumber => $checkinitem->biblionumber });
213
    if ( $biblio && ( $success || $return_success )) {
214
        $checkinmessage = "Returned ".$biblio->title;
215
    }
216
217
    if ( $issuer ) {
218
        $checkinbranchcode = $issuer->{branchcode};
219
        #home branch of item
220
        if ($checkinbranchcode) {
221
            my $checkinlibrary = Koha::Libraries->find( $checkinbranchcode );
222
            $checkinmessage.=", ".$checkinlibrary->branchname;
223
        }
158
    }
224
    }
159
225
226
    $template->param(checkinmessage => $checkinmessage || undef);
227
    $template->param(SelfCheckTimeout => 10000); #don't show returns long
228
    $template->param(uibarcode => $uibarcode);
160
    $template->param( returned => $success );
229
    $template->param( returned => $success );
161
}
230
}
162
elsif ( $patron && ( $op eq 'cud-checkout' ) ) {
231
elsif ( $patron && ( $op eq 'cud-checkout' ) ) {
163
- 

Return to bug 22322