-
- $data{'opacnotes'} =~ s/\\//g;
- $data{'borrowernotes'} =~ s/\\//g;
-
- # increase step to see next page
- if ($nok) {
- foreach my $error (@errors) {
- $template->param( $error => 1);
- }
- $template->param(nok => 1);
- }
- else {
- $step++;
- }
-
- warn "CITY".$data{city};
- $template->param(
- BorrowerMandatoryField => C4::Context->preference("BorrowerMandatoryField"),#field to test with javascript
- category_type => $category_type,#to know the category type of the borrower
- select_city => $select_city,
- "step_$step" => 1,# associate with step to know where u are
- step => $step,
- destination => $destination,#to know wher u come from and wher u must go in redirect
- check_member => $check_member,#to know if the borrower already exist(=>1) or not (=>0)
-# flags =>$data{'flags'},
- "op$op" => 1,
-# op => $op,
- nodouble => $nodouble,
- borrowerid => $borrowerid,#register number
- cardnumber => $data{'cardnumber'},
- surname => uc($data{'surname'}),
- firstname => ucfirst($data{'firstname'}),
- "title_".$data{'title'} => " SELECTED ",
- title => $data{'title'},
- othernames => $data{'othernames'},
- initials => $data{'initials'},
- streetnumber => $data{'streetnumber'},
- streettype =>$data{'streettype'},
- address => $data{'address'},
- address2 => $data{'address2'},
- city => $data{'city'},
- zipcode => $data{'zipcode'},
- email => $data{'email'},
- phone => $data{'phone'},
- mobile => $data{'mobile'},
- fax => $data{'fax'},
- phonepro => $data{'phonepro'},
- emailpro => $data{'emailpro'},
- b_address => $data{'b_address'},
- b_city => $data{'b_city'},
- b_zipcode => $data{'b_zipcode'},
- b_email => $data{'b_email'},
- b_phone => $data{'b_phone'},
- dateofbirth => $data{'dateofbirth'},
- branchcode => $data{'branchcode'},
- catcodepopup => $catcodepopup,
- categorycode => $data{'categorycode'},
- dateenrolled => format_date($data{'dateenrolled'}),
- dateexpiry => format_date($data{'dateexpiry'}),
- debarred => $data{'debarred'},
- gonenoaddress => $data{'gonenoaddress'},
- lost => $data{'lost'},
- contactname => uc($data{'contactname'}),
- contactfirstname=> ucfirst($data{'contactfirstname'}),
- "contacttitle_".$data{'contacttitle'} => "SELECTED" ,
- contacttitle => $data{'contacttitle'},
- guarantorid => $guarantorid,
- ethcatpopup => $ethcatpopup,
- sex => $data{'sex'},
- login => $data{'login'},
- password => $data{'password'},
- opacnotes => $data{'opacnotes'},
- contactnotes => $data{'contactnotes'},
- borrowernotes => $data{'borrowernotes'},
- relshiploop => \@relshipdata,
- relationship => $data{'relationship'},
- citypopup => $citypopup,
- roadpopup => $roadpopup,
- contacttype => $data{'contacttype'},
- organisations => $data{'organisations'},
- flagloop => \@flagdata,
-# "contacttype_".$data{'contacttype'} =>" SELECTED ",
- dateformat => display_date_format(),
- check_categorytype =>$check_categorytype,#to recover the category type with checkcategorytype function
- modify => $modify,
-# city_choice => $city_choice ,#check if the city was selected
- nok => $nok,#flag to konw if an error
- CGIbranch => $CGIbranch,
- memberofinstution => $member_of_institution,
- CGIorganisations => $CGIorganisations,
- );
- #$template->param(Institution => 1) if ($categorycode eq "I");
- output_html_with_http_headers $input, $cookie, $template->output;
+my $onlymine=(C4::Context->preference('IndependantBranches') &&
+ C4::Context->userenv &&
+ C4::Context->userenv->{flags} !=1 &&
+ C4::Context->userenv->{branch}?1:0);
+
+my $branches=GetBranches($onlymine);
+my $default;
+
+foreach my $branch (sort keys %$branches) {
+ push @select_branch,$branch;
+ $select_branches{$branch} = $branches->{$branch}->{'branchname'};
+ $default = C4::Context->userenv->{'branch'} if (C4::Context->userenv && C4::Context->userenv->{'branch'});
+}
+# --------------------------------------------------------------------------------------------------------
+ #in modify mod :default value from $CGIbranch comes from borrowers table
+ #in add mod: default value come from branches table (ip correspendence)
+$default=$data{'branchcode'} if ($op eq 'modify');
+my $CGIbranch = CGI::scrolling_list(-id => 'branchcode',
+ -name => 'branchcode',
+ -values => \@select_branch,
+ -labels => \%select_branches,
+ -size => 1,
+ -override => 1,
+ -multiple =>0,
+ -default => $default,
+ );
+my $CGIorganisations;
+my $member_of_institution;
+if (C4::Context->preference("memberofinstitution")){
+ my $organisations=get_institutions();
+ my @orgs;
+ my %org_labels;
+ foreach my $organisation (keys %$organisations) {
+ push @orgs,$organisation;
+ $org_labels{$organisation}=$organisations->{$organisation}->{'surname'};
+ }
+ $member_of_institution=1;
+
+ $CGIorganisations = CGI::scrolling_list( -id => 'organisations',
+ -name => 'organisations',
+ -labels => \%org_labels,
+ -values => \@orgs,
+ -size => 5,
+ -multiple => 'true'
+
+ );