Bug 34945: Remove the use of event attributes from OPAC clubs tab
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / clubs / enroll.tt
1 [% USE AuthorisedValues %]
2
3 <h2>
4     Enroll in <em>[% club.name | html %]</em>
5 </h2>
6
7 <div class="container">
8     <form id="patron-enrollment-form">
9         <legend class="sr-only">Enrollment</legend>
10         <input type="hidden" name="id" value="[% club.id | html %]" />
11         <input type="hidden" name="borrowernumber" value="[% borrowernumber | html %]" />
12         <fieldset class="rows">
13             <ol>
14                 [% FOREACH f IN club.club_template.club_template_enrollment_fields %]
15                     <li>
16                         <label>[% f.name | html %]</label>
17                         [% IF f.authorised_value_category %]
18                             <select name="[% f.id | html %]">
19                                 [% FOREACH a IN AuthorisedValues.Get( f.authorised_value_category ) %]
20                                     <option value="[% a.authorised_value | html %]">[% a.lib | html %]</option>
21                                 [% END %]
22                             </select>
23                         [% ELSE %]
24                             <input type="text" name="[% f.id | html %]" />
25                         [% END %]
26                         <span class="hint">[% f.description | html %]</span>
27                     </li>
28                 [% END %]
29             </ol>
30         </fieldset>
31         <fieldset class="action">
32             <button class="btn btn-primary add_enrollment">Finish enrollment</button>
33             <a href="#" class="cancel show_clubs">Cancel</a>
34         </fieldset>
35     </form>
36 </div>
37
38 <script>
39 function addEnrollment() {
40     $("body").css("cursor", "progress");
41     $.ajax({
42         type: "POST",
43         url: '/cgi-bin/koha/svc/club/enroll',
44         data: $( "#patron-enrollment-form" ).serialize(),
45         success: function( data ) {
46             if ( data.success ) {
47                 $('#opac-user-clubs_panel').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrowernumber | html %]&id=[% club.id | html %]', function() {
48                     $("body").css("cursor", "default");
49                 });
50             } else {
51                 alert(_("Unable to create enrollment!"));
52             }
53         },
54         dataType: 'json'
55     });
56     return false;
57 }
58
59 function showClubs() {
60     $("body").css("cursor", "progress");
61     $('#opac-user-clubs_panel').load('/cgi-bin/koha/clubs/clubs-tab.pl?borrowernumber=[% borrowernumber | html %]&id=[% club.id | html %]', function() {
62         $("body").css("cursor", "default");
63     });
64 }
65
66     $(document).ready(function(){
67         $(".add_enrollment").on("click", function(e){
68             e.preventDefault();
69             addEnrollment();
70         });
71
72         $(".show_clubs").on("click", function(e){
73             e.preventDefault();
74             showClubs();
75         });
76     });
77 </script>