[Koha-cvs] CVS: koha/C4 SearchMarc.pm,1.28,1.29
Paul POULAIN
tipaul at users.sourceforge.net
Mon Oct 25 11:38:04 CEST 2004
Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25502/C4
Modified Files:
SearchMarc.pm
Log Message:
rewritting item status checking : now, each item is shown with it's callnumber and status (available, on loan,...)
Index: SearchMarc.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/SearchMarc.pm,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -r1.28 -r1.29
*** SearchMarc.pm 23 Sep 2004 16:16:24 -0000 1.28
--- SearchMarc.pm 25 Oct 2004 09:38:00 -0000 1.29
***************
*** 320,329 ****
# HINT : biblionumber as bn is important. The hash is fills biblionumber with items.biblionumber.
# so if you dont' has an item, you get a not nice epty value.
! $sth = $dbh->prepare("SELECT biblio.biblionumber as bn,count(*) as tot,biblio.*, biblioitems.*, items.*,marc_biblio.bibid
FROM biblio, marc_biblio
- LEFT JOIN items on items.biblionumber = biblio.biblionumber
LEFT JOIN biblioitems on biblio.biblionumber = biblioitems.biblionumber
! WHERE biblio.biblionumber = marc_biblio.biblionumber AND bibid = ?
! GROUP BY items.biblionumber, items.holdingbranch, items.itemcallnumber");
my @finalresult = ();
my @CNresults=();
--- 320,327 ----
# HINT : biblionumber as bn is important. The hash is fills biblionumber with items.biblionumber.
# so if you dont' has an item, you get a not nice epty value.
! $sth = $dbh->prepare("SELECT biblio.biblionumber as bn,biblio.*, biblioitems.*,marc_biblio.bibid
FROM biblio, marc_biblio
LEFT JOIN biblioitems on biblio.biblionumber = biblioitems.biblionumber
! WHERE biblio.biblionumber = marc_biblio.biblionumber AND bibid = ?");
my @finalresult = ();
my @CNresults=();
***************
*** 331,334 ****
--- 329,334 ----
my $oldline;
my ($oldbibid, $oldauthor, $oldtitle);
+ my $sth_itemCN = $dbh->prepare("select * from items where biblionumber=?");
+ my $sth_issue = $dbh->prepare("select date_due,returndate from issues where itemnumber=?");
# parse all biblios between start & end.
while (($counter <= $#result) && ($counter <= ($offset + $length))) {
***************
*** 337,376 ****
my $continue=1;
my $line = $sth->fetchrow_hashref;
! my $oldbiblionumber=$line->{bn};
! $continue=0 unless $line->{bn};
! while ($continue) {
# parse the result, putting holdingbranch & itemcallnumber in separate array
# then all other fields in the main array
! if ($oldbiblionumber && ($oldbiblionumber ne $line->{bn}) && $oldline) {
! my %newline;
! %newline = %$oldline;
! $newline{totitem} = $totalitems;
! $newline{biblionumber} = $oldbiblionumber;
! my @CNresults2= @CNresults;
! $newline{CN} = \@CNresults2;
! $newline{'even'} = 1 if $#finalresult % 2 == 0;
! $newline{'odd'} = 1 if $#finalresult % 2 == 1;
! $newline{'timestamp'} = format_date($newline{timestamp});
! @CNresults = ();
! push @finalresult, \%newline;
! $totalitems=0;
! }
! $continue=0 unless $line->{bn};
! if ($continue) {
! $oldbiblionumber = $line->{bn};
! $totalitems +=$line->{tot} if ($line->{holdingbranch});
! $oldline = $line;
! # item callnumber & branch
! my %lineCN;
! $lineCN{holdingbranch} = $line->{holdingbranch};
! $lineCN{itemcallnumber} = $line->{itemcallnumber};
! $lineCN{location} = $line->{location};
! push @CNresults,\%lineCN;
! $line = $sth->fetchrow_hashref;
}
! }
$counter++;
}
- #add the last line, that is not reached byt the loop / if ($oldbiblionumber...)
my $nbresults = $#result+1;
return (\@finalresult, $nbresults);
--- 337,381 ----
my $continue=1;
my $line = $sth->fetchrow_hashref;
! my $biblionumber=$line->{bn};
! # $continue=0 unless $line->{bn};
! # my $lastitemnumber;
! $sth_itemCN->execute($biblionumber);
! my @CNresults = ();
! while (my $item = $sth_itemCN->fetchrow_hashref) {
# parse the result, putting holdingbranch & itemcallnumber in separate array
# then all other fields in the main array
!
! # search if item is on loan
! my $date_due;
! $sth_issue->execute($item->{itemnumber});
! while (my $loan = $sth_issue->fetchrow_hashref) {
! if ($loan->{date_due} and !$loan->{returndate}) {
! $date_due = $loan->{date_due};
! }
}
! # store this item
! my %lineCN;
! $lineCN{holdingbranch} = $item->{holdingbranch};
! $lineCN{itemcallnumber} = $item->{itemcallnumber};
! $lineCN{location} = $item->{location};
! $lineCN{date_due} = format_date($date_due);
! push @CNresults,\%lineCN;
! $totalitems++;
! }
! # save the biblio in the final array, with item and item issue status
! my %newline;
! %newline = %$line;
! $newline{totitem} = $totalitems;
! $newline{biblionumber} = $biblionumber;
! my @CNresults2= @CNresults;
! $newline{CN} = \@CNresults2;
! $newline{'even'} = 1 if $#finalresult % 2 == 0;
! $newline{'odd'} = 1 if $#finalresult % 2 == 1;
! $newline{'timestamp'} = format_date($newline{timestamp});
! @CNresults = ();
! push @finalresult, \%newline;
! $totalitems=0;
$counter++;
}
my $nbresults = $#result+1;
return (\@finalresult, $nbresults);
More information about the Koha-cvs
mailing list