X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=serials%2Fsubscription-add.pl;h=b17fc608d0a692fd12e8c5a2f4c2be9c903c3101;hb=afd2418d7387dc2a50835128e24840686600ef4b;hp=a3e57a4627294ef526d33742dee8b3461eb36c94;hpb=48b0472a633251525820ab2c18f5ee3c7e49778b;p=koha-ffzg.git diff --git a/serials/subscription-add.pl b/serials/subscription-add.pl index a3e57a4627..b17fc608d0 100755 --- a/serials/subscription-add.pl +++ b/serials/subscription-add.pl @@ -69,7 +69,8 @@ if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { my $subscriptionid = $query->param('subscriptionid'); $subs = GetSubscription($subscriptionid); -## FIXME : Check rights to edit if mod. Could/Should display an error message. + + ## FIXME : Check rights to edit if mod. Could/Should display an error message. if ($subs->{'cannotedit'} && $op eq 'modify'){ carp "Attempt to modify subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed"; print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid"); @@ -87,7 +88,6 @@ if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { if (!defined $subs->{letter}) { $subs->{letter}= q{}; } - letter_loop($subs->{'letter'}, $template); my $nextexpected = GetNextExpected($subscriptionid); $nextexpected->{'isfirstissue'} = $nextexpected->{planneddate} eq $firstissuedate ; $subs->{nextacquidate} = $nextexpected->{planneddate} if($op eq 'modify'); @@ -122,12 +122,20 @@ if ($op eq 'modify' || $op eq 'dup' || $op eq 'modsubscription') { my @fields_id = map { fieldid => $_ }, split '\|', $dont_copy_fields; $template->param( dont_export_field_loop => \@fields_id ); } + + my $letters = get_letter_loop( $subs->{letter} ); + $template->param( letterloop => $letters ); + } -my $onlymine=C4::Context->preference('IndependentBranches') && - C4::Context->userenv && - C4::Context->userenv->{flags} % 2 !=1 && - C4::Context->userenv->{branch}; +my $onlymine = + C4::Context->preference('IndependentBranches') + && C4::Context->userenv + && !C4::Context->IsSuperLibrarian + && ( + not C4::Auth::haspermission( C4::Context->userenv->{id}, { serials => 'superserials' } ) + ) + && C4::Context->userenv->{branch}; my $branches = GetBranches($onlymine); my $branchloop; for my $thisbranch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches}) { @@ -147,7 +155,8 @@ $template->param(branchloop => $branchloop, ); # prepare template variables common to all $op conditions: if ($op!~/^mod/) { - letter_loop(q{}, $template); + my $letters = get_letter_loop(); + $template->param( letterloop => $letters ); } if ($op eq 'addsubscription') { @@ -167,7 +176,10 @@ if ($op eq 'addsubscription') { } $template->param(subtype => \@sub_type_data); - letter_loop( '', $template ) if ($op ne 'modsubscription' && $op ne 'dup' && $op ne 'modify'); + if ( $op ne 'modsubscription' && $op ne 'dup' && $op ne 'modify' ) { + my $letters = get_letter_loop(); + $template->param( letterloop => $letters ); + } my $new_biblionumber = $query->param('biblionumber_for_new_subscription'); if (defined $new_biblionumber) { @@ -208,32 +220,30 @@ if ($op eq 'addsubscription') { } $template->param(numberpatterns => \@numberpatternloop); - # Get installed locales - # FIXME this will not work with all environments. - # If call to locale fails, @locales will be an empty array, which is fine. - my @locales = map { - chomp; - # we don't want POSIX and C locales - /^C|^POSIX$/ ? () : $_ - } `locale -a`; - $template->param(locales => \@locales); + my $languages = [ map { + { + language => $_->{iso639_2_code}, + description => $_->{language_description} || $_->{language} + } + } @{ C4::Languages::getAllLanguages() } ]; + + $template->param( locales => $languages ); output_html_with_http_headers $query, $cookie, $template->output; } -sub letter_loop { - my ($selected_letter, $templte) = @_; - my $letters = GetLetters('serial'); - my $letterloop; - foreach my $thisletter (keys %{$letters}) { - push @{$letterloop}, { - value => $thisletter, - selected => $thisletter eq $selected_letter, - lettername => $letters->{$thisletter}, - }; - } - $templte->param(letterloop => $letterloop); - return; +sub get_letter_loop { + my ($selected_lettercode) = @_; + my $letters = GetLetters({ module => 'serial' }); + return [ + map { + { + value => $_->{code}, + lettername => $_->{name}, + ( $_->{code} eq $selected_lettercode ? ( selected => 1 ) : () ), + } + } @$letters + ]; } sub _get_sub_length {