Bugzilla – Attachment 40171 Details for
Bug 14368
Add discharges history
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14368: Add discharges history.
Bug-14368-Add-discharges-history.patch (text/plain), 8.19 KB, created by
Indranil Das Gupta
on 2015-06-16 10:17:16 UTC
(
hide
)
Description:
Bug 14368: Add discharges history.
Filename:
MIME Type:
Creator:
Indranil Das Gupta
Created:
2015-06-16 10:17:16 UTC
Size:
8.19 KB
patch
obsolete
>From 5df13550f0e7cf04ebe06264d19cf45df9317241 Mon Sep 17 00:00:00 2001 >From: Matthias Meusburger <matthias.meusburger@biblibre.com> >Date: Tue, 9 Jun 2015 14:35:07 +0200 >Subject: [PATCH] Bug 14368: Add discharges history. > >Currently, once a user is discharged, lifting the discharge debarment does >not allow the user to ask for a discharge again. > >This patch adds the ability for a user to be discharged several times and to >keep an history of the discharges. > >Test plan: > > - As a user, ask for a discharge. > - As a librarian, allow the discharge. > - Check that the requested and validated dates appear on the discharge panel of the borrower in the admin interface. > - Lift the discharge debarment of the user. > - Check that you can repeat these steps and that the new discharges are added in the discharge panel of the borrower in the admin interface. > >Please note that you will need to run misc/devel/update_dbix_class_files.pl after the SQL update. >Adding a primary key to the discharges table was mandatory for DBIX::Class to be able to query with order_by. > >Signed-off-by: Indranil Das Gupta (L2C2 Technologies) <indradg@gmail.com> >--- > Koha/Borrower/Discharge.pm | 35 ++++++++++++++++++++-- > .../bug_14368_Add_discharges_history.sql | 1 + > installer/data/mysql/kohastructure.sql | 2 ++ > .../prog/en/modules/members/discharge.tt | 21 +++++++++++++ > members/discharge.pl | 6 ++++ > opac/opac-discharge.pl | 2 +- > t/db_dependent/Borrower_Discharge.t | 7 +++++ > 7 files changed, 71 insertions(+), 3 deletions(-) > create mode 100644 installer/data/mysql/atomicupdate/bug_14368_Add_discharges_history.sql > >diff --git a/Koha/Borrower/Discharge.pm b/Koha/Borrower/Discharge.pm >index ba0216d..edbed9b 100644 >--- a/Koha/Borrower/Discharge.pm >+++ b/Koha/Borrower/Discharge.pm >@@ -45,12 +45,27 @@ sub can_be_discharged { > } > } > >+sub is_discharged { >+ my ($params) = @_; >+ return unless $params->{borrowernumber}; >+ my $borrowernumber = $params->{borrowernumber}; >+ >+ >+ my $restricted = Koha::Borrower::Debarments::IsDebarred($borrowernumber); >+ my $validated = get_validated({borrowernumber => $borrowernumber}); >+ >+ if ($restricted && $validated) { >+ return 1; >+ } else { >+ return 0; >+ } >+} >+ > sub request { > my ($params) = @_; > my $borrowernumber = $params->{borrowernumber}; > return unless $borrowernumber; > return unless can_be_discharged({ borrowernumber => $borrowernumber }); >- return if count($params); > > return $rs->create({ > borrower => $borrowernumber, >@@ -76,7 +91,7 @@ sub discharge { > }); > > # Generate the discharge >- my $discharge = $rs->search({ borrower => $borrowernumber }); >+ my $discharge = $rs->search({ borrower => $borrowernumber }, { order_by => { -desc => 'needed' }, rows => 1 }); > if( $discharge->count > 0 ) { > $discharge->update({ validated => dt_from_string }); > } >@@ -149,4 +164,20 @@ sub get_pendings { > return \@rs; > } > >+sub get_validated { >+ my ($params) = @_; >+ my $branchcode = $params->{branchcode}; >+ my $borrowernumber = $params->{borrowernumber}; >+ >+ my $cond = { >+ 'me.validated' => { '!=', undef }, >+ ( defined $borrowernumber ? ( 'me.borrower' => $borrowernumber ) : () ), >+ ( defined $branchcode ? ( 'borrower.branchcode' => $branchcode ) : () ), >+ }; >+ >+ my @rs = $rs->search( $cond, { join => 'borrower' } ); >+ return \@rs; >+} >+ >+ > 1; >diff --git a/installer/data/mysql/atomicupdate/bug_14368_Add_discharges_history.sql b/installer/data/mysql/atomicupdate/bug_14368_Add_discharges_history.sql >new file mode 100644 >index 0000000..2c822eb >--- /dev/null >+++ b/installer/data/mysql/atomicupdate/bug_14368_Add_discharges_history.sql >@@ -0,0 +1 @@ >+ALTER TABLE discharges ADD COLUMN discharge_id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST; >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index 6683125..d5f4665 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -3525,9 +3525,11 @@ CREATE TABLE items_search_fields ( > > DROP TABLE IF EXISTS discharges; > CREATE TABLE discharges ( >+ discharge_id int(11) NOT NULL AUTO_INCREMENT, > borrower int(11) DEFAULT NULL, > needed timestamp NULL DEFAULT NULL, > validated timestamp NULL DEFAULT NULL, >+ PRIMARY KEY (discharge_id), > KEY borrower_discharges_ibfk1 (borrower), > CONSTRAINT borrower_discharges_ibfk1 FOREIGN KEY (borrower) REFERENCES borrowers (borrowernumber) ON DELETE CASCADE ON UPDATE CASCADE > ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/discharge.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/discharge.tt >index 00d3a3a..b14d773 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/discharge.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/discharge.tt >@@ -1,3 +1,4 @@ >+[% USE KohaDates %] > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Patrons › [% IF (unknowuser) %]Patron does not exist[% ELSE %]Discharge for [% firstname %] [% surname %] ([% cardnumber %])[% END %]</title> > [% INCLUDE 'doc-head-close.inc' %] >@@ -37,6 +38,26 @@ > <input type="hidden" value="[% borrowernumber %]" name="borrowernumber" /> > </form> > [% END %] >+ [% IF validated_discharges %] >+ <h2>Already validated discharges</h2> >+ <table> >+ <thead> >+ <tr> >+ <th>Requested</th> >+ <th>Validated</th> >+ </tr> >+ </thead> >+ <tbody> >+ [% FOR d IN validated_discharges %] >+ <tr> >+ <td>[% d.needed | $KohaDates with_hours = 1 %]</td> >+ <td>[% d.validated | $KohaDates with_hours = 1 %]</td> >+ </tr> >+ [% END %] >+ </tbody> >+ </table> >+ [% END %] >+ > </div> > > >diff --git a/members/discharge.pl b/members/discharge.pl >index 7c73af9..8529527 100755 >--- a/members/discharge.pl >+++ b/members/discharge.pl >@@ -98,6 +98,11 @@ if ( $input->param('borrowernumber') ) { > } > } > >+ # Already generated discharges >+ my $validated_discharges = Koha::Borrower::Discharge::get_validated({ >+ branchcode => $data->{'branchcode'}, >+ }); >+ > $template->param( > borrowernumber => $borrowernumber, > biblionumber => $data->{'biblionumber'}, >@@ -120,6 +125,7 @@ if ( $input->param('borrowernumber') ) { > branchcode => $data->{'branchcode'}, > has_reserves => $has_reserves, > can_be_discharged => $can_be_discharged, >+ validated_discharges => $validated_discharges, > ); > } > >diff --git a/opac/opac-discharge.pl b/opac/opac-discharge.pl >index 5955a3e..b8d8a4f 100755 >--- a/opac/opac-discharge.pl >+++ b/opac/opac-discharge.pl >@@ -92,7 +92,7 @@ else { > validated => 1, > }); > $template->param( >- available => $available, >+ available => $available && Koha::Borrower::Discharge::is_discharged({borrowernumber => $loggedinuser}), > pending => $pending, > ); > } >diff --git a/t/db_dependent/Borrower_Discharge.t b/t/db_dependent/Borrower_Discharge.t >index b585db2..6a4b806 100644 >--- a/t/db_dependent/Borrower_Discharge.t >+++ b/t/db_dependent/Borrower_Discharge.t >@@ -49,6 +49,13 @@ is( Koha::Borrower::Discharge::can_be_discharged({ borrowernumber => $borrowernu > > is(Koha::Borrower::Discharge::generate_as_pdf,undef,"Confirm failure when lacking borrower number"); > >+# Verify that the user is not discharged anymore if the restriction has been lifted >+Koha::Borrower::Discharge::discharge({ borrowernumber => $borrowernumber }); >+is( Koha::Borrower::Discharge::is_discharged({ borrowernumber => $borrowernumber }), 1, 'The patron has been discharged' ); >+is(Koha::Borrower::Debarments::IsDebarred($borrowernumber), '9999-12-31', 'The patron has been debarred after discharge'); >+Koha::Borrower::Debarments::DelDebarment($borrowernumber); >+is( Koha::Borrower::Discharge::is_discharged({ borrowernumber => $borrowernumber }), 1, 'The patron is not discharged after the restriction has been lifted' ); >+ > # Check if PDF::FromHTML is installed. > my $check = eval { require PDF::FromHTML; }; > >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14368
:
40079
|
40171
|
40508
|
40512
|
42593
|
42598
|
42640
|
42670
|
42671
|
42672
|
42673
|
42720
|
42723
|
42930