From 536939c51b120206c639a67114f6bcb6bbe02c18 Mon Sep 17 00:00:00 2001 From: bob_lyon Date: Thu, 20 Jul 2006 03:22:15 +0000 Subject: [PATCH] Merging in katipo changes for serials --- serials/claims.pl | 84 +++++++++++++++++++++++++ serials/lateissues-excel.pl | 121 ++++++++++++++++++++++++++++++++++++ serials/lateissues.pl | 12 +++- serials/member-search.pl | 48 ++++++++++++++ serials/reorder_members.pl | 29 +++++++++ 5 files changed, 293 insertions(+), 1 deletion(-) create mode 100755 serials/claims.pl create mode 100755 serials/lateissues-excel.pl create mode 100755 serials/member-search.pl create mode 100755 serials/reorder_members.pl diff --git a/serials/claims.pl b/serials/claims.pl new file mode 100755 index 0000000000..b6e1954f30 --- /dev/null +++ b/serials/claims.pl @@ -0,0 +1,84 @@ +#!/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 HTML::Template; +use Data::Dumper; + +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,@supplierinfo); +if($supplierid){ + ($singlesupplier,@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; diff --git a/serials/lateissues-excel.pl b/serials/lateissues-excel.pl new file mode 100755 index 0000000000..19e31fb04b --- /dev/null +++ b/serials/lateissues-excel.pl @@ -0,0 +1,121 @@ +#!/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 HTML::Template; +# use Date::Manip; +use Text::CSV_XS; + + +# &Date_Init("DateFormat=non-US"); # set non-USA date, eg:19/08/2005 + + +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"; +} diff --git a/serials/lateissues.pl b/serials/lateissues.pl index 2762d4a542..db2ecf36c9 100755 --- a/serials/lateissues.pl +++ b/serials/lateissues.pl @@ -58,6 +58,10 @@ my %supplierlist = GetSuppliersWithLateIssues; my @select_supplier; push @select_supplier,""; foreach my $supplierid (keys %supplierlist){ + my ($count, @dummy) = GetLateIssues($supplierid); + my ($count2, @dummy2) = GetMissingIssues($supplierid); + my $counting = $count+$count2; + $supplierlist{$supplierid} = $supplierlist{$supplierid}." ($counting)"; push @select_supplier, $supplierid } my $CGIsupplier=CGI::scrolling_list( @@ -69,7 +73,11 @@ my $CGIsupplier=CGI::scrolling_list( -multiple => 0 ); my @lateissues; -@lateissues = GetLateIssues($supplierid) if $supplierid; +my $count; +($count,@lateissues) = GetLateIssues($supplierid) if $supplierid; +my @missingissues; +my $count2; +($count2, @missingissues) = GetMissingIssues($supplierid) if $supplierid; my @supplierinfo; my $nothing; ($nothing,@supplierinfo)=GetBookSeller($supplierid) if $supplierid; @@ -86,6 +94,8 @@ my ($template, $loggedinuser, $cookie) $template->param( CGIsupplier => $CGIsupplier, lateissues => \@lateissues, + missingissues => \@missingissues, + supplierid => $supplierid, phone => $supplierinfo[0]->{phone}, booksellerfax => $supplierinfo[0]->{booksellerfax}, bookselleremail => $supplierinfo[0]->{bookselleremail}, diff --git a/serials/member-search.pl b/serials/member-search.pl new file mode 100755 index 0000000000..54e87a9e5f --- /dev/null +++ b/serials/member-search.pl @@ -0,0 +1,48 @@ +#!/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::Output; +use C4::Acquisition; +use C4::Interface::CGI::Output; +use C4::Context; +use HTML::Template; +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; diff --git a/serials/reorder_members.pl b/serials/reorder_members.pl new file mode 100755 index 0000000000..ee498d5db9 --- /dev/null +++ b/serials/reorder_members.pl @@ -0,0 +1,29 @@ +#!/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::Output; +use C4::Acquisition; +use C4::Interface::CGI::Output; +use C4::Context; +use HTML::Template; +use C4::Search; +use C4::Serials; +use Data::Dumper; + +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"); + -- 2.39.5