From 805d8c8f4d8fa488b582ebab027551e557212cb5 Mon Sep 17 00:00:00 2001 From: Ryan Higgins Date: Sun, 11 Nov 2007 16:39:27 -0600 Subject: [PATCH] changes to item-level itype reintroduce items.itype (had been removed by updatedatabase but still in kohastructure) populate itype with bi.itemtype. fix error in getbiblio Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- C4/Biblio.pm | 28 ++++++++++++++++------------ C4/Circulation.pm | 10 +++++----- installer/kohastructure.sql | 1 + 3 files changed, 22 insertions(+), 17 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 3f2bcb3fe4..c655cbf7ae 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -258,7 +258,7 @@ sub AddItem { $sth = $dbh->prepare( "SELECT notforloan FROM itemtypes WHERE itemtype=?"); - $sth->execute( C4::Context->preference('item-level_itypes') ? $item->{'ccode'} : $itemtype ); + $sth->execute( C4::Context->preference('item-level_itypes') ? $item->{'itype'} : $itemtype ); my $notforloan = $sth->fetchrow; ##Change the notforloan field if $notforloan found if ( $notforloan > 0 ) { @@ -652,19 +652,21 @@ sub GetBiblioData { my ( $bibnum ) = @_; my $dbh = C4::Context->dbh; - my $query = C4::Context->preference('item-level_itypes') - ? " SELECT * , biblioitems.notes AS bnotes, itemtypes.notforloan as bi_notforloan, biblio.notes + # 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 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 " - : " 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 - "; + AND biblioitems.biblionumber = biblio.biblionumber "; + my $sth = $dbh->prepare($query); $sth->execute($bibnum); my $data; @@ -733,7 +735,7 @@ sub GetItemsInfo { 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.ccode = itemtypes.itemtype " + " 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 $sth = $dbh->prepare($query); @@ -1142,7 +1144,7 @@ sub GetBiblioItemData { my $dbh = C4::Context->dbh; my $query = "SELECT *,biblioitems.notes AS bnotes FROM biblio, biblioitems "; - if(C4::Context->preference('item-level_itypes')) { + unless(C4::Context->preference('item-level_itypes')) { $query .= "LEFT JOIN itemtypes on biblioitems.itemtype=itemtypes.itemtype "; } $query .= " WHERE biblio.biblionumber = biblioitems.biblionumber @@ -3784,6 +3786,7 @@ sub _koha_new_items { cn_source = ?, cn_sort = ?, ccode = ?, + itype = ?, materials = ?, uri = ? "; @@ -3813,6 +3816,7 @@ sub _koha_new_items { $item->{'items.cn_source'}, $items_cn_sort, $item->{'ccode'}, + $item->{'itype'}, $item->{'materials'}, $item->{'uri'}, ); diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 036577c4df..e25c616080 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -378,7 +378,7 @@ sub TooMany { my $branch_issuer = C4::Context->userenv->{'branchcode'}; #TODO : specify issuer or borrower for circrule. my $type = (C4::Context->preference('item-level_itypes')) - ? $item->{'ccode'} # item-level + ? $item->{'itype'} # item-level : $item->{'itemtype'}; # biblio-level my $sth = @@ -395,7 +395,7 @@ sub TooMany { AND i.itemnumber = s2.itemnumber AND s1.biblioitemnumber = s2.biblioitemnumber" . (C4::Context->preference('item-level_itypes')) - ? " AND s2.ccode=? " + ? " AND s2.itype=? " : " AND s1.itemtype= ? "; my $sth2= $dbh->prepare($query2); my $sth3 = @@ -960,7 +960,7 @@ if ($borrower and $barcode and $barcodecheck ne '0'){ (borrowernumber, itemnumber,issuedate, date_due, branchcode) VALUES (?,?,?,?,?)" ); - my $itype=(C4::Context->preference('item-level_itypes')) ? $biblio->{'itemtype'} : $biblio->{'ccode'}; + my $itype=(C4::Context->preference('item-level_itypes')) ? $biblio->{'itemtype'} : $biblio->{'itype'}; my $loanlength = GetLoanLength( $borrower->{'categorycode'}, $itype, @@ -1625,7 +1625,7 @@ sub AddRenewal { my $borrower = C4::Members::GetMemberDetails( $borrowernumber, 0 ); my $loanlength = GetLoanLength( $borrower->{'categorycode'}, - (C4::Context->preference('item-level_itypes')) ? $biblio->{'ccode'} : $biblio->{'itemtype'} , + (C4::Context->preference('item-level_itypes')) ? $biblio->{'itype'} : $biblio->{'itemtype'} , $borrower->{'branchcode'} ); #FIXME -- choose issuer or borrower branch. @@ -1709,7 +1709,7 @@ sub GetIssuingCharges { 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.ccode = itemtypes.itemtype " + ? " LEFT JOIN itemtypes ON items.itype = itemtypes.itemtype " : " LEFT JOIN itemtypes ON biblioitems.itemtype = itemtypes.itemtype "; $qcharge .= "WHERE items.itemnumber =?"; diff --git a/installer/kohastructure.sql b/installer/kohastructure.sql index b06ebe78c2..49505054b0 100644 --- a/installer/kohastructure.sql +++ b/installer/kohastructure.sql @@ -818,6 +818,7 @@ CREATE TABLE `deleteditems` ( `ccode` varchar(10) default NULL, `materials` varchar(10) default NULL, `uri` varchar(255) default NULL, + `itype` varchar(10) default NULL, `marc` longblob, PRIMARY KEY (`itemnumber`), KEY `delitembarcodeidx` (`barcode`), -- 2.39.2