1 package C4::BookShelves; #asummes C4/BookShelves
7 # Change log is at the bottom of the file
9 #requires DBI.pm to be installed
15 use C4::Circulation::Circ2;
16 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
18 # set the version for version checking
22 @EXPORT = qw(&GetShelfList &GetShelfContents &AddToShelf &RemoveFromShelf &AddShelf &RemoveShelf);
29 %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
31 # your exported package globals go here,
32 # as well as any optionally exported functions
34 @EXPORT_OK = qw($Var1 %Hashit);
37 # non-exported package globals go here
38 use vars qw(@more $stuff);
40 # initalize package globals, first exported ones
45 # then the others (which are still accessible as $Some::Module::stuff)
49 # all file-scoped lexicals must be created before
50 # the functions below that use them.
52 # file-private lexicals go here
56 # here's a file-private function as a closure,
57 # callable as &$priv_func; it cannot be prototyped.
62 # make all your functions, whether exported or not;
67 my $sth=$dbh->prepare("select shelfnumber,shelfname from bookshelf");
70 while (my ($shelfnumber, $shelfname) = $sth->fetchrow) {
71 my $sti=$dbh->prepare("select count(*) from shelfcontents where shelfnumber=$shelfnumber");
73 my ($count) = $sti->fetchrow;
74 $shelflist{$shelfnumber}->{'shelfname'}=$shelfname;
75 $shelflist{$shelfnumber}->{'count'}=$count;
81 sub GetShelfContents {
82 my ($env, $shelfnumber) = @_;
84 my $sth=$dbh->prepare("select itemnumber from shelfcontents where shelfnumber=$shelfnumber order by itemnumber");
86 while (my ($itemnumber) = $sth->fetchrow) {
87 my ($item) = getiteminformation($env, $itemnumber, 0);
88 push (@itemlist, $item);
94 my ($env, $itemnumber, $shelfnumber) = @_;
95 my $sth=$dbh->prepare("select * from shelfcontents where shelfnumber=$shelfnumber and itemnumber=$itemnumber");
100 $sth=$dbh->prepare("insert into shelfcontents (shelfnumber, itemnumber, flags) values ($shelfnumber, $itemnumber, 0)");
105 sub RemoveFromShelf {
106 my ($env, $itemnumber, $shelfnumber) = @_;
107 my $sth=$dbh->prepare("delete from shelfcontents where shelfnumber=$shelfnumber and itemnumber=$itemnumber");
112 my ($env, $shelfname) = @_;
113 my $q_shelfname=$dbh->quote($shelfname);
114 my $sth=$dbh->prepare("select * from bookshelf where shelfname=$q_shelfname");
117 return(0, "Shelf \"$shelfname\" already exists");
119 $sth=$dbh->prepare("insert into bookshelf (shelfname) values ($q_shelfname)");
126 my ($env, $shelfnumber) = @_;
127 my $sth=$dbh->prepare("select count(*) from shelfcontents where shelfnumber=$shelfnumber");
129 my ($count)=$sth->fetchrow;
131 return (0, "Shelf has $count items on it");
133 $sth=$dbh->prepare("delete from bookshelf where shelfnumber=$shelfnumber");
140 END { } # module clean-up code here (global destructor)
145 # Revision 1.2 2001/02/07 23:47:43 tonnesen
146 # Added header and log substition variables
148 # Revision 1.1 2001/02/07 20:27:17 tonnesen
149 # Start of code to implement virtual bookshelves in Koha.