From d9be1036aae7c63c6b356dd620f3685f993ebe8d Mon Sep 17 00:00:00 2001 From: tipaul Date: Thu, 27 Oct 2005 12:08:44 +0000 Subject: [PATCH] new features for serial module : - the last 5 issues are now shown, and their status can be changed (but not reverted to "waited", as there can be only one "waited") - the library can create a "distribution list". this paper contains a list of borrowers (selected from the borrower list, or manually entered), and print it for a given issue. once printed, the sheet can be put on the issue and distributed to every reader on the list (one by one). --- C4/Bull.pm | 21 +++- bull/distributedto.pl | 102 ++++++++++++++++++ bull/printlist.pl | 62 +++++++++++ bull/statecollection.pl | 2 +- bull/subscription-add.pl | 9 +- bull/subscription-detail.pl | 12 ++- .../default/en/bull/distributedto.tmpl | 85 +++++++++++++++ .../default/en/bull/printlist.tmpl | 18 ++++ .../default/en/bull/statecollection.tmpl | 10 +- .../default/en/bull/subscription-add.tmpl | 10 +- .../default/en/bull/subscription-detail.tmpl | 5 +- updater/updatedatabase | 7 +- 12 files changed, 321 insertions(+), 22 deletions(-) create mode 100755 bull/distributedto.pl create mode 100755 bull/printlist.pl create mode 100644 koha-tmpl/intranet-tmpl/default/en/bull/distributedto.tmpl create mode 100644 koha-tmpl/intranet-tmpl/default/en/bull/printlist.tmpl diff --git a/C4/Bull.pm b/C4/Bull.pm index 6bf871c378..734a00fe70 100755 --- a/C4/Bull.pm +++ b/C4/Bull.pm @@ -50,9 +50,10 @@ Give all XYZ functions &get_full_subscription_list_from_biblionumber &modsubscriptionhistory &newissue &getserials &getlatestserials &serialchangestatus - &Find_Next_Date, &Get_Next_Seq + &Find_Next_Date &Get_Next_Seq &hassubscriptionexpired &subscriptionexpirationdate &subscriptionrenew - &getSupplierListWithLateIssues &GetLateIssues &serialdelete &getlatestserials); + &getSupplierListWithLateIssues &GetLateIssues &serialdelete &getlatestserials + ); sub getSupplierListWithLateIssues { my $dbh = C4::Context->dbh; @@ -344,16 +345,28 @@ sub modsubscriptionhistory { $opacnote =~ s/^,//g; $sth->execute($histstartdate,$enddate,$recievedlist,$missinglist,$opacnote,$librariannote,$subscriptionid); } + # get every serial not arrived for a given subscription # as well as the number of issues registered in the database (all types) # this number is used to see if a subscription can be deleted (=it must have only 1 issue) sub getserials { my ($subscriptionid) = @_; my $dbh = C4::Context->dbh; - # status = 2 is "arrived" - my $sth=$dbh->prepare("select serialid,serialseq, status, planneddate,notes from serial where subscriptionid = ? and status <>2 and status <>4 and status <>5"); + # OK, now add the last 5 issues arrives/missing + my $sth=$dbh->prepare("select serialid,serialseq, status, planneddate,notes from serial where subscriptionid = ? and (status in (2,4,5)) order by serialid desc"); $sth->execute($subscriptionid); + my $counter=0; my @serials; + while((my $line = $sth->fetchrow_hashref) && $counter <5) { + $counter++; + $line->{"status".$line->{status}} = 1; # fills a "statusX" value, used for template status select list + $line->{"planneddate"} = format_date($line->{"planneddate"}); + push @serials,$line; + } + + # status = 2 is "arrived" + $sth=$dbh->prepare("select serialid,serialseq, status, planneddate,notes from serial where subscriptionid = ? and status <>2 and status <>4 and status <>5"); + $sth->execute($subscriptionid); while(my $line = $sth->fetchrow_hashref) { $line->{"status".$line->{status}} = 1; # fills a "statusX" value, used for template status select list $line->{"planneddate"} = format_date($line->{"planneddate"}); diff --git a/bull/distributedto.pl b/bull/distributedto.pl new file mode 100755 index 0000000000..94779c0e88 --- /dev/null +++ b/bull/distributedto.pl @@ -0,0 +1,102 @@ +#!/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 + +use strict; +use CGI; +use C4::Date; +use C4::Auth; +use C4::Context; +use C4::Output; +use C4::Interface::CGI::Output; +use C4::Search; +use HTML::Template; + +sub StringSearch { + my ($searchstring)=@_; + my $dbh = C4::Context->dbh; + $searchstring=~ s/\'/\\\'/g; + my @data=split(' ',$searchstring); + my $count=@data; + my $sth=$dbh->prepare("Select surname,firstname from borrowers where (surname like ?) order by surname"); + $sth->execute("$data[0]%"); + my @results; + my $cnt=0; + while (my $data=$sth->fetchrow_hashref){ + push(@results,$data); + $cnt ++; + } + $sth->finish; + return($cnt,\@results); +} + +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; + +unless ($distributedto) { + # read the previous distributedto + my $sth = $dbh->prepare('select distributedto from subscription where subscriptionid=?'); + $sth->execute($subscriptionid); + ($distributedto) = $sth->fetchrow; +} + +if ($SaveList) { + my $sth = $dbh->prepare("update subscription set distributedto=? where subscriptionid=?"); + $sth->execute($distributedto,$subscriptionid); +} +my ($template, $borrowernumber, $cookie) + = get_template_and_user({template_name => "bull/distributedto.tmpl", + query => $input, + type => "intranet", + authnotrequired => 0, + flagsrequired => {cataloguing => 1}, + debug => 1, + }); + +my $env; +my $count=0; +my $results; +($count,$results)=StringSearch($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; + diff --git a/bull/printlist.pl b/bull/printlist.pl new file mode 100755 index 0000000000..4b7dd63d18 --- /dev/null +++ b/bull/printlist.pl @@ -0,0 +1,62 @@ +#!/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 + +use HTML::Template; +use strict; +require Exporter; +use C4::Context; +use C4::Output; # contains gettemplate +use CGI; +use C4::Auth; +use C4::Bull; +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//g; + +my ($template, $loggedinuser, $cookie) += get_template_and_user({template_name => "bull/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: diff --git a/bull/statecollection.pl b/bull/statecollection.pl index c8a6b84d20..8d97cbf1cb 100755 --- a/bull/statecollection.pl +++ b/bull/statecollection.pl @@ -59,7 +59,7 @@ if ($op eq 'serialchangestatus') { } } my $subs = &getsubscription($subscriptionid); -my ($totalissues,@serialslist) = getserials($subscriptionid); +my ($totalissues,@serialslist) = getserials($subscriptionid,10); my $sth=$dbh->prepare("select * from subscriptionhistory where subscriptionid = ?"); $sth->execute($subscriptionid); diff --git a/bull/subscription-add.pl b/bull/subscription-add.pl index 78ed183cba..0b89cc101d 100755 --- a/bull/subscription-add.pl +++ b/bull/subscription-add.pl @@ -38,7 +38,7 @@ my ($template, $loggedinuser, $cookie) #FIXME : If Budgets are never used, then these lines are useless. -my $dbh = C4::Context->dbh; +$dbh = C4::Context->dbh; my $sthtemp = $dbh->prepare("Select flags, branchcode from borrowers where borrowernumber = ?"); $sthtemp->execute($loggedinuser); my ($flags, $homebranch)=$sthtemp->fetchrow; @@ -48,12 +48,13 @@ if ($op eq 'mod') { my $subscriptionid = $query->param('subscriptionid'); my $subs = &getsubscription($subscriptionid); $auser = $subs->{'user'}; - $librarian => $subs->{'librarian'}, + $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'}; $periodicity = $subs->{'periodicity'}; $dow = $subs->{'dow'}; @@ -84,6 +85,7 @@ if ($op eq 'mod') { $bibliotitle = $subs->{'bibliotitle'}, $notes = $subs->{'notes'}; $letter = $subs->{'letter'}; + defined $letter or $letter=''; $template->param( $op => 1, user => $auser, @@ -133,7 +135,7 @@ if ($op eq 'mod') { ##FIXME : Looks like never used. (my $temp,@budgets) = bookfunds($homebranch); # find default value & set it for the template -for (my $i=0;$i<=$#budgets;$i++) { +for (my $i=0;$i<$#budgets;$i++) { if ($budgets[$i]->{'aqbudgetid'} eq $aqbudgetid) { $budgets[$i]->{'selected'}=1; } @@ -143,7 +145,6 @@ $template->param(budgets => \@budgets); my @letterlist = GetLetterList('serial'); for (my $i=0;$i<=$#letterlist;$i++) { - warn "$letterlist[$i]->{'code'} eq ".$letter; $letterlist[$i]->{'selected'} =1 if $letterlist[$i]->{'code'} eq $letter; } $template->param(letters => \@letterlist); diff --git a/bull/subscription-detail.pl b/bull/subscription-detail.pl index f375c6e49b..679ec6df25 100755 --- a/bull/subscription-detail.pl +++ b/bull/subscription-detail.pl @@ -12,11 +12,11 @@ use C4::Context; use HTML::Template; my $query = new CGI; -my $op = $query->param('op'); +my $op = $query->param('op') || ''; my $dbh = C4::Context->dbh; my $sth; # my $id; -my ($template, $loggedinuser, $cookie, $subs); +my ($template, $loggedinuser, $cookie, $subs, $user, $sessionID, $flags); my ($subscriptionid,$auser,$librarian,$cost,$aqbooksellerid, $aqbooksellername,$aqbudgetid, $bookfundid, $startdate, $periodicity, $dow, $numberlength, $weeklength, $monthlength, $add1,$every1,$whenmorethan1,$setto1,$lastvalue1,$innerloop1, @@ -28,7 +28,7 @@ $subscriptionid = $query->param('subscriptionid'); if ($op eq 'modsubscription') { $auser = $query->param('user'); - $librarian => $query->param('librarian'), + $librarian = $query->param('librarian'); $cost = $query->param('cost'); $aqbooksellerid = $query->param('aqbooksellerid'); $biblionumber = $query->param('biblionumber'); @@ -76,7 +76,9 @@ if ($op eq 'del') { exit; } -my $subs = &getsubscription($subscriptionid); +$subs = &getsubscription($subscriptionid); +# html'ize distributedto +$subs->{distributedto}=~ s/\n/
/g; my ($totalissues,@serialslist) = getserials($subscriptionid); $totalissues-- if $totalissues; # the -1 is to have 0 if this is a new subscription (only 1 issue) @@ -89,7 +91,7 @@ $totalissues-- if $totalissues; # the -1 is to have 0 if this is a new subscript debug => 1, }); -my ($user, $cookie, $sessionID, $flags) = checkauth($query, 0, {catalogue => 1}, "intranet"); +($user, $cookie, $sessionID, $flags) = checkauth($query, 0, {catalogue => 1}, "intranet"); $template->param( user => $subs->{auser}, diff --git a/koha-tmpl/intranet-tmpl/default/en/bull/distributedto.tmpl b/koha-tmpl/intranet-tmpl/default/en/bull/distributedto.tmpl new file mode 100644 index 0000000000..74b20ab571 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/default/en/bull/distributedto.tmpl @@ -0,0 +1,85 @@ + +
+

Select borrowers or enter manually the names

+

+

+ + + + + + + + +
+ "> + + +

Distributed to

+

+ +

+

+ + saved

+ + + "> + + +

+ + + +
+
+

+ +
+ diff --git a/koha-tmpl/intranet-tmpl/default/en/bull/printlist.tmpl b/koha-tmpl/intranet-tmpl/default/en/bull/printlist.tmpl new file mode 100644 index 0000000000..f16177c951 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/default/en/bull/printlist.tmpl @@ -0,0 +1,18 @@ + + +

Distribution list

+

Title : ,

+
+ +
+ +
+

+

+

+

+

phone :

+
+ + + \ No newline at end of file diff --git a/koha-tmpl/intranet-tmpl/default/en/bull/statecollection.tmpl b/koha-tmpl/intranet-tmpl/default/en/bull/statecollection.tmpl index a34e7b89f5..8961c35fe2 100644 --- a/koha-tmpl/intranet-tmpl/default/en/bull/statecollection.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/bull/statecollection.tmpl @@ -73,6 +73,9 @@ " size=20 maxlength=255> + + ,'')" class="button bull">print + @@ -128,10 +131,13 @@ diff --git a/koha-tmpl/intranet-tmpl/default/en/bull/subscription-add.tmpl b/koha-tmpl/intranet-tmpl/default/en/bull/subscription-add.tmpl index 05e9093172..c878e9f868 100644 --- a/koha-tmpl/intranet-tmpl/default/en/bull/subscription-add.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/bull/subscription-add.tmpl @@ -15,8 +15,8 @@ ">

Librarian

-

" size=4> (" disabled readonly>)...

-

" size=4> (" disabled readonly>)...

+

" size=4> (" disabled readonly>)...

+

" size=4> (" disabled readonly>)...

@@ -32,6 +32,7 @@

+

...

warning