Bug 34188: Require Library Branch Selection when Logging in
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / clubs / patron-enroll.tt
1 [% USE AuthorisedValues %]
2
3 <h1 id="heading">
4     Enroll in <em>[% club.name | html %]</em>
5 </h1>
6
7 <div class="container">
8     <form id="patron-enrollment-form">
9         <input type="hidden" name="id" value="[% club.id | html %]" />
10         <input type="hidden" name="borrowernumber" value="[% borrowernumber | html %]" />
11         <input type="hidden" name="enrollent_id" value="[% enrollent_id | html %]" />
12         <fieldset class="rows">
13             <ol>
14             [% IF club_enrollment_fields %]
15                 [% FOREACH f IN club.club_template.club_template_enrollment_fields %]
16                     [% FOREACH c IN club_enrollment_fields %]
17                         [% IF f.id == c.club_template_enrollment_field_id %]
18                             <li>
19                                 <label>[% f.name | html %]</label>
20                                 [% IF f.authorised_value_category %]
21                                     <select name="[% f.id | html %]">
22                                         [% FOREACH a IN AuthorisedValues.Get( f.authorised_value_category ) %]
23                                             [% IF a.authorised_value == c.value %]
24                                                 <option value="[% a.authorised_value | html %]" selected="selected">[% a.lib | html %]</option>
25                                             [% ELSE %]
26                                                 <option value="[% a.authorised_value | html %]">[% a.lib | html %]</option>
27                                             [% END %]
28                                         [% END %]
29                                     </select>
30                                 [% ELSE %]
31                                     <input type="text" name="[% f.id | html %]" value="[% c.value | html %]"/>
32                                 [% END %]
33                                 <span class="hint">[% f.description | html %]</span>
34                             </li>
35                         [% END %]
36                     [% END %]
37                 [% END %]
38             [% ELSE %]
39                 [% FOREACH f IN club.club_template.club_template_enrollment_fields %]
40                     <li>
41                         <label>[% f.name | html %]</label>
42                         [% IF f.authorised_value_category %]
43                             <select name="[% f.id | html %]">
44                                 [% FOREACH a IN AuthorisedValues.Get( f.authorised_value_category ) %]
45                                     <option value="[% a.authorised_value | html %]">[% a.lib | html %]</option>
46                                 [% END %]
47                             </select>
48                         [% ELSE %]
49                             <input type="text" name="[% f.id | html %]" />
50                         [% END %]
51                         <span class="hint">[% f.description | html %]</span>
52                     </li>
53                 [% END %]
54             [% END %]
55                 <li>
56                     <a href="#" class="btn btn-sm btn-default" onclick="addEnrollment(); return false;">Finish enrollment</a>
57                     <a class="cancel" href="#" onclick="showClubs(); return false;">Cancel</a>
58                 </li>
59             </ol>
60         </fieldset>
61     </form>
62 </div>
63
64 <script>
65 if([% enrollent_id | html %]){
66     $("#heading").html(_("Modifying enrollment")+" <em>[% club.name | html %]</em>");
67 }
68 function addEnrollment() {
69     $("body").css("cursor", "progress");
70     $.ajax({
71         type: "POST",
72         url: '/cgi-bin/koha/svc/club/enroll',
73         data: $( "#patron-enrollment-form" ).serialize(),
74         success: function( data ) {
75             if ( data.success ) {
76                 $('#clubs_panel').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber | html %]&id=[% club.id | html %]', function() {
77                     $("body").css("cursor", "default");
78                 });
79             } else {
80                 alert(_("Unable to create enrollment!"));
81             }
82         },
83         dataType: 'json'
84     });
85     return false;
86 }
87
88 function showClubs() {
89     $("body").css("cursor", "progress");
90     $('#clubs_panel').load('/cgi-bin/koha/clubs/patron-clubs-tab.pl?borrowernumber=[% borrowernumber | html %]&id=[% club.id | html %]', function() {
91         $("body").css("cursor", "default");
92     });
93 }
94 </script>