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