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
22 # use warnings; # FIXME: really.
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');
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 ($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 $newdata{$key} = $input->param($key) if (defined $input->param($key));
119 $newdata{$key} =~ s/\"/"/gg unless $key eq 'borrowernotes' or $key eq 'opacnote';
121 my $dateobject = C4::Dates->new();
122 my $syspref = $dateobject->regexp(); # same syspref format for all 3 dates
123 my $iso = $dateobject->regexp('iso'); #
124 foreach (qw(dateenrolled dateexpiry dateofbirth)) {
125 my $userdate = $newdata{$_} or next;
126 if ($userdate =~ /$syspref/) {
127 $newdata{$_} = format_date_in_iso($userdate); # if they match syspref format, then convert to ISO
128 } elsif ($userdate =~ /$iso/) {
129 warn "Date $_ ($userdate) is already in ISO format";
131 ($userdate eq '0000-00-00') and warn "Data error: $_ is '0000-00-00'";
132 $template->param( "ERROR_$_" => 1 ); # else ERROR!
133 push(@errors,"ERROR_$_");
136 # check permission to modify login info.
137 if (ref($borrower_data) && ($borrower_data->{'category_type'} eq 'S') && ! (C4::Auth::haspermission($dbh,$userenv->{'id'},{'staffaccess'=>1})) ) {
142 #############test for member being unique #############
143 if ($op eq 'insert'){
144 my $category_type_send=$category_type if ($category_type eq 'I');
145 my $check_category; # recover the category code of the doublon suspect borrowers
146 # ($result,$categorycode) = checkuniquemember($collectivity,$surname,$firstname,$dateofbirth)
147 ($check_member,$check_category) = checkuniquemember(
149 ($newdata{surname} ? $newdata{surname} : $data{surname} ),
150 ($newdata{firstname} ? $newdata{firstname} : $data{firstname} ),
151 ($newdata{dateofbirth} ? $newdata{dateofbirth} : $data{dateofbirth})
154 # recover the category type if the borrowers is a doublon
155 if ($check_category) {
156 my $tmpborrowercategory=GetBorrowercategory($check_category);
157 $check_categorytype=$tmpborrowercategory->{'category_type'};
161 #recover all data from guarantor address phone ,fax...
162 if (($category_type eq 'C' || $category_type eq 'P') and $guarantorid ne '' ){
163 my $guarantordata=GetMember($guarantorid);
164 $guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'};
165 if (($data{'contactname'} eq '' or $data{'contactname'} ne $guarantordata->{'surname'})) {
166 $data{'contactfirstname'}= $guarantordata->{'firstname'};
167 $data{'contactname'} = $guarantordata->{'surname'};
168 $data{'contacttitle'} = $guarantordata->{'title'};
169 foreach (qw(streetnumber address streettype address2 zipcode city phone phonepro mobile fax email emailpro branchcode)) {
170 $data{$_} = $guarantordata->{$_};
175 ###############test to take the right zipcode and city name ##############
176 if ($guarantorid eq '') {
177 # set only if parameter was passed from the form
178 $newdata{'city'} = $input->param('city') if defined($input->param('city'));
179 $newdata{'zipcode'} = $input->param('zipcode') if defined($input->param('zipcode'));
182 #builds default userid
183 if ( (defined $newdata{'userid'}) && ($newdata{'userid'} eq '')){
184 $newdata{'userid'} = Generate_Userid($borrowernumber, $newdata{'firstname'}, $newdata{'surname'});
187 $debug and warn join "\t", map {"$_: $newdata{$_}"} qw(dateofbirth dateenrolled dateexpiry);
188 my $extended_patron_attributes = ();
189 if ($op eq 'save' || $op eq 'insert'){
190 if (checkcardnumber($newdata{cardnumber},$newdata{borrowernumber})){
191 push @errors, 'ERROR_cardnumber';
193 my $dateofbirthmandatory = (scalar grep {$_ eq "dateofbirth"} @field_check) ? 1 : 0;
194 if ($newdata{dateofbirth} && $dateofbirthmandatory) {
195 my $age = GetAge($newdata{dateofbirth});
196 my $borrowercategory=GetBorrowercategory($newdata{'categorycode'});
197 my ($low,$high) = ($borrowercategory->{'dateofbirthrequired'}, $borrowercategory->{'upperagelimit'});
198 if (($high && ($age > $high)) or ($age < $low)) {
199 push @errors, 'ERROR_age_limitations';
200 $template->param('ERROR_age_limitations' => "$low to $high");
203 if (C4::Context->preference("IndependantBranches")) {
204 if ($userenv && $userenv->{flags} != 1){
205 $debug and print STDERR " $newdata{'branchcode'} : ".$userenv->{flags}.":".$userenv->{branch};
206 unless (!$newdata{'branchcode'} || $userenv->{branch} eq $newdata{'branchcode'}){
207 push @errors, "ERROR_branch";
211 # Check if the userid is unique
212 unless (Check_Userid($newdata{'userid'},$borrowernumber)) {
213 push @errors, "ERROR_login_exist";
216 my $password = $input->param('password');
217 push @errors, "ERROR_short_password" if( $password && $minpw && $password ne '****' && (length($password) < $minpw) );
219 if (C4::Context->preference('ExtendedPatronAttributes')) {
220 $extended_patron_attributes = parse_extended_patron_attributes($input);
221 foreach my $attr (@$extended_patron_attributes) {
222 unless (C4::Members::Attributes::CheckUniqueness($attr->{code}, $attr->{value}, $borrowernumber)) {
223 push @errors, "ERROR_extended_unique_id_failed";
224 $template->param(ERROR_extended_unique_id_failed => "$attr->{code}/$attr->{value}");
230 if ($op eq 'modify' || $op eq 'insert' || $op eq 'save' ){
231 unless ($newdata{'dateexpiry'}){
232 my $arg2 = $newdata{'dateenrolled'} || C4::Dates->today('iso');
233 $newdata{'dateexpiry'} = GetExpiryDate($newdata{'categorycode'},$arg2);
237 ### Error checks should happen before this line.
239 $nok = $nok || scalar(@errors);
240 if ((!$nok) and ($op eq 'insert' or $op eq 'save')){
241 $debug and warn "$op dates: " . join "\t", map {"$_: $newdata{$_}"} qw(dateofbirth dateenrolled dateexpiry);
242 if ($op eq 'insert'){
243 # we know it's not a duplicate borrowernumber or there would already be an error
244 $borrowernumber = &AddMember(%newdata);
246 # If 'AutoEmailOpacUser' syspref is on, email user their account details from the 'notice' that matches the user's branchcode.
247 if ( C4::Context->preference("AutoEmailOpacUser") == 1 && $newdata{'userid'} && $newdata{'password'}) {
248 #look for defined primary email address, if blank - attempt to use borr.email and borr.emailpro instead
250 if (C4::Context->preference("AutoEmailPrimaryAddress") ne 'OFF' &&
251 $newdata{C4::Context->preference("AutoEmailPrimaryAddress")} =~ /\w\@\w/ ) {
252 $emailaddr = $newdata{C4::Context->preference("AutoEmailPrimaryAddress")}
254 elsif ($newdata{email} =~ /\w\@\w/) {
255 $emailaddr = $newdata{email}
257 elsif ($newdata{emailpro} =~ /\w\@\w/) {
258 $emailaddr = $newdata{emailpro}
260 elsif ($newdata{B_email} =~ /\w\@\w/) {
261 $emailaddr = $newdata{B_email}
263 # if we manage to find a valid email address, send notice
265 $newdata{emailaddr} = $emailaddr;
266 my $letter = getletter ('members', "ACCTDETAILS:$newdata{'branchcode'}") ;
267 # if $branch notice fails, then email a default notice instead.
268 $letter = getletter ('members', "ACCTDETAILS") if !$letter;
269 SendAlerts ( 'members' , \%newdata , $letter ) if $letter
273 if ($data{'organisations'}){
274 # need to add the members organisations
275 my @orgs=split(/\|/,$data{'organisations'});
276 add_member_orgs($borrowernumber,\@orgs);
278 if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) {
279 C4::Members::Attributes::SetBorrowerAttributes($borrowernumber, $extended_patron_attributes);
281 } elsif ($op eq 'save'){
282 if ($NoUpdateLogin) {
283 delete $newdata{'password'};
284 delete $newdata{'userid'};
286 &ModMember(%newdata);
287 if (C4::Context->preference('ExtendedPatronAttributes') and $input->param('setting_extended_patron_attributes')) {
288 C4::Members::Attributes::SetBorrowerAttributes($borrowernumber, $extended_patron_attributes);
291 print scalar ($destination eq "circ") ?
292 $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber") :
293 $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrowernumber") ;
294 exit; # You can only send 1 redirect! After that, content or other headers don't matter.
298 print $input->redirect("/cgi-bin/koha/deletemem.pl?member=$borrowernumber");
299 exit; # same as above
303 $op="add" if ($op eq "insert");
304 $op="modify" if ($op eq "save");
306 $template->param( updtype => ($op eq 'add' ?'I':'M')); # used to check for $op eq "insert"... but we just changed $op!
308 $template->param( step_1 => 1,step_2 => 1,step_3 => 1, step_4 => 1);
311 if (C4::Context->preference("IndependantBranches")) {
312 my $userenv = C4::Context->userenv;
313 if ($userenv->{flags} != 1 && $data{branchcode}){
314 unless ($userenv->{branch} eq $data{'branchcode'}){
315 print $input->redirect("/cgi-bin/koha/members/members-home.pl");
321 my $arg2 = $newdata{'dateenrolled'} || C4::Dates->today('iso');
322 $data{'dateexpiry'} = GetExpiryDate($newdata{'categorycode'},$arg2);
323 $template->param( updtype => 'I', step_1=>1, step_2=>1, step_3=>1, step_4=>1);
325 if ($op eq "modify") {
326 $template->param( updtype => 'M',modify => 1 );
327 $template->param( step_1=>1, step_2=>1, step_3=>1, step_4=>1) unless $step;
329 # my $cardnumber=$data{'cardnumber'};
330 $data{'cardnumber'}=fixup_cardnumber($data{'cardnumber'}) if $op eq 'add';
331 if ($data{'sex'} eq 'F'){
332 $template->param(female => 1);
333 } elsif ($data{'sex'} eq 'M'){
334 $template->param( male => 1);
336 $template->param( none => 1);
339 ##Now all the data to modify a member.
340 my ($categories,$labels)=ethnicitycategories();
342 my $ethnicitycategoriescount=$#{$categories};
344 if ($ethnicitycategoriescount>=0) {
345 $ethcatpopup = CGI::popup_menu(-name=>'ethnicity',
348 -values=>$categories,
349 -default=>$data{'ethnicity'},
351 $template->param(ethcatpopup => $ethcatpopup); # bad style, has to be fixed
355 foreach (qw(C A S P I X)) {
356 my $action="WHERE category_type=?";
357 ($categories,$labels)=GetborCatFromCatType($_,$action);
359 foreach my $cat (@$categories){
360 push @categoryloop,{'categorycode' => $cat,
361 'categoryname' => $labels->{$cat},
362 'categorycodeselected' => ($cat eq $borrower_data->{'categorycode'} || $cat eq $categorycode),
366 $typehash{'typename'}=$_;
367 $typehash{'categoryloop'}=\@categoryloop;
368 push @typeloop,{'typename' => $_,
369 'categoryloop' => \@categoryloop};
371 $template->param('typeloop' => \@typeloop);
374 $select_city=getidcity($data{'city'}) if ($guarantorid ne '0');
375 ($default_city=$select_city) if ($step eq 0);
376 if ($select_city eq '' ){
377 $default_city = &getidcity($data{'city'});
380 ($cityid,$name_city)=GetCities();
381 $template->param( city_cgipopup => 1) if ($cityid );
382 my $citypopup = CGI::popup_menu(-name=>'select_city',
383 -id => 'select_city',
386 -default=>$default_city,
389 my $default_roadtype;
390 $default_roadtype=$data{'streettype'} ;
391 my($roadtypeid,$road_type)=GetRoadTypes();
392 $template->param( road_cgipopup => 1) if ($roadtypeid );
393 my $roadpopup = CGI::popup_menu(-name=>'streettype',
395 -values=>$roadtypeid,
398 -default=>$default_roadtype
401 my $default_borrowertitle;
402 $default_borrowertitle=$data{'title'} ;
403 my($borrowertitle)=GetTitles();
404 $template->param( title_cgipopup => 1) if ($borrowertitle);
405 my $borrotitlepopup = CGI::popup_menu(-name=>'title',
407 -values=>$borrowertitle,
409 -default=>$default_borrowertitle
412 my @relationships = split /,|\|/, C4::Context->preference('BorrowerRelationship');
414 while (@relationships) {
415 my $relship = shift @relationships || '';
416 my %row = ('relationship' => $relship);
417 if ($data{'relationship'} eq $relship) {
418 $row{'selected'}=' selected';
422 push(@relshipdata, \%row);
425 my %flags = ( 'gonenoaddress' => ['gonenoaddress' ],
427 'debarred' => ['debarred']);
431 foreach (keys(%flags)) {
433 my %row = ('key' => $key,
434 'name' => $flags{$key}[0]);
436 $row{'yes'}=' checked';
441 $row{'no'}=' checked';
443 push @flagdata,\%row;
451 my $onlymine=(C4::Context->preference('IndependantBranches') &&
452 C4::Context->userenv &&
453 C4::Context->userenv->{flags} !=1 &&
454 C4::Context->userenv->{branch}?1:0);
456 my $branches=GetBranches($onlymine);
459 for my $branch (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) {
460 push @select_branch,$branch;
461 $select_branches{$branch} = $branches->{$branch}->{'branchname'};
462 $default = C4::Context->userenv->{'branch'} if (C4::Context->userenv && C4::Context->userenv->{'branch'});
464 # --------------------------------------------------------------------------------------------------------
465 #in modify mod :default value from $CGIbranch comes from borrowers table
466 #in add mod: default value come from branches table (ip correspendence)
467 $default=$data{'branchcode'} if ($op eq 'modify' || ($op eq 'add' && $category_type eq 'C'));
468 my $CGIbranch = CGI::scrolling_list(-id => 'branchcode',
469 -name => 'branchcode',
470 -values => \@select_branch,
471 -labels => \%select_branches,
475 -default => $default,
477 my $CGIorganisations;
478 my $member_of_institution;
479 if (C4::Context->preference("memberofinstitution")){
480 my $organisations=get_institutions();
483 foreach my $organisation (keys %$organisations) {
484 push @orgs,$organisation;
485 $org_labels{$organisation}=$organisations->{$organisation}->{'surname'};
487 $member_of_institution=1;
489 $CGIorganisations = CGI::scrolling_list( -id => 'organisations',
490 -name => 'organisations',
491 -labels => \%org_labels,
499 # --------------------------------------------------------------------------------------------------------
501 my $CGIsort = buildCGIsort("Bsort1","sort1",$data{'sort1'});
503 $template->param(CGIsort1 => $CGIsort);
505 $template->param( sort1 => $data{'sort1'}); # shouldn't this be in an "else" statement like the 2nd one?
507 $CGIsort = buildCGIsort("Bsort2","sort2",$data{'sort2'});
509 $template->param(CGIsort2 => $CGIsort);
511 $template->param( sort2 => $data{'sort2'});
515 foreach my $error (@errors) {
516 $template->param($error) || $template->param( $error => 1);
518 $template->param(nok => 1);
521 #Formatting data for display
523 if ($data{'dateenrolled'} eq ''){
524 $data{'dateenrolled'}=C4::Dates->today('iso');
526 if (C4::Context->preference('uppercasesurnames')) {
527 $data{'surname'} =uc($data{'surname'} );
528 $data{'contactname'}=uc($data{'contactname'});
530 foreach (qw(dateenrolled dateexpiry dateofbirth)) {
531 $data{$_} = format_date($data{$_}); # back to syspref for display
532 $template->param( $_ => $data{$_});
535 if (C4::Context->preference('ExtendedPatronAttributes')) {
536 $template->param(ExtendedPatronAttributes => 1);
537 patron_attributes_form($template, $borrowernumber);
540 $template->param( "showguarantor" => ($category_type=~/A|I|S|X/) ? 0 : 1); # associate with step to know where you are
541 $debug and warn "memberentry step: $step";
542 $template->param(%data);
543 $template->param( "step_$step" => 1) if $step; # associate with step to know where u are
544 $template->param( step => $step ) if $step; # associate with step to know where u are
545 $template->param( debug => $debug ) if $debug;
547 BorrowerMandatoryField => C4::Context->preference("BorrowerMandatoryField"),#field to test with javascript
548 category_type => $category_type,#to know the category type of the borrower
549 DHTMLcalendar_dateformat => C4::Dates->DHTMLcalendar(),
550 select_city => $select_city,
551 "$category_type" => 1,# associate with step to know where u are
552 destination => $destination,#to know wher u come from and wher u must go in redirect
553 check_member => $check_member,#to know if the borrower already exist(=>1) or not (=>0)
554 flags =>$data{'flags'},
556 nodouble => $nodouble,
557 borrowernumber => $borrowernumber,#register number
558 "contacttitle_".$data{'contacttitle'} => "SELECTED" ,
559 guarantorid => $borrower_data ? $borrower_data->{'guarantorid'} : $guarantorid,
560 ethcatpopup => $ethcatpopup,
561 relshiploop => \@relshipdata,
562 citypopup => $citypopup,
563 roadpopup => $roadpopup,
564 borrotitlepopup => $borrotitlepopup,
565 guarantorinfo => $guarantorinfo,
566 flagloop => \@flagdata,
567 dateformat => C4::Dates->new()->visual(),
568 C4::Context->preference('dateformat') => 1,
569 check_categorytype =>$check_categorytype,#to recover the category type with checkcategorytype function
571 nok => $nok,#flag to konw if an error
572 CGIbranch => $CGIbranch,
573 memberofinstution => $member_of_institution,
574 CGIorganisations => $CGIorganisations,
575 NoUpdateLogin => $NoUpdateLogin
578 output_html_with_http_headers $input, $cookie, $template->output;
580 sub parse_extended_patron_attributes {
582 my @patron_attr = grep { /^patron_attr_\d+$/ } $input->param();
586 foreach my $key (@patron_attr) {
587 my $value = $input->param($key);
588 next unless defined($value) and $value ne '';
589 my $password = $input->param("${key}_password");
590 my $code = $input->param("${key}_code");
591 next if exists $dups{$code}->{$value};
592 $dups{$code}->{$value} = 1;
593 push @attr, { code => $code, value => $value, password => $password };
598 sub patron_attributes_form {
599 my $template = shift;
600 my $borrowernumber = shift;
602 my @types = C4::Members::AttributeTypes::GetAttributeTypes();
603 if (scalar(@types) == 0) {
604 $template->param(no_patron_attribute_types => 1);
607 my $attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
609 # map patron's attributes into a more convenient structure
611 foreach my $attr (@$attributes) {
612 push @{ $attr_hash{$attr->{code}} }, $attr;
615 my @attribute_loop = ();
617 foreach my $type_code (map { $_->{code} } @types) {
618 my $attr_type = C4::Members::AttributeTypes->fetch($type_code);
620 code => $attr_type->code(),
621 description => $attr_type->description(),
622 repeatable => $attr_type->repeatable(),
623 password_allowed => $attr_type->password_allowed(),
624 category => $attr_type->authorised_value_category(),
627 if (exists $attr_hash{$attr_type->code()}) {
628 foreach my $attr (@{ $attr_hash{$attr_type->code()} }) {
629 my $newentry = { map { $_ => $entry->{$_} } %$entry };
630 $newentry->{value} = $attr->{value};
631 $newentry->{password} = $attr->{password};
632 $newentry->{use_dropdown} = 0;
633 if ($attr_type->authorised_value_category()) {
634 $newentry->{use_dropdown} = 1;
635 $newentry->{auth_val_loop} = GetAuthorisedValues($attr_type->authorised_value_category(), $attr->{value});
638 $newentry->{form_id} = "patron_attr_$i";
639 #use Data::Dumper; die Dumper($entry) if $entry->{use_dropdown};
640 push @attribute_loop, $newentry;
644 my $newentry = { map { $_ => $entry->{$_} } %$entry };
645 if ($attr_type->authorised_value_category()) {
646 $newentry->{use_dropdown} = 1;
647 $newentry->{auth_val_loop} = GetAuthorisedValues($attr_type->authorised_value_category());
649 $newentry->{form_id} = "patron_attr_$i";
650 push @attribute_loop, $newentry;
653 $template->param(patron_attributes => \@attribute_loop);