debug => 1,
});
-my $member=$input->param('bornum');
+my $borrowernumber=$input->param('borrowernumber');
my $actionType=$input->param('actionType') || '';
my $modify=$input->param('modify');
my $delete=$input->param('delete');
my $op=$input->param('op');
my $categorycode=$input->param('categorycode');
+my $destination=$input->param('destination');
+
+
my $nok;
# if a add or modify is requested => check validity of data.
} else {
#check cardnumber is valid
my $nounique;
- if ( $data{'actionType'} eq "Add" ) {
+ if ( $op eq "add" ) {
$nounique = 0;
} else {
$nounique = 1;
push @errors, "ERROR_invalid_cardnumber";
}
}
+
if ($data{'sex'} eq '' && $categorycode ne "I"){
push @errors, "ERROR_gender";
$nok=1;
push @errors,"ERROR_surname";
$nok=1;
}
- if ($data{'address'} eq ''){
+ if ($data{'streetaddress'} eq ''){
push @errors, "ERROR_address";
$nok=1;
}
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);
if (my $data2=$sth->fetchrow_hashref){
&modmember(%data);
}else{
- $data{borrowernumber} = &newmember(%data);
+ $borrowernumber = &newmember(%data);
+ }
+
+ if($destination eq "circ"){
+ print $input->redirect("/cgi-bin/koha/circ/circulation.pl?findborrower=$data{'cardnumber'}");
+ } else {
+ print $input->redirect("/cgi-bin/koha/members/moremember.pl?bornum=$borrowernumber");
}
- print $input->redirect("/cgi-bin/koha/members/moremember.pl?bornum=$data{'borrowernumber'}");
}
}
if ($delete){
- print $input->redirect("/cgi-bin/koha/deletemem.pl?member=$member");
+ 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);
$data->{$key}=$input->param($key);
}
} else {
- $data=borrdata('',$member);
+ $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');
my @select_branch;
my %select_branches;
my $branches=getbranches();
+ my $default;
foreach my $branch (keys %$branches) {
- push @select_branch, $branch;
- $select_branches{$branch} = $branches->{$branch}->{'branchname'};
+ if (C4::Context->preference("IndependantBranches")) {
+ my $userenv = C4::Context->userenv;
+ if ($userenv->{flags} == 1){
+ push @select_branch, $branch;
+ $select_branches{$branch} = $branches->{$branch}->{'branchname'};
+ $default = $data->{'branchcode'};
+ } else {
+ push @select_branch, $branch if ($branch eq $userenv->{branch});
+ $select_branches{$branch} = $branches->{$branch}->{'branchname'} if ($branch eq $userenv->{branch});
+ $default = $userenv->{branch};
+ }
+ } else {
+ push @select_branch, $branch;
+ $select_branches{$branch} = $branches->{$branch}->{'branchname'};
+ $default = $data->{'branchcode'};
+ }
}
+
my $CGIbranch=CGI::scrolling_list( -name => 'branchcode',
-id => 'branchcode',
-values => \@select_branch,
-labels => \%select_branches,
-size => 1,
-multiple => 0 );
+
+ my $CGIsort1 = buildCGIsort("Bsort1","sort1",$data->{'sort1'});
+ if ($CGIsort1) {
+ $template->param(CGIsort1 => $CGIsort1);
+ } else {
+ $template->param( sort1 => $data->{'sort1'});
+ }
+
+ my $CGIsort2 = buildCGIsort("Bsort2","sort2",$data->{'sort2'});
+ if ($CGIsort2) {
+ $template->param(CGIsort2 =>$CGIsort2);
+ } else {
+ $template->param( sort2 => $data->{'sort2'});
+ }
+
$template->param( actionType => $actionType,
- member => $member,
+ destination => $destination,
+ borrowernumber => $borrowernumber,
address => $data->{'streetaddress'},
firstname => $data->{'firstname'},
surname => $data->{'surname'},
initials => $data->{'initials'},
ethcatpopup => $ethcatpopup,
catcodepopup => $catcodepopup,
- streetaddress => $data->{'physstreet'},
+ streetaddress => $data->{'streetaddress'},
+ physstreet => $data->{'physstreet'},
zipcode => $data->{'zipcode'},
streetcity => $data->{'streetcity'},
homezipcode => $data->{'homezipcode'},
flagloop => \@flagdata,
relshiploop => \@relshipdata,
"title_".$data->{'title'} => " SELECTED ",
- dateenrolled => $data->{'dateenrolled'},
- expiry => $data->{'expiry'},
+ joining => format_date($data->{'dateenrolled'}),
+ expiry => format_date($data->{'expiry'}),
cardnumber => $cardnumber,
dateofbirth => $data->{'dateofbirth'},
- sort1 => $data->{'sort1'},
- sort2 => $data->{'sort2'},
dateformat => display_date_format(),
modify => $modify,
CGIbranch => $CGIbranch);