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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt (-43 / +82 lines)
Lines 303-362 Link Here
303
                                </div>
303
                                </div>
304
                            [% END %]
304
                            [% END %]
305
305
306
                            <div class="sco_entry">
306
                            <div class="row">
307
                                <form id="mainform" action="/cgi-bin/koha/sco/sco-main.pl" name="mainform" method="post">
307
                                <div id="sco_entry_checkout" class="sco_entry col" >
308
                                    [% INCLUDE 'csrf-token.inc' %]
308
                                    <h4>Check out</h4>
309
                                    <fieldset>
309
                                    <form id="mainform" action="/cgi-bin/koha/sco/sco-main.pl" name="mainform" method="post">
310
                                        <legend>Log in to your account</legend>
310
                                        [% INCLUDE 'csrf-token.inc' %]
311
                                        <div class="row">
311
                                        <fieldset>
312
                                            <div class="col-md-6">
312
                                            <legend>Log in to your account</legend>
313
                                                [% IF ( Koha.Preference('SelfCheckoutByLogin') ) %]
313
                                                <div class="col-md-6">
314
                                                    <div class="row">
314
                                                    [% IF ( Koha.Preference('SelfCheckoutByLogin') ) %]
315
                                                        <div class="col-md-12"> [% PROCESS login_label for="patronlogin" %] </div>
315
                                                        <div class="row">
316
                                                        <div class="col-md-12">
316
                                                            <div class="col-md-12"> [% PROCESS login_label for="patronlogin" %] </div>
317
                                                            <input type="text" id="patronlogin" class="form-control focus noEnterSubmit" size="20" name="patronlogin" autocomplete="off" />
317
                                                            <div class="col-md-12">
318
                                                        </div>
318
                                                                <input type="text" id="patronlogin" class="form-control focus noEnterSubmit" size="20" name="patronlogin" autocomplete="off" />
319
                                                        <div class="col-md-12">
319
                                                            </div>
320
                                                            <label for="patronpw">Password:</label>
320
                                                            <div class="col-md-12">
321
                                                        </div>
321
                                                                <label for="patronpw">Password:</label>
322
                                                        <div class="col-md-12">
322
                                                            </div>
323
                                                            <input type="password" id="patronpw" class="form-control" size="20" name="patronpw" autocomplete="off" />
323
                                                            <div class="col-md-12">
324
                                                                <input type="password" id="patronpw" class="form-control" size="20" name="patronpw" autocomplete="off" />
325
                                                            </div>
326
                                                            <div class="col-md-12">
327
                                                                <button type="submit" class="btn btn-primary">Log in</button>
328
                                                            </div>
324
                                                        </div>
329
                                                        </div>
325
                                                        <div class="col-md-12">
330
                                                        <!-- /.row -->
326
                                                            <button type="submit" class="btn btn-primary">Log in</button>
331
                                                    [% ELSE %]
332
                                                        <div class="row">
333
                                                            <div class="col-md-12">
334
                                                                <label for="patronid">Please enter your card number:</label>
335
                                                            </div>
336
                                                            <div class="col-md-12">
337
                                                                <input type="text" id="patronid" class="form-control focus" size="20" name="patronid" autocomplete="off" />
338
                                                            </div>
339
                                                            <div class="col-md-12">
340
                                                                <button type="submit" class="btn btn-primary">Submit</button>
341
                                                            </div>
327
                                                        </div>
342
                                                        </div>
328
                                                    </div>
343
                                                        <!-- /.row -->
329
                                                    <!-- /.row -->
344
                                                    [% END %]
330
                                                [% ELSE %]
345
                                                </div>
346
                                                <!-- /.col-md-6 -->
347
                                            [% FOREACH INPUT IN INPUTS %]
348
                                                <input type="hidden" name="[% INPUT.name | html %]" value="[% INPUT.value | html %]" />
349
                                            [% END %]
350
                                            <input type="hidden" name="op" value="cud-login" />
351
                                        </fieldset>
352
                                    </form>
353
                                    <!-- /#mainform -->
354
                                </div>
355
                                <!-- / #sco_entry_checkout -->
356
                                <div id="sco_entry_checkin" class="sco_entry col" >
357
                                    <h4>Check in</h4>
358
                                    <form id="barcodeform" action="/cgi-bin/koha/sco/sco-main.pl" name="barcodeform" method="post">
359
                                        [% INCLUDE 'csrf-token.inc' %]
360
                                        <fieldset>
361
                                                <div class="col-md-6">
331
                                                    <div class="row">
362
                                                    <div class="row">
332
                                                        <div class="col-md-12">
363
                                                        <div class="col-md-12">
333
                                                            <label for="patronid">Please enter your card number:</label>
364
                                                            <label for="sco_entry_barcode">Please enter barcode:</label>
334
                                                        </div>
365
                                                        </div>
335
                                                        <div class="col-md-12">
366
                                                        <div class="col-md-12">
336
                                                            <input type="text" id="patronid" class="form-control focus" size="20" name="patronid" autocomplete="off" />
367
                                                            [% IF ( returned == 1 || returned == 0 || empty_return ) %]
368
                                                                <input type="text" id="sco_entry_barcode"  class="form-control focus" size="20" name="sco_entry_barcode" autocomplete="off" />
369
                                                            [% ELSE %]
370
                                                                <input type="text" id="sco_entry_barcode" class="form-control" size="20" name="sco_entry_barcode" autocomplete="off" />
371
                                                            [% END %]
337
                                                        </div>
372
                                                        </div>
338
                                                        <div class="col-md-12">
373
                                                        <div class="col-md-12">
339
                                                            <button type="submit" class="btn btn-primary">Submit</button>
374
                                                            <button type="submit" class="btn btn-primary">Submit</button>
340
                                                        </div>
375
                                                        </div>
341
                                                    </div>
376
                                                    </div>
342
                                                    <!-- /.row -->
377
                                                    <!-- /.row -->
343
                                                [% END %]
378
                                                    [% FOREACH INPUT IN INPUTS %]
344
                                            </div>
379
                                                    <input type="hidden" name="[% INPUT.name |html %]" value="[% INPUT.value |html %]">
345
                                            <!-- /.col-md-6 -->
380
                                                    [% END %]
346
                                        </div>
381
                                                    <input type="hidden" name="op" value="cud-sco_entry_checkin" />
347
                                        <!-- /.row -->
382
                                                </div>
348
                                        [% FOREACH INPUT IN INPUTS %]
383
                                                <!-- /.col-md-6 -->
349
                                            <input type="hidden" name="[% INPUT.name | html %]" value="[% INPUT.value | html %]" />
384
                                        </fieldset>
350
                                        [% END %]
385
                                    </form>
351
                                        <input type="hidden" name="op" value="cud-login" />
386
                                    <!-- /#barcodeform -->
352
                                    </fieldset>
387
                                </div>
353
                                </form>
388
                                <!-- / #sco_entry_checkin -->
354
                                <!-- /#mainform -->
389
                                [% IF ( SCOMainUserBlock ) %]
390
                                    <div id="scomainuserblock"> [% PROCESS koha_news_block news => SCOMainUserBlock %] </div>
391
                                [% END %]
355
                            </div>
392
                            </div>
356
                            <!-- / .sco_entry -->
393
                            <!-- / .row -->
357
                            [% IF ( SCOMainUserBlock ) %]
358
                                <div id="scomainuserblock"> [% PROCESS koha_news_block news => SCOMainUserBlock %] </div>
359
                            [% END %]
360
                        </div>
394
                        </div>
361
                        <!-- / .span12 -->
395
                        <!-- / .span12 -->
362
                    </div>
396
                    </div>
Lines 453-459 Link Here
453
487
454
                $(document).ready(function() {
488
                $(document).ready(function() {
455
                    dofocus();
489
                    dofocus();
456
                    [% IF ( patronid ) %]sco_init();[% END %]
490
                    [% IF ( patronid || barcode ) %]sco_init();[% END %]
457
491
458
                    var dTables = $("#loanTable, #holdst, #finestable");
492
                    var dTables = $("#loanTable, #holdst, #finestable");
459
                    dTables.each(function(){
493
                    dTables.each(function(){
Lines 711-717 Link Here
711
        [% ELSIF ( returned == 1 ) %]
745
        [% ELSIF ( returned == 1 ) %]
712
            <span class="sco-alert-success return"></span>
746
            <span class="sco-alert-success return"></span>
713
            <div class="alert alert-info">
747
            <div class="alert alert-info">
714
                <p>Item checked in <i>([% barcode | html %])</i></p>
748
                <p>Item checked in: [% title | html %] <i>([% barcode | html %])</i>[% IF library %], [% library | html %][% END %]</p>
749
            </div>
750
        [% ELSIF ( empty_return == 1 ) %]
751
            <span class="sco-alert-success return"></span>
752
            <div class="alert alert-info">
753
                <p>Please enter barcode.</p>
715
            </div>
754
            </div>
716
        [% END %]
755
        [% END %]
717
    [% END %]
756
    [% 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