# in modify mod: userbranch value for GetBranchesLoop() comes from borrowers table
# in add mod: userbranch value come from branches table (ip correspondence)
-my $userbranch = C4::Context->userenv->{'branch'};
+my $userbranch = '';
+if (C4::Context->userenv && C4::Context->userenv->{'branch'}) {
+ $userbranch = C4::Context->userenv->{'branch'};
+}
+
if (defined ($data{'branchcode'}) and ( $op eq 'modify' || ( $op eq 'add' && $category_type eq 'C' ) )) {
$userbranch = $data{'branchcode'};
}
my ( $borr ) = GetMemberDetails( $borrowernumber );
# pass the pickup branch along....
- my $branch = $input->param('branch') || $borr->{'branchcode'} || C4::Context->userenv->{branch} || '' ;
+ my $userbranch = '';
+ if (C4::Context->userenv && C4::Context->userenv->{'branch'}) {
+ $userbranch = C4::Context->userenv->{'branch'};
+ }
+ my $branch = $input->param('branch') || $borr->{'branchcode'} || $userbranch || '' ;
# make branch selection options...
my $branchloop = GetBranchesLoop($branch);
=cut
sub set_parameters {
- my ($template) = @_;
- my $userbranch = C4::Context->userenv->{'branch'};
- $template->param( branchloop => GetBranchesLoop($userbranch) );
- return $template;
+ my ($template) = @_;
+ my $userbranch = '';
+ if (C4::Context->userenv && C4::Context->userenv->{'branch'}) {
+ $userbranch = C4::Context->userenv->{'branch'};
+ }
+ $template->param( branchloop => GetBranchesLoop($userbranch) );
+ return $template;
}
sub calculate {
my $branches = GetBranches();
my $itemtypes = GetItemTypes();
-my $userbranch = C4::Context->userenv->{branch};
+my $userbranch = '';
+if (C4::Context->userenv && C4::Context->userenv->{'branch'}) {
+ $userbranch = C4::Context->userenv->{'branch'};
+}
+
# Select borrowers infos
my $findborrower = $input->param('findborrower');