Bugzilla – Attachment 194470 Details for
Bug 26355
Allow patrons to self-renew through the OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26355: Update the OPAC templates to support the Vue island
Bug-26355-Update-the-OPAC-templates-to-support-the.patch (text/plain), 15.96 KB, created by
ByWater Sandboxes
on 2026-03-04 20:42:47 UTC
(
hide
)
Description:
Bug 26355: Update the OPAC templates to support the Vue island
Filename:
MIME Type:
Creator:
ByWater Sandboxes
Created:
2026-03-04 20:42:47 UTC
Size:
15.96 KB
patch
obsolete
>From e911a2ceea1dfe5ea630af6f0eb9811c0454a4a7 Mon Sep 17 00:00:00 2001 >From: Matt Blenkinsop <matt.blenkinsop@openfifth.co.uk> >Date: Thu, 19 Feb 2026 13:32:24 +0000 >Subject: [PATCH] Bug 26355: Update the OPAC templates to support the Vue > island > >Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org> >--- > .../bootstrap/en/modules/opac-memberentry.tt | 64 +++++++++++++++++-- > .../bootstrap/en/modules/opac-user.tt | 41 +++++++++++- > opac/opac-memberentry.pl | 23 ++----- > opac/opac-user.pl | 37 +++++++---- > 4 files changed, 125 insertions(+), 40 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >index 8a7563c775..55dc4d6573 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >@@ -92,6 +92,9 @@ > [% IF nochanges %] > <div class="alert alert-error">No changes were made.</div> > [% END %] >+ [% IF self_renewal %] >+ <div class="alert alert-info">Please verify your details to proceed with your self-renewal.</div> >+ [% END %] > [% END %] > > [% IF empty_mandatory_fields %] >@@ -241,7 +244,11 @@ > > > [% END %] > >- <form method="post" action="/cgi-bin/koha/opac-memberentry.pl" id="memberentry-form" autocomplete="off"> >+ <form >+ method="post" >+ [% IF (self_renewal) %]action="/api/v1/public/patrons/[% logged_in_user.borrowernumber | uri %]/self_renewal" id="self-renewal-form"[% ELSE %]action="/cgi-bin/koha/opac-memberentry.pl" id="memberentry-form"[% END %] >+ autocomplete="off" >+ > > [% INCLUDE 'csrf-token.inc' %] > > [% 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' ] %] >@@ -1362,7 +1369,11 @@ > [% IF OPACPatronDetails %] > <fieldset class="action"> > <input type="hidden" name="op" value="cud-update" /> >- <input type="submit" class="btn btn-primary" value="Submit update request" /> >+ [% IF (self_renewal) %] >+ <input type="submit" class="btn btn-primary" value="Submit renewal request" /> >+ [% ELSE %] >+ <input type="submit" class="btn btn-primary" value="Submit update request" /> >+ [% END %] > </fieldset> > [% END %] > [% ELSE %] >@@ -1391,16 +1402,23 @@ > [% INCLUDE 'calendar.inc' %] > <script> > $(document).ready(function() { >+ let formName >+ [% IF (self_renewal) %] >+ formName = 'self-renewal-form' >+ [% ELSE %] >+ formName = 'memberentry-form' >+ [% END %] >+ > [% IF op == 'edit' && !OPACPatronDetails %] >- $("#memberentry-form :input").attr('readonly', true); >+ $("#" + formName + " :input").attr('readonly', true); > $("#borrower_branchcode").attr('disabled',true); > $("#borrower_title").attr('disabled',true); >- $('#memberentry-form :radio').attr('disabled',true); >+ $('#' + formName + ' :radio').attr('disabled',true); > $('span.required').remove(); > $('label.required').removeClass('required'); > [% END %] > >- $("#memberentry-form").validate({ >+ $("#" + formName).validate({ > rules: { > borrower_email: { > email: true >@@ -1430,8 +1448,40 @@ > return false; > } > else { >- form.beenSubmitted = true; >- form.submit(); >+ if(formName === 'self-renewal-form') { >+ const formValues = $(form).serializeArray() >+ const renewalBody = formValues.reduce((body, curr, i) => { >+ if(curr.name.includes("borrower")) { >+ const fieldName = curr.name.replace("borrower_", "") >+ body[fieldName] = curr.value >+ } >+ if(curr.name === "patron_attribute_code") { >+ const matchingValue = formValues[i + 1].value >+ body.extended_attributes.push({code: curr.value, attribute: matchingValue}) >+ } >+ return body >+ }, {extended_attributes: []}) >+ const options = { >+ url: $(form).attr('action'), >+ method: $(form).attr('method').toUpperCase(), >+ contentType: 'application/json', >+ data: JSON.stringify({patron: renewalBody}) >+ }; >+ $.ajax(options) >+ .then(function(result) { >+ let newLocation = "/cgi-bin/koha/opac-user.pl?self_renewal_success=" + result.expiry_date >+ if(result.confirmation_sent) { >+ newLocation += "&confirmation_sent=1" >+ } >+ document.location = newLocation >+ }) >+ .fail(function(err) { >+ document.location = "/cgi-bin/koha/opac-user.pl?self_renewal_success=0"; >+ }); >+ } else { >+ form.beenSubmitted = true; >+ form.submit(); >+ } > } > } > }); >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >index 7e0e16ade5..83851a2d33 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >@@ -1,4 +1,5 @@ > [% USE raw %] >+[% USE To %] > [% USE Asset %] > [% USE Koha %] > [% USE KohaDates %] >@@ -126,18 +127,41 @@ > </div> > [% END %] > >- [% IF ( borrower.warndeparture ) %] >+ [% IF ( borrower.warndeparture) %] > <div class="alert alert-warning" id="warndeparture"> >- <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> >+ <strong>Please note:</strong >+ ><span> >+ Your library card will expire on <span id="warndeparture_date">[% borrower.warndeparture | $KohaDates %]</span>. >+ [% IF ( !self_renewal_available) %]Please contact the library for more information.[% END %]</span >+ > > [% IF ( borrower.returnbeforeexpiry ) %]<span id="warndeparture_returnbeforeexpiry"> Also note that you must return all checked out items before your library card expires.</span>[% END %] > </div> > [% END %] >- > [% IF ( borrower.warnexpired ) %] > <div class="alert alert-warning" id="warnexpired"> > <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> > </div> > [% END %] >+ [% IF ( self_renewal_available && !self_renewal_alert ) %] >+ <div class="alert alert-info" id="self_renewal_available"> >+ [% IF ( self_renewal_available ) %] >+ <span> You are eligible for self-renewal. <a href="#patronSelfRenewal" data-bs-toggle="modal">Please click here to renew your account.</a></span> >+ [% END %] >+ </div> >+ [% END %] >+ [% IF ( self_renewal_success ) %] >+ <div class="alert alert-success" id="self_renewal_success"> >+ <span>Your account has been successfully renewed until [% self_renewal_success | $KohaDates %].</span> >+ [% IF ( self_renewal_confirmation_sent ) %] >+ <span>You should receive a confirmation shortly.</span> >+ [% END %] >+ </div> >+ [% END %] >+ [% IF ( self_renewal_alert ) %] >+ <div class="alert alert-warning" id="self_renewal_alert"> >+ <span>[% self_renewal_alert | html %]</span> >+ </div> >+ [% END %] > > [% IF ( RENEW_ERROR ) %] > <div class="alert alert-warning"> >@@ -1010,6 +1034,17 @@ > </main> > <!-- /#main --> > >+[% IF ( self_renewal_available ) %] >+ <patron-self-renewal patron="[% borrowernumber | html %]"></patron-self-renewal> >+[% END %] >+ >+[% SET islands = Asset.js("js/vue/dist/islands.esm.js").match('(src="([^"]+)")').1 %] >+<script src="[% islands | $raw %]" type="module"> >+</script> >+<script type="module"> >+ import { hydrate } from "[% islands | $raw %]"; >+ hydrate(); >+</script> > [%# hold suspend modal form %] > <div id="suspendHoldModal" class="modal" tabindex="-1" role="dialog" aria-labelledby="suspendModalLabel" aria-hidden="true" data-focus="false"> > <div class="modal-dialog"> >diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl >index 1daa2daf2c..011f3f2fbe 100755 >--- a/opac/opac-memberentry.pl >+++ b/opac/opac-memberentry.pl >@@ -354,22 +354,8 @@ if ( $op eq 'cud-create' ) { > $borrower_changes{borrowernumber} = $borrowernumber; > $borrower_changes{extended_attributes} = to_json($extended_attributes_changes); > >- Koha::Patron::Modifications->search( { borrowernumber => $borrowernumber } )->delete; >- >- $borrower_changes{verification_token} = q{}; # prevent warn Missing value for PK column >- my $m = Koha::Patron::Modification->new( \%borrower_changes )->store(); >- >- #Automatically approve patron profile changes if set in syspref >- >- if ( C4::Context->preference('AutoApprovePatronProfileSettings') ) { >- >- # Need to get the object from database, otherwise it is not complete enough to allow deletion >- # when approval has been performed. >- my $tmp_m = Koha::Patron::Modifications->find( { borrowernumber => $borrowernumber } ); >- $tmp_m->approve() if $tmp_m; >- } >- > my $patron = Koha::Patrons->find($borrowernumber); >+ $patron->request_modification( \%borrower_changes ); > $template->param( borrower => $patron->unblessed ); > } else { > my $patron = Koha::Patrons->find($borrowernumber); >@@ -385,9 +371,12 @@ if ( $op eq 'cud-create' ) { > my $patron = Koha::Patrons->find($borrowernumber); > my $borrower = $patron->unblessed; > >+ my $self_renewal = $cgi->param('self_renewal') || 0; >+ > $template->param( >- borrower => $borrower, >- hidden => GetHiddenFields( $mandatory, 'edit' ), >+ borrower => $borrower, >+ hidden => GetHiddenFields( $mandatory, 'edit' ), >+ self_renewal => $self_renewal > ); > > if ( C4::Context->preference('OPACpatronimages') ) { >diff --git a/opac/opac-user.pl b/opac/opac-user.pl >index e0671b33aa..5aa491879c 100755 >--- a/opac/opac-user.pl >+++ b/opac/opac-user.pl >@@ -419,20 +419,31 @@ if ( C4::Context->preference("ArticleRequests") ) { > ); > } > >+my $self_renewal_available = $patron->is_eligible_for_self_renewal(); >+my $self_renewal_alert; >+my $self_renewal_success = $query->param('self_renewal_success'); >+$self_renewal_alert = $patron->category->self_renewal_failure_message >+ if defined $self_renewal_success && !$self_renewal_success; >+my $self_renewal_confirmation_sent = $query->param('confirmation_sent'); >+ > $template->param( >- patron_messages => $patron_messages, >- opacnote => $borr->{opacnote}, >- patronupdate => $patronupdate, >- OpacRenewalAllowed => C4::Context->preference("OpacRenewalAllowed"), >- userview => 1, >- tab => scalar $query->param('tab') || 0, >- SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'), >- AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'), >- OpacHoldNotes => C4::Context->preference('OpacHoldNotes'), >- failed_holds => scalar $query->param('failed_holds'), >- opac_user_holds => scalar $query->param('opac-user-holds') || 0, >- opac_user_overdues => scalar $query->param('opac-user-overdues') || 0, >- opac_user_article_requests => scalar $query->param('opac-user-article-requests') || 0, >+ patron_messages => $patron_messages, >+ opacnote => $borr->{opacnote}, >+ patronupdate => $patronupdate, >+ OpacRenewalAllowed => C4::Context->preference("OpacRenewalAllowed"), >+ userview => 1, >+ tab => scalar $query->param('tab') || 0, >+ SuspendHoldsOpac => C4::Context->preference('SuspendHoldsOpac'), >+ AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'), >+ OpacHoldNotes => C4::Context->preference('OpacHoldNotes'), >+ failed_holds => scalar $query->param('failed_holds'), >+ opac_user_holds => scalar $query->param('opac-user-holds') || 0, >+ opac_user_overdues => scalar $query->param('opac-user-overdues') || 0, >+ opac_user_article_requests => scalar $query->param('opac-user-article-requests') || 0, >+ self_renewal_available => $self_renewal_available, >+ self_renewal_success => $self_renewal_success, >+ self_renewal_alert => $self_renewal_alert, >+ self_renewal_confirmation_sent => $self_renewal_confirmation_sent, > ); > > # if not an empty string this indicates to return >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26355
:
191781
|
191782
|
191783
|
191784
|
191785
|
191786
|
191787
|
191788
|
191789
|
192440
|
192441
|
192442
|
192443
|
192444
|
192445
|
192446
|
192447
|
192448
|
193065
|
193066
|
193067
|
193068
|
193069
|
193070
|
193071
|
193072
|
193073
|
193074
|
193249
|
193250
|
193251
|
193252
|
193253
|
193521
|
193522
|
193523
|
193524
|
193525
|
193526
|
193527
|
193528
|
193529
|
193581
|
193635
|
193654
|
193699
|
193756
|
193757
|
193758
|
193759
|
193760
|
193761
|
193762
|
193763
|
193764
|
193765
|
193921
|
194435
|
194464
|
194465
|
194466
|
194467
|
194468
|
194469
| 194470 |
194471
|
194472
|
194473
|
194474