Skip to content
Browse files

Merge commit 'hall/1-3-Lost-Library-Card-Tracking' into Bug3469

Conflicts:

	koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tmpl
  • Loading branch information...
2 parents 9c54d01 + 2b4a8fe commit 4177aad16928145754c929dd834302dae2b614e3 J. David Bavousett committed Apr 2, 2010
View
21 C4/Members.pm
@@ -256,6 +256,20 @@ AND attribute like ?
$data = $sth->fetchall_arrayref({});
$sth->finish;
+
+ $query = "SELECT borrowers.*, categories.* FROM borrowers
+ LEFT JOIN categories ON borrowers.categorycode=categories.categorycode
+ LEFT JOIN statistics ON borrowers.borrowernumber = statistics.borrowernumber
+ WHERE statistics.type = 'card_replaced' AND statistics.other = ? GROUP BY statistics.other";
+ $sth = $dbh->prepare( $query );
+ $sth->execute( $searchstring );
+ my $prevcards_data = $sth->fetchall_arrayref({});
+ foreach my $row ( @$prevcards_data ) {
+ $row->{'PreviousCardnumber'} = 1;
+ }
+
+ $data = [ @$prevcards_data, @$data ];
+
return ( scalar(@$data), $data );
}
@@ -584,6 +598,13 @@ true on success, or false on failure
sub ModMember {
my (%data) = @_;
my $dbh = C4::Context->dbh;
+
+ my $member = GetMemberDetails( $data{'borrowernumber'} );
+
+ if ( $member->{'cardnumber'} ne $data{'cardnumber'} ) {
+ C4::Stats::UpdateStats( C4::Context->userenv->{branch}, 'card_replaced', '', $member->{'cardnumber'}, '', '', $data{'borrowernumber'} );
+ }
+
my $iso_re = C4::Dates->new()->regexp('iso');
foreach (qw(dateofbirth dateexpiry dateenrolled)) {
if (my $tempdate = $data{$_}) { # assignment, not comparison
View
20 C4/Stats.pm
@@ -118,6 +118,26 @@ sub TotalPaid {
return @{$sth->fetchall_arrayref({})};
}
+sub GetPreviousCardnumbers {
+ my ( $borrowernumber ) = @_;
+ my $dbh = C4::Context->dbh;
+
+ my $member = C4::Members::GetMember( $borrowernumber );
+ my $cardnumber = $member->{'cardnumber'};
+
+ my $query = "SELECT DISTINCT(other) AS previous_cardnumber, DATE_FORMAT( datetime, '%m/%e/%Y') as previous_cardnumber_date FROM statistics WHERE type = 'card_replaced' AND borrowernumber = ? AND other != ? AND other !='' ";
+ my $sth = $dbh->prepare( $query );
+ $sth->execute( $borrowernumber, $cardnumber );
+
+ my @results;
+ while ( my $data = $sth->fetchrow_hashref ) {
+ push( @results, $data );
+ }
+ $sth->finish;
+
+ return @results;
+}
+
1;
__END__
View
3 circ/circulation.pl
@@ -221,8 +221,9 @@
}
elsif ( $#borrowers == 0 ) {
$query->param( 'borrowernumber', $borrowers[0]->{'borrowernumber'} );
- $query->param( 'barcode', '' );
+ $query->param( 'barcode', '' );
$borrowernumber = $borrowers[0]->{'borrowernumber'};
+ $template->param( PreviousCardnumber => $borrowers[0]->{'PreviousCardnumber'} );
}
else {
$borrowerslist = \@borrowers;
View
1 koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tmpl
@@ -395,6 +395,7 @@ No patron matched <span class="ex"><!-- TMPL_VAR name="message" --></span>
<!-- /TMPL_IF -->
<label for="barcode">Checking out to <!-- TMPL_VAR name="firstname" --> <!-- TMPL_VAR name="surname" --> (<!-- TMPL_VAR NAME="cardnumber" -->) </label>
+ <!-- TMPL_IF NAME="PreviousCardnumber" --><div><span class="circ-hlt">Warning: Scanned Old Card</span></div><!-- /TMPL_IF -->
<div class="hint">Enter item barcode:</div>
<input type="text" name="barcode" id="barcode" class="barcode focus" size="14" /> <input type="submit" value="Check Out" />
View
5 koha-tmpl/intranet-tmpl/prog/en/modules/members/member.tmpl
@@ -74,7 +74,10 @@
<tr>
<!-- /TMPL_UNLESS -->
<!-- /TMPL_IF -->
- <td><!-- TMPL_VAR NAME="cardnumber" --></td>
+ <td>
+ <!-- TMPL_VAR NAME="cardnumber" -->
+ <!-- TMPL_IF NAME="PreviousCardnumber" --><p class="overdue">Warning: Found With Previous Cardnumber</p><!-- /TMPL_IF -->
+ </td>
<td style="white-space: nowrap;"><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->"><!-- TMPL_VAR NAME="surname" -->, <!-- TMPL_VAR NAME="firstname" --></a> <br /> <!-- TMPL_VAR NAME="address" --><!-- TMPL_IF NAME="address2" --><br /><!-- TMPL_VAR NAME="address2" --><!-- /TMPL_IF --><!-- TMPL_IF NAME="city" --><br /><!-- TMPL_VAR NAME=city --><!-- /TMPL_IF --><!-- TMPL_IF NAME="zipcode" --> <!-- TMPL_VAR NAME="zipcode" --><!-- /TMPL_IF --><!-- TMPL_IF NAME="country" -->, <!-- TMPL_VAR NAME="country" --><!-- /TMPL_IF --></td>
<td><!-- TMPL_VAR NAME="category_description" --> (<!-- TMPL_VAR name="category_type" -->)</td>
<td><!-- TMPL_VAR NAME="branchcode" --></td>
View
23 koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tmpl
@@ -331,6 +331,27 @@ if (nodename =="barcodes[]"){
</div>
<div class="action"><a href="memberentry.pl?op=modify&amp;borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->&amp;step=3">Edit</a></div>
+ <!-- TMPL_IF NAME="previousCardnumbersLoop" -->
+ <div id="previouscardnumbers" >
+ <h3>Previous Cardnumbers</h3>
+ <ul>
+ <form method="post" action="restore_cardnumber.pl">
+ <table border="0"><tr><td>
+ <select name="previous_cardnumber" id="previous_cardnumber" size="<!-- TMPL_VAR NAME="previousCardnumbersCount" -->">
+ <!-- TMPL_LOOP NAME="previousCardnumbersLoop" -->
+ <!--TMPL_IF NAME="previous_cardnumber" -->
+ <option value="<!-- TMPL_VAR NAME="previous_cardnumber" -->"><!-- TMPL_VAR NAME="previous_cardnumber" --> : <!-- TMPL_VAR NAME="previous_cardnumber_date" --></option>
+ <!-- /TMPL_IF -->
+ <!-- /TMPL_LOOP -->
+ </select></td>
+ <input type="hidden" name="borrowernumber" id="borrowernumber" value="<!-- TMPL_VAR NAME="borrowernumber" -->" />
+ <td><input type="submit" value="Restore" /></td>
+ </table>
+ </form>
+ </ul>
+ </div>
+<!-- /TMPL_IF -->
+
<div id="patron-alternate-address" style="padding-top: 1em;">
<h3>Alternate Address</h3>
<!-- TMPL_UNLESS NAME="I"--><!-- TMPL_UNLESS NAME="C"-->
@@ -363,6 +384,7 @@ if (nodename =="barcodes[]"){
</div>
<div class="action"><a href="memberentry.pl?op=modify&amp;borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->&amp;step=2">Edit</a></div>
+
</div>
</div>
@@ -385,6 +407,7 @@ if (nodename =="barcodes[]"){
<!-- /TMPL_IF -->
</div>
+
<div id="checkedout">
<!-- TMPL_IF NAME="issueloop" -->
<form action="/cgi-bin/koha/reserve/renewscript.pl" method="post" class="checkboxed">
View
1 members/member.pl
@@ -100,6 +100,7 @@
count => $i+1,
borrowernumber => $results->[$i]{'borrowernumber'},
cardnumber => $results->[$i]{'cardnumber'},
+ PreviousCardnumber => $results->[$i]{'PreviousCardnumber'},
surname => $results->[$i]{'surname'},
firstname => $results->[$i]{'firstname'},
categorycode => $results->[$i]{'categorycode'},
View
11 members/moremember.pl
@@ -50,7 +50,7 @@ =head1 moremember.pl
use C4::Form::MessagingPreferences;
#use Smart::Comments;
-#use Data::Dumper;
+use Data::Dumper;
use vars qw($debug);
@@ -405,6 +405,15 @@ BEGIN
$template->param(SMSnumber => defined $data->{'smsalertnumber'} ? $data->{'smsalertnumber'} : $data->{'mobile'});
}
+my @previousCardnumbers = C4::Stats::GetPreviousCardnumbers( $borrowernumber );
+
+if ( @previousCardnumbers ) {
+ $template->param(
+ previousCardnumbersLoop => \@previousCardnumbers,
+ previousCardnumbersCount => scalar( @previousCardnumbers )
+ );
+}
+
$template->param(
detailview => 1,
AllowRenewalLimitOverride => C4::Context->preference("AllowRenewalLimitOverride"),
View
50 members/restore_cardnumber.pl
@@ -0,0 +1,50 @@
+#!/usr/bin/perl
+
+#script to delete items
+#written 2/5/00
+#by chris@katipo.co.nz
+
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
+use strict;
+
+use CGI;
+use C4::Context;
+use C4::Output;
+use C4::Auth;
+use C4::Members;
+
+my $input = new CGI;
+
+my ($template, $borrowernumber, $cookie)
+ = get_template_and_user({template_name => "members/deletemem.tmpl",
+ query => $input,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => {borrowers => 1},
+ debug => 1,
+ });
+
+my $borrowernumber = $input->param('borrowernumber');
+my $previous_cardnumber = $input->param('previous_cardnumber');
+
+ModMember( borrowernumber => $borrowernumber, cardnumber => $previous_cardnumber );
+
+print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber");
+
+

0 comments on commit 4177aad

Please sign in to comment.
Something went wrong with that request. Please try again.