Merge branch 'serials_mods' of git://github.com/colinsc/koha into to-push

Description by Colin Campbell:

A number of commits, subsequent to enabling warnings in C4::Serials and
eradicating errors and removing dead code.
These are extracted from an install branch running at UN FAO in Rome.
Commits have been rebased on current 3.2 HEAD.
These are not major new functionality, but  a series of fixes to
eradicate some randomness caused by undefined values. Includes a commit
to fix Licenses in the serials directory.

* 'serials_mods' of git://github.com/colinsc/koha:
  Check value is defined before splitting it
  Fix FSF Address in directory serials/
  Bug 4380 Use syspref to resolve which bib display is used
  Remove bottleneck making claims page unuseable
  Clean up Pod Documentation
  add warnings to Serials.pm
  Add Text to claim date column's header
  Basic refactoring of serials-edit.pm
  Remove unused or unnecessary variables in claims processing

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
This commit is contained in:
Galen Charlton 2010-04-16 00:16:16 -04:00
commit df4b588c6e
16 changed files with 589 additions and 636 deletions

File diff suppressed because it is too large Load diff

View file

@ -167,10 +167,10 @@
<form id="claims" name="claims" action="claims.pl" method="post">
<fieldset><label for="supplierid">View: </label>
<select id="supplierid" size="1" name="supplierid">
<!-- TMPL_LOOP name="supplier_loop" -->
<option value="<!--TMPL_VAR name="id"-->" <!-- TMPL_IF NAME="selected" -->selected="1"<!-- /TMPL_IF -->>
<!--TMPL_VAR name="name"--></option>
<!--/TMPL_LOOP-->
<!-- TMPL_LOOP NAME="supplier_loop" -->
<option value="<!-- TMPL_VAR NAME="id" -->"<!-- TMPL_IF NAME="selected" --> selected="yes" <!-- /TMPL_IF -->><!-- TMPL_VAR NAME="name" -->
</option>
<!-- /TMPL_LOOP -->
</select>
<input type="submit" value="OK" />
<!-- TMPL_IF name="phone" -->Phone: <!-- TMPL_VAR name="phone" --><!-- /TMPL_IF -->
@ -253,7 +253,7 @@
<th>Issue number</th>
<th>Status</th>
<th>Since</th>
<th>&nbsp;</th>
<th>Claim Date</th>
<th>Begin Claim</th>
</tr></thead>
<tbody><!-- TMPL_LOOP name="missingissues" -->
@ -292,10 +292,6 @@
<!-- /TMPL_LOOP --></tbody>
</table>
<p><span class="exportSelected"></span></p>
<!-- TMPL_IF Name="singlesupplier"-->
<input type="hidden" name="supplierid" value="<!--TMPL_VAR NAME="supplierid"-->" />
<!-- <a href="claims.pl?supplierid=<!-- TMPL_VAR name="supplierid" -->&amp;op=preview" onclick="popup(<!-- TMPL_VAR name="supplierid" -->,''); return false" class="button">Vendor Group Claim Notice</a></p> -->
<!-- /TMPL_IF -->
<!--TMPL_IF Name="letter" -->
<fieldset class="action"> <label for="letter_code">Select notice:</label>
@ -306,9 +302,9 @@
</select>
<input type="hidden" name="op" value="send_alert" /><input type="submit" name="submit" class="button" value="Send notification" /></fieldset>
<!--/TMPL_IF-->
</form>
<!-- /TMPL_IF -->
</form>
<!-- TMPL_ELSE -->
<div id="doc" class="yui-t7">

View file

@ -424,7 +424,7 @@ function CloneSubfield(index){
<!--TMPL_IF name="abouttoexpire"--><a href="#" onclick="javascript:popup(<!--TMPL_VAR Name="subscriptionid"-->)">Renew <!--TMPL_VAR Name="subscriptionid"--></a>
<!--/TMPL_IF-->
<!--/TMPL_LOOP-->
<li><a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR name="biblionumber" -->" title="go to <!-- TMPL_VAR name="bibliotitle" -->">Show Biblio</a></li></ul>
<li><a href="/cgi-bin/koha/catalogue/<!-- TMPL_VAR NAME='default_bib_view' -->.pl?biblionumber=<!-- TMPL_VAR name="biblionumber" -->" title="go to <!-- TMPL_VAR name="bibliotitle" -->">Show Biblio</a></li></ul>
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->

View file

@ -82,7 +82,7 @@ function popup(subscriptionid) {
<li><span class="label">Subscription ID: </span><!--TMPL_VAR name="subscriptionid"--></li>
<li><span class="label">Librarian identity:</span> <!-- TMPL_VAR name="librarian" --></li>
<li><span class="label">Vendor:</span> <a href="/cgi-bin/koha/acqui/supplier.pl?supplierid=<!-- TMPL_VAR name="aqbooksellerid"-->"><!-- TMPL_VAR name="aqbooksellername" -->&nbsp;</a></li>
<li><span class="label">Biblio:</span> <i>(<!-- TMPL_VAR name="bibnum" -->)</i> <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR name="bibnum" -->"><!-- TMPL_VAR name="bibliotitle" --></a></li>
<li><span class="label">Biblio:</span> <i>(<!-- TMPL_VAR name="bibnum" -->)</i> <a href="/cgi-bin/koha/catalogue/<!-- TMPL_VAR NAME='default_bib_view' -->.pl?biblionumber=<!-- TMPL_VAR name="bibnum" -->"><!-- TMPL_VAR name="bibliotitle" --></a></li>
<!-- TMPL_IF name="branchcode" --><li><span class="label">Library:</span> <!-- TMPL_VAR name="branchcode" -->&nbsp;</li><!-- /TMPL_IF -->
<!-- TMPL_IF name="serialsadditems" -->
<li>Serial receipt creates an item record.</li>

View file

@ -12,9 +12,9 @@
# 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
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
=head1 NAME

View file

@ -1,5 +1,20 @@
#!/usr/bin/perl
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use strict;
use warnings;
use CGI;
@ -10,7 +25,7 @@ use C4::Output;
use C4::Bookseller;
use C4::Context;
use C4::Letters;
my $input = new CGI;
my $input = CGI->new;
my $serialid = $input->param('serialid');
my $op = $input->param('op');
@ -18,26 +33,26 @@ my $claimletter = $input->param('claimletter');
my $supplierid = $input->param('supplierid');
my $suppliername = $input->param('suppliername');
my $order = $input->param('order');
my %supplierlist = GetSuppliersWithLateIssues();
my $supplierlist = GetSuppliersWithLateIssues();
if ($supplierid) {
foreach my $s ( @{$supplierlist} ) {
if ($s->{id} == $supplierid ) {
$s->{selected} = 1;
last;
}
}
}
# open template first (security & userenv set here)
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "serials/claims.tmpl",
= get_template_and_user({template_name => 'serials/claims.tmpl',
query => $input,
type => "intranet",
type => 'intranet',
authnotrequired => 0,
flagsrequired => {serials => 1},
debug => 1,
});
my $supplier_loop = [];
foreach my $s_id (sort {$supplierlist{$a} cmp $supplierlist{$b} } keys %supplierlist){
my ($count) = GetLateOrMissingIssues($s_id,q{},$order);
push @{$supplier_loop}, {
id => $s_id,
name => $supplierlist{$s_id} . "($count)",
selected => ( $supplierid && $supplierid == $s_id ),
};
}
my $letters = GetLetters('claimissues');
my @letters;
@ -46,37 +61,28 @@ foreach (keys %{$letters}){
}
my $letter=((scalar(@letters)>1) || ($letters[0]->{name}||$letters[0]->{code}));
my ($count2, @missingissues);
my @missingissues;
my @supplierinfo;
if ($supplierid) {
($count2, @missingissues) = GetLateOrMissingIssues($supplierid,$serialid,$order);
}
my ($singlesupplier,@supplierinfo);
if($supplierid){
(@supplierinfo)=GetBookSeller($supplierid);
} else { # set up supplierid for the claim links out of main table if all suppliers is chosen
for my $mi (@missingissues){
$mi->{supplierid} = getsupplierbyserialid($mi->{serialid});
}
@missingissues = GetLateOrMissingIssues($supplierid,$serialid,$order);
@supplierinfo=GetBookSeller($supplierid);
}
my $preview=0;
if($op && $op eq 'preview'){
$preview = 1;
} else {
my @serialnums=$input->param('serialid');
if (@serialnums) { # i.e. they have been flagged to generate claims
SendAlerts('claimissues',\@serialnums,$input->param("letter_code"));
my $cntupdate=UpdateClaimdateIssues(\@serialnums);
### $cntupdate SHOULD be equal to scalar(@$serialnums)
}
}
if ($op eq "send_alert"){
my @serialnums=$input->param("serialid");
SendAlerts('claimissues',\@serialnums,$input->param("letter_code"));
my $cntupdate=UpdateClaimdateIssues(\@serialnums);
### $cntupdate SHOULD be equal to scalar(@$serialnums)
$template->param('SHOWCONFIRMATION' => 1);
$template->param('suppliername' => $suppliername);
}
$template->param('letters'=>\@letters,'letter'=>$letter);
$template->param(
order =>$order,
supplier_loop => $supplier_loop,
supplier_loop => $supplierlist,
phone => $supplierinfo[0]->{phone},
booksellerfax => $supplierinfo[0]->{booksellerfax},
bookselleremail => $supplierinfo[0]->{bookselleremail},
@ -84,7 +90,6 @@ $template->param(
missingissues => \@missingissues,
supplierid => $supplierid,
claimletter => $claimletter,
singlesupplier => $singlesupplier,
supplierloop => \@supplierinfo,
dateformat => C4::Context->preference("dateformat"),
DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),

View file

@ -1,5 +1,20 @@
#!/usr/bin/perl
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use strict;
use warnings;
use CGI;
@ -32,12 +47,10 @@ my @serialid = $query->param('serialid');
my $op = $query->param('op') || q{};
my $serialidcount = @serialid;
my %supplierlist = GetSuppliersWithLateIssues;
my @loop1;
my ($count, @lateissues);
my @lateissues;
if($op ne 'claims'){
($count, @lateissues) = GetLateIssues($supplierid);
@lateissues = GetLateIssues($supplierid);
for my $issue (@lateissues){
push @loop1,
[ $issue->{'name'}, $issue->{'title'}, $issue->{'serialseq'}, $issue->{'planneddate'},];
@ -45,9 +58,9 @@ if($op ne 'claims'){
}
my $totalcount2 = 0;
my @loop2;
my ($count2, @missingissues);
my @missingissues;
for (my $k=0;$k<@serialid;$k++){
($count2, @missingissues) = GetLateOrMissingIssues($supplierid, $serialid[$k]);
@missingissues = GetLateOrMissingIssues($supplierid, $serialid[$k]);
for (my $j=0;$j<@missingissues;$j++){
my @rows2 = ($missingissues[$j]->{'name'}, # lets build up a row
@ -57,7 +70,7 @@ for (my $k=0;$k<@serialid;$k++){
);
push (@loop2, \@rows2);
}
$totalcount2 = $totalcount2 + $count2;
$totalcount2 += scalar @missingissues;
# update claim date to let one know they have looked at this missing item
updateClaim($serialid[$k]);
}
@ -107,6 +120,7 @@ for my $row ( @loop2 ) {
print ",,,,,,,\n";
print ",,,,,,,\n";
if($op ne 'claims'){
my $count = scalar @lateissues;
print ",,Total Number Late, $count\n";
}
if($serialidcount == 1){

View file

@ -11,9 +11,9 @@
# 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
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
=head1 member-search.pl

View file

@ -1,4 +1,19 @@
#!/usr/bin/perl
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# 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

View file

@ -1,5 +1,20 @@
#!/usr/bin/perl
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
# 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

View file

@ -11,9 +11,9 @@
# 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
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
=head1 Routing.pl

View file

@ -17,7 +17,6 @@
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
=head1 NAME
serials-recieve.pl
@ -61,7 +60,6 @@ op can be :
=cut
use strict;
use warnings;
use CGI;
@ -74,232 +72,312 @@ use C4::Output;
use C4::Context;
use C4::Serials;
#use Smart::Comments;
my $query = new CGI;
my $dbh = C4::Context->dbh;
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 $query = CGI->new();
my $dbh = C4::Context->dbh;
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 @subscriptionids = $query->param('subscriptionid');
my $op = $query->param('op');
if (scalar(@subscriptionids)==1 && index($subscriptionids[0],",")>0){
@subscriptionids =split (/,/,$subscriptionids[0]);
my $op = $query->param('op');
if ( scalar(@subscriptionids) == 1 && index( $subscriptionids[0], q|,| ) > 0 ) {
@subscriptionids = split( /,/, $subscriptionids[0] );
}
my @errors;
my @errseq;
# If user comes from subscription details
unless (@serialids){
foreach my $subscriptionid (@subscriptionids){
my $serstatus=$query->param('serstatus');
if ($serstatus){
my ($count,@tmpser)=GetSerials2($subscriptionid,$serstatus);
foreach (@tmpser) {
push @serialids, $_->{'serialid'};
}
unless (@serialids) {
foreach my $subscriptionid (@subscriptionids) {
my $serstatus = $query->param('serstatus');
if ($serstatus) {
my @tmpser = GetSerials2( $subscriptionid, $serstatus );
foreach (@tmpser) {
push @serialids, $_->{'serialid'};
}
}
}
}
}
unless (scalar(@serialids)){
my $string="serials-collection.pl?subscriptionid=".join(",",@subscriptionids);
$string=~s/,$//;
# warn $string;
print $query->redirect($string);
unless ( scalar(@serialids) ) {
my $string =
"serials-collection.pl?subscriptionid=" . join( ",", @subscriptionids );
$string =~ s/,$//;
print $query->redirect($string);
}
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "serials/serials-edit.tmpl",
query => $query,
type => "intranet",
authnotrequired => 0,
flagsrequired => {serials => 1},
debug => 1,
});
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
{
template_name => "serials/serials-edit.tmpl",
query => $query,
type => "intranet",
authnotrequired => 0,
flagsrequired => { serials => 1 },
debug => 1,
}
);
my @serialdatalist;
my %processedserialid;
foreach my $tmpserialid (@serialids){
foreach my $tmpserialid (@serialids) {
#filtering serialid for duplication
#NEW serial should appear only once and are created afterwards
next unless (defined($tmpserialid) && $tmpserialid =~/^[0-9]+$/ && !$processedserialid{$tmpserialid});
my $data=GetSerialInformation($tmpserialid);
$data->{publisheddate}=format_date($data->{publisheddate});
$data->{planneddate}=format_date($data->{planneddate});
$data->{'editdisable'}=((HasSubscriptionExpired($data->{subscriptionid})&& $data->{'status1'})||$data->{'cannotedit'});
push @serialdatalist,$data;
$processedserialid{$tmpserialid}=1;
if ( defined($tmpserialid)
&& $tmpserialid =~ /^[0-9]+$/
&& !$processedserialid{$tmpserialid} )
{
my $data = GetSerialInformation($tmpserialid);
$data->{publisheddate} = format_date( $data->{publisheddate} );
$data->{planneddate} = format_date( $data->{planneddate} );
$data->{'editdisable'} = (
(
HasSubscriptionExpired( $data->{subscriptionid} )
&& $data->{'status1'}
)
|| $data->{'cannotedit'}
);
push @serialdatalist, $data;
$processedserialid{$tmpserialid} = 1;
}
}
my $bibdata=GetBiblioData($serialdatalist[0]->{'biblionumber'});
my $bibdata = GetBiblioData( $serialdatalist[0]->{'biblionumber'} );
my @newserialloop;
my @subscriptionloop;
# check, for each subscription edited, that we have an empty item line if applicable for the subscription
my %processedsubscriptionid;
foreach my $subscriptionid (@subscriptionids){
#Donot process subscriptionid twice if it was already processed.
my $subscriptiondetail = GetSubscription($subscriptionid);
next unless (defined($subscriptionid) && !$processedsubscriptionid{$subscriptionid});
my $cell;
if ($serialdatalist[0]->{'serialsadditems'}){
#Create New empty item
$cell =
PrepareItemrecordDisplay( $serialdatalist[0]->{'biblionumber'},'', $subscriptiondetail);
$cell->{serialsadditems} = 1;
foreach my $subscriptionid (@subscriptionids) {
#Do not process subscriptionid twice if it was already processed.
if ( defined($subscriptionid)
&& !$processedsubscriptionid{$subscriptionid} )
{
my $cell;
if ( $serialdatalist[0]->{'serialsadditems'} ) {
#Create New empty item
$cell =
PrepareItemrecordDisplay( $serialdatalist[0]->{'biblionumber'},
'', GetSubscription($subscriptionid) );
$cell->{serialsadditems} = 1;
}
$cell->{'subscriptionid'} = $subscriptionid;
$cell->{'itemid'} = "NNEW";
$cell->{'serialid'} = "NEW";
$cell->{'issuesatonce'} = 1;
push @newserialloop, $cell;
push @subscriptionloop,
{
'subscriptionid' => $subscriptionid,
'abouttoexpire' => abouttoexpire($subscriptionid),
'subscriptionexpired' => HasSubscriptionExpired($subscriptionid),
};
$processedsubscriptionid{$subscriptionid} = 1;
}
$cell->{'subscriptionid'}=$subscriptionid;
$cell->{'itemid'} = "NNEW";
$cell->{'serialid'} = "NEW";
$cell->{'issuesatonce'} = 1;
push @newserialloop,$cell;
push @subscriptionloop, {'subscriptionid'=>$subscriptionid,
'abouttoexpire'=>abouttoexpire($subscriptionid),
'subscriptionexpired'=>HasSubscriptionExpired($subscriptionid),
};
$processedsubscriptionid{$subscriptionid}=1;
$template->param(bibliotitle => $subscriptiondetail->{'bibliotitle'},
callnumber => $subscriptiondetail->{'callnumber'},
);
}
$template->param(newserialloop=>\@newserialloop);
$template->param(subscriptions=>\@subscriptionloop);
$template->param( newserialloop => \@newserialloop );
$template->param( subscriptions => \@subscriptionloop );
if ( $op and $op eq 'serialchangestatus' ) {
if ($op and $op eq 'serialchangestatus') {
# my $sth = $dbh->prepare("select status from serial where serialid=?");
my $newserial;
for (my $i=0;$i<=$#serialids;$i++) {
# $sth->execute($serialids[$i]);
# my ($oldstatus) = $sth->fetchrow;
if ($serialids[$i] && $serialids[$i] eq "NEW") {
if ($serialseqs[$i]){
for ( my $i = 0 ; $i <= $#serialids ; $i++ ) {
if ( $serialids[$i] && $serialids[$i] eq "NEW" ) {
if ( $serialseqs[$i] ) {
#IF newserial was provided a name Then we have to create a newSerial
### FIXME if NewIssue is modified to use subscription biblionumber, then biblionumber would not be useful.
$newserial = NewIssue( $serialseqs[$i],$subscriptionids[$i],$serialdatalist[0]->{'biblionumber'},
$status[$i],
format_date_in_iso($planneddates[$i]),
format_date_in_iso($publisheddates[$i]),
$notes[$i]);
}
}elsif ($serialids[$i]){
ModSerialStatus($serialids[$i],
$serialseqs[$i],
format_date_in_iso($planneddates[$i]),
format_date_in_iso($publisheddates[$i]),
$status[$i],
$notes[$i]);
### FIXME if NewIssue is modified to use subscription biblionumber, then biblionumber would not be useful.
$newserial = NewIssue(
$serialseqs[$i],
$subscriptionids[$i],
$serialdatalist[0]->{'biblionumber'},
$status[$i],
format_date_in_iso( $planneddates[$i] ),
format_date_in_iso( $publisheddates[$i] ),
$notes[$i]
);
}
}
elsif ( $serialids[$i] ) {
ModSerialStatus(
$serialids[$i],
$serialseqs[$i],
format_date_in_iso( $planneddates[$i] ),
format_date_in_iso( $publisheddates[$i] ),
$status[$i],
$notes[$i]
);
}
}
my @moditems = $query->param('moditem');
if (scalar(@moditems)){
my @tags = $query->param('tag');
my @subfields = $query->param('subfield');
my @field_values = $query->param('field_value');
my @serials = $query->param('serial');
my @bibnums = $query->param('bibnum');
my @itemid = $query->param('itemid');
my @ind_tag = $query->param('ind_tag');
my @indicator = $query->param('indicator');
#Rebuilding ALL the data for items into a hash
# parting them on $itemid.
my %itemhash;
my $countdistinct;
my $range=scalar(@itemid);
for (my $i=0; $i<$range; $i++){
unless ($itemhash{$itemid[$i]}){
if ($serials[$countdistinct] && $serials[$countdistinct] ne "NEW"){
$itemhash{$itemid[$i]}->{'serial'}=$serials[$countdistinct];
} else {
$itemhash{$itemid[$i]}->{'serial'}=$newserial;
}
$itemhash{$itemid[$i]}->{'bibnum'}=$bibnums[$countdistinct];
$countdistinct++;
}
push @{$itemhash{$itemid[$i]}->{'tags'}},$tags[$i];
push @{$itemhash{$itemid[$i]}->{'subfields'}},$subfields[$i];
push @{$itemhash{$itemid[$i]}->{'field_values'}},$field_values[$i];
push @{$itemhash{$itemid[$i]}->{'ind_tag'}},$ind_tag[$i];
push @{$itemhash{$itemid[$i]}->{'indicator'}},$indicator[$i];
}
foreach my $item (keys %itemhash){
# Verify Itemization is "Valid", i.e. serial status is Arrived or Missing
my $index=-1;
for (my $i=0; $i<scalar(@serialids);$i++){
$index = $i if ($itemhash{$item}->{'serial'} eq $serialids[$i] || ($itemhash{$item}->{'serial'} == $newserial && $serialids[$i] eq "NEW"));
}
if ($index>=0 && $status[$index]==2){
my $xml = TransformHtmlToXml( $itemhash{$item}->{'tags'},
$itemhash{$item}->{'subfields'},
$itemhash{$item}->{'field_values'},
$itemhash{$item}->{'indicator'},
$itemhash{$item}->{'ind_tag'});
# warn $xml;
my $record=MARC::Record::new_from_xml($xml, 'UTF-8');
if ($item=~/^N/){
#New Item
# if autoBarcode is set to 'incremental', calculate barcode...
my ($barcodetagfield,$barcodetagsubfield) = &GetMarcFromKohaField("items.barcode", GetFrameworkCode($serialdatalist[0]->{'biblionumber'}));
if (C4::Context->preference("autoBarcode") eq 'incremental' ) {
if (!$record->field($barcodetagfield)->subfield($barcodetagsubfield)) {
my $sth_barcode = $dbh->prepare("select max(abs(barcode)) from items");
$sth_barcode->execute;
my ($newbarcode) = $sth_barcode->fetchrow;
# OK, we have the new barcode, add the entry in MARC record # FIXME -> should be using barcode plugin here.
$record->field($barcodetagfield)->update( $barcodetagsubfield => ++$newbarcode );
}
}
# check for item barcode # being unique
my $exists;
if ($record->subfield($barcodetagfield,$barcodetagsubfield)) {
$exists = GetItemnumberFromBarcode($record->subfield($barcodetagfield,$barcodetagsubfield));
}
# push @errors,"barcode_not_unique" if($exists);
# if barcode exists, don't create, but report The problem.
if ($exists){
push @errors,"barcode_not_unique" if($exists);
push @errseq,{"serialseq"=>$serialseqs[$index]};
} else {
my ($biblionumber,$bibitemnum,$itemnumber) = AddItemFromMarc($record,$itemhash{$item}->{'bibnum'});
AddItem2Serial($itemhash{$item}->{'serial'},$itemnumber);
}
} else {
#modify item
my ($oldbiblionumber,$oldbibnum,$itemnumber) = ModItemFromMarc($record,$itemhash{$item}->{'bibnum'},$item);
}
}
}
}
# ### FIXME this part of code is not very pretty. Nor is it very efficient... There MUST be a more perlish way to write it. But it works.
# my $redirect ="serials-home.pl?";
# $redirect.=join("&",map{"serialseq=".$_} @serialseqs);
# $redirect.="&".join("&",map{"planneddate=".$_} @planneddates);
# $redirect.="&".join("&",map{"publisheddate=".$_} @publisheddates);
# $redirect.="&".join("&",map{"status=".$_} @status);
# $redirect.="&".join("&",map{"notes=".$_} @notes);
if ( scalar(@moditems) ) {
my @tags = $query->param('tag');
my @subfields = $query->param('subfield');
my @field_values = $query->param('field_value');
my @serials = $query->param('serial');
my @bibnums = $query->param('bibnum');
my @itemid = $query->param('itemid');
my @ind_tag = $query->param('ind_tag');
my @indicator = $query->param('indicator');
if (scalar(@errors)>0){
$template->param("Errors" => 1);
if (scalar(@errseq)>0){
$template->param("barcode_not_unique" => 1);
$template->param('errseq'=>\@errseq);
#Rebuilding ALL the data for items into a hash
# parting them on $itemid.
my %itemhash;
my $countdistinct;
my $range = scalar(@itemid);
for ( my $i = 0 ; $i < $range ; $i++ ) {
unless ( $itemhash{ $itemid[$i] } ) {
if ( $serials[$countdistinct]
&& $serials[$countdistinct] ne "NEW" )
{
$itemhash{ $itemid[$i] }->{'serial'} =
$serials[$countdistinct];
}
else {
$itemhash{ $itemid[$i] }->{'serial'} = $newserial;
}
$itemhash{ $itemid[$i] }->{'bibnum'} = $bibnums[$countdistinct];
$countdistinct++;
}
push @{ $itemhash{ $itemid[$i] }->{'tags'} }, $tags[$i];
push @{ $itemhash{ $itemid[$i] }->{'subfields'} }, $subfields[$i];
push @{ $itemhash{ $itemid[$i] }->{'field_values'} },
$field_values[$i];
push @{ $itemhash{ $itemid[$i] }->{'ind_tag'} }, $ind_tag[$i];
push @{ $itemhash{ $itemid[$i] }->{'indicator'} }, $indicator[$i];
}
} else {
my $redirect ="serials-collection.pl?";
my %hashsubscription;
foreach (@subscriptionids) {
$hashsubscription{$_}=1;
}
$redirect.=join("&",map{"subscriptionid=".$_} sort keys %hashsubscription);
print $query->redirect("$redirect");
}
foreach my $item ( keys %itemhash ) {
# Verify Itemization is "Valid", i.e. serial status is Arrived or Missing
my $index = -1;
for ( my $i = 0 ; $i < scalar(@serialids) ; $i++ ) {
if (
$itemhash{$item}->{serial} eq $serialids[$i]
|| ( $itemhash{$item}->{serial} == $newserial
&& $serialids[$i] eq 'NEW' )
) {
$index = $i
}
}
if ( $index >= 0 && $status[$index] == 2 ) {
my $xml = TransformHtmlToXml(
$itemhash{$item}->{'tags'},
$itemhash{$item}->{'subfields'},
$itemhash{$item}->{'field_values'},
$itemhash{$item}->{'indicator'},
$itemhash{$item}->{'ind_tag'}
);
# warn $xml;
my $bib_record = MARC::Record::new_from_xml( $xml, 'UTF-8' );
if ( $item =~ /^N/ ) {
#New Item
# if autoBarcode is set to 'incremental', calculate barcode...
my ( $barcodetagfield, $barcodetagsubfield ) =
GetMarcFromKohaField(
'items.barcode',
GetFrameworkCode(
$serialdatalist[0]->{'biblionumber'}
)
);
if ( C4::Context->preference("autoBarcode") eq
'incremental' )
{
if ( !$bib_record->field($barcodetagfield)
->subfield($barcodetagsubfield) )
{
my $sth_barcode = $dbh->prepare(
"select max(abs(barcode)) from items");
$sth_barcode->execute;
my ($newbarcode) = $sth_barcode->fetchrow;
# OK, we have the new barcode, add the entry in MARC record # FIXME -> should be using barcode plugin here.
$bib_record->field($barcodetagfield)
->update( $barcodetagsubfield => ++$newbarcode );
}
}
# check for item barcode # being unique
my $exists;
if (
$bib_record->subfield(
$barcodetagfield, $barcodetagsubfield
)
)
{
$exists = GetItemnumberFromBarcode(
$bib_record->subfield(
$barcodetagfield, $barcodetagsubfield
)
);
}
# push @errors,"barcode_not_unique" if($exists);
# if barcode exists, don't create, but report The problem.
if ($exists) {
push @errors, 'barcode_not_unique';
push @errseq, { serialseq => $serialseqs[$index] };
}
else {
my ( $biblionumber, $bibitemnum, $itemnumber ) =
AddItemFromMarc( $bib_record,
$itemhash{$item}->{bibnum} );
AddItem2Serial( $itemhash{$item}->{serial},
$itemnumber );
}
}
else {
#modify item
my ( $oldbiblionumber, $oldbibnum, $itemnumber ) =
ModItemFromMarc( $bib_record,
$itemhash{$item}->{'bibnum'}, $item );
}
}
}
}
if ( @errors ) {
$template->param( Errors => 1 );
if ( @errseq ) {
$template->param( barcode_not_unique => 1, errseq => \@errseq );
}
}
else {
my $redirect = "serials-collection.pl?";
$redirect .= join( '&', map { "subscriptionid=" . $_ } sort @subscriptionids );# ID The sort necessary
print $query->redirect($redirect);
}
}
my $default_bib_view = get_default_view();
$template->param(
serialsadditems => $serialdatalist[0]->{'serialsadditems'},
biblionumber => $serialdatalist[0]->{'biblionumber'},
serialslist => \@serialdatalist,
bibliotitle => $bibdata->{'title'},
biblionumber => $serialdatalist[0]->{'biblionumber'},
serialslist => \@serialdatalist,
default_bib_view => $default_bib_view,
);
output_html_with_http_headers $query, $cookie, $template->output;
sub get_default_view {
my $defaultview = C4::Context->preference('IntranetBiblioDefaultView');
my $views = { C4::Search::enabled_staff_search_views };
if ($defaultview eq 'isbd' && $views->{can_view_ISBD}) {
return 'ISBDdetail';
} elsif ($defaultview eq 'marc' && $views->{can_view_MARC}) {
return 'MARCdetail';
} elsif ($defaultview eq 'labeled_marc' && $views->{can_view_labeledMARC}) {
return 'labeledMARCdetail';
} else {
return 'detail';
}
}

View file

@ -11,9 +11,9 @@
# 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
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use strict;

View file

@ -11,9 +11,9 @@
# 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
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use strict;
use warnings;

View file

@ -11,9 +11,9 @@
# 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
# You should have received a copy of the GNU General Public License along
# with Koha; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
use strict;
use warnings;
@ -101,6 +101,7 @@ if (! $subs->{dow}) {
if (! $subs->{periodicity}) {
$subs->{periodicity} = '0';
}
my $default_bib_view = get_default_view();
$template->param(
subscriptionid => $subscriptionid,
serialslist => \@serialslist,
@ -118,6 +119,21 @@ $template->param(
intranetstylesheet => C4::Context->preference('intranetstylesheet'),
intranetcolorstylesheet => C4::Context->preference('intranetcolorstylesheet'),
irregular_issues => scalar @irregular_issues,
default_bib_view => $default_bib_view,
);
output_html_with_http_headers $query, $cookie, $template->output;
sub get_default_view {
my $defaultview = C4::Context->preference('IntranetBiblioDefaultView');
my $views = { C4::Search::enabled_staff_search_views };
if ($defaultview eq 'isbd' && $views->{can_view_ISBD}) {
return 'ISBDdetail';
} elsif ($defaultview eq 'marc' && $views->{can_view_MARC}) {
return 'MARCdetail';
} elsif ($defaultview eq 'labeled_marc' && $views->{can_view_labeledMARC}) {
return 'labeledMARCdetail';
} else {
return 'detail';
}
}

8
t/Serials.t Normal file
View file

@ -0,0 +1,8 @@
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 1;
use_ok('C4::Serials');