Bugzilla – Attachment 2381 Details for
Bug 5026
Undefined dates not formatted in serials update
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Updated fuller patch
0001-Bug-5026-Undefined-dates-formatted-poorly-in-serials.patch (text/plain), 9.25 KB, created by
Colin Campbell
on 2010-07-16 15:42:13 UTC
(
hide
)
Description:
Updated fuller patch
Filename:
MIME Type:
Creator:
Colin Campbell
Created:
2010-07-16 15:42:13 UTC
Size:
9.25 KB
patch
obsolete
>From 360b711f67db4df75add065f8b91304d2d0d980c Mon Sep 17 00:00:00 2001 >From: Colin Campbell <colin.campbell@ptfs-europe.com> >Date: Fri, 16 Jul 2010 14:14:06 +0100 >Subject: [PATCH] Bug 5026 Undefined dates formatted poorly in serials-edit >Content-Type: text/plain; charset="utf-8" > >Don't display junk in empty fields >Don't generate errors > >Merged some changes to make variable names moremeaningful >in loops ( within loops) >--- > C4/Serials.pm | 13 +++++- > serials/serials-edit.pl | 100 ++++++++++++++++++++++++++--------------------- > 2 files changed, 65 insertions(+), 48 deletions(-) > >diff --git a/C4/Serials.pm b/C4/Serials.pm >index 032246c..ddf20f7 100644 >--- a/C4/Serials.pm >+++ b/C4/Serials.pm >@@ -712,9 +712,16 @@ sub GetSerials2 { > my @serials; > > 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"} ); >- $line->{"publisheddate"} = format_date( $line->{"publisheddate"} ); >+ $line->{ "status" . $line->{status} } = 1; # fills a "statusX" value, used for template status select list >+ # Format dates for display >+ for my $datefield ( qw( planneddate publisheddate ) ) { >+ if ($line->{$datefield} =~m/^00/) { >+ $line->{$datefield} = q{}; >+ } >+ else { >+ $line->{"planneddate"} = format_date( $line->{$datefield} ); >+ } >+ } > push @serials, $line; > } > return @serials; >diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl >index dee624c..698ac8e 100755 >--- a/serials/serials-edit.pl >+++ b/serials/serials-edit.pl >@@ -90,33 +90,29 @@ my @errseq; > > # If user comes from subscription details > unless (@serialids) { >- foreach my $subscriptionid (@subscriptionids) { >- my $serstatus = $query->param('serstatus'); >- if ($serstatus) { >+ my $serstatus = $query->param('serstatus'); >+ if ($serstatus) { >+ foreach my $subscriptionid (@subscriptionids) { > my @tmpser = GetSerials2( $subscriptionid, $serstatus ); >- foreach (@tmpser) { >- push @serialids, $_->{'serialid'}; >- } >+ @serialids = map { $_->{serialid} } @tmpser; > } > } > } > >-unless ( scalar(@serialids) ) { >+unless ( @serialids ) { > my $string = >- "serials-collection.pl?subscriptionid=" . join( ",", @subscriptionids ); >- $string =~ s/,$//; >- >+ 'serials-collection.pl?subscriptionid=' . join ',', @subscriptionids; > 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 => 'receive_serials'}, >- debug => 1, >+ template_name => 'serials/serials-edit.tmpl', >+ query => $query, >+ type => 'intranet', >+ authnotrequired => 0, >+ flagsrequired => { serials => 1 }, >+ debug => 1, > } > ); > >@@ -124,30 +120,37 @@ my @serialdatalist; > my %processedserialid; > > my $today = C4::Dates->new(); >-foreach my $tmpserialid (@serialids) { >+foreach my $serialid (@serialids) { > > #filtering serialid for duplication > #NEW serial should appear only once and are created afterwards >- if ( defined($tmpserialid) >- && $tmpserialid =~ /^[0-9]+$/ >- && !$processedserialid{$tmpserialid} ) >+ if ( $serialid >+ && $serialid =~ /^[0-9]+$/ >+ && !$processedserialid{$serialid} ) > { >- my $data = GetSerialInformation($tmpserialid); >- $data->{publisheddate} = format_date( $data->{publisheddate} ); >- $data->{planneddate} = format_date( $data->{planneddate} ); >- $data->{arriveddate}=$today->output('syspref'); >- $data->{'editdisable'} = ( >+ my $serinfo = GetSerialInformation($serialid); #TODO duplicates work done by GetSerials2 above >+ for my $d ( qw( publisheddate planneddate )){ >+ if ( $serinfo->{$d} =~m/^00/ ) { >+ $serinfo->{$d} = q{}; >+ } >+ else { >+ $serinfo->{$d} = format_date( $serinfo->{$d} ); >+ } >+ } >+ $serinfo->{arriveddate}=$today->output('syspref'); >+ >+ $serinfo->{'editdisable'} = ( > ( >- HasSubscriptionExpired( $data->{subscriptionid} ) >- && $data->{'status1'} >+ HasSubscriptionExpired( $serinfo->{subscriptionid} ) >+ && $serinfo->{'status1'} > ) >- || $data->{'cannotedit'} >+ || $serinfo->{'cannotedit'} > ); >- push @serialdatalist, $data; >- $processedserialid{$tmpserialid} = 1; >+ push @serialdatalist, $serinfo; >+ $processedserialid{$serialid} = 1; > } > } >-my $bibdata = GetBiblioData( $serialdatalist[0]->{'biblionumber'} ); >+my $biblio = GetBiblioData( $serialdatalist[0]->{'biblionumber'} ); > > my @newserialloop; > my @subscriptionloop; >@@ -157,8 +160,7 @@ my %processedsubscriptionid; > foreach my $subscriptionid (@subscriptionids) { > > #Do not process subscriptionid twice if it was already processed. >- if ( defined($subscriptionid) >- && !$processedsubscriptionid{$subscriptionid} ) >+ if ( $subscriptionid && !$processedsubscriptionid{$subscriptionid} ) > { > my $cell; > if ( $serialdatalist[0]->{'serialsadditems'} ) { >@@ -170,8 +172,8 @@ foreach my $subscriptionid (@subscriptionids) { > $cell->{serialsadditems} = 1; > } > $cell->{'subscriptionid'} = $subscriptionid; >- $cell->{'itemid'} = "NNEW"; >- $cell->{'serialid'} = "NEW"; >+ $cell->{'itemid'} = 'NNEW'; >+ $cell->{'serialid'} = 'NEW'; > $cell->{'issuesatonce'} = 1; > push @newserialloop, $cell; > push @subscriptionloop, >@@ -190,8 +192,16 @@ if ( $op and $op eq 'serialchangestatus' ) { > > my $newserial; > for ( my $i = 0 ; $i <= $#serialids ; $i++ ) { >+ my ($plan_date, $pub_date); >+ >+ if (defined $planneddates[$i] && $planneddates[$i] ne 'XXX') { >+ $plan_date = format_date_in_iso( $planneddates[$i] ); >+ } >+ if (defined $publisheddates[$i] && $publisheddates[$i] ne 'XXX') { >+ $pub_date = format_date_in_iso( $publisheddates[$i] ); >+ } > >- if ( $serialids[$i] && $serialids[$i] eq "NEW" ) { >+ if ( $serialids[$i] && $serialids[$i] eq 'NEW' ) { > if ( $serialseqs[$i] ) { > > #IF newserial was provided a name Then we have to create a newSerial >@@ -201,8 +211,8 @@ if ( $op and $op eq 'serialchangestatus' ) { > $subscriptionids[$i], > $serialdatalist[0]->{'biblionumber'}, > $status[$i], >- format_date_in_iso( $planneddates[$i] ), >- format_date_in_iso( $publisheddates[$i] ), >+ $plan_date, >+ $pub_date, > $notes[$i] > ); > } >@@ -211,8 +221,8 @@ if ( $op and $op eq 'serialchangestatus' ) { > ModSerialStatus( > $serialids[$i], > $serialseqs[$i], >- format_date_in_iso( $planneddates[$i] ), >- format_date_in_iso( $publisheddates[$i] ), >+ $plan_date, >+ $pub_date, > $status[$i], > $notes[$i] > ); >@@ -291,14 +301,14 @@ if ( $op and $op eq 'serialchangestatus' ) { > $serialdatalist[0]->{'biblionumber'} > ) > ); >- if ( C4::Context->preference("autoBarcode") eq >+ 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"); >+ 'select max(abs(barcode)) from items'); > $sth_barcode->execute; > my ($newbarcode) = $sth_barcode->fetchrow; > >@@ -356,8 +366,8 @@ if ( $op and $op eq 'serialchangestatus' ) { > } > } > else { >- my $redirect = "serials-collection.pl?"; >- $redirect .= join( '&', map { "subscriptionid=" . $_ } sort @subscriptionids );# ID The sort necessary >+ my $redirect = 'serials-collection.pl?'; >+ $redirect .= join( '&', map { 'subscriptionid=' . $_ } @subscriptionids ); > print $query->redirect($redirect); > } > } >@@ -365,7 +375,7 @@ my $default_bib_view = get_default_view(); > > $template->param( > serialsadditems => $serialdatalist[0]->{'serialsadditems'}, >- bibliotitle => $bibdata->{'title'}, >+ bibliotitle => $biblio->{'title'}, > biblionumber => $serialdatalist[0]->{'biblionumber'}, > serialslist => \@serialdatalist, > default_bib_view => $default_bib_view, >-- >1.7.1.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 5026
:
2380
|
2381
|
2898
|
2984
|
2988