Lines 110-128
$template->param( relationships => scalar $patron->guarantor_relationships ) if
Link Here
|
110 |
my @relations = split /,|\|/, C4::Context->preference('borrowerRelationship'); |
110 |
my @relations = split /,|\|/, C4::Context->preference('borrowerRelationship'); |
111 |
my $empty_relationship_allowed = grep {$_ eq ""} @relations; |
111 |
my $empty_relationship_allowed = grep {$_ eq ""} @relations; |
112 |
$template->param( empty_relationship_allowed => $empty_relationship_allowed ); |
112 |
$template->param( empty_relationship_allowed => $empty_relationship_allowed ); |
113 |
|
|
|
114 |
my $guarantorinfo = $input->param('guarantorinfo'); |
115 |
my $guarantor_id = $input->param('new_guarantor_id'); |
113 |
my $guarantor_id = $input->param('new_guarantor_id'); |
116 |
my $guarantor = undef; |
114 |
my $guarantor = undef; |
117 |
$guarantor = Koha::Patrons->find( $guarantor_id ) if $guarantor_id; |
115 |
$guarantor = Koha::Patrons->find( $guarantor_id ) if $guarantor_id; |
118 |
$template->param( guarantor => $guarantor ); |
116 |
$template->param( guarantor => $guarantor ); |
119 |
|
|
|
120 |
my @delete_guarantor = $input->multi_param('delete_guarantor'); |
117 |
my @delete_guarantor = $input->multi_param('delete_guarantor'); |
121 |
foreach my $id ( @delete_guarantor ) { |
118 |
foreach my $id ( @delete_guarantor ) { |
122 |
my $r = Koha::Patron::Relationships->find( $id ); |
119 |
my $r = Koha::Patron::Relationships->find( $id ); |
123 |
$r->delete() if $r; |
120 |
$r->delete() if $r; |
124 |
} |
121 |
} |
125 |
|
122 |
|
|
|
123 |
#Search existing guarantor id(s) and new ones from params |
124 |
my @guarantor_ids; |
125 |
my @guarantors = $patron->guarantor_relationships()->guarantors unless !$patron; |
126 |
foreach my $guarantor (@guarantors){ |
127 |
push @guarantor_ids, $guarantor->id; |
128 |
}; |
129 |
my @new_guarantor_ids = grep { $_ ne '' } $input->multi_param('new_guarantor_id'); |
130 |
push (@guarantor_ids, @new_guarantor_ids); |
131 |
|
126 |
## Deal with debarments |
132 |
## Deal with debarments |
127 |
$template->param( |
133 |
$template->param( |
128 |
debarments => scalar GetDebarments( { borrowernumber => $borrowernumber } ) ); |
134 |
debarments => scalar GetDebarments( { borrowernumber => $borrowernumber } ) ); |
Lines 287-301
if ( ( $op eq 'insert' ) and !$nodouble ) {
Link Here
|
287 |
} |
293 |
} |
288 |
} |
294 |
} |
289 |
|
295 |
|
290 |
if ( $guarantor_id ) { |
296 |
if ( @guarantor_ids ) { |
291 |
if (my $guarantor = Koha::Patrons->find( $guarantor_id )) { |
297 |
foreach my $guarantor_id ( @guarantor_ids ){ |
292 |
my $guarantor_category = $guarantor->category->category_type; |
298 |
if (my $guarantor = Koha::Patrons->find( $guarantor_id )){ |
293 |
push @errors, 'ERROR_guarantor_is_guarantee' if ( ($guarantor_category eq 'C') && |
299 |
push @errors, 'ERROR_guarantor_is_guarantee' if ( ($guarantor->is_child) && |
294 |
($op eq 'save' || $op eq 'insert') ); |
300 |
($op eq 'save' || $op eq 'insert') ); |
|
|
301 |
} |
295 |
} |
302 |
} |
296 |
} |
303 |
} |
297 |
|
304 |
|
298 |
my $valid_guarantor = $guarantor_id ? $guarantor_id : $newdata{'contactname'}; |
305 |
my $valid_guarantor = @guarantor_ids or $newdata{'contactname'} ? 1 : 0; |
299 |
|
306 |
|
300 |
if($category_type eq 'C' && ($op eq 'save' || $op eq 'insert') && C4::Context->preference('ChildNeedsGuarantor')){ |
307 |
if($category_type eq 'C' && ($op eq 'save' || $op eq 'insert') && C4::Context->preference('ChildNeedsGuarantor')){ |
301 |
if(!$valid_guarantor){ |
308 |
if(!$valid_guarantor){ |
302 |
- |
|
|