[Koha-cvs] koha C4/Koha.pm C4/Serials.pm koha-tmpl/intrane... [rel_3_0]

Henri-Damien LAURENT laurenthdl at alinto.com
Mon Nov 13 10:33:20 CET 2006


CVSROOT:	/cvsroot/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	Henri-Damien LAURENT <hdl>	06/11/13 09:33:20

Modified files:
	C4             : Koha.pm Serials.pm 
Added files:
	koha-tmpl/intranet-tmpl/prog/en/serials: serials-collection.tmpl 
	                                         serials-edit.tmpl 
	serials        : serials-collection.pl serials-edit.pl 

Log message:
	proposing a new facility to edit state collection for a serial.
	Be warned it is still under developement.
	
	I need to discuss which direction to go to in order to make the best choice.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Koha.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.40.2.19&r2=1.40.2.20
http://cvs.savannah.gnu.org/viewcvs/koha/C4/Serials.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.5.2.4&r2=1.5.2.5
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/serials/serials-collection.tmpl?cvsroot=koha&only_with_tag=rel_3_0&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/serials/serials-edit.tmpl?cvsroot=koha&only_with_tag=rel_3_0&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/serials/serials-collection.pl?cvsroot=koha&only_with_tag=rel_3_0&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/serials/serials-edit.pl?cvsroot=koha&only_with_tag=rel_3_0&rev=1.1.2.1

Patches:
Index: C4/Koha.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Koha.pm,v
retrieving revision 1.40.2.19
retrieving revision 1.40.2.20
diff -u -b -r1.40.2.19 -r1.40.2.20
--- C4/Koha.pm	2 Nov 2006 10:12:09 -0000	1.40.2.19
+++ C4/Koha.pm	13 Nov 2006 09:33:20 -0000	1.40.2.20
@@ -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: Koha.pm,v 1.40.2.19 2006/11/02 10:12:09 toins Exp $
+# $Id: Koha.pm,v 1.40.2.20 2006/11/13 09:33:20 hdl Exp $
 
 use strict;
 require Exporter;
@@ -25,7 +25,7 @@
 use C4::Output;
 use vars qw($VERSION @ISA @EXPORT);
 
-$VERSION = do { my @v = '$Revision: 1.40.2.19 $' =~ /\d+/g; shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
+$VERSION = do { my @v = '$Revision: 1.40.2.20 $' =~ /\d+/g; shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
 
 =head1 NAME
 
@@ -68,8 +68,7 @@
 			&displayLanguagesLimit
 			&displaySubtypesLimit
 			&displayLimitTypes
-			&displayPrimaryServers
-			&displaySecondaryServers
+			&displayServers
 			&displayLanguages
             &getnbpages
             &getitemtypeimagesrcfromurl
@@ -986,13 +985,13 @@
     { value => '', label => 'Keyword' },
     { value => 'au', label => 'Author' },
     { value => 'au,phr', label => '&nbsp;&nbsp;&nbsp;&nbsp; Author Phrase' },
-#    { value => 'cpn', label => '&nbsp;&nbsp;&nbsp;&nbsp; Corporate Name' },
-#   { value => 'cfn', label => '&nbsp;&nbsp;&nbsp;&nbsp; Conference Name' },
-#   { value => 'cpn,phr', label => '&nbsp;&nbsp;&nbsp;&nbsp; Corporate Name Phrase' },
-#   { value => 'cfn,phr', label => '&nbsp;&nbsp;&nbsp;&nbsp; Conference Name Phrase' },
-#    { value => 'pn', label => '&nbsp;&nbsp;&nbsp;&nbsp; Personal Name' },
-#    { value => 'pn,phr', label => '&nbsp;&nbsp;&nbsp;&nbsp; Personal Name Phrase' },
-#    { value => 'ln', label => 'Language' },
+    { value => 'cpn', label => '&nbsp;&nbsp;&nbsp;&nbsp; Corporate Name' },
+    { value => 'cfn', label => '&nbsp;&nbsp;&nbsp;&nbsp; Conference Name' },
+    { value => 'cpn,phr', label => '&nbsp;&nbsp;&nbsp;&nbsp; Corporate Name Phrase' },
+    { value => 'cfn,phr', label => '&nbsp;&nbsp;&nbsp;&nbsp; Conference Name Phrase' },
+    { value => 'pn', label => '&nbsp;&nbsp;&nbsp;&nbsp; Personal Name' },
+    { value => 'pn,phr', label => '&nbsp;&nbsp;&nbsp;&nbsp; Personal Name Phrase' },
+    { value => 'ln', label => 'Language' },
 #    { value => 'mt', label => 'Material Type' },
 #    { value => 'mt,phr', label => 'Material Type Phrase' },
 #    { value => 'mc', label => 'Musical Composition' },
@@ -1211,28 +1210,37 @@
 ];
 return $outer_limit_types_loop;
 }
-sub displayPrimaryServers {
-	my $primary_servers_loop = [
-    	{ inner_servers_loop => [
-        	{label => C4::Context->preference('LibraryName')." Catalog", id=>"NPL", name=>"server", value=>"localhost:9900/biblios",checked=>"checked",icon => "npl.png",zed => "1"},
-        	{label => "OPLIN Databases", id=>"OPLIN", name=>"server", value=>"",checked=>"",icon => "oplin.ico",zed => "1"},
-    	],
-    	},
-	];
-	return $primary_servers_loop;
+sub displayServers {
+    my ($position,$type)=@_;
+    my $dbh=C4::Context->dbh;
+    my $strsth="SELECT * FROM z3950servers where 1";
+    $strsth.= " AND position=\"$position\"" if ($position);
+    $strsth.= " AND type=\"$type\"" if ($type);
+    my $rq=$dbh->prepare($strsth);
+    $rq->execute;
+    my @primaryserverloop;
+    while (my $data=$rq->fetchrow_hashref){
+      my %cell;
+      $cell{label}=$data->{'description'};
+      $cell{id}=$data->{'name'};
+      $cell{value}=$data->{host}.($data->{port}?":".$data->{port}:"")."/".$data->{database} if ($data->{host});
+      $cell{checked}=$data->{checked};
+	 push @primaryserverloop,{label => $data->{description}, id=>$data->{name}, name=>"server", value=>$data->{host}.":".$data->{port}."/".$data->{database},checked=>"checked",icon => $data->{icon},zed => $data->{type} eq 'zed',opensearch=>$data->{type} eq 'opensearch'};
+    }
+	return \@primaryserverloop;
 }
 
 sub displaySecondaryServers {
-	my $secondary_servers_loop = [ 
-		{ inner_sup_servers_loop => [
-        	{label => "Google", id=>"GOOG", value=>"google",icon => "google.ico",opensearch => "1"},
-        	{label => "Yahoo", id=>"YAH", value=>"yahoo", icon =>"yahoo.ico", zed => "1"},
-        	{label => "Worldcat", id=>"WCT", value=>"worldcat", icon => "worldcat.gif", zed => "1"},
-        	{label => "Library of Congress", id=>"LOC", name=> "server", value=>"z3950.loc.gov:7090/Voyager", icon =>"loc.ico", zed => "1"},
-    	],
-    	},
-	];
-	return $secondary_servers_loop;
+# 	my $secondary_servers_loop = [ 
+# 		{ inner_sup_servers_loop => [
+#         	{label => "Google", id=>"GOOG", value=>"google",icon => "google.ico",opensearch => "1"},
+#         	{label => "Yahoo", id=>"YAH", value=>"yahoo", icon =>"yahoo.ico", zed => "1"},
+#         	{label => "Worldcat", id=>"WCT", value=>"worldcat", icon => "worldcat.gif", zed => "1"},
+#         	{label => "Library of Congress", id=>"LOC", name=> "server", value=>"z3950.loc.gov:7090/Voyager", icon =>"loc.ico", zed => "1"},
+#     	],
+#     	},
+# 	];
+ 	return ;#$secondary_servers_loop;
 }
 
 sub displayLanguages {

Index: C4/Serials.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Serials.pm,v
retrieving revision 1.5.2.4
retrieving revision 1.5.2.5
diff -u -b -r1.5.2.4 -r1.5.2.5
--- C4/Serials.pm	30 Oct 2006 09:53:14 -0000	1.5.2.4
+++ C4/Serials.pm	13 Nov 2006 09:33:20 -0000	1.5.2.5
@@ -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: Serials.pm,v 1.5.2.4 2006/10/30 09:53:14 tipaul Exp $
+# $Id: Serials.pm,v 1.5.2.5 2006/11/13 09:33:20 hdl Exp $
 
 use strict;
 use C4::Date;
@@ -31,7 +31,7 @@
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.5.2.4 $' =~ /\d+/g;
+$VERSION = do { my @v = '$Revision: 1.5.2.5 $' =~ /\d+/g;
         shift(@v) . "." . join("_", map {sprintf "%03d", $_ } @v); };
 
 
@@ -61,6 +61,7 @@
     &GetNextSeq         &NewIssue           &ItemizeSerials    &GetSerials
     &GetLatestSerials   &ModSerialStatus    &GetNextDate
     &ReNewSubscription  &GetLateIssues      &GetMissingIssues
+    &GetSerialInformation
     
     &GetSuppliersWithLateIssues             &getsupplierbyserialid
     &GetDistributedTo   &SetDistributedTo
@@ -212,6 +213,44 @@
     return $dbh->prepare($query);
 }
 
+=head2 GetSerialInformation
+
+=over 4
+
+$data = GetSerialInformation($serialid);
+returns a hash containing :
+  items : items marcrecord (can be an array)
+  serial table field
+  subscription table field
+  + information about subscription expiration
+=back
+
+=cut
+sub GetSerialInformation{
+    my ($serialid)=@_;
+    my $dbh = C4::Context->dbh;
+    my $query = qq|
+        SELECT serial.*,subscription.*
+        FROM   serial LEFT JOIN subscription ON subscription.subscriptionid=serial.subscriptionid
+        WHERE  serialid = ?
+    |;
+    my $rq=$dbh->prepare($query);
+    $rq->execute($serialid);
+    my $data=$rq->fetchrow_hashref;
+    if (C4::Context->preference("serialsadditems")){
+      my @itemnumbers= split /,/,$data->{'itemnumber'};
+      foreach my $itemnum (@itemnumbers){
+      #It is ASSUMED that MARCgetitem ALWAYS WORK... 
+      #Maybe MARCgetitem should return values on failure
+        my $itemrecord=MARCgetitem($dbh,$data->{'subscription.biblionumber'},$itemnum);
+        push @{$data->{'items'}},{'record'=>MARCgetitem($dbh,$data->{'subscription.biblionumber'},$itemnum)};
+      }
+   }
+   $data->{"status".$data->{status}}=1;
+   $data->{'subscriptionexpired'} = HasSubscriptionExpired($data->{'subscriptionid'});
+   $data->{'subscriptionaboutexpire'} = abouttoexpire($data->{'subscriptionid'});
+   return $data;
+}
 
 =head2 GetSubscription
 
@@ -267,6 +306,7 @@
     my $dbh = C4::Context->dbh;
     my $query = qq(
         SELECT subscription.*,
+               branches.branchname,
                subscriptionhistory.*,
                aqbudget.bookfundid,
                aqbooksellers.name AS aqbooksellername,
@@ -276,6 +316,7 @@
        LEFT JOIN aqbudget ON subscription.aqbudgetid=aqbudget.aqbudgetid
        LEFT JOIN aqbooksellers ON subscription.aqbooksellerid=aqbooksellers.id
        LEFT JOIN biblio ON biblio.biblionumber=subscription.biblionumber
+       LEFT JOIN branches ON branches.branchcode=subscription.branchcode
        WHERE subscription.biblionumber = ?
     );
     my $sth = $dbh->prepare($query);
@@ -312,14 +353,17 @@
     my ($biblionumber) = @_;
     my $dbh = C4::Context->dbh;
     my $query=qq|
-                SELECT  serial.serialseq,
+  SELECT serial.serialid,
+    serial.serialseq,
                         serial.planneddate,
                         serial.publisheddate,
                         serial.status,
-                        serial.notes,
-                        year(serial.publisheddate) AS year,
-                        aqbudget.bookfundid,aqbooksellers.name AS aqbooksellername,
-                        biblio.title AS bibliotitle
+    serial.notes as notes,
+    year(IF(serial.publisheddate="00-00-0000",serial.planneddate,serial.publisheddate)) as year,
+    aqbudget.bookfundid,aqbooksellers.name as aqbooksellername,
+    biblio.title as bibliotitle,
+    subscription.branchcode AS branchcode,
+    subscription.subscriptionid AS subscriptionid
                 FROM serial
                 LEFT JOIN subscription ON
                     (serial.subscriptionid=subscription.subscriptionid AND subscription.biblionumber=serial.biblionumber)
@@ -327,12 +371,14 @@
                 LEFT JOIN aqbooksellers on subscription.aqbooksellerid=aqbooksellers.id
                 LEFT JOIN biblio on biblio.biblionumber=subscription.biblionumber
                 WHERE subscription.biblionumber = ?
-                ORDER BY year,serial.publisheddate,serial.subscriptionid,serial.planneddate
+  ORDER BY year DESC,
+          IF(serial.publisheddate="00-00-0000",serial.planneddate,serial.publisheddate) DESC,
+          serial.subscriptionid
     |;
-
     my $sth = $dbh->prepare($query);
     $sth->execute($biblionumber);
     my @res;
+    my %tmpresults;
     my $year;
     my $startdate;
     my $aqbooksellername;
@@ -341,43 +387,33 @@
     my $first;
     my $previousnote="";
     while (my $subs = $sth->fetchrow_hashref) {
-        ### BUG To FIX: When there is no published date, will create many null ids!!!
-
-        if ($year and ($year==$subs->{year})){
-            if ($first eq 1){$first=0;}
-            my $temp=$res[scalar(@res)-1]->{'serials'};
-            push @$temp,
-                {'publisheddate' =>format_date($subs->{'publisheddate'}),
-                'planneddate' => format_date($subs->{'planneddate'}), 
-                'serialseq' => $subs->{'serialseq'},
-                "status".$subs->{'status'} => 1,
-                'notes' => $subs->{'notes'} eq $previousnote?"":$subs->{notes},
-                };
-        } else {
-            $first=1 if (not $year);
-            $year= $subs->{'year'};
-            $startdate= format_date($subs->{'startdate'});
-            $aqbooksellername= $subs->{'aqbooksellername'};
-            $bibliotitle= $subs->{'bibliotitle'};
-            my @temp;
-            push @temp,
-                {'publisheddate' =>format_date($subs->{'publisheddate'}),
-                            'planneddate' => format_date($subs->{'planneddate'}), 
-                'serialseq' => $subs->{'serialseq'},
-                "status".$subs->{'status'} => 1,
-                'notes' => $subs->{'notes'} eq $previousnote?"":$subs->{notes},
-                };
-
-            push @res,{
+        $subs->{'publisheddate'}=($subs->{'publisheddate'}?format_date($subs->{'publisheddate'}):"XXX");
+        $subs->{'planneddate'} = format_date($subs->{'planneddate'}), 
+        $subs->{"status".$subs->{'status'}} = 1;
+#         $subs->{'notes'} = $subs->{'notes'} eq $previousnote?"":$subs->{notes};
+        if ($subs->{'year'} && $subs->{'year'} ne ""){
+          $year=$subs->{'year'};
+        } else {
+          $year="manage"
+        }
+		if ($tmpresults{$year}){
+          push @{$tmpresults{$year}->{'serials'}},$subs;
+		}else {
+          $tmpresults{$year}={
                 'year'=>$year,
-                'startdate'=>$startdate,
-                'aqbooksellername'=>$aqbooksellername,
-                'bibliotitle'=>$bibliotitle,
-                'serials'=>\@temp,
-                'first'=>$first 
+#               'startdate'=>format_date($subs->{'startdate'}),
+              'aqbooksellername'=>$subs->{'aqbooksellername'},
+              'bibliotitle'=>$subs->{'bibliotitle'},
+              'serials'=>[$subs],
+              'first'=>$first,
+              'branchcode' => $subs->{'branchcode'} ,
+              'subscriptionid' => $subs->{'subscriptionid'} ,
             };
         }
-        $previousnote=$subs->{notes};
+# 		$previousnote=$subs->{notes};
+	}
+    foreach my $key (sort {$b cmp $a} keys %tmpresults){
+       push @res,$tmpresults{$key};
     }
     return \@res;
 }
@@ -872,7 +908,7 @@
 
 =cut
 sub ModSubscription {
-    my ($auser,$aqbooksellerid,$cost,$aqbudgetid,$startdate,
+    my ($auser,$branchcode,$aqbooksellerid,$cost,$aqbudgetid,$startdate,
                     $periodicity,$firstacquidate,$dow,$irregularity,$numberpattern,$numberlength,$weeklength,$monthlength,
                     $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1,
                     $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2,
@@ -880,7 +916,7 @@
                     $numberingmethod, $status, $biblionumber, $callnumber, $notes, $letter, $hemisphere, $subscriptionid) = @_;
     my $dbh = C4::Context->dbh;
     my $query = "UPDATE subscription
-                    SET librarian=?, aqbooksellerid=?,cost=?,aqbudgetid=?,startdate=?,
+                    SET librarian=?, branchcode=?,aqbooksellerid=?,cost=?,aqbudgetid=?,startdate=?,
                         periodicity=?,firstacquidate=?,dow=?,irregularity=?, numberpattern=?, numberlength=?,weeklength=?,monthlength=?,
                         add1=?,every1=?,whenmorethan1=?,setto1=?,lastvalue1=?,innerloop1=?,
                         add2=?,every2=?,whenmorethan2=?,setto2=?,lastvalue2=?,innerloop2=?,
@@ -888,7 +924,7 @@
                         numberingmethod=?, status=?, biblionumber=?, callnumber=?, notes=?, letter=?, hemisphere=?
                     WHERE subscriptionid = ?";
     my $sth=$dbh->prepare($query);
-    $sth->execute($auser,$aqbooksellerid,$cost,$aqbudgetid,$startdate,
+    $sth->execute($auser,$branchcode,$aqbooksellerid,$cost,$aqbudgetid,$startdate,
                     $periodicity,$firstacquidate,$dow,$irregularity,$numberpattern,$numberlength,$weeklength,$monthlength,
                     $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1,
                     $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2,
@@ -902,7 +938,7 @@
 
 =over 4
 
-$subscriptionid = &NewSubscription($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,
+$subscriptionid = &NewSubscription($auser,branchcode,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,
     $startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength,
     $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1,
     $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2,
@@ -918,7 +954,7 @@
 
 =cut
 sub NewSubscription {
-    my ($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,
+    my ($auser,$branchcode,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,
         $startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength,
         $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1,
         $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2,
@@ -930,18 +966,18 @@
 #save subscription (insert into database)
     my $query = qq|
         INSERT INTO subscription
-            (librarian,aqbooksellerid,cost,aqbudgetid,biblionumber,
+            (librarian,branchcode,aqbooksellerid,cost,aqbudgetid,biblionumber,
             startdate,periodicity,dow,numberlength,weeklength,monthlength,
             add1,every1,whenmorethan1,setto1,lastvalue1,innerloop1,
             add2,every2,whenmorethan2,setto2,lastvalue2,innerloop2,
             add3,every3,whenmorethan3,setto3,lastvalue3,innerloop3,
             numberingmethod, status, notes, letter,firstacquidate,irregularity,
             numberpattern, callnumber, hemisphere)
-        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
+        VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
         |;
     my $sth=$dbh->prepare($query);
     $sth->execute(
-        $auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,
+        $auser,$branchcode,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,
         format_date_in_iso($startdate),$periodicity,$dow,$numberlength,$weeklength,$monthlength,
         $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1,
         $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2,
@@ -1337,6 +1373,19 @@
     |;
     my $sth = $dbh->prepare($query);
     $sth->execute($serialseq,$subscriptionid);
+    #Delete element from subscription history
+    my $query = qq|
+        SELECT * FROM subscriptionhistory
+        WHERE       subscriptionid= ?
+    |;
+    my $sth = $dbh->prepare($query);
+    $sth->execute($subscriptionid);
+    my $data=$sth->fetchrow_hashref;
+    $data->{'missinglist'}=~s/$serialseq//;
+    $data->{'recievedlist'}=~s/$serialseq//;
+    my $strsth = "UPDATE subscriptionhistory SET ".join(",",map{join("=",$_,$dbh->quote($data->{$_}))} keys %$data)." WHERE subscriptionid=?";
+    $sth=$dbh->prepare($strsth);
+    $sth->execute($subscriptionid);
 }
 
 =head2 GetMissingIssues

Index: koha-tmpl/intranet-tmpl/prog/en/serials/serials-collection.tmpl
===================================================================
RCS file: koha-tmpl/intranet-tmpl/prog/en/serials/serials-collection.tmpl
diff -N koha-tmpl/intranet-tmpl/prog/en/serials/serials-collection.tmpl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ koha-tmpl/intranet-tmpl/prog/en/serials/serials-collection.tmpl	13 Nov 2006 09:33:20 -0000	1.1.2.1
@@ -0,0 +1,119 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" --><!-- TMPL_VAR NAME="LibraryName" --> Catalog -- Serials
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+<!--TMPL_INCLUDE NAME="menus.inc" -->
+<!--TMPL_INCLUDE NAME="menu-serials.inc" -->
+
+
+<script language="JavaScript" type="text/javascript">
+function showlayer(numlayer)
+{
+	var yeardata=document.getElementsByName("yeardata");
+    for (i=0; i<=yeardata.length; i++ ) {
+		ong=yeardata[i].getAttribute('id');
+        if (numlayer==ong) {
+			yeardata[i].style.visibility="visible";
+		} else {
+			yeardata[i].style.visibility="hidden";
+		}
+	}
+}
+showlayer(<!-- TMPL_VAR NAME="yearmax"-->);
+function show(branchcode)
+{
+  if (branchcode !=""){
+	for (var eltlist in document.getElementsbyName("branch")) {
+      eltslist.style.visibility="hidden" ;
+    }
+  } else {
+    branchcode="branch";
+  }
+  for (eltslist in document.getElementsbyName(branchcode)) {
+      eltslist.style.visibility="visible";
+  }
+}
+</script>
+
+<!-- TMPL_UNLESS name="popup" -->
+<div id="main">
+	<h2>Subscription information for <em><!-- TMPL_VAR name="bibliotitle" --></em></h2>
+<!-- /TMPL_UNLESS -->
+
+View Subscription information :
+<!--TMPL_LOOP Name="subscriptions"-->
+	<a href="subscription-detail.pl?subscriptionid=<!-- TMPL_VAR name="subscriptionid" -->">#<!-- TMPL_VAR name="subscriptionid" --></a> 
+<!--/TMPL_LOOP -->
+	
+Show branch :
+ <a href="#" onclick="show(''); return false;">ALL</a>
+<!--TMPL_LOOP Name="subscriptions"-->
+    <a href="#" onclick="show(<!--TMPL_VAR Name="branchcode"-->); return false;" id="<!--TMPL_VAR Name="branchcode"-->"><!--TMPL_VAR Name="branchname"--></a>
+<!--/TMPL_LOOP -->
+	
+    <div class="tabsubs">
+    <!-- TMPL_LOOP NAME="years" -->
+        <!-- TMPL_IF NAME="year" -->
+            <a  class="tabsubs" href="javascript:showlayer(<!-- TMPL_VAR NAME="year" -->)"><!-- TMPL_VAR NAME="year" --></a>
+        <!-- /TMPL_IF -->
+    <!-- /TMPL_LOOP -->
+    <a class="tabsubs" href="serial-issues.pl?biblionumber=<!-- TMPL_VAR name="biblionumber" -->&selectview=small">Compact view</a>
+    </div>
+
+<form name="edition" action="serials-edit.pl">
+    <!-- TMPL_LOOP NAME="years" -->
+    <div name="yeardata" id="<!-- TMPL_VAR NAME="year" -->" class="tabsub" 
+      <!--TMPL_IF Name="first" -->style="visibility:visible"
+      <!--/TMPL_IF -->>
+        <table width="400px">
+            <tr>
+                <th> Date
+                </th>
+                <th>Date received
+                </th>
+                <th> Number
+                </th>
+                <th> Status
+                </th>
+                <th> Notes
+                </th>
+                <th>branch
+                </th>
+                <th>Edit
+                </th>
+            </tr>
+      <!-- TMPL_LOOP Name="serials" -->
+            <tr name="branch <!--TMPL_VAR Name=branchcode"-->">
+                <td>
+                    <!-- TMPL_VAR Name="publisheddate" -->
+                </td>
+                <td>
+                    <!-- TMPL_VAR Name="planneddate" -->
+                </td>
+                <td>
+                    <!-- TMPL_VAR Name="serialseq" -->
+                </td>
+                <td>
+                    <!-- TMPL_IF Name="status1" -->Waited<!-- /TMPL_IF -->
+                    <!-- TMPL_IF Name="status2" -->Arrived<!-- /TMPL_IF -->
+                    <!-- TMPL_IF Name="status3" -->Late<!-- /TMPL_IF -->
+                    <!-- TMPL_IF Name="status4" -->Missing<!-- /TMPL_IF -->
+                </td>
+                <td>
+                    <!-- TMPL_VAR Name="Notes" -->
+                </td>
+                <td>
+                    <!-- TMPL_VAR Name="branchcode" -->
+                </td>
+                <td>
+                  <input type="checkbox" name="serialid" value=<!--TMPL_VAR Name="serialid"--> />
+                </td>
+            </tr>
+      <!-- /TMPL_LOOP -->
+        </table>
+    </div>
+    <!--/TMPL_LOOP -->
+  <input type="submit" value="Edit serials" class="button bull">
+  </form>
+  </div>
+
+</body>
+</html>

Index: koha-tmpl/intranet-tmpl/prog/en/serials/serials-edit.tmpl
===================================================================
RCS file: koha-tmpl/intranet-tmpl/prog/en/serials/serials-edit.tmpl
diff -N koha-tmpl/intranet-tmpl/prog/en/serials/serials-edit.tmpl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ koha-tmpl/intranet-tmpl/prog/en/serials/serials-edit.tmpl	13 Nov 2006 09:33:20 -0000	1.1.2.1
@@ -0,0 +1,294 @@
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->Koha -- Subscription edit<!--
+TMPL_INCLUDE NAME="doc-head-close.inc" -->
+Koha -- Serial Edit
+<!-- TMPL_INCLUDE NAME="menus.inc" -->
+<!--TMPL_INCLUDE NAME="menu-serials.inc" -->
+
+<!--------------------------MAIN BODY OF PAGE-------------------------->
+<h1>Serial Edition: <!-- TMPL_VAR name="bibliotitle" --></h1>
+<form method="post" name="f" action="serials-edit.pl" onsubmit="return barcode_check()">
+<div id="action">
+    <input type="button" value="Save"  onClick="Check(this.form)" accesskey="w" />
+    <a href="subscription-detail.pl?subscriptionid=<!-- TMPL_VAR name="subscriptionid" -->" title="detail of the subscription">Subscription Details</a>
+    <!-- <a href="/cgi-bin/koha/serials/serials-home.pl?biblionumber=<!-- TMPL_VAR name="biblionumber" -->" class="button" title="all subscriptions on <!-- TMPL_VAR name="bibliotitle" -->">Search All Subscriptions</a> -->
+    <a href="/cgi-bin/koha/detail.pl?bib=<!-- TMPL_VAR name="biblionumber" -->" title="go to <!-- TMPL_VAR name="bibliotitle" -->">Show Biblio</a>
+</div>
+
+  <input type="hidden" name="op" value="serialchangestatus">
+	<table cellspacing="0" cellpadding="0" border="0" class="collapse">
+	<tr>
+		<th>
+			Numbered
+		</th>
+		<th>
+			Published on
+		</th>
+		<th>
+			planned for
+		</th>
+		<th>
+			Status
+		</th>
+		<th>
+			Notes
+		</th>
+	</tr>
+<!-- TMPL_LOOP name="serialslist" -->
+    <tr>
+        <td>
+            <input type="hidden" name="serialid" value="<!-- TMPL_VAR name="serialid" -->" />
+            <input type="hidden" name="subscriptionid" value="<!-- TMPL_VAR name="subscriptionid" -->" />
+            <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
+            <input type="hidden" name="itemcount" value="<!-- TMPL_VAR name="issuesatonce" -->" />
+            <input type="hidden" name="user" value="<!-- TMPL_VAR name="librarian" -->" />
+            Issue <input type="text" name="serialseq" value="<!-- TMPL_VAR name="serialseq" -->" size="20" maxlength="100">
+        </td>
+        <td>
+            <input type="text" name="publisheddate" value="<!-- TMPL_VAR name="publisheddate" -->" size=10 maxlength=15>
+        </td>
+        <td>
+            <input type="text" name="planneddate" value="<!-- TMPL_VAR name="planneddate" -->" size=10 maxlength=15>
+        </td>
+        <td>
+            <select name="status" size="1" id="status<!-- TMPL_VAR NAME="num" -->">
+  <!--TMPL_IF name="status1" -->
+                    <option value="1" selected>Waited</option>
+  <!-- /TMPL_IF -->
+  <!--TMPL_IF name="status2" -->
+                    <option value="2" selected>Arrived</option>
+  <!--TMPL_ELSE -->
+                    <option value="2">Arrived</option>
+  <!-- /TMPL_IF -->
+  <!--TMPL_IF name="status3" -->
+                    <option value="3" selected>Late</option>
+  <!-- TMPL_ELSE -->
+                    <option value="3">Late</option>
+  <!-- /TMPL_IF -->
+  <!--TMPL_IF name="status4" -->
+                    <option value="4" selected>Missing</option>
+  <!-- TMPL_ELSE -->
+                    <option value="4">Missing</option>
+  <!-- /TMPL_IF -->
+  <!--TMPL_IF name="status5" -->
+                    <option value="5" selected>Not Available</option>
+  <!-- TMPL_ELSE -->
+                    <option value="5">Not Available</option>
+  <!-- /TMPL_IF -->
+  <!--TMPL_IF name="status6" -->
+                    <option value="6" selected>Delete</option>
+  <!-- TMPL_ELSE -->
+                    <option value="6">Delete</option>
+  <!-- /TMPL_IF -->
+            </select>
+
+        </td>
+        <td>
+            <input type="text" name="notes" value="<!-- TMPL_VAR name="notes" -->" size=20 maxlength=255>
+        </td>
+    </tr>
+  <!--TMPL_IF Name="serialsadditems"-->
+<!-- Exemple de possibilite -->
+          <tr>
+          <td colspan="5">
+      <a id="label<!--TMPL_VAR Name="serialid"-->" style="color: grey; font-size: 80%; cursor: se-resize;"  onclick="unHideItems('items<!--TMPL_VAR Name="serialid"-->','label<!--TMPL_VAR Name="serialid"-->')">
+             Items   </a>
+        <fieldset style="display:none;" id="items<!--TMPL_VAR Name="serialid"-->">
+        <legend><a style="cursor: se-resize;"  onclick="HideItems('items<!--TMPL_VAR Name="serialid"-->','label<!--TMPL_VAR Name="serialid"-->')">
+                Items</a>
+        </legend>
+          <div id="cataloguing_additem_itemlist">
+        <input type="hidden" name="itemnumber" value="<!-- TMPL_VAR NAME="itemnumber" -->" />
+        Saisir ici les informations de l'exemplaire.
+        Avantage : <br />
+        - Lien avec l'exemplaire assez imm&eacute;diat.<br />
+        -  + visuel.<br />
+        Par javascript, on peut mettre &agrave; jour les champs attaches a serialseq et notes.
+        On a un seul formulaire dans la page
+        Inconvenient : Impossible a coder avec notre facon habituelle de saisir les exemplaires.
+        Il faudrait avoir une liste de hash directement renvoyee par le CGI.<br />
+        Seule possibilite que j'entrevoie :Mettre un attribut a chaque sous-champ.<br />
+        Puis reconstruire un HASH des donnees TAG/subfield/value<br />
+        input type="hidden" name="serial" value="<!-- TMPL_VAR NAME="serialid" -->" /
+        <table>
+        <tr>
+        <!-- TMPL_LOOP NAME="iteminformation" -->
+            <td>
+                <label><!-- TMPL_VAR NAME="subfield" --> - <!-- TMPL_IF name="mandatory" --><b><!-- /TMPL_IF --><!-- TMPL_VAR NAME="marc_lib" --><!-- TMPL_IF name="mandatory" --> *</b><!-- /TMPL_IF --></label>
+                <!-- TMPL_VAR NAME="marc_value" -->
+                <input type="hidden" name="itemnum" value="<!-- TMPL_VAR NAME="itemnumber" -->" />
+                <input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="tag" -->" />
+                <input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="subfield" -->" />
+                <input type="hidden" name="mandatory" value="<!-- TMPL_VAR NAME="mandatory" -->" />
+            </td>
+        <!-- /tmpl_loop -->
+        
+        <input type="hidden" name="moditem" value="" /> 
+        <input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="itemtagfield" -->" />
+        <input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="itemtagsubfield" -->" />
+        <input type="hidden" name="serial" value="<!-- TMPL_VAR NAME="serialid" -->" />
+        <input type="hidden" name="itemnum" value="<!-- TMPL_VAR NAME="itemnumber" -->" />
+        <input type="hidden" name="field_value" value="<!-- TMPL_VAR NAME="itemnumber" -->" />
+        </tr>
+        </table>
+
+        </div>
+        </fieldset>
+    </td>
+    </tr>
+<!-- Exemple de possibilite -->
+  <!-- /TMPL_IF -->
+<!-- /TMPL_LOOP -->
+</table>
+</div>
+  <!--TMPL_IF Name="serialsadditems"-->
+<!-- Autre solution -->
+<div id="edititems">
+  <a id="label" style="color: grey; font-size: 80%; cursor: se-resize;"  onclick="unHideItems('items','label')">
+    Items
+  </a>
+  <fieldset style="display:none;" id="items">
+  <legend>  <a style="cursor: se-resize;"  onclick="HideItems('items','label')">
+Items  </a>
+  </legend>
+    <div id="cataloguing_additem_itemlist">
+      <form method="post" action="additem.pl" name="f">
+      <input type="hidden" name="op" value="<!-- TMPL_VAR NAME="op" -->" />
+      <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
+      On affiche d'abord un tableau des exemplaires de la liste des bulletins.
+      Et on a le meme formulaire que pour la page d'ajout des exemplaires.<br />
+      Inconvenient : Le lien entre les informations de l'exemplaire et celle de serial risque d'etre beaucoup plus  virtuel qu'autre chose.
+      
+      <!-- TMPL_IF name="item_loop" -->
+          <h2>Existing items</h2>
+          <table>
+              <tr>
+                  <!-- TMPL_LOOP NAME="item_header_loop" -->
+                      <th>
+                          <!-- TMPL_VAR NAME="header_value" -->
+                      </th>
+                  <!-- /TMPL_LOOP -->
+                  <th colspan="2">&nbsp;</th>
+              </tr>
+                  <!-- TMPL_LOOP NAME="item_loop" -->
+                  <tr>
+                      <!-- TMPL_VAR NAME="item_value" -->
+                      <td><a href="additem.pl?op=edititem&amp;biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&amp;itemnumber=<!-- TMPL_VAR NAME="itemnumber" -->">Edit</a></td>
+                      <td><a href="javascript:confirm_deletion(<!-- TMPL_VAR NAME="biblionumber" -->,<!-- TMPL_VAR NAME="itemnumber" -->)">Delete</a></td>
+                  </tr>
+                  <!-- /TMPL_LOOP -->
+          </table>
+          </form>
+          </div>
+      <!-- /TMPL_IF -->
+  </div>
+  
+    <div id="cataloguing_additem_newitem">
+        <!-- TMPL_IF name="opisadd" -->
+            <h2>Add Item</h2>
+        <!-- TMPL_ELSE -->
+            <h2>Edit Item</h2>
+        <!-- /TMPL_IF -->	
+            <!-- TMPL_LOOP NAME="item" -->
+                <p>
+                    <label><!-- TMPL_VAR NAME="subfield" --> - <!-- TMPL_IF name="mandatory" --><b><!-- /TMPL_IF --><!-- TMPL_VAR NAME="marc_lib" --><!-- TMPL_IF name="mandatory" --> *</b><!-- /TMPL_IF --></label>
+                    <!-- TMPL_VAR NAME="marc_value" -->
+                    <input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="tag" -->" />
+                    <input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="subfield" -->" />
+                    <input type="hidden" name="mandatory" value="<!-- TMPL_VAR NAME="mandatory" -->" />
+                </p>
+            <!-- /tmpl_loop -->
+        <input type="hidden" name="itemnumber" value="<!-- TMPL_VAR NAME="itemnumber" -->" />
+        <!-- TMPL_IF name="barcode_not_unique" -->
+            ERROR : Barcode already exists !
+        <!-- /TMPL_IF -->
+        <!-- TMPL_IF name="opisadd" -->
+        <input type="button" value="Add item"  onClick="Check(this.form)" accesskey="w" />
+        <!-- TMPL_ELSE -->
+        <input type="hidden" name="tag" value="<!-- TMPL_VAR NAME="itemtagfield" -->" />
+        <input type="hidden" name="subfield" value="<!-- TMPL_VAR NAME="itemtagsubfield" -->" />
+        <input type="hidden" name="field_value" value="<!-- TMPL_VAR NAME="itemnumber" -->" />
+        <input type="button" value="Save Changes" onClick="Check(this.form)" accesskey="w" />
+        <!-- /TMPL_IF -->
+        </form>
+    </div>
+  </fieldset>
+</div>
+  <!--/TMPL_IF-->
+<script language="JavaScript" type="text/javascript">
+
+function popup() {
+	window.open("subscription-renew.pl?subscriptionid=<!-- TMPL_VAR
+name="subscriptionid">","subscription_renewal",'width=700,height=400,toolbar=false,scrollbars=yes');
+}
+
+function barcode_check(){
+    <!-- TMPL_IF NAME="count" -->
+    var count = <!-- TMPL_VAR NAME="count" -->;
+    for(var i=1;i<=count;i++){
+
+        var barcodenum = "barcode"+i;
+        var statusnum = "status"+i;
+        var elembarcode = "document.getElementById('"+barcodenum+"')";
+        var elemstatus = "document.getElementById('"+statusnum+"')";
+// alert(elembarcode+"\n"+eval(elembarcode+".value));
+// alert(elemstatus+"\n"+eval(elemstatus+".value"));
+        if(eval(elembarcode+".value") =='' && eval(elemstatus+".value") == 2){
+            var answer = confirm("Leave barcode blank?\n - Note: unable to change this later");
+            if (answer){
+                document.f.submit();
+            } else {
+                return false;
+            }
+        }
+        if(eval(elembarcode+".value".indexOf('TEMP')) > 0 && eval(elemstatus+".value") == 2){
+            var answer = confirm("A barcode was not entered.\nDo you want to put in a barcode\nor do you want to use a system generated barcode?");
+            if (answer){
+                document.f.submit();
+            } else {
+                return false;
+            }
+        }
+    }
+    <!--/TMPL_IF-->
+}
+
+function _(s) { return s } // dummy function for gettext
+function Check(f) {
+    var total_errors=0;
+//	alert(f.field_value.length);
+    for (i=0 ; i<f.field_value.length ; i++) {
+//	alert (f.field_value[i].value);
+        if (f.field_value[i].value.length==0 && f.mandatory[i].value==1) {
+            document.getElementById("error"+i).style.backgroundColor="#FF0000";
+            total_errors++;
+        } else {
+//			document.getElementById("error"+i).style.backgroundColor="#FFFFFF";
+        }
+    }
+    var alertString2;
+    if (total_errors==0) {
+        document.f.submit();
+    } else {
+        alertString2  = _("Form not submitted because of the following problem(s)");
+        alertString2 += "\n------------------------------------------------------------------------------------\n";
+        alertString2 += "\n- "+ total_errors+_(" mandatory fields empty (see bold subfields)");
+        alert(alertString2);
+    }
+}
+<!--TMPL_IF Name="serialsadditems"-->
+function unHideItems(index,labelindex) {
+	subfield = document.getElementById(index);
+	subfield.style.display = 'block';
+	label = document.getElementById(labelindex);
+	label.style.display='none';	
+}
+function HideItems(index,labelindex) {
+	subfield = document.getElementById(index);
+	subfield.style.display = 'none';
+	label = document.getElementById(labelindex);
+	label.style.display='block';	
+}
+<!--/TMPL_IF>
+</script>
+
+<!-- TMPL_INCLUDE name="intranet-bottom.inc" -->

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	13 Nov 2006 09:33:20 -0000	1.1.2.1
@@ -0,0 +1,69 @@
+#!/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.1.2.1 2006/11/13 09:33:20 hdl 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;
+use HTML::Template;
+
+my $query = new CGI;
+my $op = $query->param('op');
+my $dbh = C4::Context->dbh;
+my $selectview = $query->param('selectview');
+$selectview = C4::Context->preference("SubscriptionHistory") unless $selectview;
+
+my $sth;
+# my $id;
+my ($template, $loggedinuser, $cookie);
+my $biblionumber = $query->param('biblionumber');
+my $subscriptiondescs = GetSubscriptionsFromBiblionumber($biblionumber);
+my $subscriptions = GetFullSubscriptionsFromBiblionumber($biblionumber);
+
+my $title = $subscriptions->[0]{bibliotitle};
+my $yearmin=($subscriptions->[0]{year} eq "manage" && scalar(@$subscriptions)>1)? $subscriptions->[1]{year} :$subscriptions->[0]{year};
+my $yearmax=$subscriptions->[scalar(@$subscriptions)-1]{year};
+($template, $loggedinuser, $cookie)
+  = get_template_and_user({template_name => "serials/serials-collection.tmpl",
+                            query => $query,
+                            type => "intranet",
+                            authnotrequired => 1,
+                            debug => 1,
+                            });
+
+$template->param(
+          biblionumber => $query->param('biblionumber'),
+          subscriptions => $subscriptiondescs,
+          years => $subscriptions,
+          yearmin => $yearmin,
+          yearmax =>$yearmax,
+          bibliotitle => $title,
+          suggestion => C4::Context->preference("suggestion"),
+          virtualshelves => C4::Context->preference("virtualshelves"),
+          );
+
+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	13 Nov 2006 09:33:20 -0000	1.1.2.1
@@ -0,0 +1,202 @@
+#!/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.1.2.1 2006/11/13 09:33:20 hdl 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 $op = $query->param('op');
+my $dbh = C4::Context->dbh;
+my @serialids = $query->param('serialid');
+# my $auser = $query->param('user');
+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 @moditems = $query->param('moditem');
+
+my @serialdatalist;
+foreach my $tmpserialid (@serialids){
+  my $data=GetSerialInformation($tmpserialid);
+  push @serialdatalist,$data;
+}
+# 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]);
+        }
+    }
+    print $query->redirect("serials-collection.pl?biblionumber=".$serialdatalist[0]->{biblionumber});
+}
+my ($template, $loggedinuser, $cookie)
+= get_template_and_user({template_name => "serials/serials-edit.tmpl",
+                query => $query,
+                type => "intranet",
+                authnotrequired => 0,
+                flagsrequired => {catalogue => 1},
+                debug => 1,
+                });
+
+foreach my $tmpserialid (@serialids){
+#   my $data=GetSerialInformation($tmpserialid);
+#   push @serialdatalist,$data;
+  if (C4::Context->preference("serialsadditems")){
+      my $fwk=MARCfind_frameworkcode($dbh,$serialdatalist[0]->{'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 (@serialdatalist){
+              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(serialsadditems =>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=>[]) ;
+  }
+}
+
+
+
+$template->param(
+#             user => $auser,
+            serialslist => \@serialdatalist,
+#             count => $count,
+#             biblionumber => $subscription->{biblionumber},
+#             histstartdate => format_date($solhistory->{'histstartdate'}),
+#             enddate => format_date($solhistory->{'enddate'}),
+#             subscriptionid => $subscriptionid,
+#             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;





More information about the Koha-cvs mailing list