Bugzilla – Attachment 152496 Details for
Bug 25079
Show club enrollment question answers in staff interface
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25079: Add a 'edit' functionality to the Clubs tool in the staff interface
Bug-25079-Add-a-edit-functionality-to-the-Clubs-to.patch (text/plain), 9.87 KB, created by
Hammat wele
on 2023-06-20 23:54:26 UTC
(
hide
)
Description:
Bug 25079: Add a 'edit' functionality to the Clubs tool in the staff interface
Filename:
MIME Type:
Creator:
Hammat wele
Created:
2023-06-20 23:54:26 UTC
Size:
9.87 KB
patch
obsolete
>From f71a227b546a194aa86515938f4e226469b79ce7 Mon Sep 17 00:00:00 2001 >From: Hammat Wele <hammat.wele@inlibro.com> >Date: Wed, 12 Apr 2023 00:32:02 +0000 >Subject: [PATCH] Bug 25079: Add a 'edit' functionality to the Clubs tool in > the staff interface > >A club enrollment can be cancel but it can't be edited >This patch add a 'edit' functionality to the Clubs tool in the staff interface > >Test plan >1. Create a club template > 1.1. Go to Tools > Patron clubs > 1.2. Click on 'New Club Template' > 1.3. Fill the form > 1.4. on the 'Club fields' section, Click on Add new field > 1.5. Fill in the form > 1.6. on the 'Enrollment fields' section, Click on Add new field > 1.7. Fill in the form > 1.8. Click on Save button > >2. Creation of the club > 2.1. Go to Tools > Patron clubs > 'Clubs' section (bottom) > 2.2. Click on the 'New Club' button and select the club template create on step 1 > 2.3. Fill in the form > 2.4. Click on Save button > >3. Club enrollement > On the intranet > 3.1. Search for a pratron and open the patron folder > 3.2. Click on the 'Clubs' tab > 3.3. Find the name of the club and click on 'Enroll' > 3.4. Fill the questionnaire > 3.5. Confirm registration > ---> Note that the enrollement can be canceled but it cannot be modified > >4. Apply the patch >5. Click one more time on the 'Clubs' tab > ---> Note that the enrollement can now be modified > >Signed-off-by: Sam Lau <samalau@gmail.com> >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > clubs/patron-enroll.pl | 9 ++++-- > .../prog/en/modules/clubs/patron-clubs-tab.tt | 7 +++-- > .../prog/en/modules/clubs/patron-enroll.tt | 29 +++++++++++++++++-- > opac/svc/club/enroll | 2 +- > svc/club/enroll | 29 +++++++++++++++++-- > 5 files changed, 66 insertions(+), 10 deletions(-) > >diff --git a/clubs/patron-enroll.pl b/clubs/patron-enroll.pl >index 367b3c0f4b..b0f66bdb08 100755 >--- a/clubs/patron-enroll.pl >+++ b/clubs/patron-enroll.pl >@@ -24,6 +24,7 @@ use CGI; > use C4::Auth qw( get_template_and_user ); > use C4::Output qw( output_html_with_http_headers ); > use Koha::Clubs; >+use Koha::Club::Enrollment::Fields; > > my $cgi = CGI->new; > >@@ -38,12 +39,16 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > > my $id = $cgi->param('id'); > my $borrowernumber = $cgi->param('borrowernumber'); >+my $enrollent_id = scalar $cgi->param('enrollent_id'); > > my $club = Koha::Clubs->find($id); >+my @club_enrollment_fields = Koha::Club::Enrollment::Fields->search({'club_enrollment_id'=> $enrollent_id})->as_list; > > $template->param( >- club => $club, >- borrowernumber => $borrowernumber, >+ club => $club, >+ borrowernumber => $borrowernumber, >+ enrollent_id => $enrollent_id || 0, >+ club_enrollment_fields => \@club_enrollment_fields, > ); > > output_html_with_http_headers( $cgi, $cookie, $template->output ); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt >index 53dd18dc7a..6b2f5f93d3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-clubs-tab.tt >@@ -21,6 +21,9 @@ > <td>[% e.date_enrolled | $KohaDates %]</td> > [% IF CAN_user_clubs_enroll %] > <td> >+ <button class="btn btn-xs btn-default" onclick="loadEnrollmentForm([% e.club.id %],[% e.id %])"> >+ <i class="fa fa-edit"></i>Modify enrollment >+ </button> > <button class="btn btn-xs btn-default" onclick="cancelEnrollment( [% e.id | html %] )"> > <i class="fa fa-times"></i> Cancel enrollment > </button> >@@ -72,9 +75,9 @@ $("#table_clubnoenrollmemnts, #table_clubenrollments").dataTable($.extend(true, > })); > > [% IF CAN_user_clubs_enroll %] >-function loadEnrollmentForm( id ) { >+function loadEnrollmentForm( id, enrollent_id = 0 ) { > $("body").css("cursor", "progress"); >- $('#clubs_panel').load('/cgi-bin/koha/clubs/patron-enroll.pl?borrowernumber=[% borrowernumber | html %]&id=' + id, function() { >+ $('#clubs_panel').load('/cgi-bin/koha/clubs/patron-enroll.pl?borrowernumber=[% borrowernumber | html %]&id=' + id +'&enrollent_id='+ enrollent_id, function() { > $("body").css("cursor", "default"); > }); > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-enroll.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-enroll.tt >index 64adfafd71..46f60e001e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-enroll.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/clubs/patron-enroll.tt >@@ -1,6 +1,6 @@ > [% USE AuthorisedValues %] > >-<h1> >+<h1 id="heading"> > Enroll in <em>[% club.name | html %]</em> > </h1> > >@@ -8,8 +8,30 @@ > <form id="patron-enrollment-form"> > <input type="hidden" name="id" value="[% club.id | html %]" /> > <input type="hidden" name="borrowernumber" value="[% borrowernumber | html %]" /> >+ <input type="hidden" name="enrollent_id" value="[% enrollent_id | html %]" /> > <fieldset class="rows"> > <ol> >+ [% IF club_enrollment_fields %] >+ [% FOREACH f IN club.club_template.club_template_enrollment_fields %] >+ [% FOREACH c IN club_enrollment_fields %] >+ [% IF f.id == c.club_template_enrollment_field_id %] >+ <li> >+ <label>[% f.name %]</label> >+ [% IF f.authorised_value_category %] >+ <select name="[% f.id %]"> >+ [% FOREACH a IN AuthorisedValues.Get( f.authorised_value_category ) %] >+ <option value="[% a.authorised_value %]" [% IF a.authorised_value == c.value %]selected="selected"[% END %]>[% a.lib %]</option> >+ [% END %] >+ </select> >+ [% ELSE %] >+ <input type="text" name="[% f.id %]" value="[% c.value %]"/> >+ [% END %] >+ <span class="hint">[% f.description %]</span> >+ </li> >+ [% END %] >+ [% END %] >+ [% END %] >+ [% ELSE %] > [% FOREACH f IN club.club_template.club_template_enrollment_fields %] > <li> > <label>[% f.name | html %]</label> >@@ -25,7 +47,7 @@ > <span class="hint">[% f.description | html %]</span> > </li> > [% END %] >- >+ [% END %] > <li> > <a href="#" class="btn btn-sm btn-default" onclick="addEnrollment(); return false;">Finish enrollment</a> > <a class="cancel" href="#" onclick="showClubs(); return false;">Cancel</a> >@@ -36,6 +58,9 @@ > </div> > > <script> >+if([% enrollent_id %]){ >+ $("#heading").html(_("Modifying enrollment")+" <em>[% club.name %]</em>"); >+} > function addEnrollment() { > $("body").css("cursor", "progress"); > $.ajax({ >diff --git a/opac/svc/club/enroll b/opac/svc/club/enroll >index aff1d51fb9..ed19fc89b0 100755 >--- a/opac/svc/club/enroll >+++ b/opac/svc/club/enroll >@@ -64,7 +64,7 @@ if ( $borrowernumber && $id ) { > { > club_enrollment_id => $enrollment->id(), > club_template_enrollment_field_id => $e->id(), >- value => $cgi->param( $e->id() ), >+ value => scalar $cgi->param( $e->id() ), > } > )->store(); > } >diff --git a/svc/club/enroll b/svc/club/enroll >index 9c88c54717..0d7762b8b9 100755 >--- a/svc/club/enroll >+++ b/svc/club/enroll >@@ -38,11 +38,29 @@ if ( $auth_status ne "ok" ) { > > my $id = $cgi->param('id'); > my $borrowernumber = $cgi->param('borrowernumber'); >+my $enrollent_id = scalar $cgi->param('enrollent_id'); > > my $club = Koha::Clubs->find($id); > > my $enrollment; >-if ($club) { >+ >+my @club_enrollment_fields; >+ >+if($enrollent_id){ >+ my @enrollment_fields = $club->club_template()->club_template_enrollment_fields()->as_list; >+ @club_enrollment_fields = Koha::Club::Enrollment::Fields->search({'club_enrollment_id'=> $enrollent_id})->as_list; >+ >+ foreach my $club_enrollment_field (@club_enrollment_fields){ >+ foreach my $e (@enrollment_fields){ >+ if($e->id()==$club_enrollment_field->club_template_enrollment_field_id){ >+ my $value = $cgi->param( $e->id() ); >+ $club_enrollment_field->value($value); >+ $club_enrollment_field->update(); >+ } >+ } >+ } >+} >+elsif ($club) { > $enrollment = Koha::Club::Enrollment->new( > { > club_id => $club->id(), >@@ -61,7 +79,7 @@ if ($club) { > { > club_enrollment_id => $enrollment->id(), > club_template_enrollment_field_id => $e->id(), >- value => $cgi->param( $e->id() ), >+ value => scalar $cgi->param( $e->id() ), > } > )->store(); > } >@@ -71,4 +89,9 @@ if ($club) { > binmode STDOUT, ':encoding(UTF-8)'; > print $cgi->header( -type => 'text/plain', -charset => 'UTF-8' ); > >-print to_json( { success => $enrollment ? 1 : 0 } ); >+if($enrollent_id){ >+ print to_json( { success => @club_enrollment_fields ? 1 : 0 } ); >+} >+else{ >+ print to_json( { success => $enrollment ? 1 : 0 } ); >+} >\ No newline at end of file >-- >2.34.1
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 25079
:
149544
|
149545
|
151603
|
151604
|
151818
|
151819
|
151820
| 152496 |
152497
|
152498