View | Details | Raw Unified | Return to bug 30874
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (-8 / +7 lines)
Lines 242-248 legend:hover { Link Here
242
                            [% END %]
242
                            [% END %]
243
                            <!--    field always hidden in different form (1,2,3) -->
243
                            <!--    field always hidden in different form (1,2,3) -->
244
                            <input type="hidden" name="BorrowerMandatoryField" value="[% BorrowerMandatoryField | html %]" />
244
                            <input type="hidden" name="BorrowerMandatoryField" value="[% BorrowerMandatoryField | html %]" />
245
                            <input type="hidden" name="category_type" value="[% category_type | html %]" />
246
                            <input type="hidden" name="updtype" value="[% updtype | html %]" />
245
                            <input type="hidden" name="updtype" value="[% updtype | html %]" />
247
                            <input type="hidden" name="destination" value="[% destination | html %]" />
246
                            <input type="hidden" name="destination" value="[% destination | html %]" />
248
                            <input type="hidden" name="check_member" value="[% check_member | html %]" />
247
                            <input type="hidden" name="check_member" value="[% check_member | html %]" />
Lines 269-277 legend:hover { Link Here
269
                            [% IF ( step_1 ) %]
268
                            [% IF ( step_1 ) %]
270
                                [% UNLESS notitle && nosurname && nofirstname && nodateofbirth && noinitials && noothernames &&nosex %]
269
                                [% UNLESS notitle && nosurname && nofirstname && nodateofbirth && noinitials && noothernames &&nosex %]
271
                                    <fieldset class="rows" id="memberentry_identity">
270
                                    <fieldset class="rows" id="memberentry_identity">
272
                                        <legend id="identity_lgd">[% IF ( I ) %]Organization [% ELSE %]Patron [% END %]identity</legend>
271
                                        <legend id="identity_lgd">[% IF ( patron_category.category_type == 'I' ) %]Organization [% ELSE %]Patron [% END %]identity</legend>
273
                                        <ol>
272
                                        <ol>
274
                                            [% UNLESS ( I ) %]
273
                                            [% UNLESS ( patron_category.category_type == 'I' ) %]
275
                                                [% UNLESS notitle %]
274
                                                [% UNLESS notitle %]
276
                                                    [% IF Koha.Preference('BorrowersTitles') %]
275
                                                    [% IF Koha.Preference('BorrowersTitles') %]
277
                                                        <li>
276
                                                        <li>
Lines 301-307 legend:hover { Link Here
301
300
302
                                            [% UNLESS nosurname %]
301
                                            [% UNLESS nosurname %]
303
                                                <li>
302
                                                <li>
304
                                                    [% IF ( I ) %]
303
                                                    [% IF ( patron_category.category_type == 'I' ) %]
305
                                                        <label for="surname" class="required">
304
                                                        <label for="surname" class="required">
306
                                                            Name:
305
                                                            Name:
307
                                                        </label>
306
                                                        </label>
Lines 325-331 legend:hover { Link Here
325
                                                </li>
324
                                                </li>
326
                                            [% END # /UNLESS nosurname %]
325
                                            [% END # /UNLESS nosurname %]
327
326
328
                                            [% UNLESS ( I ) %]
327
                                            [% UNLESS ( patron_category.category_type == 'I' ) %]
329
                                                [% UNLESS nofirstname %]
328
                                                [% UNLESS nofirstname %]
330
                                                    <li>
329
                                                    <li>
331
                                                        [% IF ( mandatoryfirstname ) %]
330
                                                        [% IF ( mandatoryfirstname ) %]
Lines 389-399 legend:hover { Link Here
389
                                                    [% IF ( mandatoryothernames ) %]
388
                                                    [% IF ( mandatoryothernames ) %]
390
                                                        <span class="required">Required</span>
389
                                                        <span class="required">Required</span>
391
                                                    [% END %]
390
                                                    [% END %]
392
                                                    [% IF ( I ) %]<input type="hidden" name="sex" value="N" />[% END %]
391
                                                    [% IF ( patron_category.category_type == 'I' ) %]<input type="hidden" name="sex" value="N" />[% END %]
393
                                                </li>
392
                                                </li>
394
                                            [% END #/UNLESS noothernames %]
393
                                            [% END #/UNLESS noothernames %]
395
394
396
                                            [% UNLESS ( I ) %]
395
                                            [% UNLESS ( patron_category.category_type == 'I' ) %]
397
                                                [% UNLESS nosex %]
396
                                                [% UNLESS nosex %]
398
                                                    <li class="radio">
397
                                                    <li class="radio">
399
                                                        [% UNLESS ( opduplicate ) %]
398
                                                        [% UNLESS ( opduplicate ) %]
Lines 440-446 legend:hover { Link Here
440
                                                [% FOREACH r IN relationships %]
439
                                                [% FOREACH r IN relationships %]
441
                                                    <fieldset>
440
                                                    <fieldset>
442
                                                        <ol>
441
                                                        <ol>
443
                                                            [% IF category_type == 'I' %]
442
                                                            [% IF patron_category.category_type == 'I' %]
444
                                                                <li class="guarantor-details" data-borrowernumber="[% r.guarantor_id | $raw %]">
443
                                                                <li class="guarantor-details" data-borrowernumber="[% r.guarantor_id | $raw %]">
445
                                                                    <span class="label">Organization:</span>
444
                                                                    <span class="label">Organization:</span>
446
                                                                    [% INCLUDE 'patron-title.inc' patron=r.guarantor hide_patron_infos_if_needed=1 %]
445
                                                                    [% INCLUDE 'patron-title.inc' patron=r.guarantor hide_patron_infos_if_needed=1 %]
(-)a/members/memberentry.pl (-16 / +4 lines)
Lines 172-188 if ( $op eq 'modify' or $op eq 'save' or $op eq 'duplicate' ) { Link Here
172
    }
172
    }
173
173
174
    $borrower_data = $patron->unblessed;
174
    $borrower_data = $patron->unblessed;
175
    $borrower_data->{category_type} = $patron->category->category_type;
176
}
175
}
177
176
178
my $categorycode  = $input->param('categorycode') || $borrower_data->{'categorycode'};
177
my $categorycode  = $input->param('categorycode') || $borrower_data->{'categorycode'};
179
my $category_type = $input->param('category_type') || '';
180
181
my $category = Koha::Patron::Categories->find($categorycode);
178
my $category = Koha::Patron::Categories->find($categorycode);
182
$category_type ||= $category && $category->category_type;
183
184
$category_type="A" unless $category_type; # FIXME we should display a error message instead of a 500 error !
185
186
$template->param( patron_category => $category );
179
$template->param( patron_category => $category );
187
180
188
# if a add or modify is requested => check validity of data.
181
# if a add or modify is requested => check validity of data.
Lines 212-218 if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' ) Link Here
212
    }
205
    }
213
206
214
    # check permission to modify login info.
207
    # check permission to modify login info.
215
    if (ref($borrower_data) && ($borrower_data->{'category_type'} eq 'S') && ! (C4::Auth::haspermission($userenv->{'id'},{'staffaccess'=>1})) )  {
208
    if (ref($borrower_data) && ($category->category_type eq 'S') && ! (C4::Auth::haspermission($userenv->{'id'},{'staffaccess'=>1})) )  {
216
        $NoUpdateLogin = 1;
209
        $NoUpdateLogin = 1;
217
    }
210
    }
218
}
211
}
Lines 222-228 if ( $op eq 'insert' || $op eq 'modify' || $op eq 'save' || $op eq 'duplicate' ) Link Here
222
    my @keys_to_delete = (
215
    my @keys_to_delete = (
223
        qr/^(borrowernumber|date_renewed|debarred|debarredcomment|flags|privacy|updated_on|lastseen|login_attempts|overdrive_auth_token|anonymized)$/, # Bug 28935
216
        qr/^(borrowernumber|date_renewed|debarred|debarredcomment|flags|privacy|updated_on|lastseen|login_attempts|overdrive_auth_token|anonymized)$/, # Bug 28935
224
        qr/^BorrowerMandatoryField$/,
217
        qr/^BorrowerMandatoryField$/,
225
        qr/^category_type$/,
226
        qr/^check_member$/,
218
        qr/^check_member$/,
227
        qr/^destination$/,
219
        qr/^destination$/,
228
        qr/^nodouble$/,
220
        qr/^nodouble$/,
Lines 297-310 $newdata{'lang'} = $input->param('lang') if defined($input->param('lang')) Link Here
297
if ( ( defined $newdata{'userid'} && $newdata{'userid'} eq '' ) || $check_BorrowerUnwantedField =~ /userid/ && !defined $data{'userid'} ) {
289
if ( ( defined $newdata{'userid'} && $newdata{'userid'} eq '' ) || $check_BorrowerUnwantedField =~ /userid/ && !defined $data{'userid'} ) {
298
    my $fake_patron = Koha::Patron->new;
290
    my $fake_patron = Koha::Patron->new;
299
    $fake_patron->userid($patron->userid) if $patron; # editing
291
    $fake_patron->userid($patron->userid) if $patron; # editing
300
    if ( ( defined $newdata{'firstname'} || $category_type eq 'I' ) && ( defined $newdata{'surname'} ) ) {
292
    if ( ( defined $newdata{'firstname'} || $category->category_type eq 'I' ) && ( defined $newdata{'surname'} ) ) {
301
        # Full page edit, firstname and surname input zones are present
293
        # Full page edit, firstname and surname input zones are present
302
        $fake_patron->firstname($newdata{firstname});
294
        $fake_patron->firstname($newdata{firstname});
303
        $fake_patron->surname($newdata{surname});
295
        $fake_patron->surname($newdata{surname});
304
        $fake_patron->generate_userid;
296
        $fake_patron->generate_userid;
305
        $newdata{'userid'} = $fake_patron->userid;
297
        $newdata{'userid'} = $fake_patron->userid;
306
    }
298
    }
307
    elsif ( ( defined $data{'firstname'} || $category_type eq 'I' ) && ( defined $data{'surname'} ) ) {
299
    elsif ( ( defined $data{'firstname'} || $category->category_type eq 'I' ) && ( defined $data{'surname'} ) ) {
308
        # Partial page edit (access through "Details"/"Library details" tab), firstname and surname input zones are not used
300
        # Partial page edit (access through "Details"/"Library details" tab), firstname and surname input zones are not used
309
        # Still, if the userid field is erased, we can create a new userid with available firstname and surname
301
        # Still, if the userid field is erased, we can create a new userid with available firstname and surname
310
        # FIXME clean thiscode newdata vs data is very confusing
302
        # FIXME clean thiscode newdata vs data is very confusing
Lines 741-747 if (C4::Context->userenv && C4::Context->userenv->{'branch'}) { Link Here
741
    $userbranch = C4::Context->userenv->{'branch'};
733
    $userbranch = C4::Context->userenv->{'branch'};
742
}
734
}
743
735
744
if (defined ($data{'branchcode'}) and ( $op eq 'modify' || $op eq 'duplicate' || ( $op eq 'add' && $category_type eq 'C' ) )) {
736
if (defined ($data{'branchcode'}) and ( $op eq 'modify' || $op eq 'duplicate' || ( $op eq 'add' && $category->category_type eq 'C' ) )) {
745
    $userbranch = $data{'branchcode'};
737
    $userbranch = $data{'branchcode'};
746
}
738
}
747
$template->param( userbranch => $userbranch );
739
$template->param( userbranch => $userbranch );
Lines 812-819 $template->param( step => $step ) if $step; # associate with step to know wh Link Here
812
804
813
$template->param(
805
$template->param(
814
  BorrowerMandatoryField => C4::Context->preference("BorrowerMandatoryField"),#field to test with javascript
806
  BorrowerMandatoryField => C4::Context->preference("BorrowerMandatoryField"),#field to test with javascript
815
  category_type => $category_type,#to know the category type of the borrower
816
  "$category_type"  => 1,# associate with step to know where u are
817
  destination   => $destination,#to know where u come from and where u must go in redirect
807
  destination   => $destination,#to know where u come from and where u must go in redirect
818
  check_member    => $check_member,#to know if the borrower already exist(=>1) or not (=>0) 
808
  check_member    => $check_member,#to know if the borrower already exist(=>1) or not (=>0) 
819
  "op$op"   => 1);
809
  "op$op"   => 1);
Lines 825-831 $template->param( Link Here
825
  relshiploop => \@relshipdata,
815
  relshiploop => \@relshipdata,
826
  btitle=> $default_borrowertitle,
816
  btitle=> $default_borrowertitle,
827
  flagloop  => \@flagdata,
817
  flagloop  => \@flagdata,
828
  category_type =>$category_type,
829
  modify          => $modify,
818
  modify          => $modify,
830
  nok     => $nok,#flag to know if an error
819
  nok     => $nok,#flag to know if an error
831
  NoUpdateLogin =>  $NoUpdateLogin,
820
  NoUpdateLogin =>  $NoUpdateLogin,
832
- 

Return to bug 30874