[Koha-patches] [PATCH] Placed a Revision History tab on the moremember.tmpl

Galen Charlton gmcharlt at gmail.com
Tue Jul 28 03:34:58 CEST 2009


Hi,

There are some problems with this patch:

[1] If CataloguingLog is turned on, any actions on a bib or item
record sharing the same ID number as the patron will also be
displayed.

[2] Similarly, if SubscriptionLog is turned on, action history for
serials will get mixed in.  The query in GetMemberRevisions needs to
limit itself to action_logs.module values that refer to
borrowernumbers.

[3] The action_logs.object column that the query in GetMemberRevisions
depends on is not indexed, meaning that getting the patron revision
history will become an increasingly expensive operation.

I will be establishing a wip-ptfs-pending branch in my RM repository,
where this patch will sent until a followup patch or a replacement
patch that addresses the first two problems (at least) is ready.
Also, please see bug 3445.

Regards,

Galen

On Fri, Jul 24, 2009 at 6:37 PM, Colin
Campbell<colin.campbell at ptfs-europe.com> wrote:
> From: David Birmingham <dbirmingham at ptfs.com>
>
> The moremember.tmpl had additional patron info at the
> bottom of the page such as "Checked out" and "On Holds".
> I added a "Revision History" tab that shows brief info
> about the librarian who added or modified the patron record,
> what he or she did, and when it happened.
>
> Sponsored by East Brunswick Public Library, East Brunswick, NJ USA
>
> Signed-off-by: J. David Bavousett <dbavousett at ptfs.com>
> Signed-off-by: Colin Campbell <colin.campbell at ptfs-europe.com>
> ---
>  C4/Members.pm                                      |   45 ++++++++++++++++++--
>  .../prog/en/modules/members/moremember.tmpl        |   24 ++++++++++
>  members/moremember.pl                              |   13 ++++++
>  3 files changed, 78 insertions(+), 4 deletions(-)
>
> diff --git a/C4/Members.pm b/C4/Members.pm
> index b2ce916..1a13c67 100644
> --- a/C4/Members.pm
> +++ b/C4/Members.pm
> @@ -59,22 +59,24 @@ BEGIN {
>                &GetSortDetails
>                &GetTitles
>
> -    &GetPatronImage
> -    &PutPatronImage
> -    &RmPatronImage
> +               &GetPatronImage
> +               &PutPatronImage
> +               &RmPatronImage
>
>                &GetMemberAccountRecords
>                &GetBorNotifyAcctRecord
>
>                &GetborCatFromCatType
>                &GetBorrowercategory
> -    &GetBorrowercategoryList
> +               &GetBorrowercategoryList
>
>                &GetBorrowersWhoHaveNotBorrowedSince
>                &GetBorrowersWhoHaveNeverBorrowed
>                &GetBorrowersWithIssuesHistoryOlderThan
>
>                &GetExpiryDate
> +
> +                &GetMemberRevisions
>        );
>
>        #Modify data
> @@ -1298,6 +1300,41 @@ sub GetExpiryDate {
>     return sprintf("%04d-%02d-%02d", Add_Delta_YM(@date,0,$enrolmentperiod));
>  }
>
> +=head2 GetMemberRevisions
> +
> +=over 4
> +
> +$revisions = &GetMemberRevisions($borrowernumber);
> +
> +Looks up addition/modification occurences of a patron's
> +account by library staff via the action_logs table.
> +Uses patron's borrowernumber for database selection.
> +
> +&GetMemberRevisions returns a reference-to array where each element
> +is a reference-to-hash whose keys are the fields of the action_logs
> +table.
> +
> +=cut
> +
> +#'
> +sub GetMemberRevisions {
> +
> +    my ($borrowernumber) = @_;
> +    my $dbh = C4::Context->dbh;
> +    my $sth;
> +    my $select = "
> +    SELECT *
> +      FROM action_logs
> +      WHERE object=?
> +    ";
> +    $sth = $dbh->prepare($select);
> +    $sth->execute($borrowernumber);
> +    my $data = $sth->fetchall_arrayref({});
> +    ($data) and return ($data);
> +
> +    return undef;
> +}
> +
>  =head2 checkuserpassword (OUEST-PROVENCE)
>
>  check for the password and login are not used
> diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl
> index d3deaf9..1b0a169 100644
> --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl
> +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl
> @@ -366,6 +366,7 @@ if (nodename =="barcodes[]"){
>                <li><a href="#checkedout">Checked Out</a></li>
>                <li><a href="#finesandcharges">Fines &amp; Charges</a></li>
>                <li><a href="#onhold">On Hold</a></li>
> +               <li><a href="#revisionhistory">Revision History</a></li>
>        </ul>
>
>  <div id="finesandcharges">
> @@ -377,6 +378,29 @@ if (nodename =="barcodes[]"){
>     <!-- /TMPL_IF -->
>  </div>
>
> +<div id="revisionhistory">
> +    <h2>Revision History</h2>
> +    <!-- TMPL_IF NAME="revisionloop" -->
> +      <table id="revisionst">
> +        <thead><tr>
> +          <th>Staff</th>
> +          <th>Action</th>
> +          <th>Date/Time</th>
> +        </tr></thead>
> +        <tbody><!-- TMPL_LOOP NAME="revisionloop" -->
> +          <tr>
> +          <td><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="staffnumber" -->" title="display detail for this librarian.">
> +          <!-- TMPL_VAR NAME="staffnumber" --> </a></td>
> +          <td><!-- TMPL_VAR NAME="staffaction" --></td>
> +          <td><!-- TMPL_VAR NAME="timestamp" --></td>
> +          </tr>
> +        <!-- /TMPL_LOOP --></tbody>
> +      </table>
> +    <!-- TMPL_ELSE -->
> +      <p>Patron has no revisions.</p>
> +    <!-- /TMPL_IF -->
> +</div>
> +
>  <div id="checkedout">
>     <h2>Checked Out</h2>
>     <!-- TMPL_IF NAME="issueloop" -->
> diff --git a/members/moremember.pl b/members/moremember.pl
> index 494121f..dd7c9fe 100755
> --- a/members/moremember.pl
> +++ b/members/moremember.pl
> @@ -319,6 +319,19 @@ if ($borrowernumber) {
>     $template->param( reservloop => \@reservloop );
>  }
>
> +# extract staff activity on patron record
> +my $revisions = &GetMemberRevisions($borrowernumber);
> +my $revision_count = scalar(@$revisions);
> +my @revisiondata;
> +for ( my $i = 0; $i < $revision_count; $i++) {
> +  my %row = %{ $revisions->[$i] };
> +  $row{'staffnumber'} = $revisions->[$i]{'user'};
> +  $row{'staffaction'} = $revisions->[$i]{'action'};
> +  $row{'timestamp'} = $revisions->[$i]{'timestamp'};
> +  push( @revisiondata, \%row );
> +}
> +$template->param( revisionloop => \@revisiondata );
> +
>  # current alert subscriptions
>  my $alerts = getalert($borrowernumber);
>  foreach (@$alerts) {
> --
> 1.6.2.5
>
> _______________________________________________
> Koha-patches mailing list
> Koha-patches at lists.koha.org
> http://lists.koha.org/mailman/listinfo/koha-patches
>



More information about the Koha-patches mailing list