Bug 13618: Remove html filter for NEXT
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / usage_statistics.tt
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% USE Koha %]
5 [% USE KohaDates %]
6 [% USE Price %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Koha &rsaquo; Administration &rsaquo; Koha usage statistics</title>
9 [% INCLUDE 'doc-head-close.inc' %]
10 [% Asset.css("lib/leaflet/leaflet.css") | $raw %]
11 </head>
12
13 <body id="admin_usage_statistics" class="admin">
14 [% INCLUDE 'header.inc' %]
15 [% INCLUDE 'cat-search.inc' %]
16
17 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; Usage statistics</div>
18
19 <div id="doc3" class="yui-t2">
20    <div id="bd">
21     <div id="yui-main">
22     <div class="yui-b">
23
24 [% FOR m IN messages %]
25     <div class="dialog [% m.type | html %]">
26         [% SWITCH m.code %]
27         [% CASE 'error_on_update' %]
28             An error occurred when updating this patron category. Perhaps it already exists.
29         [% CASE 'error_on_insert' %]
30             An error occurred when inserting this patron category. The patron category might already exist.
31         [% CASE 'error_on_delete' %]
32             An error occurred when deleting this patron category. Check the logs.
33         [% CASE 'success_on_update' %]
34             Patron category updated successfully.
35         [% CASE 'success_on_insert' %]
36             Patron category inserted successfully.
37         [% CASE 'success_on_delete' %]
38             Patron category deleted successfully.
39         [% CASE 'already_exists' %]
40             This patron category already exists.
41         [% CASE %]
42             [% m.code | html %]
43         [% END %]
44     </div>
45 [% END %]
46
47 [% IF NOT Koha.Preference('UsageStats') %]
48     <div class="dialog message">You are not sharing any data with the Koha community</div>
49 [% END %]
50
51     <form id="category_form" action="/cgi-bin/koha/admin/usage_statistics.pl" method="post">
52         <h1>Modify the statistics you share with the Koha community</h1>
53         <fieldset class="rows">
54             <ol style="float:left;">
55                 <li>
56                     <label for="UsageStats">Share my Koha usage statistics: </label>
57                     <select name="UsageStats" id="UsageStats">
58                     [% IF Koha.Preference('UsageStats') %]
59                         <option value="1" selected="selected">Yes</option>
60                         <option value="0">No</option>
61                     [% ELSE %]
62                         <option value="1">Yes</option>
63                         <option value="0" selected="selected">No</option>
64                     [% END %]
65                     </select>
66                 </li>
67                 <li>
68                     <label for="UsageStatsCountry">Your country: </label>
69                     [% SET UsageStatsCountry = Koha.Preference('UsageStatsCountry') %]
70                     [% SET IsUsageStatsCountryValid = 0 %]
71                     [% IF NOT UsageStatsCountry %]
72                         [% SET IsUsageStatsCountryValid = 1 %]
73                     [% END %]
74                     [% PROCESS 'country-list.inc' %]
75                     <select name="UsageStatsCountry" id="UsageStatsCountry">
76                         <option value="">&nbsp;</option>
77                         [% FOR country IN countries %]
78                             [% IF country == UsageStatsCountry %]
79                                 <option value="[% country | html %]" selected="selected">[% country | html %]</option>
80                                 [% SET IsUsageStatsCountryValid = 1 %]
81                             [% ELSE %]
82                                 <option value="[% country | html %]">[% country | html %]</option>
83                             [% END %]
84                         [% END %]
85                     </select>
86                     [% UNLESS IsUsageStatsCountryValid %]
87                         Note: The value of your system preference 'UsageStatsCountry' is not valid ([% UsageStatsCountry | html %]).
88                         Please select a valid one.
89                     [% END %]
90                 </li>
91                 <li>
92                     <label for="UsageStatsLibraryName">Library name: </label>
93                     <input type="text" value="[% Koha.Preference('UsageStatsLibraryName') | html %]" name="UsageStatsLibraryName" id="UsageStatsLibraryName" />
94                 </li>
95                 <li>
96                     <label for="UsageStatsLibraryType">Library type: </label>
97                     [% SET UsageStatsLibraryType = Koha.Preference('UsageStatsLibraryType') %]
98                     <select name="UsageStatsLibraryType" id="UsageStatsLibraryType">
99                         <option value="">&nbsp;</option>
100                         [% IF UsageStatsLibraryType == 'public' %]
101                             <option value="public" selected="selected">Public</option>
102                         [% ELSE %]
103                             <option value="public">Public</option>
104                         [% END %]
105
106                         [% IF UsageStatsLibraryType == 'school' %]
107                             <option value="school" selected="selected">School</option>
108                         [% ELSE %]
109                             <option value="school">School</option>
110                         [% END %]
111                         [% IF UsageStatsLibraryType == 'academic' %]
112                             <option value="academic" selected="selected">Academic</option>
113                         [% ELSE %]
114                             <option value="academic">Academic</option>
115                         [% END %]
116                         [% IF UsageStatsLibraryType == 'research' %]
117                             <option value="research" selected="selected">Research</option>
118                         [% ELSE %]
119                             <option value="research">Research</option>
120                         [% END %]
121                         [% IF UsageStatsLibraryType == 'private' %]
122                             <option value="private" selected="selected">Private</option>
123                         [% ELSE %]
124                             <option value="private">Private</option>
125                         [% END %]
126                         [% IF UsageStatsLibraryType == 'societyAssociation' %]
127                             <option value="societyAssociation" selected="selected">Society or association</option>
128                         [% ELSE %]
129                             <option value="societyAssociation">Society or association</option>
130                         [% END %]
131                         [% IF UsageStatsLibraryType == 'corporate' %]
132                             <option value="corporate" selected="selected">Corporate</option>
133                         [% ELSE %]
134                             <option value="corporate">Corporate</option>
135                         [% END %]
136                         [% IF UsageStatsLibraryType == 'government' %]
137                             <option value="government" selected="selected">Government</option>
138                         [% ELSE %]
139                             <option value="government">Government</option>
140                         [% END %]
141                         [% IF UsageStatsLibraryType == 'religiousOrg' %]
142                             <option value="religiousOrg" selected="selected">Religious organization</option>
143                         [% ELSE %]
144                             <option value="religiousOrg">Religious organization</option>
145                         [% END %]
146                         [% IF UsageStatsLibraryType == 'subscription' %]
147                             <option value="subscription" selected="selected">Subscription</option>
148                         [% ELSE %]
149                             <option value="subscription">Subscription</option>
150                         [% END %]
151                     </select>
152                 </li>
153                 <li>
154                     <label for="UsageStatsLibraryUrl">Library URL: </label>
155                     <input type="text" name="UsageStatsLibraryUrl" value="[% Koha.Preference('UsageStatsLibraryUrl') | html %]" id="UsageStatsLibraryUrl" />
156                 </li>
157                 <li>
158                     <span class="label">Last update: </span>
159                     [% IF UsageStatsLastUpdateTime %]
160                         [% UsageStatsLastUpdateTime | html %]
161                     [% ELSE %]
162                         Your data have never been shared
163                     [% END %]
164                 </li>
165                 <li>
166                     <label for="UsageStatsGeolocation">Geolocation: </label>
167                     <input id="UsageStatsGeolocation" name="UsageStatsGeolocation" value="[% Koha.Preference('UsageStatsGeolocation') | html %]" type="text" value="[% Koha.Preference('UsageStatsLibrariesInfo') | html %]" size="35" readonly="readonly" />
168                     <a href="#" class="change_geolocation" data-branchname="" data-id="UsageStatsGeolocation"><img src="[% interface | html %]/lib/leaflet/images/marker-icon.png" title="Set geolocation" style="max-height: 2em;" /></a>
169                 </li>
170                 <li>
171                     <label for="UsageStatsLibrariesInfo">Libraries informations: </label>
172                     <select name="UsageStatsLibrariesInfo" id="UsageStatsLibrariesInfo">
173                         [% IF Koha.Preference('UsageStatsLibrariesInfo') %]
174                             <option value="1" selected="selected">Yes</option>
175                             <option value="0">No</option>
176                         [% ELSE %]
177                             <option value="1">Yes</option>
178                             <option value="0" selected="selected">No</option>
179                         [% END %]
180                     </select>
181                 </li>
182
183                 <li id="libraries_info">
184                     <fieldset class="rows">
185                     <legend>Libraries</legend>
186                     <ol>
187                         [% FOR l IN libraries %]
188                         <li>
189                             <label for="[% l.branchcode | html %]">[% l.branchname | html %]: </label>
190                             <div style="float:left;">
191                                 <div>Country: [% l.branchcountry | html %]</div>
192                                 <div>Url: [% l.branchurl | html %]</div>
193                                 <div>
194                                     Geolocation: <input type="text" id="geolocation_[% l.branchcode | html %]" name="geolocation_[% l.branchcode | html %]" value="[% l.geolocation | html %]" size="35" readonly="readonly" />
195                                     <a href="#" class="change_geolocation" data-branchname="[% l.branchname | html %]" data-id="geolocation_[% l.branchcode | html %]"><img src="[% interface | html %]/lib/leaflet/images/marker-icon.png" title="Set geolocation for [% l.branchname | html %]" style="max-height: 2em;" /></a>
196                                 </div>
197                             </div>
198                         </li>
199                         [% END %]
200                     </ol>
201                     </fieldset>
202                 </li>
203                 <li>
204                     <label for="MyPublicLink">See your public page: </label>
205                     [% IF Koha.Preference('UsageStatsPublicID') %]
206                         [% SET my_url = 'https://hea.koha-community.org/libraries/' _  Koha.Preference('UsageStatsPublicID') %]
207                         <a href="[% my_url | html %]">[% my_url | html %]</a>
208                     [% ELSE %]
209                         You do not have anything public yet.
210                     [% END %]
211                 </li>
212
213             </ol>
214             <div style="clear:right"></div>
215         <div id="mapid" style="width: 600px; height: 400px; margin-left: 40%:"></div>
216     </fieldset>
217
218         <fieldset class="action">
219             <input type="hidden" name="op" value="update" />
220             <input type="submit" value="Update your statistics usage" />
221             <a class="cancel" href="/cgi-bin/koha/admin/usage_statistics.pl">Cancel</a>
222         </fieldset>
223     </form>
224 </div>
225 </div>
226 <div class="yui-b">
227 [% INCLUDE 'admin-menu.inc' %]
228 </div>
229 </div>
230
231 [% MACRO jsinclude BLOCK %]
232     [% INCLUDE 'calendar.inc' %]
233     [% Asset.js("js/admin-menu.js") | $raw %]
234     <script src="[% interface | html %]/lib/leaflet/leaflet.js"></script>
235     <script type="text/javascript">
236         function positionMap() {
237             var tbh = $("#mapid");
238             var mapContainer = tbh.parent();
239             mapContainer.css('position', 'relative');
240             mapContainer.css('min-height', tbh.outerHeight(true));
241             tbh.css('position', 'absolute');
242             tbh.css('right', 0);
243
244             var offsetTop = mapContainer.offset().top;
245             var s = parseInt($(window).scrollTop(), 10);
246             tbh.css('top', '').css('bottom', '');
247             if (s > offsetTop) {
248                 var mapContainerOffsetBottom = offsetTop + mapContainer.innerHeight();
249                 if (s + tbh.outerHeight(true) > mapContainerOffsetBottom) {
250                     tbh.css('bottom', 0);
251                 } else {
252                     tbh.css('top', s - offsetTop);
253                 }
254             } else {
255                 tbh.css('top', 0);
256             }
257         }
258
259         $(document).ready(function() {
260             $(window).scroll(positionMap);
261             positionMap();
262         });
263
264         var map = L.map('mapid').setView([0,0], 1);
265
266         L.tileLayer('https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', {
267             maxZoom: 18,
268             attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
269                 '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'
270         }).addTo(map);
271
272         var default_elt = { 'text': _("Main library"), 'id': 'UsageStatsGeolocation' };
273         var current_elt = default_elt;
274
275         // Add the title
276         var title = L.control({position: 'topright'});
277         title.onAdd = function (map) {
278             this._div = L.DomUtil.create('div', 'title');
279             this.update();
280             return this._div;
281         };
282         title.update = function (props) {
283             this._div.innerHTML = '<h4>' + _("Click on the map to set the geolocation for %s").format(current_elt.text) + '</h4>';
284         };
285         title.addTo(map);
286
287         var markers = {};
288         function add_to_map(elt, latlng) {
289             var marker = markers[elt.id];
290             if (marker) map.removeLayer(marker);
291             marker = L.marker(latlng).addTo(map);
292             marker.bindPopup(elt.text);
293             marker.on('mouseover', function (e) {this.openPopup(); });
294             marker.on('mouseout',  function (e) {this.closePopup();});
295             markers[elt.id] = marker;
296         }
297
298         // Init the map
299         [% IF Koha.Preference('UsageStatsGeolocation') %]
300             var latlng = [ [% Koha.Preference('UsageStatsGeolocation') | html %] ];
301             add_to_map( current_elt, latlng );
302         [% END %]
303         [% FOR l IN libraries %]
304             [% NEXT UNLESS l.geolocation %]
305             add_to_map( { 'text': "[% l.branchname | html %]", 'id': "geolocation_[% l.branchcode | html %]" }, [ [% l.geolocation | html %] ] );
306         [% END %]
307
308         // On click, update the geolocation and the marker
309         map.on('click', function(e){
310             add_to_map( current_elt, e.latlng );
311             $("#" + current_elt.id).val(e.latlng.lat + ',' + e.latlng.lng);
312         });
313
314         // Auto zoom
315         var group = new L.featureGroup(Object.keys(markers).map(function(key){return markers[key]}));
316         if ( group.getBounds().isValid() ) map.fitBounds(group.getBounds());
317
318         // On click on the marker icons, update the title of the map
319         $(document).ready(function(){
320             $(".change_geolocation").on('click', function(e){
321                 e.preventDefault();
322                 if ( $(this).data('branchname') ) {
323                     current_elt = { 'text': $(this).data('branchname'), 'id': $(this).data('id') };
324                 } else {
325                     current_elt = default_elt;
326                 }
327                 title.update();
328             });
329             $("#UsageStatsLibrariesInfo").change();
330         });
331
332         $("#UsageStatsLibrariesInfo").on('change', function(){
333             if ( $(this).val() == 1 ) $("#libraries_info").show()
334             else $("#libraries_info").hide();
335             positionMap();
336         });
337
338     </script>
339 [% END %]
340 [% INCLUDE 'intranet-bottom.inc' %]