3 # Copyright 2006 SAN OUEST PROVENCE et Paul POULAIN
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 2 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with
17 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
18 # Suite 330, Boston, MA 02111-1307 USA
26 # use Digest::MD5 qw(md5_base64);
33 use C4::Members::Attributes;
34 use C4::Members::AttributeTypes;
36 use C4::Dates qw/format_date format_date_in_iso/;
40 use C4::Branch; # GetBranches
45 $debug = $ENV{DEBUG} || 0;
49 ($debug) or $debug = $input->param('debug') || 0;
52 my $dbh = C4::Context->dbh;
54 my ($template, $loggedinuser, $cookie)
55 = get_template_and_user({template_name => "members/memberentrygen.tmpl",
59 flagsrequired => {borrowers => 1},
60 debug => ($debug) ? 1 : 0,
62 my $guarantorid = $input->param('guarantorid');
63 my $borrowernumber = $input->param('borrowernumber');
64 my $actionType = $input->param('actionType') || '';
65 my $modify = $input->param('modify');
66 my $delete = $input->param('delete');
67 my $op = $input->param('op');
68 my $destination = $input->param('destination');
69 my $cardnumber = $input->param('cardnumber');
70 my $check_member = $input->param('check_member');
71 my $name_city = $input->param('name_city');
72 my $nodouble = $input->param('nodouble')||$op eq 'modify';
73 my $select_city = $input->param('select_city');
74 my $nok = $input->param('nok');
75 my $guarantorinfo = $input->param('guarantorinfo');
76 my $step = $input->param('step') || 0;
79 # $check_categorytype contains the value of duplicate borrowers category type to redirect in good template in step =2
80 my $check_categorytype=$input->param('check_categorytype');
81 # NOTE: Alert for ethnicity and ethnotes fields, they are invalid in all borrowers form
84 my $userenv = C4::Context->userenv;
86 $template->param("uppercasesurnames" => C4::Context->preference('uppercasesurnames'));
88 my $minpw = C4::Context->preference('minPasswordLength');
89 $template->param("minPasswordLength" => $minpw);
91 # function to designate mandatory fields (visually with css)
92 my $check_BorrowerMandatoryField=C4::Context->preference("BorrowerMandatoryField");
93 my @field_check=split(/\|/,$check_BorrowerMandatoryField);
94 foreach (@field_check) {
95 $template->param( "mandatory$_" => 1);
97 $template->param("add"=>1) if ($op eq 'add');
98 $template->param("checked" => 1) if (defined($nodouble) && $nodouble eq 1);
99 ($borrower_data = GetMember($borrowernumber,'borrowernumber')) if ($op eq 'modify' or $op eq 'save');
100 my $categorycode = $input->param('categorycode') || $borrower_data->{'categorycode'};
101 my $category_type = $input->param('category_type');
102 my $new_c_type = $category_type; #if we have input param, then we've already chosen the cat_type.
103 unless ($category_type or !($categorycode)){
104 my $borrowercategory = GetBorrowercategory($categorycode);
105 $category_type = $borrowercategory->{'category_type'};
106 my $category_name = $borrowercategory->{'description'};
107 $template->param("categoryname"=>$category_name);
109 $category_type="A" unless $category_type; # FIXME we should display a error message instead of a 500 error !
111 # if a add or modify is requested => check validity of data.
112 %data = %$borrower_data if ($borrower_data);
114 my %newdata; # comes from $input->param()
115 if ($op eq 'insert' || $op eq 'modify' || $op eq 'save') {
116 my @names= ($borrower_data && $op ne 'save') ? keys %$borrower_data : $input->param();
117 foreach my $key (@names) {
118 if (defined $input->param($key)) {
119 $newdata{$key} = $input->param($key);
120 $newdata{$key} =~ s/\"/"/g unless $key eq 'borrowernotes' or $key eq 'opacnote';
123 my $dateobject = C4::Dates->new();
124 my $syspref = $dateobject->regexp(); # same syspref format for all 3 dates
125 my $iso = $dateobject->regexp('iso'); #
126 foreach (qw(dateenrolled dateexpiry dateofbirth)) {
127 my $userdate = $newdata{$_} or next;
128 if ($userdate =~ /$syspref/) {
129 $newdata{$_} = format_date_in_iso($userdate); # if they match syspref format, then convert to ISO
130 } elsif ($userdate =~ /$iso/) {
131 warn "Date $_ ($userdate) is already in ISO format";
133 ($userdate eq '0000-00-00') and warn "Data error: $_ is '0000-00-00'";
134 $template->param( "ERROR_$_" => 1 ); # else ERROR!
135 push(@errors,"ERROR_$_");
138 # check permission to modify login info.
139 if (ref($borrower_data) && ($borrower_data->{'category_type'} eq 'S') && ! (C4::Auth::haspermission($userenv->{'id'},{'staffaccess'=>1})) ) {
144 #############test for member being unique #############
145 if (($op eq 'insert') and !$nodouble){
146 my $category_type_send=$category_type if ($category_type eq 'I');
147 my $check_category; # recover the category code of the doublon suspect borrowers
148 # ($result,$categorycode) = checkuniquemember($collectivity,$surname,$firstname,$dateofbirth)
149 ($check_member,$check_category) = checkuniquemember(
151 ($newdata{surname} ? $newdata{surname} : $data{surname} ),
152 ($newdata{firstname} ? $newdata{firstname} : $data{firstname} ),
153 ($newdata{dateofbirth} ? $newdata{dateofbirth} : $data{dateofbirth})
158 # recover the category type if the borrowers is a doublon
159 if ($check_category) {
160 my $tmpborrowercategory=GetBorrowercategory($check_category);
161 $check_categorytype=$tmpborrowercategory->{'category_type'};
165 #recover all data from guarantor address phone ,fax...
166 if ( defined($guarantorid) and
167 ( $category_type eq 'C' || $category_type eq 'P' ) and
168 $guarantorid ne '' and
169 $guarantorid ne '0' ) {
170 if (my $guarantordata=GetMember($guarantorid)) {
171 $guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'};
172 if ( !defined($data{'contactname'}) or $data{'contactname'} eq '' or
173 $data{'contactname'} ne $guarantordata->{'surname'} ) {
174 $newdata{'contactfirstname'}= $guarantordata->{'firstname'};
175 $newdata{'contactname'} = $guarantordata->{'surname'};
176 $newdata{'contacttitle'} = $guarantordata->{'title'};
177 foreach (qw(streetnumber address streettype address2
178 zipcode city phone phonepro mobile fax email emailpro branchcode)) {
179 $newdata{$_} = $guarantordata->{$_};
185 ###############test to take the right zipcode and city name ##############
186 if (!defined($guarantorid) or $guarantorid eq '' or $guarantorid eq '0') {
187 # set only if parameter was passed from the form
188 $newdata{'city'} = $input->param('city') if defined($input->param('city'));
189 $newdata{'zipcode'} = $input->param('zipcode') if defined($input->param('zipcode'));
192 #builds default userid
193 if ( (defined $newdata{'userid'}) && ($newdata{'userid'} eq '')){
194 $newdata{'userid'} = Generate_Userid($borrowernumber, $newdata{'firstname'}, $newdata{'surname'});
197 $debug and warn join "\t", map {"$_: $newdata{$_}"} qw(dateofbirth dateenrolled dateexpiry);
198 my $extended_patron_attributes = ();
199 if ($op eq 'save' || $op eq 'insert'){
200 if (checkcardnumber($newdata{cardnumber},$newdata{borrowernumber})){
201 push @errors, 'ERROR_cardnumber';
203 my $dateofbirthmandatory = (scalar grep {$_ eq "dateofbirth"} @field_check) ? 1 : 0;
204 if ($newdata{dateofbirth} && $dateofbirthmandatory) {
205 my $age = GetAge($newdata{dateofbirth});
206 my $borrowercategory=GetBorrowercategory($newdata{'categorycode'});
207 my ($low,$high) = ($borrowercategory->{'dateofbirthrequired'}, $borrowercategory->{'upperagelimit'});
208 if (($high && ($age > $high)) or ($age < $low)) {
209 push @errors, 'ERROR_age_limitations';
210 $template->param('ERROR_age_limitations' => "$low to $high");
213 if (C4::Context->preference("IndependantBranches")) {
214 if ($userenv && $userenv->{flags} != 1){
215 $debug and print STDERR " $newdata{'branchcode'} : ".$userenv->{flags}.":".$userenv->{branch};
216 unless (!$newdata{'branchcode'} || $userenv->{branch} eq $newdata{'branchcode'}){
217 push @errors, "ERROR_branch";
221 # Check if the userid is unique
222 unless (Check_Userid($newdata{'userid'},$borrowernumber)) {
223 push @errors, "ERROR_login_exist";
226 my $password = $input->param('password');
227 push @errors, "ERROR_short_password" if( $password && $minpw && $password ne '****' && (length($password) < $minpw) );
229 if (C4::Context->preference('ExtendedPatronAttributes')) {
230 $extended_patron_attributes = parse_extended_patron_attributes($input);
231 foreach my $attr (@$extended_patron_attributes) {
232 unless (C4::Members::Attributes::CheckUniqueness($attr->{code}, $attr->{value}, $borrowernumber)) {
233 push @errors, "ERROR_extended_unique_id_failed";
234 $template->param(ERROR_extended_unique_id_failed => "$attr->{code}/$attr->{value}");
240 if ($op eq 'modify' || $op eq 'insert' || $op eq 'save' ){
241 unless ($newdata{'dateexpiry'}){
242 my $arg2 = $newdata{'dateenrolled'} || C4::Dates->today('iso');
243 $newdata{'dateexpiry'} = GetExpiryDate($newdata{'categorycode'},$arg2);
247 ### Error checks should happen before this line.
248 $nok = $nok || scalar(@errors);
249 if ((!$nok) and $nodouble and ($op eq 'insert' or $op eq 'save')){
250 $debug and warn "$op dates: " . join "\t", map {"$_: $newdata{$_}"} qw(dateofbirth dateenrolled dateexpiry);
251 if ($op eq 'insert'){
252 # we know it's not a duplicate borrowernumber or there would already be an error
253 $borrowernumber = &AddMember(%newdata);
255 # If 'AutoEmailOpacUser' syspref is on, email user their account details from the 'notice' that matches the user's branchcode.
256 if ( C4::Context->preference("AutoEmailOpacUser") == 1 && $newdata{'userid'} && $newdata{'password'}) {
257 #look for defined primary email address, if blank - attempt to use borr.email and borr.emailpro instead
259 if (C4::Context->preference("AutoEmailPrimaryAddress") ne 'OFF' &&
260 $newdata{C4::Context->preference("AutoEmailPrimaryAddress")} =~ /\w\@\w/ ) {
261 $emailaddr = $newdata{C4::Context->preference("AutoEmailPrimaryAddress")}
263 elsif ($newdata{email} =~ /\w\@\w/) {
264 $emailaddr = $newdata{email}
266 elsif ($newdata{emailpro} =~ /\w\@\w/) {
267 $emailaddr = $newdata{emailpro}
269 elsif ($newdata{B_email} =~ /\w\@\w/) {
270 $emailaddr = $newdata{B_email}
272 # if we manage to find a valid email address, send notice
274 $newdata{emailaddr} = $emailaddr;
275 my $letter = getletter ('members', "ACCTDETAILS:$newdata{'branchcode'}") ;
276 # if $branch notice fails, then email a default notice instead.
277 $letter = getletter ('members', "ACCTDETAILS") if !$letter;
278 SendAlerts ( 'members' , \%newdata , $letter ) if $letter
282 if ($data{'organisations'}){
283 # need to add the members organisations
284 my @orgs=split(/\|/,$data{'organisations'});
285 add_member_orgs($borrowernumber,\@orgs);
287 if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) {
288 C4::Members::Attributes::SetBorrowerAttributes($borrowernumber, $extended_patron_attributes);
290 } elsif ($op eq 'save'){
291 if ($NoUpdateLogin) {
292 delete $newdata{'password'};
293 delete $newdata{'userid'};
295 &ModMember(%newdata);
296 if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) {
297 C4::Members::Attributes::SetBorrowerAttributes($borrowernumber, $extended_patron_attributes);
300 print scalar ($destination eq "circ") ?
301 $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber") :
302 $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber") ;
303 exit; # You can only send 1 redirect! After that, content or other headers don't matter.
307 print $input->redirect("/cgi-bin/koha/deletemem.pl?member=$borrowernumber");
308 exit; # same as above
311 if ($nok or !$nodouble){
312 $op="add" if ($op eq "insert");
313 $op="modify" if ($op eq "save");
315 $template->param( updtype => ($op eq 'add' ?'I':'M')); # used to check for $op eq "insert"... but we just changed $op!
317 $template->param( step_1 => 1,step_2 => 1,step_3 => 1, step_4 => 1);
320 if (C4::Context->preference("IndependantBranches")) {
321 my $userenv = C4::Context->userenv;
322 if ($userenv->{flags} != 1 && $data{branchcode}){
323 unless ($userenv->{branch} eq $data{'branchcode'}){
324 print $input->redirect("/cgi-bin/koha/members/members-home.pl");
330 my $arg2 = $newdata{'dateenrolled'} || C4::Dates->today('iso');
331 $data{'dateexpiry'} = GetExpiryDate($newdata{'categorycode'},$arg2);
332 $template->param( updtype => 'I', step_1=>1, step_2=>1, step_3=>1, step_4=>1);
334 if ($op eq "modify") {
335 $template->param( updtype => 'M',modify => 1 );
336 $template->param( step_1=>1, step_2=>1, step_3=>1, step_4=>1) unless $step;
338 # my $cardnumber=$data{'cardnumber'};
339 $data{'cardnumber'}=fixup_cardnumber($data{'cardnumber'}) if $op eq 'add';
340 if(!defined($data{'sex'})){
341 $template->param( none => 1);
342 } elsif($data{'sex'} eq 'F'){
343 $template->param( female => 1);
344 } elsif ($data{'sex'} eq 'M'){
345 $template->param( male => 1);
347 $template->param( none => 1);
350 ##Now all the data to modify a member.
351 my ($categories,$labels)=ethnicitycategories();
353 my $ethnicitycategoriescount=$#{$categories};
355 if ($ethnicitycategoriescount>=0) {
356 $ethcatpopup = CGI::popup_menu(-name=>'ethnicity',
359 -values=>$categories,
360 -default=>$data{'ethnicity'},
362 $template->param(ethcatpopup => $ethcatpopup); # bad style, has to be fixed
366 foreach (qw(C A S P I X)) {
367 my $action="WHERE category_type=?";
368 ($categories,$labels)=GetborCatFromCatType($_,$action);
370 foreach my $cat (@$categories){
371 push @categoryloop,{'categorycode' => $cat,
372 'categoryname' => $labels->{$cat},
373 'categorycodeselected' => ((defined($borrower_data->{'categorycode'}) &&
374 $cat eq $borrower_data->{'categorycode'})
375 || (defined($categorycode) && $cat eq $categorycode)),
379 $typehash{'typename'}=$_;
380 $typehash{'categoryloop'}=\@categoryloop;
381 push @typeloop,{'typename' => $_,
382 'categoryloop' => \@categoryloop};
384 $template->param('typeloop' => \@typeloop);
387 $select_city=getidcity($data{'city'}) if defined $guarantorid and ($guarantorid ne '0');
388 ($default_city=$select_city) if ($step eq 0);
389 if (!defined($select_city) or $select_city eq '' ){
390 $default_city = &getidcity($data{'city'});
393 ($cityid,$name_city)=GetCities();
394 $template->param( city_cgipopup => 1) if ($cityid );
395 my $citypopup = CGI::popup_menu(-name=>'select_city',
396 -id => 'select_city',
399 -default=>$default_city,
402 my $default_roadtype;
403 $default_roadtype=$data{'streettype'} ;
404 my($roadtypeid,$road_type)=GetRoadTypes();
405 $template->param( road_cgipopup => 1) if ($roadtypeid );
406 my $roadpopup = CGI::popup_menu(-name=>'streettype',
408 -values=>$roadtypeid,
411 -default=>$default_roadtype
414 my $default_borrowertitle;
415 $default_borrowertitle=$data{'title'} ;
416 my($borrowertitle)=GetTitles();
417 $template->param( title_cgipopup => 1) if ($borrowertitle);
418 my $borrotitlepopup = CGI::popup_menu(-name=>'title',
420 -values=>$borrowertitle,
422 -default=>$default_borrowertitle
425 my @relationships = split /,|\|/, C4::Context->preference('BorrowerRelationship');
427 while (@relationships) {
428 my $relship = shift @relationships || '';
429 my %row = ('relationship' => $relship);
430 if (defined($data{'relationship'}) and $data{'relationship'} eq $relship) {
431 $row{'selected'}=' selected';
435 push(@relshipdata, \%row);
438 my %flags = ( 'gonenoaddress' => ['gonenoaddress' ],
440 'debarred' => ['debarred']);
444 foreach (keys(%flags)) {
446 my %row = ('key' => $key,
447 'name' => $flags{$key}[0]);
449 $row{'yes'}=' checked';
454 $row{'no'}=' checked';
456 push @flagdata,\%row;
464 my $onlymine=(C4::Context->preference('IndependantBranches') &&
465 C4::Context->userenv &&
466 C4::Context->userenv->{flags} !=1 &&
467 C4::Context->userenv->{branch}?1:0);
469 my $branches=GetBranches($onlymine);
472 for my $branch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) {
473 push @select_branch,$branch;
474 $select_branches{$branch} = $branches->{$branch}->{'branchname'};
475 $default = C4::Context->userenv->{'branch'} if (C4::Context->userenv && C4::Context->userenv->{'branch'});
477 # --------------------------------------------------------------------------------------------------------
478 #in modify mod :default value from $CGIbranch comes from borrowers table
479 #in add mod: default value come from branches table (ip correspendence)
480 $default=$data{'branchcode'} if ($op eq 'modify' || ($op eq 'add' && $category_type eq 'C'));
481 my $CGIbranch = CGI::scrolling_list(-id => 'branchcode',
482 -name => 'branchcode',
483 -values => \@select_branch,
484 -labels => \%select_branches,
488 -default => $default,
490 my $CGIorganisations;
491 my $member_of_institution;
492 if (C4::Context->preference("memberofinstitution")){
493 my $organisations=get_institutions();
496 foreach my $organisation (keys %$organisations) {
497 push @orgs,$organisation;
498 $org_labels{$organisation}=$organisations->{$organisation}->{'surname'};
500 $member_of_institution=1;
502 $CGIorganisations = CGI::scrolling_list( -id => 'organisations',
503 -name => 'organisations',
504 -labels => \%org_labels,
512 # --------------------------------------------------------------------------------------------------------
514 my $CGIsort = buildCGIsort("Bsort1","sort1",$data{'sort1'});
516 $template->param(CGIsort1 => $CGIsort);
518 $template->param( sort1 => $data{'sort1'}); # shouldn't this be in an "else" statement like the 2nd one?
520 $CGIsort = buildCGIsort("Bsort2","sort2",$data{'sort2'});
522 $template->param(CGIsort2 => $CGIsort);
524 $template->param( sort2 => $data{'sort2'});
528 foreach my $error (@errors) {
529 $template->param($error) || $template->param( $error => 1);
531 $template->param(nok => 1);
534 #Formatting data for display
536 if (!defined($data{'dateenrolled'}) or $data{'dateenrolled'} eq ''){
537 $data{'dateenrolled'}=C4::Dates->today('iso');
539 if (C4::Context->preference('uppercasesurnames')) {
540 $data{'surname'} =uc($data{'surname'} );
541 $data{'contactname'}=uc($data{'contactname'});
543 foreach (qw(dateenrolled dateexpiry dateofbirth)) {
544 $data{$_} = format_date($data{$_}); # back to syspref for display
545 $template->param( $_ => $data{$_});
548 if (C4::Context->preference('ExtendedPatronAttributes')) {
549 $template->param(ExtendedPatronAttributes => 1);
550 patron_attributes_form($template, $borrowernumber);
553 $template->param( "showguarantor" => ($category_type=~/A|I|S|X/) ? 0 : 1); # associate with step to know where you are
554 $debug and warn "memberentry step: $step";
555 $template->param(%data);
556 $template->param( "step_$step" => 1) if $step; # associate with step to know where u are
557 $template->param( step => $step ) if $step; # associate with step to know where u are
558 $template->param( debug => $debug ) if $debug;
561 BorrowerMandatoryField => C4::Context->preference("BorrowerMandatoryField"),#field to test with javascript
562 category_type => $category_type,#to know the category type of the borrower
563 DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
564 select_city => $select_city,
565 "$category_type" => 1,# associate with step to know where u are
566 destination => $destination,#to know wher u come from and wher u must go in redirect
567 check_member => $check_member,#to know if the borrower already exist(=>1) or not (=>0)
571 nodouble => $nodouble,
572 borrowernumber => $borrowernumber, #register number
573 guarantorid => (defined($borrower_data->{'guarantorid'})) ? $borrower_data->{'guarantorid'} : $guarantorid,
574 ethcatpopup => $ethcatpopup,
575 relshiploop => \@relshipdata,
576 citypopup => $citypopup,
577 roadpopup => $roadpopup,
578 borrotitlepopup => $borrotitlepopup,
579 guarantorinfo => $guarantorinfo,
580 flagloop => \@flagdata,
581 dateformat => C4::Dates->new()->visual(),
582 C4::Context->preference('dateformat') => 1,
583 check_categorytype =>$check_categorytype,#to recover the category type with checkcategorytype function
585 nok => $nok,#flag to konw if an error
586 CGIbranch => $CGIbranch,
587 memberofinstution => $member_of_institution,
588 CGIorganisations => $CGIorganisations,
589 NoUpdateLogin => $NoUpdateLogin
592 if(defined($data{'flags'})){
593 $template->param(flags=>$data{'flags'});
595 if(defined($data{'contacttitle'})){
596 $template->param("contacttitle_" . $data{'contacttitle'} => "SELECTED");
600 output_html_with_http_headers $input, $cookie, $template->output;
602 sub parse_extended_patron_attributes {
604 my @patron_attr = grep { /^patron_attr_\d+$/ } $input->param();
608 foreach my $key (@patron_attr) {
609 my $value = $input->param($key);
610 next unless defined($value) and $value ne '';
611 my $password = $input->param("${key}_password");
612 my $code = $input->param("${key}_code");
613 next if exists $dups{$code}->{$value};
614 $dups{$code}->{$value} = 1;
615 push @attr, { code => $code, value => $value, password => $password };
620 sub patron_attributes_form {
621 my $template = shift;
622 my $borrowernumber = shift;
624 my @types = C4::Members::AttributeTypes::GetAttributeTypes();
625 if (scalar(@types) == 0) {
626 $template->param(no_patron_attribute_types => 1);
629 my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
631 # map patron's attributes into a more convenient structure
633 foreach my $attr (@$attributes) {
634 push @{ $attr_hash{$attr->{code}} }, $attr;
637 my @attribute_loop = ();
639 foreach my $type_code (map { $_->{code} } @types) {
640 my $attr_type = C4::Members::AttributeTypes->fetch($type_code);
642 code => $attr_type->code(),
643 description => $attr_type->description(),
644 repeatable => $attr_type->repeatable(),
645 password_allowed => $attr_type->password_allowed(),
646 category => $attr_type->authorised_value_category(),
649 if (exists $attr_hash{$attr_type->code()}) {
650 foreach my $attr (@{ $attr_hash{$attr_type->code()} }) {
651 my $newentry = { map { $_ => $entry->{$_} } %$entry };
652 $newentry->{value} = $attr->{value};
653 $newentry->{password} = $attr->{password};
654 $newentry->{use_dropdown} = 0;
655 if ($attr_type->authorised_value_category()) {
656 $newentry->{use_dropdown} = 1;
657 $newentry->{auth_val_loop} = GetAuthorisedValues($attr_type->authorised_value_category(), $attr->{value});
660 $newentry->{form_id} = "patron_attr_$i";
661 #use Data::Dumper; die Dumper($entry) if $entry->{use_dropdown};
662 push @attribute_loop, $newentry;
666 my $newentry = { map { $_ => $entry->{$_} } %$entry };
667 if ($attr_type->authorised_value_category()) {
668 $newentry->{use_dropdown} = 1;
669 $newentry->{auth_val_loop} = GetAuthorisedValues($attr_type->authorised_value_category());
671 $newentry->{form_id} = "patron_attr_$i";
672 push @attribute_loop, $newentry;
675 $template->param(patron_attributes => \@attribute_loop);