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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt (-7 / +53 lines)
Lines 92-97 Link Here
92
                        [% IF nochanges %]
92
                        [% IF nochanges %]
93
                            <div class="alert alert-error">No changes were made.</div>
93
                            <div class="alert alert-error">No changes were made.</div>
94
                        [% END %]
94
                        [% END %]
95
                        [% IF self_renewal %]
96
                            <div class="alert alert-info">Please verify your details to proceed with your self-renewal.</div>
97
                        [% END %]
95
                    [% END %]
98
                    [% END %]
96
99
97
                    [% IF empty_mandatory_fields %]
100
                    [% IF empty_mandatory_fields %]
Lines 241-247 Link Here
241
                        >
244
                        >
242
                    [% END %]
245
                    [% END %]
243
246
244
                    <form method="post" action="/cgi-bin/koha/opac-memberentry.pl" id="memberentry-form" autocomplete="off">
247
                    <form method="post" [% IF (self_renewal) %]action="/api/v1/public/patrons/self_renewal" id="self-renewal-form"[% ELSE %]action="/cgi-bin/koha/opac-memberentry.pl" id="memberentry-form"[% END %] autocomplete="off">
245
                        [% INCLUDE 'csrf-token.inc' %]
248
                        [% INCLUDE 'csrf-token.inc' %]
246
249
247
                        [% FOREACH field = ['streetnumber' 'streettype'  'cardnumber' 'branchcode' 'categorycode' 'title' 'surname' 'firstname' 'preferred_name' 'middle_name' 'dateofbirth' 'initials' 'pronouns' 'othernames' 'address' 'address2' 'city' 'state' 'zipcode' 'country' 'phone' 'phonepro' 'mobile' 'email' 'emailpro' 'fax' 'B_streettype' 'B_streetnumber' 'B_address' 'B_address2' 'B_city' 'B_state' 'B_zipcode' 'B_country' 'B_phone' 'B_email' 'contactnote' 'altcontactsurname' 'altcontactfirstname' 'altcontactaddress1' 'altcontactaddress2' 'altcontactaddress3' 'altcontactstate' 'altcontactzipcode' 'altcontactcountry' 'altcontactphone' 'password' 'lang' ] %]
250
                        [% FOREACH field = ['streetnumber' 'streettype'  'cardnumber' 'branchcode' 'categorycode' 'title' 'surname' 'firstname' 'preferred_name' 'middle_name' 'dateofbirth' 'initials' 'pronouns' 'othernames' 'address' 'address2' 'city' 'state' 'zipcode' 'country' 'phone' 'phonepro' 'mobile' 'email' 'emailpro' 'fax' 'B_streettype' 'B_streetnumber' 'B_address' 'B_address2' 'B_city' 'B_state' 'B_zipcode' 'B_country' 'B_phone' 'B_email' 'contactnote' 'altcontactsurname' 'altcontactfirstname' 'altcontactaddress1' 'altcontactaddress2' 'altcontactaddress3' 'altcontactstate' 'altcontactzipcode' 'altcontactcountry' 'altcontactphone' 'password' 'lang' ] %]
Lines 1362-1368 Link Here
1362
                                    [% IF OPACPatronDetails %]
1365
                                    [% IF OPACPatronDetails %]
1363
                                        <fieldset class="action">
1366
                                        <fieldset class="action">
1364
                                            <input type="hidden" name="op" value="cud-update" />
1367
                                            <input type="hidden" name="op" value="cud-update" />
1365
                                            <input type="submit" class="btn btn-primary" value="Submit update request" />
1368
                                            [% IF (self_renewal) %]
1369
                                                <input type="submit" class="btn btn-primary" value="Submit renewal request" />
1370
                                            [% ELSE %]
1371
                                                <input type="submit" class="btn btn-primary" value="Submit update request" />
1372
                                            [% END %]
1366
                                        </fieldset>
1373
                                        </fieldset>
1367
                                    [% END %]
1374
                                    [% END %]
1368
                                [% ELSE %]
1375
                                [% ELSE %]
Lines 1391-1406 Link Here
1391
    [% INCLUDE 'calendar.inc' %]
1398
    [% INCLUDE 'calendar.inc' %]
1392
    <script>
1399
    <script>
1393
        $(document).ready(function() {
1400
        $(document).ready(function() {
1401
                let formName
1402
                [% IF (self_renewal) %]
1403
                    formName = 'self-renewal-form'
1404
                [% ELSE %]
1405
                    formName = 'memberentry-form'
1406
                [% END %]
1407
1394
                [% IF op == 'edit' && !OPACPatronDetails %]
1408
                [% IF op == 'edit' && !OPACPatronDetails %]
1395
                    $("#memberentry-form :input").attr('readonly', true);
1409
                    $("#" + formName + " :input").attr('readonly', true);
1396
                    $("#borrower_branchcode").attr('disabled',true);
1410
                    $("#borrower_branchcode").attr('disabled',true);
1397
                    $("#borrower_title").attr('disabled',true);
1411
                    $("#borrower_title").attr('disabled',true);
1398
                    $('#memberentry-form :radio').attr('disabled',true);
1412
                    $('#' + formName + ' :radio').attr('disabled',true);
1399
                    $('span.required').remove();
1413
                    $('span.required').remove();
1400
                    $('label.required').removeClass('required');
1414
                    $('label.required').removeClass('required');
1401
                [% END %]
1415
                [% END %]
1402
1416
1403
                $("#memberentry-form").validate({
1417
                $("#" + formName).validate({
1404
                    rules: {
1418
                    rules: {
1405
                        borrower_email: {
1419
                        borrower_email: {
1406
                            email: true
1420
                            email: true
Lines 1430-1437 Link Here
1430
                            return false;
1444
                            return false;
1431
                        }
1445
                        }
1432
                        else {
1446
                        else {
1433
                            form.beenSubmitted = true;
1447
                            if(formName === 'self-renewal-form') {
1434
                            form.submit();
1448
                                const formValues = $(form).serializeArray()
1449
                                const renewalBody = formValues.reduce((body, curr, i) => {
1450
                                    if(curr.name.includes("borrower")) {
1451
                                        const fieldName = curr.name.replace("borrower_", "")
1452
                                        body[fieldName] = curr.value
1453
                                    }
1454
                                    if(curr.name === "patron_attribute_code") {
1455
                                        const matchingValue = formValues[i + 1].value
1456
                                        body.extended_attributes.push({code: curr.value, attribute: matchingValue})
1457
                                    }
1458
                                    return body
1459
                                }, {extended_attributes: []})
1460
                                const options = {
1461
                                    url: $(form).attr('action'),
1462
                                    method: $(form).attr('method').toUpperCase(),
1463
                                    contentType: 'application/json',
1464
                                    data: JSON.stringify(renewalBody)
1465
                                };
1466
                                $.ajax(options)
1467
                                    .then(function(result) {
1468
                                        let newLocation = "/cgi-bin/koha/opac-user.pl?self_renewal_success=" + result.expiry_date
1469
                                        if(result.confirmation_sent) {
1470
                                            newLocation += "&confirmation_sent=1"
1471
                                        }
1472
                                        document.location = newLocation
1473
                                    })
1474
                                    .fail(function(err) {
1475
                                        document.location = "/cgi-bin/koha/opac-user.pl?self_renewal_success=0";
1476
                                    });
1477
                            } else {
1478
                                form.beenSubmitted = true;
1479
                                form.submit();
1480
                            }
1435
                        }
1481
                        }
1436
                    }
1482
                    }
1437
                });
1483
                });
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (-3 / +38 lines)
Lines 1-4 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE To %]
2
[% USE Asset %]
3
[% USE Asset %]
3
[% USE Koha %]
4
[% USE Koha %]
4
[% USE KohaDates %]
5
[% USE KohaDates %]
Lines 119-136 Link Here
119
                        </div>
120
                        </div>
120
                    [% END %]
121
                    [% END %]
121
122
122
                    [% IF ( borrower.warndeparture ) %]
123
                    [% IF ( borrower.warndeparture) %]
123
                        <div class="alert alert-warning" id="warndeparture">
124
                        <div class="alert alert-warning" id="warndeparture">
124
                            <strong>Please note:</strong><span> Your library card will expire on <span id="warndeparture_date">[% borrower.warndeparture | $KohaDates %]</span>. Please contact the library for more information.</span>
125
                            <strong>Please note:</strong
126
                            ><span>
127
                                Your library card will expire on <span id="warndeparture_date">[% borrower.warndeparture | $KohaDates %]</span>.
128
                                [% IF ( !self_renewal_available) %]Please contact the library for more information.[% END %]</span
129
                            >
125
                            [% IF ( borrower.returnbeforeexpiry ) %]<span id="warndeparture_returnbeforeexpiry"> Also note that you must return all checked out items before your library card expires.</span>[% END %]
130
                            [% IF ( borrower.returnbeforeexpiry ) %]<span id="warndeparture_returnbeforeexpiry"> Also note that you must return all checked out items before your library card expires.</span>[% END %]
126
                        </div>
131
                        </div>
127
                    [% END %]
132
                    [% END %]
128
129
                    [% IF ( borrower.warnexpired ) %]
133
                    [% IF ( borrower.warnexpired ) %]
130
                        <div class="alert alert-warning" id="warnexpired">
134
                        <div class="alert alert-warning" id="warnexpired">
131
                            <strong>Please note: </strong><span>Your account has expired as of [% borrower.warnexpired | $KohaDates %]. Please contact the library if you wish to renew your account.</span>
135
                            <strong>Please note: </strong><span>Your account has expired as of [% borrower.warnexpired | $KohaDates %]. Please contact the library if you wish to renew your account.</span>
132
                        </div>
136
                        </div>
133
                    [% END %]
137
                    [% END %]
138
                    [% IF ( self_renewal_available && !self_renewal_alert ) %]
139
                        <div class="alert alert-info" id="self_renewal_available">
140
                            [% IF ( self_renewal_available ) %]
141
                                <span> You are eligible for self-renewal. <a href="#patronSelfRenewal" data-bs-toggle="modal">Please click here to renew your account.</a></span>
142
                            [% END %]
143
                        </div>
144
                    [% END %]
145
                    [% IF ( self_renewal_success ) %]
146
                        <div class="alert alert-success" id="self_renewal_success">
147
                            <span>Your account has been successfully renewed until [% self_renewal_success | $KohaDates %].</span>
148
                            [% IF ( self_renewal_confirmation_sent ) %]
149
                                <span>You should receive a confirmation shortly.</span>
150
                            [% END %]
151
                        </div>
152
                    [% END %]
153
                    [% IF ( self_renewal_alert ) %]
154
                        <div class="alert alert-warning" id="self_renewal_alert">
155
                            <span>[% self_renewal_alert | html %]</span>
156
                        </div>
157
                    [% END %]
134
158
135
                    [% IF ( RENEW_ERROR ) %]
159
                    [% IF ( RENEW_ERROR ) %]
136
                        <div class="alert alert-warning">
160
                        <div class="alert alert-warning">
Lines 1003-1008 Link Here
1003
</main>
1027
</main>
1004
<!-- /#main -->
1028
<!-- /#main -->
1005
1029
1030
[% IF ( self_renewal_available ) %]
1031
    <patron-self-renewal></patron-self-renewal>
1032
[% END %]
1033
1034
[% SET islands = Asset.js("js/vue/dist/islands.esm.js").match('(src="([^"]+)")').1 %]
1035
<script src="[% islands | $raw %]" type="module">
1036
</script>
1037
<script type="module">
1038
    import { hydrate } from "[% islands | $raw %]";
1039
    hydrate();
1040
</script>
1006
[%# hold suspend modal form %]
1041
[%# hold suspend modal form %]
1007
<div id="suspendHoldModal" class="modal" tabindex="-1" role="dialog" aria-labelledby="suspendModalLabel" aria-hidden="true" data-focus="false">
1042
<div id="suspendHoldModal" class="modal" tabindex="-1" role="dialog" aria-labelledby="suspendModalLabel" aria-hidden="true" data-focus="false">
1008
    <div class="modal-dialog">
1043
    <div class="modal-dialog">
(-)a/opac/opac-memberentry.pl (-17 / +6 lines)
Lines 354-375 if ( $op eq 'cud-create' ) { Link Here
354
            $borrower_changes{borrowernumber}      = $borrowernumber;
354
            $borrower_changes{borrowernumber}      = $borrowernumber;
355
            $borrower_changes{extended_attributes} = to_json($extended_attributes_changes);
355
            $borrower_changes{extended_attributes} = to_json($extended_attributes_changes);
356
356
357
            Koha::Patron::Modifications->search( { borrowernumber => $borrowernumber } )->delete;
358
359
            $borrower_changes{verification_token} = q{};    # prevent warn Missing value for PK column
360
            my $m = Koha::Patron::Modification->new( \%borrower_changes )->store();
361
362
            #Automatically approve patron profile changes if set in syspref
363
364
            if ( C4::Context->preference('AutoApprovePatronProfileSettings') ) {
365
366
                # Need to get the object from database, otherwise it is not complete enough to allow deletion
367
                # when approval has been performed.
368
                my $tmp_m = Koha::Patron::Modifications->find( { borrowernumber => $borrowernumber } );
369
                $tmp_m->approve() if $tmp_m;
370
            }
371
372
            my $patron = Koha::Patrons->find($borrowernumber);
357
            my $patron = Koha::Patrons->find($borrowernumber);
358
            $patron->request_modification( \%borrower_changes );
373
            $template->param( borrower => $patron->unblessed );
359
            $template->param( borrower => $patron->unblessed );
374
        } else {
360
        } else {
375
            my $patron = Koha::Patrons->find($borrowernumber);
361
            my $patron = Koha::Patrons->find($borrowernumber);
Lines 385-393 if ( $op eq 'cud-create' ) { Link Here
385
    my $patron   = Koha::Patrons->find($borrowernumber);
371
    my $patron   = Koha::Patrons->find($borrowernumber);
386
    my $borrower = $patron->unblessed;
372
    my $borrower = $patron->unblessed;
387
373
374
    my $self_renewal = $cgi->param('self_renewal') || 0;
375
388
    $template->param(
376
    $template->param(
389
        borrower => $borrower,
377
        borrower     => $borrower,
390
        hidden   => GetHiddenFields( $mandatory, 'edit' ),
378
        hidden       => GetHiddenFields( $mandatory, 'edit' ),
379
        self_renewal => $self_renewal
391
    );
380
    );
392
381
393
    if ( C4::Context->preference('OPACpatronimages') ) {
382
    if ( C4::Context->preference('OPACpatronimages') ) {
(-)a/opac/opac-user.pl (-14 / +24 lines)
Lines 419-438 if ( C4::Context->preference("ArticleRequests") ) { Link Here
419
    );
419
    );
420
}
420
}
421
421
422
my $self_renewal_available = $patron->is_eligible_for_self_renewal();
423
my $self_renewal_alert;
424
my $self_renewal_success = $query->param('self_renewal_success');
425
$self_renewal_alert = $patron->category->self_renewal_failure_message
426
    if defined $self_renewal_success && !$self_renewal_success;
427
my $self_renewal_confirmation_sent = $query->param('confirmation_sent');
428
422
$template->param(
429
$template->param(
423
    patron_messages            => $patron_messages,
430
    patron_messages                => $patron_messages,
424
    opacnote                   => $borr->{opacnote},
431
    opacnote                       => $borr->{opacnote},
425
    patronupdate               => $patronupdate,
432
    patronupdate                   => $patronupdate,
426
    OpacRenewalAllowed         => C4::Context->preference("OpacRenewalAllowed"),
433
    OpacRenewalAllowed             => C4::Context->preference("OpacRenewalAllowed"),
427
    userview                   => 1,
434
    userview                       => 1,
428
    tab                        => scalar $query->param('tab') || 0,
435
    tab                            => scalar $query->param('tab') || 0,
429
    SuspendHoldsOpac           => C4::Context->preference('SuspendHoldsOpac'),
436
    SuspendHoldsOpac               => C4::Context->preference('SuspendHoldsOpac'),
430
    AutoResumeSuspendedHolds   => C4::Context->preference('AutoResumeSuspendedHolds'),
437
    AutoResumeSuspendedHolds       => C4::Context->preference('AutoResumeSuspendedHolds'),
431
    OpacHoldNotes              => C4::Context->preference('OpacHoldNotes'),
438
    OpacHoldNotes                  => C4::Context->preference('OpacHoldNotes'),
432
    failed_holds               => scalar $query->param('failed_holds'),
439
    failed_holds                   => scalar $query->param('failed_holds'),
433
    opac_user_holds            => scalar $query->param('opac-user-holds')            || 0,
440
    opac_user_holds                => scalar $query->param('opac-user-holds')            || 0,
434
    opac_user_overdues         => scalar $query->param('opac-user-overdues')         || 0,
441
    opac_user_overdues             => scalar $query->param('opac-user-overdues')         || 0,
435
    opac_user_article_requests => scalar $query->param('opac-user-article-requests') || 0,
442
    opac_user_article_requests     => scalar $query->param('opac-user-article-requests') || 0,
443
    self_renewal_available         => $self_renewal_available,
444
    self_renewal_success           => $self_renewal_success,
445
    self_renewal_alert             => $self_renewal_alert,
446
    self_renewal_confirmation_sent => $self_renewal_confirmation_sent,
436
);
447
);
437
448
438
# if not an empty string this indicates to return
449
# if not an empty string this indicates to return
439
- 

Return to bug 26355