From tgarip at neu.edu.tr Sun Apr 1 13:54:16 2007 From: tgarip at neu.edu.tr (Tumer Garip) Date: Sun, 01 Apr 2007 11:54:16 +0000 Subject: [Koha-cvs] koha/C4 Biblioadd.pm Record.pm [rel_TG] Message-ID: CVSROOT: /sources/koha Module name: koha Branch: rel_TG Changes by: Tumer Garip 07/04/01 11:54:16 Modified files: C4 : Biblioadd.pm Removed files: C4 : Record.pm Log message: remove unused pacakges to prevent confusion CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/C4/Biblioadd.pm?cvsroot=koha&only_with_tag=rel_TG&r1=1.1.2.3&r2=1.1.2.4 http://cvs.savannah.gnu.org/viewcvs/koha/C4/Record.pm?cvsroot=koha&only_with_tag=rel_TG&r1=1.6.2.1&r2=0 Patches: Index: Biblioadd.pm =================================================================== RCS file: /sources/koha/koha/C4/Attic/Biblioadd.pm,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -b -r1.1.2.3 -r1.1.2.4 --- Biblioadd.pm 30 Mar 2007 00:14:42 -0000 1.1.2.3 +++ Biblioadd.pm 1 Apr 2007 11:54:16 -0000 1.1.2.4 @@ -24,7 +24,7 @@ use MARC::Record; use MARC::File::USMARC; use C4::Biblio; - +use Unicode::Normalize; my $format="USMARC"; $format="UNIMARC" if (C4::Context->preference('marcflavour') eq 'UNIMARC'); use MARC::File::XML(RecordFormat =>$format); @@ -116,7 +116,7 @@ $record->insert_fields_ordered($newfield); } my $xml=MARC::File::XML::record($record); - + $xml=NFC($xml); my $xmlhash=XML_xml2hash_onerecord($xml); return $xmlhash,$encoding; Index: Record.pm =================================================================== RCS file: Record.pm diff -N Record.pm --- Record.pm 25 Mar 2007 23:46:14 -0000 1.6.2.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,575 +0,0 @@ -package C4::Record; -# -# Copyright 2006 (C) LibLime -# Joshua Ferraro -# -# This file is part of Koha. -# -# Koha is free software; you can redistribute it and/or modify it under the -# terms of the GNU General Public License as published by the Free Software -# Foundation; either version 2 of the License, or (at your option) any later -# version. -# -# Koha is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR -# A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA -# -# $Id: Record.pm,v 1.6.2.1 2007/03/25 23:46:14 tgarip1957 Exp $ -# -use strict; use warnings; #FIXME: turn off warnings before release - -# please specify in which methods a given module is used -use MARC::Record; # marc2marcxml, marcxml2marc, html2marc, changeEncoding -use MARC::File::XML; # marc2marcxml, marcxml2marc, html2marcxml, changeEncoding -#use MARC::Crosswalk::DublinCore; # marc2dcxml -#use MODS::Record; # marc2modsxml -use Unicode::Normalize; # _entity_encode - -use vars qw($VERSION @ISA @EXPORT); - -# set the version for version checking -$VERSION = do { my @v = '$Revision: 1.6.2.1 $' =~ /\d+/g; - shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); }; - - at ISA = qw(Exporter); - -# only export API methods - - at EXPORT = qw( - &marc2marc - &marc2marcxml - &marcxml2marc - &marc2dcxml - &marc2modsxml - - &html2marcxml - &html2marc - &changeEncoding -); - -=head1 NAME - -C4::Record - MARC, MARCXML, DC, MODS, XML, etc. Record Management Functions and API - -=head1 SYNOPSIS - -New in Koha 3.x. This module handles all record-related management functions. - -=head1 API (EXPORTED FUNCTIONS) - -=head2 marc2marc - Convert from one flavour of ISO-2709 to another - -=over 4 - -my ($error,$newmarc) = marc2marc($marc,$to_flavour,$from_flavour,$encoding); - -Returns an ISO-2709 scalar - -=back - -=cut - -sub marc2marc { - my ($marc,$to_flavour,$from_flavour,$encoding) = @_; - my $error = "Feature not yet implemented\n"; - return ($error,$marc); -} - -=head2 marc2marcxml - Convert from ISO-2709 to MARCXML - -=over 4 - -my ($error,$marcxml) = marc2marcxml($marc,$encoding,$flavour); - -Returns a MARCXML scalar - -=over 2 - -C<$marc> - an ISO-2709 scalar or MARC::Record object - -C<$encoding> - UTF-8 or MARC-8 [UTF-8] - -C<$flavour> - MARC21 or UNIMARC - -C<$dont_entity_encode> - a flag that instructs marc2marcxml not to entity encode the xml before returning (optional) - -=back - -=back - -=cut - -sub marc2marcxml { - my ($marc,$encoding,$flavour,$dont_entity_encode) = @_; - my $error; # the error string - my $marcxml; # the final MARCXML scalar - - # test if it's already a MARC::Record object, if not, make it one - my $marc_record_obj; - if ($marc =~ /^MARC::Record/) { # it's already a MARC::Record object - $marc_record_obj = $marc; - } else { # it's not a MARC::Record object, make it one - eval { $marc_record_obj = MARC::Record->new_from_usmarc($marc) }; # handle exceptions - - # conversion to MARC::Record object failed, populate $error - if ($@) { $error .="\nCreation of MARC::Record object failed: ".$MARC::File::ERROR }; - } - # only proceed if no errors so far - unless ($error) { - - # check the record for warnings - my @warnings = $marc_record_obj->warnings(); - if (@warnings) { - warn "\nWarnings encountered while processing ISO-2709 record with title \"".$marc_record_obj->title()."\":\n"; - foreach my $warn (@warnings) { warn "\t".$warn }; - } - unless($encoding) {$encoding = "UTF-8"}; # set default encoding - unless($flavour) {$flavour = C4::Context->preference("marcflavour")}; # set default MARC flavour - - # attempt to convert the record to MARCXML - eval { $marcxml = $marc_record_obj->as_xml_record($flavour) }; #handle exceptions - - # record creation failed, populate $error - if ($@) { - $error .= "Creation of MARCXML failed:".$MARC::File::ERROR; - $error .= "Additional information:\n"; - my @warnings = $@->warnings(); - foreach my $warn (@warnings) { $error.=$warn."\n" }; - - # record creation was successful - } else { - - # check the record for warning flags again (warnings() will be cleared already if there was an error, see above block - @warnings = $marc_record_obj->warnings(); - if (@warnings) { - warn "\nWarnings encountered while processing ISO-2709 record with title \"".$marc_record_obj->title()."\":\n"; - foreach my $warn (@warnings) { warn "\t".$warn }; - } - } - - # only proceed if no errors so far - unless ($error) { - - # entity encode the XML unless instructed not to - unless ($dont_entity_encode) { - my ($marcxml_entity_encoded) = _entity_encode($marcxml); - $marcxml = $marcxml_entity_encoded; - } - } - } - # return result to calling program - return ($error,$marcxml); -} - -=head2 marcxml2marc - Convert from MARCXML to ISO-2709 - -=over 4 - -my ($error,$marc) = marcxml2marc($marcxml,$encoding,$flavour); - -Returns an ISO-2709 scalar - -=over 2 - -C<$marcxml> - a MARCXML record - -C<$encoding> - UTF-8 or MARC-8 [UTF-8] - -C<$flavour> - MARC21 or UNIMARC - -=back - -=back - -=cut - -sub marcxml2marc { - my ($marcxml,$encoding,$flavour) = @_; - my $error; # the error string - my $marc; # the final ISO-2709 scalar - unless($encoding) {$encoding = "UTF-8"}; # set the default encoding - unless($flavour) {$flavour = C4::Context->preference("marcflavour")}; # set the default MARC flavour - - # attempt to do the conversion - eval { $marc = MARC::Record->new_from_xml($marcxml,$encoding,$flavour) }; # handle exceptions - - # record creation failed, populate $error - if ($@) {$error .="\nCreation of MARCXML Record failed: ".$@; - $error.=$MARC::File::ERROR if ($MARC::File::ERROR); - }; - # return result to calling program - return ($error,$marc); -} - -=head2 marc2dcxml - Convert from ISO-2709 to Dublin Core - -=over 4 - -my ($error,$dcxml) = marc2dcxml($marc,$qualified); - -Returns a DublinCore::Record object, will eventually return a Dublin Core scalar - -FIXME: should return actual XML, not just an object - -=over 2 - -C<$marc> - an ISO-2709 scalar or MARC::Record object - -C<$qualified> - specify whether qualified Dublin Core should be used in the input or output [0] - -=back - -=back - -=cut - -sub marc2dcxml { - my ($marc,$qualified) = @_; - my $error; - # test if it's already a MARC::Record object, if not, make it one - my $marc_record_obj; - if ($marc =~ /^MARC::Record/) { # it's already a MARC::Record object - $marc_record_obj = $marc; - } else { # it's not a MARC::Record object, make it one - eval { $marc_record_obj = MARC::Record->new_from_usmarc($marc) }; # handle exceptions - - # conversion to MARC::Record object failed, populate $error - if ($@) { - $error .="\nCreation of MARC::Record object failed: ".$MARC::File::ERROR; - } - } - my $crosswalk = MARC::Crosswalk::DublinCore->new; - if ($qualified) { - $crosswalk = MARC::Crosswalk::DublinCore->new( qualified => 1 ); - } - my $dcxml = $crosswalk->as_dublincore($marc_record_obj); - return ($error,$dcxml); -} -=head2 marc2modsxml - Convert from ISO-2709 to MODS - -=over 4 - -my ($error,$modsxml) = marc2modsxml($marc); - -Returns a MODS scalar - -=back - -=cut - -sub marc2modsxml { - use XML::XSLT; - #use XML::LibXSLT; - my ($marc) = @_; - my $error; - my $marcxml; - - # open some files for testing - open MARCBIG21MARC21SLIM,"/home/koha/head/koha/C4/MARC21slim2MODS3-1.xsl" or die $!; - my $marcbig2marc21_slim; # = scalar (MARC21MARC8); - foreach my $line () { - $marcbig2marc21_slim .= $line; - } - - # set some defailts - my $to_encoding = "UTF-8"; - my $flavour = "MARC21"; - - # first convert our ISO-2709 to MARCXML - ($error,$marcxml) = marc2marcxml($marc,$to_encoding,$flavour); - my $xslt_obj = XML::XSLT->new ($marcbig2marc21_slim, warnings => 1); - $xslt_obj->transform ($marcxml); - my $xslt_string = $xslt_obj->toString; - $xslt_obj->dispose(); - warn $xslt_string; - return ($error,$xslt_string); -} -=head2 html2marcxml - -=over 4 - -my ($error,$marcxml) = html2marcxml($tags,$subfields,$values,$indicator,$ind_tag); - -Returns a MARCXML scalar - -this is used in addbiblio.pl and additem.pl to build the MARCXML record from -the form submission. - -FIXME: this could use some better code documentation - -=back - -=cut - -sub html2marcxml { - my ($tags,$subfields,$values,$indicator,$ind_tag) = @_; - my $error; - # add the header info - my $marcxml= MARC::File::XML::header(C4::Context->preference('TemplateEncoding'),C4::Context->preference('marcflavour')); - - # some flags used to figure out where in the record we are - my $prevvalue; - my $prevtag=-1; - my $first=1; - my $j = -1; - - # handle characters that would cause the parser to choke FIXME: is there a more elegant solution? - for (my $i=0;$i<=@$tags;$i++){ - @$values[$i] =~ s/&/&/g; - @$values[$i] =~ s//>/g; - @$values[$i] =~ s/"/"/g; - @$values[$i] =~ s/'/'/g; - - if ((@$tags[$i] ne $prevtag)){ - $j++ unless (@$tags[$i] eq ""); - #warn "IND:".substr(@$indicator[$j],0,1).substr(@$indicator[$j],1,1)." ".@$tags[$i]; - if (!$first){ - $marcxml.="\n"; - if ((@$tags[$i] > 10) && (@$values[$i] ne "")){ - my $ind1 = substr(@$indicator[$j],0,1); - my $ind2 = substr(@$indicator[$j],1,1); - $marcxml.="\n"; - $marcxml.="@$values[$i]\n"; - $first=0; - } else { - $first=1; - } - } else { - if (@$values[$i] ne "") { - # handle the leader - if (@$tags[$i] eq "000") { - $marcxml.="@$values[$i]\n"; - $first=1; - # rest of the fixed fields - } elsif (@$tags[$i] < 010) { #FIXME: <10 was the way it was, there might even be a better way - $marcxml.="@$values[$i]\n"; - $first=1; - } else { - my $ind1 = substr(@$indicator[$j],0,1); - my $ind2 = substr(@$indicator[$j],1,1); - $marcxml.="\n"; - $marcxml.="@$values[$i]\n"; - $first=0; - } - } - } - } else { # @$tags[$i] eq $prevtag - if (@$values[$i] eq "") { - } else { - if ($first){ - my $ind1 = substr(@$indicator[$j],0,1); - my $ind2 = substr(@$indicator[$j],1,1); - $marcxml.="\n"; - $first=0; - } - $marcxml.="@$values[$i]\n"; - } - } - $prevtag = @$tags[$i]; - } - $marcxml.= MARC::File::XML::footer(); - #warn $marcxml; - return ($error,$marcxml); -} - -=head2 html2marc - -=over 4 - -Probably best to avoid using this ... it has some rather striking problems: - -=over 2 - -* saves blank subfields - -* subfield order is hardcoded to always start with 'a' for repeatable tags (because it is hardcoded in the addfield routine). - -* only possible to specify one set of indicators for each set of tags (ie, one for all the 650s). (because they were stored in a hash with the tag as the key). - -* the underlying routines didn't support subfield reordering or subfield repeatability. - -=back - -I've left it in here because it could be useful if someone took the time to fix it. -- kados - -=back - -=cut - -sub html2marc { - my ($dbh,$rtags,$rsubfields,$rvalues,%indicators) = @_; - my $prevtag = -1; - my $record = MARC::Record->new(); -# my %subfieldlist=(); - my $prevvalue; # if tag <10 - my $field; # if tag >=10 - for (my $i=0; $i< @$rtags; $i++) { - # rebuild MARC::Record -# warn "0=>".@$rtags[$i].@$rsubfields[$i]." = ".@$rvalues[$i].": "; - if (@$rtags[$i] ne $prevtag) { - if ($prevtag < 10) { - if ($prevvalue) { - if (($prevtag ne '000') && ($prevvalue ne "")) { - $record->add_fields((sprintf "%03s",$prevtag),$prevvalue); - } elsif ($prevvalue ne ""){ - $record->leader($prevvalue); - } - } - } else { - if (($field) && ($field ne "")) { - $record->add_fields($field); - } - } - $indicators{@$rtags[$i]}.=' '; - # skip blank tags, I hope this works - if (@$rtags[$i] eq ''){ - $prevtag = @$rtags[$i]; - undef $field; - next; - } - if (@$rtags[$i] <10) { - $prevvalue= @$rvalues[$i]; - undef $field; - } else { - undef $prevvalue; - if (@$rvalues[$i] eq "") { - undef $field; - } else { - $field = MARC::Field->new( (sprintf "%03s",@$rtags[$i]), substr($indicators{@$rtags[$i]},0,1),substr($indicators{@$rtags[$i]},1,1), @$rsubfields[$i] => @$rvalues[$i]); - } -# warn "1=>".@$rtags[$i].@$rsubfields[$i]." = ".@$rvalues[$i].": ".$field->as_formatted; - } - $prevtag = @$rtags[$i]; - } else { - if (@$rtags[$i] <10) { - $prevvalue=@$rvalues[$i]; - } else { - if (length(@$rvalues[$i])>0) { - $field->add_subfields(@$rsubfields[$i] => @$rvalues[$i]); -# warn "2=>".@$rtags[$i].@$rsubfields[$i]." = ".@$rvalues[$i].": ".$field->as_formatted; - } - } - $prevtag= @$rtags[$i]; - } - } - #} - # the last has not been included inside the loop... do it now ! - #use Data::Dumper; - #warn Dumper($field->{_subfields}); - $record->add_fields($field) if (($field) && $field ne ""); - #warn "HTML2MARC=".$record->as_formatted; - return $record; -} - -=head2 changeEncoding - Change the encoding of a record - -=over 4 - -my ($error, $newrecord) = changeEncoding($record,$format,$flavour,$to_encoding,$from_encoding); - -Changes the encoding of a record - -=over 2 - -C<$record> - the record itself can be in ISO-2709, a MARC::Record object, or MARCXML for now (required) - -C<$format> - MARC or MARCXML (required) - -C<$flavour> - MARC21 or UNIMARC, if MARC21, it will change the leader (optional) [defaults to Koha system preference] - -C<$to_encoding> - the encoding you want the record to end up in (optional) [UTF-8] - -C<$from_encoding> - the encoding the record is currently in (optional, it will probably be able to tell unless there's a problem with the record) - -=back - -FIXME: the from_encoding doesn't work yet - -FIXME: better handling for UNIMARC, it should allow management of 100 field - -FIXME: shouldn't have to convert to and from xml/marc just to change encoding someone needs to re-write MARC::Record's 'encoding' method to actually alter the encoding rather than just changing the leader - -=back - -=cut - -sub changeEncoding { - my ($record,$format,$flavour,$to_encoding,$from_encoding) = @_; - my $newrecord; - my $error; - unless($flavour) {$flavour = C4::Context->preference("marcflavour")}; - unless($to_encoding) {$to_encoding = "UTF-8"}; - - # ISO-2709 Record (MARC21 or UNIMARC) - if (lc($format) =~ /^marc$/o) { - # if we're converting encoding of an ISO2709 file, we need to roundtrip through XML - # because MARC::Record doesn't directly provide us with an encoding method - # It's definitely less than idea and should be fixed eventually - kados - my $marcxml; # temporary storage of MARCXML scalar - ($error,$marcxml) = marc2marcxml($record,$to_encoding,$flavour); - unless ($error) { - ($error,$newrecord) = marcxml2marc($marcxml,$to_encoding,$flavour); - } - - # MARCXML Record - } elsif (lc($format) =~ /^marcxml$/o) { # MARCXML Record - my $marc; - ($error,$marc) = marcxml2marc($record,$to_encoding,$flavour); - unless ($error) { - ($error,$newrecord) = marc2marcxml($record,$to_encoding,$flavour); - } - } else { - $error.="Unsupported record format:".$format; - } - return ($error,$newrecord); -} - -=head1 INTERNAL FUNCTIONS - -=head2 _entity_encode - Entity-encode an array of strings - -=over 4 - -my ($entity_encoded_string) = _entity_encode($string); - -or - -my (@entity_encoded_strings) = _entity_encode(@strings); - -Entity-encode an array of strings - -=back - -=cut - -sub _entity_encode { - my @strings = @_; - my @strings_entity_encoded; - foreach my $string (@strings) { - my $nfc_string = NFC($string); - $nfc_string =~ s/([\x{0080}-\x{fffd}])/sprintf('&#x%X;',ord($1))/sgoe; - push @strings_entity_encoded, $nfc_string; - } - return @strings_entity_encoded; -} - -END { } # module clean-up code here (global destructor) -1; -__END__ - -=back - -=head1 AUTHOR - -Joshua Ferraro - -=head1 MODIFICATIONS - -# $Id: Record.pm,v 1.6.2.1 2007/03/25 23:46:14 tgarip1957 Exp $ - -=cut From tgarip at neu.edu.tr Mon Apr 2 02:52:00 2007 From: tgarip at neu.edu.tr (Tumer Garip) Date: Mon, 02 Apr 2007 00:52:00 +0000 Subject: [Koha-cvs] koha/misc export_marc_biblios.pl build_authorit... [rel_TG] Message-ID: CVSROOT: /sources/koha Module name: koha Branch: rel_TG Changes by: Tumer Garip 07/04/02 00:52:00 Modified files: misc : export_marc_biblios.pl Added files: misc : build_authorities.pl bulkauthimport_marc.pl bulkbiblioimport_marc.pl bulkitemsimport_marc.pl bulkkohaimport_xml.pl export_marc_authorities.pl misc/migration_tools: build_marc_items.pl separate_items_from_biblios.pl Log message: Utilities to upgrade from rel2_2 DB and create new separated biblio+holdings marc db CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/misc/export_marc_biblios.pl?cvsroot=koha&only_with_tag=rel_TG&r1=1.1.2.1&r2=1.1.2.2 http://cvs.savannah.gnu.org/viewcvs/koha/misc/build_authorities.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1 http://cvs.savannah.gnu.org/viewcvs/koha/misc/bulkauthimport_marc.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1 http://cvs.savannah.gnu.org/viewcvs/koha/misc/bulkbiblioimport_marc.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1 http://cvs.savannah.gnu.org/viewcvs/koha/misc/bulkitemsimport_marc.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1 http://cvs.savannah.gnu.org/viewcvs/koha/misc/bulkkohaimport_xml.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1 http://cvs.savannah.gnu.org/viewcvs/koha/misc/export_marc_authorities.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1 http://cvs.savannah.gnu.org/viewcvs/koha/misc/migration_tools/build_marc_items.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1 http://cvs.savannah.gnu.org/viewcvs/koha/misc/migration_tools/separate_items_from_biblios.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1 Patches: Index: export_marc_biblios.pl =================================================================== RCS file: /sources/koha/koha/misc/Attic/export_marc_biblios.pl,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -b -r1.1.2.1 -r1.1.2.2 --- export_marc_biblios.pl 26 Mar 2007 22:38:10 -0000 1.1.2.1 +++ export_marc_biblios.pl 2 Apr 2007 00:51:59 -0000 1.1.2.2 @@ -1,5 +1,5 @@ #!/usr/bin/perl -## This script allows you to export a rel_2_2 bibliographic db in +## This script allows you to export a authorities db in #MARC21 format from the command line. # use strict; Index: build_authorities.pl =================================================================== RCS file: build_authorities.pl diff -N build_authorities.pl --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ build_authorities.pl 2 Apr 2007 00:51:59 -0000 1.1.2.1 @@ -0,0 +1,250 @@ +#!/usr/bin/perl +# script that rebuild thesaurus from biblio table. + +use strict; + +# Koha modules used +use MARC::File::XML; +use MARC::File::USMARC; +use MARC::Record; +use MARC::Batch; +use C4::Context; +use C4::Biblio; +use C4::AuthoritiesMarc; +use Time::HiRes qw(gettimeofday); +use Encode; +use Getopt::Long; +use Data::Dumper; +my ( $input_marc_file, $number) = ('',0); +my ($version, $verbose, $delete, $confirm, $howmany); +GetOptions( + 'h' => \$version, + 'd' => \$delete, + 'v' => \$verbose, + 'c' => \$confirm, +# this $howmany parameter & other commented code was here to enable incremental building of the authorities, but it does not work well. +# 'n:s' => \$howmany, +); + +if ($version || (!$confirm)) { + print <> parameters >> thesaurus structure >> add). It can be whatever you want. NP/CO/NG/TI/NC in CVS refers to UNIMARC french RAMEAU category codes. +* in values a sub-hash with the following values : +\ttaglist : the list of MARC tags using this authority +\tkey : the list of MARC subfields used as key for authority. 2 entries in biblio having the same key will be considered as the same. +\tother : the list of MARC subfields not used as key, but to be copied in authority. +\tauthtag : the field in authority that will be reported in biblio. Remember that all subfields in tag "authtag" will be reported in the same subfield of the biblio (in MARC tags that are in "taglist") + + +Any warning will be stored in the warnings.log file. +EOF +;#' +die; +} + +my $dbh = C4::Context->dbh; + + +my %whattodo = (AUTH => { + # the list of MARC tags using this authority + taglist => "100|700", + # the list of MARC subfields used as key for authority. 2 entries in biblio having the same key will be considered as the same. + key => "a|d", + # the list of MARC subfields not used as key, but to be copied in authority. + other => "", + # the field in authority that will be reported in biblio. Remember that all subfields in tag "authtag" will be reported in the same subfield of the biblio (in MARC tags that are in "taglist") + authtag => "100", + }, + + CORP => {taglist => "110|710", + key => "a|b", + other => "", + authtag => "110", + }, + ESUB => { taglist => "650|651|655|656|657", + key => "a|x|v|y|z", + other => "", + authtag => "150", + }, + TSUB => { taglist => "690", + key => "a|x|v|y|z", + other => "", + authtag => "150", + }, + + ); +my %authorities; + +open WARNING_FILE,">:utf8","warnings.log"; + +my $field_list; +my $category_list; +foreach (keys %whattodo) { + $field_list .= $whattodo{$_}->{taglist}.'|'; + $category_list.= "'".$_."'," +} +chop $field_list; + +if ($delete) { + + print "deleting AUTHORITIES \n"; + $dbh->do("delete from auth_header where authtypecode in ($category_list)"); +# die; +} +my $existing=$dbh->prepare("select authid,authtypecode from auth_header where authtypecode=?"); +my $delsth=$dbh->prepare("delete from auth_header where authid=?"); +my $starttime = gettimeofday; +my $i=1; +my $z=1; +foreach my $DOauthtype (keys %whattodo) { +$existing->execute($DOauthtype); +my $modified; +my $alreadydone; +my $totalskipped; +print "reading authorities.. \n"; +while (my ($authid,$authtypecode) = $existing->fetchrow) { + my $authrecord = XMLgetauthorityhash($dbh,$authid); +my $DOauthtag = $whattodo{$DOauthtype}->{authtag}; +my $DOkey = $whattodo{$DOauthtype}->{key}; + +my $authPrimaryKey; + + foreach my $sub(split '\|',$DOkey) { + my $term=XML_readline_onerecord($authrecord,"","",$DOauthtag,$sub); + $term=~s/^\s+|\s+$//g ; + $term=~ s/(\.|\?|\;|\=|\/|\\|\:|\!|,|\-|\"|\(|\)|\[|\]|\{|\}|\/)//g; + $term=~s/\s\s/\s/g; + $authPrimaryKey .= join('|',$term)."|" if $term; + } + + $authPrimaryKey=uc($authPrimaryKey) if $authPrimaryKey; + if (!$authorities{$DOauthtype}->{$authPrimaryKey} && $authPrimaryKey) { + $authorities{$DOauthtype}->{$authPrimaryKey}->{authid} = $authid; + $authorities{$DOauthtype}->{$authPrimaryKey}->{record} = $authrecord; + $authorities{$DOauthtype}->{$authPrimaryKey}->{modified} = 0; + $z++; + } + +}#while authid +}#foreach authtype in authorities +print "received authorities $z \n"; +$|=1; # flushes output + +my $sth = $dbh->prepare("select biblionumber from biblio"); +$sth->execute; + + +my $modified; +my $alreadydone; +my $totalskipped; +while (my ($biblionumber) = $sth->fetchrow) { + my $record = XMLgetbibliohash($dbh,$biblionumber); + $modified=0; + $i++; + + print " $i in ".(gettimeofday-$starttime)." s\n" unless ($i % 100); + + my $totdone=0; + foreach my $DOauthtype (keys %whattodo) { + my $DOtaglist = $whattodo{$DOauthtype}->{taglist}; + my $DOkey = $whattodo{$DOauthtype}->{key}; + my $DOother = $whattodo{$DOauthtype}->{other}; + my $DOauthtag = $whattodo{$DOauthtype}->{authtag}; + # try to find the authority in + # build the "key" + my $authPrimaryKey; + foreach my $sub(split '\|',$DOkey) { + my $term=XML_readline_onerecord($record,"","",$DOauthtag,$sub); + $term=~s/^\s+|\s+$//g ; + $term=~ s/(\.|\?|\;|\=|\/|\\|\:|\!|,|\-|\"|\(|\)|\[|\]|\{|\}|\/)//g; + $term=~s/\s\s/\s/g; + $authPrimaryKey .= join('|',$term)."|" if $term; + }##foreach $DOkey + + $authPrimaryKey=uc($authPrimaryKey) if $authPrimaryKey; + + + # if authority exist, check it can't be completed by subfields not previously seen. + # otherwise, create if with whatever available. + if ($authorities{$DOauthtype}->{$authPrimaryKey} && $authPrimaryKey) { + # check that the existing authority has all the datas. Otherwise, add them, but don't modify already parsed biblios. + # at the end of the script, all authorities will be updated. So, the "merge_authority.pl" tool can be used to update all biblios. + foreach my $subfieldtotest (split '\|',$DOother) { + my $existsubauth=XML_readline_onerecord($authorities{$DOauthtype}->{$authPrimaryKey}->{record},"","",$DOauthtag,$subfieldtotest); + my $existsub=XML_readline_onerecord($record,"","",$DOauthtag,$subfieldtotest); + $existsub=Encode::encode('utf8',$existsub); + $existsubauth=Encode::encode('utf8',$existsubauth); + if ($existsubauth ne $existsub && $existsub && $existsubauth) { + print WARNING_FILE "========\nERROR ON $i $subfieldtotest authorities seems to differ, can't choose between : \n".$existsubauth." \n====== AND ======\n ".$existsub."\n=======\n"; + print "W"; + } + # + if (!$existsubauth && $existsub) { + XML_writeline($authorities{$DOauthtype}->{$authPrimaryKey}->{record},"",$existsub,"",$DOauthtag,$subfieldtotest); + + $authorities{$DOauthtype}->{$authPrimaryKey}->{modified} = 1; + } + + }#each subfieltotest + } elsif( $authPrimaryKey) { + my $authrecord = " nz||a22 o||4500";##dummyrecord + $authrecord=XML_xml2hash_onerecord($authrecord); + my $authfield; + foreach my $sub (split '\|',$DOkey) { + my $existsub=XML_readline_onerecord($record,"","",$DOauthtag,$sub); + $existsub=Encode::encode('utf8',$existsub); + XML_writeline($authrecord,"",$existsub,"",$DOauthtag,$sub) if $existsub; + } + foreach my $sub(split '\|',$DOother) { + my $existsub=XML_readline_onerecord($record,"","",$DOauthtag,$sub); + $existsub=Encode::encode('utf8',$existsub); + XML_writeline($authrecord,"",$existsub,"",$DOauthtag,$sub) if $existsub; + + } + my $authid = AUTHaddauthority($dbh,$authrecord,'',$DOauthtype); + print "AUTHORITY $authid added \n"; + $authorities{$DOauthtype}->{$authPrimaryKey}->{authid} = $authid; + $authorities{$DOauthtype}->{$authPrimaryKey}->{record} = $authrecord; + $authorities{$DOauthtype}->{$authPrimaryKey}->{modified} = 0; + XML_writeline($record,"authid",$authid,"biblios"); + $modified++; + } + + + } + +# +# NC +# +# OK, done, now store modified biblio if it has been modified + if ($modified) { + NEWnewbiblio($dbh,$record); + print "$modified"; + } else { + # if $totalskipped is not null, we are in a biblio that has no authorities entry, but inside an already done part of the job + print "*"; + } +} + +# +# now, parse authorities & modify them if they have been modified/completed by a subfield not existing on the 1st biblio using this authority. +# +foreach my $authtype (keys %whattodo) { + foreach my $authentry (keys %{$authorities{$authtype}}) { + print "AUTH : $authentry\n" if $authorities{$authtype}->{$authentry}->{modified}; + + AUTHaddauthority($dbh,$authorities{$authtype}->{$authentry}->{record},$authorities{$authtype}->{$authentry}->{authid},$authtype) if $authorities{$authtype}->{$authentry}->{modified}; + } +} +# +my $timeneeded = gettimeofday - $starttime; +print "$i entries done in $timeneeded seconds (".($i/$timeneeded)." per second)\n"; +close WARNING_FILE; \ No newline at end of file Index: bulkauthimport_marc.pl =================================================================== RCS file: bulkauthimport_marc.pl diff -N bulkauthimport_marc.pl --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ bulkauthimport_marc.pl 2 Apr 2007 00:51:59 -0000 1.1.2.1 @@ -0,0 +1,82 @@ +#!/usr/bin/perl +# small script that import an iso2709 file into koha 2.0 + +use strict; + +# Koha modules used +use MARC::File::USMARC; +use MARC::File::XML; +use MARC::Record; +use MARC::Batch; +use C4::Biblio; +use C4::Context; +use C4::AuthoritiesMarc; +use Time::HiRes qw(gettimeofday); + +use Getopt::Long; +my $input_marc_file =""); +my ($version, $delete, $test_parameter,$auth, $verbose); +GetOptions( + 'file:s' => \$input_marc_file, + 'h:s' =>\$version, + 'd' => \$delete, + 't' => \$test_parameter, + 'auth:s' => \$auth, + 'v:s' => \$verbose, +); + +if ($version || ($input_marc_file eq '')) { + print <dbh; + +if ($delete) { + print "deleting authorities\n"; + $dbh->do("truncate table auth_header"); + +} +if ($test_parameter) { + print "TESTING MODE ONLY\n DOING NOTHING\n===============\n"; +} + +my $starttime = gettimeofday; +my $batch = MARC::Batch->new( 'USMARC', $input_marc_file ); +$batch->warnings_off(); +$batch->strict_off(); +my $i=0; +while ( my $record = $batch->next() ) { + $i++; +my $xml=MARC::File::XML::record($record); +my $xmlhash=XML_xml2hash_onerecord($xml); + $auth=XML_readline_onerecord($xmlhash,"authtypecode","authorities") unless $auth; + my $authid=XML_readline_onerecord($xmlhash,"authid","authorities") + if (!$auth||$auth eq""){ + print "Records do not have authoritytype define with -auth parameter"; + die; + } + ## now, create authority with AUTHadd call. + unless ($test_parameter) { + $authid = AUTHaddauthority($dbh,$xmlhash,$authid,$authtypecode); + warn "ADDED authority NB $authid in DB\n" if $verbose; + } +} +my $timeneeded = gettimeofday - $starttime; +print "$i MARC record done in $timeneeded seconds"; Index: bulkbiblioimport_marc.pl =================================================================== RCS file: bulkbiblioimport_marc.pl diff -N bulkbiblioimport_marc.pl --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ bulkbiblioimport_marc.pl 2 Apr 2007 00:51:59 -0000 1.1.2.1 @@ -0,0 +1,76 @@ +#!/usr/bin/perl +# small script that import an iso2709 file into koha 2.0 + +use strict; + +# Koha modules used +use MARC::File::USMARC; +use MARC::File::XML; +use MARC::Record; +use MARC::Batch; +use C4::Biblio; +use C4::Context; +use Time::HiRes qw(gettimeofday); + +use Getopt::Long; +my ($input_marc_file= ""); +my ($version, $delete, $test_parameter,$frameworkcode, $verbose); +GetOptions( + 'file:s' => \$input_marc_file, + 'h:s' =>\$version, + 'd' => \$delete, + 't' => \$test_parameter, + 'frame:s' => \$frameworkcode, + 'v:s' => \$verbose, +); + +if ($version || ($input_marc_file eq '')) { + print <dbh; + +if ($delete) { + print "deleting biblio\n"; + $dbh->do("truncate table biblio"); + +} +if ($test_parameter) { + print "TESTING MODE ONLY\n DOING NOTHING\n===============\n"; +} + +my $starttime = gettimeofday; +my $batch = MARC::Batch->new( 'USMARC', $input_marc_file ); +$batch->warnings_off(); +$batch->strict_off(); +my $i=0; +while ( my $record = $batch->next() ) { + $i++; +my $xml=MARC::File::XML::record($record); +my $xmlhash=XML_xml2hash_onerecord($xml); + + ## now, create authority with NEWnew call. + unless ($test_parameter) { + my $biblionumber =NEWnewbiblio($dbh,$xmlhash,$frameworkcode); + warn "ADDED biblionumber NB $biblionumber in DB\n" if $verbose; + } +} +my $timeneeded = gettimeofday - $starttime; +print "$i MARC record done in $timeneeded seconds"; Index: bulkitemsimport_marc.pl =================================================================== RCS file: bulkitemsimport_marc.pl diff -N bulkitemsimport_marc.pl --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ bulkitemsimport_marc.pl 2 Apr 2007 00:51:59 -0000 1.1.2.1 @@ -0,0 +1,78 @@ +#!/usr/bin/perl +# small script that import an iso2709 file into koha 2.0 + +use strict; + +# Koha modules used +use MARC::File::USMARC; +use MARC::File::XML; +use MARC::Record; +use MARC::Batch; +use C4::Biblio; +use C4::Context; +use Time::HiRes qw(gettimeofday); + +use Getopt::Long; +my $input_marc_file = ''; +my ($version, $delete, $test_parameter, $verbose); +GetOptions( + 'file:s' => \$input_marc_file, + 'h:s' =>\$version, + 'd' => \$delete, + 't' => \$test_parameter, + 'v:s' => \$verbose, +); + +if ($version || ($input_marc_file eq '')) { + print <dbh; + +if ($delete) { + print "deleting items\n"; + $dbh->do("truncate table items"); + +} +if ($test_parameter) { + print "TESTING MODE ONLY\n DOING NOTHING\n===============\n"; +} + +my $starttime = gettimeofday; +my $batch = MARC::Batch->new( 'USMARC', $input_marc_file ); +$batch->warnings_off(); +$batch->strict_off(); +my $i=0; +while ( my $record = $batch->next() ) { + $i++; +my $xml=MARC::File::XML::record($record); +my $xmlhash=XML_xml2hash_onerecord($xml); +my $biblionumber=XML_readline_onerecord($xmlhash,"biblionumber","holdings"); + if (!$biblionumber){ + print "NO biblionumber in record cannot continue"; + die; + } + ## now, create authority with NEWnew call. + unless ($test_parameter) { + my $itemnumber = NEWnewitem($dbh,$xmlhash,$biblionumber); + warn "ADDED itemnumber NB $itemnumber in DB\n" if $verbose; + } +} +my $timeneeded = gettimeofday - $starttime; +print "$i MARC record done in $timeneeded seconds"; Index: bulkkohaimport_xml.pl =================================================================== RCS file: bulkkohaimport_xml.pl diff -N bulkkohaimport_xml.pl --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ bulkkohaimport_xml.pl 2 Apr 2007 00:51:59 -0000 1.1.2.1 @@ -0,0 +1,89 @@ +#!/usr/bin/perl +# small script that import an iso2709 file into koha 2.0 + +use strict; + +# Koha modules used + +use C4::Biblio; +use C4::Context; +use Time::HiRes qw(gettimeofday); + +use Getopt::Long; +my $input_marc_file= ""; +my ($version, $delete, $test_parameter,$frameworkcode, $verbose); +GetOptions( + 'file:s' => \$input_marc_file, + 'h:s' =>\$version, + 'd:s' => \$delete, + 't' => \$test_parameter, + 'frame:s' => \$frameworkcode, + 'v:s' => \$verbose, +); + +if ($version || ($input_marc_file eq '')) { + print <dbh; + +if ($delete) { + print "deleting biblio\n"; + $dbh->do("truncate table biblio"); + print "deleting items\n"; + $dbh->do("truncate table items"); + +} +if ($test_parameter) { + print "TESTING MODE ONLY\n DOING NOTHING\n===============\n"; +} + +my $starttime = gettimeofday; +open INPUT, "<:utf8","$input_marc_file" || print "no infile $input_marc_file"; +my $i=0; +my $xml; + while ( ) { +if (m/\/ || m/\<\/kohacollection\>/){next;} + + $xml.=$_; + if (m/\<\/koharecord\>/){ + $xml=createrecord($xml); + }#koharecord +}#while +close(INPUT); +my $timeneeded = gettimeofday - $starttime; +print "$i KOHA records done in $timeneeded seconds"; + +sub createrecord{ +my $xmlin=shift; +my $xmlhash=XML_xml2hash($xmlin); + my ($biblio, at items)=XML_separate($xmlhash); + ## now, create biblios with NEWnew call. + unless ($test_parameter) { + $i++; + my $biblionumber = NEWnewbiblio($dbh,$biblio,$frameworkcode); + print "ADDED biblionumber NB $biblionumber in DB\n" if $verbose; + foreach my $item (@items){ + my $itemnumber = NEWnewitem($dbh,$item,$biblionumber); + print "ADDED itemnumber NB $itemnumber in DB\n" if $verbose; + } + }##test + return ""; +} \ No newline at end of file Index: export_marc_authorities.pl =================================================================== RCS file: export_marc_authorities.pl diff -N export_marc_authorities.pl --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ export_marc_authorities.pl 2 Apr 2007 00:51:59 -0000 1.1.2.1 @@ -0,0 +1,34 @@ +#!/usr/bin/perl +## This script allows you to export a authorities db in +#MARC21 format from the command line. +# +use strict; + +use C4::Auth; +use MARC::Record; +use MARC::File::USMARC; +use MARC::File::XML; +use Getopt::Long; +my $out_marc_file; + +GetOptions( + 'file:s' => \$out_marc_file, + +); +my $record; +open(OUT,">:utf8", $out_marc_file) or die $!; + + +my $dbh=C4::Context->dbh; + my $sth; + $sth=$dbh->prepare("select marcxml from auth_header order by authid "); + $sth->execute(); + + while (my ($xml) = $sth->fetchrow) { + eval{ + $record=MARC::Record->new_from_xml( $xml,"UTF-8"); + }; + if ($@){next;} + print OUT $record->as_usmarc; + } +close(OUT); Index: migration_tools/build_marc_items.pl =================================================================== RCS file: migration_tools/build_marc_items.pl diff -N migration_tools/build_marc_items.pl --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ migration_tools/build_marc_items.pl 2 Apr 2007 00:51:59 -0000 1.1.2.1 @@ -0,0 +1,112 @@ +#!/usr/bin/perl +#----------------------------------- +# Script Name: build_marc_items.pl +# Script Version: 4.1.0 +# Date: 01/04/2007 +##I Utility function to export items from a rel2_2 as separete marc records +##Writen by Tumer Garip tgarip at neu.edu.tr + + + +use strict; + +use C4::Context; +use C4::Biblio; +use MARC::Record; +use MARC::File::USMARC; +use MARC::Field; +my $dbh=C4::Context->dbh; +use Time::HiRes qw(gettimeofday); +use Getopt::Long; +my $outitems; +GetOptions( + 'outitems:s' => \$outitems, +); +if (!$outitems ) { + print <'001', biblionumber => '004', + multivolumepart => '952i', + barcode => '952p', + booksellerid =>'952e', dateaccessioned => '008', + homebranch => '952a', holdingbranch => '952b', + price => '952u', replacementprice => '952v', + replacementpricedate =>'952w' , datelastseen => '005', + multivolume => '952j', stack =>'952f', + itemlost => '9521', wthdrawn =>'9520', + paidfor => '952r', itemnotes => '952z', + itemcallnumber =>'952o', notforloan => '952y', + location =>'952g', Cutterextra =>'952m', + ); + +open(OUTITEMS,">:utf8","$outitems") ; +my $starttime = gettimeofday; +my $sth=$dbh->prepare("SELECT * FROM items order by itemnumber"); +$sth->execute; + + +my $b=0; +my $timeneeded; +while (my $data = $sth->fetchrow_hashref) { +my $record=MARC::Record->new(); +my %prevtag; +my $addedfield; +foreach my $key (keys %mapping_list){ + if($data->{$key}){ +my $newtag=substr($mapping_list{$key},0,3); +my $newsub=substr($mapping_list{$key},3,1); + if ($key eq 'datelastseen'){ + my $datelastseen=$data->{$key}; + $datelastseen=~s /\-//g; + $datelastseen.="000000.0"; ###MARC field 005 requires this + $data->{$key}=$datelastseen; + }elsif($key eq 'dateaccessioned'){ + my $dateaccessioned=$data->{$key}; + $dateaccessioned=~s /\-//g; + $dateaccessioned=substr($dateaccessioned,2,6); + $dateaccessioned.="s xxu||||| |||| 00| 0 xxx d"; + $data->{$key}=$dateaccessioned;## MARC 008 requires this + } + + if ($newsub && !$prevtag{$newtag}){ + $addedfield=MARC::Field->new($newtag,"","",$newsub=>$data->{$key}); + $record->insert_fields_ordered($addedfield) ; + }elsif (!$newsub && !$prevtag{$newtag}){ + $addedfield=MARC::Field->new($newtag,$data->{$key}); + $record->insert_fields_ordered($addedfield) ; + }elsif($prevtag{$newtag}){ + $record->field($newtag)->update($newsub=>$data->{$key}); + }## a subfield exists + + $prevtag{$newtag}=1; + } + + + +}##foreach $key +$b++; +## Now print out +$record->leader(' nx||a22 1i|4500'); +print OUTITEMS $record->as_usmarc; +}##while + +close(OUTITEMS); + + $timeneeded = gettimeofday - $starttime ; + print "$b items in $timeneeded s\n" ; + + +$dbh->disconnect(); Index: migration_tools/separate_items_from_biblios.pl =================================================================== RCS file: migration_tools/separate_items_from_biblios.pl diff -N migration_tools/separate_items_from_biblios.pl --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ migration_tools/separate_items_from_biblios.pl 2 Apr 2007 00:51:59 -0000 1.1.2.1 @@ -0,0 +1,63 @@ +#!/usr/bin/perl +# script that separate old KOHA rel2 marc records into biblios and holdings records +# Written by TG on 10/04/2006 +use strict; + +# Koha modules used + +use C4::Context; +use C4::Biblio; +use MARC::Record; +use MARC::File::USMARC; +use MARC::Batch; +use Time::HiRes qw(gettimeofday); +use Getopt::Long; +my ($outbiblios,$input_marc_file); +GetOptions( + 'file:s' => \$input_marc_file, + 'outbiblio:s' => \$outbiblios, + +); +if ($outbiblios || ($input_marc_file eq '')) { + print <$outbiblio") ; +my $starttime = gettimeofday; +my $timeneeded; + +my $i=0; +my $batch = MARC::Batch->new( 'USMARC', $input_marc_file ); +$batch->warnings_off(); +$batch->strict_off(); +my $i=0; + +while ( my $record = $batch->next() ) { +my @itemfields=$record->field('$itemtag); + foreach my $itemfield(@itemfields){ + $record->delete_field($itemfield); + } +$i++; +print OUTBIBLIO $record; +} +close OUTBIBLIO; +$timeneeded = gettimeofday - $starttime ; + warn "$i records in $timeneeded s\n" ; + +END; From laurenthdl at alinto.com Mon Apr 2 15:57:49 2007 From: laurenthdl at alinto.com (Henri-Damien LAURENT) Date: Mon, 02 Apr 2007 13:57:49 +0000 Subject: [Koha-cvs] koha/C4 Date.pm [rel_2_2] Message-ID: CVSROOT: /sources/koha Module name: koha Branch: rel_2_2 Changes by: Henri-Damien LAURENT 07/04/02 13:57:49 Modified files: C4 : Date.pm Log message: Adding a check if date is already iso in format_date_in_iso CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/C4/Date.pm?cvsroot=koha&only_with_tag=rel_2_2&r1=1.13.4.5&r2=1.13.4.6 Patches: Index: Date.pm =================================================================== RCS file: /sources/koha/koha/C4/Date.pm,v retrieving revision 1.13.4.5 retrieving revision 1.13.4.6 diff -u -b -r1.13.4.5 -r1.13.4.6 --- Date.pm 8 Feb 2007 09:54:46 -0000 1.13.4.5 +++ Date.pm 2 Apr 2007 13:57:49 -0000 1.13.4.6 @@ -100,7 +100,9 @@ { return ""; } - + if (check_whether_iso($olddate)){ + return $olddate; + } else { my $dateformat = get_date_format(); my ($year,$month,$day); my @date; @@ -142,5 +144,14 @@ $newdate = sprintf("%04d-%02d-%02d",$date[0],$date[1],$date[2]); return $newdate; + } } +sub check_whether_iso +{ + my $olddate = shift; + my @olddate= split /\-/,$olddate ; + return 1 if (length($olddate[0])==4 && length($olddate[1])<=2 && length($olddate[2])<=2); + return 0; +} + 1; From jmf at liblime.com Mon Apr 2 17:20:53 2007 From: jmf at liblime.com (Joshua Ferraro) Date: Mon, 02 Apr 2007 15:20:53 +0000 Subject: [Koha-cvs] koha/opac opac-reserve.pl [dev_week] Message-ID: CVSROOT: /sources/koha Module name: koha Branch: dev_week Changes by: Joshua Ferraro 07/04/02 15:20:53 Modified files: opac : opac-reserve.pl Log message: As requested by NPL, changing the redirect in dev_week's opac-reserve.pl from this: Line 246 print $query->redirect("/cgi-bin/koha/opac-user.pl"); To this: print $query->redirect("/cgi-bin/koha/opac-user.pl?display=reserves"); ...so that patrons are redirected to their list of reserves instead of their list of checkouts CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-reserve.pl?cvsroot=koha&only_with_tag=dev_week&r1=1.22.2.9.2.3&r2=1.22.2.9.2.4 Patches: Index: opac-reserve.pl =================================================================== RCS file: /sources/koha/koha/opac/opac-reserve.pl,v retrieving revision 1.22.2.9.2.3 retrieving revision 1.22.2.9.2.4 diff -u -b -r1.22.2.9.2.3 -r1.22.2.9.2.4 --- opac-reserve.pl 9 Oct 2006 13:22:24 -0000 1.22.2.9.2.3 +++ opac-reserve.pl 2 Apr 2007 15:20:53 -0000 1.22.2.9.2.4 @@ -243,7 +243,7 @@ if ($query->param('all')) { CreateReserve(undef,$branch,$borrowernumber,$biblionumber,'a', undef, $rank,'',$title); } - print $query->redirect("/cgi-bin/koha/opac-user.pl"); + print $query->redirect("/cgi-bin/koha/opac-user.pl?display=reserves"); } else { # Here we check that the borrower can actually make reserves Stage 1. my $noreserves = 0; From btoumi at ouestprovence.fr Tue Apr 3 16:21:56 2007 From: btoumi at ouestprovence.fr (Bruno Toumi) Date: Tue, 03 Apr 2007 14:21:56 +0000 Subject: [Koha-cvs] koha/koha-tmpl/intranet-tmpl/prog/en catalogue/... Message-ID: CVSROOT: /cvsroot/koha Module name: koha Changes by: Bruno Toumi 07/04/03 14:21:56 Modified files: koha-tmpl/intranet-tmpl/prog/en/catalogue: detail.tmpl koha-tmpl/intranet-tmpl/prog/en/includes: action-catalogue.inc Log message: add security when u delete biblio : u must delete linked items before delete biblio CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/catalogue/detail.tmpl?cvsroot=koha&r1=1.5&r2=1.6 http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/includes/action-catalogue.inc?cvsroot=koha&r1=1.3&r2=1.4 Patches: Index: catalogue/detail.tmpl =================================================================== RCS file: /cvsroot/koha/koha/koha-tmpl/intranet-tmpl/prog/en/catalogue/detail.tmpl,v retrieving revision 1.5 retrieving revision 1.6 diff -u -b -r1.5 -r1.6 --- catalogue/detail.tmpl 11 Mar 2007 21:08:12 -0000 1.5 +++ catalogue/detail.tmpl 3 Apr 2007 14:21:56 -0000 1.6 @@ -216,11 +216,25 @@ function Dopop(link) { newin=window.open(link,'popup','width=500,height=400,toolbar=false,scrollbars=yes'); } -function confirm_deletion() { - var is_confirmed = confirm('Are you sure you want to delete this biblio?'); +function confirm_deletion(count) { + var is_confirmed; + if (count>0){ + is_confirmed= alert('you have [ '+ count +' ] item(s) linked \n you must delete all items before delete this biblio'); + } + else{ + is_confirmed= confirm('Are you sure you want to delete this biblio? '); + } + + if (is_confirmed) { + if (count>0){ +// window.location="/cgi-bin/koha/catalogue/detail.pl?biblionumber="; + } + else{ window.location="/cgi-bin/koha/cataloguing/addbiblio.pl?op=delete&biblionumber="; } + + } } Index: includes/action-catalogue.inc =================================================================== RCS file: /cvsroot/koha/koha/koha-tmpl/intranet-tmpl/prog/en/includes/action-catalogue.inc,v retrieving revision 1.3 retrieving revision 1.4 diff -u -b -r1.3 -r1.4 --- includes/action-catalogue.inc 10 Mar 2007 01:53:23 -0000 1.3 +++ includes/action-catalogue.inc 3 Apr 2007 14:21:56 -0000 1.4 @@ -10,7 +10,7 @@ "> Edit item - + )"> Delete From alaurin at ouestprovence.fr Tue Apr 3 17:04:32 2007 From: alaurin at ouestprovence.fr (LAURIN arnaud) Date: Tue, 03 Apr 2007 15:04:32 +0000 Subject: [Koha-cvs] koha/circ branchreserves.pl Message-ID: CVSROOT: /sources/koha Module name: koha Changes by: LAURIN arnaud 07/04/03 15:04:30 Modified files: circ : branchreserves.pl Log message: bugfixing for displaying the maxpicking delays for reservations, now the method of date works is using Add_Delta_Days and not delta year and month now the system working CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/circ/branchreserves.pl?cvsroot=koha&r1=1.4&r2=1.5 Patches: Index: branchreserves.pl =================================================================== RCS file: /sources/koha/koha/circ/branchreserves.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -b -r1.4 -r1.5 --- branchreserves.pl 9 Mar 2007 14:34:31 -0000 1.4 +++ branchreserves.pl 3 Apr 2007 15:04:30 -0000 1.5 @@ -1,6 +1,6 @@ #!/usr/bin/perl -# $Id: branchreserves.pl,v 1.4 2007/03/09 14:34:31 tipaul Exp $ +# $Id: branchreserves.pl,v 1.5 2007/04/03 15:04:30 alaurin Exp $ # Copyright 2000-2002 Katipo Communications # @@ -30,7 +30,7 @@ use Date::Calc qw( Today - Add_Delta_YM + Add_Delta_Days Date_to_Days ); use C4::Reserves2; @@ -123,8 +123,8 @@ my ( $waiting_year, $waiting_month, $waiting_day ) = split /-/, $num->{'waitingdate'}; ( $waiting_year, $waiting_month, $waiting_day ) = - Add_Delta_YM( $waiting_year, $waiting_month, $waiting_day, - C4::Context->preference('ReservesMaxPickUpDelay'), 0 ); + Add_Delta_Days( $waiting_year, $waiting_month, $waiting_day, + C4::Context->preference('ReservesMaxPickUpDelay')); my $calcDate = Date_to_Days( $waiting_year, $waiting_month, $waiting_day ); my $today = Date_to_Days(&Today); my $warning = ( $today > $calcDate ); From alaurin at ouestprovence.fr Tue Apr 3 17:41:36 2007 From: alaurin at ouestprovence.fr (LAURIN arnaud) Date: Tue, 03 Apr 2007 15:41:36 +0000 Subject: [Koha-cvs] koha/circ currenttransfers.pl waitingreservestr... Message-ID: CVSROOT: /sources/koha Module name: koha Changes by: LAURIN arnaud 07/04/03 15:41:36 Modified files: circ : currenttransfers.pl waitingreservestransfers.pl Log message: bugfixing of warnings in current transfers and waitingreservestranfers same bugfixing as branchreserves CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/circ/currenttransfers.pl?cvsroot=koha&r1=1.4&r2=1.5 http://cvs.savannah.gnu.org/viewcvs/koha/circ/waitingreservestransfers.pl?cvsroot=koha&r1=1.6&r2=1.7 Patches: Index: currenttransfers.pl =================================================================== RCS file: /sources/koha/koha/circ/currenttransfers.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -b -r1.4 -r1.5 --- currenttransfers.pl 9 Mar 2007 14:34:32 -0000 1.4 +++ currenttransfers.pl 3 Apr 2007 15:41:36 -0000 1.5 @@ -1,6 +1,6 @@ #!/usr/bin/perl -# $Id: currenttransfers.pl,v 1.4 2007/03/09 14:34:32 tipaul Exp $ +# $Id: currenttransfers.pl,v 1.5 2007/04/03 15:41:36 alaurin Exp $ # Copyright 2000-2002 Katipo Communications # @@ -30,7 +30,7 @@ use C4::Interface::CGI::Output; use Date::Calc qw( Today - Add_Delta_YM + Add_Delta_Days Date_to_Days ); @@ -82,8 +82,8 @@ $num->{'datesent'}; $sent_day = ( split " ", $sent_day )[0]; ( $sent_year, $sent_month, $sent_day ) = - Add_Delta_YM( $sent_year, $sent_month, $sent_day, - C4::Context->preference('TransfersMaxDaysWarning'), 0 ); + Add_Delta_Days( $sent_year, $sent_month, $sent_day, + C4::Context->preference('TransfersMaxDaysWarning')); my $calcDate = Date_to_Days( $sent_year, $sent_month, $sent_day ); my $today = Date_to_Days(&Today); my $warning = ( $today > $calcDate ); Index: waitingreservestransfers.pl =================================================================== RCS file: /sources/koha/koha/circ/waitingreservestransfers.pl,v retrieving revision 1.6 retrieving revision 1.7 diff -u -b -r1.6 -r1.7 --- waitingreservestransfers.pl 9 Mar 2007 14:34:32 -0000 1.6 +++ waitingreservestransfers.pl 3 Apr 2007 15:41:36 -0000 1.7 @@ -1,6 +1,6 @@ #!/usr/bin/perl -# $Id: waitingreservestransfers.pl,v 1.6 2007/03/09 14:34:32 tipaul Exp $ +# $Id: waitingreservestransfers.pl,v 1.7 2007/04/03 15:41:36 alaurin Exp $ # Copyright 2000-2002 Katipo Communications # @@ -29,7 +29,7 @@ use C4::Circulation::Circ2; use Date::Calc qw( Today - Add_Delta_YM + Add_Delta_Days Date_to_Days ); use C4::Koha; @@ -99,8 +99,8 @@ my ( $reserve_year, $reserve_month, $reserve_day ) = split /-/, $num->{'reservedate'}; ( $reserve_year, $reserve_month, $reserve_day ) = - Add_Delta_YM( $reserve_year, $reserve_month, $reserve_day, - C4::Context->preference('ReservesMaxPickUpDelay'), 0 ); + Add_Delta_Days( $reserve_year, $reserve_month, $reserve_day, + C4::Context->preference('ReservesMaxPickUpDelay')); my $calcDate = Date_to_Days( $reserve_year, $reserve_month, $reserve_day ); my $today = Date_to_Days(&Today); From tgarip at neu.edu.tr Tue Apr 3 20:23:14 2007 From: tgarip at neu.edu.tr (Tumer Garip) Date: Tue, 03 Apr 2007 18:23:14 +0000 Subject: [Koha-cvs] koha/C4 Barcodes/PrinterConfig.pm Biblio.pm [rel_TG] Message-ID: CVSROOT: /sources/koha Module name: koha Branch: rel_TG Changes by: Tumer Garip 07/04/03 18:23:14 Modified files: C4/Barcodes : PrinterConfig.pm C4 : Biblio.pm Log message: Bug fixing on barcode printing CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/C4/Barcodes/PrinterConfig.pm?cvsroot=koha&only_with_tag=rel_TG&r1=1.4.2.1&r2=1.4.2.2 http://cvs.savannah.gnu.org/viewcvs/koha/C4/Biblio.pm?cvsroot=koha&only_with_tag=rel_TG&r1=1.187.2.2&r2=1.187.2.3 Patches: Index: Barcodes/PrinterConfig.pm =================================================================== RCS file: /sources/koha/koha/C4/Barcodes/PrinterConfig.pm,v retrieving revision 1.4.2.1 retrieving revision 1.4.2.2 diff -u -b -r1.4.2.1 -r1.4.2.2 --- Barcodes/PrinterConfig.pm 26 Mar 2007 02:19:20 -0000 1.4.2.1 +++ Barcodes/PrinterConfig.pm 3 Apr 2007 18:23:13 -0000 1.4.2.2 @@ -149,7 +149,7 @@ # Calculates the next label position and return that label number my $nextIndexX = $labelNum % @positionsForX; my $nextIndexY = $labelNum % @positionsForY; - if ($labelNum== 0) { + if (!$gfxObject) { $page = $pdf->page; $page->mediabox($pageType); $gfxObject = $page->gfx; Index: Biblio.pm =================================================================== RCS file: /sources/koha/koha/C4/Biblio.pm,v retrieving revision 1.187.2.2 retrieving revision 1.187.2.3 diff -u -b -r1.187.2.2 -r1.187.2.3 --- Biblio.pm 25 Mar 2007 23:46:14 -0000 1.187.2.2 +++ Biblio.pm 3 Apr 2007 18:23:14 -0000 1.187.2.3 @@ -960,9 +960,9 @@ # add the item to zebra it will add the biblio as well!!! ZEBRAop( $dbh, $biblionumber,"specialUpdate","biblioserver" ); -return $itemnumber; -}## added new item +}## added new item +return $itemnumber; } @@ -1219,10 +1219,18 @@ if ($server eq "biblioserver"){ ($marcxml) =ZEBRA_readyXML($dbh,$biblionumber); }elsif($server eq "authorityserver"){ - $marcxml =C4::AuthoritiesMarc::XMLgetauthority($dbh,$biblionumber); + $marcxml =C4::AuthoritiesMarc::ZEBRA_readyauthority($dbh,$biblionumber); } ZEBRAopserver($marcxml,$op,$server,$biblionumber); ZEBRAopcommit($server); +## If a delete operation delete the SQL DB as well + if ($op eq "recordDelete" ){ + if ($server eq "biblioserver"){ + ZEBRAdelbiblio($dbh,$biblionumber); + }elsif ($server eq "authorityserver"){ + ZEBRAdelauthority($dbh,$biblionumber); + } + } }else{ my $sth=$dbh->prepare("insert into zebraqueue (biblio_auth_number ,server,operation) values(?,?,?)"); $sth->execute($biblionumber,$server,$op); From tgarip at neu.edu.tr Tue Apr 3 20:24:49 2007 From: tgarip at neu.edu.tr (Tumer Garip) Date: Tue, 03 Apr 2007 18:24:49 +0000 Subject: [Koha-cvs] koha bookshelves/addbookbybiblionumber.pl koha-... [rel_TG] Message-ID: CVSROOT: /sources/koha Module name: koha Branch: rel_TG Changes by: Tumer Garip 07/04/03 18:24:49 Added files: bookshelves : addbookbybiblionumber.pl koha-tmpl/intranet-tmpl/default/en/bookshelves: addbookbybiblionumber.tmpl Log message: CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/bookshelves/addbookbybiblionumber.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.5.2.2 http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/default/en/bookshelves/addbookbybiblionumber.tmpl?cvsroot=koha&only_with_tag=rel_TG&rev=1.6.2.1 Patches: Index: bookshelves/addbookbybiblionumber.pl =================================================================== RCS file: bookshelves/addbookbybiblionumber.pl diff -N bookshelves/addbookbybiblionumber.pl --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ bookshelves/addbookbybiblionumber.pl 3 Apr 2007 18:24:48 -0000 1.5.2.2 @@ -0,0 +1,126 @@ +#!/usr/bin/perl +#script to provide bookshelf management +# WARNING: This file uses 4-character tabs! +# +# $Header: /sources/koha/koha/bookshelves/addbookbybiblionumber.pl,v 1.5.2.2 2007/04/03 18:24:48 tgarip1957 Exp $ +# +# Copyright 2000-2002 Katipo Communications +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it under the +# terms of the GNU General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) any later +# version. +# +# Koha is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, +# Suite 330, Boston, MA 02111-1307 USA + +use strict; +use C4::Search; +use C4::Biblio; +use CGI; +use C4::BookShelves; +use C4::Circulation::Circ2; +use C4::Auth; +use C4::Interface::CGI::Output; +use C4::Context; +my $dbh=C4::Context->dbh; +my $env; +my $query = new CGI; +my $biblionumber = $query->param('biblionumber'); +my $shelfnumber = $query->param('shelfnumber'); +my $newbookshelf = $query->param('newbookshelf'); +my $category = $query->param('category'); + +my ($template, $loggedinuser, $cookie) += get_template_and_user({template_name => "bookshelves/addbookbybiblionumber.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {catalogue => 1}, + }); + +my $x; # for trash +($x,$x,$shelfnumber) = AddShelf('',$newbookshelf,$loggedinuser,$category) if $newbookshelf; + +if ($shelfnumber) { + &AddToShelfFromBiblio( $biblionumber, $shelfnumber); + print "Content-Type: text/html\n\n"; + exit; +} else { + + my ( $bibliohash ) = XMLgetbibliohash($dbh,$biblionumber); + my $biblios=XMLmarc2koha_onerecord($dbh,$bibliohash,"biblios"); + my ($shelflist) = GetShelves($loggedinuser,3); + my @shelvesloop; + my %shelvesloop; + foreach my $element (sort keys %$shelflist) { + push (@shelvesloop, $element); + $shelvesloop{$element} = $shelflist->{$element}->{'shelfname'}; + } + + my $CGIbookshelves=CGI::scrolling_list( -name => 'shelfnumber', + -values => \@shelvesloop, + -labels => \%shelvesloop, + -size => 1, + -tabindex=>'', + -multiple => 0 ); + + $template->param(biblionumber => $biblionumber, + title => $biblios->{'title'}, + author => $biblios->{'author'}, + CGIbookshelves => $CGIbookshelves, + intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), + intranetstylesheet => C4::Context->preference("intranetstylesheet"), + IntranetNav => C4::Context->preference("IntranetNav"), + ); + + output_html_with_http_headers $query, $cookie, $template->output; +} +# $Log: addbookbybiblionumber.pl,v $ +# Revision 1.5.2.2 2007/04/03 18:24:48 tgarip1957 +# *** empty log message *** +# +# Revision 1.5 2006/09/27 21:19:21 tgarip1957 +# Finalized XML version for intranet +# +# Revision 1.4 2006/07/04 14:36:51 toins +# Head & rel_2_2 merged +# +# Revision 1.3.2.4 2006/06/20 16:21:42 oleonard +# Adding "tabindex=''" to CGI:scrolling_lists to prevent incorrect tabbing. See Bug 1098 +# +# Revision 1.3.2.3 2006/02/05 21:59:21 kados +# Adds script support for IntranetNav ... see mail to koha-devel for +# details +# +# Revision 1.3.2.2 2006/02/05 21:45:25 kados +# Adds support for intranetstylesheet system pref in Koha scripts +# +# Revision 1.3.2.1 2006/02/04 21:26:47 kados +# Adds support for intranetcolorstylesheet +# +# Revision 1.3 2004/12/15 17:28:22 tipaul +# adding bookshelf features : +# * create bookshelf on the fly +# * modify a bookshelf (this being not finished, will commit the rest soon) +# +# Revision 1.2 2004/11/19 16:31:30 tipaul +# bugfix for bookshelves not in official CVS +# +# Revision 1.1.2.2 2004/03/10 15:08:18 tipaul +# modifying shelves : introducing category of shelf : private, public, free for all +# +# Revision 1.1.2.1 2004/02/19 10:14:36 tipaul +# new feature : adding book to bookshelf from biblio detail screen. +# + +# Local Variables: +# tab-width: 4 +# End: Index: koha-tmpl/intranet-tmpl/default/en/bookshelves/addbookbybiblionumber.tmpl =================================================================== RCS file: koha-tmpl/intranet-tmpl/default/en/bookshelves/addbookbybiblionumber.tmpl diff -N koha-tmpl/intranet-tmpl/default/en/bookshelves/addbookbybiblionumber.tmpl --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ koha-tmpl/intranet-tmpl/default/en/bookshelves/addbookbybiblionumber.tmpl 3 Apr 2007 18:24:48 -0000 1.6.2.1 @@ -0,0 +1,11 @@ + +
+

Select bookshelf

+
+ "> +

+

+

+ +
+ From kyle.m.hall at gmail.com Wed Apr 4 14:53:32 2007 From: kyle.m.hall at gmail.com (Kyle Hall) Date: Wed, 04 Apr 2007 12:53:32 +0000 Subject: [Koha-cvs] koha/koha-tmpl/intranet-tmpl/ccfls/en/catalogue... [dev_week] Message-ID: CVSROOT: /sources/koha Module name: koha Branch: dev_week Changes by: Kyle Hall 07/04/04 12:53:32 Modified files: koha-tmpl/intranet-tmpl/ccfls/en/catalogue: detail.tmpl Log message: Added direct edit item links CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/ccfls/en/catalogue/detail.tmpl?cvsroot=koha&only_with_tag=dev_week&r1=1.1.2.1.2.11&r2=1.1.2.1.2.12 Patches: Index: detail.tmpl =================================================================== RCS file: /sources/koha/koha/koha-tmpl/intranet-tmpl/ccfls/en/catalogue/Attic/detail.tmpl,v retrieving revision 1.1.2.1.2.11 retrieving revision 1.1.2.1.2.12 diff -u -b -r1.1.2.1.2.11 -r1.1.2.1.2.12 --- detail.tmpl 28 Mar 2007 12:03:19 -0000 1.1.2.1.2.11 +++ detail.tmpl 4 Apr 2007 12:53:32 -0000 1.1.2.1.2.12 @@ -112,6 +112,7 @@ Last Seen Item Notes Barcode + @@ -136,6 +137,10 @@ &item=&bib=&bi=#">   --> + + &itemnum=">Edit + + &item=">Fix Itemtype From paul at koha-fr.org Wed Apr 4 18:46:24 2007 From: paul at koha-fr.org (paul poulain) Date: Wed, 04 Apr 2007 16:46:24 +0000 Subject: [Koha-cvs] koha bookshelves/addbookbybiblionumber.pl books... Message-ID: CVSROOT: /sources/koha Module name: koha Changes by: paul poulain 07/04/04 16:46:23 Modified files: bookshelves : addbookbybiblionumber.pl shelves.pl C4 : Accounts.pm Auth.pm Auth_with_ldap.pm Biblio.pm BookShelves.pm Date.pm Members.pm Print.pm Reserves2.pm C4/Circulation : Fines.pm catalogue : issuehistory.pl moredetail.pl circ : bookcount.pl branchoverdues.pl branchreserves.pl branchtransfers.pl circulation.pl currenttransfers.pl returns.pl selectbranchprinter.pl waitingreservestransfers.pl members : deletemem.pl member-flags.pl member-password.pl moremember.pl pay.pl misc : fines.pl fines2.pl misc/cronjobs : notifyMailsOp.pl misc/notifys : contact_history.pl fines.pl printnote.pl opac : opac-account.pl opac-addbookbybiblionumber.pl opac-passwd.pl opac-readingrecord.pl opac-renew.pl opac-reserve.pl opac-review.pl opac-shelves.pl opac-showreviews.pl opac-user.pl opac-userdetails.pl opac-userupdate.pl reports : acquisitions_stats.pl bor_issues_top.pl borrowers_out.pl borrowers_stats.pl cat_issues_top.pl catalogue_out.pl catalogue_stats.pl inventory.pl issues_avg_stats.pl issues_stats.pl manager.pl reserve : placerequest.pl renewscript.pl request.pl serials : routing-preview.pl tools : cleanborrowers.pl inventory.pl itemslost.pl Removed files: C4/Circulation : Circ2.pm Log message: HUGE COMMIT : code cleaning circulation. some stuff to do, i'll write a mail on koha-devel NOW ! CVSWeb URLs: http://cvs.savannah.gnu.org/viewcvs/koha/bookshelves/addbookbybiblionumber.pl?cvsroot=koha&r1=1.6&r2=1.7 http://cvs.savannah.gnu.org/viewcvs/koha/bookshelves/shelves.pl?cvsroot=koha&r1=1.11&r2=1.12 http://cvs.savannah.gnu.org/viewcvs/koha/C4/Accounts.pm?cvsroot=koha&r1=1.18&r2=1.19 http://cvs.savannah.gnu.org/viewcvs/koha/C4/Auth.pm?cvsroot=koha&r1=1.58&r2=1.59 http://cvs.savannah.gnu.org/viewcvs/koha/C4/Auth_with_ldap.pm?cvsroot=koha&r1=1.6&r2=1.7 http://cvs.savannah.gnu.org/viewcvs/koha/C4/Biblio.pm?cvsroot=koha&r1=1.194&r2=1.195 http://cvs.savannah.gnu.org/viewcvs/koha/C4/BookShelves.pm?cvsroot=koha&r1=1.20&r2=1.21 http://cvs.savannah.gnu.org/viewcvs/koha/C4/Date.pm?cvsroot=koha&r1=1.28&r2=1.29 http://cvs.savannah.gnu.org/viewcvs/koha/C4/Members.pm?cvsroot=koha&r1=1.40&r2=1.41 http://cvs.savannah.gnu.org/viewcvs/koha/C4/Print.pm?cvsroot=koha&r1=1.19&r2=1.20 http://cvs.savannah.gnu.org/viewcvs/koha/C4/Reserves2.pm?cvsroot=koha&r1=1.51&r2=1.52 http://cvs.savannah.gnu.org/viewcvs/koha/C4/Circulation/Fines.pm?cvsroot=koha&r1=1.23&r2=1.24 http://cvs.savannah.gnu.org/viewcvs/koha/C4/Circulation/Circ2.pm?cvsroot=koha&r1=1.129&r2=0 http://cvs.savannah.gnu.org/viewcvs/koha/catalogue/issuehistory.pl?cvsroot=koha&r1=1.2&r2=1.3 http://cvs.savannah.gnu.org/viewcvs/koha/catalogue/moredetail.pl?cvsroot=koha&r1=1.10&r2=1.11 http://cvs.savannah.gnu.org/viewcvs/koha/circ/bookcount.pl?cvsroot=koha&r1=1.2&r2=1.3 http://cvs.savannah.gnu.org/viewcvs/koha/circ/branchoverdues.pl?cvsroot=koha&r1=1.4&r2=1.5 http://cvs.savannah.gnu.org/viewcvs/koha/circ/branchreserves.pl?cvsroot=koha&r1=1.5&r2=1.6 http://cvs.savannah.gnu.org/viewcvs/koha/circ/branchtransfers.pl?cvsroot=koha&r1=1.27&r2=1.28 http://cvs.savannah.gnu.org/viewcvs/koha/circ/circulation.pl?cvsroot=koha&r1=1.102&r2=1.103 http://cvs.savannah.gnu.org/viewcvs/koha/circ/currenttransfers.pl?cvsroot=koha&r1=1.5&r2=1.6 http://cvs.savannah.gnu.org/viewcvs/koha/circ/returns.pl?cvsroot=koha&r1=1.46&r2=1.47 http://cvs.savannah.gnu.org/viewcvs/koha/circ/selectbranchprinter.pl?cvsroot=koha&r1=1.17&r2=1.18 http://cvs.savannah.gnu.org/viewcvs/koha/circ/waitingreservestransfers.pl?cvsroot=koha&r1=1.7&r2=1.8 http://cvs.savannah.gnu.org/viewcvs/koha/members/deletemem.pl?cvsroot=koha&r1=1.10&r2=1.11 http://cvs.savannah.gnu.org/viewcvs/koha/members/member-flags.pl?cvsroot=koha&r1=1.6&r2=1.7 http://cvs.savannah.gnu.org/viewcvs/koha/members/member-password.pl?cvsroot=koha&r1=1.5&r2=1.6 http://cvs.savannah.gnu.org/viewcvs/koha/members/moremember.pl?cvsroot=koha&r1=1.30&r2=1.31 http://cvs.savannah.gnu.org/viewcvs/koha/members/pay.pl?cvsroot=koha&r1=1.8&r2=1.9 http://cvs.savannah.gnu.org/viewcvs/koha/misc/fines.pl?cvsroot=koha&r1=1.2&r2=1.3 http://cvs.savannah.gnu.org/viewcvs/koha/misc/fines2.pl?cvsroot=koha&r1=1.13&r2=1.14 http://cvs.savannah.gnu.org/viewcvs/koha/misc/cronjobs/notifyMailsOp.pl?cvsroot=koha&r1=1.2&r2=1.3 http://cvs.savannah.gnu.org/viewcvs/koha/misc/notifys/contact_history.pl?cvsroot=koha&r1=1.2&r2=1.3 http://cvs.savannah.gnu.org/viewcvs/koha/misc/notifys/fines.pl?cvsroot=koha&r1=1.4&r2=1.5 http://cvs.savannah.gnu.org/viewcvs/koha/misc/notifys/printnote.pl?cvsroot=koha&r1=1.2&r2=1.3 http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-account.pl?cvsroot=koha&r1=1.12&r2=1.13 http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-addbookbybiblionumber.pl?cvsroot=koha&r1=1.6&r2=1.7 http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-passwd.pl?cvsroot=koha&r1=1.4&r2=1.5 http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-readingrecord.pl?cvsroot=koha&r1=1.11&r2=1.12 http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-renew.pl?cvsroot=koha&r1=1.4&r2=1.5 http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-reserve.pl?cvsroot=koha&r1=1.30&r2=1.31 http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-review.pl?cvsroot=koha&r1=1.4&r2=1.5 http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-shelves.pl?cvsroot=koha&r1=1.9&r2=1.10 http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-showreviews.pl?cvsroot=koha&r1=1.4&r2=1.5 http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-user.pl?cvsroot=koha&r1=1.24&r2=1.25 http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-userdetails.pl?cvsroot=koha&r1=1.13&r2=1.14 http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-userupdate.pl?cvsroot=koha&r1=1.15&r2=1.16 http://cvs.savannah.gnu.org/viewcvs/koha/reports/acquisitions_stats.pl?cvsroot=koha&r1=1.13&r2=1.14 http://cvs.savannah.gnu.org/viewcvs/koha/reports/bor_issues_top.pl?cvsroot=koha&r1=1.10&r2=1.11 http://cvs.savannah.gnu.org/viewcvs/koha/reports/borrowers_out.pl?cvsroot=koha&r1=1.8&r2=1.9 http://cvs.savannah.gnu.org/viewcvs/koha/reports/borrowers_stats.pl?cvsroot=koha&r1=1.12&r2=1.13 http://cvs.savannah.gnu.org/viewcvs/koha/reports/cat_issues_top.pl?cvsroot=koha&r1=1.12&r2=1.13 http://cvs.savannah.gnu.org/viewcvs/koha/reports/catalogue_out.pl?cvsroot=koha&r1=1.7&r2=1.8 http://cvs.savannah.gnu.org/viewcvs/koha/reports/catalogue_stats.pl?cvsroot=koha&r1=1.19&r2=1.20 http://cvs.savannah.gnu.org/viewcvs/koha/reports/inventory.pl?cvsroot=koha&r1=1.4&r2=1.5 http://cvs.savannah.gnu.org/viewcvs/koha/reports/issues_avg_stats.pl?cvsroot=koha&r1=1.7&r2=1.8 http://cvs.savannah.gnu.org/viewcvs/koha/reports/issues_stats.pl?cvsroot=koha&r1=1.15&r2=1.16 http://cvs.savannah.gnu.org/viewcvs/koha/reports/manager.pl?cvsroot=koha&r1=1.6&r2=1.7 http://cvs.savannah.gnu.org/viewcvs/koha/reserve/placerequest.pl?cvsroot=koha&r1=1.5&r2=1.6 http://cvs.savannah.gnu.org/viewcvs/koha/reserve/renewscript.pl?cvsroot=koha&r1=1.5&r2=1.6 http://cvs.savannah.gnu.org/viewcvs/koha/reserve/request.pl?cvsroot=koha&r1=1.8&r2=1.9 http://cvs.savannah.gnu.org/viewcvs/koha/serials/routing-preview.pl?cvsroot=koha&r1=1.3&r2=1.4 http://cvs.savannah.gnu.org/viewcvs/koha/tools/cleanborrowers.pl?cvsroot=koha&r1=1.2&r2=1.3 http://cvs.savannah.gnu.org/viewcvs/koha/tools/inventory.pl?cvsroot=koha&r1=1.3&r2=1.4 http://cvs.savannah.gnu.org/viewcvs/koha/tools/itemslost.pl?cvsroot=koha&r1=1.2&r2=1.3 Patches: Index: bookshelves/addbookbybiblionumber.pl =================================================================== RCS file: /sources/koha/koha/bookshelves/addbookbybiblionumber.pl,v retrieving revision 1.6 retrieving revision 1.7 diff -u -b -r1.6 -r1.7 --- bookshelves/addbookbybiblionumber.pl 9 Mar 2007 14:32:26 -0000 1.6 +++ bookshelves/addbookbybiblionumber.pl 4 Apr 2007 16:46:22 -0000 1.7 @@ -20,7 +20,7 @@ # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA -# $Id: addbookbybiblionumber.pl,v 1.6 2007/03/09 14:32:26 tipaul Exp $ +# $Id: addbookbybiblionumber.pl,v 1.7 2007/04/04 16:46:22 tipaul Exp $ =head1 NAME @@ -60,7 +60,7 @@ use CGI; use C4::Output; use C4::BookShelves; -use C4::Circulation::Circ2; +use C4::Circulation; use C4::Auth; use C4::Interface::CGI::Output; @@ -122,6 +122,11 @@ } # $Log: addbookbybiblionumber.pl,v $ +# Revision 1.7 2007/04/04 16:46:22 tipaul +# HUGE COMMIT : code cleaning circulation. +# +# some stuff to do, i'll write a mail on koha-devel NOW ! +# # Revision 1.6 2007/03/09 14:32:26 tipaul # rel_3_0 moved to HEAD # Index: bookshelves/shelves.pl =================================================================== RCS file: /sources/koha/koha/bookshelves/shelves.pl,v retrieving revision 1.11 retrieving revision 1.12 diff -u -b -r1.11 -r1.12 --- bookshelves/shelves.pl 9 Mar 2007 14:32:26 -0000 1.11 +++ bookshelves/shelves.pl 4 Apr 2007 16:46:22 -0000 1.12 @@ -67,7 +67,7 @@ use CGI; use C4::Output; use C4::BookShelves; -use C4::Circulation::Circ2; +use C4::Biblio; use C4::Auth; use C4::Interface::CGI::Output; @@ -86,7 +86,7 @@ if ( $query->param('modifyshelfcontents') ) { my $shelfnumber = $query->param('viewshelf'); my $barcode = $query->param('addbarcode'); - my ($item) = getiteminformation( 0, $barcode ); + my ($item) = GetItem( 0, $barcode ); if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' ) ) { AddToShelf( $item->{'itemnumber'}, $shelfnumber ); foreach ( $query->param ) { @@ -281,6 +281,11 @@ # # $Log: shelves.pl,v $ +# Revision 1.12 2007/04/04 16:46:22 tipaul +# HUGE COMMIT : code cleaning circulation. +# +# some stuff to do, i'll write a mail on koha-devel NOW ! +# # Revision 1.11 2007/03/09 14:32:26 tipaul # rel_3_0 moved to HEAD # Index: C4/Accounts.pm =================================================================== RCS file: /sources/koha/koha/C4/Accounts.pm,v retrieving revision 1.18 retrieving revision 1.19 diff -u -b -r1.18 -r1.19 --- C4/Accounts.pm 9 Mar 2007 23:33:26 -0000 1.18 +++ C4/Accounts.pm 4 Apr 2007 16:46:22 -0000 1.19 @@ -17,18 +17,18 @@ # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA -# $Id: Accounts.pm,v 1.18 2007/03/09 23:33:26 kados Exp $ +# $Id: Accounts.pm,v 1.19 2007/04/04 16:46:22 tipaul Exp $ use strict; require Exporter; use C4::Context; use C4::Stats; use C4::Members; -#use C4::Circulation::Circ2; +#use C4::Circulation; use vars qw($VERSION @ISA @EXPORT); # set the version for version checking -$VERSION = do { my @v = '$Revision: 1.18 $' =~ /\d+/g; +$VERSION = do { my @v = '$Revision: 1.19 $' =~ /\d+/g; shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); }; =head1 NAME @@ -55,7 +55,7 @@ =head2 checkaccount - $owed = &checkaccount($env, $borrowernumber, $dbh, $date); + $owed = &checkaccount($borrowernumber, $dbh, $date); Looks up the total amount of money owed by a borrower (fines, etc.). @@ -71,7 +71,7 @@ sub checkaccount { #take borrower number #check accounts and list amounts owing - my ($env,$borrowernumber,$dbh,$date)=@_; + my ($borrowernumber,$dbh,$date)=@_; my $select="SELECT SUM(amountoutstanding) AS total FROM accountlines WHERE borrowernumber = ? @@ -126,7 +126,7 @@ warn $branch; my $amountleft = $data; # begin transaction - my $nextaccntno = getnextacctno($env,$borrowernumber,$dbh); + my $nextaccntno = getnextacctno($borrowernumber); # get lines with outstanding amounts to offset my $sth = $dbh->prepare("select * from accountlines where (borrowernumber = ?) and (amountoutstanding<>0) @@ -189,7 +189,7 @@ $env{'branchcode'}=$branch; my $dbh = C4::Context->dbh; # begin transaction - my $nextaccntno = getnextacctno(\%env,$borrowernumber,$dbh); + my $nextaccntno = getnextacctno($borrowernumber); my $newamtos=0; my $sth=$dbh->prepare("Select * from accountlines where borrowernumber=? and accountno=?"); $sth->execute($borrowernumber,$accountno); @@ -234,7 +234,7 @@ =head2 getnextacctno - $nextacct = &getnextacctno($env, $borrowernumber, $dbh); + $nextacct = &getnextacctno($borrowernumber); Returns the next unused account number for the patron with the given borrower number. @@ -248,11 +248,12 @@ #' # FIXME - Okay, so what does the above actually _mean_? sub getnextacctno { - my ($env,$borrowernumber,$dbh)=@_; + my ($borrowernumber)=@_; my $nextaccntno = 1; - my $sth = $dbh->prepare("select * from accountlines - where (borrowernumber = ?) - order by accountno desc"); + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("SELECT * FROM accountlines + WHERE (borrowernumber = ?) + ORDER BY accountno DESC"); $sth->execute($borrowernumber); if (my $accdata=$sth->fetchrow_hashref){ $nextaccntno = $accdata->{'accountno'} + 1; @@ -330,7 +331,7 @@ my $insert; $itemnum=~ s/ //g; my %env; - my $accountno=getnextacctno('',$borrowernumber,$dbh); + my $accountno=getnextacctno($borrowernumber); my $amountleft=$amount; if ($type eq 'CS' || $type eq 'CB' || $type eq 'CW' @@ -395,8 +396,8 @@ my $accdata = ""; my $amountleft = $data; if ($barcode ne ''){ - my $item=getiteminformation('',$barcode); - my $nextaccntno = getnextacctno($env,$borrowernumber,$dbh); + my $item=GetBiblioFromItemNumber('',$barcode); + my $nextaccntno = getnextacctno($borrowernumber); my $query="Select * from accountlines where (borrowernumber=? and itemnumber=? and amountoutstanding > 0)"; if ($type eq 'CL'){ @@ -431,7 +432,7 @@ $usth->finish; } # begin transaction - my $nextaccntno = getnextacctno($env,$borrowernumber,$dbh); + my $nextaccntno = getnextacctno($borrowernumber); # get lines with outstanding amounts to offset my $sth = $dbh->prepare("select * from accountlines where (borrowernumber = ?) and (amountoutstanding >0) @@ -483,7 +484,7 @@ my $amountleft = $data *-1; # begin transaction - my $nextaccntno = getnextacctno($env,$borrowernumber,$dbh); + my $nextaccntno = getnextacctno($borrowernumber); # get lines with outstanding amounts to offset my $sth = $dbh->prepare("select * from accountlines where (borrowernumber = ?) and (amountoutstanding<0) Index: C4/Auth.pm =================================================================== RCS file: /sources/koha/koha/C4/Auth.pm,v retrieving revision 1.58 retrieving revision 1.59 diff -u -b -r1.58 -r1.59 --- C4/Auth.pm 9 Mar 2007 14:31:47 -0000 1.58 +++ C4/Auth.pm 4 Apr 2007 16:46:22 -0000 1.59 @@ -27,7 +27,7 @@ use C4::Context; use C4::Output; # to get the template use C4::Interface::CGI::Output; -use C4::Circulation::Circ2; # getpatroninformation +use C4::Members; use C4::Koha; use C4::Branch; # GetBranches @@ -37,7 +37,7 @@ use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); # set the version for version checking -$VERSION = do { my @v = '$Revision: 1.58 $' =~ /\d+/g; +$VERSION = do { my @v = '$Revision: 1.59 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); }; @@ -130,7 +130,7 @@ $borrowernumber = getborrowernumber($user); my ( $borr, $alternativeflags ) = - getpatroninformation( undef, $borrowernumber ); + GetMemberDetails( $borrowernumber ); my @bordat; $bordat[0] = $borr; $template->param( "USER_INFO" => \@bordat ); Index: C4/Auth_with_ldap.pm =================================================================== RCS file: /sources/koha/koha/C4/Auth_with_ldap.pm,v retrieving revision 1.6 retrieving revision 1.7 diff -u -b -r1.6 -r1.7 --- C4/Auth_with_ldap.pm 9 Mar 2007 14:31:47 -0000 1.6 +++ C4/Auth_with_ldap.pm 4 Apr 2007 16:46:22 -0000 1.7 @@ -27,7 +27,6 @@ use C4::Context; use C4::Output; # to get the template use C4::Interface::CGI::Output; -use C4::Circulation::Circ2; # getpatroninformation use C4::Members; # use Net::LDAP; @@ -136,7 +135,7 @@ $borrowernumber = getborrowernumber($user); my ( $borr, $alternativeflags ) = - getpatroninformation( undef, $borrowernumber ); + GetMemberDetails( $borrowernumber ); my @bordat; $bordat[0] = $borr; $template->param( USER_INFO => \@bordat, ); Index: C4/Biblio.pm =================================================================== RCS file: /sources/koha/koha/C4/Biblio.pm,v retrieving revision 1.194 retrieving revision 1.195 diff -u -b -r1.194 -r1.195 --- C4/Biblio.pm 30 Mar 2007 12:00:42 -0000 1.194 +++ C4/Biblio.pm 4 Apr 2007 16:46:22 -0000 1.195 @@ -33,7 +33,7 @@ use vars qw($VERSION @ISA @EXPORT); # set the version for version checking -$VERSION = do { my @v = '$Revision: 1.194 $' =~ /\d+/g; shift(@v).".".join( "_", map { sprintf "%03d", $_ } @v ); }; +$VERSION = do { my @v = '$Revision: 1.195 $' =~ /\d+/g; shift(@v).".".join( "_", map { sprintf "%03d", $_ } @v ); }; @ISA = qw( Exporter ); @@ -52,9 +52,12 @@ &GetBiblioFromItemNumber &GetMarcItem + &GetItem &GetItemInfosOf &GetItemStatus &GetItemLocation + &GetLostItems + &GetItemsForInventory &GetMarcNotes &GetMarcSubjects @@ -82,6 +85,7 @@ &ModZebra &ModItemInMarc &ModItemInMarconefield + &ModDateLastSeen ); # To delete something @@ -501,6 +505,24 @@ ModZebra($biblionumber,"specialUpdate","biblioserver"); } +=head2 ModDateLastSeen + +&ModDateLastSeen($itemnum) +Mark item as seen. Is called when an item is issued, returned or manually marked during inventory/stocktaking +C<$itemnum> is the item number + +=cut + +sub ModDateLastSeen { + my ($itemnum) = @_; + my $dbh = C4::Context->dbh; + my $sth = + $dbh->prepare( + "update items set itemlost=0, datelastseen = now() where items.itemnumber = ?" + ); + $sth->execute($itemnum); + return; +} =head2 DelBiblio =over @@ -970,6 +992,114 @@ return \%itemlocation; } +=head2 GetLostItems + +$items = GetLostItems($where,$orderby); + +This function get the items lost into C<$items>. + +=over 2 + +=item input: +C<$where> is a hashref. it containts a field of the items table as key +and the value to match as value. +C<$orderby> is a field of the items table. + +=item return: +C<$items> is a reference to an array full of hasref which keys are items' table column. + +=item usage in the perl script: + +my %where; +$where{barcode} = 0001548; +my $items = GetLostItems( \%where, "homebranch" ); +$template->param(itemsloop => $items); + +=back + +=cut + +sub GetLostItems { + # Getting input args. + my $where = shift; + my $orderby = shift; + my $dbh = C4::Context->dbh; + + my $query = " + SELECT * + FROM items + WHERE itemlost IS NOT NULL + AND itemlost <> 0 + "; + foreach my $key (keys %$where) { + $query .= " AND " . $key . " LIKE '%" . $where->{$key} . "%'"; + } + $query .= " ORDER BY ".$orderby if defined $orderby; + + my $sth = $dbh->prepare($query); + $sth->execute; + my @items; + while ( my $row = $sth->fetchrow_hashref ){ + push @items, $row; + } + return \@items; +} + +=head2 GetItemsForInventory + +$itemlist = GetItemsForInventory($minlocation,$maxlocation,$datelastseen,$offset,$size) + +Retrieve a list of title/authors/barcode/callnumber, for biblio inventory. + +The sub returns a list of hashes, containing itemnumber, author, title, barcode & item callnumber. +It is ordered by callnumber,title. + +The minlocation & maxlocation parameters are used to specify a range of item callnumbers +the datelastseen can be used to specify that you want to see items not seen since a past date only. +offset & size can be used to retrieve only a part of the whole listing (defaut behaviour) + +=cut + +sub GetItemsForInventory { + my ( $minlocation, $maxlocation, $datelastseen, $branch, $offset, $size ) = @_; + my $dbh = C4::Context->dbh; + my $sth; + if ($datelastseen) { + my $query = + "SELECT itemnumber,barcode,itemcallnumber,title,author,datelastseen + FROM items + LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber + WHERE itemcallnumber>= ? + AND itemcallnumber <=? + AND (datelastseen< ? OR datelastseen IS NULL)"; + $query.= " AND items.homebranch=".$dbh->quote($branch) if $branch; + $query .= " ORDER BY itemcallnumber,title"; + $sth = $dbh->prepare($query); + $sth->execute( $minlocation, $maxlocation, $datelastseen ); + } + else { + my $query =" + SELECT itemnumber,barcode,itemcallnumber,title,author,datelastseen + FROM items + LEFT JOIN biblio ON items.biblionumber=biblio.biblionumber + WHERE itemcallnumber>= ? + AND itemcallnumber <=?"; + $query.= " AND items.homebranch=".$dbh->quote($branch) if $branch; + $query .= " ORDER BY itemcallnumber,title"; + $sth = $dbh->prepare($query); + $sth->execute( $minlocation, $maxlocation ); + } + my @results; + while ( my $row = $sth->fetchrow_hashref ) { + $offset-- if ($offset); + if ( ( !$offset ) && $size ) { + push @results, $row; + $size--; + } + } + return \@results; +} + =head2 &GetBiblioItemData =over 4 @@ -1110,6 +1240,39 @@ return ( $count, @results ); } # sub GetBiblio +=head2 GetItem + +=over 4 + +$data = &GetItem($itemnumber,$barcode); + +return Item information, for a given itemnumber or barcode + +=back + +=cut + +sub GetItem { + my ($itemnumber,$barcode) = @_; + my $dbh = C4::Context->dbh; + if ($itemnumber) { + my $sth = $dbh->prepare(" + SELECT * FROM items + WHERE itemnumber = ?"); + $sth->execute($itemnumber); + my $data = $sth->fetchrow_hashref; + return $data; + } else { + my $sth = $dbh->prepare(" + SELECT * FROM items + WHERE barcode = ?" + ); + $sth->execute($barcode); + my $data = $sth->fetchrow_hashref; + return $data; + } +} # sub GetItem + =head2 get_itemnumbers_of =over 4 @@ -1445,6 +1608,8 @@ return $newrecord; } + + =head2 GetMarcNotes =over 4 @@ -3487,8 +3652,13 @@ =cut -# $Id: Biblio.pm,v 1.194 2007/03/30 12:00:42 tipaul Exp $ +# $Id: Biblio.pm,v 1.195 2007/04/04 16:46:22 tipaul Exp $ # $Log: Biblio.pm,v $ +# Revision 1.195 2007/04/04 16:46:22 tipaul +# HUGE COMMIT : code cleaning circulation. +# +# some stuff to do, i'll write a mail on koha-devel NOW ! +# # Revision 1.194 2007/03/30 12:00:42 tipaul # why the hell do we need to explicitly utf8 decode this string ? I really don't know, but it seems it's mandatory, otherwise, tag descriptions are not properly encoded... # Index: C4/BookShelves.pm =================================================================== RCS file: /sources/koha/koha/C4/BookShelves.pm,v retrieving revision 1.20 retrieving revision 1.21 diff -u -b -r1.20 -r1.21 --- C4/BookShelves.pm 9 Mar 2007 14:31:47 -0000 1.20 +++ C4/BookShelves.pm 4 Apr 2007 16:46:22 -0000 1.21 @@ -3,7 +3,7 @@ package C4::BookShelves; -# $Id: BookShelves.pm,v 1.20 2007/03/09 14:31:47 tipaul Exp $ +# $Id: BookShelves.pm,v 1.21 2007/04/04 16:46:22 tipaul Exp $ # Copyright 2000-2002 Katipo Communications # @@ -25,11 +25,11 @@ use strict; require Exporter; use C4::Context; -use C4::Circulation::Circ2; +use C4::Circulation; use vars qw($VERSION @ISA @EXPORT); # set the version for version checking -$VERSION = do { my @v = '$Revision: 1.20 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); }; +$VERSION = do { my @v = '$Revision: 1.21 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); }; =head1 NAME @@ -161,7 +161,7 @@ C<$shelfnumber>. Returns a reference-to-array, whose elements are references-to-hash, -as returned by C. +as returned by C. =cut @@ -422,6 +422,11 @@ # # $Log: BookShelves.pm,v $ +# Revision 1.21 2007/04/04 16:46:22 tipaul +# HUGE COMMIT : code cleaning circulation. +# +# some stuff to do, i'll write a mail on koha-devel NOW ! +# # Revision 1.20 2007/03/09 14:31:47 tipaul # rel_3_0 moved to HEAD # Index: C4/Date.pm =================================================================== RCS file: /sources/koha/koha/C4/Date.pm,v retrieving revision 1.28 retrieving revision 1.29 diff -u -b -r1.28 -r1.29 --- C4/Date.pm 10 Mar 2007 00:28:11 -0000 1.28 +++ C4/Date.pm 4 Apr 2007 16:46:22 -0000 1.29 @@ -31,6 +31,7 @@ &get_date_format_string_for_DHTMLcalendar &format_date &format_date_in_iso + &fixdate ); @@ -183,4 +184,56 @@ return 1 if (length($olddate[0])==4 && length($olddate[1])<=2 && length($olddate[2])<=2); return 0; } + +=head2 fixdate + +( $date, $invalidduedate ) = fixdate( $year, $month, $day ); + +=cut + +sub fixdate { + my ( $year, $month, $day ) = @_; + my $invalidduedate; + my $date; + if ( $year && $month && $day ) { + if ( ( $year eq 0 ) && ( $month eq 0 ) && ( $year eq 0 ) ) { + + # $env{'datedue'}=''; + } + else { + if ( ( $year eq 0 ) || ( $month eq 0 ) || ( $year eq 0 ) ) { + $invalidduedate = 1; + } + else { + if ( + ( $day > 30 ) + && ( ( $month == 4 ) + || ( $month == 6 ) + || ( $month == 9 ) + || ( $month == 11 ) ) + ) + { + $invalidduedate = 1; + } + elsif ( ( $day > 29 ) && ( $month == 2 ) ) { + $invalidduedate = 1; + } + elsif ( + ( $month == 2 ) + && ( $day > 28 ) + && ( ( $year % 4 ) + && ( ( !( $year % 100 ) || ( $year % 400 ) ) ) ) + ) + { + $invalidduedate = 1; + } + else { + $date = "$year-$month-$day"; + } + } + } + } + return ( $date, $invalidduedate ); +} + 1; Index: C4/Members.pm =================================================================== RCS file: /sources/koha/koha/C4/Members.pm,v retrieving revision 1.40 retrieving revision 1.41 diff -u -b -r1.40 -r1.41 --- C4/Members.pm 9 Mar 2007 14:31:47 -0000 1.40 +++ C4/Members.pm 4 Apr 2007 16:46:22 -0000 1.41 @@ -17,7 +17,7 @@ # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA -# $Id: Members.pm,v 1.40 2007/03/09 14:31:47 tipaul Exp $ +# $Id: Members.pm,v 1.41 2007/04/04 16:46:22 tipaul Exp $ use strict; require Exporter; @@ -26,10 +26,13 @@ use Digest::MD5 qw(md5_base64); use Date::Calc qw/Today Add_Delta_YM/; use C4::Log; # logaction +use C4::Accounts; +use C4::Overdues; +use C4::Reserves2; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); -$VERSION = do { my @v = '$Revision: 1.40 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); }; +$VERSION = do { my @v = '$Revision: 1.41 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); }; =head1 NAME @@ -52,7 +55,7 @@ @ISA = qw(Exporter); @EXPORT = qw( - &BornameSearch &GetMember + &BornameSearch &GetMember &GetMemberDetails &borrdata &borrdata2 &fixup_cardnumber &findguarantees &findguarantor &GuarantornameSearch &modmember &newmember &changepassword &borrissues &allissues @@ -236,6 +239,256 @@ return undef; } +=head2 GetMemberDetails + +($borrower, $flags) = &GetMemberDetails($borrowernumber, $cardnumber); + +Looks up a patron and returns information about him or her. If +C<$borrowernumber> is true (nonzero), C<&GetMemberDetails> looks +up the borrower by number; otherwise, it looks up the borrower by card +number. + +C<$env> is effectively ignored, but should be a reference-to-hash. + +C<$borrower> is a reference-to-hash whose keys are the fields of the +borrowers table in the Koha database. In addition, +C<$borrower-E{flags}> is a hash giving more detailed information +about the patron. Its keys act as flags : + + if $borrower->{flags}->{LOST} { + # Patron's card was reported lost + } + +Each flag has a C key, giving a human-readable explanation of +the flag. If the state of a flag means that the patron should not be +allowed to borrow any more books, then it will have a C key +with a true value. + +The possible flags are: + +=head3 CHARGES + +=over 4 + +=item Shows the patron's credit or debt, if any. + +=back + +=head3 GNA + +=over 4 + +=item (Gone, no address.) Set if the patron has left without giving a +forwarding address. + +=back + +=head3 LOST + +=over 4 + +=item Set if the patron's card has been reported as lost. + +=back + +=head3 DBARRED + +=over 4 + +=item Set if the patron has been debarred. + +=back + +=head3 NOTES + +=over 4 + +=item Any additional notes about the patron. + +=back + +=head3 ODUES + +=over 4 + +=item Set if the patron has overdue items. This flag has several keys: + +C<$flags-E{ODUES}{itemlist}> is a reference-to-array listing the +overdue items. Its elements are references-to-hash, each describing an +overdue item. The keys are selected fields from the issues, biblio, +biblioitems, and items tables of the Koha database. + +C<$flags-E{ODUES}{itemlist}> is a string giving a text listing of +the overdue items, one per line. + +=back + +=head3 WAITING + +=over 4 + +=item Set if any items that the patron has reserved are available. + +C<$flags-E{WAITING}{itemlist}> is a reference-to-array listing the +available items. Each element is a reference-to-hash whose keys are +fields from the reserves table of the Koha database. + +=back + +=cut + +sub GetMemberDetails { + my ( $borrowernumber, $cardnumber ) = @_; + my $dbh = C4::Context->dbh; + my $query; + my $sth; + if ($borrowernumber) { + $sth = $dbh->prepare("select * from borrowers where borrowernumber=?"); + $sth->execute($borrowernumber); + } + elsif ($cardnumber) { + $sth = $dbh->prepare("select * from borrowers where cardnumber=?"); + $sth->execute($cardnumber); + } + else { + return undef; + } + my $borrower = $sth->fetchrow_hashref; + my $amount = C4::Accounts::checkaccount( $borrowernumber, $dbh ); + $borrower->{'amountoutstanding'} = $amount; + my $flags = patronflags( $borrower, $dbh ); + my $accessflagshash; + + $sth = $dbh->prepare("select bit,flag from userflags"); + $sth->execute; + while ( my ( $bit, $flag ) = $sth->fetchrow ) { + if ( $borrower->{'flags'} && $borrower->{'flags'} & 2**$bit ) { + $accessflagshash->{$flag} = 1; + } + } + $sth->finish; + $borrower->{'flags'} = $flags; + $borrower->{'authflags'} = $accessflagshash; + + # find out how long the membership lasts + $sth = + $dbh->prepare( + "select enrolmentperiod from categories where categorycode = ?"); + $sth->execute( $borrower->{'categorycode'} ); + my $enrolment = $sth->fetchrow; + $borrower->{'enrolmentperiod'} = $enrolment; + return ($borrower); #, $flags, $accessflagshash); +} + +=head2 patronflags + + Not exported + + NOTE!: If you change this function, be sure to update the POD for + &GetMemberDetails. + + $flags = &patronflags($env, $patron, $dbh); + + $flags->{CHARGES} + {message} Message showing patron's credit or debt + {noissues} Set if patron owes >$5.00 + {GNA} Set if patron gone w/o address + {message} "Borrower has no valid address" + {noissues} Set. + {LOST} Set if patron's card reported lost + {message} Message to this effect + {noissues} Set. + {DBARRED} Set is patron is debarred + {message} Message to this effect + {noissues} Set. + {NOTES} Set if patron has notes + {message} Notes about patron + {ODUES} Set if patron has overdue books + {message} "Yes" + {itemlist} ref-to-array: list of overdue books + {itemlisttext} Text list of overdue items + {WAITING} Set if there are items available that the + patron reserved + {message} Message to this effect + {itemlist} ref-to-array: list of available items + +=cut + +sub patronflags { + my %flags; + my ( $patroninformation, $dbh ) = @_; + my $amount = + C4::Accounts::checkaccount( $patroninformation->{'borrowernumber'}, $dbh ); + if ( $amount > 0 ) { + my %flaginfo; + my $noissuescharge = C4::Context->preference("noissuescharge"); + $flaginfo{'message'} = sprintf "Patron owes \$%.02f", $amount; + if ( $amount > $noissuescharge ) { + $flaginfo{'noissues'} = 1; + } + $flags{'CHARGES'} = \%flaginfo; + } + elsif ( $amount < 0 ) { + my %flaginfo; + $flaginfo{'message'} = sprintf "Patron has credit of \$%.02f", -$amount; + $flags{'CHARGES'} = \%flaginfo; + } + if ( $patroninformation->{'gonenoaddress'} + && $patroninformation->{'gonenoaddress'} == 1 ) + { + my %flaginfo; + $flaginfo{'message'} = 'Borrower has no valid address.'; + $flaginfo{'noissues'} = 1; + $flags{'GNA'} = \%flaginfo; + } + if ( $patroninformation->{'lost'} && $patroninformation->{'lost'} == 1 ) { + my %flaginfo; + $flaginfo{'message'} = 'Borrower\'s card reported lost.'; + $flaginfo{'noissues'} = 1; + $flags{'LOST'} = \%flaginfo; + } + if ( $patroninformation->{'debarred'} + && $patroninformation->{'debarred'} == 1 ) + { + my %flaginfo; + $flaginfo{'message'} = 'Borrower is Debarred.'; + $flaginfo{'noissues'} = 1; + $flags{'DBARRED'} = \%flaginfo; + } + if ( $patroninformation->{'borrowernotes'} + && $patroninformation->{'borrowernotes'} ) + { + my %flaginfo; + $flaginfo{'message'} = "$patroninformation->{'borrowernotes'}"; + $flags{'NOTES'} = \%flaginfo; + } + my ( $odues, $itemsoverdue ) = + checkoverdues( $patroninformation->{'borrowernumber'}, $dbh ); + if ( $odues > 0 ) { + my %flaginfo; + $flaginfo{'message'} = "Yes"; + $flaginfo{'itemlist'} = $itemsoverdue; + foreach ( sort { $a->{'date_due'} cmp $b->{'date_due'} } + @$itemsoverdue ) + { + $flaginfo{'itemlisttext'} .= + "$_->{'date_due'} $_->{'barcode'} $_->{'title'} \n"; + } + $flags{'ODUES'} = \%flaginfo; + } + my $itemswaiting = + C4::Reserves2::GetWaitingReserves( $patroninformation->{'borrowernumber'} ); + my $nowaiting = scalar @$itemswaiting; + if ( $nowaiting > 0 ) { + my %flaginfo; + $flaginfo{'message'} = "Reserved items available"; + $flaginfo{'itemlist'} = $itemswaiting; + $flags{'WAITING'} = \%flaginfo; + } + return ( \%flags ); +} + + =item borrdata $borrower = &borrdata($cardnumber, $borrowernumber); Index: C4/Print.pm =================================================================== RCS file: /sources/koha/koha/C4/Print.pm,v retrieving revision 1.19 retrieving revision 1.20 diff -u -b -r1.19 -r1.20 --- C4/Print.pm 9 Mar 2007 14:31:47 -0000 1.19 +++ C4/Print.pm 4 Apr 2007 16:46:22 -0000 1.20 @@ -17,19 +17,19 @@ # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA -# $Id: Print.pm,v 1.19 2007/03/09 14:31:47 tipaul Exp $ +# $Id: Print.pm,v 1.20 2007/04/04 16:46:22 tipaul Exp $ use strict; require Exporter; use C4::Context; -use C4::Circulation::Circ2; +use C4::Circulation; use vars qw($VERSION @ISA @EXPORT); # set the version for version checking # set the version for version checking -$VERSION = do { my @v = '$Revision: 1.19 $' =~ /\d+/g; +$VERSION = do { my @v = '$Revision: 1.20 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); }; @@ -65,12 +65,12 @@ C<&remoteprint> will print to the file F. C<$borrower> is a reference-to-hash giving information about a patron. -This may be gotten from C<&getpatroninformation>. The patron's name +This may be gotten from C<&GetMemberDetails>. The patron's name will be printed in the output. C<$items> is a reference-to-list, where each element is a reference-to-hash describing a borrowed item. C<$items> may be gotten -from C<¤tissues>. +from C<&GetBorrowerIssues>. =cut @@ -197,12 +197,12 @@ #' sub printslip { my ( $env, $borrowernumber ) = @_; - my ( $borrower, $flags ) = getpatroninformation( $env, $borrowernumber, 0 ); + my ( $borrower, $flags ) = GetMemberDetails( $borrowernumber); $env->{'todaysissues'} = 1; - my ($borrowerissues) = currentissues( $env, $borrower ); + my ($borrowerissues) = GetBorrowerIssues( $borrower ); $env->{'nottodaysissues'} = 1; $env->{'todaysissues'} = 0; - my ($borroweriss2) = currentissues( $env, $borrower ); + my ($borroweriss2) = GetBorrowerIssues( $borrower ); $env->{'nottodaysissues'} = 0; my $i = 0; my @issues; Index: C4/Reserves2.pm =================================================================== RCS file: /sources/koha/koha/C4/Reserves2.pm,v retrieving revision 1.51 retrieving revision 1.52 diff -u -b -r1.51 -r1.52 --- C4/Reserves2.pm 30 Mar 2007 13:30:38 -0000 1.51 +++ C4/Reserves2.pm 4 Apr 2007 16:46:22 -0000 1.52 @@ -20,20 +20,20 @@ # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA -# $Id: Reserves2.pm,v 1.51 2007/03/30 13:30:38 tipaul Exp $ +# $Id: Reserves2.pm,v 1.52 2007/04/04 16:46:22 tipaul Exp $ use strict; require Exporter; use C4::Context; use C4::Biblio; use C4::Search; -use C4::Circulation::Circ2; +use C4::Circulation; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); my $library_name = C4::Context->preference("LibraryName"); # set the version for version checking -$VERSION = do { my @v = '$Revision: 1.51 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); }; +$VERSION = do { my @v = '$Revision: 1.52 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); }; =head1 NAME @@ -75,6 +75,8 @@ &CountReservesFromBorrower &FixPriority &FindReservesInQueue + GetReservesForBranch + GetReservesToBranch ); # make all your functions, whether exported or not; @@ -87,7 +89,6 @@ =cut -#' sub GlobalCancel { my $messages; my $nextreservinfo; @@ -117,7 +118,7 @@ my $nextreservinfo; my ( $restype, $checkreserves ) = CheckReserves($itemnumber); if ($checkreserves) { - my $iteminfo = C4::Circulation::Circ2::getiteminformation($itemnumber,undef); + my $iteminfo = GetItem($itemnumber); if ( $iteminfo->{'holdingbranch'} ne $checkreserves->{'branchcode'} ) { $messages->{'transfert'} = $checkreserves->{'branchcode'}; #minus priorities of others reservs @@ -167,37 +168,37 @@ #first step update the value of the first person on reserv my $dbh = C4::Context->dbh; - my $query = qq/ + my $query = " UPDATE reserves SET priority = 0 , itemnumber = ? WHERE cancellationdate IS NULL AND borrowernumber=? AND biblionumber=? - /; + "; my $sth_upd = $dbh->prepare($query); $sth_upd->execute( $itemnumber, $borrowernumber, $biblionumber ); $sth_upd->finish; # second step update all others reservs - $query = qq/ + $query = " SELECT priority,borrowernumber,biblionumber,reservedate FROM reserves WHERE priority !='0' AND biblionumber = ? AND cancellationdate IS NULL - /; + "; my $sth_oth = $dbh->prepare($query); $sth_oth->execute($biblionumber); while ( my ( $priority, $borrowernumber, $biblionumber, $reservedate ) = $sth_oth->fetchrow_array ) { $priority--; - $query = qq/ + $query = " UPDATE reserves SET priority = ? WHERE biblionumber = ? AND borrowernumber = ? AND reservedate = ? - /; + "; my $sth_upd_oth = $dbh->prepare($query); $sth_upd_oth->execute( $priority, $biblionumber, $borrowernumber, $reservedate ); @@ -219,13 +220,13 @@ #first : check if we have a reservation for this item . my ($itemnumber) = @_; my $dbh = C4::Context->dbh; - my $query = qq/ + my $query = " SELECT priority,borrowernumber FROM reserves WHERE itemnumber=? AND cancellationdate IS NULL AND found IS NULL AND priority='0' - /; + "; my $sth_find = $dbh->prepare($query); $sth_find->execute($itemnumber); my ( $priority, $borrowernumber ) = $sth_find->fetchrow_array; @@ -233,13 +234,13 @@ return unless $borrowernumber; # step 2 : if we have a borrowernumber, we update the value found to 'W' to notify the borrower - $query = qq/ + $query = " UPDATE reserves SET found='W',waitingdate = now() WHERE borrowernumber=? AND itemnumber=? AND found IS NULL - /; + "; my $sth_set = $dbh->prepare($query); $sth_set->execute( $borrowernumber, $itemnumber ); $sth_set->finish; @@ -258,13 +259,13 @@ my ( $itemnumber, $borrowernumber ) = @_; if ($itemnumber) { my $dbh = C4::Context->dbh; - my $query = qq/ + my $query = " SELECT reservedate,borrowernumber FROM reserves WHERE itemnumber=? AND cancellationdate IS NULL AND (found <> 'F' OR found IS NULL) - /; + "; my $sth_res = $dbh->prepare($query); $sth_res->execute($itemnumber); my ( $reservedate, $borrowernumber ) = $sth_res->fetchrow_array; @@ -272,14 +273,14 @@ } if ($borrowernumber) { my $dbh = C4::Context->dbh; - my $query = qq/ + my $query = " SELECT * FROM reserves WHERE borrowernumber=? AND cancellationdate IS NULL AND (found != 'F' or found is null) ORDER BY reservedate - /; + "; my $sth_find = $dbh->prepare($query); $sth_find->execute($borrowernumber); @@ -324,7 +325,7 @@ my @bind; # Find the desired items in the reserves - my $query = qq/ + my $query = " SELECT branchcode, timestamp AS rtimestamp, priority, @@ -337,7 +338,7 @@ FROM reserves WHERE cancellationdate IS NULL AND (found <> \'F\' OR found IS NULL) - /; + "; if ( $biblionumber ne '' ) { $query .= ' @@ -511,25 +512,25 @@ if ($item) { my $qitem = $dbh->quote($item); # Look up the item by itemnumber - my $query = qq( + my $query = " SELECT items.biblionumber, items.biblioitemnumber, itemtypes.notforloan FROM items, biblioitems, itemtypes WHERE items.biblioitemnumber = biblioitems.biblioitemnumber AND biblioitems.itemtype = itemtypes.itemtype AND itemnumber=$qitem - ); + "; $sth = $dbh->prepare($query); } else { my $qbc = $dbh->quote($barcode); # Look up the item by barcode - my $query = qq( + my $query = " SELECT items.biblionumber, items.biblioitemnumber, itemtypes.notforloan FROM items, biblioitems, itemtypes WHERE items.biblioitemnumber = biblioitems.biblioitemnumber AND biblioitems.itemtype = itemtypes.itemtype AND barcode=$qbc - ); + "; $sth = $dbh->prepare($query); # FIXME - This function uses $item later on. Ought to set it here. @@ -611,14 +612,14 @@ if ( ( $item and $borr ) and ( not $biblio ) ) { # removing a waiting reserve record.... # update the database... - my $query = qq/ + my $query = " UPDATE reserves SET cancellationdate = now(), found = Null, priority = 0 WHERE itemnumber = ? AND borrowernumber = ? - /; + "; my $sth = $dbh->prepare($query); $sth->execute( $item, $borr ); $sth->finish; @@ -844,17 +845,17 @@ # update reserves record.... if ($diffBranchSend) { - $query = qq/ + $query = " UPDATE reserves SET priority = 0, itemnumber = ? WHERE borrowernumber = ? AND biblionumber = ? AND timestamp = ? - /; + "; } else { - $query = qq/ + $query = " UPDATE reserves SET priority = 0, found = 'W', @@ -863,7 +864,7 @@ WHERE borrowernumber = ? AND biblionumber = ? AND timestamp = ? - /; + "; } $sth = $dbh->prepare($query); $sth->execute( $item, $borr, $biblio, $timestamp ); @@ -889,13 +890,13 @@ my ($borr) = @_; my $dbh = C4::Context->dbh; my @itemswaiting; - my $query = qq/ + my $query = " SELECT * FROM reserves WHERE borrowernumber = ? AND reserves.found = 'W' AND cancellationdate IS NULL - /; + "; my $sth = $dbh->prepare($query); $sth->execute($borr); while ( my $data = $sth->fetchrow_hashref ) { @@ -1002,7 +1003,7 @@ #eval { # updates take place here if ( $fee > 0 ) { - my $nextacctno = &getnextacctno( $env, $borrowernumber, $dbh ); + my $nextacctno = &getnextacctno( $borrowernumber ); my $query = qq/ INSERT INTO accountlines (borrowernumber,accountno,date,amount,description,accounttype,amountoutstanding) @@ -1383,6 +1384,63 @@ return ( $#results + 1, \@results ); } + +=head2 GetReservesToBranch + + at transreserv = GetReservesToBranch( $frombranch, $excludingbranch ); + +=cut + +sub GetReservesToBranch { + my ( $frombranch, $excludingbranch ) = @_; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare( + "SELECT borrowernumber,reservedate,itemnumber,timestamp + FROM reserves + WHERE priority='0' AND cancellationdate is null + AND branchcode=? + AND branchcode!=? + AND found IS NULL " + ); + $sth->execute( $frombranch, $excludingbranch ); + my @transreserv; + my $i = 0; + while ( my $data = $sth->fetchrow_hashref ) { + $transreserv[$i] = $data; + $i++; + } + $sth->finish; + return (@transreserv); +} + +=head2 GetReservesForBranch + + at transreserv = GetReservesForBranch($frombranch); + +=cut + +sub GetReservesForBranch { + my ($frombranch) = @_; + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare( " + SELECT borrowernumber,reservedate,itemnumber,waitingdate + FROM reserves + WHERE priority='0' + AND cancellationdate IS NULL + AND found='W' + AND branchcode=? + ORDER BY waitingdate" ); + $sth->execute($frombranch); + my @transreserv; + my $i = 0; + while ( my $data = $sth->fetchrow_hashref ) { + $transreserv[$i] = $data; + $i++; + } + $sth->finish; + return (@transreserv); +} + =back =head1 AUTHOR Index: C4/Circulation/Fines.pm =================================================================== RCS file: /sources/koha/koha/C4/Circulation/Fines.pm,v retrieving revision 1.23 retrieving revision 1.24 diff -u -b -r1.23 -r1.24 --- C4/Circulation/Fines.pm 30 Mar 2007 13:30:36 -0000 1.23 +++ C4/Circulation/Fines.pm 4 Apr 2007 16:46:22 -0000 1.24 @@ -1,6 +1,6 @@ package C4::Circulation::Fines; -# $Id: Fines.pm,v 1.23 2007/03/30 13:30:36 tipaul Exp $ +# $Id: Fines.pm,v 1.24 2007/04/04 16:46:22 tipaul Exp $ # Copyright 2000-2002 Katipo Communications # @@ -29,7 +29,7 @@ use C4::Log; # logaction # set the version for version checking -$VERSION = do { my @v = '$Revision: 1.23 $' =~ /\d+/g; +$VERSION = do { my @v = '$Revision: 1.24 $' =~ /\d+/g; shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); }; =head1 NAME @@ -38,7 +38,7 @@ =head1 SYNOPSIS - use C4::Circulation::Fines; + use C4::Overdues; =head1 DESCRIPTION @@ -439,11 +439,11 @@ # $sth3->finish; # $accountno[0]++; # begin transaction - my $nextaccntno = getnextacctno(undef,$borrowernumber,$dbh); + my $nextaccntno = getnextacctno($borrowernumber); my $sth2 = $dbh->prepare( - "Insert into accountlines + "INSERT INTO accountlines (borrowernumber,itemnumber,date,amount, - description,accounttype,amountoutstanding,accountno) values + description,accounttype,amountoutstanding,accountno) VALUES (?,?,now(),?,?,'FU',?,?)" ); $sth2->execute( $borrowernumber, $itemnum, $amount, @@ -764,11 +764,11 @@ sub CreateItemAccountLine { my ($borrowernumber,$itemnumber,$date,$amount,$description,$accounttype,$amountoutstanding,$timestamp,$notify_id,$level)=@_; my $dbh = C4::Context->dbh; - my $nextaccntno = getnextacctno(undef,$borrowernumber,$dbh); - my $query= qq|INSERT into accountlines + my $nextaccntno = getnextacctno($borrowernumber); + my $query= "INSERT into accountlines (borrowernumber,accountno,itemnumber,date,amount,description,accounttype,amountoutstanding,timestamp,notify_id,notify_level) VALUES - (?,?,?,?,?,?,?,?,?,?,?)|; + (?,?,?,?,?,?,?,?,?,?,?)"; my $sth=$dbh->prepare($query); Index: catalogue/issuehistory.pl =================================================================== RCS file: /sources/koha/koha/catalogue/issuehistory.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- catalogue/issuehistory.pl 9 Mar 2007 15:35:46 -0000 1.2 +++ catalogue/issuehistory.pl 4 Apr 2007 16:46:23 -0000 1.3 @@ -15,7 +15,7 @@ # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA -# $Id: issuehistory.pl,v 1.2 2007/03/09 15:35:46 tipaul Exp $ +# $Id: issuehistory.pl,v 1.3 2007/04/04 16:46:23 tipaul Exp $ use strict; require Exporter; @@ -23,7 +23,7 @@ use C4::Auth; use C4::Interface::CGI::Output; -use C4::Circulation::Circ2; # GetIssuesFromBiblio +use C4::Circulation; # GetBiblioIssues my $query = new CGI; my ( $template, $borrowernumber, $cookie ) = get_template_and_user( @@ -43,7 +43,7 @@ my $title = $params->{'title'}; my $author = $params->{'author'}; -my $issues = GetIssuesFromBiblio($biblionumber); +my $issues = GetBiblioIssues($biblionumber); my $total = scalar @$issues; if ( $total && !$title ) { Index: catalogue/moredetail.pl =================================================================== RCS file: /sources/koha/koha/catalogue/moredetail.pl,v retrieving revision 1.10 retrieving revision 1.11 diff -u -b -r1.10 -r1.11 --- catalogue/moredetail.pl 9 Mar 2007 14:32:39 -0000 1.10 +++ catalogue/moredetail.pl 4 Apr 2007 16:46:23 -0000 1.11 @@ -17,7 +17,7 @@ # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, # Suite 330, Boston, MA 02111-1307 USA -# $Id: moredetail.pl,v 1.10 2007/03/09 14:32:39 tipaul Exp $ +# $Id: moredetail.pl,v 1.11 2007/04/04 16:46:23 tipaul Exp $ use strict; require Exporter; @@ -29,7 +29,7 @@ use C4::Auth; use C4::Interface::CGI::Output; use C4::Date; -use C4::Circulation::Circ2; # to use itemissues +use C4::Circulation; # to use itemissues my $query=new CGI; Index: circ/bookcount.pl =================================================================== RCS file: /sources/koha/koha/circ/bookcount.pl,v retrieving revision 1.2 retrieving revision 1.3 diff -u -b -r1.2 -r1.3 --- circ/bookcount.pl 9 Mar 2007 15:37:12 -0000 1.2 +++ circ/bookcount.pl 4 Apr 2007 16:46:23 -0000 1.3 @@ -1,6 +1,6 @@ #!/usr/bin/perl -# $Id: bookcount.pl,v 1.2 2007/03/09 15:37:12 tipaul Exp $ +# $Id: bookcount.pl,v 1.3 2007/04/04 16:46:23 tipaul Exp $ #written 7/3/2002 by Finlay #script to display reports @@ -25,7 +25,7 @@ use strict; use CGI; use C4::Context; -use C4::Circulation::Circ2; +use C4::Circulation; use C4::Output; use C4::Koha; use C4::Auth; Index: circ/branchoverdues.pl =================================================================== RCS file: /sources/koha/koha/circ/branchoverdues.pl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -b -r1.4 -r1.5 --- circ/branchoverdues.pl 10 Mar 2007 06:28:07 -0000 1.4 +++ circ/branchoverdues.pl 4 Apr 2007 16:46:23 -0000 1.5 @@ -1,6 +1,6 @@ #!/usr/bin/perl -# $Id: branchoverdues.pl,v 1.4 2007/03/10 06:28:07 kados Exp $ +# $Id: branchoverdues.pl,v 1.5 2007/04/04 16:46:23 tipaul Exp $ # # This file is part of Koha. # @@ -23,7 +23,7 @@ use C4::Interface::CGI::Output; use C4::Auth; use C4::Date; -use C4::Circulation::Circ2; # AddNotifyLine +use C4::Overdues; # AddNotifyLine use C4::Koha; # GetDepartment... use Mail::Sendmail; use Getopt::Long; Index: circ/branchreserves.pl =================================================================== RCS file: /sources/koha/koha/circ/branchreserves.pl,v retrieving revision 1.5 retrieving revision 1.6 diff -u -b -r1.5 -r1.6 --- circ/branchreserves.pl 3 Apr 2007 15:04:30 -0000 1.5 +++ circ/branchreserves.pl 4 Apr 2007 16:46:23 -0000 1.6 @@ -1,6 +1,6 @@ #!/usr/bin/perl -# $Id: branchreserves.pl,v 1.5 2007/04/03 15:04:30 alaurin Exp $ +# $Id: branchreserves.pl,v 1.6 2007/04/04 16:46:23 tipaul Exp $ # Copyright 2000-2002 Katipo Communications # @@ -26,7 +26,7 @@ use C4::Branch; # GetBranchName use C4::Auth; use C4::Date; -use C4::Circulation::Circ2; +use C4::Circulation; use Date::Calc qw( Today @@ -77,8 +77,8 @@ # if we have a result if ($nextreservinfo) { - my $borrowerinfo = getpatroninformation( \%env, $nextreservinfo ); - my $iteminfo = C4::Circulation::Circ2::getiteminformation($item); + my $borrowerinfo = GetMemberDetails( $nextreservinfo ); + my $iteminfo = GetBiblioFromItemNumber($item); if ( $messages->{'transfert'} ) { my $branchname = GetBranchName( $messages->{'transfert'} ); $template->param( @@ -114,8 +114,8 @@ foreach my $num (@getreserves) { my %getreserv; my %env; - my $gettitle = getiteminformation( $num->{'itemnumber'} ); - my $getborrower = getpatroninformation( \%env, $num->{'borrowernumber'} ); + my $gettitle = GetBiblioFromItemNumber( $num->{'itemnumber'} ); + my $getborrower = GetMemberDetails( $num->{'borrowernumber'} ); my $itemtypeinfo = getitemtypeinfo( $gettitle->{'itemtype'} ); $getreserv{'waitingdate'} = format_date( $num->{'waitingdate'} ); Index: circ/branchtransfers.pl =================================================================== RCS file: /sources/koha/koha/circ/branchtransfers.pl,v retrieving revision 1.27 retrieving revision 1.28 diff -u -b -r1.27 -r1.28 --- circ/branchtransfers.pl 9 Mar 2007 14:34:31 -0000 1.27 +++ circ/branchtransfers.pl 4 Apr 2007 16:46:23 -0000 1.28 @@ -23,7 +23,7 @@ use strict; use CGI; -use C4::Circulation::Circ2; +use C4::Circulation; use C4::Output; use C4::Reserves2; use C4::Auth; @@ -157,7 +157,7 @@ $item{barcode} = $bc; $item{frombrcd} = $frbcd; $item{tobrcd} = $tobcd; - my ($iteminformation) = getiteminformation( 0, $bc ); + my ($iteminformation) = GetBiblioFromItemNumer( 0, $bc ); $item{'biblionumber'} = $iteminformation->{'biblionumber'}; $item{'title'} = $iteminformation->{'title'}; $item{'author'} = $iteminformation->{'author'}; @@ -193,7 +193,7 @@ if ($found) { my $res = $messages->{'ResFound'}; $branchname = $branches->{ $res->{'branchcode'} }->{'branchname'}; - my ($borr) = getpatroninformation( \%env, $res->{'borrowernumber'}, 0 ); + my ($borr) = GetMemberDetails( $res->{'borrowernumber'}, 0 ); $title = $borr->{'title'}; $surname = $borr->{'surname'}; $firstname = $borr->{'firstname'}; @@ -243,7 +243,7 @@ $err{errwasreturned} = 1; $allmessages = 1; my ($borrowerinfo) = - getpatroninformation( \%env, $messages->{'WasReturned'}, 0 ); + GetMemberDetails( $messages->{'WasReturned'}, 0 ); $title = $borrowerinfo->{'title'};