From 1de6fd157c8a5de54f3308c4b8a2a3a3dd73ed00 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Wed, 22 Aug 2012 14:35:37 +0200 Subject: [PATCH] Bug 8436: Add limit on branch in checkexpiration.pl This limit is only available for superlibrarians and patrons that have superserials permission. Other patrons will only see subscriptions of their branch. --- .../prog/en/modules/serials/checkexpiration.tt | 16 ++++++++ serials/checkexpiration.pl | 41 ++++++++++++++++++-- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt index f2b01a5..fe4d9e8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/checkexpiration.tt @@ -51,6 +51,22 @@
  • + [% IF (branches_loop.size) %] +
  • + +
  • + [% END %]
  • diff --git a/serials/checkexpiration.pl b/serials/checkexpiration.pl index bf4b6e9..d7b3f67 100755 --- a/serials/checkexpiration.pl +++ b/serials/checkexpiration.pl @@ -47,6 +47,7 @@ use warnings; use CGI; use C4::Auth; use C4::Serials; # GetExpirationDate +use C4::Branch; use C4::Output; use C4::Context; use C4::Dates qw/format_date format_date_in_iso/; @@ -54,7 +55,7 @@ use Date::Calc qw/Today Date_to_Days/; my $query = new CGI; -my ( $template, $loggedinuser, $cookie ) = get_template_and_user ( +my ( $template, $loggedinuser, $cookie, $flags ) = get_template_and_user ( { template_name => "serials/checkexpiration.tmpl", query => $query, @@ -67,6 +68,7 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user ( my $title = $query->param('title'); my $issn = $query->param('issn'); +my $branch = $query->param('branch'); my $date = format_date_in_iso($query->param('date')); if ($date) { @@ -76,11 +78,16 @@ if ($date) { foreach my $subscription ( @subscriptions ) { my $subscriptionid = $subscription->{'subscriptionid'}; my $expirationdate = GetExpirationDate($subscriptionid); - $subscription->{expirationdate} = $expirationdate; next if $expirationdate !~ /\d{4}-\d{2}-\d{2}/; # next if not in ISO format. + if ( ( ref $flags->{serials} and $flags->{serials}->{superserials} ) + or ( !ref $flags->{serials} and $flags->{serials} == 1 ) ) + { + $subscription->{cannotedit} = 0; + } if ( Date_to_Days(split "-",$expirationdate) < Date_to_Days(split "-",$date) && - Date_to_Days(split "-",$expirationdate) > Date_to_Days(&Today) ) { + Date_to_Days(split "-",$expirationdate) > Date_to_Days(&Today) && + ( !$branch || ($subscription->{'branchcode'} eq $branch) ) ) { $subscription->{expirationdate}=format_date($subscription->{expirationdate}); push @subscriptions_loop,$subscription; } @@ -95,8 +102,34 @@ if ($date) { "BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1, ); } + +my $branchname; +my @branches_loop; +if ( $flags->{superlibrarian} + or ( ref $flags->{serials} and $flags->{serials}->{superserials} ) + or ( !ref $flags->{serials} and $flags->{serials} == 1 ) ) +{ + my $branches = GetBranches(); + foreach my $b (sort keys %$branches) { + my $selected = 0; + if( $branch and $branch eq $b ){ + $selected = 1; + $branchname = $branches->{$b}->{branchname}; + } + push @branches_loop, { + branchcode => $b, + branchname => $branches->{$b}->{branchname}, + selected => $selected, + }; + } +} + $template->param ( DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(), - (uc(C4::Context->preference("marcflavour"))) => 1 + (uc(C4::Context->preference("marcflavour"))) => 1, + branches_loop => \@branches_loop, + branchcode => $branch, + branchname => $branchname, ); + output_html_with_http_headers $query, $cookie, $template->output; -- 1.7.10.4