X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=serials%2Fserials-edit.pl;h=309527ea4addb00416ea599227b9d14b1c21304c;hb=e8b2f04638ca4bcccf85d53f8c540c43b7615716;hp=5c87851a324d36d40144796c116eba8f6d70e110;hpb=ba6c8485ca7afdaaace20d021591ac532de55b3a;p=koha.git diff --git a/serials/serials-edit.pl b/serials/serials-edit.pl index 5c87851a32..309527ea4a 100755 --- a/serials/serials-edit.pl +++ b/serials/serials-edit.pl @@ -5,18 +5,18 @@ # # 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 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 3 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. +# 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. +# You should have received a copy of the GNU General Public License +# along with Koha; if not, see . =head1 NAME @@ -63,9 +63,9 @@ op can be : use strict; use warnings; -use CGI; +use CGI qw ( -utf8 ); +use Encode qw( decode is_utf8 ); use C4::Auth; -use C4::Dates qw/format_date format_date_in_iso/; use C4::Biblio; use C4::Items; use C4::Koha; @@ -73,6 +73,8 @@ use C4::Output; use C4::Context; use C4::Serials; use C4::Search qw/enabled_staff_search_views/; +use Koha::DateUtils; + use List::MoreUtils qw/uniq/; my $query = CGI->new(); @@ -81,6 +83,7 @@ my @serialids = $query->param('serialid'); my @serialseqs = $query->param('serialseq'); my @planneddates = $query->param('planneddate'); my @publisheddates = $query->param('publisheddate'); +my @publisheddatetexts = $query->param('publisheddatetext'); my @status = $query->param('status'); my @notes = $query->param('notes'); my @subscriptionids = $query->param('subscriptionid'); @@ -94,9 +97,10 @@ my @errseq; # If user comes from subscription details unless (@serialids) { my $serstatus = $query->param('serstatus'); + my @statuses = split ',', $serstatus; if ($serstatus) { foreach my $subscriptionid (@subscriptionids) { - my @tmpser = GetSerials2( $subscriptionid, $serstatus ); + my @tmpser = GetSerials2( $subscriptionid, \@statuses ); push @serialids, map { $_->{serialid} } @tmpser; } } @@ -112,7 +116,7 @@ unless ( @serialids ) { my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { - template_name => 'serials/serials-edit.tmpl', + template_name => 'serials/serials-edit.tt', query => $query, type => 'intranet', authnotrequired => 0, @@ -124,7 +128,8 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( my @serialdatalist; my %processedserialid; -my $today = C4::Dates->new(); +my $today = output_pref( { dt => dt_from_string, dateonly => 1 } ); + foreach my $serialid (@serialids) { #filtering serialid for duplication @@ -134,15 +139,16 @@ foreach my $serialid (@serialids) { && !$processedserialid{$serialid} ) { 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->{$d} = output_pref( { dt => dt_from_string( $serinfo->{$d} ), dateonly => 1 } ); } } - $serinfo->{arriveddate}=$today->output('syspref'); + $serinfo->{arriveddate} = $today; $serinfo->{'editdisable'} = ( ( @@ -151,6 +157,8 @@ foreach my $serialid (@serialids) { ) || $serinfo->{'cannotedit'} ); + $serinfo->{editdisable} = 0 if C4::Auth::haspermission( C4::Context->userenv->{id}, { serials => 'receive_serials' } ); + $serinfo->{editdisable} ||= ($serinfo->{status8} and $serinfo->{closed}); push @serialdatalist, $serinfo; $processedserialid{$serialid} = 1; } @@ -181,7 +189,7 @@ foreach my $subscriptionid (@subscriptionids) { $cell->{'itemid'} = 'NNEW'; $cell->{'serialid'} = 'NEW'; $cell->{'issuesatonce'} = 1; - $cell->{arriveddate}=$today->output('syspref'); + $cell->{arriveddate} = $today; push @newserialloop, $cell; push @subscriptionloop, @@ -200,7 +208,7 @@ if ( $op and $op eq 'serialchangestatus' ) { # Convert serialseqs to UTF-8 to prevent encoding problems foreach my $seq (@serialseqs) { - utf8::decode($seq) unless utf8::is_utf8($seq); + $seq = Encode::decode('UTF-8', $seq) unless Encode::is_utf8($seq); } my $newserial; @@ -208,10 +216,10 @@ if ( $op and $op eq 'serialchangestatus' ) { my ($plan_date, $pub_date); if (defined $planneddates[$i] && $planneddates[$i] ne 'XXX') { - $plan_date = format_date_in_iso( $planneddates[$i] ); + $plan_date = eval { output_pref( { dt => dt_from_string( $planneddates[$i] ), dateonly => 1, dateformat => 'iso' } ); }; } if (defined $publisheddates[$i] && $publisheddates[$i] ne 'XXX') { - $pub_date = format_date_in_iso( $publisheddates[$i] ); + $pub_date = eval { output_pref( { dt => dt_from_string( $publisheddates[$i] ), dateonly => 1, dateformat => 'iso' } ); }; } if ( $serialids[$i] && $serialids[$i] eq 'NEW' ) { @@ -226,6 +234,7 @@ if ( $op and $op eq 'serialchangestatus' ) { $status[$i], $plan_date, $pub_date, + $publisheddatetexts[$i], $notes[$i] ); } @@ -236,6 +245,7 @@ if ( $op and $op eq 'serialchangestatus' ) { $serialseqs[$i], $plan_date, $pub_date, + $publisheddatetexts[$i], $status[$i], $notes[$i] ); @@ -317,8 +327,12 @@ if ( $op and $op eq 'serialchangestatus' ) { if ( C4::Context->preference('autoBarcode') eq 'incremental' ) { - if ( !$bib_record->field($barcodetagfield) - ->subfield($barcodetagsubfield) ) + if ( + !( + $bib_record->field($barcodetagfield) + && $bib_record->field($barcodetagfield)->subfield($barcodetagsubfield) + ) + ) { my $sth_barcode = $dbh->prepare( 'select max(abs(barcode)) from items'); @@ -394,11 +408,14 @@ my $default_bib_view = get_default_view(); $template->param( serialsadditems => $serialdatalist[0]->{'serialsadditems'}, callnumber => $serialdatalist[0]->{'callnumber'}, + internalnotes => $serialdatalist[0]->{'internalnotes'}, bibliotitle => $biblio->{'title'}, biblionumber => $serialdatalist[0]->{'biblionumber'}, serialslist => \@serialdatalist, default_bib_view => $default_bib_view, location => $locationlib, + (uc(C4::Context->preference("marcflavour"))) => 1 + ); output_html_with_http_headers $query, $cookie, $template->output;