From 2db99e1dd549c87ef452f7a0dcbae550518deaba Mon Sep 17 00:00:00 2001 From: tipaul Date: Fri, 3 Dec 2004 14:34:54 +0000 Subject: [PATCH] adding "show me late issues" screen --- C4/Bull.pm | 58 +++++++++++++++++-- bull/lateissues.pl | 46 +++++++++++++++ .../default/en/bull/lateissues.tmpl | 49 ++++++++++++++++ 3 files changed, 149 insertions(+), 4 deletions(-) create mode 100755 bull/lateissues.pl create mode 100644 koha-tmpl/intranet-tmpl/default/en/bull/lateissues.tmpl diff --git a/C4/Bull.pm b/C4/Bull.pm index e831d8fea7..3c2ae0d775 100755 --- a/C4/Bull.pm +++ b/C4/Bull.pm @@ -48,8 +48,57 @@ Give all XYZ functions &modsubscriptionhistory &getserials &serialchangestatus &Find_Next_Date, &Get_Next_Seq - &hassubscriptionexpired &subscriptionexpirationdate &subscriptionrenew); + &hassubscriptionexpired &subscriptionexpirationdate &subscriptionrenew + &getSupplierListWithLateIssues &GetLateIssues); +sub getSupplierListWithLateIssues { + my $dbh = C4::Context->dbh; + my $sth = $dbh->prepare("SELECT DISTINCT id, name + FROM subscription, serial + LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id + WHERE subscription.subscriptionid = serial.subscriptionid AND + (planneddate < now( ) OR serial.STATUS = 3) + "); + $sth->execute; + my %supplierlist; + while (my ($id,$name) = $sth->fetchrow) { + $supplierlist{$id} = $name; + } + return %supplierlist; +} +sub GetLateIssues { + my ($supplierid) = @_; + my $dbh = C4::Context->dbh; + my $sth; + if ($supplierid) { + $sth = $dbh->prepare("SELECT name,title,planneddate,serialseq,serial.subscriptionid + FROM subscription, serial, biblio + LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id + WHERE subscription.subscriptionid = serial.subscriptionid AND + ((planneddate < now() and serial.STATUS =1) OR serial.STATUS = 3) and + subscription.aqbooksellerid=$supplierid and + biblio.biblionumber = subscription.biblionumber + "); + } else { + $sth = $dbh->prepare("SELECT name,title,planneddate,serialseq,serial.subscriptionid + FROM subscription, serial, biblio + LEFT JOIN aqbooksellers ON subscription.aqbooksellerid = aqbooksellers.id + WHERE subscription.subscriptionid = serial.subscriptionid AND + ((planneddate < now() and serial.STATUS <=3) OR serial.STATUS = 3) and + biblio.biblionumber = subscription.biblionumber + "); + } + $sth->execute; + my @issuelist; + my $last_title; + while (my $line = $sth->fetchrow_hashref) { + $line->{title} = "" if $line->{title} eq $last_title; + $last_title = $line->{title} if ($line->{title}); + $line->{planneddate} = format_date($line->{planneddate}); + push @issuelist,$line; + } + return @issuelist; +} sub newsubscription { my ($auser,$aqbooksellerid,$cost,$aqbudgetid,$biblionumber, $startdate,$periodicity,$dow,$numberlength,$weeklength,$monthlength, @@ -77,7 +126,7 @@ sub newsubscription { #then create the 1st waited number my $subscriptionid = $dbh->{'mysql_insertid'}; $sth = $dbh->prepare("insert into subscriptionhistory (biblionumber, subscriptionid, histstartdate, enddate, missinglist, recievedlist, opacnote, librariannote) values (?,?,?,?,?,?,?,?)"); - $sth->execute($biblionumber, $subscriptionid, format_date_in_iso($startdate), 0, "", "", 0, $notes); + $sth->execute($biblionumber, $subscriptionid, format_date_in_iso($startdate), 0, "", "", "", $notes); # reread subscription to get a hash (for calculation of the 1st issue number) $sth = $dbh->prepare("select * from subscription where subscriptionid = ? "); $sth->execute($subscriptionid); @@ -149,6 +198,7 @@ sub modsubscription { sub getsubscriptions { my ($title,$ISSN) = @_; + return unless $title or $ISSN; my $dbh = C4::Context->dbh; my $sth; $sth = $dbh->prepare("select subscription.subscriptionid,biblio.title,biblioitems.issn from subscription,biblio,biblioitems where biblio.biblionumber = biblioitems.biblionumber and biblio.biblionumber=subscription.biblionumber and (biblio.title like ? or biblioitems.issn = ? )"); @@ -247,7 +297,7 @@ sub Get_Next_Date(@) { $resultdate=DateCalc($planneddate,"3 months"); } if ($subscription->{periodicity} == 8) { - $resultdate=DateCalc($planneddate,"1 quarter"); + $resultdate=DateCalc($planneddate,"3 months"); } if ($subscription->{periodicity} == 9) { $resultdate=DateCalc($planneddate,"2 weeks"); @@ -312,7 +362,7 @@ sub hassubscriptionexpired { # we don't do the same test if the subscription is based on X numbers or on X weeks/months if ($subscription->{numberlength}) { my $sth = $dbh->prepare("select count(*) from serial where subscriptionid=? and planneddate>=?"); - $sth->execute($subscriptionid,$subscription->{planneddate}); + $sth->execute($subscriptionid,$subscription->{startdate}); my $res = $sth->fetchrow; if ($subscription->{numberlength}>=$res) { return 0; diff --git a/bull/lateissues.pl b/bull/lateissues.pl new file mode 100755 index 0000000000..e85e9be9a3 --- /dev/null +++ b/bull/lateissues.pl @@ -0,0 +1,46 @@ +#!/usr/bin/perl + +use strict; +use CGI; +use C4::Auth; +use C4::Bull; +use C4::Output; +use C4::Interface::CGI::Output; +use C4::Context; +use HTML::Template; + +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 = getSupplierListWithLateIssues; +my @select_supplier; +push @select_supplier,""; +foreach my $supplierid (keys %supplierlist){ + push @select_supplier, $supplierid +} +my $CGIsupplier=CGI::scrolling_list( -name => 'supplierid', + -values => \@select_supplier, + -default => $supplierid, + -labels => \%supplierlist, + -size => 1, + -multiple => 0 ); + +my @lateissues; +@lateissues = GetLateIssues($supplierid) if $supplierid; +my ($template, $loggedinuser, $cookie) += get_template_and_user({template_name => "bull/lateissues.tmpl", + query => $query, + type => "intranet", + authnotrequired => 0, + flagsrequired => {catalogue => 1}, + debug => 1, + }); + +$template->param( + CGIsupplier => $CGIsupplier, + lateissues => \@lateissues + ); +output_html_with_http_headers $query, $cookie, $template->output; diff --git a/koha-tmpl/intranet-tmpl/default/en/bull/lateissues.tmpl b/koha-tmpl/intranet-tmpl/default/en/bull/lateissues.tmpl new file mode 100644 index 0000000000..a2db8eefb8 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/default/en/bull/lateissues.tmpl @@ -0,0 +1,49 @@ + + +
+

Late issues

+ + + + + + + + + + + + + + + + + + + + + + + + +
SupplierTitleIssue numberLate since 
+ + +   + + +
+ + + + + + + + + " class="button bull">Detail + " class="button bull">Recieve +
+
+ + -- 2.39.5