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).
This commit is contained in:
tipaul 2005-10-27 12:08:44 +00:00
parent 73ef51958f
commit d9be1036aa
12 changed files with 321 additions and 22 deletions

View File

@ -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"});

102
bull/distributedto.pl Executable file
View File

@ -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;

62
bull/printlist.pl Executable file
View File

@ -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/<br\/>/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:

View File

@ -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);

View File

@ -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);

View File

@ -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/<br \/>/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},

View File

@ -0,0 +1,85 @@
<!-- TMPL_INCLUDE NAME="popup-top.inc" -->
<div id="mainbloc">
<h1>Select borrowers or enter manually the names</h1>
<p>
<form action="/cgi-bin/koha/bull/distributedto.pl" method="post" name="Aform">
<table>
<tr>
<td>
<input type="text" name="searchfield" value="<!-- TMPL_VAR name="searchfield" -->">
<input type="submit" class="button" value="Filter">
</td>
<td rowspan="2">
<h2>Distributed to</h2>
<p>
<textarea name="distributedto" rows="15" cols="30"><!-- TMPL_VAR name="distributedto" --></textarea>
</p>
<p>
<!-- TMPL_IF name="save" -->
saved</p><p>
<!-- /TMPL_IF -->
<input type="hidden" name="SaveList" value="0">
<input type="hidden" name="subscriptionid" value="<!-- TMPL_VAR name="subscriptionid" -->">
<input type="button" name="save" value="Save" class="button" onClick="FSaveList()">
<input type="button" name="clode" value="Close" class="button" onClick="javascript:window.close()">
</td>
</tr>
<tr>
<td>
<!-- TMPL_VAR NAME="borrowername" -->
<select name="borlist" size="15">
<!-- TMPL_LOOP name="borlist" -->
<option value="<!-- TMPL_VAR name="surname" --><!-- TMPL_VAR name="firstname" -->">
<!-- TMPL_VAR name="surname" --> <!-- TMPL_VAR name="firstname" -->
</option>
<!-- /TMPL_LOOP -->
</select>
<input type="button" name="insert" value="&gt;&gt;" class="button" onclick="insertValueQuery()" title="Insert" />
</td>
</tr>
</table>
</form>
</p>
<script language="javascript" type="text/javascript">
// GPL code coming from PhpMyAdmin
function insertValueQuery() {
var myQuery = document.Aform.distributedto;
var myListBox = document.Aform.borlist;
if(myListBox.options.length > 0) {
var chaineAj = "";
var NbSelect = 0;
for(var i=0; i<myListBox.options.length; i++) {
if (myListBox.options[i].selected){
NbSelect++;
if (NbSelect > 1)
chaineAj += ", ";
chaineAj += myListBox.options[i].value;
}
}
//IE support
if (document.selection) {
myQuery.focus();
sel = document.selection.createRange();
sel.text = chaineAj;
document.Aform.insert.focus();
}
//MOZILLA/NETSCAPE support
else if (document.Aform.distributedto.selectionStart || document.Aform.distributedto.selectionStart == "0") {
var startPos = document.Aform.distributedto.selectionStart;
var endPos = document.Aform.distributedto.selectionEnd;
var chaineSql = document.Aform.distributedto.value;
myQuery.value = chaineSql.substring(0, startPos) +''+ chaineAj+"\n" + chaineSql.substring(endPos, chaineSql.length);
} else {
myQuery.value += chaineAj;
}
}
}
function FSaveList() {
document.Aform.SaveList.value=1;
document.Aform.submit();
}
</script>
</div>
<!-- TMPL_INCLUDE NAME="parameters-bottom.inc" -->

View File

@ -0,0 +1,18 @@
<html>
<body onLoad="window.print();">
<h1>Distribution list</h1>
<h2>Title : <!-- TMPL_VAR name="title" -->, <!-- TMPL_VAR name="serialseq" --></h2>
<div style="border : 1px solid black;">
<!-- TMPL_VAR name="distributedto" -->
</div>
<div style=border-top: 1px solid black;">
<p><!-- TMPL_VAR name="branchname" --></p>
<p><!-- TMPL_VAR name="branchaddress1" --></p>
<p><!-- TMPL_VAR name="branchaddress2" --></p>
<p><!-- TMPL_VAR name="branchaddress3" --></p>
<p>phone : <!-- TMPL_VAR name="branchphone" --> <i><!-- TMPL_VAR name="branchemail" --></i></p>
</div>
</body>
</html>

View File

@ -73,6 +73,9 @@
<td>
<input type="text" name="notes" value="<!-- TMPL_VAR name="notes" -->" size=20 maxlength=255>
</td>
<td>
<a href="javascript:PrintList(<!-- TMPL_VAR name="subscriptionid" -->,'<!-- TMPL_VAR name="serialseq" -->')" class="button bull">print</a>
</td>
</tr>
<!-- /TMPL_LOOP -->
<!-- TMPL_UNLESS name="hassubscriptionexpired" -->
@ -128,10 +131,13 @@
</table>
<script language="JavaScript" type="text/javascript">
function popup()
{
function popup() {
window.open("subscription-renew.pl?subscriptionid=<!-- TMPL_VAR name="subscriptionid">","subscription renewal",'width=700,height=400,toolbar=false,scrollbars=yes');
}
function PrintList(subscriptionid,serialseq) {
window.open("printlist.pl?subscriptionid="+subscriptionid+"&serialseq="+serialseq);
}
</script>
<!-- TMPL_INCLUDE name="bull-bottom.inc" -->

View File

@ -15,8 +15,8 @@
<input type="hidden" name="op" value="addsubscription">
<input type="hidden" name="user" value="<!-- TMPL_VAR name="user" -->">
<p>Librarian</td><td> <!-- TMPL_VAR name="user" --></p>
<p><label class="label100">Supplier</label><input type="text" name="aqbooksellerid" value="<!-- TMPL_VAR name="aqbooksellerid" -->" size=4> (<input type="text" name="aqbooksellername" value="<!-- TMPL_VAR name="aqbooksellername" -->" disabled readonly>)<a href="#" onClick="FindAcqui(f)">...</a></p>
<p><label class="label100">Biblio</label><input type="text" name="biblionumber" value="<!-- TMPL_VAR name="biblionumber" -->" size=4> (<input type="text" name="title" value="<!-- TMPL_VAR name="bibliotitle" -->" disabled readonly>)<a href="#" onClick="Plugin(f)">...</a></p>
<p><label class="label100">Supplier</label><input type="text" name="aqbooksellerid" value="<!-- TMPL_VAR name="aqbooksellerid" -->" size=4> (<input type="text" name="aqbooksellername" value="<!-- TMPL_VAR name="aqbooksellername" -->" disabled readonly>)<a href="#" onClick="FindAcqui(f)" class="button bull">...</a></p>
<p><label class="label100">Biblio</label><input type="text" name="biblionumber" value="<!-- TMPL_VAR name="biblionumber" -->" size=4> (<input type="text" name="title" value="<!-- TMPL_VAR name="bibliotitle" -->" disabled readonly>)<a href="#" onClick="Plugin(f)" class="button bull">...</a></p>
<p><label class="label100">Notes</label><textarea name="notes" cols="30" rows="2"><!-- TMPL_VAR name="notes" --></textarea></p>
<!-- TMPL_IF name="letters" -->
<p><label class="label100">Enable issue alert</label>
@ -32,6 +32,7 @@
</select>
</p>
<!-- /TMPL_IF -->
<p><label class="label100">Distributed to </label><a href="#" onClick="DistributedTo()" class="button bull">...</a></p>
<p class="problem">warning</p>
<ul>
<li>remember you <b>must</b> have created a biblio <b>before</b> creating a subscription</li>
@ -232,6 +233,11 @@ function FindAcqui(f)
window.open("acqui-search.pl","Find a supplier",'width=500,height=400,toolbar=false,scrollbars=yes');
}
function DistributedTo()
{
window.open("distributedto.pl?subscriptionid=<!-- TMPL_VAR name="subscriptionid" -->","Distributed to",'width=800,height=600,toolbar=false,scrollbars=yes');
}
function Check(f)
{

View File

@ -4,7 +4,6 @@
<h1 class="bull">Subscription for <!-- TMPL_VAR name="bibliotitle" --></h1>
<a href="subscription-add.pl?op=mod&subscriptionid=<!-- TMPL_VAR name="subscriptionid" -->" class="button bull" title="Modify subscription">Edit</a>
<a href="statecollection.pl?subscriptionid=<!-- TMPL_VAR name="subscriptionid" -->" class="button bull" title="Recieve issues">Receive issues</a>
<a href="distribution.pl?subscriptionid=<!-- TMPL_VAR name="subscriptionid" -->" class="button bull" title="Recieve issues">Define distribution</a>
<a href="serial-issues.pl?biblionumber=<!-- TMPL_VAR name="biblionumber" -->" class="button bull" title="All issues on this title">Issue history</a>
<a href="/cgi-bin/koha/bull-home.pl?biblionumber=<!-- TMPL_VAR name="biblionumber" -->" class="button bull" title="all subscriptions on <!-- TMPL_VAR name="bibliotitle" -->">Subscriptions</a>
<!-- TMPL_IF name="letter" -->
@ -32,8 +31,8 @@
Borrowers can't subscribe to issue alerts
<!-- /TMPL_IF -->
</p>
<p><label>Distributed to</label></p>
<p><!-- TMPL_IF name="distributedto" --></p>
<p><label>Distributed to</label>
<p><ul><!-- TMPL_VAR name="distributedto" --></ul></p>
</div>
<div id="bloc25">
<h2 class="bull">Planning</h2>

View File

@ -97,7 +97,7 @@ my %requiretables = (
);
my %requirefields = (
subscription => { 'letter' => 'char(20) NULL'},
subscription => { 'letter' => 'char(20) NULL', 'distributedto' => 'text NULL'},
itemtypes => { 'imageurl' => 'char(200) NULL'},
# tablename => { 'field' => 'fieldtype' },
);
@ -737,6 +737,11 @@ sub MARCgetitem {
exit;
# $Log$
# Revision 1.124 2005/10/27 12:09:05 tipaul
# 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).
#
# Revision 1.123 2005/10/26 09:13:37 tipaul
# big commit, still breaking things...
#