Permalink
Browse files

Merge branch 'Bug4241' into ptfs-master

Conflicts:

	admin/systempreferences.pl
	members/pay.pl
  • Loading branch information...
J. David Bavousett
J. David Bavousett committed May 5, 2010
2 parents 65f3dd8 + 8bce938 commit 4ea3941c38a7dfa1f529f0574df998c4c4a1dc22
View
@@ -128,7 +128,7 @@ sub recordpayment {
);
$usth->execute( $borrowernumber, $nextaccntno, 0 - $data, 0 - $amountleft );
$usth->finish;
- UpdateStats( $branch, 'payment', $data, '', '', '', $borrowernumber, $nextaccntno );
+ C4::Stats::UpdateStats( $branch, 'payment', $data, '', '', '', $borrowernumber, $nextaccntno );
$sth->finish;
}
@@ -197,7 +197,7 @@ sub makepayment {
# FIXME - The second argument to &UpdateStats is supposed to be the
# branch code.
# UpdateStats is now being passed $accountno too. MTJ
- UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber,
+ C4::Stats::UpdateStats( $user, 'payment', $amount, '', '', '', $borrowernumber,
$accountno );
$sth->finish;
@@ -342,15 +342,15 @@ sub chargelostitem{
my $sth2=$dbh->prepare("INSERT INTO accountlines
(borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding,itemnumber)
VALUES (?,?,now(),?,?,'L',?,?)");
- $sth2->execute($issues->{'borrowernumber'},$accountno,$issues->{'replacementprice'},
+ $sth2->execute($issues->{'borrowernumber'},$accountno,$issues->{'replacementprice'} || 0,
"Lost Item $issues->{'title'} $issues->{'barcode'}",
- $issues->{'replacementprice'},$itemnumber);
+ $issues->{'replacementprice'} || 0,$itemnumber);
$sth2->finish;
# FIXME: Log this ?
}
#FIXME : Should probably have a way to distinguish this from an item that really was returned.
warn " $issues->{'borrowernumber'} / $itemnumber ";
- C4::Circulation::MarkIssueReturned($issues->{borrowernumber},$itemnumber);
+ C4::Circulation::MarkIssueReturned($issues->{borrowernumber},$itemnumber) if ( C4::Context->preference( 'MarkLostItemsReturned' ) );
# Shouldn't MarkIssueReturned do this?
ModItem({ onloan => undef }, undef, $itemnumber);
}
@@ -557,7 +557,7 @@ sub fixcredit {
}
$sth->finish;
$type = "Credit " . $type;
- UpdateStats( $user, $type, $data, $user, '', '', $borrowernumber );
+ C4::Stats::UpdateStats( $user, $type, $data, $user, '', '', $borrowernumber );
$amountleft *= -1;
return ($amountleft);
View
@@ -1019,6 +1019,7 @@ sub AddIssue {
ModItem({ issues => $item->{'issues'},
holdingbranch => C4::Context->userenv->{'branch'},
itemlost => 0,
+ paidfor => '',
datelastborrowed => C4::Dates->new()->output('iso'),
onloan => $datedue->output('iso'),
}, $item->{'biblionumber'}, $item->{'itemnumber'});
View
@@ -30,6 +30,7 @@ use C4::Log;
use C4::Branch;
require C4::Reserves;
use C4::Charset;
+use C4::Stats;
use vars qw($VERSION @ISA @EXPORT);
@@ -48,6 +49,7 @@ BEGIN {
ModItemFromMarc
ModItem
ModDateLastSeen
+ ModItemLost
ModItemTransfer
DelItem
@@ -576,6 +578,33 @@ sub ModDateLastSeen {
ModItem({ itemlost => 0, datelastseen => $today->output("iso") }, undef, $itemnumber);
}
+=head2 ModItemLost
+
+=over 4
+
+ModItemLost( $biblionumber, $itemnumber, $lostvalue );
+
+=back
+
+Changes itemlost for a given item. If $lostvalue > 0, then a log entry is made
+for that item.
+
+=cut
+
+sub ModItemLost {
+ my ( $biblionumber, $itemnumber, $lostvalue ) = @_;
+ my $dbh = C4::Context->dbh;
+ ModItem( { itemlost => $lostvalue }, $biblionumber, $itemnumber );
+ my $data = $dbh->selectrow_hashref( "
+ SELECT
+ items.replacementprice, issues.borrowernumber, items.itype
+ FROM items LEFT JOIN issues USING (itemnumber)
+ WHERE items.itemnumber = ?
+ ", {}, $itemnumber );
+ return unless ( $data->{'borrowernumber'} );
+ C4::Stats::UpdateStats( C4::Context->userenv->{'branch'}, 'itemlost', $data->{'replacementprice'} || 0, $lostvalue, $itemnumber, $data->{'itype'}, $data->{'borrowernumber'}, 0 ) if ( $lostvalue > 0 );
+}
+
=head2 DelItem
=over 4
View
@@ -28,6 +28,8 @@ use C4::Overdues;
use C4::Reserves;
use C4::Accounts;
use C4::Biblio;
+use C4::Items;
+use C4::Koha qw( GetAuthValCode );
our ($VERSION,@ISA,@EXPORT,@EXPORT_OK,$debug);
@@ -67,6 +69,7 @@ BEGIN {
&GetMemberAccountRecords
&GetBorNotifyAcctRecord
+ &GetLostStats
&GetborCatFromCatType
&GetBorrowercategory
@@ -1270,6 +1273,46 @@ sub GetBorNotifyAcctRecord {
return ( $total, \@acctlines, $numlines );
}
+sub GetLostStats {
+ my ( $borrowernumber, $hide_old ) = @_;
+ my $dbh = C4::Context->dbh;
+ my $category = GetAuthValCode( 'items.itemlost', '' );
+ my %summary;
+
+ my $lost_items = $dbh->selectall_arrayref( "
+ SELECT
+ authorised_values.lib as description, value, statistics.itemnumber,
+ items.itemnumber as item_exists, items.itemlost, items.paidfor
+ FROM statistics
+ LEFT JOIN items ON (statistics.itemnumber = items.itemnumber)
+ LEFT JOIN authorised_values ON (authorised_value = itemlost AND authorised_values.category = ?)
+ WHERE statistics.type = 'itemlost' AND statistics.borrowernumber = ?
+ GROUP BY statistics.itemnumber
+ ORDER BY authorised_values.lib
+ ", { Slice => {} }, $category, $borrowernumber );
+
+ foreach my $item ( @$lost_items ) {
+ next if ( $hide_old && ( !$item->{'item_exists'} || !$item->{'itemlost'} || $item->{'paidfor'} ) );
+ my $type_summary = ( $summary{$item->{'itemlost'}} ||= {
+ description => $item->{'description'},
+ items => [],
+ total_amount => 0,
+ } );
+
+ my $iteminfo = GetItem( $item->{'itemnumber'} );
+
+ push @{ $type_summary->{'items'} }, {
+ biblionumber => $iteminfo->{'biblionumber'},
+ itemnumber => $iteminfo->{'itemnumber'},
+ barcode => $iteminfo->{'barcode'},
+ };
+
+ $type_summary->{'total_amount'} += $item->{'value'};
+ }
+
+ return [ map { $_->{'total_amount'} = sprintf( '%0.2f', $_->{'total_amount'} ); $_ } values %summary ];
+}
+
=head2 checkuniquemember (OUEST-PROVENCE)
($result,$categorycode) = &checkuniquemember($collectivity,$surname,$firstname,$dateofbirth);
@@ -178,6 +178,7 @@ =head1 systempreferences.pl
$tabsysprefs{HoldButtonIgnore} = "Circulation";
$tabsysprefs{AllowDueDateInPast} = "Circulation";
$tabsysprefs{CircFinesBreakdown} = "Circulation";
+$tabsysprefs{MarkLostItemsReturned} = "Circulation";
# Staff Client
$tabsysprefs{TemplateEncoding} = "StaffClient";
View
@@ -53,15 +53,16 @@
$_ = 0;
}
}
-
+if ( $itemlost ne $item_data_hashref->{'itemlost'} ) {
+ ModItemLost( $biblionumber, $itemnumber, $itemlost );
+ C4::Accounts::chargelostitem( $itemnumber ) if ( $itemlost == 1 );
+}
# modify MARC item if input differs from items table.
my $item_changes = {};
if (defined $itemnotes) { # i.e., itemnotes parameter passed from form
if ((not defined $item_data_hashref->{'itemnotes'}) or $itemnotes ne $item_data_hashref->{'itemnotes'}) {
$item_changes->{'itemnotes'} = $itemnotes;
}
-} elsif ($itemlost ne $item_data_hashref->{'itemlost'}) {
- $item_changes->{'itemlost'} = $itemlost;
} elsif ($wthdrawn ne $item_data_hashref->{'wthdrawn'}) {
$item_changes->{'wthdrawn'} = $wthdrawn;
} elsif ($damaged ne $item_data_hashref->{'damaged'}) {
@@ -74,6 +75,4 @@
ModItem($item_changes, $biblionumber, $itemnumber);
-C4::Accounts::chargelostitem($itemnumber) if ($itemlost==1) ;
-
print $cgi->redirect("moredetail.pl?biblionumber=$biblionumber&itemnumber=$itemnumber#item$itemnumber");
@@ -218,6 +218,27 @@ if (nodename =="barcodes[]"){
</div>
+<!-- TMPL_IF NAME="lost_summary" -->
+<div class="rows" id="lost-summary" style="padding : .5em;">
+ <ol>
+ <!-- unless __last__ below intentionally duplicated, to prevent whitespace problems -->
+ <!-- TMPL_LOOP NAME="lost_summary" -->
+ <li>
+ <span class="label"><!-- TMPL_VAR NAME="description" -->:</span>
+ <!-- TMPL_LOOP NAME="items" -->
+ <!-- TMPL_IF NAME="itemnumber" -->
+ <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->"><!-- TMPL_VAR NAME="barcode" --></a><!-- TMPL_UNLESS NAME="__last__" -->,<!-- /TMPL_UNLESS -->
+ <!-- TMPL_ELSE -->
+ &lt;deleted item&gt;<!-- TMPL_UNLESS NAME="__last__" -->,<!-- /TMPL_UNLESS -->
+ <!-- /TMPL_IF -->
+ <!-- /TMPL_LOOP -->
+ (total: $<!-- TMPL_VAR NAME="total_amount" -->)
+ </li>
+ <!-- /TMPL_LOOP -->
+ </ol>
+</div>
+<!-- /TMPL_IF -->
+
<!-- Begin Upload Patron Image Section -->
<div id="manage-patron-image">
View
@@ -393,6 +393,8 @@ BEGIN
$template->param($data);
+$template->param( lost_summary => GetLostStats( $borrowernumber, 1 ) );
+
if (C4::Context->preference('ExtendedPatronAttributes')) {
$template->param(ExtendedPatronAttributes => 1);
$template->param(patron_attributes => C4::Members::Attributes::GetBorrowerAttributes($borrowernumber));
View
@@ -37,6 +37,8 @@ =head1 pay.pl
use C4::Koha;
use C4::Overdues;
use C4::Branch; # GetBranches
+use C4::Dates;
+use C4::Items qw( ModItem );
my $input = new CGI;
@@ -58,7 +60,7 @@ =head1 pay.pl
}
# get borrower details
-my $data = GetMember( $borrowernumber,'borrowernumber' );
+our $data = GetMember( $borrowernumber,'borrowernumber' );
my $user = $input->remote_user;
$user ||= q{};
@@ -92,10 +94,18 @@ =head1 pay.pl
if ( $temp eq 'yes' ) {
# FIXME : using array +4, +5, +6 is dirty. Should use arrays for each accountline
- my $amount = $input->param( $names[ $i + 4 ] ); # out
+ my $itemnumber = $input->param( $names[ $i + 1 ] );
+ my $accounttype = $input->param( $names[ $i + 2 ] );
+ my $amount = $input->param( $names[ $i + 4 ] );
my $borrowernumber = $input->param( $names[ $i + 5 ] );
my $accountno = $input->param( $names[ $i + 6 ] );
makepayment( $borrowernumber, $accountno, $amount, $user, $branch );
+
+ if ( $accounttype eq 'L' && $itemnumber ) {
+ my $bor = "$data->{'firstname'} $data->{'surname'} $data->{'cardnumber'}";
+ ModItem( { paidfor => "Paid for by $bor " . C4::Dates->today() }, undef, $itemnumber );
+ }
+
$check = 2;
}
}
@@ -340,5 +350,9 @@ sub writeoff {
$itemnum, $amount );
$sth->finish;
UpdateStats( $branch, 'writeoff', $amount, '', $itemnum, '', $borrowernumber, $accountnum );
- return;
+
+ if ( $accounttype eq 'L' && $itemnum ) {
+ my $bor = "$data->{'firstname'} $data->{'surname'} $data->{'cardnumber'}";
+ ModItem( { paidfor => "Paid for by $bor " . C4::Dates->today() }, undef, $itemnum );
+ }
}
@@ -153,7 +153,7 @@ sub longoverdue_sth {
while (my $row=$sth_items->fetchrow_hashref) {
printf ("Due %s: item %5s from borrower %5s to lost: %s\n", $row->{date_due}, $row->{itemnumber}, $row->{borrowernumber}, $lostvalue) if($verbose);
if($confirm) {
- ModItem({ itemlost => $lostvalue }, $row->{'biblionumber'}, $row->{'itemnumber'});
+ ModItemLost($row->{'biblionumber'}, $row->{'itemnumber'}, $lostvalue);
chargelostitem($row->{'itemnumber'}) if( $charge && $charge eq $lostvalue);
}
$count++;

0 comments on commit 4ea3941

Please sign in to comment.