Bug 26350: Librarians can request discharge on behalf of patron 2020-09-03-discharge
authorDobrica Pavlinusic <dpavlin@rot13.org>
Wed, 2 Sep 2020 08:59:22 +0000 (10:59 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Thu, 3 Sep 2020 09:21:13 +0000 (11:21 +0200)
While deploying discharges in our library we figured out that librarians
need ability to request discharge document on behalf of patrons from
intranet page.

It was logical to add another option on Discharge patron tab.

It nicely addresses Bug 16466 since it shows status of pending
discharge instead of button to issue new discharge.

To test:
1. apply patch
2. make sure that useDischarge is enabled in administration
3. verify that "Request new discharge" button is availabe, click on it
4. after page reload, message "Patron has pending discharge request."
   will appear
5. click on "Generate discharge" to approve discharge and generate
   pdf (this is unchanged compared to exsting workflow)

koha-tmpl/intranet-tmpl/prog/en/modules/members/discharge.tt
members/discharge.pl

index b832fdf..206ca8f 100644 (file)
         <p>Patron has holds. They will be cancelled if the discharge is generated.</p>
     [% END %]
     <form method="post">
+        [% IF pending %]
+        <p>Patron has pending discharge request.</p>
+        [% ELSIF is_discharged %]
+        <p>Patron is discharged.</p>
+        [% ELSIF can_be_discharged %]
+        <p><input type="submit" value="Request new discharge" name="request" /></p>
+        [% END %]
         <input type="submit" value="Generate discharge" name="discharge" />
         <input type="hidden" value="[% patron.borrowernumber | html %]" name="borrowernumber" />
     </form>
index db74cfc..b3ce894 100755 (executable)
@@ -66,8 +66,29 @@ my $can_be_discharged = Koha::Patron::Discharge::can_be_discharged({
     borrowernumber => $borrowernumber
 });
 
+my $is_discharged = Koha::Patron::Discharge::is_discharged({borrowernumber => $loggedinuser});
+
+my $pending = Koha::Patron::Discharge::count({
+    borrowernumber => $borrowernumber,
+    pending        => 1,
+});
+
+$template->param( can_be_discharged => $can_be_discharged );
+$template->param( is_discharged => $is_discharged );
+$template->param( pending => $pending );
+
+if ( ! $pending and $can_be_discharged and $input->param('request') ) {
+    my $success = Koha::Patron::Discharge::request({
+        borrowernumber => $borrowernumber,
+    });
+    if ( $success ) {
+               $template->param( pending => 1 );
+    }
+}
+
 # Generating discharge if needed
 if ( $input->param('discharge') and $can_be_discharged ) {
+
     my $is_discharged = Koha::Patron::Discharge::is_discharged({
         borrowernumber => $borrowernumber,
     });