Lines 102-120
my @relations = split /\|/, C4::Context->preference('borrowerRelationship'), -1;
Link Here
|
102 |
@relations = ('') unless @relations; |
102 |
@relations = ('') unless @relations; |
103 |
my $empty_relationship_allowed = grep {$_ eq ""} @relations; |
103 |
my $empty_relationship_allowed = grep {$_ eq ""} @relations; |
104 |
$template->param( empty_relationship_allowed => $empty_relationship_allowed ); |
104 |
$template->param( empty_relationship_allowed => $empty_relationship_allowed ); |
105 |
|
|
|
106 |
my $guarantorinfo = $input->param('guarantorinfo'); |
107 |
my $guarantor_id = $input->param('new_guarantor_id'); |
105 |
my $guarantor_id = $input->param('new_guarantor_id'); |
108 |
my $guarantor = undef; |
106 |
my $guarantor = undef; |
109 |
$guarantor = Koha::Patrons->find( $guarantor_id ) if $guarantor_id; |
107 |
$guarantor = Koha::Patrons->find( $guarantor_id ) if $guarantor_id; |
110 |
$template->param( guarantor => $guarantor ); |
108 |
$template->param( guarantor => $guarantor ); |
111 |
|
|
|
112 |
my @delete_guarantor = $input->multi_param('delete_guarantor'); |
109 |
my @delete_guarantor = $input->multi_param('delete_guarantor'); |
113 |
foreach my $id ( @delete_guarantor ) { |
110 |
foreach my $id ( @delete_guarantor ) { |
114 |
my $r = Koha::Patron::Relationships->find( $id ); |
111 |
my $r = Koha::Patron::Relationships->find( $id ); |
115 |
$r->delete() if $r; |
112 |
$r->delete() if $r; |
116 |
} |
113 |
} |
117 |
|
114 |
|
|
|
115 |
#Search existing guarantor id(s) and new ones from params |
116 |
my @guarantor_ids; |
117 |
my @guarantors = $patron->guarantor_relationships()->guarantors unless !$patron; |
118 |
foreach my $guarantor (@guarantors){ |
119 |
push @guarantor_ids, $guarantor->id; |
120 |
}; |
121 |
my @new_guarantor_ids = grep { $_ ne '' } $input->multi_param('new_guarantor_id'); |
122 |
push (@guarantor_ids, @new_guarantor_ids); |
123 |
|
118 |
## Deal with debarments |
124 |
## Deal with debarments |
119 |
$template->param( |
125 |
$template->param( |
120 |
debarments => scalar GetDebarments( { borrowernumber => $borrowernumber } ) ); |
126 |
debarments => scalar GetDebarments( { borrowernumber => $borrowernumber } ) ); |
Lines 280-294
if ( ( $op eq 'insert' ) and !$nodouble ) {
Link Here
|
280 |
} |
286 |
} |
281 |
} |
287 |
} |
282 |
|
288 |
|
283 |
if ( $guarantor_id ) { |
289 |
if ( @guarantor_ids ) { |
284 |
if (my $guarantor = Koha::Patrons->find( $guarantor_id )) { |
290 |
foreach my $guarantor_id ( @guarantor_ids ){ |
285 |
my $guarantor_category = $guarantor->category->category_type; |
291 |
if (my $guarantor = Koha::Patrons->find( $guarantor_id )){ |
286 |
push @errors, 'ERROR_guarantor_is_guarantee' if ( ($guarantor_category eq 'C') && |
292 |
push @errors, 'ERROR_guarantor_is_guarantee' if ( ($guarantor->is_child) && |
287 |
($op eq 'save' || $op eq 'insert') ); |
293 |
($op eq 'save' || $op eq 'insert') ); |
|
|
294 |
} |
288 |
} |
295 |
} |
289 |
} |
296 |
} |
290 |
|
297 |
|
291 |
my $valid_guarantor = $guarantor_id ? $guarantor_id : $newdata{'contactname'}; |
298 |
my $valid_guarantor = @guarantor_ids || $newdata{'contactname'} ? 1 : 0; |
292 |
|
299 |
|
293 |
if($category_type eq 'C' && ($op eq 'save' || $op eq 'insert') && C4::Context->preference('ChildNeedsGuarantor')){ |
300 |
if($category_type eq 'C' && ($op eq 'save' || $op eq 'insert') && C4::Context->preference('ChildNeedsGuarantor')){ |
294 |
if(!$valid_guarantor){ |
301 |
if(!$valid_guarantor){ |
295 |
- |
|
|