[Koha-cvs] koha/intranet/cgi-bin/serials acqui-search-resu... [rel_TG]

Tumer Garip tgarip at neu.edu.tr
Sat Mar 10 02:27:28 CET 2007


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_TG
Changes by:	Tumer Garip <tgarip1957>	07/03/10 01:27:28

Added files:
	intranet/cgi-bin/serials: acqui-search-result.pl acqui-search.pl 
	                          claims.pl distributedto.pl 
	                          lateissues-excel.pl lateissues.pl 
	                          member-search.pl printlist.pl 
	                          reorder_members.pl routing-preview.pl 
	                          routing.pl serial-issues.pl 
	                          serials-home.pl serials-receive.pl 
	                          subscription-add-new.pl 
	                          subscription-add.pl 
	                          subscription-bib-search.pl 
	                          subscription-detail-new.pl 
	                          subscription-detail.pl 
	                          subscription-renew.pl viewalerts.pl 

Log message:
	fresh files for rel_TG

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/acqui-search-result.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/acqui-search.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/claims.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/distributedto.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/lateissues-excel.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/lateissues.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/member-search.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/printlist.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/reorder_members.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/routing-preview.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/routing.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/serial-issues.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/serials-home.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/serials-receive.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/subscription-add-new.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/subscription-add.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/subscription-bib-search.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/subscription-detail-new.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/subscription-detail.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/subscription-renew.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1
http://cvs.savannah.gnu.org/viewcvs/koha/intranet/cgi-bin/serials/viewalerts.pl?cvsroot=koha&only_with_tag=rel_TG&rev=1.1.2.1

Patches:
Index: acqui-search-result.pl
===================================================================
RCS file: acqui-search-result.pl
diff -N acqui-search-result.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ acqui-search-result.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,102 @@
+#!/usr/bin/perl
+
+#script to show suppliers and orders
+#written by chris at katipo.co.nz 23/2/2000
+
+# 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: acqui-search-result.pl,v 1.1.2.1 2007/03/10 01:27:27 tgarip1957 Exp $
+
+=head1 NAME
+
+acqui-search-result.pl
+
+=head1 DESCRIPTION
+ TODO
+ 
+=head1 PARAMETERS
+
+=over 4
+
+=item supplier
+
+=back
+
+=cut
+
+
+use strict;
+use C4::Auth;
+use C4::Biblio;
+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)
+    = get_template_and_user({template_name => "serials/acqui-search-result.tmpl",
+                 query => $query,
+                 type => "intranet",
+                 authnotrequired => 0,
+                 flagsrequired => {acquisition => 1},
+                 debug => 1,
+                 });
+
+my $supplier=$query->param('supplier');
+my @suppliers = GetBookSeller($supplier);
+my $count = scalar @suppliers;
+
+#build result page
+my $toggle=0;
+my @loop_suppliers;
+for (my $i=0; $i<$count; $i++) {
+    my $orders = GetPendingOrders($suppliers[$i]->{'id'});
+    my $ordcount = scalar @$orders;
+    
+    my %line;
+    if ($toggle==0){
+        $line{even}=1;
+        $toggle=1;
+    } else {
+        $line{even}=0;
+        $toggle=0;
+    }
+    $line{aqbooksellerid} =$suppliers[$i]->{'id'};
+    $line{name} = $suppliers[$i]->{'name'};
+    $line{active} = $suppliers[$i]->{'active'};
+    my @loop_basket;
+    for (my $i2=0;$i2<$ordcount;$i2++){
+        my %inner_line;
+        $inner_line{basketno} =$orders->[$i2]->{'basketno'};
+        $inner_line{total} =$orders->[$i2]->{'count(*)'};
+        $inner_line{authorisedby} = $orders->[$i2]->{'authorisedby'};
+        $inner_line{creationdate} = format_date($orders->[$i2]->{'creationdate'});
+        $inner_line{closedate} = format_date($orders->[$i2]->{'closedate'});
+        push @loop_basket, \%inner_line;
+    }
+    $line{loop_basket} = \@loop_basket;
+    push @loop_suppliers, \%line;
+}
+$template->param(loop_suppliers => \@loop_suppliers,
+                        supplier => $supplier,
+                        count => $count);
+
+output_html_with_http_headers $query, $cookie, $template->output;

Index: acqui-search.pl
===================================================================
RCS file: acqui-search.pl
diff -N acqui-search.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ acqui-search.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,97 @@
+#!/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: acqui-search.pl,v 1.1.2.1 2007/03/10 01:27:27 tgarip1957 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",
+			     query => $query,
+			     type => "intranet",
+			     authnotrequired => 0,
+			     flagsrequired => {acquisition => 1},
+			     debug => 1,
+			     });
+
+
+
+
+# budget
+my $dbh = C4::Context->dbh;
+my $sthtemp = $dbh->prepare("Select flags, branchcode from borrowers where borrowernumber = ?");
+$sthtemp->execute($loggedinuser);
+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 @loop_budget = ();
+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);
+	push @loop_budget, \%line;
+	$total+=$results[$i]->{'budgetamount'};
+	$totspent+=$spent;
+	$totcomtd+=$comtd;
+	$totavail+=$avail;
+}
+#currencies
+my @rates=GetCurrencies();
+my $count = scalar @rates;
+
+my @loop_currency = ();
+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,
+						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"),
+						);
+
+output_html_with_http_headers $query, $cookie, $template->output;

Index: claims.pl
===================================================================
RCS file: claims.pl
diff -N claims.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ claims.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,83 @@
+#!/usr/bin/perl
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Serials;
+use C4::Acquisition;
+
+use C4::Interface::CGI::Output;
+use C4::Context;
+
+
+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 %supplierlist = GetSuppliersWithLateIssues;
+my @select_supplier;
+
+foreach my $supplierid (keys %supplierlist){
+        my ($count, @dummy) = GetMissingIssues($supplierid);
+        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 $CGIsupplier=CGI::scrolling_list( -name     => 'supplierid',
+			-values   => \@select_supplier,
+			-default  => $supplierid,
+			-labels   => \%supplierlist,
+			-size     => 1,
+			-multiple => 0 );
+
+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);
+} 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'});
+   }
+}
+
+
+my $preview=0;
+if($op eq 'preview'){
+    $preview = 1;
+}
+
+my ($template, $loggedinuser, $cookie)
+= get_template_and_user({template_name => "serials/claims.tmpl",
+				query => $query,
+				type => "intranet",
+				authnotrequired => 0,
+				flagsrequired => {catalogue => 1},
+				debug => 1,
+				});
+
+$template->param(
+	CGIsupplier => $CGIsupplier,
+    	CGIletter => $CGIletter,
+        preview => $preview,
+        missingissues => \@missingissues,
+        supplierid => $supplierid,
+        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;

Index: distributedto.pl
===================================================================
RCS file: distributedto.pl
diff -N distributedto.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ distributedto.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,105 @@
+#!/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: distributedto.pl,v 1.1.2.1 2007/03/10 01:27:27 tgarip1957 Exp $
+
+=head1 NAME
+
+distributedto
+
+=head1 DESCRIPTION
+
+this script is launched as a popup. It allows to choose for who the subscription can be distributed.
+
+=head1 PARAMETERS
+
+=over 4
+
+=item searchfield
+to filter on the members.
+
+=item distributedto
+to know if there are already some members to in the distributed list
+
+=item subscriptionid
+to know what subscription this scrpit have to distribute.
+
+=item SaveList
+
+=back
+
+=cut
+
+
+use strict;
+use CGI;
+use C4::Date;
+use C4::Auth;
+use C4::Context;
+
+use C4::Interface::CGI::Output;
+use C4::Search;
+
+use C4::Serials;
+use C4::Members;
+
+my $input = new CGI;
+my $searchfield=$input->param('searchfield');
+defined $searchfield or $searchfield='';
+my $distributedto=$input->param('distributedto');
+my $subscriptionid = $input->param('subscriptionid');
+$searchfield=~ s/\,//g;
+my $SaveList=$input->param('SaveList');
+my $dbh = C4::Context->dbh;
+
+$distributedto = GetDistributedTo($subscriptionid) unless $distributedto;
+
+SetDistributedto($distributedto,$subscriptionid) if ($SaveList) ;
+
+my ($template, $borrowernumber, $cookie)
+    = get_template_and_user({template_name => "serials/distributedto.tmpl",
+                 query => $input,
+                 type => "intranet",
+                 authnotrequired => 0,
+                 flagsrequired => {cataloguing => 1},
+                 debug => 1,
+                 });
+
+my ($count,$results)=GetBorrowersFromSurname($searchfield) if $searchfield;
+my $toggle="0";
+my @loop_data =();
+for (my $i=0; $i < $count; $i++){
+    if ($i % 2){
+            $toggle=1;
+    } else {
+            $toggle=0;
+    }
+    my %row_data;
+    $row_data{toggle} = $toggle;
+    $row_data{firstname} = $results->[$i]{'firstname'};
+    $row_data{surname} = $results->[$i]{'surname'};
+    push(@loop_data, \%row_data);
+}
+$template->param(borlist => \@loop_data,
+                searchfield => $searchfield,
+                distributedto => $distributedto,
+                SaveList => $SaveList,
+                subscriptionid => $subscriptionid,
+                );
+output_html_with_http_headers $input, $cookie, $template->output;

Index: lateissues-excel.pl
===================================================================
RCS file: lateissues-excel.pl
diff -N lateissues-excel.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ lateissues-excel.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,119 @@
+#!/usr/bin/perl
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Serials;
+use C4::Acquisition;
+use C4::Output;
+use C4::Interface::CGI::Output;
+use C4::Context;
+
+use Text::CSV_XS;
+
+
+
+
+my $csv = Text::CSV_XS->new(
+        {
+            'quote_char'  => '"',
+            'escape_char' => '"',
+            'sep_char'    => ',',
+            'binary'      => 1
+        }
+    );
+
+
+my $query = new CGI;
+my $supplierid = $query->param('supplierid');
+my @serialid = $query->param('serialid');
+my $op = $query->param('op');
+my $serialidcount = @serialid;
+
+my %supplierlist = GetSuppliersWithLateIssues;
+my @select_supplier;
+
+my @loop1;
+my ($count, @lateissues);
+if($op ne 'claims'){
+    ($count, @lateissues) = GetLateIssues($supplierid);
+    for (my $i=0;$i<@lateissues;$i++){
+        my @rows1 = ($lateissues[$i]->{'name'},          # lets build up a row
+            	     $lateissues[$i]->{'title'}, 
+                     $lateissues[$i]->{'serialseq'},
+                     $lateissues[$i]->{'planneddate'},
+                     );
+        push (@loop1, \@rows1);
+    }
+}
+my $totalcount2 = 0;
+my @loop2;
+my ($count2, @missingissues);
+for (my $k=0;$k<@serialid;$k++){
+    ($count2, @missingissues) = GetMissingIssues($supplierid, $serialid[$k]);
+
+    for (my $j=0;$j<@missingissues;$j++){
+	my @rows2 = ($missingissues[$j]->{'name'},          # lets build up a row
+	             $missingissues[$j]->{'title'}, 
+                     $missingissues[$j]->{'serialseq'},
+                     $missingissues[$j]->{'planneddate'},
+                     );
+        push (@loop2, \@rows2);
+    }
+    $totalcount2 = $totalcount2 + $count2;
+    # update claim date to let one know they have looked at this missing item
+    updateClaim($serialid[$k]);
+}
+
+my $heading ='';
+my $filename ='';
+if($supplierid){
+    if($missingissues[0]->{'name'}){ # if exists display supplier name in heading for neatness
+	# not necessarily needed as the name will appear in supplier column also
+        $heading = "FOR $missingissues[0]->{'name'}";
+	$filename = "_$missingissues[0]->{'name'}"; 
+    }
+}
+
+print $query->header(
+        -type       => 'application/vnd.ms-excel',
+        -attachment => "claims".$filename.".csv",
+    );
+
+if($op ne 'claims'){
+    print "LATE ISSUES ".$heading."\n\n";
+    print "SUPPLIER,TITLE,ISSUE NUMBER,LATE SINCE\n";
+
+    for my $row ( @loop1 ) {
+    
+        $csv->combine(@$row);
+        my $string = $csv->string;
+        print $string, "\n";
+    }
+
+    print ",,,,,,,\n\n";
+}
+if($serialidcount == 1){
+    print "MISSING ISSUE ".$heading."\n\n";
+} else {
+    print "MISSING ISSUES ".$heading."\n\n";
+}
+print "SUPPLIER,TITLE,ISSUE NUMBER,LATE SINCE\n";
+
+for my $row ( @loop2 ) {
+    
+        $csv->combine(@$row);
+        my $string = $csv->string;
+        print $string, "\n";
+    }
+
+print ",,,,,,,\n";
+print ",,,,,,,\n";
+if($op ne 'claims'){
+    print ",,Total Number Late, $count\n";
+}
+if($serialidcount == 1){
+
+} else {
+    print ",,Total Number Missing, $totalcount2\n";
+}

Index: lateissues.pl
===================================================================
RCS file: lateissues.pl
diff -N lateissues.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ lateissues.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,90 @@
+#!/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: lateissues.pl,v 1.1.2.1 2007/03/10 01:27:27 tgarip1957 Exp $
+
+=head1 NAME
+
+lateissues
+
+=head1 DESCRIPTION
+
+this script display late issue by types.
+
+=head1 PARAMETERS
+
+=over 4
+
+=item supplierid
+the id of the supplier this script has to search late issues.
+
+=back
+
+=cut
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Serials;
+use C4::Acquisition;
+use C4::Interface::CGI::Output;
+use C4::Context;
+use C4::Bookseller;
+
+my $query = new CGI;
+# my $title = $query->param('title');
+# my $ISSN = $query->param('ISSN');
+# my @subscriptions = GetSubscriptions($title,$ISSN);
+
+my $supplierid = $query->param('supplierid');
+my %supplierlist = GetSuppliersWithLateIssues;
+my @select_supplier;
+push @select_supplier,"";
+foreach my $supplier (keys %supplierlist){
+    push @select_supplier, $supplier
+}
+my $CGIsupplier=CGI::scrolling_list(
+            -name     => 'supplierid',
+            -values   => \@select_supplier,
+            -default  => $supplierid,
+            -labels   => \%supplierlist,
+            -size     => 1,
+            -multiple => 0 );
+
+my ($count, at lateissues);
+($count, at lateissues) = GetLateIssues($supplierid) ;
+my @supplierinfo=GetBookSeller($supplierid) if $supplierid;
+
+my ($template, $loggedinuser, $cookie)
+= get_template_and_user({template_name => "serials/lateissues.tmpl",
+                query => $query,
+                type => "intranet",
+                authnotrequired => 0,
+                flagsrequired => {catalogue => 1},
+                debug => 1,
+                });
+
+$template->param(
+    CGIsupplier => $CGIsupplier,
+    lateissues => \@lateissues,
+    phone => $supplierinfo[0]->{phone},
+    booksellerfax => $supplierinfo[0]->{booksellerfax},
+    bookselleremail => $supplierinfo[0]->{bookselleremail},
+    );
+output_html_with_http_headers $query, $cookie, $template->output;

Index: member-search.pl
===================================================================
RCS file: member-search.pl
diff -N member-search.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ member-search.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,46 @@
+#!/usr/bin/perl
+
+# Member Search.pl script used to search for members to add to a routing list
+use strict;
+use CGI;
+use C4::Koha;
+use C4::Auth;
+use C4::Date;
+use C4::Acquisition;
+use C4::Interface::CGI::Output;
+use C4::Context;
+use C4::Search;
+use C4::Serials;
+
+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",
+				query => $query,
+				type => "intranet",
+				authnotrequired => 0,
+				flagsrequired => {catalogue => 1},
+				debug => 1,
+				});
+
+
+if($searchstring){
+    my ($count, $members) = &BornameSearch($env, $searchstring, "surname", "advanced");
+    
+    $template->param(
+	subscriptionid => $subscriptionid,
+ 	    memberloop => $members,
+	        member => $searchstring,
+    );
+} else {
+    $template->param(
+	subscriptionid => $subscriptionid,
+    );
+}
+        output_html_with_http_headers $query, $cookie, $template->output;

Index: printlist.pl
===================================================================
RCS file: printlist.pl
diff -N printlist.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ printlist.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,83 @@
+#!/usr/bin/perl
+# NOTE: Use standard 8-space tabs for this file (indents are 4 spaces)
+
+# 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: printlist.pl,v 1.1.2.1 2007/03/10 01:27:27 tgarip1957 Exp $
+
+=head1 NAME
+
+printlist.pl
+
+=head1 DESCRIPTION
+
+this script print the list of members who have reserved the subscription given on input arg.
+
+=head1 PARAMETERS
+
+=over 4
+
+=item serialseq
+
+=item subscriptionid
+
+=back
+
+=cut
+
+
+use strict;
+require Exporter;
+use C4::Context;
+use CGI;
+use C4::Auth;
+use C4::Serials;
+use C4::Interface::CGI::Output;
+use C4::Koha;
+
+my $query=new CGI;
+
+my $serialseq=$query->param('serialseq');
+my $subscriptionid=$query->param('subscriptionid');
+my $subscription = GetSubscription($subscriptionid);
+$subscription->{'distributedto'} =~ s/\n/<br\/>/g;
+
+my ($template, $loggedinuser, $cookie)
+= get_template_and_user({template_name => "serials/printlist.tmpl",
+                query => $query,
+                type => "intranet",
+                authnotrequired => 0,
+                flagsrequired => {catalogue => 1},
+                debug => 1,
+                });
+$template->param(serialseq => $serialseq,
+                title => $subscription->{bibliotitle},
+                branchname => getbranchdetail(C4::Context->userenv->{'branch'})->{branchname},
+                branchaddress1 => getbranchdetail(C4::Context->userenv->{'branch'})->{address1},
+                branchaddress2 => getbranchdetail(C4::Context->userenv->{'branch'})->{address2},
+                branchaddress3 => getbranchdetail(C4::Context->userenv->{'branch'})->{address3},
+                branchphone => getbranchdetail(C4::Context->userenv->{'branch'})->{branchphone},
+                branchemail => getbranchdetail(C4::Context->userenv->{'branch'})->{branchemail},
+                distributedto => $subscription->{'distributedto'},
+                );
+output_html_with_http_headers $query, $cookie, $template->output;
+
+
+# Local Variables:
+# tab-width: 8
+# End:

Index: reorder_members.pl
===================================================================
RCS file: reorder_members.pl
diff -N reorder_members.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ reorder_members.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,24 @@
+#!/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
+use strict;
+use CGI;
+
+use C4::Acquisition;
+use C4::Interface::CGI::Output;
+
+use C4::Serials;
+
+
+my $query = new CGI;
+my $subscriptionid = $query->param('subscriptionid');
+my $routingid = $query->param('routingid');
+my $rank = $query->param('rank');
+
+reorder_members($subscriptionid,$routingid,$rank);
+
+print $query->redirect("/cgi-bin/koha/serials/routing.pl?subscriptionid=$subscriptionid");
+

Index: routing-preview.pl
===================================================================
RCS file: routing-preview.pl
diff -N routing-preview.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ routing-preview.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,121 @@
+#!/usr/bin/perl
+
+# Routing Preview.pl script used to view a routing list after creation
+# lets one print out routing slip and create (in this instance) the heirarchy
+# of reserves for the serial
+use strict;
+use CGI;
+use C4::Koha;
+use C4::Auth;
+use C4::Date;
+use C4::Output;
+use C4::Acquisition;
+use C4::Reserves2;
+use C4::Circulation::Circ2;
+use C4::Interface::CGI::Output;
+use C4::Context;
+use C4::Search;
+use C4::Serials;
+
+my $query = new CGI;
+my $subscriptionid = $query->param('subscriptionid');
+my $issue = $query->param('issue');
+my $routingid;
+my $ok = $query->param('ok');
+my $edit = $query->param('edit');
+my $delete = $query->param('delete');
+my $dbh = C4::Context->dbh;
+
+if($delete){
+    delroutingmember($routingid,$subscriptionid);
+    my $sth = $dbh->prepare("UPDATE serial SET routingnotes = NULL WHERE subscriptionid = ?");
+    $sth->execute($subscriptionid);    
+    print $query->redirect("routing.pl?subscriptionid=$subscriptionid&op=new");    
+}
+
+if($edit){
+    print $query->redirect("routing.pl?subscriptionid=$subscriptionid");
+}
+    
+my ($routing, @routinglist) = getroutinglist($subscriptionid);
+my $subs = GetSubscription($subscriptionid);
+my ($count, at serials) = GetSerials($subscriptionid);
+my ($template, $loggedinuser, $cookie);
+
+if($ok){
+    my $env;
+    # get biblio information....
+    my $biblio = $subs->{'biblionumber'};
+    
+    # get existing reserves .....
+    my ($count,$reserves) = FindReserves($biblio);
+    my $totalcount = $count;
+    foreach my $res (@$reserves) {
+        if ($res->{'found'} eq 'W') {
+	    $count--;
+        }
+    }
+    my ($count2, at bibitems) = bibitems($biblio);
+    my @itemresults = ItemInfo($env, $subs->{'biblionumber'}, 'intra');    
+    my $branch = $itemresults[0]->{'holdingbranch'};
+    my $const = 'o';
+    my $notes;
+    my $title = $subs->{'bibliotitle'};
+    for(my $i=0;$i<$routing;$i++){
+	my $sth = $dbh->prepare("SELECT * FROM reserves WHERE biblionumber = ? AND borrowernumber = ? 
+                                 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);
+        } else {
+            CreateReserve(\$env,$branch,$routinglist[$i]->{'borrowernumber'},$biblio,$const,\@bibitems,$routinglist[$i]->{'ranking'},$notes,$title);
+	}
+    }
+    
+    
+    ($template, $loggedinuser, $cookie)
+= get_template_and_user({template_name => "serials/routing-preview-slip.tmpl",
+				query => $query,
+				type => "intranet",
+				authnotrequired => 0,
+				flagsrequired => {catalogue => 1},
+				debug => 1,
+				});    
+} else {
+    ($template, $loggedinuser, $cookie)
+= get_template_and_user({template_name => "serials/routing-preview.tmpl",
+				query => $query,
+				type => "intranet",
+				authnotrequired => 0,
+				flagsrequired => {catalogue => 1},
+				debug => 1,
+				});
+}    
+
+# my $firstdate = "$serials[0]->{'serialseq'} ($serials[0]->{'planneddate'})";
+my @results;
+my $data;
+for(my $i=0;$i<$routing;$i++){
+    $data=borrdata('',$routinglist[$i]->{'borrowernumber'});
+    $data->{'location'}=$data->{'streetaddress'};
+    $data->{'name'}="$data->{'firstname'} $data->{'surname'}";
+    $data->{'routingid'}=$routinglist[$i]->{'routingid'};
+    $data->{'subscriptionid'}=$subscriptionid;
+    push(@results, $data);
+}
+
+my $routingnotes = $serials[0]->{'routingnotes'};
+$routingnotes =~ s/\n/\<br \/\>/g;
+  
+$template->param(
+    title => $subs->{'bibliotitle'},
+    issue => $issue,
+    subscriptionid => $subscriptionid,
+    memberloop => \@results,    
+    routingnotes => $routingnotes,
+    );
+
+        output_html_with_http_headers $query, $cookie, $template->output;

Index: routing.pl
===================================================================
RCS file: routing.pl
diff -N routing.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ routing.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,122 @@
+#!/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
+use strict;
+use CGI;
+use C4::Koha;
+use C4::Auth;
+use C4::Date;
+use C4::Acquisition;
+use C4::Interface::CGI::Output;
+use C4::Context;
+use C4::Search;
+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 $notes = $query->param('notes');
+my $op = $query->param('op');
+my $date_selected = $query->param('date_selected');
+my $dbh = C4::Context->dbh;
+
+if($op eq 'delete'){
+    delroutingmember($routingid,$subscriptionid);
+}
+
+if($op eq 'add'){
+    addroutingmember($bornum,$subscriptionid);
+}
+if($op eq 'save'){
+    my $sth = $dbh->prepare("UPDATE serial SET routingnotes = ? WHERE subscriptionid = ?");
+    $sth->execute($notes,$subscriptionid);
+    print $query->redirect("routing-preview.pl?subscriptionid=$subscriptionid&issue=$date_selected");
+}
+    
+my ($routing, @routinglist) = getroutinglist($subscriptionid);
+my $subs = GetSubscription($subscriptionid);
+my ($count, at serials) = old_getserials($subscriptionid);
+my ($serialdates) = GetLatestSerials($subscriptionid,$count);
+
+my @dates;
+my $i=0;
+foreach my $dateseq (@$serialdates) {
+        $dates[$i]->{'planneddate'} = $dateseq->{'planneddate'};
+        $dates[$i]->{'serialseq'} = $dateseq->{'serialseq'};
+        $dates[$i]->{'serialid'} = $dateseq->{'serialid'};
+        if($date_selected eq $dateseq->{'serialid'}){
+            $dates[$i]->{'selected'} = ' selected';
+        } else {
+            $dates[$i]->{'selected'} = '';
+        }
+        $i++;
+}
+
+my ($template, $loggedinuser, $cookie)
+= get_template_and_user({template_name => "serials/routing.tmpl",
+				query => $query,
+				type => "intranet",
+				authnotrequired => 0,
+				flagsrequired => {catalogue => 1},
+				debug => 1,
+				});
+# my $date;
+# if($serialseq){
+#    for(my $i = 0;$i<@serials; $i++){
+#	if($serials[$i]->{'serialseq'} eq $serialseq){
+#	    $date = $serials[$i]->{'planneddate'}
+#	}
+#    }
+# } else {
+#    $serialseq = $serials[0]->{'serialseq'};
+#    $date = $serials[0]->{'planneddate'};
+# }
+
+# my $issue = "$serialseq ($date)";
+  
+my @results;
+my $data;
+for(my $i=0;$i<$routing;$i++){
+    $data=borrdata('',$routinglist[$i]->{'borrowernumber'});
+    $data->{'location'}=$data->{'streetaddress'};
+    $data->{'name'}="$data->{'firstname'} $data->{'surname'}";
+    $data->{'routingid'}=$routinglist[$i]->{'routingid'};
+    $data->{'subscriptionid'}=$subscriptionid;
+    my $rankingbox = '<select name="itemrank" onchange="reorder_item('.$subscriptionid.','.$routinglist[$i]->{'routingid'}.',this.options[this.selectedIndex].value)">';
+    for(my $j=1; $j <= $routing; $j++) {
+	$rankingbox .= "<option ";
+	if($routinglist[$i]->{'ranking'} == $j){
+	    $rankingbox .= " selected='SELECTED'";
+	}
+	$rankingbox .= " value='$j'>$j</option>";
+    }
+    $rankingbox .= "</select>";
+    $data->{'routingbox'} = $rankingbox;
+    
+    push(@results, $data);
+}
+# warn Dumper(@results);
+# for adding routing list
+my $new;
+if ($op eq 'new') {
+    $new = 1;
+} else {
+# for modify routing list default
+    $new => 0;
+}
+
+$template->param(
+    title => $subs->{'bibliotitle'},
+    subscriptionid => $subscriptionid,
+    memberloop => \@results,    
+    op => $new,
+    dates => \@dates,
+    routingnotes => $serials[0]->{'routingnotes'},
+    );
+
+        output_html_with_http_headers $query, $cookie, $template->output;

Index: serial-issues.pl
===================================================================
RCS file: serial-issues.pl
diff -N serial-issues.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ serial-issues.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,117 @@
+#!/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: serial-issues.pl,v 1.1.2.1 2007/03/10 01:27:27 tgarip1957 Exp $
+
+=head1 NAME
+
+serial-issue.pl
+
+=head1 DESCRIPTION
+
+this script give more information about a susbcription given on input arg.
+
+=head1 PARAMETERS
+
+=over 4
+
+=item selectview
+can be equal to "full" or not.
+
+=item biblionumber
+the biblionumber this script has to give more infos.
+
+=back
+
+
+=cut
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Koha;
+use C4::Date;
+use C4::Serials;
+use C4::Output;
+use C4::Interface::CGI::Output;
+use C4::Context;
+
+
+my $query = new CGI;
+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');
+if ($selectview eq "full"){
+    my $subscriptions = GetFullSubscriptionsFromBiblionumber($biblionumber);
+
+    my $title = $subscriptions->[0]{bibliotitle};
+    my $yearmin=$subscriptions->[0]{year};
+    my $yearmax=$subscriptions->[scalar(@$subscriptions)-1]{year};
+
+    ($template, $loggedinuser, $cookie)
+     = get_template_and_user({template_name => "serials/serial-issues-full.tmpl",
+     query => $query,
+     type => "intranet",
+     authnotrequired => 1,
+     debug => 1,
+     });
+ 
+ # replace CR by <br> in librarian note
+ # $subscription->{opacnote} =~ s/\n/\<br\/\>/g;
+ 
+    $template->param(
+        biblionumber => $query->param('biblionumber'),
+        years => $subscriptions,
+        yearmin => $yearmin,
+        yearmax =>$yearmax,
+        bibliotitle => $title,
+        suggestion => C4::Context->preference("suggestion"),
+        virtualshelves => C4::Context->preference("virtualshelves"),
+    );
+
+} else {
+    my $subscriptions = GetSubscriptionsFromBiblionumber($biblionumber);
+    ($template, $loggedinuser, $cookie)
+    = get_template_and_user({template_name => "serials/serial-issues.tmpl",
+        query => $query,
+        type => "intranet",
+        authnotrequired => 1,
+        debug => 1,
+     });
+
+ # replace CR by <br> in librarian note
+ # $subscription->{opacnote} =~ s/\n/\<br\/\>/g;
+
+    $template->param(
+        biblionumber => "".$query->param('biblionumber'),
+        subscription_LOOP => $subscriptions,
+        suggestion => "".C4::Context->preference("suggestion"),
+        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: serials-home.pl
diff -N serials-home.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ serials-home.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,90 @@
+#!/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-home.pl,v 1.1.2.1 2007/03/10 01:27:27 tgarip1957 Exp $
+
+=head1 NAME
+
+serials-home.pl
+
+=head1 DESCRIPTION
+
+this script is the main page for serials/
+
+=head1 PARAMETERS
+
+=over 4
+
+=item title
+
+=item ISSN
+
+=item biblionumber
+
+=back
+
+=cut
+
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Serials;
+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 $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",
+				query => $query,
+				type => "intranet",
+				authnotrequired => 0,
+				flagsrequired => {catalogue => 1},
+				debug => 1,
+				});
+
+# 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'});
+	$subscriptions[$i]->{'routingedit'} = $checkrouting;
+	# warn "check $checkrouting";
+    }
+}
+
+$template->param(
+	subscriptions => \@subscriptions,
+	title => $title,
+	ISSN => $ISSN,
+        done_searched => $searched,
+        routing => $routing,
+        alt_links => $alt_links,
+	);
+output_html_with_http_headers $query, $cookie, $template->output;

Index: serials-receive.pl
===================================================================
RCS file: serials-receive.pl
diff -N serials-receive.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ serials-receive.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,223 @@
+#!/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-receive.pl,v 1.1.2.1 2007/03/10 01:27:27 tgarip1957 Exp $
+
+=head1 NAME
+
+serials-receive.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 receivedlist
+
+=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::Interface::CGI::Output;
+use C4::Context;
+use C4::Serials;
+
+my $query = new CGI;
+my $op = $query->param('op');
+my $dbh = C4::Context->dbh;
+my $subscriptionid = $query->param('subscriptionid');
+my $histstartdate = format_date_in_iso($query->param('histstartdate'));
+my $enddate = format_date_in_iso($query->param('enddate'));
+my $receivedlist = $query->param('receivedlist');
+my $missinglist = $query->param('missinglist');
+my $opacnote = $query->param('opacnote');
+my $librariannote = $query->param('librariannote');
+my @serialids = $query->param('serialid');
+my @serialseqs = $query->param('serialseq');
+my @planneddates = $query->param('planneddate');
+my @publisheddates = $query->param('publisheddate');
+my @status = $query->param('status');
+my @notes = $query->param('notes');
+my @barcodes = $query->param('barcode');
+my @itemcallnumbers = $query->param('itemcallnumber');
+my @locations = $query->param('location');
+my @itemstatus = $query->param('itemstatus');
+my @holdingbranches = $query->param('holdingbranch');
+my $hassubscriptionexpired = HasSubscriptionExpired($subscriptionid);
+my $abouttoexpire = abouttoexpire($subscriptionid);
+my @itemnumbers=$query->param('itemnumber');
+my $subscription=GetSubscription($subscriptionid);
+
+my $auser = $subscription->{'librarian'}; # bob
+my $routing = check_routing($subscriptionid); # to see if routing list exists
+my $manualdate ='';
+my $manualissue ='';
+my $manualstatus =0;
+my $manualid ='';
+if ($op eq 'found'){
+    $manualdate = $query->param('planneddate');
+    $manualissue = $query->param('missingissue');
+    $manualstatus = 1;
+    my $sth = $dbh->prepare("select serialid from serial where subscriptionid = ? AND serialseq = ? AND planneddate = ?");
+    $sth->execute($subscriptionid,$manualissue,format_date_in_iso($manualdate));
+    $manualid = $sth->fetchrow;
+}
+if ($op eq 'modsubscriptionhistory') {
+	ModSubscriptionHistory($subscriptionid,$histstartdate,$enddate,$receivedlist,$missinglist,$opacnote,$librariannote);
+}
+
+# change status except, if subscription has expired, for the "waited" issue.
+if ($op eq 'serialchangestatus') {
+	my $sth = $dbh->prepare("select status from serial where serialid=?");
+	for (my $i=0;$i<=$#serialids;$i++) {
+		$sth->execute($serialids[$i]);
+		my $today=get_today();
+		my ($oldstatus) = $sth->fetchrow;
+		if ($serialids[$i]) {
+	 my $planneddate = ($planneddates[$i]?format_date_in_iso($planneddates[$i]):$today) if ($status[$i]==2);
+			ModSerialStatus($serialids[$i],$serialseqs[$i],format_date_in_iso($publisheddates[$i]),format_date_in_iso($planneddates[$i]),$status[$i],$notes[$i],$itemnumbers[$i]) unless ($hassubscriptionexpired && $oldstatus ==1 );
+			if (($status[$i]==2) && $itemnumbers[$i]){
+				my %info;
+				my $status2;
+			        my $sth2 = $dbh->prepare("UPDATE subscriptionhistory SET lastbranch = ? WHERE subscriptionid = ?");
+			        $sth2->execute($holdingbranches[$i],$subscriptionid);
+			        $sth2->finish;			    
+			        # remove from missing list if item being checked in is on it
+				    removeMissingIssue($serialseqs[$i],$subscriptionid);
+			}
+		} else {
+			# add a special issue
+			if ($serialseqs[$i]) {
+				NewIssue($serialseqs[$i],$subscriptionid,$subscription->{biblionumber},$status[$i],format_date_in_iso($publisheddates[$i]), format_date_in_iso($planneddates[$i]),$itemnumbers[$i]);
+			}
+			if (($status[$i]==2) &&  $itemnumbers[$i] && !$hassubscriptionexpired){
+				my %info;
+				my $status2;
+			        my $sth2 = $dbh->prepare("UPDATE subscriptionhistory SET lastbranch = ? WHERE subscriptionid = ?");
+			        $sth2->execute($holdingbranches[$i],$subscriptionid);
+			        $sth2->finish;
+			        # remove from missing list if item being checked in is on it
+			       
+				    removeMissingIssue($serialseqs[$i],$subscriptionid);
+			       
+			}
+
+		}
+	}
+
+}
+my ($template, $loggedinuser, $cookie)
+= get_template_and_user({template_name => "serials/serials-receive.tmpl",
+				query => $query,
+				type => "intranet",
+				authnotrequired => 0,
+				flagsrequired => {catalogue => 1},
+				debug => 1,
+				});
+
+my $subs = &GetSubscription($subscriptionid);
+my ($totalissues, at serialslist) = GetSerials($subscriptionid);
+my $count = @serialslist;
+for(my $i=0;$i<$count;$i++){
+    $serialslist[$i]->{'callnumber'} = $subscription->{'callnumber'};
+    my $temp = rand(10000000);
+    $serialslist[$i]->{'barcode'} = "TEMP" . sprintf("%.0f",$temp);
+}
+# use Data::Dumper;
+# warn Dumper(@serialslist);
+
+my $sth= C4::Serials::GetSubscriptionHistoryFromSubscriptionId();
+
+$sth->execute($subscriptionid);
+my $solhistory = $sth->fetchrow_hashref;
+
+my $subs = &GetSubscription($subscriptionid);
+my ($totalissues, at serialslist) = GetSerials($subscriptionid);
+
+if (C4::Context->preference("serialsadditems")){
+    $template->param(scriptaddserials=>"/cgi-bin/koha/cataloguing/additem.pl?biblionumber=  $serialslist[0]->{'biblionumber'}&fromserials=1&serialid=",
+				serialsadditems=>1	) ;
+}
+
+my $sth= C4::Serials::GetSubscriptionHistoryFromSubscriptionId();
+$sth->execute($subscriptionid);
+my $solhistory = $sth->fetchrow_hashref;
+
+    
+$template->param(
+                        user => $auser,
+			serialslist => \@serialslist,
+                        count => $count,
+			biblionumber => $subscription->{biblionumber},
+			histstartdate => format_date($solhistory->{'histstartdate'}),
+			enddate => format_date($solhistory->{'enddate'}),
+			receivedlist => $solhistory->{'receivedlist'},
+			missinglist => $solhistory->{'missinglist'},
+			opacnote => $solhistory->{'opacnote'},
+			librariannote => $solhistory->{'librariannote'},
+			subscriptionid => $subscriptionid,
+			bibliotitle => $subs->{bibliotitle},
+			biblionumber => $subs->{biblionumber},
+			hassubscriptionexpired =>$hassubscriptionexpired,
+			abouttoexpire =>$abouttoexpire,    
+			intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
+			intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+			IntranetNav => C4::Context->preference("IntranetNav"),
+                        routing => $routing,
+                        missingseq => $manualissue,
+                        frommissing => $manualstatus,
+                        missingdate => $manualdate,
+                        missingid => $manualid,
+		);
+output_html_with_http_headers $query, $cookie, $template->output;

Index: subscription-add-new.pl
===================================================================
RCS file: subscription-add-new.pl
diff -N subscription-add-new.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ subscription-add-new.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,309 @@
+#!/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
+# 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: subscription-add-new.pl,v 1.1.2.1 2007/03/10 01:27:27 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 Date::Calc qw(:all);
+use C4::Serials;
+use C4::Bookfund;
+use C4::Interface::CGI::Output;
+use C4::Context;
+use C4::Letters;
+use C4::Members;
+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,
+    $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);
+
+    my @budgets;
+my ($template, $loggedinuser, $cookie)
+= get_template_and_user({template_name => "serials/subscription-add.tmpl",
+                query => $query,
+                type => "intranet",
+                authnotrequired => 0,
+                flagsrequired => {catalogue => 1},
+                debug => 1,
+                });
+
+my $weekarrayjs='';
+my $count = 0;
+my $today=get_today();
+my ($year,$month,$day)=split /-|\/|\.|:/,$today ;
+my $firstday = Day_of_Year($year,$month,$day);
+my ($wkno,$dyear) = Week_of_Year($year,$month,$day); 
+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= Add_Delta_Days($year,$month,$day, $count);
+
+        $weekarrayjs .= "'Wk $wkno: ".format_date($newdate[0]."-".$newdate[1]."-".$newdate[2])."',";
+        $wkno++;    
+}
+chop($weekarrayjs);
+# warn $weekarrayjs;
+
+my $sub_on;
+my @subscription_types = (
+            'issues', 'weeks', 'months'
+        ); 
+my @sub_type_data;
+if ($op eq 'mod') {
+    my $subscriptionid = $query->param('subscriptionid');
+    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){
+	    $sublength = $weeklength;
+	    $sub_on = $subscription_types[1];
+	} else {
+	    $sublength = $numberlength;
+	    $sub_on = $subscription_types[0];
+	}
+        
+
+        while (@subscription_types) {
+           my $sub_type = shift @subscription_types;
+           my %row = ( 'name' => $sub_type );
+           if ( $sub_on eq $sub_type ) {
+	     $row{'selected'} = ' selected';
+           } else {
+	     $row{'selected'} = '';
+           }
+           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(
+        $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,
+        );
+}
+
+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;
+        for(my $i =0;$i<$irregular_count;$i++){
+            $irregularity .=$irregular[$i]."|";
+        }
+        $irregularity =~ s/\|$//;
+        
+    my $auser = $query->param('user');
+    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 $periodicity = $query->param('periodicity');
+    my $dow = $query->param('dow');
+	my $numberlength = 0;
+	my $weeklength = 0;
+	my $monthlength = 0;
+        my $numberpattern = $query->param('numbering_pattern');
+        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 $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 $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 $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 $numberingmethod = $query->param('numberingmethod');
+	my $status = 1;
+    my $biblionumber = $query->param('biblionumber');
+    my $notes = $query->param('notes');
+    my $letter = $query->param('letter');
+            my $hemisphere = $query->param('hemisphere') || 1;
+
+    my $subscriptionid = NewSubscription($auser,$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    );
+    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 );
+           if ( $sub_on eq $sub_type ) {
+	     $row{'selected'} = ' selected';
+           } else {
+	     $row{'selected'} = '';
+           }
+           push( @sub_type_data, \%row );
+        }    
+    $template->param(subtype => \@sub_type_data,
+ 	         weekarrayjs => $weekarrayjs,
+	         weekno => $weekno,
+	);
+    output_html_with_http_headers $query, $cookie, $template->output;
+}

Index: subscription-add.pl
===================================================================
RCS file: subscription-add.pl
diff -N subscription-add.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ subscription-add.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,311 @@
+#!/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
+# 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: subscription-add.pl,v 1.1.2.1 2007/03/10 01:27:27 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::Interface::CGI::Output;
+use C4::Context;
+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,
+    $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);
+
+    my @budgets;
+my ($template, $loggedinuser, $cookie)
+= get_template_and_user({template_name => "serials/subscription-add.tmpl",
+                query => $query,
+                type => "intranet",
+                authnotrequired => 0,
+                flagsrequired => {catalogue => 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 $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)."',";
+        $wkno++;    
+}
+chop($weekarrayjs);
+# warn $weekarrayjs;
+
+my $sub_on;
+my @subscription_types = (
+            'issues', 'weeks', 'months'
+        ); 
+my @sub_type_data;
+if ($op eq 'mod') {
+    my $subscriptionid = $query->param('subscriptionid');
+    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){
+	    $sublength = $weeklength;
+	    $sub_on = $subscription_types[1];
+	} else {
+	    $sublength = $numberlength;
+	    $sub_on = $subscription_types[0];
+	}
+        
+
+        while (@subscription_types) {
+           my $sub_type = shift @subscription_types;
+           my %row = ( 'name' => $sub_type );
+           if ( $sub_on eq $sub_type ) {
+	     $row{'selected'} = ' selected';
+           } else {
+	     $row{'selected'} = '';
+           }
+           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(
+        $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,
+        );
+}
+
+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;
+        for(my $i =0;$i<$irregular_count;$i++){
+            $irregularity .=$irregular[$i]."|";
+        }
+        $irregularity =~ s/\|$//;
+        
+    my $auser = $query->param('user');
+    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 $periodicity = $query->param('periodicity');
+    my $dow = $query->param('dow');
+	my $numberlength = 0;
+	my $weeklength = 0;
+	my $monthlength = 0;
+        my $numberpattern = $query->param('numbering_pattern');
+        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 $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 $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 $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 $numberingmethod = $query->param('numberingmethod');
+	my $status = 1;
+    my $biblionumber = $query->param('biblionumber');
+    my $notes = $query->param('notes');
+    my $letter = $query->param('letter');
+            my $hemisphere = $query->param('hemisphere') || 1;
+
+    my $subscriptionid = NewSubscription($auser,$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    );
+    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 );
+           if ( $sub_on eq $sub_type ) {
+	     $row{'selected'} = ' selected';
+           } else {
+	     $row{'selected'} = '';
+           }
+           push( @sub_type_data, \%row );
+        }    
+    $template->param(subtype => \@sub_type_data,
+ 	         weekarrayjs => $weekarrayjs,
+	         weekno => $weekno,
+	);
+    output_html_with_http_headers $query, $cookie, $template->output;
+}

Index: subscription-bib-search.pl
===================================================================
RCS file: subscription-bib-search.pl
diff -N subscription-bib-search.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ subscription-bib-search.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,172 @@
+#!/usr/bin/perl
+# WARNING: 4-character tab stops here
+
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
+use strict;
+
+use CGI;
+use C4::Koha;
+use C4::Auth;
+use C4::Context;
+use C4::Search;
+use C4::Auth;
+use C4::Interface::CGI::Output;
+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 $dbh = C4::Context->dbh;
+
+my $startfrom=$query->param('startfrom');
+$startfrom=0 if(!defined $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 ($total,$facets, at results) = ZEBRAsearch_kohafields(\@kohafield,\@value,\@relation,$order,\@and_or,1,"",$startfrom,$resultsperpage,"intranet");
+ 										
+	($template, $loggedinuser, $cookie)
+		= get_template_and_user({template_name => "serials/result.tmpl",
+				query => $query,
+				type => "intranet",
+				authnotrequired => 0,
+				flagsrequired => {borrowers => 1},
+				flagsrequired => {catalogue => 1},
+				debug => 1,
+				});
+
+	# multi page display gestion
+	my $displaynext=0;
+	my $displayprev=$startfrom;
+	if(($total - (($startfrom+1)*($resultsperpage))) > 0 ){
+		$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 = ();
+
+	if ($total>$resultsperpage)
+	{
+		for (my $i=1; $i<$total/$resultsperpage+1; $i++)
+		{
+			if ($i<16)
+			{
+	    		my $highlight=0;
+	    		($startfrom==($i-1)) && ($highlight=1);
+	    		push @numbers, { number => $i,
+					highlight => $highlight ,
+					searchdata=> \@field_data,
+					startfrom => ($i-1)};
+			}
+    	}
+	}
+
+	my $from = $startfrom*$resultsperpage+1;
+	my $to;
+
+ 	if($total < (($startfrom+1)*$resultsperpage))
+	{
+		$to = $total;
+	} else {
+		$to = (($startfrom+1)*$resultsperpage);
+	}
+	$template->param(result => \@results,
+							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 {
+	($template, $loggedinuser, $cookie)
+		= get_template_and_user({template_name => "serials/subscription-bib-search.tmpl",
+				query => $query,
+				type => "intranet",
+				authnotrequired => 0,
+				flagsrequired => {catalogue => 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,
+ 				-labels   => \%itemtypes,
+				-size     => 1,
+	 			-tabindex=>'',
+				-multiple => 0 );
+	$sth->finish;
+
+	$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;
+
+# Local Variables:
+# tab-width: 4
+# End:

Index: subscription-detail-new.pl
===================================================================
RCS file: subscription-detail-new.pl
diff -N subscription-detail-new.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ subscription-detail-new.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,128 @@
+#!/usr/bin/perl
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Koha;
+use C4::Date;
+use C4::Serials;
+use C4::Output;
+use C4::Interface::CGI::Output;
+use C4::Context;
+use Date::Calc qw(:all);
+my $query = new CGI;
+my $op = $query->param('op');
+my $dbh = C4::Context->dbh;
+my $sth;
+# 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,
+	$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);
+
+$subscriptionid = $query->param('subscriptionid');
+
+
+if ($op eq 'del') {
+$biblionumber = $query->param('biblionumber');
+	&DelSubscription($subscriptionid,$biblionumber);
+print	$query->redirect("/cgi-bin/koha/serials/serials-home.pl");
+#	exit;
+
+}
+my $subs = &GetSubscription($subscriptionid);
+my ($routing, @routinglist) = getroutinglist($subscriptionid);
+my ($totalissues, at serialslist) = GetSerials($subscriptionid);
+$totalissues-- if $totalissues; # the -1 is to have 0 if this is a new subscription (only 1 issue)
+# the subscription must be deletable if there is NO issues for a reason or another (should not happend, but...)
+
+($template, $loggedinuser, $cookie)
+= get_template_and_user({template_name => "serials/subscription-detail.tmpl",
+				query => $query,
+				type => "intranet",
+				authnotrequired => 0,
+				flagsrequired => {catalogue => 1},
+				debug => 1,
+				});
+
+my ($user, $cookie, $sessionID, $flags)
+	= checkauth($query, 0, {catalogue => 1}, "intranet");
+my $weekarrayjs='';
+my $count = 0;
+my $today=get_today();
+my ($year,$month,$day)=split /-|\/|\.|:/,$today ;
+my $firstday = Day_of_Year($year,$month,$day);
+
+my ($wkno,$dyear) = Week_of_Year($year,$month,$day); 
+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= Add_Delta_Days($year,$month,$day, $count);
+
+        $weekarrayjs .= "'Wk $wkno: ".format_date($newdate[0]."-".$newdate[1]."-".$newdate[2])."',";
+        $wkno++;    
+}
+chop($weekarrayjs);
+
+$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,
+			intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+			intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), 
+			);
+
+output_html_with_http_headers $query, $cookie, $template->output;

Index: subscription-detail.pl
===================================================================
RCS file: subscription-detail.pl
diff -N subscription-detail.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ subscription-detail.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,131 @@
+#!/usr/bin/perl
+
+use strict;
+use CGI;
+use C4::Auth;
+use C4::Koha;
+use C4::Date;
+use C4::Serials;
+use C4::Output;
+use C4::Interface::CGI::Output;
+use C4::Context;
+use DateTime;
+
+my $query = new CGI;
+my $op = $query->param('op');
+my $dbh = C4::Context->dbh;
+my $sth;
+# 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,
+	$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);
+
+$subscriptionid = $query->param('subscriptionid');
+
+
+if ($op eq 'del') {
+$biblionumber = $query->param('biblionumber');
+	&DelSubscription($subscriptionid,$biblionumber);
+print	$query->redirect("/cgi-bin/koha/serials/serials-home.pl");
+#	exit;
+
+}
+my $subs = &GetSubscription($subscriptionid);
+my ($routing, @routinglist) = getroutinglist($subscriptionid);
+my ($totalissues, at serialslist) = GetSerials($subscriptionid);
+$totalissues-- if $totalissues; # the -1 is to have 0 if this is a new subscription (only 1 issue)
+# the subscription must be deletable if there is NO issues for a reason or another (should not happend, but...)
+
+($template, $loggedinuser, $cookie)
+= get_template_and_user({template_name => "serials/subscription-detail.tmpl",
+				query => $query,
+				type => "intranet",
+				authnotrequired => 0,
+				flagsrequired => {catalogue => 1},
+				debug => 1,
+				});
+
+my ($user, $cookie, $sessionID, $flags)
+	= checkauth($query, 0, {catalogue => 1}, "intranet");
+
+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 $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)."',";
+        $wkno++;    
+}
+chop($weekarrayjs);
+
+$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,
+			intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+			intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"), 
+			);
+
+output_html_with_http_headers $query, $cookie, $template->output;

Index: subscription-renew.pl
===================================================================
RCS file: subscription-renew.pl
diff -N subscription-renew.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ subscription-renew.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,100 @@
+#!/usr/bin/perl
+# WARNING: 4-character tab stops here
+
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
+# $Id: subscription-renew.pl,v 1.1.2.1 2007/03/10 01:27:27 tgarip1957 Exp $
+
+=head1 NAME
+
+subscription-renew.pl
+
+=head1 DESCRIPTION
+
+this script renew an existing subscription.
+
+=head1 Parameters
+
+=over 4
+
+=item op
+op use to know the operation to do on this template.
+ * renew : to renew the subscription.
+
+Note that if op = modsubscription there are a lot of other parameters.
+
+=item subscriptionid
+Id of the subscription this script has to renew
+
+=back
+
+=cut
+
+
+use strict;
+require Exporter;
+use CGI;
+use C4::Koha;
+use C4::Auth;
+use C4::Date;
+use C4::Context;
+use C4::Search;
+use C4::Auth;
+use C4::Interface::CGI::Output;
+use C4::Serials;
+
+my $query = new CGI;
+my $dbh = C4::Context->dbh;
+
+my $op = $query->param('op');
+my $subscriptionid = $query->param('subscriptionid');
+my $done = 0; # for after form has been submitted
+my ($template, $loggedinuser, $cookie)
+        = get_template_and_user({template_name => "serials/subscription-renew.tmpl",
+                query => $query,
+                type => "intranet",
+                authnotrequired => 0,
+                flagsrequired => {catalogue => 1},
+                debug => 1,
+                });
+if ($op eq "renew") {
+    ReNewSubscription($subscriptionid,$loggedinuser,$query->param('startdate'),$query->param('numberlength'),$query->param('weeklength'),$query->param('monthlength'),$query->param('note'));
+    $done = 1;
+}
+
+my $subscription= GetSubscription($subscriptionid);
+
+$template->param(startdate => format_date(GetSubscriptionExpirationDate($subscriptionid)),
+                numberlength => $subscription->{numberlength},
+                weeklength => $subscription->{weeklength},
+                monthlength => $subscription->{monthlength},
+                subscriptionid => $subscriptionid,
+                bibliotitle => $subscription->{bibliotitle},
+                $op => 1,
+                done => $done,
+                intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
+                intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+                IntranetNav => C4::Context->preference("IntranetNav"),
+            );
+
+# Print the page
+output_html_with_http_headers $query, $cookie, $template->output;
+
+# Local Variables:
+# tab-width: 4
+# End:

Index: viewalerts.pl
===================================================================
RCS file: viewalerts.pl
diff -N viewalerts.pl
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ viewalerts.pl	10 Mar 2007 01:27:27 -0000	1.1.2.1
@@ -0,0 +1,60 @@
+#!/usr/bin/perl
+
+# $Id: viewalerts.pl,v 1.1.2.1 2007/03/10 01:27:27 tgarip1957 Exp $
+
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA  02111-1307 USA
+
+use strict;
+use C4::Auth;
+use C4::Context;
+
+use CGI;
+use C4::Interface::CGI::Output;
+
+use C4::Koha;
+use C4::Letters;
+use C4::Serials;
+
+my $dbh = C4::Context->dbh;
+
+my $input = new CGI;
+my $print = $input->param('print');
+
+
+my ($template, $loggedinuser, $cookie)
+    = get_template_and_user({template_name => 'serials/viewalerts.tmpl',
+                 query => $input,
+                 type => "intranet",
+                 authnotrequired => 0,
+                 flagsrequired => {catalogue => 1},
+                 debug => 1,
+                 });
+
+my $subscriptionid=$input->param('subscriptionid');
+
+my $borrowers = getalert('','issue',$subscriptionid);
+my $subscription = GetSubscription($subscriptionid);
+
+foreach (@$borrowers) {
+    $_->{name} = findrelatedto('borrower',$_->{borrowernumber});
+}
+$template->param(alertloop => $borrowers,
+                bibliotitle => $subscription->{bibliotitle},
+                subscriptionid => $subscriptionid);
+
+output_html_with_http_headers $input, $cookie, $template->output;





More information about the Koha-cvs mailing list