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 443-474 Link Here
443
                        </div>
443
                        </div>
444
                    </div>
444
                    </div>
445
                        [% ELSE # IF validuser %]
445
                        [% ELSE # IF validuser %]
446
                            <div class="sco_entry" >
446
                        <div class="row">
447
                            <div class="sco_entry col-5" >
448
                            <h4>Check out</h4>
447
                                <form id="mainform" action="/cgi-bin/koha/sco/sco-main.pl" name="mainform" method="post">
449
                                <form id="mainform" action="/cgi-bin/koha/sco/sco-main.pl" name="mainform" method="post">
448
                                    <fieldset>
450
                                    <fieldset>
449
                                        [% IF ( Koha.Preference('SelfCheckoutByLogin') ) %]
451
                                        [% IF ( Koha.Preference('SelfCheckoutByLogin') ) %]
450
                                            <legend>Log in to your account</legend>
452
                                            <div class="row mb-2">
451
                                            <label for="patronlogin">Login:</label>
453
                                                <div class="col-3">
452
                                            <input type="text" id="patronlogin" class="focus noEnterSubmit" size="20" name="patronlogin" autocomplete="off"/>
454
                                                    <label for="patronlogin">Username:</label>
453
                                            <label for="patronpw">Password:</label>
454
                                            <input type="password" id="patronpw" size="20" name="patronpw" autocomplete="off"/>
455
                                            <fieldset class="action">
456
                                                <button type="submit" class="btn btn-primary">Log in</button>
457
                                            </fieldset>
458
                                        [% ELSE %]
459
                                            <div class="form-row">
460
                                                <div class="col-auto">
461
                                                    <label for="patronid">Please enter your card number:</label>
462
                                                </div>
455
                                                </div>
456
                                                <div class="col-5">
457
                                                    <input type="text" id="patronlogin" class="form-control focus noEnterSubmit" size="20" name="patronlogin" autocomplete="off"/>
458
                                                </div>
459
                                            </div>
460
                                            <div class="row mb-2">
463
                                                <div class="col-3">
461
                                                <div class="col-3">
464
                                                    <input type="text" id="patronid" class="form-control focus" size="20" name="patronid" autocomplete="off" />
462
                                                    <label for="patronpw">Password:</label>
463
                                                </div>
464
                                                <div class="col-5">
465
                                                    <input type="password" id="patronpw" class="form-control" size="20" name="patronpw" autocomplete="off"/>
465
                                                </div>
466
                                                </div>
466
                                                <div class="col-auto">
467
                                            </div>
467
                                                    <button type="submit" class="btn btn-primary">Submit</button>
468
                                            <div class="row justify-content-end">
469
                                                <div class="col-6">
470
                                                    <fieldset class="action">
471
                                                    <button type="submit" class="btn btn-primary">Log in</button>
472
                                                    </fieldset>
468
                                                </div>
473
                                                </div>
469
                                            </div> <!-- /.form-row -->
474
                                            </div>
475
                                        [% ELSE %]
476
                                        <div class="row">
477
                                            <div class="col-auto">
478
                                                <label for="patronid">Please enter your card number:</label>
479
                                            </div>
480
                                            <div class="col-4">
481
                                                <input type="text" id="patronid" class="form-control focus" size="20" name="patronid" autocomplete="off" />
482
                                            </div>
483
                                            <div class="col">
484
                                                <button type="submit" class="btn btn-primary">Submit</button>
485
                                            </div>
486
                                        </div>
470
                                        [% END %]
487
                                        [% END %]
471
472
                                        [% FOREACH INPUT IN INPUTS %]
488
                                        [% FOREACH INPUT IN INPUTS %]
473
                                            <input type="hidden" name="[% INPUT.name | html %]" value="[% INPUT.value | html %]">
489
                                            <input type="hidden" name="[% INPUT.name | html %]" value="[% INPUT.value | html %]">
474
                                        [% END %]
490
                                        [% END %]
Lines 476-483 Link Here
476
                                    </fieldset>
492
                                    </fieldset>
477
                                </form>
493
                                </form>
478
                            </div> <!-- / .sco_entry -->
494
                            </div> <!-- / .sco_entry -->
495
                            <div class="sco_entry col" >
496
                                <form id="barcodeform" action="/cgi-bin/koha/sco/sco-main.pl" name="barcodeform" method="post">
497
                                    <fieldset>
498
                                    <div class="row">
499
                                        <div class="col">
500
                                            <h4>Check in</h4>
501
                                        </div>
502
                                    </div>
503
                                        <div class="row">
504
                                            <div class="col-auto">
505
                                                <label for="uibarcode">Please enter barcode:</label>
506
                                            </div>
507
                                            <div class="col-3">
508
                                                [% IF ( checkinmessage ) %]
509
                                                    <input type="text" id="uibarcode"  class="form-control focus" name="uibarcode" autocomplete="off" />
510
                                                [% ELSE %]
511
                                                    <input type="text" id="uibarcode" class="form-control" name="uibarcode" autocomplete="off" />
512
                                                [% END %]
513
                                            </div>
514
                                            <div class="col">
515
                                                <button type="submit" class="btn btn-primary">Submit</button>
516
                                            </div>
517
                                        </div>
518
                                        [% FOREACH INPUT IN INPUTS %]
519
                                        <input type="hidden" name="[% INPUT.name |html %]" value="[% INPUT.value |html %]">
520
                                        [% END %]
521
                                        <input type="hidden" name="op" value="checkin" />
522
                                    </fieldset>
523
                                </form>
524
                            </div> <!-- / .sco_entry -->
525
                        </div> <!-- / .row -->
479
                        [% END # / IF validuser %]
526
                        [% END # / IF validuser %]
480
                    [% END # / UNLESS ( hide_main %]
527
                    [% END # / UNLESS ( hide_main %]
528
                    <b>[% checkinmessage %]</b>
481
                    [% IF ( SCOMainUserBlock ) %]
529
                    [% IF ( SCOMainUserBlock ) %]
482
                        <div id="scomainuserblock">
530
                        <div id="scomainuserblock">
483
                            [% PROCESS koha_news_block news => SCOMainUserBlock %]
531
                            [% PROCESS koha_news_block news => SCOMainUserBlock %]
Lines 486-492 Link Here
486
                </div> <!-- / .span12 -->
534
                </div> <!-- / .span12 -->
487
            </div> <!-- / .row -->
535
            </div> <!-- / .row -->
488
        </div> <!-- / .container-fluid -->
536
        </div> <!-- / .container-fluid -->
489
    </div> <!-- / .main -->
537
      </div> <!-- / .main -->
490
    <span id="audio-alert"></span>
538
    <span id="audio-alert"></span>
491
539
492
[% INCLUDE 'opac-bottom.inc' %]
540
[% INCLUDE 'opac-bottom.inc' %]
Lines 555-561 Link Here
555
603
556
        $(document).ready(function() {
604
        $(document).ready(function() {
557
            dofocus();
605
            dofocus();
558
            [% IF ( patronid ) %]sco_init();[% END %]
606
            [% IF ( patronid || uibarcode ) %]sco_init();[% END %]
559
607
560
            var dTables = $("#loanTable, #holdst, #finestable");
608
            var dTables = $("#loanTable, #holdst, #finestable");
561
            dTables.each(function(){
609
            dTables.each(function(){
Lines 589-594 Link Here
589
                dataTables.DataTable().responsive.recalc();
637
                dataTables.DataTable().responsive.recalc();
590
            } );
638
            } );
591
639
640
592
            $("#logout_form").on("click", function(e){
641
            $("#logout_form").on("click", function(e){
593
                e.preventDefault(e);
642
                e.preventDefault(e);
594
                clearTimeout(mainTimeout);
643
                clearTimeout(mainTimeout);
Lines 606-612 Link Here
606
                [% ELSE %]
655
                [% ELSE %]
607
                    location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
656
                    location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
608
                [% END %]
657
                [% END %]
658
                return true;
659
            });
609
660
661
            $("#logout_form_vara").on("click", function() {
662
                clearTimeout(mainTimeout);
663
                [% IF Koha.Preference('SelfCheckReceiptPrompt') %]
664
                var confirmStart = Date.now();
665
                if(confirm(_("Would you like to print a receipt?"))){
666
                    if ( (Date.now() - confirmStart) < [% SelfCheckTimeout %] ) {
667
                        window.open("/cgi-bin/koha/sco/printslip.pl?borrowernumber=[% borrowernumber %]&amp;print=qslip");
668
                    }
669
                    else {
670
                        alert(_("Timeout while waiting for print confirmation"));
671
                    }
672
                }
673
                [% END %]
610
                return true;
674
                return true;
611
            });
675
            });
612
676
(-)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-99 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, $load_checkouts ) = (
101
my ( $op, $patronlogin, $patronpw, $barcode, $confirmed, $newissues, $load_checkouts, $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")       || '',
Lines 101-106 my ( $op, $patronlogin, $patronpw, $barcode, $confirmed, $newissues, $load_check Link Here
101
    $query->param("confirmed")      || '',
106
    $query->param("confirmed")      || '',
102
    $query->param("newissues")      || '',
107
    $query->param("newissues")      || '',
103
    $query->param("load_checkouts") || '',
108
    $query->param("load_checkouts") || '',
109
    $query->param("uibarcode")      || '',
110
    $query->param("checkinmessage") || undef,
104
);
111
);
105
112
106
my $jwt = $query->cookie('JWT');
113
my $jwt = $query->cookie('JWT');
Lines 116-121 my @newissueslist = split /,/, $newissues; Link Here
116
my $issuenoconfirm = 1; #don't need to confirm on issue.
123
my $issuenoconfirm = 1; #don't need to confirm on issue.
117
my $issuer   = Koha::Patrons->find( $issuerid )->unblessed;
124
my $issuer   = Koha::Patrons->find( $issuerid )->unblessed;
118
125
126
my $checkinitem;
127
my $checkinbranchcode;
128
my $userenv = C4::Context->userenv;
129
my $userenv_branch = $userenv->{'branch'} // '';
130
my $daysmode = Koha::CirculationRules->get_effective_daysmode(
131
    {
132
        branchcode   => $userenv_branch,
133
    }
134
);
135
my $calendar    = Koha::Calendar->new( branchcode => $userenv_branch, days_mode => $daysmode );
136
my $today       = DateTime->now( time_zone => C4::Context->tz());
137
119
my $patronid = $jwt ? Koha::Token->new->decode_jwt({ token => $jwt }) : undef;
138
my $patronid = $jwt ? Koha::Token->new->decode_jwt({ token => $jwt }) : undef;
120
unless ( $patronid ) {
139
unless ( $patronid ) {
121
    if ( C4::Context->preference('SelfCheckoutByLogin') ) {
140
    if ( C4::Context->preference('SelfCheckoutByLogin') ) {
Lines 140-146 my $branch = $issuer->{branchcode}; Link Here
140
my $confirm_required = 0;
159
my $confirm_required = 0;
141
my $return_only = 0;
160
my $return_only = 0;
142
161
143
if ( $patron && $op eq "returnbook" && $allowselfcheckreturns ) {
162
if ( ( $op eq "checkin" && $uibarcode ) || $patron && $op eq "returnbook" && $allowselfcheckreturns ) {
144
    my $success = 1;
163
    my $success = 1;
145
164
146
165
Lines 153-168 if ( $patron && $op eq "returnbook" && $allowselfcheckreturns ) { Link Here
153
        }
172
        }
154
    }
173
    }
155
174
156
    if ($success) {
175
    if ($success && ( $op ne "checkin" && !$uibarcode )) {
157
        # Patron cannot checkin an item they don't own
176
        # Patron cannot checkin an item they don't own
158
        $success = 0
177
        $success = 0
159
          unless $patron->checkouts->find( { itemnumber => $item->itemnumber } );
178
          unless $patron->checkouts->find( { itemnumber => $item->itemnumber } );
160
    }
179
    }
161
180
162
    if ( $success ) {
181
    $uibarcode =~ s/^\s+|\s+$//g;
163
        ($success) = AddReturn( $barcode, $branch )
182
    $checkinitem = Koha::Items->find({ barcode => $uibarcode });
183
    if( !$checkinitem ){
184
        $checkinmessage = "Item not found.";
185
    }
186
    my $tobranch = $checkinitem->homebranch;
187
188
    my ($return_success,$messages,$issueinformation,$borrower) = AddReturn($uibarcode,$branch,undef,$today) unless !$success;
189
190
    my $needstransfer = $messages->{'NeedsTransfer'};
191
    if($messages->{'ResFound'}) {
192
        my $reserve = $messages->{'ResFound'};
193
        my $reserve_id = $reserve->{'reserve_id'};
194
        my $resborrower = $reserve->{'borrowernumber'};
195
        my $diffBranchReturned = $reserve->{'branchcode'};
196
        my $itemnumber = $checkinitem->itemnumber;
197
        my $diffBranchSend = ($branch ne $diffBranchReturned) ? $diffBranchReturned : undef;
198
        if($diffBranchSend) {
199
            ModReserveAffect( $itemnumber, $resborrower, $diffBranchSend, $reserve_id);
200
            ModItemTransfer($itemnumber,$branch,$diffBranchReturned, 'ResFound');
201
        }
202
        else {
203
            my $settransit = C4::Context->preference('RequireSCCheckInBeforeNotifyingPickups') ? 1 : 0;
204
            ModReserveAffect( $itemnumber, $resborrower, $settransit, $reserve_id);
205
        }
206
        $borrower = Koha::Patrons->find({ cardnumber => $patronid });
207
    }
208
    else {
209
         if($needstransfer) {
210
             ModItemTransfer($checkinitem->itemnumber, $branch, $tobranch, 'NeedsTransfer');
211
         }
212
    }
213
214
    if($messages->{'WrongTransfer'}) {
215
       updateWrongTransfer($checkinitem->itemnumber,$tobranch,$branch);
216
    }
217
218
    my $biblio = Koha::Biblios->find({ biblionumber => $checkinitem->biblionumber });
219
    if ( $biblio && ( $success || $return_success )) {
220
        $checkinmessage = "Returned ".$biblio->title;
221
    }
222
223
    if ( $issuer ) {
224
        $checkinbranchcode = $issuer->{branchcode};
225
        #home branch of item
226
        if ($checkinbranchcode) {
227
            my $checkinlibrary = Koha::Libraries->find( $checkinbranchcode );
228
            $checkinmessage.=", ".$checkinlibrary->branchname;
229
        }
164
    }
230
    }
165
231
232
    $template->param(checkinmessage => $checkinmessage || undef);
233
    $template->param(SelfCheckTimeout => 10000); #don't show returns long
234
    $template->param(uibarcode => $uibarcode);
166
    $template->param( returned => $success );
235
    $template->param( returned => $success );
167
}
236
}
168
elsif ( $patron && ( $op eq 'checkout' ) ) {
237
elsif ( $patron && ( $op eq 'checkout' ) ) {
169
- 

Return to bug 22322