From 8a87b560ac569b7f9503fa3e4aeed258526f1193 Mon Sep 17 00:00:00 2001 From: hdl Date: Fri, 29 Jul 2005 16:12:53 +0000 Subject: [PATCH] Fixing bug in deletemem.pl : flags verification was not good. Adding branch Independancy management. In memberentry.pl and deletemem.pl --- members/deletemem.pl | 14 +++++++++++++- members/memberentry.pl | 40 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/members/deletemem.pl b/members/deletemem.pl index cb8753bac0..2f0e1b33b7 100755 --- a/members/deletemem.pl +++ b/members/deletemem.pl @@ -38,7 +38,7 @@ use C4::Auth; my $input = new CGI; my $flagsrequired; -$flagsrequired->{borrower}=1; +$flagsrequired->{borrowers}=1; my ($loggedinuser, $cookie, $sessionID) = checkauth($input, 0, $flagsrequired); @@ -55,6 +55,18 @@ foreach (sort keys %$issues) { $i++; } my ($bor,$flags)=getpatroninformation(\%env, $member,''); + +if (C4::Context->preference("IndependantBranches")) { + my $userenv = C4::Context->userenv; + unless ($userenv->{flags} == 1){ + unless ($userenv->{'branch'} eq $bor->{'branchcode'}){ + warn "user ".$userenv->{'branch'} ."borrower :". $bor->{'branchcode'}; + print $input->redirect("/cgi-bin/koha/members/moremember.pl?bornum=$member"); + exit 1; + } + } +} + my $dbh = C4::Context->dbh; my $sth=$dbh->prepare("Select * from borrowers where guarantor=?"); $sth->execute($member); diff --git a/members/memberentry.pl b/members/memberentry.pl index 4ad7af21e5..62f2002f44 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -90,6 +90,7 @@ if ($op eq 'add' or $op eq 'modify') { push @errors, "ERROR_invalid_cardnumber"; } } + if ($data{'sex'} eq '' && $categorycode ne "I"){ push @errors, "ERROR_gender"; $nok=1; @@ -110,6 +111,15 @@ if ($op eq 'add' or $op eq 'modify') { push @errors, "ERROR_city"; $nok=1; } + if (C4::Context->preference("IndependantBranches")) { + my $userenv = C4::Context->userenv; + if ($userenv->{flags} == 1){ + unless ($userenv->{branch} eq $data{'branchcode'}){ + push @errors, "ERROR_branch"; + $nok=1; + } + } + } if ($nok) { foreach my $error (@errors) { $template->param( $error => 1); @@ -133,7 +143,25 @@ if ($op eq 'add' or $op eq 'modify') { } } if ($delete){ - print $input->redirect("/cgi-bin/koha/deletemem.pl?member=$borrowernumber"); + my @errors; + my $nok; + my $branch =$input->param('branchcode'); + if (C4::Context->preference("IndependantBranches")) { + my $userenv = C4::Context->userenv; + if ($userenv->{flags} == 1){ + if ($userenv->{branch} eq $branch){ + print $input->redirect("/cgi-bin/koha/deletemem.pl?member=$borrowernumber"); + } else { + push @errors, "ERROR_branch"; + $nok=1; + print $input->redirect("/cgi-bin/koha/members/moremember.pl?bornum=$borrowernumber"); + } + } else { + print $input->redirect("/cgi-bin/koha/deletemem.pl?member=$borrowernumber"); + } + } else { + print $input->redirect("/cgi-bin/koha/deletemem.pl?member=$borrowernumber"); + } } else { # this else goes down the whole script if ($actionType eq 'Add'){ $template->param( addAction => 1); @@ -150,6 +178,16 @@ if ($delete){ } else { $data=borrdata('',$borrowernumber); } + if (C4::Context->preference("IndependantBranches")) { + my $userenv = C4::Context->userenv; + unless ($userenv->{flags} == 1){ + warn "userenv=".$userenv->{'branch'}." member branch :".$data->{'branchcode'}; + unless ($userenv->{'branch'} eq $data->{'branchcode'}){ + print $input->redirect("/cgi-bin/koha/members/moremember.pl?bornum=$borrowernumber"); + exit 1; + } + } + } if ($actionType eq 'Add'){ $template->param( updtype => 'I'); } else { -- 2.39.5