Bug 18911: (follow-up) We should save changes with a POST
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / modules / opac-messaging.tt
1 [% USE Koha %]
2 [% INCLUDE 'doc-head-open.inc' %]
3 <title>[% IF ( LibraryNameTitle ) %][% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %][% ELSE %]Koha online[% END %] catalog &rsaquo; Your messaging settings</title>
4 [% INCLUDE 'doc-head-close.inc' %]
5 [% BLOCK cssinclude %][% END %]
6 </head>
7 [% INCLUDE 'bodytag.inc' bodyid='opac-messaging' %]
8 [% INCLUDE 'masthead.inc' %]
9
10 <div class="main">
11     <ul class="breadcrumb">
12         <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
13         <li><a href="/cgi-bin/koha/opac-user.pl">[% INCLUDE 'patron-title.inc' patron = logged_in_user %]</a> <span class="divider">&rsaquo;</span></li>
14         <li><a href="#">Your messaging settings</a></li>
15     </ul>
16
17     <div class="container-fluid">
18         <div class="row-fluid">
19             <div class="span2">
20                 <div id="navigation">
21                     [% INCLUDE 'navigation.inc' IsPatronPage=1 %]
22                 </div>
23             </div>
24             <div class="span10">
25                 [% IF Koha.Preference( 'EnhancedMessagingPreferencesOPAC' )  %]
26                 <div id="usermessaging" class="maincontent">
27                     <h3>Your messaging settings</h3>
28                     [% IF ( settings_updated ) %]
29                         <div class="alert alert-success"><h4>Settings updated</h4></div>
30                     [% END %]
31                     <form action="/cgi-bin/koha/opac-messaging.pl" method="post" name="opacmessaging">
32                         <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
33                         <input type="hidden" name="modify" value="yes" />
34
35                             <table class="table table-bordered table-condensed table-striped">
36                                 <thead>
37                                     <tr>
38                                         <th>&nbsp;</th>
39                                         <th>Days in advance</th>
40                                         [% IF ( SMSSendDriver ) %]<th>SMS</th>[% END %]
41                                         [% IF ( TalkingTechItivaPhone ) %]<th>Phone</th>[% END %]
42                                         <th>Email</th>
43                                         <th>Digests only <i id="info_digests" data-toggle="tooltip" title="You can ask for a digest to reduce the number of messages. Messages will be saved and sent as a single message." data-placement="right" class="fa fa-info-circle"></i></th>
44                                     </tr>
45                                 </thead>
46                                 <tbody>
47                                 [% FOREACH messaging_preference IN messaging_preferences %]
48                                     <tr>
49                                         <td>[% IF ( messaging_preference.Item_Due ) %]Item due
50                                               [% ELSIF ( messaging_preference.Advance_Notice ) %]Advance notice
51                                               [% ELSIF ( messaging_preference.Upcoming_Events ) %]Upcoming events
52                                               [% ELSIF ( messaging_preference.Hold_Filled ) %]Hold filled
53                                               [% ELSIF ( messaging_preference.Item_Check_in ) %]Item check-in
54                                               [% ELSIF ( messaging_preference.Item_Checkout ) %]Item checkout
55                                               [% ELSE %]Unknown [% END %]</td>
56                                         [% IF ( messaging_preference.takes_days ) %]
57                                             <td><select class="input-mini" name="[% messaging_preference.message_attribute_id | html %]-DAYS">
58                                             [% FOREACH select_day IN messaging_preference.select_days %]
59                                                 [% IF ( select_day.selected ) %]
60                                                     <option value="[% select_day.day | html %]" selected="selected">[% select_day.day | html %]</option>
61                                                 [% ELSE %]
62                                                     <option value="[% select_day.day | html %]">[% select_day.day | html %]</option>
63                                                 [% END %]
64                                             [% END %]
65                                             </select></td>
66                                         [% ELSE %]
67                                             <td>-</td>
68                                         [% END %]
69                                         [% IF ( SMSSendDriver ) %]
70                                             [% IF ( messaging_preference.transport_sms ) %]
71                                                 <td>
72                                                     [% IF ( messaging_preference.transports_sms ) %]
73                                                       <input type="checkbox" id="sms[% messaging_preference.message_attribute_id | html %]" name="[% messaging_preference.message_attribute_id | html %]" value="sms" checked="checked" />
74                                                     [% ELSE %]
75                                                         <input type="checkbox" id="sms[% messaging_preference.message_attribute_id | html %]" name="[% messaging_preference.message_attribute_id | html %]" value="sms" />
76                                                     [% END %]
77                                                 </td>
78                                             [% ELSE %]
79                                                 <td>-</td>
80                                             [% END %]
81                                         [% END %]
82                                         [% IF ( TalkingTechItivaPhone ) %]
83                                             [% IF ( messaging_preference.transport_phone ) %]
84                                             <td>
85                                               [% IF ( messaging_preference.transports_phone ) %]
86                                               <input type="checkbox"
87                                                          id="phone[% messaging_preference.message_attribute_id | html %]"
88                                                          name="[% messaging_preference.message_attribute_id | html %]"
89                                                          value="phone" checked="checked" onclick = "document.opacmessaging.none[% messaging_preference.message_attribute_id | html %].checked=false;" />
90                                               [% ELSE %]
91                                               <input type="checkbox"
92                                                          id="phone[% messaging_preference.message_attribute_id | html %]"
93                                                          name="[% messaging_preference.message_attribute_id | html %]"
94                                                          value="phone" onclick = "document.opacmessaging.none[% messaging_preference.message_attribute_id | html %].checked=false;" />
95                                               [% END %]
96                                             </td>
97                                             [% ELSE %]
98                                                 <td>-</td>
99                                             [% END %]
100                                         [% END %]
101
102                                         [% IF ( messaging_preference.transport_email ) %]
103                                             <td>
104                                                 [% IF ( messaging_preference.transports_email ) %]
105                                                     <input type="checkbox" id="email[% messaging_preference.message_attribute_id | html %]" name="[% messaging_preference.message_attribute_id | html %]" value="email" checked="checked" onclick = "document.opacmessaging.none[% messaging_preference.message_attribute_id | html %].checked=false;" />
106                                                 [% ELSE %]
107                                                     <input type="checkbox" id="email[% messaging_preference.message_attribute_id | html %]" name="[% messaging_preference.message_attribute_id | html %]" value="email" onclick = "document.opacmessaging.none[% messaging_preference.message_attribute_id | html %].checked=false;" />
108                                                 [% END %]
109                                             </td>
110                                         [% ELSE %]
111                                             <td>-</td>
112                                         [% END %]
113
114                                         [% IF ( messaging_preference.has_digest ) %]
115                                             <td>
116                                                 [% IF ( messaging_preference.digest ) %]
117                                                     <input type="checkbox" id="digest[% messaging_preference.message_attribute_id | html %]" value="[% messaging_preference.message_attribute_id | html %]" name="digest" checked="checked" onclick = "document.opacmessaging.none[% messaging_preference.message_attribute_id | html %].checked=false;" />
118                                                 [% ELSE %]
119                                                     <input type="checkbox" id="digest[% messaging_preference.message_attribute_id | html %]" value="[% messaging_preference.message_attribute_id | html %]" name="digest" onclick = "document.opacmessaging.none[% messaging_preference.message_attribute_id | html %].checked=false;" />
120                                                 [% END %]
121                                             </td>
122                                         [% ELSE %]
123                                         <td>-</td>
124                                         [% END %]
125
126                                     </tr>
127                                 [% END # / FOREACH messaging_preferences%]
128                             </tbody>
129                         </table>
130
131                         <fieldset class="rows">
132                             [% IF ( SMSSendDriver ) %]
133                                 <ol><li><label>Notice:</label>Some charges for text messages may be incurred when using this service. Please check with your mobile service provider if you have questions.</li></ol>
134                                 <ol><li>
135                                     <label for="SMSnumber">SMS number:</label> <input type="text" id="SMSnumber" name="SMSnumber" value="[% SMSnumber | html %]" pattern="^\+?[1-9]\d{1,14}$" />
136                                     <i>Please enter numbers only. <b>(123) 456-7890</b> would be entered as <b>1234567890</b>.</i>
137                                 </li></ol>
138                             [% END %]
139
140                             [% IF ( SMSSendDriver == 'Email' ) %]
141                                 <ol><li>
142                                     <label for="sms_provider_id">SMS provider:</label>
143                                     <select id="sms_provider_id" name="sms_provider_id">
144                                         <option value="">Unknown</option>
145                                         [% FOREACH s IN sms_providers %]
146                                             [% IF s.id == sms_provider_id %]
147                                                 <option value="[% s.id | html %]" selected="selected">[% s.name | html %]</option>
148                                             [% ELSE %]
149                                                 <option value="[% s.id | html %]">[% s.name | html %]</option>
150                                             [% END %]
151                                         [% END %]
152                                     </select>
153                                     <i>Please contact a library staff member if you are unsure of your mobile service provider, or you do not see your provider in this list.</i>
154                                 </li></ol>
155                             [% END %]
156
157                             [% IF Koha.Preference('TranslateNotices') %]
158                                 <ol>
159                                     <li>
160                                         <label for="lang">Preferred language for notices: </label>
161                                         <select id="lang" name="lang">
162                                             <option value="default">Default</option>
163                                             [% FOR language IN languages %]
164                                                 [% FOR sublanguage IN language.sublanguages_loop %]
165                                                     [% IF language.plural %]
166                                                         [% IF sublanguage.rfc4646_subtag == patron_lang %]
167                                                             <option value="[% sublanguage.rfc4646_subtag | html %]" selected="selected">[% sublanguage.native_description | html %] [% sublanguage.region_description | html %] ([% sublanguage.rfc4646_subtag | html %])</option>
168                                                         [% ELSE %]
169                                                             <option value="[% sublanguage.rfc4646_subtag | html %]">[% sublanguage.native_description | html %] [% sublanguage.region_description | html %] ([% sublanguage.rfc4646_subtag | html %])</option>
170                                                         [% END %]
171                                                     [% ELSE %]
172                                                         [% IF sublanguage.rfc4646_subtag == patron_lang %]
173                                                             <option value="[% sublanguage.rfc4646_subtag | html %]" selected="selected">[% sublanguage.native_description | html %] ([% sublanguage.rfc4646_subtag | html %])</option>
174                                                         [% ELSE %]
175                                                             <option value="[% sublanguage.rfc4646_subtag | html %]">[% sublanguage.native_description | html %] ([% sublanguage.rfc4646_subtag | html %])</option>
176                                                         [% END %]
177                                                     [% END # /IF language.plural %]
178                                                 [% END # /FOR sublanguage %]
179                                             [% END #/FOR language %]
180                                         </select> <!-- /#lang -->
181                                     </li>
182                                 </ol>
183                             [% END #/IF Koha.Preference('TranslateNotices') %]
184
185                         </fieldset>
186
187                         <fieldset class="action">
188                           <input type="submit" value="Submit changes" class="btn" /> <a class="cancel" href="/cgi-bin/koha/opac-user.pl">Cancel</a>
189                         </fieldset>
190                     </form>
191                 </div> <!-- / #usermessaging -->
192                 [% ELSE %]
193                     <h4>You are not allowed to call this page directly</h4>
194                 [% END %]
195            </div> <!-- / .span10 -->
196         </div> <!-- / .row-fluid -->
197     </div> <!-- / .container-fluid -->
198 </div> <!-- / .main -->
199
200 [% INCLUDE 'opac-bottom.inc' %]
201 [% BLOCK jsinclude %]
202 <script>//<![CDATA[
203   $(document).ready(function(){
204     $(".none").click(function(){
205       if($(this).attr("checked")){
206         var rowid = $(this).attr("id");
207         newid = Number(rowid.replace("none",""))
208           $("#sms"+newid).removeAttr("checked");
209           $("#email"+newid).removeAttr("checked");
210           $("#digest"+newid).removeAttr("checked");
211           $("#rss"+newid).removeAttr("checked");
212       }
213     });
214     $("#info_digests").tooltip();
215   });
216
217 function normalizeSMS(value){
218   let has_plus = value.charAt(0) === '+';
219   let new_value = value.replace(/\D/g,'');
220   if ( has_plus ) new_value = '+' + new_value;
221   return new_value;
222 }
223
224 var sms_input = document.getElementById('SMSnumber');
225
226 if (typeof sms_input !== 'undefined' && sms_input !== null) {
227   sms_input.addEventListener('keyup', function(){
228     var field = sms_input.value;
229     sms_input.value = normalizeSMS(field);
230   });
231
232   sms_input.addEventListener('paste', function(event) {
233     let paste = (event.clipboardData || window.clipboardData).getData('text');
234     setTimeout(function () {
235       sms_input.value = normalizeSMS(paste);
236     }, 100);
237   });
238 }
239
240 //]]>
241 </script>
242 [% END %]