[Koha-cvs] koha opac/opac-authoritiesdetail.pl opac/opac-a...

paul poulain paul at koha-fr.org
Fri Mar 9 16:47:41 CET 2007


CVSROOT:	/sources/koha
Module name:	koha
Changes by:	paul poulain <tipaul>	07/03/09 15:47:41

Added files:
	opac           : opac-authoritiesdetail.pl 
	                 opac-authorities-home.pl opac-browser.pl 
	                 opac-tags_subject.pl opac-topissues.pl 
	reserve        : renewscript.pl 
	serials        : checkexpiration.pl receipt.pl 
	                 serials-collection.pl serials-edit.pl 
	                 serials-recieve.pl statecollection.pl 

Log message:
	rel_3_0 moved to HEAD (introducing new files)

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-authoritiesdetail.pl?cvsroot=koha&rev=1.2
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-authorities-home.pl?cvsroot=koha&rev=1.2
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-browser.pl?cvsroot=koha&rev=1.2
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-tags_subject.pl?cvsroot=koha&rev=1.2
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-topissues.pl?cvsroot=koha&rev=1.2
http://cvs.savannah.gnu.org/viewcvs/koha/reserve/renewscript.pl?cvsroot=koha&rev=1.5
http://cvs.savannah.gnu.org/viewcvs/koha/serials/checkexpiration.pl?cvsroot=koha&rev=1.2
http://cvs.savannah.gnu.org/viewcvs/koha/serials/receipt.pl?cvsroot=koha&rev=1.2
http://cvs.savannah.gnu.org/viewcvs/koha/serials/serials-collection.pl?cvsroot=koha&rev=1.2
http://cvs.savannah.gnu.org/viewcvs/koha/serials/serials-edit.pl?cvsroot=koha&rev=1.2
http://cvs.savannah.gnu.org/viewcvs/koha/serials/serials-recieve.pl?cvsroot=koha&rev=1.6
http://cvs.savannah.gnu.org/viewcvs/koha/serials/statecollection.pl?cvsroot=koha&rev=1.3

Patches:
Index: opac/opac-authoritiesdetail.pl
===================================================================
RCS file: opac/opac-authoritiesdetail.pl
diff -N opac/opac-authoritiesdetail.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ opac/opac-authoritiesdetail.pl	9 Mar 2007 15:47:41 -0000	1.2
@@ -0,0 +1,201 @@
+#!/usr/bin/perl
+
+# 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
+
+=head1 NAME
+
+etail.pl : script to show an authority in MARC format
+
+=head1 SYNOPSIS
+
+
+=head1 DESCRIPTION
+
+This script needs an authid
+
+It shows the authority in a (nice) MARC format depending on authority MARC
+parameters tables.
+
+=head1 FUNCTIONS
+
+=over 2
+
+=cut
+
+use strict;
+require Exporter;
+use C4::AuthoritiesMarc;
+use C4::Auth;
+use C4::Context;
+use C4::Output;
+use C4::Interface::CGI::Output;
+use CGI;
+use MARC::Record;
+use C4::Koha;
+
+
+my $query = new CGI;
+
+my $dbh = C4::Context->dbh;
+
+my $authid       = $query->param('authid');
+my $authtypecode = &AUTHfind_authtypecode( $dbh, $authid );
+my $tagslib      = &AUTHgettagslib( $dbh, 1, $authtypecode );
+
+# open template
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "opac-authoritiesdetail.tmpl",
+        query           => $query,
+        type            => "opac",
+        authnotrequired => 1,
+        debug           => 1,
+    }
+);
+
+my $record;
+if ( C4::Context->preference("AuthDisplayHierarchy") ) {
+    my $trees = BuildUnimarcHierarchies($authid);
+
+    #   warn "trees :$trees";
+    my @trees = split /;/, $trees;
+    push @trees, $trees unless (@trees);
+    my @loophierarchies;
+    foreach my $tree (@trees) {
+
+        #     warn "tree :$tree";
+
+        my @tree = split /,/, $tree;
+        push @tree, $tree unless (@tree);
+        my $cnt = 0;
+        my @loophierarchy;
+        foreach my $element (@tree) {
+
+            #       warn "tree :$element";
+            my %cell;
+            my $elementdata = AUTHgetauthority( $dbh, $element );
+            $record = $elementdata if ( $authid == $element );
+            push @loophierarchy,
+              BuildUnimarcHierarchy( $elementdata, "child" . $cnt, $authid );
+            $cnt++;
+        }
+        push @loophierarchies, { 'loopelement' => \@loophierarchy };
+        $template->param(
+            'displayhierarchy' =>
+              C4::Context->preference("AuthDisplayHierarchy"),
+            'loophierarchies' => \@loophierarchies,
+        );
+    }
+}
+else {
+    $record = AUTHgetauthority( $dbh, $authid );
+}
+my $count = AUTHcount_usage($authid);
+
+# find the marc field/subfield used in biblio by this authority
+my $sth =
+  $dbh->prepare(
+    "select distinct tagfield from marc_subfield_structure where authtypecode=?"
+  );
+$sth->execute($authtypecode);
+my $biblio_fields;
+while ( my ($tagfield) = $sth->fetchrow ) {
+    $biblio_fields .= $tagfield . "9,";
+}
+chop $biblio_fields;
+
+# fill arrays
+my @loop_data = ();
+my $tag;
+
+# loop through each tab 0 through 9
+# for (my $tabloop = 0; $tabloop<=10;$tabloop++) {
+# loop through each tag
+my @fields    = $record->fields();
+foreach my $field (@fields) {
+    my @subfields_data;
+
+    # if tag <10, there's no subfield, use the "@" trick
+    if ( $field->tag() < 10 ) {
+        next if ( $tagslib->{ $field->tag() }->{'@'}->{hidden} );
+        my %subfield_data;
+        $subfield_data{marc_lib}   = $tagslib->{ $field->tag() }->{'@'}->{lib};
+        $subfield_data{marc_value} = $field->data();
+        $subfield_data{marc_subfield} = '@';
+        $subfield_data{marc_tag}      = $field->tag();
+        push( @subfields_data, \%subfield_data );
+    }
+    else {
+        my @subf = $field->subfields;
+
+        # loop through each subfield
+        for my $i ( 0 .. $#subf ) {
+            $subf[$i][0] = "@" unless $subf[$i][0];
+            next if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{hidden} );
+            my %subfield_data;
+            $subfield_data{marc_lib} =
+              $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{lib};
+            if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{isurl} ) {
+                $subfield_data{marc_value} =
+                  "<a href=\"$subf[$i][1]\">$subf[$i][1]</a>";
+            }
+            else {
+                $subfield_data{marc_value} = $subf[$i][1];
+            }
+            $subfield_data{marc_subfield} = $subf[$i][0];
+            $subfield_data{marc_tag}      = $field->tag();
+            push( @subfields_data, \%subfield_data );
+        }
+    }
+    if ( $#subfields_data >= 0 ) {
+        my %tag_data;
+        $tag_data{tag} =
+          $field->tag() . ' -' . $tagslib->{ $field->tag() }->{lib};
+        $tag_data{subfield} = \@subfields_data;
+        push( @loop_data, \%tag_data );
+    }
+}
+$template->param( "0XX" => \@loop_data );
+
+my $authtypes = getauthtypes;
+my @authtypesloop;
+foreach my $thisauthtype ( keys %$authtypes ) {
+    my $selected = 1 if $thisauthtype eq $authtypecode;
+    my %row = (
+        value        => $thisauthtype,
+        selected     => $selected,
+        authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
+    );
+    push @authtypesloop, \%row;
+}
+
+$template->param(
+    authid               => $authid,
+    count                => $count,
+    biblio_fields        => $biblio_fields,
+    authtypetext         => $authtypes->{$authtypecode}{'authtypetext'},
+    authtypesloop        => \@authtypesloop,
+    LibraryName          => C4::Context->preference("LibraryName"),
+    OpacNav              => C4::Context->preference("OpacNav"),
+    opaccredits          => C4::Context->preference("opaccredits"),
+    opacsmallimage       => C4::Context->preference("opacsmallimage"),
+    opaclayoutstylesheet => C4::Context->preference("opaclayoutstylesheet"),
+    opaccolorstylesheet  => C4::Context->preference("opaccolorstylesheet"),
+);
+output_html_with_http_headers $query, $cookie, $template->output;
+

Index: opac/opac-authorities-home.pl
===================================================================
RCS file: opac/opac-authorities-home.pl
diff -N opac/opac-authorities-home.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ opac/opac-authorities-home.pl	9 Mar 2007 15:47:41 -0000	1.2
@@ -0,0 +1,269 @@
+#!/usr/bin/perl
+# WARNING: 4-character tab stops here
+
+# 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;
+require Exporter;
+use CGI;
+use C4::Auth;
+
+use C4::Context;
+use C4::Auth;
+use C4::Output;
+use C4::Interface::CGI::Output;
+use C4::AuthoritiesMarc;
+use C4::Koha;    # XXX subfield_is_koha_internal_p
+
+my $query        = new CGI;
+my $op           = $query->param('op');
+my $authtypecode = $query->param('authtypecode');
+my $dbh          = C4::Context->dbh;
+
+my $startfrom = $query->param('startfrom');
+my $authid    = $query->param('authid');
+$startfrom = 0 if ( !defined $startfrom );
+my ( $template, $loggedinuser, $cookie );
+my $resultsperpage;
+
+my $authtypes = getauthtypes;
+my @authtypesloop;
+foreach my $thisauthtype ( sort { $authtypes->{$a} <=> $authtypes->{$b} }
+    keys %$authtypes )
+{
+    my $selected = 1 if $thisauthtype eq $authtypecode;
+    my %row = (
+        value        => $thisauthtype,
+        selected     => $selected,
+        authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
+    );
+    push @authtypesloop, \%row;
+}
+
+if ( $op eq "do_search" ) {
+    my @marclist  = $query->param('marclist');
+    my @and_or    = $query->param('and_or');
+    my @excluding = $query->param('excluding');
+    my @operator  = $query->param('operator');
+    my @value     = $query->param('value');
+
+    $resultsperpage = $query->param('resultsperpage');
+    $resultsperpage = 19 if ( !defined $resultsperpage );
+    my @tags;
+    my ( $results, $total, @fields ) =
+      authoritysearch( $dbh, \@marclist, \@and_or, \@excluding, \@operator,
+        \@value, $startfrom * $resultsperpage,
+        $resultsperpage, $authtypecode );
+    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+        {
+            template_name   => "opac-authoritiessearchresultlist.tmpl",
+            query           => $query,
+            type            => 'opac',
+            authnotrequired => 1,
+            debug           => 1,
+        }
+    );
+
+    # multi page display gestion
+    my $displaynext = 0;
+    my $displayprev = $startfrom;
+    if ( ( $total - ( ( $startfrom + 1 ) * ($resultsperpage) ) ) > 0 ) {
+        $displaynext = 1;
+    }
+
+    my @field_data = ();
+
+# we must get parameters once again. Because if there is a mainentry, it has been replaced by something else during the search, thus the links next/previous would not work anymore
+    my @marclist_ini = $query->param('marclist');
+    for ( my $i = 0 ; $i <= $#marclist ; $i++ ) {
+        push @field_data, { term => "marclist",  val => $marclist_ini[$i] };
+        push @field_data, { term => "and_or",    val => $and_or[$i] };
+        push @field_data, { term => "excluding", val => $excluding[$i] };
+        push @field_data, { term => "operator",  val => $operator[$i] };
+        push @field_data, { term => "value",     val => $value[$i] };
+    }
+
+    my @numbers = ();
+
+    if ( $total > $resultsperpage ) {
+        for ( my $i = 1 ; $i < $total / $resultsperpage + 1 ; $i++ ) {
+            if ( $i < 16 ) {
+                my $highlight = 0;
+                ( $startfrom == ( $i - 1 ) ) && ( $highlight = 1 );
+                push @numbers,
+                  {
+                    number     => $i,
+                    highlight  => $highlight,
+                    searchdata => \@field_data,
+                    startfrom  => ( $i - 1 )
+                  };
+            }
+        }
+    }
+
+    my $from = $startfrom * $resultsperpage + 1;
+    my $to;
+
+    if ( $total < ( ( $startfrom + 1 ) * $resultsperpage ) ) {
+        $to = $total;
+    }
+    else {
+        $to = ( ( $startfrom + 1 ) * $resultsperpage );
+    }
+    $template->param( result => $results ) if $results;
+    $template->param( FIELDS => \@fields );
+    $template->param(
+        startfrom      => $startfrom,
+        displaynext    => $displaynext,
+        displayprev    => $displayprev,
+        resultsperpage => $resultsperpage,
+        startfromnext  => $startfrom + 1,
+        startfromprev  => $startfrom - 1,
+        searchdata     => \@field_data,
+        total          => $total,
+        from           => $from,
+        to             => $to,
+        numbers        => \@numbers,
+        authtypecode   => $authtypecode,
+        isEDITORS      => $authtypecode eq 'EDITORS',
+    );
+
+}
+elsif ( $op eq "delete" ) {
+
+    &AUTHdelauthority( $dbh, $authid, 1 );
+
+    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+        {
+            template_name   => "authorities/authorities-home.tmpl",
+            query           => $query,
+            type            => 'intranet',
+            authnotrequired => 0,
+            flagsrequired   => { catalogue => 1 },
+            debug           => 1,
+        }
+    );
+
+    # 	$template->param("statements" => \@statements,
+    # 						"nbstatements" => $nbstatements);
+}
+elsif ( $op eq "AddStatement" ) {
+
+    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+        {
+            template_name   => "authorities/authorities-home.tmpl",
+            query           => $query,
+            type            => 'intranet',
+            authnotrequired => 0,
+            flagsrequired   => { catalogue => 1 },
+            debug           => 1,
+        }
+    );
+
+    # Gets the entered information
+    my @marcfields = $query->param('marclist');
+    my @and_or     = $query->param('and_or');
+    my @excluding  = $query->param('excluding');
+    my @operator   = $query->param('operator');
+    my @value      = $query->param('value');
+
+    my @statements = ();
+
+    # List of the marc tags to display
+    my $marcarray = create_marclist();
+
+    my $nbstatements = $query->param('nbstatements');
+    $nbstatements = 1 if ( !defined $nbstatements );
+
+    for ( my $i = 0 ; $i < $nbstatements ; $i++ ) {
+        my %fields = ();
+
+        # Recreates the old scrolling lists with the previously selected values
+        my $marclist = create_scrolling_list(
+            {
+                name     => "marclist",
+                values   => $marcarray,
+                size     => 1,
+                default  => $marcfields[$i],
+                onChange => "sql_update()"
+            }
+        );
+
+        $fields{'marclist'} = $marclist;
+        $fields{'first'}    = 1 if ( $i == 0 );
+
+# Restores the and/or parameters (no need to test the 'and' for activation because it's the default value)
+        $fields{'or'} = 1 if ( $and_or[$i] eq "or" );
+
+        #Restores the "not" parameters
+        $fields{'not'} = 1 if ( $excluding[$i] );
+
+        #Restores the operators (most common operators first);
+        if    ( $operator[$i] eq "=" )        { $fields{'eq'}       = 1; }
+        elsif ( $operator[$i] eq "contains" ) { $fields{'contains'} = 1; }
+        elsif ( $operator[$i] eq "start" )    { $fields{'start'}    = 1; }
+        elsif ( $operator[$i] eq ">" )  { $fields{'gt'} = 1; } #greater than
+        elsif ( $operator[$i] eq ">=" ) { $fields{'ge'} = 1; } #greater or equal
+        elsif ( $operator[$i] eq "<" )  { $fields{'lt'} = 1; } #lower than
+        elsif ( $operator[$i] eq "<=" ) { $fields{'le'} = 1; } #lower or equal
+
+        #Restores the value
+        $fields{'value'} = $value[$i];
+
+        push @statements, \%fields;
+    }
+    $nbstatements++;
+
+    # The new scrolling list
+    my $marclist = create_scrolling_list(
+        {
+            name     => "marclist",
+            values   => $marcarray,
+            size     => 1,
+            onChange => "sql_update()"
+        }
+    );
+    push @statements, { "marclist" => $marclist };
+
+    $template->param(
+        "statements"   => \@statements,
+        "nbstatements" => $nbstatements
+    );
+
+}
+else {
+    ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+        {
+            template_name   => "opac-authorities-home.tmpl",
+            query           => $query,
+            type            => 'opac',
+            authnotrequired => 1,
+            debug           => 1,
+        }
+    );
+
+}
+
+$template->param( authtypesloop => \@authtypesloop );
+
+# Print the page
+output_html_with_http_headers $query, $cookie, $template->output;
+
+# Local Variables:
+# tab-width: 4
+# End:

Index: opac/opac-browser.pl
===================================================================
RCS file: opac/opac-browser.pl
diff -N opac/opac-browser.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ opac/opac-browser.pl	9 Mar 2007 15:47:41 -0000	1.2
@@ -0,0 +1,85 @@
+#!/usr/bin/perl
+
+# 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
+
+# $Id: opac-browser.pl,v 1.2 2007/03/09 15:47:41 tipaul Exp $
+
+=head1 opac-tags_subject.pl
+
+TODO :: Description here
+
+=cut
+
+use strict;
+require Exporter;
+use C4::Auth;
+use C4::Context;
+use C4::Output;
+use C4::Interface::CGI::Output;
+use CGI;
+use C4::Biblio;
+use C4::Koha;       # use getitemtypeinfo
+
+my $query = new CGI;
+
+my $dbh = C4::Context->dbh;
+
+# open template
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "opac-browser.tmpl",
+        query           => $query,
+        type            => "opac",
+        authnotrequired => 1,
+        debug           => 1,
+    }
+);
+
+# the level of browser to display
+my $level = $query->param('level') || 0;
+my $filter = $query->param('filter');
+$level++; # the level passed is the level of the PREVIOUS list, not the current one. Thus the ++
+
+# build this level loop
+my $sth = $dbh->prepare("SELECT * FROM browser WHERE level=? and classification like ? ORDER BY classification");
+$sth->execute($level,$filter."%");
+my @level_loop;
+my $i=0;
+while (my $line = $sth->fetchrow_hashref) {
+    $line->{description} =~ s/\((.*)\)//g;
+    $i++;
+    $line->{count3}=1 unless $i %3;
+    push @level_loop,$line;
+}
+
+# now rebuild hierarchy loop
+$sth = $dbh->prepare("SELECT * FROM browser where classification=?");
+$filter =~ s/\.//g;
+my @hierarchy_loop;
+for (my $i=1;$i <=length($filter);$i++) {
+    $sth->execute(substr($filter,0,$i));
+    my $line = $sth->fetchrow_hashref;
+    push @hierarchy_loop,$line;
+}
+
+$template->param(
+    LEVEL_LOOP => \@level_loop,
+    HIERARCHY_LOOP => \@hierarchy_loop,
+);
+
+output_html_with_http_headers $query, $cookie, $template->output;

Index: opac/opac-tags_subject.pl
===================================================================
RCS file: opac/opac-tags_subject.pl
diff -N opac/opac-tags_subject.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ opac/opac-tags_subject.pl	9 Mar 2007 15:47:41 -0000	1.2
@@ -0,0 +1,82 @@
+#!/usr/bin/perl
+
+# 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
+
+# $Id: opac-tags_subject.pl,v 1.2 2007/03/09 15:47:41 tipaul Exp $
+
+=head1 opac-tags_subject.pl
+
+TODO :: Description here
+
+=cut
+
+use strict;
+require Exporter;
+use C4::Auth;
+use C4::Context;
+use C4::Output;
+use C4::Interface::CGI::Output;
+use CGI;
+use C4::Biblio;
+use C4::Koha;       # use getitemtypeinfo
+
+my $query = new CGI;
+
+my $dbh = C4::Context->dbh;
+
+# open template
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "opac-tags_subject.tmpl",
+        query           => $query,
+        type            => "opac",
+        authnotrequired => 1,
+        debug           => 1,
+    }
+);
+
+my $number = $query->param('number') || 100;
+
+my $sth = $dbh->prepare("SELECT entry,weight FROM tags ORDER BY weight DESC LIMIT $number");
+$sth->execute;
+
+my %result;
+my $max=0;
+my $min=9999;
+my ($entry,$weight);
+while (($entry,$weight) = $sth->fetchrow) {
+    $result{$entry}=$weight;
+    $max = $weight if $weight > $max;
+    $min = $weight if $weight < $min;
+}
+
+$min++ if $min == $max;
+
+my @loop;
+foreach my $entry (sort keys %result) {
+    my %line;
+    $line{entry} = $entry;
+    $line{weight} = int(($result{$entry}-$min)/($max-$min)*25)+10;
+    push @loop, \%line;
+}
+$template->param(
+    LOOP => \@loop,
+    number => $number
+);
+
+output_html_with_http_headers $query, $cookie, $template->output;

Index: opac/opac-topissues.pl
===================================================================
RCS file: opac/opac-topissues.pl
diff -N opac/opac-topissues.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ opac/opac-topissues.pl	9 Mar 2007 15:47:41 -0000	1.2
@@ -0,0 +1,120 @@
+#!/usr/bin/perl
+
+# $Id: opac-topissues.pl,v 1.2 2007/03/09 15:47:41 tipaul 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::Auth;
+use CGI;
+use C4::Context;
+use C4::Search;
+use C4::Output;
+use C4::Koha;
+use C4::Branch;
+use C4::Interface::CGI::Output;
+use Date::Manip;
+
+=head1 NAME
+
+plugin that shows a stats on borrowers
+
+=head1 DESCRIPTION
+
+
+=over2
+
+=cut
+
+my $input = new CGI;
+my $branches = GetBranches();
+my $itemtypes = GetItemTypes();
+
+my ($template, $borrowernumber, $cookie)
+	= get_template_and_user({template_name => 'opac-topissues.tmpl',
+				query => $input,
+				type => "opac",
+				authnotrequired => 1,
+				debug => 1,
+				});
+my $dbh = C4::Context->dbh;
+# Displaying results
+my $limit = $input->param('limit') || 10;
+my $branch = $input->param('branch');
+my $itemtype = $input->param('itemtype');
+my $timeLimit = $input->param('timeLimit') || 3;
+my $whereclause;
+$whereclause .= 'items.homebranch='.$dbh->quote($branch)." AND " if ($branch); 
+$whereclause .= 'biblioitems.itemtype='.$dbh->quote($itemtype)." AND " if $itemtype;
+$whereclause .= 'TO_DAYS(NOW()) - TO_DAYS(biblio.timestamp) <= '.$timeLimit*30 if $timeLimit;
+$whereclause =~ s/ AND $//;
+$whereclause = " WHERE ".$whereclause if $whereclause;
+my $query = "SELECT biblio.timestamp, biblio.biblionumber, title, 
+                author, sum( items.issues ) AS tot, biblioitems.itemtype,
+                biblioitems.publishercode,biblioitems.publicationyear,
+                itemtypes.description
+                FROM biblio
+                LEFT JOIN items USING (biblionumber)
+                LEFT JOIN biblioitems USING (biblionumber)
+                LEFT JOIN itemtypes ON itemtypes.itemtype = biblioitems.itemtype
+                $whereclause
+                GROUP BY biblio.biblionumber
+                ORDER BY tot DESC
+                LIMIT $limit
+                ";
+
+my $sth = $dbh->prepare($query);
+$sth->execute();
+my @results;
+while (my $line= $sth->fetchrow_hashref) {
+    push @results, $line;
+}
+
+$template->param(do_it => 1,
+                limit => $limit,
+                branch => $branches->{$branch}->{branchname},
+                itemtype => $itemtypes->{$itemtype}->{description},
+                timeLimit => $timeLimit,
+                results_loop => \@results,
+                );
+
+my $branches = GetBranches;
+my @branchloop;
+foreach my $thisbranch (keys %$branches) {
+        my %row =(value => $thisbranch,
+                    branchname => $branches->{$thisbranch}->{'branchname'},
+                        );
+        push @branchloop, \%row;
+}
+
+#doctype
+my $itemtypes = GetItemTypes;
+my @itemtypeloop;
+foreach my $thisitemtype (keys %$itemtypes) {
+        my %row =(value => $thisitemtype,
+                    description => $itemtypes->{$thisitemtype}->{'description'},
+                        );
+        push @itemtypeloop, \%row;
+}
+
+$template->param(
+                branchloop =>\@branchloop,
+                itemtypeloop =>\@itemtypeloop,
+                );
+output_html_with_http_headers $input, $cookie, $template->output;
+

Index: reserve/renewscript.pl
===================================================================
RCS file: reserve/renewscript.pl
diff -N reserve/renewscript.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ reserve/renewscript.pl	9 Mar 2007 15:47:41 -0000	1.5
@@ -0,0 +1,69 @@
+#!/usr/bin/perl
+
+# $Id: renewscript.pl,v 1.5 2007/03/09 15:47:41 tipaul Exp $
+
+#written 18/1/2000 by chris at katipo.co.nz
+#script to renew items from the web
+
+
+# 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 CGI;
+use C4::Circulation::Circ2;
+
+my $input = new CGI;
+
+#
+# find items to renew, all items or a selection of items
+#
+
+my @data;
+if ($input->param('renew_all')) {
+    @data = $input->param('all_items[]');
+}
+else {
+    @data = $input->param('items[]');
+}
+
+#
+# renew items
+#
+my %env;
+my $cardnumber = $input->param("cardnumber");
+my $borrowernumber = $input->param("borrowernumber");
+
+foreach my $itemno (@data) {
+    #check status before renewing issue
+    if (renewstatus(\%env,$borrowernumber,$itemno)){
+        renewbook(\%env,$borrowernumber,$itemno);
+    }
+}
+
+#
+# redirection to the referrer page
+#
+if ($input->param('destination') eq "circ"){
+    print $input->redirect(
+        '/cgi-bin/koha/circ/circulation.pl?findborrower='.$cardnumber
+    );
+}
+else {
+    print $input->redirect(
+        '/cgi-bin/koha/members/moremember.pl?borrowernumber='.$borrowernumber
+    );
+}

Index: serials/checkexpiration.pl
===================================================================
RCS file: serials/checkexpiration.pl
diff -N serials/checkexpiration.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ serials/checkexpiration.pl	9 Mar 2007 15:47:41 -0000	1.2
@@ -0,0 +1,100 @@
+#!/usr/bin/perl
+
+#
+# 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: checkexpiration.pl,v 1.2 2007/03/09 15:47:41 tipaul Exp $
+
+=head1 NAME
+
+checkexpiration.pl
+
+=head1 DESCRIPTION
+
+This script check what subscription will expire before C<$datenumber $datelimit>
+
+=head1 PARAMETERS
+
+=over 4
+
+=item title
+    To filter subscription on title
+
+=item issn
+    To filter subscription on issn
+
+=item date
+The date to filter on.
+
+=back
+
+=cut
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Serials; # GetExpirationDate
+use C4::Output;
+use C4::Interface::CGI::Output;
+use C4::Context;
+use Date::Calc qw/Today Date_to_Days/;
+
+my $query = new CGI;
+
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user (
+    {
+        template_name   => "serials/checkexpiration.tmpl",
+        query           => $query,
+        type            => "intranet",
+        authnotrequired => 0,
+        flagsrequired   => { serials => 1 },
+        debug           => 1,
+    }
+);
+
+my $title = $query->param('title');
+my $issn  = $query->param('issn');
+my $date  = $query->param('date');
+my $today = join "-",&Today;
+
+if ($date) {
+
+    my @subscriptions = GetSubscriptions( $title, $issn );
+    my @subscriptions_loop;
+
+    foreach my $subscription ( @subscriptions ) {
+        my $subscriptionid = $subscription->{'subscriptionid'};
+        my $expirationdate = GetExpirationDate($subscriptionid);
+
+        $subscription->{expirationdate} = $expirationdate;
+        next if $expirationdate !~ /\d{4}-\d{2}-\d{2}/; # next if not in good format.
+        if ( Date_to_Days(split "-",$expirationdate) < Date_to_Days(split "-",$date) &&
+             Date_to_Days(split "-",$expirationdate) > Date_to_Days(split "-",$today) ) {
+            push @subscriptions_loop,$subscription;             
+        }
+    }
+    
+    $template->param (
+        title           => $title,
+        issn            => $issn,
+        numsubscription => scalar @subscriptions_loop,
+        date => $date,
+        subscriptions_loop => \@subscriptions_loop,
+        "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
+    );
+}
+
+output_html_with_http_headers $query, $cookie, $template->output;

Index: serials/receipt.pl
===================================================================
RCS file: serials/receipt.pl
diff -N serials/receipt.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ serials/receipt.pl	9 Mar 2007 15:47:41 -0000	1.2
@@ -0,0 +1,154 @@
+#!/usr/bin/perl
+
+# 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
+
+# $Id: receipt.pl,v 1.2 2007/03/09 15:47:41 tipaul Exp $
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Output;
+use C4::Interface::CGI::Output;
+use C4::Context;
+
+
+my $query = new CGI;
+
+my $op = $query->param('op');
+my $search = $query->param('titleorissn');
+my $startfrom=$query->param('startfrom');
+
+if ($op eq 'search')
+{
+    my $total;
+    my $results;
+    my $dbh = C4::Context->dbh;
+    my @marclist = $query->param('marclist');
+	my @and_or = $query->param('and_or');
+	my @excluding = $query->param('excluding');
+	my @operator = $query->param('operator');
+	my @value = $query->param('value');
+
+	my $resultsperpage= $query->param('resultsperpage');
+	$resultsperpage = 19 unless $resultsperpage;
+
+
+    my $sth = $dbh->prepare("select subscriptionid, biblionumber from subscription");
+    $sth->execute();
+    my @finalsolution;
+    while (my $first_step = $sth->fetchrow_hashref)
+    {
+	my $sth2 = $dbh->prepare("select b3.title from biblioitems b2, biblio b3 where b3.biblionumber = ? and b2.biblionumber = b3.biblionumber and (b2.issn = ? or b3.title like ?)");
+	$sth2->execute($first_step->{'biblionumber'},$search, "%$search%");
+	my @answear;
+	@answear = $sth2->fetchrow_array;
+	$total = scalar @answear;
+	if ($total >= 1)
+	{
+	    $first_step->{'serial'} = $answear[0];
+	    push @finalsolution ,$first_step;
+	}
+    }
+my ($template, $loggedinuser, $cookie)
+= get_template_and_user({template_name => "serials/receipt-search-result.tmpl",
+				query => $query,
+				type => "intranet",
+				authnotrequired => 0,
+				flagsrequired => {serials => 1},
+				debug => 1,
+				});
+    $template->param(subtable => \@finalsolution, total => $total
+		,);
+
+	my $displaynext=0;
+	my $displayprev=$startfrom;
+	if(($total - (($startfrom+1)*($resultsperpage))) > 0 ){
+		$displaynext = 1;
+	}
+
+	my @field_data = ();
+
+
+	for(my $i = 0 ; $i <= $#marclist ; $i++)
+	{
+		push @field_data, { term => "marclist", val=>$marclist[$i] };
+		push @field_data, { term => "and_or", val=>$and_or[$i] };
+		push @field_data, { term => "excluding", val=>$excluding[$i] };
+		push @field_data, { term => "operator", val=>$operator[$i] };
+		push @field_data, { term => "value", val=>$value[$i] };
+	}
+
+	my @numbers = ();
+
+	if ($total>$resultsperpage)
+	{
+		for (my $i=1; $i<$total/$resultsperpage+1; $i++)
+		{
+			if ($i<16)
+			{
+	    		my $highlight=0;
+	    		($startfrom==($i-1)) && ($highlight=1);
+	    		push @numbers, { number => $i,
+					highlight => $highlight ,
+					searchdata=> \@field_data,
+					startfrom => ($i-1)};
+			}
+    	}
+	}
+
+	my $from = $startfrom*$resultsperpage+1;
+	my $to;
+
+ 	if($total < (($startfrom+1)*$resultsperpage))
+	{
+		$to = $total;
+	} else {
+		$to = (($startfrom+1)*$resultsperpage);
+	}
+    $results = \@finalsolution;
+	$template->param(result => $results) if $results;
+	$template->param(
+							startfrom=> $startfrom,
+							displaynext=> $displaynext,
+							displayprev=> $displayprev,
+							resultsperpage => $resultsperpage,
+							startfromnext => $startfrom+1,
+							startfromprev => $startfrom-1,
+							searchdata=>\@field_data,
+							total=>$total,
+							from=>$from,
+							to=>$to,
+							numbers=>\@numbers,
+							intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
+		intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+		IntranetNav => C4::Context->preference("IntranetNav"),
+							);
+output_html_with_http_headers $query, $cookie, $template->output;
+
+}
+else{
+my ($template, $loggedinuser, $cookie)
+= get_template_and_user({template_name => "serials/receipt.tmpl",
+				query => $query,
+				type => "intranet",
+				authnotrequired => 0,
+				flagsrequired => {serials => 1},
+				debug => 1,
+				});
+output_html_with_http_headers $query, $cookie, $template->output;
+}

Index: serials/serials-collection.pl
===================================================================
RCS file: serials/serials-collection.pl
diff -N serials/serials-collection.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ serials/serials-collection.pl	9 Mar 2007 15:47:41 -0000	1.2
@@ -0,0 +1,112 @@
+#!/usr/bin/perl
+
+# 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
+
+# $Id: serials-collection.pl,v 1.2 2007/03/09 15:47:41 tipaul Exp $
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Koha;
+use C4::Date;
+use C4::Serials;
+use C4::Letters;
+use C4::Output;
+use C4::Interface::CGI::Output;
+use C4::Context;
+
+
+my $query = new CGI;
+my $op = $query->param('op');
+my $dbh = C4::Context->dbh;
+
+my $sth;
+# my $id;
+my ($template, $loggedinuser, $cookie);
+($template, $loggedinuser, $cookie)
+  = get_template_and_user({template_name => "serials/serials-collection.tmpl",
+                            query => $query,
+                            type => "intranet",
+                            authnotrequired => 0,
+                            flagsrequired => {serials => 1},
+                            debug => 1,
+                            });
+my $biblionumber = $query->param('biblionumber');
+my @subscriptionid = $query->param('subscriptionid');
+
+my $subscriptiondescs ;
+my $subscriptions;
+if (@subscriptionid){
+   my @subscriptioninformation=();
+   foreach my $subscriptionid (@subscriptionid){
+    my $subs= GetSubscription($subscriptionid);
+    $subs->{opacnote}     =~ s/\n/\<br\/\>/g;
+    $subs->{missinglist}  =~ s/\n/\<br\/\>/g;
+    $subs->{recievedlist} =~ s/\n/\<br\/\>/g;
+    ##these are display information
+    $subs->{ "periodicity" . $subs->{periodicity} } = 1;
+    $subs->{ "numberpattern" . $subs->{numberpattern} } = 1;
+    $subs->{ "status" . $subs->{'status'} } = 1;
+    $subs->{startdate}     = format_date( $subs->{startdate} );
+    $subs->{histstartdate} = format_date( $subs->{histstartdate} );
+    if ( $subs->{enddate} eq '0000-00-00' ) {
+        $subs->{enddate} = '';
+    }
+    else {
+        $subs->{enddate} = format_date( $subs->{enddate} );
+    }
+    $subs->{'abouttoexpire'}=abouttoexpire($subs->{'subscriptionid'});
+    $subs->{'subscriptionexpired'}=HasSubscriptionExpired($subs->{'subscriptionid'});
+    push @$subscriptiondescs,$subs;
+    my $tmpsubscription= GetFullSubscription($subscriptionid);
+    @subscriptioninformation=(@$tmpsubscription, at subscriptioninformation);
+  }
+  $subscriptions=PrepareSerialsData(\@subscriptioninformation);
+} else {
+  $subscriptiondescs = GetSubscriptionsFromBiblionumber($biblionumber) ;
+  my $subscriptioninformation = GetFullSubscriptionsFromBiblionumber($biblionumber);
+  $subscriptions=PrepareSerialsData($subscriptioninformation);
+}
+
+my $title = $subscriptiondescs->[0]{bibliotitle};
+my $yearmax=($subscriptions->[0]{year} eq "manage" && scalar(@$subscriptions)>1)? $subscriptions->[1]{year} :$subscriptions->[0]{year};
+my $yearmin=$subscriptions->[scalar(@$subscriptions)-1]{year};
+my $subscriptionidlist="";
+foreach my $subscription (@$subscriptiondescs){
+  $subscriptionidlist.=$subscription->{'subscriptionid'}."," ;
+  $biblionumber = $subscription->{'bibnum'} unless ($biblionumber);
+}
+
+# warn "title : $title yearmax : $yearmax nombre d'elements dans le tableau :".scalar(@$subscriptions);
+#  use Data::Dumper; warn Dumper($subscriptions);
+chop $subscriptionidlist;
+$template->param(
+          onesubscription => (scalar(@$subscriptiondescs)==1),
+          subscriptionidlist => $subscriptionidlist,
+          biblionumber => $biblionumber,
+          subscriptions => $subscriptiondescs,
+          years => $subscriptions,
+          yearmin => $yearmin,
+          yearmax =>$yearmax,
+          bibliotitle => $title,
+          suggestion => C4::Context->preference("suggestion"),
+          virtualshelves => C4::Context->preference("virtualshelves"),
+          subscr=>$query->param('subscriptionid'),
+          );
+
+output_html_with_http_headers $query, $cookie, $template->output;

Index: serials/serials-edit.pl
===================================================================
RCS file: serials/serials-edit.pl
diff -N serials/serials-edit.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ serials/serials-edit.pl	9 Mar 2007 15:47:41 -0000	1.2
@@ -0,0 +1,259 @@
+#!/usr/bin/perl
+
+# 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
+
+# $Id: serials-edit.pl,v 1.2 2007/03/09 15:47:41 tipaul Exp $
+
+=head1 NAME
+
+serials-recieve.pl
+
+=head1 Parameters
+
+=over 4
+
+=item op
+op can be :
+    * modsubscriptionhistory :to modify the subscription history 
+    * serialchangestatus     :to modify the status of this subscription
+
+=item subscriptionid
+
+=item user
+
+=item histstartdate
+
+=item enddate
+
+=item recievedlist
+
+=item missinglist
+
+=item opacnote
+
+=item librariannote
+
+=item serialid
+
+=item serialseq
+
+=item planneddate
+
+=item notes
+
+=item status
+
+=back
+
+=cut
+
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Date;
+use C4::Biblio;
+use C4::Koha;
+use C4::Output;
+use C4::Interface::CGI::Output;
+use C4::Context;
+use C4::Serials;
+
+my $query = new CGI;
+my $dbh = C4::Context->dbh;
+my @serialids = $query->param('serialid');
+my @serialseqs = $query->param('serialseq');
+my @planneddates = $query->param('planneddate');
+my @publisheddates = $query->param('publisheddate');
+my @status = $query->param('status');
+my @notes = $query->param('notes');
+my @subscriptionids = $query->param('subscriptionid');
+my $op = $query->param('op');
+# warn "op : $op";
+if (scalar(@subscriptionids)==1 && index($subscriptionids[0],",")>0){
+  @subscriptionids =split /,/,$subscriptionids[0];
+}
+my $redirectstring;
+# If user comes from subscription details
+unless (@serialids){
+  foreach my $subscriptionid (@subscriptionids){
+    my $serstatus=$query->param('serstatus');
+    if ($serstatus){
+      my ($count, at tmpser)=GetSerials2($subscriptionid,$serstatus);
+      foreach (@tmpser) {
+        push @serialids, $_->{'serialid'};
+      }
+    }
+  }
+}
+
+my ($template, $loggedinuser, $cookie)
+= get_template_and_user({template_name => "serials/serials-edit.tmpl",
+                query => $query,
+                type => "intranet",
+                authnotrequired => 0,
+                flagsrequired => {serials => 1},
+                debug => 1,
+                });
+
+my @serialdatalist;
+foreach my $tmpserialid (@serialids){
+  my $data=GetSerialInformation($tmpserialid);
+  $data->{publisheddate}=format_date($data->{publisheddate});
+  $data->{planneddate}=format_date($data->{planneddate});
+  push @serialdatalist,$data;
+}
+
+my @newserialloop;
+my @subscriptionloop;
+foreach my $subscriptionid (@subscriptionids){
+  my $cell;
+  if (C4::Context->preference("serialsadditems")){
+  #Create New empty item  
+    $cell =
+      PrepareItemrecordDisplay( $serialdatalist[0]->{'biblionumber'} );
+  }
+  $cell->{'subscriptionid'}=$subscriptionid;
+  $cell->{'subscriptionexpired'}=HasSubscriptionExpired($subscriptionid);
+  $cell->{'itemid'}       = "NNEW";
+  $cell->{'serialid'}     = "NEW";
+  $cell->{'issuesatonce'}   = 1;
+  push @newserialloop,$cell;
+  push @subscriptionloop, {'subscriptionid'=>$subscriptionid};
+}
+$template->param(newserialloop=>\@newserialloop);
+$template->param(subscriptions=>\@subscriptionloop);
+
+if ($op eq 'serialchangestatus') {
+#     my $sth = $dbh->prepare("select status from serial where serialid=?");
+    my $newserial;
+    for (my $i=0;$i<=$#serialids;$i++) {
+#         $sth->execute($serialids[$i]);
+#         my ($oldstatus) = $sth->fetchrow;
+        if ($serialids[$i] && $serialids[$i] eq "NEW") {
+          if ($serialseqs[$i]){
+            #IF newserial was provided a name Then we have to create a newSerial
+            ### FIXME if NewIssue is modified to use subscription biblionumber, then biblionumber would not be useful.
+            $newserial = NewIssue( $serialseqs[$i],$subscriptionids[$i],$serialdatalist[0]->{'biblionumber'},
+                      $status[$i],
+                      format_date_in_iso($planneddates[$i]),
+                      format_date_in_iso($publisheddates[$i]),
+                      $notes[$i]);
+          }
+        }elsif ($serialids[$i]){
+            ModSerialStatus($serialids[$i],
+                            $serialseqs[$i],
+                            format_date_in_iso($planneddates[$i]),
+                            format_date_in_iso($publisheddates[$i]),
+                            $status[$i],
+                            $notes[$i]);
+        }
+    }
+    if (C4::Context->preference("serialsadditems")){
+      my @moditems = $query->param('moditem');
+      my @tags = $query->param('tag');
+      my @subfields = $query->param('subfield');
+      my @field_values = $query->param('field_value');
+      my @serials = $query->param('serial');
+      my @bibnums = $query->param('bibnum');
+      my @itemid = $query->param('itemid');
+      my @ind_tag = $query->param('ind_tag');
+      my @indicator = $query->param('indicator');
+      #Rebuilding ALL the data for items into a hash
+      # parting them on $itemid.
+      my %itemhash;
+      my $countdistinct;
+      my $range=scalar(@itemid);
+      for (my $i=0; $i<$range; $i++){
+        unless ($itemhash{$itemid[$i]}){
+          if ($serials[$countdistinct] && $serials[$countdistinct] ne "NEW"){
+            $itemhash{$itemid[$i]}->{'serial'}=$serials[$countdistinct];
+          } else {
+            $itemhash{$itemid[$i]}->{'serial'}=$newserial;
+          }
+          $itemhash{$itemid[$i]}->{'bibnum'}=$bibnums[$countdistinct];
+          $countdistinct++;
+        }
+        push @{$itemhash{$itemid[$i]}->{'tags'}},$tags[$i];
+        push @{$itemhash{$itemid[$i]}->{'subfields'}},$subfields[$i];
+        push @{$itemhash{$itemid[$i]}->{'field_values'}},$field_values[$i];
+        push @{$itemhash{$itemid[$i]}->{'ind_tag'}},$ind_tag[$i];
+        push @{$itemhash{$itemid[$i]}->{'indicator'}},$indicator[$i];
+      }
+      foreach my $item (keys %itemhash){
+        # Verify Itemization is "Valid", i.e. serial status is Arrived or Missing
+        my $index;
+        for (my $i=0; $i<scalar(@serialids);$i++){
+          $index = $i if ($itemhash{$item}->{'serial'} eq $serialids[$i]);
+        }
+        if ($status[$index]==2){
+          my $xml = MARChtml2xml( $itemhash{$item}->{'tags'},
+                                  $itemhash{$item}->{'subfields'},
+                                  $itemhash{$item}->{'field_values'},
+                                  $itemhash{$item}->{'ind_tag'},
+                                  $itemhash{$item}->{'indicator'});
+#           warn $xml;
+          my $record=MARC::Record::new_from_xml($xml, 'UTF-8');
+          if ($item=~/^N/){
+            #New Item
+            # if autoBarcode is ON, calculate barcode...
+            my ($tagfield,$tagsubfield) = &MARCfind_marc_from_kohafield($dbh,"items.barcode");
+            if (C4::Context->preference('autoBarcode')) {
+              unless ($record->field($tagfield)->subfield($tagsubfield)) {
+                my $sth_barcode = $dbh->prepare("select max(abs(barcode)) from items");
+                $sth_barcode->execute;
+                my ($newbarcode) = $sth_barcode->fetchrow;
+                $newbarcode++;
+                # OK, we have the new barcode, now create the entry in MARC record
+                my $fieldItem = $record->field($tagfield);
+                $record->delete_field($fieldItem);
+                $fieldItem->add_subfields($tagsubfield => $newbarcode);
+                $record->insert_fields_ordered($fieldItem);
+              }
+            }
+            # check for item barcode # being unique
+            my $exists = GetItemFromBarcode($record->subfield($tagfield,$tagsubfield)) if ($record->subfield($tagfield,$tagsubfield));
+  #           push @errors,"barcode_not_unique" if($exists);
+            $template->param("barcode_not_unique" => 1,'errserialseq'=>$serialseqs[$index]);
+            # if barcode exists, don't create, but report The problem.
+            unless ($exists){
+              my ($biblionumber,$bibitemnum,$itemnumber) = AddItem($record,$itemhash{$item}->{'bibnum'});
+              AddItem2Serial($itemhash{$item}->{'serial'},$itemnumber);
+            }
+          } else {
+            #modify item
+            my ($oldbiblionumber,$oldbibnum,$itemnumber) = ModItem($record,$itemhash{$item}->{'bibnum'},$item,0);
+          }
+        }
+      }
+    }
+    print $query->redirect("serials-collection.pl?biblionumber=".$serialdatalist[0]->{biblionumber});
+}
+
+$template->param(serialsadditems =>C4::Context->preference("serialsadditems"));
+
+
+
+$template->param(
+            biblionumber =>$serialdatalist[0]->{'biblionumber'},
+            serialslist => \@serialdatalist,
+            intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
+            intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+            IntranetNav => C4::Context->preference("IntranetNav"),
+        );
+output_html_with_http_headers $query, $cookie, $template->output;

Index: serials/serials-recieve.pl
===================================================================
RCS file: serials/serials-recieve.pl
diff -N serials/serials-recieve.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ serials/serials-recieve.pl	9 Mar 2007 15:47:41 -0000	1.6
@@ -0,0 +1,288 @@
+#!/usr/bin/perl
+
+# 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
+
+# $Id: serials-recieve.pl,v 1.6 2007/03/09 15:47:41 tipaul Exp $
+
+=head1 NAME
+
+serials-recieve.pl
+
+=head1 Parameters
+
+=over 4
+
+=item op
+op can be :
+    * modsubscriptionhistory :to modify the subscription history 
+    * serialchangestatus     :to modify the status of this subscription
+
+=item subscriptionid
+
+=item user
+
+=item histstartdate
+
+=item enddate
+
+=item recievedlist
+
+=item missinglist
+
+=item opacnote
+
+=item librariannote
+
+=item serialid
+
+=item serialseq
+
+=item planneddate
+
+=item notes
+
+=item status
+
+=back
+
+=cut
+
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Date;
+use C4::Biblio;
+use C4::Koha;
+use C4::Output;
+use C4::Interface::CGI::Output;
+use C4::Context;
+use C4::Serials;
+use C4::Branch; # GetBranches
+
+my $query = new CGI;
+my $op = $query->param('op');
+my $dbh = C4::Context->dbh;
+my $subscriptionid = $query->param('subscriptionid');
+# my $auser = $query->param('user');
+my $histstartdate = format_date_in_iso($query->param('histstartdate'));
+my $enddate = format_date_in_iso($query->param('enddate'));
+my $recievedlist = $query->param('recievedlist');
+my $missinglist = $query->param('missinglist');
+my $opacnote = $query->param('opacnote');
+my $librariannote = $query->param('librariannote');
+my @serialids = $query->param('serialid');
+my @serialseqs = $query->param('serialseq');
+my @planneddates = $query->param('planneddate');
+my @publisheddates = $query->param('publisheddate');
+my @status = $query->param('status');
+my @notes = $query->param('notes');
+my @barcodes = $query->param('barcode');
+my @itemcallnumbers = $query->param('itemcallnumber');
+my @locations = $query->param('location');
+my @itemstatus = $query->param('itemstatus');
+my @homebranches = $query->param('branch');
+my $hassubscriptionexpired = HasSubscriptionExpired($subscriptionid);
+my $abouttoexpire = abouttoexpire($subscriptionid);
+
+my $subscription=GetSubscription($subscriptionid);
+
+
+my $auser = $subscription->{'librarian'}; # bob
+my $routing = check_routing($subscriptionid); # to see if routing list exists
+my $manualdate ='';
+my $manualissue ='';
+my $manualstatus =0;
+my $manualid ='';
+if ($op eq 'found'){
+    $manualdate = $query->param('planneddate');
+    $manualissue = $query->param('missingissue');
+    $manualstatus = 1;
+    my $sth = $dbh->prepare("select serialid from serial where subscriptionid = ? AND serialseq = ? AND planneddate = ?");
+    $sth->execute($subscriptionid,$manualissue,format_date_in_iso($manualdate));
+    $manualid = $sth->fetchrow;
+}
+if ($op eq 'modsubscriptionhistory') {
+    ModSubscriptionHistory($subscriptionid,$histstartdate,$enddate,$recievedlist,$missinglist,$opacnote,$librariannote);
+}
+
+# change status except, if subscription has expired, for the "waited" issue.
+if ($op eq 'serialchangestatus') {
+    my $sth = $dbh->prepare("select status from serial where serialid=?");
+    for (my $i=0;$i<=$#serialids;$i++) {
+        $sth->execute($serialids[$i]);
+        
+        my ($oldstatus) = $sth->fetchrow;
+        if ($serialids[$i]) {
+            ModSerialStatus($serialids[$i],$serialseqs[$i],format_date_in_iso($planneddates[$i]),format_date_in_iso($publisheddates[$i]),$status[$i],$notes[$i]) unless ($hassubscriptionexpired && $oldstatus == 1);
+            if (($status[$i]==2) && C4::Context->preference("serialsadditems")){
+                my %info;
+                $info{branch}=$homebranches[$i];
+                $info{barcode}=$barcodes[$i];
+                $info{itemcallnumber}=$itemcallnumbers[$i];
+                $info{location}=$locations[$i];
+                $info{status}=$itemstatus[$i];
+                $info{notes}=$serialseqs[$i]." (".$planneddates[$i].")";
+                my ($status2, @errors)= ItemizeSerials($serialids[$i],\%info);
+                my $sth2 = $dbh->prepare("UPDATE subscriptionhistory SET lastbranch = ? WHERE subscriptionid = ?");
+                $sth2->execute($homebranches[$i],$subscriptionid);
+                $sth2->finish;			    
+                # remove from missing list if item being checked in is on it
+                if ($status2 ==1){
+                removeMissingIssue($serialseqs[$i],$subscriptionid);
+                }			    
+            }
+        } else {
+            # add a special issue
+            if ($serialseqs[$i]) {
+                NewIssue($serialseqs[$i],$subscriptionid,$subscription->{biblionumber},$status[$i] ,format_date_in_iso($publisheddates[$i]),format_date_in_iso($planneddates[$i]));
+            }
+            if (($status[$i]==2) && C4::Context->preference("serialsadditems") && !hassubscriptionexpired($subscriptionid)){
+                my %info;
+                $info{branch}=$homebranches[$i];
+                $info{barcode}=$barcodes[$i];
+                $info{itemcallnumber}=$itemcallnumbers[$i];
+                $info{location}=$locations[$i];
+                $info{status}=$itemstatus[$i];
+                $info{notes}=$serialseqs[$i]." (".$planneddates[$i].")";
+                my ($status2, @errors)= ItemizeSerials($serialids[$i],\%info);
+                my $sth2 = $dbh->prepare("UPDATE subscriptionhistory SET lastbranch = ? WHERE subscriptionid = ?");
+                $sth2->execute($homebranches[$i],$subscriptionid);
+                $sth2->finish;
+                # remove from missing list if item being checked in is on it
+                if ($status2 ==1){
+                 removeMissingIssue($serialseqs[$i],$subscriptionid);
+                }
+            }
+
+        }
+    }
+}
+my ($template, $loggedinuser, $cookie)
+= get_template_and_user({template_name => "serials/serials-recieve.tmpl",
+                query => $query,
+                type => "intranet",
+                authnotrequired => 0,
+                flagsrequired => {serials => 1},
+                debug => 1,
+                });
+
+my $subs = &GetSubscription($subscriptionid);
+my ($totalissues, at serialslist) = GetSerials($subscriptionid);
+my $count = @serialslist;
+for(my $i=0;$i<$count;$i++){
+    warn "la : $i";
+    $serialslist[$i]->{'callnumber'} = $subscription->{'callnumber'};
+    my $temp = rand(10000000);
+    $serialslist[$i]->{'barcode'} = "TEMP" . sprintf("%.0f",$temp);
+}
+
+my $sth= C4::Serials::GetSubscriptionHistoryFromSubscriptionId();
+
+$sth->execute($subscriptionid);
+my $solhistory = $sth->fetchrow_hashref;
+
+my $subs = &GetSubscription($subscriptionid);
+my ($totalissues, at serialslist) = GetSerials($subscriptionid);
+
+if (C4::Context->preference("serialsadditems")){
+    my $fwk=MARCfind_frameworkcode($subscription->{biblionumber});
+
+    my $branches = GetBranches;
+    my @branchloop;
+    foreach my $thisbranch (keys %$branches) {
+        my $selected = 0;
+        if($thisbranch eq $solhistory->{'lastbranch'}){
+        $selected = 1;
+        }
+        my %row =(value => $thisbranch,
+            branchname => $branches->{$thisbranch}->{'branchname'},
+                selected => $selected,
+                );
+        push @branchloop, \%row;
+    }
+    my $itemstatushash = GetItemStatus($fwk);
+    my @itemstatusloop;
+        my $itemstatusloopcount=0;    
+    foreach my $thisitemstatus (keys %$itemstatushash) {
+        my %row =(itemval => $thisitemstatus,
+                    itemlib => $itemstatushash->{$thisitemstatus},
+                );
+#		warn "".$row{'itemval'}.", ". $row{"itemlib"};
+                $itemstatusloopcount++;
+        push @itemstatusloop, \%row;
+    }
+    my $itemlocationhash = GetItemLocation($fwk);
+    my @itemlocationloop;
+    foreach my $thisitemlocation (keys %$itemlocationhash) {
+        my %row =(value => $thisitemlocation,
+                    itemlocationname => $itemlocationhash->{$thisitemlocation},
+                );
+        push @itemlocationloop, \%row;
+    }
+
+        my $choice = 0;
+        if($itemstatusloopcount == 1){ $choice = 1;}   
+        foreach my $data (@serialslist){
+            if (scalar(@itemstatusloop)){$data->{"itemstatusloop"}=\@itemstatusloop;}
+            else { $data->{"itemstatusloop"}=[];}
+            if (scalar(@itemlocationloop)){$data->{"itemlocationloop"}=\@itemlocationloop;}
+            else {$data->{"itemlocationloop"}=[];}
+            $data->{"branchloop"}=\@branchloop ;
+    }
+# warn "Choice: $choice";
+    $template->param(choice => $choice);    
+    $template->param(serialadditems =>C4::Context->preference("serialsadditems"),
+                    branchloop => \@branchloop,
+                    ) ;
+    $template->param(itemstatus=>1,itemstatusloop=>\@itemstatusloop) if (scalar(@itemstatusloop));
+    $template->param(itemlocation=>1,itemlocationloop=>\@itemlocationloop) if (scalar(@itemlocationloop));
+}else{
+    $template->param(branchloop=>[],itemstatusloop=>[],itemlocationloop=>[]) ;
+}
+
+my $sth= C4::Serials::GetSubscriptionHistoryFromSubscriptionId();
+$sth->execute($subscriptionid);
+my $solhistory = $sth->fetchrow_hashref;
+
+$template->param(
+            user => $auser,
+            serialslist => \@serialslist,
+            count => $count,
+            biblionumber => $subscription->{biblionumber},
+            histstartdate => format_date($solhistory->{'histstartdate'}),
+            enddate => format_date($solhistory->{'enddate'}),
+            recievedlist => $solhistory->{'recievedlist'},
+            missinglist => $solhistory->{'missinglist'},
+            opacnote => $solhistory->{'opacnote'},
+            librariannote => $solhistory->{'librariannote'},
+            subscriptionid => $subscriptionid,
+            bibliotitle => $subs->{bibliotitle},
+            biblionumber => $subs->{biblionumber},
+            hassubscriptionexpired =>$hassubscriptionexpired,
+            abouttoexpire =>$abouttoexpire,    
+            intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
+            intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+            IntranetNav => C4::Context->preference("IntranetNav"),
+            routing => $routing,
+            missingseq => $manualissue,
+            frommissing => $manualstatus,
+            missingdate => $manualdate,
+            missingid => $manualid,
+        );
+output_html_with_http_headers $query, $cookie, $template->output;

Index: serials/statecollection.pl
===================================================================
RCS file: serials/statecollection.pl
diff -N serials/statecollection.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ serials/statecollection.pl	9 Mar 2007 15:47:41 -0000	1.3
@@ -0,0 +1,98 @@
+#!/usr/bin/perl
+
+# 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: statecollection.pl,v 1.3 2007/03/09 15:47:41 tipaul Exp $
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Date;
+use C4::Output;
+use C4::Interface::CGI::Output;
+use C4::Context;
+use C4::Serials;
+
+my $query = new CGI;
+my $op = $query->param('op');
+my $dbh = C4::Context->dbh;
+my $subscriptionid = $query->param('subscriptionid');
+my $auser = $query->param('user');
+my $histstartdate = format_date_in_iso($query->param('histstartdate'));
+my $enddate = format_date_in_iso($query->param('enddate'));
+my $recievedlist = $query->param('recievedlist');
+my $missinglist = $query->param('missinglist');
+my $opacnote = $query->param('opacnote');
+my $librariannote = $query->param('librariannote');
+my @serialids = $query->param('serialid');
+my @serialseqs = $query->param('serialseq');
+my @planneddates = $query->param('planneddate');
+my @notes = $query->param('notes');
+my @status = $query->param('status');
+
+my ($template, $loggedinuser, $cookie)
+= get_template_and_user({template_name => "serials/statecollection.tmpl",
+				query => $query,
+				type => "intranet",
+				authnotrequired => 0,
+				flagsrequired => {serials => 1},
+				debug => 1,
+				});
+
+my $HasSubscriptionExpired = HasSubscriptionExpired($subscriptionid);
+my $subscription=GetSubscription($subscriptionid);
+if ($op eq 'modsubscriptionhistory') {
+	modsubscriptionhistory($subscriptionid,$histstartdate,$enddate,$recievedlist,$missinglist,$opacnote,$librariannote);
+}
+# change status except, if subscription has expired, for the "waited" issue.
+if ($op eq 'serialchangestatus') {
+	my $sth = $dbh->prepare("select status from serial where serialid=?");
+	for (my $i=0;$i<=$#serialids;$i++) {
+		$sth->execute($serialids[$i]);
+		my ($oldstatus) = $sth->fetchrow;
+		if ($serialids[$i]) {
+			serialchangestatus($serialids[$i],$serialseqs[$i],format_date_in_iso($planneddates[$i]),$status[$i],$notes[$i]) unless ($HasSubscriptionExpired && $oldstatus == 1);
+		} else {
+			# add a special issue
+			if ($serialseqs[$i]) {
+				my $subscription=getsubscription($subscriptionid);
+				newissue($serialseqs[$i],$subscriptionid,$subscription->{biblionumber},$status[$i], format_date_in_iso($planneddates[$i]));
+			}
+		}
+	}
+}
+my $subs = &GetSubscription($subscriptionid);
+my ($totalissues, at serialslist) = GetSerials($subscriptionid,10);
+
+my $sth=$dbh->prepare("select * from subscriptionhistory where subscriptionid = ?");
+$sth->execute($subscriptionid);
+my $solhistory = $sth->fetchrow_hashref;
+
+	$template->param(
+			serialslist => \@serialslist,
+			biblionumber => $subscription->{biblionumber},
+			histstartdate => format_date($solhistory->{'histstartdate'}),
+			enddate => format_date($solhistory->{'enddate'}),
+			recievedlist => $solhistory->{'recievedlist'},
+			missinglist => $solhistory->{'missinglist'},
+			opacnote => $solhistory->{'opacnote'},
+			librariannote => $solhistory->{'librariannote'},
+			subscriptionid => $subscriptionid,
+			bibliotitle => $subs->{bibliotitle},
+			biblionumber => $subs->{biblionumber},
+			hassubscriptionexpired =>$HasSubscriptionExpired,
+		);
+output_html_with_http_headers $query, $cookie, $template->output;





More information about the Koha-cvs mailing list