@@ -, +, @@ guarantor --- .../prog/en/modules/members/memberentrygen.tt | 52 +++++++++++++++++++- members/memberentry.pl | 57 ++++++++++++++++------ 2 files changed, 94 insertions(+), 15 deletions(-) --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -325,7 +325,56 @@ Guarantor information - [% FOREACH r IN relationships %] + [% IF (!relationships) %] +
  • + Patron #: + [% IF guarantorid %] + [% IF logged_in_user.can_see_patron_infos( guarantor ) %] + [% guarantorid | html %] + [% ELSE %] + [% guarantorid | html %] + [% END %] + + [% END %] +
  • + [% UNLESS nocontactname %] +
  • + + [% IF ( guarantorid ) %] + [% contactname | html %] + + [% ELSE %] + + [% END %] +
  • + [% END %] + [% UNLESS nocontactfirstname %] +
  • + + [% IF ( guarantorid ) %] + [% contactfirstname | html %] + + [% ELSE %] + + [% END %] +
  • + [% END %] + [% IF ( relshiploop ) %] +
  • + + +
  • + [% END %] + [% ELSE %] + [% FOREACH r IN relationships %]
      [% IF category_type == 'I' %] @@ -370,6 +419,7 @@
    [% END # END relationships foreach %] + [% END %]
    --- a/members/memberentry.pl +++ a/members/memberentry.pl @@ -83,6 +83,7 @@ if ( C4::Context->preference('SMSSendDriver') eq 'Email' ) { $template->param( sms_providers => \@providers ); } +my $guarantorid = $input->param('guarantor_id'); my $actionType = $input->param('actionType') || ''; my $modify = $input->param('modify'); my $delete = $input->param('delete'); @@ -98,26 +99,13 @@ $nodouble = 1 if ($op eq 'modify' or $op eq 'duplicate'); # FIXME hack to rep # isn't a duplicate. Marking FIXME because this # script needs to be refactored. my $nok = $input->param('nok'); +my $guarantorinfo = $input->param('guarantorinfo'); my $step = $input->param('step') || 0; my @errors; my $borrower_data; my $NoUpdateLogin; my $userenv = C4::Context->userenv; -## Deal with guarantor stuff -$template->param( relationships => scalar $patron->guarantor_relationships ) if $patron; - -my $guarantor_id = $input->param('guarantor_id'); -my $guarantor = undef; -$guarantor = Koha::Patrons->find( $guarantor_id ) if $guarantor_id; -$template->param( guarantor => $guarantor ); - -my @delete_guarantor = $input->multi_param('delete_guarantor'); -foreach my $id ( @delete_guarantor ) { - my $r = Koha::Patron::Relationships->find( $id ); - $r->delete() if $r; -} - ## Deal with debarments $template->param( debarments => scalar GetDebarments( { borrowernumber => $borrowernumber } ) ); @@ -248,6 +236,45 @@ if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' ) } } + + +## Deal with guarantor stuff +$template->param( relationships => scalar $patron->guarantor_relationships ) if $patron; +my $guarantor_id = $input->param('guarantor_id'); +my $guarantor = undef; +$guarantor = Koha::Patrons->find( $guarantor_id ) if $guarantor_id; +$template->param( guarantor => $guarantor ); + +# Pre-fill guarantor fields if adding a guarantee to guarantor record using 'Add guarantee' button +# in this case the guarantee patron record does not already exist + +if (!$patron) { + if ( $guarantorid ) { + if (my $guarantor = Koha::Patrons->find( $guarantorid )) { + my $guarantordata = $guarantor->unblessed; + $categorycode = $guarantordata->{categorycode} eq 'I' ? 'P' : 'C'; + $guarantorinfo=$guarantordata->{'surname'}." , ".$guarantordata->{'firstname'}; + $newdata{'contactfirstname'}= $guarantordata->{'firstname'}; + $newdata{'contactname'} = $guarantordata->{'surname'}; + $newdata{'contacttitle'} = $guarantordata->{'title'}; + if ( $op eq 'add' ) { + foreach (qw(streetnumber address streettype address2 + zipcode country city state phone phonepro mobile fax email emailpro branchcode + B_streetnumber B_streettype B_address B_address2 + B_city B_state B_zipcode B_country B_email B_phone)) { + $newdata{$_} = $guarantordata->{$_}; + } + } + } + } +} + +my @delete_guarantor = $input->multi_param('delete_guarantor'); +foreach my $id ( @delete_guarantor ) { + my $r = Koha::Patron::Relationships->find( $id ); + $r->delete() if $r; +} + # Test uniqueness of surname, firstname and dateofbirth if ( ( $op eq 'insert' ) and !$nodouble ) { my $conditions; @@ -784,11 +811,13 @@ $template->param( check_member => $check_member,#to know if the borrower already exist(=>1) or not (=>0) "op$op" => 1); +$guarantorid = $borrower_data->{'guarantorid'} || $guarantorid; $template->param( patron => $patron ? $patron : \%newdata, # Used by address include templates now nodouble => $nodouble, borrowernumber => $borrowernumber, #register number relshiploop => \@relshipdata, + guarantorid => $guarantorid, btitle=> $default_borrowertitle, flagloop => \@flagdata, category_type =>$category_type, --