koha-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-devel] CVS: koha/C4 Catalogue.pm,1.6,1.7


From: Steve Tonnesen
Subject: [Koha-devel] CVS: koha/C4 Catalogue.pm,1.6,1.7
Date: Thu Sep 27 12:25:03 2001

Update of /cvsroot/koha/koha/C4
In directory usw-pr-cvs1:/tmp/cvs-serv31420/koha/C4

Modified Files:
        Catalogue.pm 
Log Message:
Started on updateItem subroutine.


Index: Catalogue.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Catalogue.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -r1.6 -r1.7
*** Catalogue.pm        2001/06/26 22:27:12     1.6
--- Catalogue.pm        2001/09/27 19:24:18     1.7
***************
*** 1,4 ****
--- 1,8 ----
  package C4::Catalogue; #asummes C4/Acquisitions.pm
  
+ # Continue working on updateItem!!!!!!
+ #
+ 
+ 
  use strict;
  require Exporter;
***************
*** 55,58 ****
--- 59,63 ----
  # only created when new biblioitems are added.
      my ($env, $biblio) = @_;
+     my $dbh=&C4Connect;  
      my $title=$biblio->{'title'};
      my $q_title=$dbh->quote($title);
***************
*** 106,109 ****
--- 111,117 ----
  # Might be nice to be able to pass a Subfield_ID directly to this routine to
  # remove ambiguity, if possible.
+ #
+ # Pass barcode to remove ambiguity for changes to individual items.  Look up
+ # field link and sequence number based on barcode.
  
      my $Record_ID=shift;
***************
*** 113,116 ****
--- 121,126 ----
      my $Subfield_OldValue=shift;
      my $Subfield_Value=shift;
+     my $barcode=shift;
+     my $Subfield_ID;
      my $dbh=&C4Connect;  
      my $sth=$dbh->prepare("select S.Subfield_ID, S.Subfield_Value from 
Bib_Table B, $firstdigit\XX_Tag_Table T, $firstdigit\XX_Subfield_Table S where 
B.Record_ID=$Record_ID and B.Tag_$firstdigit\XX_ID=T.Tag_ID and 
T.Subfield_ID=S.Subfield_ID and S.Subfield_Mark='$Subfield_Mark'");
***************
*** 121,127 ****
--- 131,139 ----
            my $sti=$dbh->prepare("update $firstdigit\XX_Subfield_Table set 
Subfield_Value=$q_Subfield_Value where Subfield_ID=$ID");
            $sti->execute;
+           $Subfield_ID=$ID;
            last;
        }
      }
+     return($Subfield_ID);
  }
  
***************
*** 329,333 ****
        my ($biblioitemnumber) =$sth->fetchrow;
        $biblioitemnumber++;
!       $sth=$dbh->prepare("insert into biblioitems 
(biblionumber,biblioitemnumber,volume,number,classification,itemtype,isbn,issn,dewey,subclass,publicationyear,publishercode,volumedate,illus,pages,notes,size,place,lccn)
 values ($biblionumber, $biblioitemnumber, $q_volume, $q_number, 
$q_classification, $q_itemtype, $q_isbn, $q_issn, $dewey, $q_subclass, 
$q_publicationyear, $q_publishercode, $q_volumedate, $q_illus, 
$q_pages,$q_notes, $q_size, $q_place, $q_lccn)");
        $sth->execute;
        #my $sth=$dbh->prepare("unlock tables");
--- 341,345 ----
        my ($biblioitemnumber) =$sth->fetchrow;
        $biblioitemnumber++;
!       $sth=$dbh->prepare("insert into biblioitems 
(biblionumber,biblioitemnumber,volume,number,classification,itemtype,isbn,issn,dewey,subclass,publicationyear,publishercode,volumedate,illus,pages,notes,size,place,lccn)
 values ($biblionumber, $biblioitemnumber, $q_volume, $q_number, 
$q_classification, $q_itemtype, $q_isbn, $q_issn, $dewey, $q_subclass, 
$publicationyear, $q_publishercode, $q_volumedate, $q_illus, $q_pages,$q_notes, 
$q_size, $q_place, $q_lccn)");
        $sth->execute;
        #my $sth=$dbh->prepare("unlock tables");
***************
*** 339,343 ****
  # same isbn/lccn/issn?
  
!     $sth=$dbh->prepare("select 
title,unititle,seriestitle,copyrightdate,notes,author from biblio where 
biblionumber=$biblionumber");
      $sth->execute;
      my ($title, $unititle,$seriestitle,$copyrightdate,$biblionotes,$author) = 
$sth->fetchrow;
--- 351,355 ----
  # same isbn/lccn/issn?
  
!     my $sth=$dbh->prepare("select 
title,unititle,seriestitle,copyrightdate,notes,author from biblio where 
biblionumber=$biblionumber");
      $sth->execute;
      my ($title, $unititle,$seriestitle,$copyrightdate,$biblionotes,$author) = 
$sth->fetchrow;
***************
*** 403,407 ****
        $subfields->{2}->{'Subfield_Mark'}='3';
        $subfields->{2}->{'Subfield_Value'}='biblio';
!       my $tag='440';
        addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
      }
--- 415,419 ----
        $subfields->{2}->{'Subfield_Mark'}='3';
        $subfields->{2}->{'Subfield_Value'}='biblio';
!       my $tag='500';
        addTag($env, $Record_ID, $tag, ' ', ' ', $subfields);
      }
***************
*** 540,544 ****
  sub updateBiblioItem {
  # Update the biblioitem with biblioitemnumber 
$biblioitem->{'biblioitemnumber'}
- # This routine should also modify the corresponding MARC record data.
  #
  # This routine should also check to see which fields are actually being
--- 552,555 ----
***************
*** 598,602 ****
      if ($biblioitem->{'dewey'} ne $obi->{'dewey'}) {
        logchange('kohadb', 'biblioitems', 'dewey', $obi->{'dewey'}, 
$biblioitem->{'dewey'});
!       my $sth=$dbh->prepare("update biblioitems set dewey=$dewey where 
biblioitemnumber=$biblioitemnumber");
        logchange('marc', '082', 'a', $obi->{'dewey'}, $biblioitem->{'dewey'});
        changeSubfield($Record_ID, '082', 'a', $obi->{'dewey'}, 
$biblioitem->{'dewey'});
--- 609,613 ----
      if ($biblioitem->{'dewey'} ne $obi->{'dewey'}) {
        logchange('kohadb', 'biblioitems', 'dewey', $obi->{'dewey'}, 
$biblioitem->{'dewey'});
!       my $sth=$dbh->prepare("update biblioitems set 
dewey=$biblioitem->{'dewey'} where biblioitemnumber=$biblioitemnumber");
        logchange('marc', '082', 'a', $obi->{'dewey'}, $biblioitem->{'dewey'});
        changeSubfield($Record_ID, '082', 'a', $obi->{'dewey'}, 
$biblioitem->{'dewey'});
***************
*** 673,683 ****
--- 684,700 ----
      my $dbh=&C4Connect;  
      my $barcode=$item->{'barcode'};
+     my $q_barcode=$dbh->quote($barcode);
+     my $biblionumber=$item->{'biblionumber'};
+     my $biblioitemnumber=$item->{'biblioitemnumber'};
      my $dateaccessioned=$item->{'dateaccessioned'};
      my $booksellerid=$item->{'booksellerid'};
+     my $q_booksellerid=$dbh->quote($booksellerid);
      my $homebranch=$item->{'homebranch'};
+     my $q_homebranch=$dbh->quote($homebranch);
      my $holdingbranch=$item->{'holdingbranch'};
      my $price=$item->{'price'};
      my $replacementprice=$item->{'replacementprice'};
      my $replacementpricedate=$item->{'replacementpricedate'};
+     my $q_replacementpricedate=$dbh->quote($replacementpricedate);
      my $notforloan=$item->{'notforloan'};
      my $itemlost=$item->{'itemlost'};
***************
*** 685,688 ****
--- 702,706 ----
      my $restricted=$item->{'restricted'};
      my $itemnotes=$item->{'itemnotes'};
+     my $q_itemnotes=$dbh->quote($itemnotes);
      my $itemtype=$item->{'itemtype'};
      my $subclass=$item->{'subclass'};
***************
*** 763,766 ****
--- 781,858 ----
  
      my ($env, $item) = @_;
+     my $dbh=&C4Connect;  
+     my $itemnumber=$item->{'itemnumber'};
+     my $biblionumber=$item->{'biblionumber'};
+     my $biblioitemnumber=$item->{'biblioitemnumber'};
+     my $barcode=$item->{'barcode'};
+     my $dateaccessioned=$item->{'dateaccessioned'};
+     my $booksellerid=$item->{'booksellerid'};
+     my $homebranch=$item->{'homebranch'};
+     my $price=$item->{'price'};
+     my $replacementprice=$item->{'replacementprice'};
+     my $replacementpricedate=$item->{'replacementpricedate'};
+     my $multivolume=$item->{'multivolume'};
+     my $stack=$item->{'stack'};
+     my $notforloan=$item->{'notforloan'};
+     my $itemlost=$item->{'itemlost'};
+     my $wthdrawn=$item->{'wthdrawn'};
+     my $bulk=$item->{'bulk'};
+     my $restricted=$item->{'restricted'};
+     my $binding=$item->{'binding'};
+     my $itemnotes=$item->{'itemnotes'};
+     my $holdingbranch=$item->{'holdingbranch'};
+     my $interim=$item->{'interim'};
+     my $sth=$dbh->prepare("select * from items where itemnumber=$itemnumber");
+     $sth->execute;
+     my $olditem=$sth->fetchrow_hashref;
+     my $q_barcode=$dbh->quote($olditem->{'barcode'});
+     $sth=$dbh->prepare("select Subfield_ID from 8XX_Subfield_Table where 
Subfield_Mark='p' and Subfield_Value=$q_barcode");
+     $sth->execute;
+     my ($Subfield852_ID) = $sth->fetchrow;
+     $sth=$dbh->prepare("select Subfield_Value from 8XX_Subfield_Table where 
Subfield_Mark=8 and Subfield_ID=$Subfield852_ID");
+     $sth->execute;
+     my ($link) = $sth->fetchrow;
+     $sth=$dbh->prepare("select Subfield_ID from 8XX_Subfield_Table where 
Subfield_Mark=8 and Subfield_Value=$link");
+     $sth->execute;
+     my ($Subfield876_ID) = $sth->fetchrow;
+     
+     if ($item->{'barcode'} ne $olditem->{'barcode'}) {
+       logchange('kohadb', 'items', 'barcode', $olditem->{'barcode'}, 
$item->{'barcode'});
+       my $q_barcode=$dbh->quote($item->{'barcode'});
+       my $sth=$dbh->prepare("update items set barcode=$q_barcode where 
itemnumber=$itemnumber");
+       logchange('marc', '876', 'p', $olditem->{'barcode'}, 
$item->{'barcode'});
+       ($Subfield_ID) = changeSubfield($Record_ID, '876', 'p', 
$olditem->{'barcode'}, $item->{'barcode'});
+     }
+     if ($item->{'booksellerid'} ne $olditem->{'booksellerid'}) {
+       logchange('kohadb', 'items', 'booksellerid', 
$olditem->{'booksellerid'}, $item->{'booksellerid'});
+       my $q_booksellerid=$dbh->quote($item->{'booksellerid'});
+       my $sth=$dbh->prepare("update items set booksellerid=$q_booksellerid 
where itemnumber=$itemnumber");
+       logchange('marc', '876', 'e', $olditem->{'booksellerid'}, 
$item->{'booksellerid'});
+       changeSubfield($Record_ID, '876', 'e', $olditem->{'booksellerid'}, 
$item->{'booksellerid'});
+     }
+     if ($item->{'dateaccessioned'} ne $olditem->{'dateaccessioned'}) {
+       logchange('kohadb', 'items', 'dateaccessioned', 
$olditem->{'dateaccessioned'}, $item->{'dateaccessioned'});
+       my $q_dateaccessioned=$dbh->quote($item->{'dateaccessioned'});
+       my $sth=$dbh->prepare("update items set 
dateaccessioned=$q_dateaccessioned where itemnumber=$itemnumber");
+       logchange('marc', '876', 'd', $olditem->{'dateaccessioned'}, 
$item->{'dateaccessioned'});
+       changeSubfield($Record_ID, '876', 'd', $olditem->{'dateaccessioned'}, 
$item->{'dateaccessioned'});
+     }
+     if ($item->{'homebranch'} ne $olditem->{'homebranch'}) {
+       # FIX ME!!!!  This really needs to check the field link and sequence
+       # number entry to make sure the right item is being modified!
+       # Use 876 p (piece designation) to ensure.
+       logchange('kohadb', 'items', 'homebranch', $olditem->{'homebranch'}, 
$item->{'homebranch'});
+       my $q_homebranch=$dbh->quote($item->{'homebranch'});
+       my $sth=$dbh->prepare("update items set homebranch=$q_homebranch where 
itemnumber=$itemnumber");
+       logchange('marc', '876', 'b', $olditem->{'homebranch'}, 
$item->{'homebranch'});
+       changeSubfield($Record_ID, '876', 'b', $olditem->{'homebranch'}, 
$item->{'homebranch'});
+     }
+     if ($item->{'holdingbranch'} ne $olditem->{'holdingbranch'}) {
+       logchange('kohadb', 'items', 'holdingbranch', 
$olditem->{'holdingbranch'}, $item->{'holdingbranch'});
+       my $q_holdingbranch=$dbh->quote($item->{'holdingbranch'});
+       my $sth=$dbh->prepare("update items set holdingbranch=$q_holdingbranch 
where itemnumber=$itemnumber");
+       logchange('marc', '876', 'l', $olditem->{'holdingbranch'}, 
$item->{'holdingbranch'});
+       changeSubfield($Record_ID, '876', 'l', $olditem->{'holdingbranch'}, 
$item->{'holdingbranch'});
+     }
  }
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]