|
Lines 37-43
unless ( C4::Context->preference('useDischarge') ) {
Link Here
|
| 37 |
exit; |
37 |
exit; |
| 38 |
} |
38 |
} |
| 39 |
|
39 |
|
| 40 |
my $op = $input->param("op") || ''; |
40 |
my $op = $input->param("op") // ''; |
| 41 |
|
41 |
|
| 42 |
# Getting the template and auth |
42 |
# Getting the template and auth |
| 43 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ |
43 |
my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ |
|
Lines 52-62
if ($can_be_discharged == 0) {
Link Here
|
| 52 |
$template->param( has_checkouts => 1 ); |
52 |
$template->param( has_checkouts => 1 ); |
| 53 |
} |
53 |
} |
| 54 |
|
54 |
|
|
|
55 |
my $pending = Koha::Patron::Discharge::count({ |
| 56 |
borrowernumber => $loggedinuser, |
| 57 |
pending => 1, |
| 58 |
}); |
| 59 |
my $available = Koha::Patron::Discharge::is_discharged({borrowernumber => $loggedinuser}); |
| 60 |
|
| 55 |
if ( $op eq 'request' ) { |
61 |
if ( $op eq 'request' ) { |
|
|
62 |
if ($pending || $available) { |
| 63 |
# Request already done |
| 64 |
print $input->redirect("/cgi-bin/koha/opac-discharge.pl"); |
| 65 |
exit; |
| 66 |
} |
| 56 |
my $success = Koha::Patron::Discharge::request({ |
67 |
my $success = Koha::Patron::Discharge::request({ |
| 57 |
borrowernumber => $loggedinuser, |
68 |
borrowernumber => $loggedinuser, |
| 58 |
}); |
69 |
}); |
| 59 |
|
|
|
| 60 |
if ($success) { |
70 |
if ($success) { |
| 61 |
$template->param( success => 1 ); |
71 |
$template->param( success => 1 ); |
| 62 |
} |
72 |
} |
|
Lines 65-70
if ( $op eq 'request' ) {
Link Here
|
| 65 |
} |
75 |
} |
| 66 |
} |
76 |
} |
| 67 |
elsif ( $op eq 'get' ) { |
77 |
elsif ( $op eq 'get' ) { |
|
|
78 |
unless ($available) { |
| 79 |
# No valid discharge to get |
| 80 |
print $input->redirect("/cgi-bin/koha/opac-discharge.pl"); |
| 81 |
exit; |
| 82 |
} |
| 68 |
eval { |
83 |
eval { |
| 69 |
|
84 |
|
| 70 |
# Getting member data |
85 |
# Getting member data |
|
Lines 92-109
elsif ( $op eq 'get' ) {
Link Here
|
| 92 |
} |
107 |
} |
| 93 |
} |
108 |
} |
| 94 |
else { |
109 |
else { |
| 95 |
my $pending = Koha::Patron::Discharge::count({ |
|
|
| 96 |
borrowernumber => $loggedinuser, |
| 97 |
pending => 1, |
| 98 |
}); |
| 99 |
# FIXME looks like $available is not needed |
| 100 |
# If a user is discharged they have a validated discharge available |
| 101 |
my $available = Koha::Patron::Discharge::count({ |
| 102 |
borrowernumber => $loggedinuser, |
| 103 |
validated => 1, |
| 104 |
}); |
| 105 |
$template->param( |
110 |
$template->param( |
| 106 |
available => $available && Koha::Patron::Discharge::is_discharged({borrowernumber => $loggedinuser}), |
111 |
available => $available, |
| 107 |
pending => $pending, |
112 |
pending => $pending, |
| 108 |
); |
113 |
); |
| 109 |
} |
114 |
} |
| 110 |
- |
|
|