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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/sco/sco-main.tt (-1 / +1 lines)
Lines 521-527 Link Here
521
                    var confirmStart = Date.now();
521
                    var confirmStart = Date.now();
522
                    confirmModal("", _("Would you like to print a receipt?"), _("Print receipt and end session"), _("End session"), function(result) {
522
                    confirmModal("", _("Would you like to print a receipt?"), _("Print receipt and end session"), _("End session"), function(result) {
523
                        if ( result && (Date.now() - confirmStart) < [% SelfCheckTimeout | html %] ) {
523
                        if ( result && (Date.now() - confirmStart) < [% SelfCheckTimeout | html %] ) {
524
                            var win = window.open("/cgi-bin/koha/sco/printslip.pl?borrowernumber=[% borrowernumber | html %]&amp;print=qslip");
524
                            var win = window.open("/cgi-bin/koha/sco/printslip.pl?print=qslip");
525
                            location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
525
                            location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
526
                        } else {
526
                        } else {
527
                            location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
527
                            location.href = '/cgi-bin/koha/sco/sco-main.pl?op=logout';
(-)a/opac/sco/printslip.pl (-11 / +33 lines)
Lines 33-70 use C4::Auth qw( in_iprange get_session get_template_and_user ); Link Here
33
use C4::Output qw( output_html_with_http_headers );
33
use C4::Output qw( output_html_with_http_headers );
34
use C4::Members qw( IssueSlip );
34
use C4::Members qw( IssueSlip );
35
35
36
36
my $input = CGI->new;
37
my $input = CGI->new;
37
unless ( in_iprange(C4::Context->preference('SelfCheckAllowByIPRanges')) ) {
38
unless (C4::Context->preference('WebBasedSelfCheck')) {
38
    print $input->header(status => '403 Forbidden - functionality not available from your location');
39
    # redirect to OPAC home if self-check is not enabled
40
    print $input->redirect("/cgi-bin/koha/opac-main.pl");
39
    exit;
41
    exit;
40
}
42
}
41
43
42
my $sessionID = $input->cookie("CGISESSID");
44
unless ( in_iprange(C4::Context->preference('SelfCheckAllowByIPRanges')) ) {
43
my $session = get_session($sessionID);
45
    # redirect to OPAC home if self-checkout not permitted from current IP
46
    print $input->redirect("/cgi-bin/koha/opac-main.pl");
47
    exit;
48
}
44
49
45
my $print = $input->param('print');
50
if (C4::Context->preference('AutoSelfCheckAllowed'))
46
my $error = $input->param('error');
51
{
52
    my $AutoSelfCheckID = C4::Context->preference('AutoSelfCheckID');
53
    my $AutoSelfCheckPass = C4::Context->preference('AutoSelfCheckPass');
54
    $input->param(-name=>'userid',-values=>[$AutoSelfCheckID]);
55
    $input->param(-name=>'password',-values=>[$AutoSelfCheckPass]);
56
    $input->param(-name=>'koha_login_context',-values=>['sco']);
57
}
58
$input->param(-name=>'sco_user_login',-values=>[1]);
47
59
48
# patrons still need to be able to print receipts
60
# patrons still need to be able to print receipts
49
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
61
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
50
    {
62
    {
51
        template_name   => "sco/printslip.tt",
63
        template_name   => "sco/printslip.tt",
64
        flagsrequired   => { self_check => "self_checkout_module" },
52
        query           => $input,
65
        query           => $input,
53
        type            => "opac",
66
        type            => "opac",
54
    }
67
    }
55
);
68
);
56
69
57
my $borrowernumber = $input->param('borrowernumber');
70
my $jwt = $input->cookie('JWT');
58
my $branch=C4::Context->userenv->{'branch'};
71
my $patronid = $jwt ? Koha::Token->new->decode_jwt({ token => $jwt }) : undef;
72
my $patron = $patronid ? Koha::Patrons->find( { cardnumber => $patronid } ) : undef;
73
74
unless ( $patron ) {
75
    print $input->header(-type => 'text/plain', -status => '403 Forbidden');
76
    exit;
77
}
78
79
my $print = $input->param('print');
80
my $error = $input->param('error');
81
59
my ($slip, $is_html);
82
my ($slip, $is_html);
60
if (my $letter = IssueSlip ($session->param('branch') || $branch, $borrowernumber, $print eq "qslip")) {
83
if (my $letter = IssueSlip ($patron->branchcode, $patron->borrowernumber, $print eq "qslip")) {
61
    $slip = $letter->{content};
84
    $slip = $letter->{content};
62
    $is_html = $letter->{is_html};
85
    $is_html = $letter->{is_html};
63
}
86
}
64
87
65
$template->{VARS}->{slip} = $slip;
88
$template->{VARS}->{slip} = $slip;
66
$template->{VARS}->{plain} = !$is_html;
89
$template->{VARS}->{plain} = !$is_html;
67
$template->{VARS}->{borrowernumber} = $borrowernumber;
90
$template->{VARS}->{borrowernumber} = $patron->borrowernumber;
68
$template->{VARS}->{stylesheet} = C4::Context->preference("SlipCSS");
91
$template->{VARS}->{stylesheet} = C4::Context->preference("SlipCSS");
69
$template->{VARS}->{error} = $error;
92
$template->{VARS}->{error} = $error;
70
93
71
- 

Return to bug 30045