$bibliotitle, $callnumber, $notes, $hemisphere, $letter, $manualhistory,$serialsadditems);
my @budgets;
+
+# Permission needed if it is a modification : edit_subscription
+# Permission needed otherwise (nothing or dup) : create_subscription
+my $permission = ($op eq "mod") ? "edit_subscription" : "create_subscription";
+
my ($template, $loggedinuser, $cookie)
= get_template_and_user({template_name => "serials/subscription-add.tmpl",
query => $query,
type => "intranet",
authnotrequired => 0,
- flagsrequired => {serials => 1},
+ flagsrequired => {serials => $permission},
debug => 1,
});
my $sub_on;
my @subscription_types = (
'issues', 'weeks', 'months'
- );
+ );
my @sub_type_data;
my $letters = GetLetters('serial');
if ($subs->{'cannotedit'} && $op eq 'mod'){
warn "Attempt to modify subscription $subscriptionid by ".C4::Context->userenv->{'id'}." not allowed";
print $query->redirect("/cgi-bin/koha/serials/subscription-detail.pl?subscriptionid=$subscriptionid");
- }
+ }
$firstissuedate = $subs->{firstacquidate}; # in iso format.
for (qw(startdate firstacquidate histstartdate enddate histenddate)) {
# TODO : Handle date formats properly.
if ($subs->{$_} eq '0000-00-00') {
$subs->{$_} = ''
} else {
- $subs->{$_} = format_date($subs->{$_});
+ $subs->{$_} = format_date($subs->{$_});
}
}
$subs->{'letter'}='' unless($subs->{'letter'});
last;
}
}
-
+
$template->param($subs);
$template->param(
$op => 1,
}
}
-my $onlymine=C4::Context->preference('IndependantBranches') &&
- C4::Context->userenv &&
- C4::Context->userenv->{flags}!=1 &&
+my $onlymine=C4::Context->preference('IndependantBranches') &&
+ C4::Context->userenv &&
+ C4::Context->userenv->{flags} % 2 !=1 &&
C4::Context->userenv->{branch};
my $branches = GetBranches($onlymine);
my @branchloop;
# if we have not received any issues yet, then we also must change the firstacquidate for the subs.
$firstissuedate = $nextacquidate if($nextexpected->{isfirstissue});
}
-
+
if ($history_only) {
ModSubscriptionHistory ($subscriptionid,$histstartdate,$histenddate,$recievedlist,$missinglist,$opacnote,$librariannote);
} else {
$row{'selected'} = '';
}
push( @sub_type_data, \%row );
- }
+ }
$template->param(subtype => \@sub_type_data,
);
}
output_html_with_http_headers $query, $cookie, $template->output;
}
+
+sub letter_loop {
+ my ($selected_letter, $template) = @_;
+ my $letters = GetLetters('serial');
+ my @letterloop;
+ foreach my $thisletter (keys %$letters) {
+ my $selected = $thisletter eq $selected_letter ? 1 : 0;
+ push @letterloop, {
+ value => $thisletter,
+ selected => $selected,
+ lettername => $letters->{$thisletter},
+ };
+ }
+ $template->param(letterloop => \@letterloop) if @letterloop;
+ return;
+}