[Koha-patches] [PATCH] Bug Fixing 2485
Joshua Ferraro
jmf at liblime.com
Fri Aug 8 21:38:14 CEST 2008
Hi Henri-Damien,
Thanks for your patch, however I'm rejecting for now because it doesn't
deal with all consequences of removing
$item->{'itemtype'}=$item->{'itype'} from CanBookBeIssued
Cheers,
Josh
On Thu, Aug 07, 2008 at 06:19:35PM +0200, Henri-Damien LAURENT wrote:
> Using Preference C4::Context->preference('item_level_itype') in order to determine itemtype information before passing it to statistics.
> ---
> C4/Circulation.pm | 73 +++++++++++++++++++++++++++++++---------------------
> 1 files changed, 43 insertions(+), 30 deletions(-)
>
> diff --git a/C4/Circulation.pm b/C4/Circulation.pm
> index ca52e27..24f28b0 100644
> --- a/C4/Circulation.pm
> +++ b/C4/Circulation.pm
> @@ -649,7 +649,9 @@ sub CanBookBeIssued {
> my $item = GetItem(GetItemnumberFromBarcode( $barcode ));
> my $issue = GetItemIssue($item->{itemnumber});
> my $biblioitem = GetBiblioItemData($item->{biblioitemnumber});
> - $item->{'itemtype'}=$item->{'itype'};
> + my $type = (C4::Context->preference('item-level_itypes'))
> + ? $item->{'itype'} # item-level
> + : $biblioitem->{'itemtype'}; # biblio-level
> my $dbh = C4::Context->dbh;
>
> #
> @@ -662,7 +664,7 @@ sub CanBookBeIssued {
> #
> if ( $borrower->{'category_type'} eq 'X' && ( $item->{barcode} )) {
> # stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 .
> - &UpdateStats(C4::Context->userenv->{'branch'},'localuse','','',$item->{'itemnumber'},$item->{'itemtype'},$borrower->{'borrowernumber'});
> + &UpdateStats(C4::Context->userenv->{'branch'},'localuse','','',$item->{'itemnumber'},$type,$borrower->{'borrowernumber'});
> return( { STATS => 1 }, {});
> }
> if ( $borrower->{flags}->{GNA} ) {
> @@ -847,30 +849,33 @@ AddIssue does the following things :
> sub AddIssue {
> my ( $borrower, $barcode, $date, $cancelreserve ) = @_;
> my $dbh = C4::Context->dbh;
> - my $barcodecheck=CheckValidBarcode($barcode);
> - if ($borrower and $barcode and $barcodecheck ne '0'){
> - # find which item we issue
> - my $item = GetItem('', $barcode) or return undef; # if we don't get an Item, abort.
> - my $datedue;
> - my $branch;
> - # Get which branchcode we need
> - if (C4::Context->preference('CircControl') eq 'PickupLibrary'){
> - $branch = C4::Context->userenv->{'branch'};
> - }
> - elsif (C4::Context->preference('CircControl') eq 'PatronLibrary'){
> - $branch = $borrower->{'branchcode'};
> - }
> - else {
> - # items home library
> - $branch = $item->{'homebranch'};
> - }
> -
> - # get actual issuing if there is one
> - my $actualissue = GetItemIssue( $item->{itemnumber});
> -
> - # get biblioinformation for this item
> - my $biblio = GetBiblioFromItemNumber($item->{itemnumber});
> -
> + my $barcodecheck=CheckValidBarcode($barcode);
> + if ($borrower and $barcode and $barcodecheck ne '0'){
> + # find which item we issue
> + my $item = GetItem('', $barcode) or return undef; # if we don't get an Item, abort.
> + my $datedue;
> + my $branch;
> + # Get which branchcode we need
> + if (C4::Context->preference('CircControl') eq 'PickupLibrary'){
> + $branch = C4::Context->userenv->{'branch'};
> + }
> + elsif (C4::Context->preference('CircControl') eq 'PatronLibrary'){
> + $branch = $borrower->{'branchcode'};
> + }
> + else {
> + # items home library
> + $branch = $item->{'homebranch'};
> + }
> +
> + # get actual issuing if there is one
> + my $actualissue = GetItemIssue( $item->{itemnumber});
> +
> + # get biblioinformation for this item
> + my $biblio = GetBiblioFromItemNumber($item->{itemnumber});
> + my $type = (C4::Context->preference('item-level_itypes'))
> + ? $item->{'itype'} # item-level
> + : $item->{'itemtype'}; # biblio-level
> +
> #
> # check if we just renew the issue.
> #
> @@ -1012,7 +1017,7 @@ sub AddIssue {
> C4::Context->userenv->{'branch'},
> 'issue', $charge,
> '', $item->{'itemnumber'},
> - $item->{'itype'}, $borrower->{'borrowernumber'}
> + $type, $borrower->{'borrowernumber'}
> );
> }
>
> @@ -1293,6 +1298,7 @@ sub AddReturn {
> # get information on item
> my $iteminformation = GetItemIssue( GetItemnumberFromBarcode($barcode));
> my $biblio = GetBiblioItemData($iteminformation->{'biblioitemnumber'});
> +
> # use Data::Dumper;warn Data::Dumper::Dumper($iteminformation);
> unless ($iteminformation->{'itemnumber'} ) {
> $messages->{'BadBarcode'} = $barcode;
> @@ -1336,7 +1342,7 @@ sub AddReturn {
>
> # case of a return of document (deal with issues and holdingbranch)
>
> - if ($doreturn) {
> + if ($doreturn) {
> my $circControlBranch;
> if($dropbox) {
> # don't allow dropbox mode to create an invalid entry in issues (issuedate > returndate) FIXME: actually checks eq, not gt
> @@ -1416,12 +1422,15 @@ sub AddReturn {
> $reserveDone = 1;
> }
>
> + my $type = (C4::Context->preference('item-level_itypes'))
> + ? $iteminformation->{'itype'} # item-level
> + : $biblio->{'itemtype'}; # biblio-level
> # update stats?
> # Record the fact that this book was returned.
> UpdateStats(
> $branch, 'return', '0', '',
> $iteminformation->{'itemnumber'},
> - $biblio->{'itemtype'},
> + $type,
> $borrower->{'borrowernumber'}
> );
>
> @@ -1976,8 +1985,12 @@ sub AddRenewal {
> 'Rent', $charge, $itemnumber );
> $sth->finish;
> }
> + my $itemtype = (C4::Context->preference('item-level_itypes'))
> + ? $item->{'itype'} # item-level
> + : $biblio->{'itemtype'}; # biblio-level
> +
> # Log the renewal
> - UpdateStats( $branch, 'renew', $charge, '', $itemnumber, $item->{itype}, $borrowernumber);
> + UpdateStats( $branch, 'renew', $charge, '', $itemnumber, $itemtype, $borrowernumber);
> }
>
> sub GetRenewCount {
> --
> 1.5.4.3
>
More information about the Koha-patches
mailing list