[Koha-patches] [PATCH] Remove item-level_itype logic.
Ryan Higgins
rch at liblime.com
Sat Dec 13 02:21:05 CET 2008
This patch removes all occurrences of item-level_itype syspref.
All circ rules should now be based on items.itemtype (db revision in previous patch).
---
C4/Auth.pm | 1 -
C4/Biblio.pm | 21 +---
C4/Bookfund.pm | 2 +-
C4/Circulation.pm | 111 +++++++-------------
C4/Items.pm | 31 ++----
C4/Labels.pm | 6 +-
C4/Overdues.pm | 20 +---
C4/Reports/Guided.pm | 14 +--
C4/Reserves.pm | 24 +---
C4/Search.pm | 20 ++--
.../opac-tmpl/prog/en/modules/opac-detail.tmpl | 2 +-
11 files changed, 80 insertions(+), 172 deletions(-)
diff --git a/C4/Auth.pm b/C4/Auth.pm
index 871929e..63988fd 100644
--- a/C4/Auth.pm
+++ b/C4/Auth.pm
@@ -266,7 +266,6 @@ sub get_template_and_user {
TagsEnabled => C4::Context->preference("TagsEnabled"),
hide_marc => C4::Context->preference("hide_marc"),
dateformat => C4::Context->preference("dateformat"),
- 'item-level_itypes' => C4::Context->preference('item-level_itypes'),
patronimages => C4::Context->preference("patronimages"),
singleBranchMode => C4::Context->preference("singleBranchMode"),
);
diff --git a/C4/Biblio.pm b/C4/Biblio.pm
index e50532c..9dab920 100755
--- a/C4/Biblio.pm
+++ b/C4/Biblio.pm
@@ -494,19 +494,10 @@ the first one is considered.
sub GetBiblioData {
my ( $bibnum ) = @_;
my $dbh = C4::Context->dbh;
-
- # my $query = C4::Context->preference('item-level_itypes') ?
- # " SELECT * , biblioitems.notes AS bnotes, biblio.notes
- # FROM biblio
- # LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber
- # WHERE biblio.biblionumber = ?
- # AND biblioitems.biblionumber = biblio.biblionumber
- #";
- my $query = " SELECT * , biblioitems.notes AS bnotes, itemtypes.notforloan as bi_notforloan, biblio.notes
+ my $query = " SELECT * , biblioitems.notes AS bnotes, biblio.notes
FROM biblio
LEFT JOIN biblioitems ON biblio.biblionumber = biblioitems.biblionumber
- LEFT JOIN itemtypes ON biblioitems.itemtype = itemtypes.itemtype
WHERE biblio.biblionumber = ?
AND biblioitems.biblionumber = biblio.biblionumber ";
@@ -527,8 +518,7 @@ $itemdata = &GetBiblioItemData($biblioitemnumber);
Looks up the biblioitem with the given biblioitemnumber. Returns a
reference-to-hash. The keys are the fields from the C<biblio>,
-C<biblioitems>, and C<itemtypes> tables in the Koha database, except
-that C<biblioitems.notes> is given as C<$itemdata-E<gt>{bnotes}>.
+C<biblioitems> tables in the Koha database.
=back
@@ -539,11 +529,8 @@ sub GetBiblioItemData {
my ($biblioitemnumber) = @_;
my $dbh = C4::Context->dbh;
my $query = "SELECT *,biblioitems.notes AS bnotes
- FROM biblio LEFT JOIN biblioitems on biblio.biblionumber=biblioitems.biblionumber ";
- unless(C4::Context->preference('item-level_itypes')) {
- $query .= "LEFT JOIN itemtypes on biblioitems.itemtype=itemtypes.itemtype ";
- }
- $query .= " WHERE biblioitemnumber = ? ";
+ FROM biblio LEFT JOIN biblioitems on biblio.biblionumber=biblioitems.biblionumber
+ WHERE biblioitemnumber = ? ";
my $sth = $dbh->prepare($query);
my $data;
$sth->execute($biblioitemnumber);
diff --git a/C4/Bookfund.pm b/C4/Bookfund.pm
index 7c00067..0825b6c 100644
--- a/C4/Bookfund.pm
+++ b/C4/Bookfund.pm
@@ -252,7 +252,7 @@ sub GetBookFundBreakdown {
$query = "
SELECT quantity,datereceived,freight,unitprice,
listprice,ecost,quantityreceived AS qrev,
- subscription,title,itemtype,aqorders.biblionumber,
+ subscription,title,aqorders.biblionumber,
aqorders.booksellerinvoicenumber,
quantity-quantityreceived AS tleft,
aqorders.ordernumber AS ordnum,entrydate,budgetdate
diff --git a/C4/Circulation.pm b/C4/Circulation.pm
index 455a90d..db56137 100644
--- a/C4/Circulation.pm
+++ b/C4/Circulation.pm
@@ -326,13 +326,10 @@ sub TooMany {
# items home library
$branch = $item->{'homebranch'};
}
- my $type = (C4::Context->preference('item-level_itypes'))
- ? $item->{'itype'} # item-level
- : $item->{'itemtype'}; # biblio-level
# given branch, patron category, and item type, determine
# applicable issuing rule
- my $issuing_rule = GetIssuingRule($cat_borrower, $type, $branch);
+ my $issuing_rule = GetIssuingRule($cat_borrower, $item->{'itemtype'}, $branch);
# if a rule is found and has a loan limit set, count
# how many loans the patron already has that meet that
@@ -347,35 +344,20 @@ sub TooMany {
# matching rule has the default item type, so count only
# those existing loans that don't fall under a more
# specific rule
- if (C4::Context->preference('item-level_itypes')) {
- $count_query .= " WHERE items.itype NOT IN (
- SELECT itemtype FROM issuingrules
- WHERE branchcode = ?
- AND (categorycode = ? OR categorycode = ?)
- AND itemtype <> '*'
- ) ";
- } else {
- $count_query .= " JOIN biblioitems USING (biblionumber)
- WHERE biblioitems.itemtype NOT IN (
- SELECT itemtype FROM issuingrules
- WHERE branchcode = ?
- AND (categorycode = ? OR categorycode = ?)
- AND itemtype <> '*'
- ) ";
- }
+ $count_query .= " WHERE items.itemtype NOT IN (
+ SELECT itemtype FROM issuingrules
+ WHERE branchcode = ?
+ AND (categorycode = ? OR categorycode = ?)
+ AND itemtype <> '*'
+ ) ";
push @bind_params, $issuing_rule->{branchcode};
push @bind_params, $issuing_rule->{categorycode};
push @bind_params, $cat_borrower;
} else {
# rule has specific item type, so count loans of that
# specific item type
- if (C4::Context->preference('item-level_itypes')) {
- $count_query .= " WHERE items.itype = ? ";
- } else {
- $count_query .= " JOIN biblioitems USING (biblionumber)
- WHERE biblioitems.itemtype= ? ";
- }
- push @bind_params, $type;
+ $count_query .= " WHERE items.itemtype = ? ";
+ push @bind_params, $item->{'itemtype'};
}
$count_query .= " AND borrowernumber = ? ";
@@ -643,7 +625,6 @@ sub CanBookBeIssued {
my $item = GetItem(GetItemnumberFromBarcode( $barcode ));
my $issue = GetItemIssue($item->{itemnumber});
my $biblioitem = GetBiblioItemData($item->{biblioitemnumber});
- $item->{'itemtype'}=$item->{'itype'};
my $dbh = C4::Context->dbh;
#
@@ -718,17 +699,12 @@ sub CanBookBeIssued {
}
elsif ( !$item->{'notforloan'} ){
# we have to check itemtypes.notforloan also
- if (C4::Context->preference('item-level_itypes')){
- # this should probably be a subroutine
- my $sth = $dbh->prepare("SELECT notforloan FROM itemtypes WHERE itemtype = ?");
- $sth->execute($item->{'itemtype'});
- my $notforloan=$sth->fetchrow_hashref();
- $sth->finish();
- if ($notforloan->{'notforloan'} == 1){
- $issuingimpossible{NOT_FOR_LOAN} = 1;
- }
- }
- elsif ($biblioitem->{'notforloan'} == 1){
+ # this should probably be a subroutine
+ my $sth = $dbh->prepare("SELECT notforloan FROM itemtypes WHERE itemtype = ?");
+ $sth->execute($item->{'itemtype'});
+ my ($notforloan)=$sth->fetchrow_array();
+ $sth->finish();
+ if ($notforloan){
$issuingimpossible{NOT_FOR_LOAN} = 1;
}
}
@@ -961,8 +937,7 @@ sub AddIssue {
VALUES (?,?,?,?,?)"
);
unless ($datedue) {
- my $itype = ( C4::Context->preference('item-level_itypes') ) ? $biblio->{'itype'} : $biblio->{'itemtype'};
- my $loanlength = GetLoanLength( $borrower->{'categorycode'}, $itype, $branch );
+ my $loanlength = GetLoanLength( $borrower->{'categorycode'}, $item->{'itemtype'}, $branch );
$datedue = CalcDateDue( C4::Dates->new( $issuedate, 'iso' ), $loanlength, $branch );
# if ReturnBeforeExpiry ON the datedue can't be after borrower expirydate
@@ -1005,7 +980,7 @@ sub AddIssue {
C4::Context->userenv->{'branch'},
'issue', $charge,
'', $item->{'itemnumber'},
- $item->{'itype'}, $borrower->{'borrowernumber'}
+ $item->{'itemtype'}, $borrower->{'borrowernumber'}
);
}
@@ -1318,19 +1293,19 @@ sub AddReturn {
if ( $hbr && $branches->{$hbr}->{'PE'} ) {
$messages->{'IsPermanent'} = $hbr;
}
-
+
# if independent branches are on and returning to different branch, refuse the return
if ($hbr ne C4::Context->userenv->{'branch'} && C4::Context->preference("IndependantBranches")){
$messages->{'Wrongbranch'} = 1;
$doreturn=0;
}
-
+
# check that the book has been cancelled
if ( $iteminformation->{'wthdrawn'} ) {
$messages->{'wthdrawn'} = 1;
$doreturn = 0;
}
-
+
# new op dev : if the book returned in an other branch update the holding branch
# update issues, thereby returning book (should push this out into another subroutine
@@ -1360,13 +1335,13 @@ sub AddReturn {
# the holdingbranch is updated if the document is returned in an other location .
if ( $iteminformation->{'holdingbranch'} ne C4::Context->userenv->{'branch'} ) {
- UpdateHoldingbranch(C4::Context->userenv->{'branch'},$iteminformation->{'itemnumber'});
+ UpdateHoldingbranch(C4::Context->userenv->{'branch'},$iteminformation->{'itemnumber'});
# reload iteminformation holdingbranch with the userenv value
$iteminformation->{'holdingbranch'} = C4::Context->userenv->{'branch'};
}
ModDateLastSeen( $iteminformation->{'itemnumber'} );
ModItem({ onloan => undef }, $biblio->{'biblionumber'}, $iteminformation->{'itemnumber'});
-
+
if ($iteminformation->{borrowernumber}){
($borrower) = C4::Members::GetMemberDetails( $iteminformation->{borrowernumber}, 0 );
}
@@ -1423,7 +1398,7 @@ sub AddReturn {
UpdateStats(
$branch, 'return', '0', '',
$iteminformation->{'itemnumber'},
- $biblio->{'itemtype'},
+ $iteminformation->{'itemtype'},
$borrower->{'borrowernumber'}
);
@@ -1837,7 +1812,7 @@ sub GetUpcomingDueIssues {
my $dbh = C4::Context->dbh;
my $statement = <<END_SQL;
-SELECT issues.*, items.itype as itemtype, items.homebranch, TO_DAYS( date_due )-TO_DAYS( NOW() ) as days_until_due
+SELECT issues.*, items.itemtype as itemtype, items.homebranch, TO_DAYS( date_due )-TO_DAYS( NOW() ) as days_until_due
FROM issues
LEFT JOIN items USING (itemnumber)
WhERE returndate is NULL
@@ -1905,12 +1880,9 @@ sub CanBookBeRenewed {
# because it's a bit messy: given the item number, we need to find
# the biblioitem, which gives us the itemtype, which tells us
# whether it may be renewed.
- my $query = "SELECT renewalsallowed FROM items ";
- $query .= (C4::Context->preference('item-level_itypes'))
- ? "LEFT JOIN itemtypes ON items.itype = itemtypes.itemtype "
- : "LEFT JOIN biblioitems on items.biblioitemnumber = biblioitems.biblioitemnumber
- LEFT JOIN itemtypes ON biblioitems.itemtype = itemtypes.itemtype ";
- $query .= "WHERE items.itemnumber = ?";
+ my $query = "SELECT renewalsallowed FROM items
+ LEFT JOIN itemtypes ON items.itemtype = itemtypes.itemtype
+ WHERE items.itemnumber = ?";
my $sth2 = $dbh->prepare($query);
$sth2->execute($itemnumber);
if ( my $data2 = $sth2->fetchrow_hashref ) {
@@ -1971,11 +1943,8 @@ sub AddRenewal {
unless ($datedue && $datedue->output('iso')) {
my $borrower = C4::Members::GetMemberDetails( $borrowernumber, 0 ) or return undef;
- my $loanlength = GetLoanLength(
- $borrower->{'categorycode'},
- (C4::Context->preference('item-level_itypes')) ? $biblio->{'itype'} : $biblio->{'itemtype'} ,
- $item->{homebranch} # item's homebranch determines loanlength OR do we want the branch specified by the AddRenewal argument?
- );
+ my $loanlength = GetLoanLength( $borrower->{'categorycode'}, $item->{'itemtype'},$item->{homebranch});
+ # item's homebranch determines loanlength OR do we want the branch specified by the AddRenewal argument?
#FIXME -- use circControl?
$datedue = CalcDateDue(C4::Dates->new(),$loanlength,$branch); # this branch is the transactional branch.
# The question of whether to use item's homebranch calendar is open.
@@ -2031,7 +2000,7 @@ sub AddRenewal {
$sth->finish;
}
# Log the renewal
- UpdateStats( $branch, 'renew', $charge, '', $itemnumber, $item->{itype}, $borrowernumber);
+ UpdateStats( $branch, 'renew', $charge, '', $itemnumber, $item->{'itemtype'}, $borrowernumber);
return $datedue;
}
@@ -2053,12 +2022,9 @@ sub GetRenewCount {
my $data = $sth->fetchrow_hashref;
$renewcount = $data->{'renewals'} if $data->{'renewals'};
$sth->finish;
- my $query = "SELECT renewalsallowed FROM items ";
- $query .= (C4::Context->preference('item-level_itypes'))
- ? "LEFT JOIN itemtypes ON items.itype = itemtypes.itemtype "
- : "LEFT JOIN biblioitems on items.biblioitemnumber = biblioitems.biblioitemnumber
- LEFT JOIN itemtypes ON biblioitems.itemtype = itemtypes.itemtype ";
- $query .= "WHERE items.itemnumber = ?";
+ my $query = "SELECT renewalsallowed FROM items
+ LEFT JOIN itemtypes ON items.itemtype = itemtypes.itemtype
+ WHERE items.itemnumber = ?";
my $sth2 = $dbh->prepare($query);
$sth2->execute($itemno);
my $data2 = $sth2->fetchrow_hashref();
@@ -2093,13 +2059,9 @@ sub GetIssuingCharges {
my $item_type;
# Get the book's item type and rental charge (via its biblioitem).
- my $qcharge = "SELECT itemtypes.itemtype,rentalcharge FROM items
- LEFT JOIN biblioitems ON biblioitems.biblioitemnumber = items.biblioitemnumber";
- $qcharge .= (C4::Context->preference('item-level_itypes'))
- ? " LEFT JOIN itemtypes ON items.itype = itemtypes.itemtype "
- : " LEFT JOIN itemtypes ON biblioitems.itemtype = itemtypes.itemtype ";
-
- $qcharge .= "WHERE items.itemnumber =?";
+ my $qcharge = "SELECT itemtypes.itemtype,rentalcharge FROM items
+ LEFT JOIN itemtypes ON items.itemtype = itemtypes.itemtype
+ WHERE items.itemnumber =?";
my $sth1 = $dbh->prepare($qcharge);
$sth1->execute($itemnumber);
@@ -2117,6 +2079,7 @@ sub GetIssuingCharges {
if ( $discount eq 'NULL' ) {
$discount = 0;
}
+ # FIXME: rentaldiscount is not exposed to interface and is undocumented.
$charge = ( $charge * ( 100 - $discount ) ) / 100;
}
$sth2->finish;
diff --git a/C4/Items.pm b/C4/Items.pm
index 3aef697..b5207e4 100644
--- a/C4/Items.pm
+++ b/C4/Items.pm
@@ -144,12 +144,6 @@ sub GetItem {
($data->{'serialseq'} , $data->{'publisheddate'}) = $ssth->fetchrow_array();
warn $data->{'serialseq'} , $data->{'publisheddate'};
}
- #if we don't have an items.itype, use biblioitems.itemtype.
- if( ! $data->{'itype'} ) {
- my $sth = $dbh->prepare("SELECT itemtype FROM biblioitems WHERE biblionumber = ?");
- $sth->execute($data->{'biblionumber'});
- ($data->{'itype'}) = $sth->fetchrow_array;
- }
return $data;
} # sub GetItem
@@ -385,7 +379,7 @@ my %default_values_for_mod_from_marc = (
itemcallnumber => undef,
itemlost => 0,
itemnotes => undef,
- itype => undef,
+ itemtype => undef,
location => undef,
materials => undef,
notforloan => 0,
@@ -1006,7 +1000,7 @@ END_SQL
}
if ( $itemtype ) {
- $query.= ' AND biblioitems.itemtype = ? ';
+ $query.= ' AND items.itemtype = ? ';
push @bind_params, $itemtype;
}
@@ -1184,14 +1178,12 @@ If this is set, it is set to C<One Order>.
sub GetItemsInfo {
my ( $biblionumber, $type ) = @_;
my $dbh = C4::Context->dbh;
- my $query = "SELECT items.*,biblio.*,biblioitems.volume,biblioitems.number,biblioitems.itemtype,biblioitems.isbn,biblioitems.issn,biblioitems.publicationyear,biblioitems.publishercode,biblioitems.volumedate,biblioitems.volumedesc,biblioitems.lccn,biblioitems.url,items.notforloan as itemnotforloan
- FROM items
- LEFT JOIN biblio ON biblio.biblionumber = items.biblionumber
- LEFT JOIN biblioitems ON biblioitems.biblioitemnumber = items.biblioitemnumber";
- $query .= (C4::Context->preference('item-level_itypes')) ?
- " LEFT JOIN itemtypes on items.itype = itemtypes.itemtype "
- : " LEFT JOIN itemtypes on biblioitems.itemtype = itemtypes.itemtype ";
- $query .= "WHERE items.biblionumber = ? ORDER BY items.dateaccessioned desc" ;
+ my $query = "SELECT items.*,biblio.*,biblioitems.volume,biblioitems.number,biblioitems.isbn,biblioitems.issn,biblioitems.publicationyear,biblioitems.publishercode,biblioitems.volumedate,biblioitems.volumedesc,biblioitems.lccn,biblioitems.url,items.notforloan as itemnotforloan
+ FROM items
+ LEFT JOIN biblio ON biblio.biblionumber = items.biblionumber
+ LEFT JOIN biblioitems ON biblioitems.biblioitemnumber = items.biblioitemnumber
+ LEFT JOIN itemtypes on items.itemtype = itemtypes.itemtype
+ WHERE items.biblionumber = ? ORDER BY items.dateaccessioned desc" ;
my $sth = $dbh->prepare($query);
$sth->execute($biblionumber);
my $i = 0;
@@ -1246,6 +1238,7 @@ sub GetItemsInfo {
$data->{'datedue'} = $datedue;
$data->{'count_reserves'} = $count_reserves;
+ #FIXME: There's an API for this...
# get notforloan complete status if applicable
my $sthnflstatus = $dbh->prepare(
'SELECT authorised_value
@@ -1267,7 +1260,7 @@ sub GetItemsInfo {
my ($lib) = $sthnflstatus->fetchrow;
$data->{notforloanvalue} = $lib;
}
- $data->{itypenotforloan} = $data->{notforloan} if (C4::Context->preference('item-level_itypes'));
+ $data->{itemtype_notforloan} = $data->{notforloan};
# my stack procedures
my $stackstatus = $dbh->prepare(
@@ -1833,7 +1826,7 @@ sub _koha_new_item {
cn_source = ?,
cn_sort = ?,
ccode = ?,
- itype = ?,
+ itemtype = ?,
materials = ?,
uri = ?,
enumchron = ?,
@@ -1869,7 +1862,7 @@ sub _koha_new_item {
$item->{'items.cn_source'},
$item->{'items.cn_sort'},
$item->{'ccode'},
- $item->{'itype'},
+ $item->{'itemtype'},
$item->{'materials'},
$item->{'uri'},
$item->{'enumchron'},
diff --git a/C4/Labels.pm b/C4/Labels.pm
index 79d5251..0c4972f 100644
--- a/C4/Labels.pm
+++ b/C4/Labels.pm
@@ -1016,7 +1016,6 @@ sub DrawSpineText {
$sth->execute();
while ( my $data = $sth->fetchrow_hashref ) {
$$item->{'itemtype'} = $data->{'description'} if ($$item->{'itemtype'} eq $data->{'itemtype'});
- $$item->{'itype'} = $data->{'description'} if ($$item->{'itype'} eq $data->{'itemtype'});
}
my $str = '';
@@ -1039,10 +1038,7 @@ sub DrawSpineText {
my $cn_source = ($$item->{'cn_source'} ? $$item->{'cn_source'} : C4::Context->preference('DefaultClassificationSource'));
for my $field (@str_fields) {
$field->{'code'} or warn "get_text_fields($layout_id, 'codes') element missing 'code' field";
- if ($field->{'code'} eq 'itemtype') {
- $field->{'data'} = C4::Context->preference('item-level_itypes') ? $$item->{'itype'} : $$item->{'itemtype'};
- }
- elsif ($$conf_data->{'formatstring'}) {
+ if ($$conf_data->{'formatstring'}) {
# if labels_conf.formatstring has a value, then it overrides the hardcoded option.
$field->{'data'} = GetBarcodeData($field->{'code'},$$item,$record) ;
}
diff --git a/C4/Overdues.pm b/C4/Overdues.pm
index 63b0842..a419974 100644
--- a/C4/Overdues.pm
+++ b/C4/Overdues.pm
@@ -117,23 +117,12 @@ Koha database.
sub Getoverdues {
my $params = shift;
my $dbh = C4::Context->dbh;
- my $statement;
- if ( C4::Context->preference('item-level_itypes') ) {
- $statement = "
- SELECT issues.*, items.itype as itemtype, items.homebranch, items.barcode
+ my $statement = "
+ SELECT issues.*, items.itemtype, items.homebranch, items.barcode
FROM issues
LEFT JOIN items USING (itemnumber)
WHERE date_due < now()
";
- } else {
- $statement = "
- SELECT issues.*, biblioitems.itemtype, items.itype, items.homebranch, items.barcode
- FROM issues
-LEFT JOIN items USING (itemnumber)
-LEFT JOIN biblioitems USING (biblioitemnumber)
- WHERE date_due < now()
-";
- }
my @bind_parameters;
if ( exists $params->{'minimumdays'} and exists $params->{'maximumdays'} ) {
@@ -1201,7 +1190,6 @@ display is filtered by branch
sub GetOverduesForBranch {
my ( $branch, $location) = @_;
- my $itype_link = (C4::Context->preference('item-level_itypes')) ? " items.itype " : " biblioitems.itemtype ";
if ( not $location ) {
my $dbh = C4::Context->dbh;
my $sth = $dbh->prepare("
@@ -1231,7 +1219,7 @@ sub GetOverduesForBranch {
LEFT JOIN items ON items.itemnumber = issues.itemnumber
LEFT JOIN biblio ON biblio.biblionumber = items.biblionumber
LEFT JOIN biblioitems ON biblioitems.biblioitemnumber=items.biblioitemnumber
- LEFT JOIN itemtypes ON itemtypes.itemtype = $itype_link
+ LEFT JOIN itemtypes ON itemtypes.itemtype = items.itemtype
LEFT JOIN branches ON branches.branchcode = issues.branchcode
WHERE ( accountlines.amountoutstanding != '0.000000')
AND ( accountlines.accounttype = 'FU')
@@ -1281,7 +1269,7 @@ sub GetOverduesForBranch {
LEFT JOIN items ON items.itemnumber = issues.itemnumber
LEFT JOIN biblio ON biblio.biblionumber = items.biblionumber
LEFT JOIN biblioitems ON biblioitems.biblioitemnumber=items.biblioitemnumber
- LEFT JOIN itemtypes ON itemtypes.itemtype = $itype_link
+ LEFT JOIN itemtypes ON itemtypes.itemtype = items.itemtype
LEFT JOIN branches ON branches.branchcode = issues.branchcode
WHERE ( accountlines.amountoutstanding != '0.000000')
AND ( accountlines.accounttype = 'FU')
diff --git a/C4/Reports/Guided.pm b/C4/Reports/Guided.pm
index ce5876e..eac2d94 100644
--- a/C4/Reports/Guided.pm
+++ b/C4/Reports/Guided.pm
@@ -70,24 +70,16 @@ $keys{'5'} = ['borrowers.borrowernumber=accountlines.borrowernumber'];
our %criteria;
$criteria{'1'} = [
- 'statistics.type', 'borrowers.categorycode',
- 'statistics.branch',
- 'biblioitems.publicationyear|date',
+ 'items.itemtype', 'statistics.type', 'borrowers.categorycode',
+ 'statistics.branch', 'biblioitems.publicationyear|date',
'items.dateaccessioned|date'
];
$criteria{'2'} =
- [ 'items.holdingbranch', 'items.homebranch' ,'items.itemlost', 'items.location', 'items.ccode'];
+ ['items.itemtype', 'items.holdingbranch', 'items.homebranch' ,'items.itemlost', 'items.location', 'items.ccode'];
$criteria{'3'} = ['borrowers.branchcode'];
$criteria{'4'} = ['aqorders.datereceived|date'];
$criteria{'5'} = ['borrowers.branchcode'];
-if (C4::Context->preference('item-level_itypes')) {
- unshift @{ $criteria{'1'} }, 'items.itype';
- unshift @{ $criteria{'2'} }, 'items.itype';
-} else {
- unshift @{ $criteria{'1'} }, 'biblioitems.itemtype';
- unshift @{ $criteria{'2'} }, 'biblioitems.itemtype';
-}
=head1 NAME
diff --git a/C4/Reserves.pm b/C4/Reserves.pm
index 58086fa..54419f6 100644
--- a/C4/Reserves.pm
+++ b/C4/Reserves.pm
@@ -616,23 +616,20 @@ sub CheckReserves {
my $query = "
SELECT items.biblionumber, items.biblioitemnumber, itemtypes.notforloan, items.notforloan AS itemnotforloan
FROM items
- LEFT JOIN biblioitems ON items.biblioitemnumber = biblioitems.biblioitemnumber
- LEFT JOIN itemtypes ON biblioitems.itemtype = itemtypes.itemtype
+ LEFT JOIN itemtypes ON items.itemtype = itemtypes.itemtype
WHERE itemnumber=$qitem
";
$sth = $dbh->prepare($query);
}
else {
my $qbc = $dbh->quote($barcode);
+ #FIXME - Remove this block. There are no callers who pass barcode, and no need to replicate that here.
# Look up the item by barcode
my $query = "
SELECT items.biblionumber, items.biblioitemnumber, itemtypes.notforloan, items.notforloan AS itemnotforloan
- FROM items
- LEFT JOIN biblioitems ON items.biblioitemnumber = biblioitems.biblioitemnumber
+ FROM items
LEFT JOIN itemtypes ON biblioitems.itemtype = itemtypes.itemtype
- WHERE items.biblioitemnumber = biblioitems.biblioitemnumber
- AND biblioitems.itemtype = itemtypes.itemtype
- AND barcode=$qbc
+ WHERE barcode=$qbc
";
$sth = $dbh->prepare($query);
@@ -1148,19 +1145,10 @@ sub IsAvailableForItemLevelRequest {
# or something similar - need to be
# consolidated
my $dbh = C4::Context->dbh;
- my $notforloan_query;
- if (C4::Context->preference('item-level_itypes')) {
- $notforloan_query = "SELECT itemtypes.notforloan
- FROM items
- JOIN itemtypes ON (itemtypes.itemtype = items.itype)
- WHERE itemnumber = ?";
- } else {
- $notforloan_query = "SELECT itemtypes.notforloan
+ my $notforloan_query = "SELECT itemtypes.notforloan
FROM items
- JOIN biblioitems USING (biblioitemnumber)
- JOIN itemtypes USING (itemtype)
+ JOIN itemtypes ON (itemtypes.itemtype = items.itemtype)
WHERE itemnumber = ?";
- }
my $sth = $dbh->prepare($notforloan_query);
$sth->execute($itemnumber);
my $notforloan_per_itemtype = 0;
diff --git a/C4/Search.pm b/C4/Search.pm
index ecb1e77..de4978f 100644
--- a/C4/Search.pm
+++ b/C4/Search.pm
@@ -1260,13 +1260,14 @@ sub searchResults {
$oldbiblio->{result_number} = $i + 1;
# add imageurl to itemtype if there is one
- $oldbiblio->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $oldbiblio->{itemtype} }->{imageurl} );
+ # FIXME: Some other mechanism needs to be in place here. itemtype is now at item level.
+ # $oldbiblio->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $oldbiblio->{itemtype} }->{imageurl} );
+ # $oldbiblio->{description} = $itemtypes{ $oldbiblio->{itemtype} }->{description};
$oldbiblio->{'authorised_value_images'} = C4::Items::get_authorised_value_images( C4::Biblio::get_biblio_authorised_values( $oldbiblio->{'biblionumber'} ) );
(my $aisbn) = $oldbiblio->{isbn} =~ /([\d-]*[X]*)/;
$aisbn =~ s/-//g;
$oldbiblio->{amazonisbn} = $aisbn;
- $oldbiblio->{description} = $itemtypes{ $oldbiblio->{itemtype} }->{description};
# Build summary if there is one (the summary is defined in the itemtypes table)
# FIXME: is this used anywhere, I think it can be commented out? -- JF
if ( $itemtypes{ $oldbiblio->{itemtype} }->{summary} ) {
@@ -1357,6 +1358,7 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
my $itembinding_count = 0;
my $itemdamaged_count = 0;
my $item_in_transit_count = 0;
+ my $itemtype_for_loan = 0;
my $can_place_holds = 0;
my $items_count = scalar(@fields);
my $maxitems =
@@ -1382,7 +1384,7 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
$item->{'branchname'} = $branches{$item->{$otherbranch}};
}
- my $prefix = $item->{$hbranch} . '--' . $item->{location} . $item->{itype} . $item->{itemcallnumber};
+ my $prefix = $item->{$hbranch} . '--' . $item->{location} . $item->{itemtype} . $item->{itemcallnumber};
# For each grouping of items (onloan, available, unavailable), we build a key to store relevant info about that item
if ( $item->{onloan} ) {
$onloan_count++;
@@ -1392,7 +1394,7 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
$onloan_items->{$key}->{branchname} = $item->{branchname};
$onloan_items->{$key}->{location} = $shelflocations->{ $item->{location} };
$onloan_items->{$key}->{itemcallnumber} = $item->{itemcallnumber};
- $onloan_items->{$key}->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $item->{itype} }->{imageurl} );
+ $onloan_items->{$key}->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $item->{itemtype} }->{imageurl} );
# if something's checked out and lost, mark it as 'long overdue'
if ( $item->{itemlost} ) {
$onloan_items->{$prefix}->{longoverdue}++;
@@ -1457,7 +1459,7 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
$other_items->{$key}->{notforloan} = GetAuthorisedValueDesc('','',$item->{notforloan},'','',$notforloan_authorised_value) if $notforloan_authorised_value;
$other_items->{$key}->{count}++ if $item->{$hbranch};
$other_items->{$key}->{location} = $shelflocations->{ $item->{location} };
- $other_items->{$key}->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $item->{itype} }->{imageurl} );
+ $other_items->{$key}->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $item->{itemtype} }->{imageurl} );
}
# item is available
else {
@@ -1468,9 +1470,10 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
$available_items->{$prefix}->{$_} = $item->{$_};
}
$available_items->{$prefix}->{location} = $shelflocations->{ $item->{location} };
- $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $item->{itype} }->{imageurl} );
+ $available_items->{$prefix}->{imageurl} = getitemtypeimagelocation( 'opac', $itemtypes{ $item->{itemtype} }->{imageurl} );
}
}
+ $itemtype_for_loan++ unless( $itemtypes{ $item->{itemtype} }->{notforloan});
} # notforloan, item level and biblioitem level
my ( $availableitemscount, $onloanitemscount, $otheritemscount );
$maxitems =
@@ -1496,9 +1499,8 @@ s/\[(.?.?.?.?)$tagsubf(.*?)]/$1$subfieldvalue$2\[$1$tagsubf$2]/g;
$oldbiblio->{XSLTResultsRecord} = $newxmlrecord;
}
- # last check for norequest : if itemtype is notforloan, it can't be reserved either, whatever the items
- $can_place_holds = 0
- if $itemtypes{ $oldbiblio->{itemtype} }->{notforloan};
+ # last check for norequest : if no itemtypes are notforloan, it can't be reserved either, whatever the items
+ $can_place_holds = 0 unless($itemtype_for_loan);
$oldbiblio->{norequests} = 1 unless $can_place_holds;
$oldbiblio->{itemsplural} = 1 if $items_count > 1;
$oldbiblio->{items_count} = $items_count;
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
index 45a9780..d10b6a6 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-detail.tmpl
@@ -267,7 +267,7 @@
<td><!-- TMPL_VAR NAME="publisheddate" --> </td><!-- /TMPL_IF -->
<td><!-- TMPL_IF name="bi_notforloan" -->
Not for loan
- <!-- TMPL_ELSIF NAME="itypenotforloan" -->
+ <!-- TMPL_ELSIF NAME="itemtype_notforloan" -->
Not for loan
<!-- TMPL_ELSE -->
<!-- TMPL_IF name="datedue" -->
--
1.5.6.2
More information about the Koha-patches
mailing list