[Koha-cvs] koha/serials acqui-search-result.pl acqui-searc...

paul poulain paul at koha-fr.org
Fri Mar 9 16:14:25 CET 2007


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

Modified files:
	serials        : acqui-search-result.pl acqui-search.pl 
	                 claims.pl distributedto.pl lateissues-excel.pl 
	                 member-search.pl reorder_members.pl 
	                 routing-preview.pl routing.pl serial-issues.pl 
	                 serials-home.pl subscription-add.pl 
	                 subscription-bib-search.pl subscription-copy.pl 
	                 subscription-detail.pl subscription-renew.pl 
	                 viewalerts.pl 

Log message:
	rel_3_0 moved to HEAD

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/serials/acqui-search-result.pl?cvsroot=koha&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/koha/serials/acqui-search.pl?cvsroot=koha&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/koha/serials/claims.pl?cvsroot=koha&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/koha/serials/distributedto.pl?cvsroot=koha&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/koha/serials/lateissues-excel.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/serials/member-search.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/serials/reorder_members.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/serials/routing-preview.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/serials/routing.pl?cvsroot=koha&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/koha/serials/serial-issues.pl?cvsroot=koha&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/koha/serials/serials-home.pl?cvsroot=koha&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/koha/serials/subscription-add.pl?cvsroot=koha&r1=1.10&r2=1.11
http://cvs.savannah.gnu.org/viewcvs/koha/serials/subscription-bib-search.pl?cvsroot=koha&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/koha/serials/subscription-copy.pl?cvsroot=koha&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/koha/serials/subscription-detail.pl?cvsroot=koha&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/koha/serials/subscription-renew.pl?cvsroot=koha&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/koha/serials/viewalerts.pl?cvsroot=koha&r1=1.4&r2=1.5

Patches:
Index: acqui-search-result.pl
===================================================================
RCS file: /sources/koha/koha/serials/acqui-search-result.pl,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- acqui-search-result.pl	27 Sep 2006 21:19:22 -0000	1.7
+++ acqui-search-result.pl	9 Mar 2007 15:14:25 -0000	1.8
@@ -20,7 +20,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: acqui-search-result.pl,v 1.7 2006/09/27 21:19:22 tgarip1957 Exp $
+# $Id: acqui-search-result.pl,v 1.8 2007/03/09 15:14:25 tipaul Exp $
 
 =head1 NAME
 
@@ -43,12 +43,14 @@
 use strict;
 use C4::Auth;
 use C4::Biblio;
+use C4::Output;
 use CGI;
 use C4::Interface::CGI::Output;
+
+
 use C4::Acquisition;
 use C4::Date;
 use C4::Bookseller;
-use C4::Acquisition;
 
 my $query=new CGI;
 my ($template, $loggedinuser, $cookie)
@@ -56,7 +58,7 @@
                  query => $query,
                  type => "intranet",
                  authnotrequired => 0,
-                 flagsrequired => {acquisition => 1},
+                 flagsrequired => {serials => 1},
                  debug => 1,
                  });
 

Index: acqui-search.pl
===================================================================
RCS file: /sources/koha/koha/serials/acqui-search.pl,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- acqui-search.pl	27 Sep 2006 21:19:22 -0000	1.7
+++ acqui-search.pl	9 Mar 2007 15:14:25 -0000	1.8
@@ -17,81 +17,81 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: acqui-search.pl,v 1.7 2006/09/27 21:19:22 tgarip1957 Exp $
+# $Id: acqui-search.pl,v 1.8 2007/03/09 15:14:25 tipaul Exp $
 
 use strict;
 use CGI;
 use C4::Auth;
 use C4::Output;
 use C4::Interface::CGI::Output;
-
 use C4::Bookfund;
-use C4::Acquisition;
+
 my $query = new CGI;
 
-my ($template, $loggedinuser, $cookie)
-    = get_template_and_user({template_name => "serials/acqui-search.tmpl",
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "serials/acqui-search.tmpl",
 			     query => $query,
 			     type => "intranet",
 			     authnotrequired => 0,
-			     flagsrequired => {acquisition => 1},
+        flagsrequired   => { serials => 1 },
 			     debug => 1,
-			     });
-
-
-
+    }
+);
 
 # budget
 my $dbh = C4::Context->dbh;
-my $sthtemp = $dbh->prepare("Select flags, branchcode from borrowers where borrowernumber = ?");
+my $sthtemp =
+  $dbh->prepare(
+    "Select flags, branchcode from borrowers where borrowernumber = ?");
 $sthtemp->execute($loggedinuser);
-my ($flags, $homebranch)=$sthtemp->fetchrow;
-my @results=GetBookFunds($homebranch);
+my ( $flags, $homebranch ) = $sthtemp->fetchrow;
+my @results = GetBookFunds($homebranch);
 my $count = scalar(@results);
 
-my $classlist='';
-my $total=0;
-my $totspent=0;
-my $totcomtd=0;
-my $totavail=0;
+my $classlist   = '';
+my $total       = 0;
+my $totspent    = 0;
+my $totcomtd    = 0;
+my $totavail    = 0;
 my @loop_budget = ();
-for (my $i=0;$i<$count;$i++){
-	my ($spent,$comtd)=GetBookFundBreakdown($results[$i]->{'bookfundid'});
-	my $avail=$results[$i]->{'budgetamount'}-($spent+$comtd);
+for ( my $i = 0 ; $i < $count ; $i++ ) {
+    my ( $spent, $comtd ) =
+      GetBookFundBreakdown( $results[$i]->{'bookfundid'} );
+    my $avail = $results[$i]->{'budgetamount'} - ( $spent + $comtd );
 	my %line;
 	$line{bookfundname} = $results[$i]->{'bookfundname'};
 	$line{budgetamount} = $results[$i]->{'budgetamount'};
-	$line{spent} = sprintf  ("%.2f", $spent);
-	$line{comtd} = sprintf  ("%.2f",$comtd);
-	$line{avail}  = sprintf  ("%.2f",$avail);
+    $line{spent}        = sprintf( "%.2f", $spent );
+    $line{comtd}        = sprintf( "%.2f", $comtd );
+    $line{avail}        = sprintf( "%.2f", $avail );
 	push @loop_budget, \%line;
-	$total+=$results[$i]->{'budgetamount'};
-	$totspent+=$spent;
-	$totcomtd+=$comtd;
-	$totavail+=$avail;
+    $total    += $results[$i]->{'budgetamount'};
+    $totspent += $spent;
+    $totcomtd += $comtd;
+    $totavail += $avail;
 }
+
 #currencies
-my @rates=GetCurrencies();
+my @rates = GetCurrencies();
 my $count = scalar @rates;
 
 my @loop_currency = ();
-for (my $i=0;$i<$count;$i++){
+for ( my $i = 0 ; $i < $count ; $i++ ) {
 	my %line;
 	$line{currency} = $rates[$i]->{'currency'};
 	$line{rate} = $rates[$i]->{'rate'};
 	push @loop_currency, \%line;
 }
-$template->param(classlist => $classlist,
+$template->param(
+    classlist     => $classlist,
 						type => 'intranet',
 						loop_budget => \@loop_budget,
 						loop_currency => \@loop_currency,
-						total => sprintf("%.2f",$total),
-						totspent => sprintf("%.2f",$totspent),
-						totcomtd => sprintf("%.2f",$totcomtd),
-						totavail => sprintf("%.2f",$totavail),
-						intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
-		intranetstylesheet => C4::Context->preference("intranetstylesheet"),
-		IntranetNav => C4::Context->preference("IntranetNav"),
-						);
+    total         => sprintf( "%.2f", $total ),
+    totspent      => sprintf( "%.2f", $totspent ),
+    totcomtd      => sprintf( "%.2f", $totcomtd ),
+    totavail      => sprintf( "%.2f", $totavail )
+);
 
 output_html_with_http_headers $query, $cookie, $template->output;

Index: claims.pl
===================================================================
RCS file: /sources/koha/koha/serials/claims.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- claims.pl	13 Dec 2006 20:07:22 -0000	1.3
+++ claims.pl	9 Mar 2007 15:14:25 -0000	1.4
@@ -5,47 +5,45 @@
 use C4::Auth;
 use C4::Serials;
 use C4::Acquisition;
-
+use C4::Output;
+use C4::Bookseller;
 use C4::Interface::CGI::Output;
 use C4::Context;
+use C4::Letters;
 
+my $input = new CGI;
 
-my $query = new CGI;
-
-my $serialid = $query->param('serialid');
-my $op = $query->param('op');
-# my $claimletter = $query->param('claimletter');
-my $supplierid = $query->param('supplierid');
+my $serialid = $input->param('serialid');
+my $op = $input->param('op');
+my $claimletter = $input->param('claimletter');
+my $supplierid = $input->param('supplierid');
+my $order = $input->param('order');
+warn "order :$order";
 my %supplierlist = GetSuppliersWithLateIssues;
 my @select_supplier;
 
 foreach my $supplierid (keys %supplierlist){
-        my ($count, @dummy) = GetMissingIssues($supplierid);
+        my ($count, @dummy) = GetLateOrMissingIssues($supplierid,"",$order);
         my $counting = $count;
         $supplierlist{$supplierid} = $supplierlist{$supplierid}." ($counting)";
 	push @select_supplier, $supplierid
 }
 
-# my @select_letter = (1,2,3,4);
-# my %letters = (1=>'Claim Form 1',2=>'Claim Form 2',3=>'Claim Form 3',4=>'Claim Form 4');
-my ($count2, @missingissues) = GetMissingIssues($supplierid,$serialid);
+my @letters = GetLetters("claimissues");
+my $letter=((scalar(@letters)>1)||($letters[0]->{name}||$letters[0]->{code}));
+my ($count2, @missingissues) = GetLateOrMissingIssues($supplierid,$serialid,$order);
 
 my $CGIsupplier=CGI::scrolling_list( -name     => 'supplierid',
 			-values   => \@select_supplier,
 			-default  => $supplierid,
 			-labels   => \%supplierlist,
 			-size     => 1,
-			-multiple => 0 );
+			-multiple => 0 
+            -onChange => 'onchange="submit();"');
 
-# my $CGIletter=CGI::scrolling_list( -name     => 'claimletter',
-#			-values   => \@select_letter,
-#			-default  => $claimletter,
-#			-labels   => \%letters,
-#			-size     => 1,
-#			-multiple => 0 );
 my ($singlesupplier, at supplierinfo);
 if($supplierid){
-   ($singlesupplier, at supplierinfo)=bookseller($supplierid);
+   (@supplierinfo)=GetBookSeller($supplierid);
 } else { # set up supplierid for the claim links out of main table if all suppliers is chosen
    for(my $i=0; $i<@missingissues;$i++){
        $missingissues[$i]->{'supplierid'} = getsupplierbyserialid($missingissues[$i]->{'serialid'});
@@ -58,26 +56,37 @@
     $preview = 1;
 }
 
+if ($op eq "send_alert"){
+  my @serialnums=$input->param("serialid");
+  SendAlerts('claimissues',\@serialnums,$input->param("letter_code"));
+  my $cntupdate=UpdateClaimdateIssues(\@serialnums);
+  ### $cntupdate SHOULD be equal to scalar(@$serialnums)
+}
+
 my ($template, $loggedinuser, $cookie)
 = get_template_and_user({template_name => "serials/claims.tmpl",
-				query => $query,
+				query => $input,
 				type => "intranet",
 				authnotrequired => 0,
-				flagsrequired => {catalogue => 1},
+				flagsrequired => {serials => 1},
 				debug => 1,
 				});
 
+$template->param('letters'=>\@letters,'letter'=>$letter);
 $template->param(
+    order =>$order,
 	CGIsupplier => $CGIsupplier,
-#    	CGIletter => $CGIletter,
+    phone => $supplierinfo[0]->{phone},
+    booksellerfax => $supplierinfo[0]->{booksellerfax},
+    bookselleremail => $supplierinfo[0]->{bookselleremail},
         preview => $preview,
         missingissues => \@missingissues,
         supplierid => $supplierid,
-#       claimletter => $claimletter,
+        claimletter => $claimletter,
         singlesupplier => $singlesupplier,
         supplierloop => \@supplierinfo,
 	intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
 		intranetstylesheet => C4::Context->preference("intranetstylesheet"),
 		IntranetNav => C4::Context->preference("IntranetNav"),
 	);
-output_html_with_http_headers $query, $cookie, $template->output;
+output_html_with_http_headers $input, $cookie, $template->output;

Index: distributedto.pl
===================================================================
RCS file: /sources/koha/koha/serials/distributedto.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- distributedto.pl	27 Sep 2006 21:19:22 -0000	1.5
+++ distributedto.pl	9 Mar 2007 15:14:25 -0000	1.6
@@ -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: distributedto.pl,v 1.5 2006/09/27 21:19:22 tgarip1957 Exp $
+# $Id: distributedto.pl,v 1.6 2007/03/09 15:14:25 tipaul Exp $
 
 =head1 NAME
 
@@ -52,9 +52,8 @@
 use C4::Date;
 use C4::Auth;
 use C4::Context;
-
+use C4::Output;
 use C4::Interface::CGI::Output;
-use C4::Search;
 
 use C4::Serials;
 use C4::Members;
@@ -77,7 +76,7 @@
                  query => $input,
                  type => "intranet",
                  authnotrequired => 0,
-                 flagsrequired => {cataloguing => 1},
+                 flagsrequired => {serials => 1},
                  debug => 1,
                  });
 

Index: lateissues-excel.pl
===================================================================
RCS file: /sources/koha/koha/serials/lateissues-excel.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- lateissues-excel.pl	6 Sep 2006 16:21:04 -0000	1.2
+++ lateissues-excel.pl	9 Mar 2007 15:14:25 -0000	1.3
@@ -9,6 +9,7 @@
 use C4::Interface::CGI::Output;
 use C4::Context;
 
+# use Date::Manip;
 use Text::CSV_XS;
 
 

Index: member-search.pl
===================================================================
RCS file: /sources/koha/koha/serials/member-search.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- member-search.pl	6 Sep 2006 16:21:04 -0000	1.2
+++ member-search.pl	9 Mar 2007 15:14:25 -0000	1.3
@@ -1,46 +1,57 @@
 #!/usr/bin/perl
 
-# Member Search.pl script used to search for members to add to a routing list
+# 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 member-search.pl
+
+Member Search.pl script used to search for members to add to a routing list
+ 
+=cut
+
 use strict;
 use CGI;
-use C4::Koha;
-use C4::Auth;
-use C4::Date;
-use C4::Acquisition;
+use C4::Auth;       # get_template_and_user
 use C4::Interface::CGI::Output;
-use C4::Context;
-use C4::Search;
-use C4::Serials;
+use C4::Members;    # BornameSearch
 
 my $query = new CGI;
 my $subscriptionid = $query->param('subscriptionid');
-my $op = $query->param('op');
 my $searchstring = $query->param('member');
-my $dbh = C4::Context->dbh;
-
-my $env;    
     
-    my ($template, $loggedinuser, $cookie)
-= get_template_and_user({template_name => "serials/member-search.tmpl",
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "serials/member-search.tmpl",
 				query => $query,
 				type => "intranet",
 				authnotrequired => 0,
-				flagsrequired => {catalogue => 1},
+        flagsrequired   => { serials => 1 },
 				debug => 1,
-				});
+    }
+);
 
-
-if($searchstring){
-    my ($count, $members) = &BornameSearch($env, $searchstring, "surname", "advanced");
+if ($searchstring) {
+    my ( $count, $members ) = &BornameSearch( '', $searchstring, "surname" );
     
     $template->param(
 	subscriptionid => $subscriptionid,
  	    memberloop => $members,
 	        member => $searchstring,
     );
-} else {
-    $template->param(
-	subscriptionid => $subscriptionid,
-    );
 }
-        output_html_with_http_headers $query, $cookie, $template->output;
+else {
+    $template->param( subscriptionid => $subscriptionid, );
+}
+output_html_with_http_headers $query, $cookie, $template->output;

Index: reorder_members.pl
===================================================================
RCS file: /sources/koha/koha/serials/reorder_members.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- reorder_members.pl	6 Sep 2006 16:21:04 -0000	1.2
+++ reorder_members.pl	9 Mar 2007 15:14:25 -0000	1.3
@@ -6,13 +6,15 @@
 # printed out
 use strict;
 use CGI;
-
+use C4::Koha;
+use C4::Auth;
+use C4::Date;
+use C4::Output;
 use C4::Acquisition;
 use C4::Interface::CGI::Output;
-
+use C4::Context;
 use C4::Serials;
 
-
 my $query = new CGI;
 my $subscriptionid = $query->param('subscriptionid');
 my $routingid = $query->param('routingid');

Index: routing-preview.pl
===================================================================
RCS file: /sources/koha/koha/serials/routing-preview.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- routing-preview.pl	6 Sep 2006 16:21:04 -0000	1.2
+++ routing-preview.pl	9 Mar 2007 15:14:25 -0000	1.3
@@ -14,7 +14,8 @@
 use C4::Circulation::Circ2;
 use C4::Interface::CGI::Output;
 use C4::Context;
-use C4::Search;
+use C4::Members;
+use C4::Biblio;
 use C4::Serials;
 
 my $query = new CGI;
@@ -55,8 +56,8 @@
 	    $count--;
         }
     }
-    my ($count2, at bibitems) = bibitems($biblio);
-    my @itemresults = ItemInfo($env, $subs->{'biblionumber'}, 'intra');    
+    my ($count2, at bibitems) = GetBiblioItemByBiblioNumber($biblio);
+    my @itemresults = GetItemsInfo($subs->{'biblionumber'}, 'intra');
     my $branch = $itemresults[0]->{'holdingbranch'};
     my $const = 'o';
     my $notes;
@@ -66,7 +67,7 @@
                                  AND cancellationdate is NULL AND (found <> 'F' or found is NULL)");
         $sth->execute($biblio,$routinglist[$i]->{'borrowernumber'});
         my $data = $sth->fetchrow_hashref;
-#	warn Dumper($data);
+
 #       warn "$routinglist[$i]->{'borrowernumber'} is the same as $data->{'borrowernumber'}";
 	if($routinglist[$i]->{'borrowernumber'} == $data->{'borrowernumber'}){
 	    UpdateReserve($routinglist[$i]->{'ranking'},$biblio,$routinglist[$i]->{'borrowernumber'},$branch);
@@ -81,16 +82,17 @@
 				query => $query,
 				type => "intranet",
 				authnotrequired => 0,
-				flagsrequired => {catalogue => 1},
+				flagsrequired => {serials => 1},
 				debug => 1,
 				});    
+    $template->param("libraryname"=>C4::Context->preference("LibraryName"));
 } else {
     ($template, $loggedinuser, $cookie)
 = get_template_and_user({template_name => "serials/routing-preview.tmpl",
 				query => $query,
 				type => "intranet",
 				authnotrequired => 0,
-				flagsrequired => {catalogue => 1},
+				flagsrequired => {serials => 1},
 				debug => 1,
 				});
 }    

Index: routing.pl
===================================================================
RCS file: /sources/koha/koha/serials/routing.pl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- routing.pl	6 Sep 2006 16:21:04 -0000	1.2
+++ routing.pl	9 Mar 2007 15:14:25 -0000	1.3
@@ -1,25 +1,48 @@
 #!/usr/bin/perl
 
-# Routing.pl script used to create a routing list for a serial subscription
-# In this instance it is in fact a setting up of a list of reserves for the item
-# where the hierarchical order can be changed on the fly and a routing list can be
-# printed out
+# 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 Routing.pl
+
+script used to create a routing list for a serial subscription
+In this instance it is in fact a setting up of a list of reserves for the item
+where the hierarchical order can be changed on the fly and a routing list can be
+printed out
+
+=cut
+
 use strict;
 use CGI;
 use C4::Koha;
 use C4::Auth;
 use C4::Date;
+use C4::Output;
 use C4::Acquisition;
 use C4::Interface::CGI::Output;
 use C4::Context;
-use C4::Search;
+
+use C4::Members;
 use C4::Serials;
 
 my $query = new CGI;
 my $subscriptionid = $query->param('subscriptionid');
 my $serialseq = $query->param('serialseq');
 my $routingid = $query->param('routingid');
-my $bornum = $query->param('bornum');
+my $borrowernumber = $query->param('borrowernumber');
 my $notes = $query->param('notes');
 my $op = $query->param('op');
 my $date_selected = $query->param('date_selected');
@@ -30,7 +53,7 @@
 }
 
 if($op eq 'add'){
-    addroutingmember($bornum,$subscriptionid);
+    addroutingmember($borrowernumber,$subscriptionid);
 }
 if($op eq 'save'){
     my $sth = $dbh->prepare("UPDATE serial SET routingnotes = ? WHERE subscriptionid = ?");
@@ -40,7 +63,7 @@
     
 my ($routing, @routinglist) = getroutinglist($subscriptionid);
 my $subs = GetSubscription($subscriptionid);
-my ($count, at serials) = old_getserials($subscriptionid);
+my ($count, at serials) = GetSerials($subscriptionid);
 my ($serialdates) = GetLatestSerials($subscriptionid,$count);
 
 my @dates;
@@ -62,7 +85,7 @@
 				query => $query,
 				type => "intranet",
 				authnotrequired => 0,
-				flagsrequired => {catalogue => 1},
+				flagsrequired => {serials => 1},
 				debug => 1,
 				});
 # my $date;
@@ -100,7 +123,7 @@
     
     push(@results, $data);
 }
-# warn Dumper(@results);
+
 # for adding routing list
 my $new;
 if ($op eq 'new') {

Index: serial-issues.pl
===================================================================
RCS file: /sources/koha/koha/serials/serial-issues.pl,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- serial-issues.pl	27 Sep 2006 21:19:22 -0000	1.6
+++ serial-issues.pl	9 Mar 2007 15:14:25 -0000	1.7
@@ -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: serial-issues.pl,v 1.6 2006/09/27 21:19:22 tgarip1957 Exp $
+# $Id: serial-issues.pl,v 1.7 2007/03/09 15:14:25 tipaul Exp $
 
 =head1 NAME
 
@@ -73,7 +73,8 @@
      = get_template_and_user({template_name => "serials/serial-issues-full.tmpl",
      query => $query,
      type => "intranet",
-     authnotrequired => 1,
+     authnotrequired => 0,
+	 flagsrequired => {serials => 1},
      debug => 1,
      });
  
@@ -110,8 +111,4 @@
         virtualshelves => "".C4::Context->preference("virtualshelves"),
     );
 }
-$template->param(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-home.pl
===================================================================
RCS file: /sources/koha/koha/serials/serials-home.pl,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- serials-home.pl	15 Nov 2006 01:38:26 -0000	1.9
+++ serials-home.pl	9 Mar 2007 15:14:25 -0000	1.10
@@ -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-home.pl,v 1.9 2006/11/15 01:38:26 tgarip1957 Exp $
+# $Id: serials-home.pl,v 1.10 2007/03/09 15:14:25 tipaul Exp $
 
 =head1 NAME
 
@@ -41,50 +41,51 @@
 
 =cut
 
-
 use strict;
 use CGI;
 use C4::Auth;
 use C4::Serials;
+use C4::Output;
 use C4::Interface::CGI::Output;
 use C4::Context;
 
 my $query = new CGI;
-my $title = $query->param('title');
-my $ISSN = $query->param('ISSN');
-my $supplierid = $query->param('supplierid');
+my $title         = $query->param('title_filter');
+my $ISSN          = $query->param('ISSN_filter');
 my $routing = $query->param('routing');
 my $searched = $query->param('searched');
 my $biblionumber = $query->param('biblionumber');
-my $alt_links = 0;
-if(C4::Context->preference("RoutingSerials")){
-    $alt_links = 0;
-}
-my @subscriptions = GetSubscriptions($title,$ISSN,$biblionumber,$supplierid);
-my ($template, $loggedinuser, $cookie)
-= get_template_and_user({template_name => "serials/serials-home.tmpl",
+
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "serials/serials-home.tmpl",
 				query => $query,
 				type => "intranet",
 				authnotrequired => 0,
-				flagsrequired => {catalogue => 1},
+        flagsrequired   => { serials => 1 },
 				debug => 1,
-				});
+    }
+);
+
+my @subscriptions;
+if ($searched){
+    @subscriptions = GetSubscriptions( $title, $ISSN, $biblionumber );
+}
 
 # to toggle between create or edit routing list options
-if($routing){ 
-    for(my $i=0;$i<@subscriptions;$i++){
-	my $checkrouting = check_routing($subscriptions[$i]->{'subscriptionid'});
+if ($routing) {
+    for ( my $i = 0 ; $i < @subscriptions ; $i++ ) {
+        my $checkrouting =
+          check_routing( $subscriptions[$i]->{'subscriptionid'} );
 	$subscriptions[$i]->{'routingedit'} = $checkrouting;
-	# warn "check $checkrouting";
     }
 }
 
 $template->param(
 	subscriptions => \@subscriptions,
-	title => $title,
-	ISSN => $ISSN,
+    title_filter  => $title,
+    ISSN_filter   => $ISSN,
         done_searched => $searched,
         routing => $routing,
-        alt_links => $alt_links,
-	);
+);
 output_html_with_http_headers $query, $cookie, $template->output;

Index: subscription-add.pl
===================================================================
RCS file: /sources/koha/koha/serials/subscription-add.pl,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- subscription-add.pl	15 Nov 2006 01:38:26 -0000	1.10
+++ subscription-add.pl	9 Mar 2007 15:14:25 -0000	1.11
@@ -1,7 +1,5 @@
 #!/usr/bin/perl
 
-# Copyright 2000-2003 Katipo Communications
-#
 # This file is part of Koha.
 #
 # Koha is free software; you can redistribute it and/or modify it under the
@@ -17,55 +15,30 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: subscription-add.pl,v 1.10 2006/11/15 01:38:26 tgarip1957 Exp $
-
-=head1 NAME
-
-subscription-add.pl
-
-=head1 DESCRIPTION
-
-this script add a subscription into the database.
-
-=head1 PARAMETERS
-
-=over 4
-
-=item op
-op use to know the operation to do on this template.
- * mod : to modify an existing subscription
- * addsubscription : to add a subscription
-
-Note that if op = mod or addsubscription there are a lot of other params.
-
-
-=back
-
-=cut
-
-
 use strict;
 use CGI;
 use C4::Koha;
 use C4::Auth;
 use C4::Date;
-use C4::Serials;
-use C4::Bookfund;
+use C4::Output;
+use C4::Acquisition;
 use C4::Interface::CGI::Output;
 use C4::Context;
+use C4::Branch; # GetBranches
+use C4::Serials;
+use Date::Manip;
 use C4::Letters;
-use C4::Members;
-use DateTime;
+
 my $query = new CGI;
 my $op = $query->param('op');
 my $dbh = C4::Context->dbh;
-my ($subscriptionid,$auser,$librarian,$cost,$aqbooksellerid, $aqbooksellername,$aqbudgetid, $bookfundid, $startdate, $periodicity,
-    $publisheddate,$dow,$irregularity, $numberpattern, $numberlength, $weeklength, $monthlength, $sublength,
+my ($subscriptionid,$auser,$branchcode,$librarian,$cost,$aqbooksellerid, $aqbooksellername,$aqbudgetid, $bookfundid, $startdate, $periodicity,
+	$firstacquidate, $dow, $irregularity, $numberpattern, $numberlength, $weeklength, $monthlength, $sublength,
     $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1,
     $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2,
     $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3,
     $numberingmethod, $status, $biblionumber,
-    $title, $notes, $letter,$callnumber,$hemisphere);
+	$bibliotitle, $callnumber, $notes, $hemisphere, $letter, $manualhistory);
 
     my @budgets;
 my ($template, $loggedinuser, $cookie)
@@ -73,26 +46,24 @@
                 query => $query,
                 type => "intranet",
                 authnotrequired => 0,
-                flagsrequired => {catalogue => 1},
+				flagsrequired => {serials => 1},
                 debug => 1,
                 });
 
+
 my $weekarrayjs='';
 my $count = 0;
-my $today=get_today();
- my $dateobj=DATE_obj($today);
-  my $year=$dateobj->year;
-  my $month=$dateobj->month;
-  my $day=$dateobj->day_of_month;
-my $firstday = $dateobj->day_of_year;
-my $wkno = $dateobj->week_number;
+my ($year, $month, $day) = UnixDate("today", "%Y", "%m", "%d");
+my $firstday = Date_DayOfYear($month,$day,$year);
+my $wkno = Date_WeekOfYear($month,$day,$year,1); # week starting monday
 my $weekno = $wkno;
 for(my $i=$firstday;$i<($firstday+365);$i=$i+7){
         $count = $i;
         if($wkno > 52){$year++; $wkno=1;}
         if($count>365){$count=$i-365;}    
-     my $newdate=DateTime->from_day_of_year(year=>$year,day_of_year=>$count);
-        $weekarrayjs .= "'Wk $wkno: ".format_date($newdate->ymd)."',";
+        my ($y,$m,$d) = Date_NthDayOfYear($year,$count);
+        my $output = "$y-$m-$d";
+        $weekarrayjs .= "'Wk $wkno: ".format_date($output)."',";
         $wkno++;    
 }
 chop($weekarrayjs);
@@ -103,38 +74,55 @@
             'issues', 'weeks', 'months'
         ); 
 my @sub_type_data;
-if ($op eq 'mod') {
+
+my $letters = GetLetters('serial');
+my @letterloop;
+foreach my $thisletter (keys %$letters) {
+    my $selected = 1 if $thisletter eq $letter;
+    my %row =(value => $thisletter,
+                selected => $selected,
+                lettername => $letters->{$thisletter},
+            );
+    push @letterloop, \%row;
+}
+$template->param(letterloop => \@letterloop);
+
+my $onlymine=C4::Context->preference('IndependantBranches') && 
+             C4::Context->userenv && 
+             C4::Context->userenv->{flags}!=1 && 
+             C4::Context->userenv->{branch};
+my $branches = GetBranches($onlymine);
+my @branchloop;
+foreach my $thisbranch (keys %$branches) {
+    my $selected = 1 if $thisbranch eq C4::Context->userenv->{'branch'};
+    my %row =(value => $thisbranch,
+                selected => $selected,
+                branchname => $branches->{$thisbranch}->{'branchname'},
+            );
+    push @branchloop, \%row;
+}
+$template->param(branchloop => \@branchloop);
+
+if ($op eq 'mod'||$op eq 'dup') {
     my $subscriptionid = $query->param('subscriptionid');
+#     warn "irregularity :$irregularity numberpattern : $numberpattern, callnumber :$callnumber, firstacquidate :$firstacquidate";
     my $subs = &GetSubscription($subscriptionid);
-    $auser = $subs->{'user'};
-    $librarian = $subs->{'librarian'};
-    $cost = $subs->{'cost'};
-    $aqbooksellerid = $subs->{'aqbooksellerid'};
-    $aqbooksellername = $subs->{'aqbooksellername'};
-    $bookfundid = $subs->{'bookfundid'};
-    $aqbudgetid = $subs->{'aqbudgetid'};
-    defined $aqbudgetid or $aqbudgetid='';
-    $startdate = $subs->{'startdate'};
-   $publisheddate = $subs->{'publisheddate'};
-    $periodicity = $subs->{'periodicity'};
-    $dow = $subs->{'dow'};
-        $irregularity = $subs->{'irregularity'};
-        $numberpattern = $subs->{'numberpattern'};
-    $numberlength = $subs->{'numberlength'};
-    $weeklength = $subs->{'weeklength'};
-    $monthlength = $subs->{'monthlength'};
-       if($monthlength > 0){
-	    $sublength = $monthlength;
-	    $sub_on = $subscription_types[2];
-	} elsif ($weeklength>0){
+    $subs->{'startdate'}=format_date($subs->{'startdate'});
+    $subs->{'firstacquidate'}=format_date($subs->{'firstacquidate'});
+    $subs->{'histstartdate'}=format_date($subs->{'histstartdate'});
+    $subs->{'enddate'}=format_date($subs->{enddate});
+    $subs->{'letter'}='' unless($subs->{'letter'});
+
+    if($subs->{numberlength} > 0){
+        $sublength = $subs->{numberlength};
+        $sub_on = $subscription_types[0];
+    } elsif ($subs->{weeklength}>0){
 	    $sublength = $weeklength;
 	    $sub_on = $subscription_types[1];
 	} else {
-	    $sublength = $numberlength;
-	    $sub_on = $subscription_types[0];
+        $sublength = $subs->{monthlength};
+        $sub_on = $subscription_types[2];
 	}
-        
-
         while (@subscription_types) {
            my $sub_type = shift @subscription_types;
            my %row = ( 'name' => $sub_type );
@@ -145,109 +133,39 @@
            }
            push( @sub_type_data, \%row );
         }
-    $add1 = $subs->{'add1'};
-    $every1 = $subs->{'every1'};
-    $whenmorethan1 = $subs->{'whenmorethan1'};
-    $setto1 = $subs->{'setto1'};
-    $lastvalue1 = $subs->{'lastvalue1'};
-    $innerloop1 = $subs->{'innerloop1'};
-    $add2 = $subs->{'add2'};
-    $every2 = $subs->{'every2'};
-    $whenmorethan2 = $subs->{'whenmorethan2'};
-    $setto2 = $subs->{'setto2'};
-    $lastvalue2 = $subs->{'lastvalue2'};
-    $innerloop2 = $subs->{'innerloop2'};
-    $add3 = $subs->{'add3'};
-    $every3 = $subs->{'every3'};
-    $whenmorethan3 = $subs->{'whenmorethan3'};
-    $setto3 = $subs->{'setto3'};
-    $lastvalue3 = $subs->{'lastvalue3'};
-    $innerloop3 = $subs->{'innerloop3'};
-    $numberingmethod = $subs->{'numberingmethod'};
-    $status = $subs->{status};
-    $biblionumber = $subs->{'biblionumber'};
-    $title = $subs->{'title'},
-           $callnumber = $subs->{'callnumber'};
-           $hemisphere = $subs->{'hemisphere'};
-    $notes = $subs->{'notes'};
-    $letter = $subs->{'letter'};
-    defined $letter or $letter='';
+
+    $template->param($subs);
     $template->param(
         $op => 1,
-        user => $auser,
-        librarian => $librarian,
-        aqbooksellerid => $aqbooksellerid,
-        aqbooksellername => $aqbooksellername,
-        cost => $cost,
-        aqbudgetid => $aqbudgetid,
-        bookfundid => $bookfundid,
-        startdate => format_date($startdate),    
-         publisheddate => format_date($publisheddate),    
-        periodicity => $periodicity,
-        numberpattern=>$numberpattern,
-        dow => $dow,
-        numberlength => $numberlength,
-        weeklength => $weeklength,
-        monthlength => $monthlength,
-	sublength=>$sublength,
-        add1 => $add1,
-        every1 => $every1,
-        whenmorethan1 => $whenmorethan1,
-        setto1 => $setto1,
-        lastvalue1 => $lastvalue1,
-        innerloop1 => $innerloop1,
-        add2 => $add2,
-        every2 => $every2,
-        whenmorethan2 => $whenmorethan2,
-        setto2 => $setto2,
-        lastvalue2 => $lastvalue2,
-        innerloop2 => $innerloop2,
-        add3 => $add3,
-        every3 => $every3,
-        whenmorethan3 => $whenmorethan3,
-        setto3 => $setto3,
-        lastvalue3 => $lastvalue3,
-        innerloop3 => $innerloop3,
-        numberingmethod => $numberingmethod,
-        status => $status,
-        biblionumber => $biblionumber,
-        title => $title,
-               callnumber => $callnumber,
-        notes => $notes,
-        letter => $letter,
-        subscriptionid => $subscriptionid,
-        weekarrayjs => $weekarrayjs,
-	        weekno => $weekno,
-	        hemisphere => $hemisphere,
-        "periodicity$periodicity" => 1,
-        "dow$dow" => 1,
-        "numberpattern$numberpattern" => 1,
+            subtype => \@sub_type_data,
+            sublength =>$sublength,
+            history => ($op eq 'mod' && ($subs->{recievedlist}||$subs->{missinglist}||$subs->{opacnote}||$subs->{librariannote}))
+            );
+    $template->param(
+                "periodicity".$subs->{'periodicity'} => 1,
+                "dow".$subs->{'periodicity'} => 1,
+                "numberpattern".$subs->{'periodicity'} => 1,
         );
 }
 
-my @letterlist = GetLetterList('serial');
-for (my $i=0;$i<=$#letterlist;$i++) {
-    $letterlist[$i]->{'selected'} =1 if $letterlist[$i]->{'code'} eq $letter;
-}
-$template->param(letters => \@letterlist);
-
 if ($op eq 'addsubscription') {
   my @irregular = $query->param('irregular');
-        my $irregular_count = @irregular;
+    my $irregular_count = scalar(@irregular);
         for(my $i =0;$i<$irregular_count;$i++){
-            $irregularity .=$irregular[$i]."|";
+        $irregularity .=$irregular[$i].",";
         }
-        $irregularity =~ s/\|$//;
+    $irregularity =~ s/\,$//;
         
     my $auser = $query->param('user');
+    my $branchcode = $query->param('branchcode');
     my $aqbooksellerid = $query->param('aqbooksellerid');
     my $cost = $query->param('cost');
     my $aqbudgetid = $query->param('aqbudgetid');
     my $startdate = $query->param('startdate');
-     my $publisheddate = $query->param('publisheddate');
-    my $callnumber=$query->param('callnumber');	  
+    my $firstacquidate = $query->param('firstacquidate');    
     my $periodicity = $query->param('periodicity');
     my $dow = $query->param('dow');
+    my $irregularity = $query->param('irregularity');
 	my $numberlength = 0;
 	my $weeklength = 0;
 	my $monthlength = 0;
@@ -262,7 +180,6 @@
 	    $numberlength = $sublength;
 	}
 
-
 	my $add1 = $query->param('add1');
 	my $every1 = $query->param('every1');
 	my $whenmorethan1 = $query->param('whenmorethan1');
@@ -281,18 +198,105 @@
 	my $numberingmethod = $query->param('numberingmethod');
 	my $status = 1;
     my $biblionumber = $query->param('biblionumber');
+    my $callnumber = $query->param('callnumber');
     my $notes = $query->param('notes');
-    my $letter = $query->param('letter');
+    my $internalnotes = $query->param('internalnotes');
             my $hemisphere = $query->param('hemisphere') || 1;
-
-    my $subscriptionid = NewSubscription($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,
+	my $letter = $query->param('letter');
+    ### BugFIX : hdl doesnot know what innerloops or letter stand for but it seems necessary. So he adds them.
+    my $manualhistory = $query->param('manualhist');
+    my ($innerloop1,$innerloop2,$innerloop3);
+	my $subscriptionid = NewSubscription($auser,$branchcode,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber,
                     $startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength,
-                    $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,
-                    $add2,$every2,$whenmorethan2,$setto2,$lastvalue2,
-                    $add3,$every3,$whenmorethan3,$setto3,$lastvalue3,
-                    $numberingmethod, $status, $notes, $letter,$irregularity,$hemisphere,$callnumber,$numberpattern,$publisheddate    );
+					$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,($manualhistory?$manualhistory:0),$internalnotes
+				);
+
+    print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
+} elsif ($op eq 'modsubscription') {
+    my $subscriptionid = $query->param('subscriptionid');
+    my @irregular = $query->param('irregular');
+    my $irregular_count = @irregular;
+    for(my $i =0;$i<$irregular_count;$i++){
+      $irregularity .=$irregular[$i].",";
+      warn "irregular : $irregular[$i] string :$irregularity";
+    }
+    $irregularity =~ s/\,$//;
+
+    my $auser = $query->param('user');
+    my $librarian => $query->param('librarian'),
+    my $branchcode = $query->param('branchcode');
+    my $cost = $query->param('cost');
+    my $aqbooksellerid = $query->param('aqbooksellerid');
+    my $biblionumber = $query->param('biblionumber');
+    my $aqbudgetid = $query->param('aqbudgetid');
+    my $startdate = format_date_in_iso($query->param('startdate'));
+    my $firstacquidate = format_date_in_iso($query->param('firstacquidate'));    
+    my $periodicity = $query->param('periodicity');
+    my $dow = $query->param('dow');
+    my $sublength = $query->param('sublength');
+    my $subtype = $query->param('subtype');
+
+    if($subtype eq 'months'){
+        $monthlength = $sublength;
+    } elsif ($subtype eq 'weeks'){
+        $weeklength = $sublength;
+    } else {
+        $numberlength = $sublength;
+    }
+    my $numberpattern = $query->param('numbering_pattern');
+    my $add1 = $query->param('add1');
+    my $every1 = $query->param('every1');
+    my $whenmorethan1 = $query->param('whenmorethan1');
+    my $setto1 = $query->param('setto1');
+    my $lastvalue1 = $query->param('lastvalue1');
+    my $innerloop1 = $query->param('innerloop1');
+    my $add2 = $query->param('add2');
+    my $every2 = $query->param('every2');
+    my $whenmorethan2 = $query->param('whenmorethan2');
+    my $setto2 = $query->param('setto2');
+    my $lastvalue2 = $query->param('lastvalue2');
+    my $innerloop2 = $query->param('innerloop2');
+    my $add3 = $query->param('add3');
+    my $every3 = $query->param('every3');
+    my $whenmorethan3 = $query->param('whenmorethan3');
+    my $setto3 = $query->param('setto3');
+    my $lastvalue3 = $query->param('lastvalue3');
+    my $innerloop3 = $query->param('innerloop3');
+    my $numberingmethod = $query->param('numberingmethod');
+    my $status = 1;
+    my $callnumber = $query->param('callnumber');
+    my $notes = $query->param('notes');
+    my $internalnotes = $query->param('internalnotes');
+    my $hemisphere = $query->param('hemisphere');
+    my $letter = $query->param('letter');
+    my $manualhistory = $query->param('manualhist');
+    my $enddate = $query->param('enddate');
+    my $histstartdate = format_date_in_iso($query->param('histstartdate'));
+    my $recievedlist = $query->param('recievedlist');
+    my $missinglist = $query->param('missinglist');
+    my $opacnote = $query->param('opacnote');
+    my $librariannote = $query->param('librariannote');
+    &ModSubscription(
+        $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,   $add3,           $every3,
+        $whenmorethan3,   $setto3,       $lastvalue3,     $innerloop3,
+        $numberingmethod, $status,       $biblionumber,   $callnumber,
+        $notes,           $letter,       $hemisphere,     $manualhistory,$internalnotes,
+        $subscriptionid);
+
+    ModSubscriptionHistory ($subscriptionid,$histstartdate,$enddate,$recievedlist,$missinglist,$opacnote,$librariannote);
     print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
 } else {
+
      while (@subscription_types) {
            my $sub_type = shift @subscription_types;
            my %row = ( 'name' => $sub_type );

Index: subscription-bib-search.pl
===================================================================
RCS file: /sources/koha/koha/serials/subscription-bib-search.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- subscription-bib-search.pl	28 Sep 2006 14:12:01 -0000	1.5
+++ subscription-bib-search.pl	9 Mar 2007 15:14:25 -0000	1.6
@@ -18,52 +18,97 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-use strict;
 
+=head1 NAME
+
+subscription-bib-search.pl
+
+=head1 DESCRIPTION
+
+this script search among all existing subscriptions.
+
+=head1 PARAMETERS
+
+=over 4
+
+=item op
+op use to know the operation to do on this template.
+ * do_search : to search the subscription.
+
+Note that if op = do_search there are some others params specific to the search :
+    marclist,and_or,excluding,operator,value
+
+=item startfrom
+to multipage gestion.
+
+
+=back
+
+=cut
+
+
+use strict;
+require Exporter;
 use CGI;
 use C4::Koha;
 use C4::Auth;
 use C4::Context;
-use C4::Search;
-use C4::Auth;
+use C4::Output;
 use C4::Interface::CGI::Output;
+use C4::Search;
 use C4::Biblio;
-use C4::Acquisition;
-use C4::Koha; # XXX subfield_is_koha_internal_p
-
 
-# Creates a scrolling list with the associated default value.
-# Using more than one scrolling list in a CGI assigns the same default value to all the
-# scrolling lists on the page !?!? That's why this function was written.
-
-my $query=new CGI;
-my $type=$query->param('type');
-my $op = $query->param('op');
+my $input=new CGI;
+# my $type=$query->param('type');
+my $op = $input->param('op');
 my $dbh = C4::Context->dbh;
 
-my $startfrom=$query->param('startfrom');
-$startfrom=0 if(!defined $startfrom);
+my $startfrom=$input->param('startfrom');
+$startfrom=0 unless $startfrom;
 my ($template, $loggedinuser, $cookie);
 my $resultsperpage;
 
 if ($op eq "do_search") {
-	my @kohafield = $query->param('kohafield');
-	my @and_or = $query->param('and_or');
-	my @relation = $query->param('relation');
-	my @value = $query->param('value');
-	my $order=$query->param('order');
-	$resultsperpage= $query->param('resultsperpage');
-	$resultsperpage = 9 if(!defined $resultsperpage);
-	# builds tag and subfield arrays
+    my $query = $input->param('q');
+
+    $resultsperpage= $input->param('resultsperpage');
+    $resultsperpage = 19 if(!defined $resultsperpage);
+
+    my ($error,$marcrecords) = SimpleSearch($query);
+    my $total = scalar @$marcrecords;
 	
-	my ($total,$facets, at results) = ZEBRAsearch_kohafields(\@kohafield,\@value,\@relation,$order,\@and_or,1,"",$startfrom,$resultsperpage,"intranet");
+    if (defined $error) {
+        $template->param(query_error => $error);
+        warn "error: ".$error;
+        output_html_with_http_headers $input, $cookie, $template->output;
+        exit;
+    }
+    my @results;
+    warn "total=".$total;
+    
+    for(my $i=0;$i<$total;$i++) {
+        my %resultsloop;
+        my $marcrecord = MARC::File::USMARC::decode($marcrecords->[$i]);
+        my $biblio = MARCmarc2koha(C4::Context->dbh,$marcrecord,'');
+
+        #build the hash for the template.
+        $resultsloop{highlight}       = ($i % 2)?(1):(0);
+        $resultsloop{title}           = $biblio->{'title'};
+        $resultsloop{subtitle}        = $biblio->{'subtitle'};
+        $resultsloop{biblionumber}    = $biblio->{'biblionumber'};
+        $resultsloop{author}          = $biblio->{'author'};
+        $resultsloop{publishercode}   = $biblio->{'publishercode'};
+        $resultsloop{publicationyear} = $biblio->{'publicationyear'};
+
+        push @results, \%resultsloop;
+    }
  										
 	($template, $loggedinuser, $cookie)
 		= get_template_and_user({template_name => "serials/result.tmpl",
-				query => $query,
+                query => $input,
 				type => "intranet",
 				authnotrequired => 0,
-				flagsrequired => {borrowers => 1},
+                flagsrequired => {serials => 1},
 				flagsrequired => {catalogue => 1},
 				debug => 1,
 				});
@@ -75,16 +120,6 @@
 		$displaynext = 1;
 	}
 
-	my @field_data = ();
-
-
-	for(my $i = 0 ; $i <= $#value ; $i++)
-	{
-		push @field_data, { term => "kohafield", val=>$kohafield[$i] };
-		push @field_data, { term => "and_or", val=>$and_or[$i] };
-		push @field_data, { term => "relation", val=>$relation[$i] };
-		push @field_data, { term => "value", val=>$value[$i] };
-	}
 
 	my @numbers = ();
 
@@ -98,7 +133,7 @@
 	    		($startfrom==($i-1)) && ($highlight=1);
 	    		push @numbers, { number => $i,
 					highlight => $highlight ,
-					searchdata=> \@field_data,
+                    searchdata=> \@results,
 					startfrom => ($i-1)};
 			}
     	}
@@ -113,59 +148,48 @@
 	} else {
 		$to = (($startfrom+1)*$resultsperpage);
 	}
-	$template->param(result => \@results,
+    $template->param(
+                            query => $query,
+                            resultsloop => \@results,
 							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,
 							);
-} else {
+} # end of if ($op eq "do_search")
+ else {
 	($template, $loggedinuser, $cookie)
 		= get_template_and_user({template_name => "serials/subscription-bib-search.tmpl",
-				query => $query,
+                query => $input,
 				type => "intranet",
 				authnotrequired => 0,
-				flagsrequired => {catalogue => 1},
+                flagsrequired => {catalogue => 1, serials=>1},
 				debug => 1,
 				});
-	my $sth=$dbh->prepare("Select itemtype,description from itemtypes order by description");
-	$sth->execute;
-	my  @itemtype;
-	my %itemtypes;
-	push @itemtype, "";
-	$itemtypes{''} = "";
-	while (my ($value,$lib) = $sth->fetchrow_array) {
-		push @itemtype, $value;
-		$itemtypes{$value}=$lib;
-	}
 
-	my $CGIitemtype=CGI::scrolling_list( -name     => 'value',
-				-values   => \@itemtype,
+    my  %itemtypes = GetItemTypes();
+    my @values = values %itemtypes;
+    my $CGIitemtype=CGI::scrolling_list(
+            -name     => 'value',
+            -values   => \@values,
  				-labels   => \%itemtypes,
 				-size     => 1,
-	 			-tabindex=>'',
-				-multiple => 0 );
-	$sth->finish;
+            -multiple => 0
+    );
 
 	$template->param(
 			CGIitemtype => $CGIitemtype,
 			);
 }
 
-
 # Print the page
-$template->param(intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
-		intranetstylesheet => C4::Context->preference("intranetstylesheet"),
-		IntranetNav => C4::Context->preference("IntranetNav"),
-		);
-output_html_with_http_headers $query, $cookie, $template->output;
+output_html_with_http_headers $input, $cookie, $template->output;
 
 # Local Variables:
 # tab-width: 4

Index: subscription-copy.pl
===================================================================
RCS file: /sources/koha/koha/serials/subscription-copy.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- subscription-copy.pl	20 Jul 2006 03:18:43 -0000	1.1
+++ subscription-copy.pl	9 Mar 2007 15:14:25 -0000	1.2
@@ -10,7 +10,7 @@
 use C4::Acquisition;
 use C4::Interface::CGI::Output;
 use C4::Context;
-use HTML::Template;
+
 use C4::Serials;
 use Date::Manip;
 

Index: subscription-detail.pl
===================================================================
RCS file: /sources/koha/koha/serials/subscription-detail.pl,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- subscription-detail.pl	15 Nov 2006 01:38:26 -0000	1.5
+++ subscription-detail.pl	9 Mar 2007 15:14:25 -0000	1.6
@@ -1,5 +1,20 @@
 #!/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
+
 use strict;
 use CGI;
 use C4::Auth;
@@ -9,7 +24,7 @@
 use C4::Output;
 use C4::Interface::CGI::Output;
 use C4::Context;
-use DateTime;
+use Date::Manip;
 
 my $query = new CGI;
 my $op = $query->param('op');
@@ -18,19 +33,18 @@
 # my $id;
 my ($template, $loggedinuser, $cookie, $subs);
 my ($subscriptionid,$auser,$librarian,$cost,$aqbooksellerid, $aqbooksellername,$aqbudgetid, $bookfundid, $startdate, $periodicity,
-	$publisheddate, $dow, $irregularity, $sublength, $subtype, $numberpattern, $numberlength, $weeklength, $monthlength,
+    $firstacquidate, $dow, $irregularity, $sublength, $subtype, $numberpattern, $numberlength, $weeklength, $monthlength,
 	$add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1,
 	$add2,$every2,$whenmorethan2,$setto2,$lastvalue2,$innerloop2,
 	$add3,$every3,$whenmorethan3,$setto3,$lastvalue3,$innerloop3,
-	$numberingmethod, $status, $biblionumber, $bibliotitle, $callnumber, $notes, $hemisphere);
+    $numberingmethod, $status, $biblionumber, $bibliotitle, $callnumber, $notes, $hemisphere,$letter,$manualhistory,$histstartdate,$enddate,$missinglist,$recievedlist,$opacnote,$librariannote);
 
 $subscriptionid = $query->param('subscriptionid');
 
 
 if ($op eq 'del') {
-$biblionumber = $query->param('biblionumber');
-	&DelSubscription($subscriptionid,$biblionumber);
-	$query->redirect("/cgi-bin/koha/serials/serials-home.pl");
+    &DelSubscription($subscriptionid);
+    print "Content-Type: text/html\n\n<META HTTP-EQUIV=Refresh CONTENT=\"0; URL=serials-home.pl\"></html>";
 	exit;
 
 }
@@ -45,7 +59,7 @@
 				query => $query,
 				type => "intranet",
 				authnotrequired => 0,
-				flagsrequired => {catalogue => 1},
+                flagsrequired => {serials => 1},
 				debug => 1,
 				});
 
@@ -54,76 +68,40 @@
 
 my $weekarrayjs='';
 my $count = 0;
-my $today=get_today();
- my $dateobj=DATE_obj($today);
-  my $year=$dateobj->year;
-  my $month=$dateobj->month;
-  my $day=$dateobj->day_of_month;
-my $firstday = $dateobj->day_of_year;
-my $wkno = $dateobj->week_number;
+my ($year, $month, $day) = UnixDate("today", "%Y", "%m", "%d");
+my $firstday = Date_DayOfYear($month,$day,$year);
+my $wkno = Date_WeekOfYear($month,$day,$year,1); # week starting monday
 my $weekno = $wkno;
 for(my $i=$firstday;$i<($firstday+365);$i=$i+7){
         $count = $i;
         if($wkno > 52){$year++; $wkno=1;}
         if($count>365){$count=$i-365;}    
-     my $newdate=DateTime->from_day_of_year(year=>$year,day_of_year=>$count);
-        $weekarrayjs .= "'Wk $wkno: ".format_date($newdate->ymd)."',";
+            my ($y,$m,$d) = Date_NthDayOfYear($year,$count);
+            my $output = "$y-$m-$d";
+            $weekarrayjs .= "'Wk $wkno: ".format_date($output)."',";
         $wkno++;    
-}
+    }
 chop($weekarrayjs);
 
+# COMMENT hdl : IMHO, we should think about passing more and more data hash to template->param rather than duplicating code a new coding Guideline ?
+$subs->{startdate}=format_date($subs->{startdate});
+$subs->{firstacquidate}=format_date($subs->{firstacquidate});
+$subs->{histstartdate}=format_date($subs->{histstartdate});
+$subs->{enddate}=format_date($subs->{enddate});
+$subs->{abouttoexpire}=abouttoexpire($subs->{subscriptionid});
+
+$template->param($subs);
+
 $template->param(
         routing => $routing,
-	user => $subs->{auser},
-	librarian => $subs->{librarian},
-	aqbooksellerid => $subs->{aqbooksellerid},
-	aqbooksellername => $subs->{aqbooksellername},
-	cost => $subs->{cost},
-	aqbudgetid => $subs->{aqbudgetid},
-	bookfundid => $subs->{bookfundid},
-	startdate => format_date($subs->{startdate}),
-	publisheddate => format_date($subs->{publisheddate}),    
-	periodicity => $subs->{periodicity},
-	dow => $subs->{dow},
-        irregularity => $subs->{irregularity},
-	numberlength => $subs->{numberlength},
-	weeklength => $subs->{weeklength},
-	monthlength => $subs->{monthlength},
-        numberpattern => $subs->{numberpattern},
-	add1 => $subs->{add1},
-	every1 => $subs->{every1},
-	whenmorethan1 => $subs->{whenmorethan1},
-	innerloop1 => $subs->{innerloop1},
-	setto1 => $subs->{setto1},
-	lastvalue1 => $subs->{lastvalue1},
-	add2 => $subs->{add2},
-	every2 => $subs->{every2},
-	whenmorethan2 => $subs->{whenmorethan2},
-	setto2 => $subs->{setto2},
-	lastvalue2 => $subs->{lastvalue2},
-	innerloop2 => $subs->{innerloop2},
-	add3 => $subs->{add3},
-	every3 => $subs->{every3},
-	whenmorethan3 => $subs->{whenmorethan3},
-	setto3 => $subs->{setto3},
-	lastvalue3 => $subs->{lastvalue3},
-	innerloop3 => $subs->{innerloop3},
-        weekarrayjs => $weekarrayjs,
-	numberingmethod => $subs->{numberingmethod},
-	status => $subs->{status},
-	biblionumber => $subs->{biblionumber},
-	bibliotitle => $subs->{bibliotitle},
-        callnumber => $subs->{callnumber},
-	notes => $subs->{notes},
-	subscriptionid => $subs->{subscriptionid},
 	serialslist => \@serialslist,
 	totalissues => $totalissues,
         hemisphere => $hemisphere,
 	);
 $template->param(
-			"periodicity$subs->{periodicity}" => 1,
-			"arrival$subs->{dow}" => 1,
-                        "numberpattern$subs->{numberpattern}" => 1,
+            "periodicity".$subs->{periodicity} => 1,
+            "arrival".$subs->{dow} => 1,
+            "numberpattern".$subs->{numberpattern} => 1,
 			intranetstylesheet => C4::Context->preference("intranetstylesheet"),
 			intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), 
 			);

Index: subscription-renew.pl
===================================================================
RCS file: /sources/koha/koha/serials/subscription-renew.pl,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- subscription-renew.pl	15 Nov 2006 01:38:26 -0000	1.6
+++ subscription-renew.pl	9 Mar 2007 15:14:25 -0000	1.7
@@ -18,7 +18,7 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-# $Id: subscription-renew.pl,v 1.6 2006/11/15 01:38:26 tgarip1957 Exp $
+# $Id: subscription-renew.pl,v 1.7 2007/03/09 15:14:25 tipaul Exp $
 
 =head1 NAME
 
@@ -52,9 +52,10 @@
 use C4::Koha;
 use C4::Auth;
 use C4::Date;
+
 use C4::Context;
-use C4::Search;
 use C4::Auth;
+use C4::Output;
 use C4::Interface::CGI::Output;
 use C4::Serials;
 
@@ -69,7 +70,7 @@
                 query => $query,
                 type => "intranet",
                 authnotrequired => 0,
-                flagsrequired => {catalogue => 1},
+                flagsrequired => {serials => 1},
                 debug => 1,
                 });
 if ($op eq "renew") {
@@ -79,7 +80,7 @@
 
 my $subscription= GetSubscription($subscriptionid);
 
-$template->param(startdate => format_date(GetSubscriptionExpirationDate($subscriptionid)),
+$template->param(startdate => format_date(GetExpirationDate($subscriptionid)),
                 numberlength => $subscription->{numberlength},
                 weeklength => $subscription->{weeklength},
                 monthlength => $subscription->{monthlength},

Index: viewalerts.pl
===================================================================
RCS file: /sources/koha/koha/serials/viewalerts.pl,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- viewalerts.pl	27 Sep 2006 21:19:22 -0000	1.4
+++ viewalerts.pl	9 Mar 2007 15:14:25 -0000	1.5
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-# $Id: viewalerts.pl,v 1.4 2006/09/27 21:19:22 tgarip1957 Exp $
+# $Id: viewalerts.pl,v 1.5 2007/03/09 15:14:25 tipaul Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -22,10 +22,10 @@
 use strict;
 use C4::Auth;
 use C4::Context;
-
+use C4::Output;
 use CGI;
 use C4::Interface::CGI::Output;
-
+use C4::Interface::CGI::Template;
 use C4::Koha;
 use C4::Letters;
 use C4::Serials;
@@ -34,14 +34,14 @@
 
 my $input = new CGI;
 my $print = $input->param('print');
-
+my $template_name;
 
 my ($template, $loggedinuser, $cookie)
     = get_template_and_user({template_name => 'serials/viewalerts.tmpl',
                  query => $input,
                  type => "intranet",
                  authnotrequired => 0,
-                 flagsrequired => {catalogue => 1},
+                 flagsrequired => {serials => 1},
                  debug => 1,
                  });
 





More information about the Koha-cvs mailing list