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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt (-19 / +57 lines)
Lines 302-308 Link Here
302
                            </div>
302
                            </div>
303
                        [% END %]
303
                        [% END %]
304
304
305
                        <div class="sco_entry">
305
                        <div id="sco_entry_checkout" class="sco_entry col" >
306
                            <h4>Check out</h4>
306
                            <form id="mainform" action="/cgi-bin/koha/sco/sco-main.pl" name="mainform" method="post">
307
                            <form id="mainform" action="/cgi-bin/koha/sco/sco-main.pl" name="mainform" method="post">
307
                                [% INCLUDE 'csrf-token.inc' %]
308
                                [% INCLUDE 'csrf-token.inc' %]
308
                                <fieldset>
309
                                <fieldset>
Lines 310-331 Link Here
310
                                    <div class="row">
311
                                    <div class="row">
311
                                        <div class="col-md-6">
312
                                        <div class="col-md-6">
312
                                            [% IF ( Koha.Preference('SelfCheckoutByLogin') ) %]
313
                                            [% IF ( Koha.Preference('SelfCheckoutByLogin') ) %]
313
                                                <div class="row">
314
                                            <div class="row">
314
                                                    <div class="col-md-12"> [% PROCESS login_label for="patronlogin" %] </div>
315
                                                <div class="col-md-12"> [% PROCESS login_label for="patronlogin" %] </div>
315
                                                    <div class="col-md-12">
316
                                                <div class="col-md-12">
316
                                                        <input type="text" id="patronlogin" class="form-control focus noEnterSubmit" size="20" name="patronlogin" autocomplete="off" />
317
                                                    <input type="text" id="patronlogin" class="form-control focus noEnterSubmit" size="20" name="patronlogin" autocomplete="off" />
317
                                                    </div>
318
                                                    <div class="col-md-12">
319
                                                        <label for="patronpw">Password:</label>
320
                                                    </div>
321
                                                    <div class="col-md-12">
322
                                                        <input type="password" id="patronpw" class="form-control" size="20" name="patronpw" autocomplete="off" />
323
                                                    </div>
324
                                                    <div class="col-md-12">
325
                                                        <button type="submit" class="btn btn-primary">Log in</button>
326
                                                    </div>
327
                                                </div>
318
                                                </div>
328
                                                <!-- /.row -->
319
                                                <div class="col-md-12">
320
                                                    <label for="patronpw">Password:</label>
321
                                                </div>
322
                                                <div class="col-md-12">
323
                                                    <input type="password" id="patronpw" class="form-control" size="20" name="patronpw" autocomplete="off" />
324
                                                </div>
325
                                                <div class="col-md-12">
326
                                                    <button type="submit" class="btn btn-primary">Log in</button>
327
                                                </div>
328
                                            </div>
329
                                            <!-- /.row -->
329
                                            [% ELSE %]
330
                                            [% ELSE %]
330
                                                <div class="row">
331
                                                <div class="row">
331
                                                    <div class="col-md-12">
332
                                                    <div class="col-md-12">
Lines 352-358 Link Here
352
                            </form>
353
                            </form>
353
                            <!-- /#mainform -->
354
                            <!-- /#mainform -->
354
                        </div>
355
                        </div>
355
                        <!-- / .sco_entry -->
356
                        <!-- / .sco_entry_checkout -->
357
                        <div id="sco_entry_checkin" class="sco_entry col" >
358
                            <form id="barcodeform" action="/cgi-bin/koha/sco/sco-main.pl" name="barcodeform" method="post">
359
                                [% INCLUDE 'csrf-token.inc' %]
360
                                <fieldset class="rows">
361
                                    <div class="row">
362
                                        <div class="col">
363
                                            <h4>Check in</h4>
364
                                        </div>
365
                                    </div>
366
                                    <div class="row">
367
                                        <div class="col-auto">
368
                                            <label for="sco_entry_barcode">Please enter barcode:</label>
369
                                        </div>
370
                                        <div class="col-3">
371
                                            [% IF ( returned == 1 || returned == 0 || empty_return ) %]
372
                                                <input type="text" id="sco_entry_barcode"  class="form-control focus" name="sco_entry_barcode" autocomplete="off" />
373
                                            [% ELSE %]
374
                                                <input type="text" id="sco_entry_barcode" class="form-control" name="sco_entry_barcode" autocomplete="off" />
375
                                            [% END %]
376
                                        </div>
377
                                        <div class="col">
378
                                            <button type="submit" class="btn btn-primary">Submit</button>
379
                                        </div>
380
                                    </div>
381
                                    [% FOREACH INPUT IN INPUTS %]
382
                                    <input type="hidden" name="[% INPUT.name |html %]" value="[% INPUT.value |html %]">
383
                                    [% END %]
384
                                    <input type="hidden" name="op" value="cud-sco_entry_checkin" />
385
                                </fieldset>
386
                            </form>
387
                        </div>
388
                        <!-- / .sco_entry_checkin -->
356
                        [% IF ( SCOMainUserBlock ) %]
389
                        [% IF ( SCOMainUserBlock ) %]
357
                            <div id="scomainuserblock"> [% PROCESS koha_news_block news => SCOMainUserBlock %] </div>
390
                            <div id="scomainuserblock"> [% PROCESS koha_news_block news => SCOMainUserBlock %] </div>
358
                        [% END %]
391
                        [% END %]
Lines 452-458 Link Here
452
485
453
            $(document).ready(function() {
486
            $(document).ready(function() {
454
                dofocus();
487
                dofocus();
455
                [% IF ( patronid ) %]sco_init();[% END %]
488
                [% IF ( patronid || barcode ) %]sco_init();[% END %]
456
489
457
                var dTables = $("#loanTable, #holdst, #finestable");
490
                var dTables = $("#loanTable, #holdst, #finestable");
458
                dTables.each(function(){
491
                dTables.each(function(){
Lines 710-716 Link Here
710
    [% ELSIF ( returned == 1 ) %]
743
    [% ELSIF ( returned == 1 ) %]
711
        <span class="sco-alert-success return"></span>
744
        <span class="sco-alert-success return"></span>
712
        <div class="alert alert-info">
745
        <div class="alert alert-info">
713
            <p>Item checked in <i>([% barcode | html %])</i></p>
746
            <p>Item checked in: [% title | html %] <i>([% barcode | html %])</i>[% IF library %], [% library | html %][% END %]</p>
747
        </div>
748
    [% ELSIF ( empty_return == 1 ) %]
749
        <span class="sco-alert-success return"></span>
750
        <div class="alert alert-info">
751
            <p>Please enter barcode.</p>
714
        </div>
752
        </div>
715
    [% END %]
753
    [% END %]
716
[% END %]
754
[% END %]
(-)a/opac/sco/sco-main.pl (-17 / +64 lines)
Lines 34-42 use CGI qw ( -utf8 ); Link Here
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 );
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::Items qw( ModItemTransfer );
40
use Koha::DateUtils qw( dt_from_string );
41
use Koha::DateUtils qw( dt_from_string );
41
use Koha::Acquisition::Currencies;
42
use Koha::Acquisition::Currencies;
42
use Koha::Items;
43
use Koha::Items;
Lines 88-101 if ( defined C4::Context->preference('SCOAllowCheckin') ) { Link Here
88
}
89
}
89
90
90
my $issuerid = $loggedinuser;
91
my $issuerid = $loggedinuser;
91
my ( $op, $patronlogin, $patronpw, $barcodestr, $confirmed, $newissues, $load_checkouts ) = (
92
my ( $op, $patronlogin, $patronpw, $barcodestr, $confirmed, $newissues, $load_checkouts, $sco_entry_barcode ) = (
92
    $query->param("op")             || '',
93
    $query->param("op")                || '',
93
    $query->param("patronlogin")    || '',
94
    $query->param("patronlogin")       || '',
94
    $query->param("patronpw")       || '',
95
    $query->param("patronpw")          || '',
95
    $query->param("barcode")        || '',
96
    $query->param("barcode")           || '',
96
    $query->param("confirmed")      || '',
97
    $query->param("confirmed")         || '',
97
    $query->param("newissues")      || '',
98
    $query->param("newissues")         || '',
98
    $query->param("load_checkouts") || '',
99
    $query->param("load_checkouts")    || '',
100
    $query->param("sco_entry_barcode") || '',
99
);
101
);
100
102
101
my $jwt = $query->cookie('JWT');
103
my $jwt = $query->cookie('JWT');
Lines 108-115 if ( $op eq "logout" ) { Link Here
108
}
110
}
109
111
110
my $barcodes = [];
112
my $barcodes = [];
111
if ($barcodestr) {
113
if ( $barcodestr || $sco_entry_barcode ) {
112
    push @$barcodes, split( /\s\n/, $barcodestr );
114
    push @$barcodes, split( /\s\n/, $barcodestr ? $barcodestr : $sco_entry_barcode );
113
    $barcodes = [ map { $_ =~ /^\s*$/ ? () : barcodedecode($_) } @$barcodes ];
115
    $barcodes = [ map { $_ =~ /^\s*$/ ? () : barcodedecode($_) } @$barcodes ];
114
}
116
}
115
117
Lines 156-166 if ($patron) { Link Here
156
    }
158
    }
157
}
159
}
158
160
159
if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) {
161
if ( ( $op eq "cud-sco_entry_checkin" ) || ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) ) {
160
    my $success = 1;
162
    my $success = 1;
161
163
164
    if ( !@$barcodes ) {
165
        $template->param( empty_return => 1 );
166
    }
167
162
    foreach my $barcode (@$barcodes) {
168
    foreach my $barcode (@$barcodes) {
163
        my $item = Koha::Items->find( { barcode => $barcode } );
169
        my $item = Koha::Items->find( { barcode => $barcode } );
170
171
        my $title          = $item ? Koha::Biblios->find( { biblionumber => $item->biblionumber } )->title : undef;
172
        my $checkinlibrary = $issuer && $branch ? Koha::Libraries->find($branch)->branchname               : undef;
173
174
        if ( !$item ) {
175
            $success = 0;
176
        }
177
164
        if ( $success && C4::Context->preference("CircConfirmItemParts") ) {
178
        if ( $success && C4::Context->preference("CircConfirmItemParts") ) {
165
            if ( defined($item)
179
            if ( defined($item)
166
                && $item->materials )
180
                && $item->materials )
Lines 169-175 if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) { Link Here
169
            }
183
            }
170
        }
184
        }
171
185
172
        if ($success) {
186
        if ( $success && ( $op ne "cud-sco_entry_checkin" ) ) {
173
187
174
            # Patron cannot checkin an item they don't own
188
            # Patron cannot checkin an item they don't own
175
            $success = 0
189
            $success = 0
Lines 177-188 if ( $patron && $op eq "cud-returnbook" && $allowselfcheckreturns ) { Link Here
177
        }
191
        }
178
192
179
        if ($success) {
193
        if ($success) {
180
            ($success) = AddReturn( $barcode, $branch );
194
195
            my $to_branch = $item->homebranch;
196
            my $messages;
197
198
            ( $success, $messages ) = AddReturn( $barcode, $branch );
199
200
            if ( $messages->{'ResFound'} ) {
201
                my $reserve          = $messages->{'ResFound'};
202
                my $reserve_id       = $reserve->{'reserve_id'};
203
                my $resborrower      = $reserve->{'borrowernumber'};
204
                my $resbranch        = $reserve->{'branchcode'};
205
                my $itemnumber       = $item->itemnumber;
206
                my $diff_branch_send = ( $branch ne $resbranch ) ? $resbranch : undef;
207
208
                if ($diff_branch_send) {
209
                    ModReserveAffect( $itemnumber, $resborrower, $diff_branch_send, $reserve_id );
210
                    ModItemTransfer( $itemnumber, $branch, $resbranch, 'ResFound' );
211
                } else {
212
                    my $set_transit = C4::Context->preference('RequireSCCheckInBeforeNotifyingPickups');
213
                    ModReserveAffect( $itemnumber, $resborrower, $set_transit, $reserve_id );
214
                }
215
            } elsif ( $messages->{'NeedsTransfer'} ) {
216
                ModItemTransfer( $item->itemnumber, $branch, $to_branch, 'NeedsTransfer' );
217
            }
218
219
            if ( $messages->{'WrongTransfer'} ) {
220
                my $item         = Koha::Items->find( $messages->{'WrongTransferItem'} );
221
                my $old_transfer = $item->get_transfer;
222
                my $new_transfer = $item->request_transfer(
223
                    { to => $old_transfer->tobranch, reason => $old_transfer->reason, replace => 'WrongTransfer' } );
224
            }
225
181
        }
226
        }
182
227
183
        $template->param(
228
        $template->param(
184
            returned => $success,
229
            SelfCheckTimeout => 10000,            #don't show returns long
185
            barcode  => $barcode
230
            returned         => $success,
231
            barcode          => $barcode,
232
            title            => $title,
233
            library          => $checkinlibrary
186
        );
234
        );
187
    }    # foreach barcode in barcodes
235
    }    # foreach barcode in barcodes
188
236
189
- 

Return to bug 22322