7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Koha › Administration › Koha usage statistics</title>
9 [% INCLUDE 'doc-head-close.inc' %]
10 [% Asset.css("lib/leaflet/leaflet.css") | $raw %]
13 <body id="admin_usage_statistics" class="admin">
14 [% INCLUDE 'header.inc' %]
15 [% INCLUDE 'cat-search.inc' %]
17 <div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> › <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> › Usage statistics</div>
19 <div class="main container-fluid">
21 <div class="col-sm-10 col-sm-push-2">
24 [% FOR m IN messages %]
25 <div class="dialog [% m.type | html %]">
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.
47 [% IF NOT Koha.Preference('UsageStats') %]
48 <div class="dialog message">You are not sharing any data with the Koha community</div>
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>
54 <div class="col-xs-12 col-sm-6">
55 <fieldset class="rows">
58 <label for="UsageStats">Share my Koha usage statistics: </label>
59 <select name="UsageStats" id="UsageStats">
60 [% IF Koha.Preference('UsageStats') %]
61 <option value="1" selected="selected">Yes</option>
62 <option value="0">No</option>
64 <option value="1">Yes</option>
65 <option value="0" selected="selected">No</option>
70 <label for="UsageStatsCountry">Your country: </label>
71 [% SET UsageStatsCountry = Koha.Preference('UsageStatsCountry') %]
72 [% SET IsUsageStatsCountryValid = 0 %]
73 [% IF NOT UsageStatsCountry %]
74 [% SET IsUsageStatsCountryValid = 1 %]
76 [% PROCESS 'country-list.inc' %]
77 <select name="UsageStatsCountry" id="UsageStatsCountry">
78 <option value=""> </option>
79 [% FOR country IN countries %]
80 [% IF country == UsageStatsCountry %]
81 <option value="[% country | html %]" selected="selected">[% country | html %]</option>
82 [% SET IsUsageStatsCountryValid = 1 %]
84 <option value="[% country | html %]">[% country | html %]</option>
88 [% UNLESS IsUsageStatsCountryValid %]
89 Note: The value of your system preference 'UsageStatsCountry' is not valid ([% UsageStatsCountry | html %]).
90 Please select a valid one.
94 <label for="UsageStatsLibraryName">Library name: </label>
95 <input type="text" value="[% Koha.Preference('UsageStatsLibraryName') | html %]" name="UsageStatsLibraryName" id="UsageStatsLibraryName" />
98 <label for="UsageStatsLibraryType">Library type: </label>
99 [% SET UsageStatsLibraryType = Koha.Preference('UsageStatsLibraryType') %]
100 <select name="UsageStatsLibraryType" id="UsageStatsLibraryType">
101 <option value=""> </option>
102 [% IF UsageStatsLibraryType == 'public' %]
103 <option value="public" selected="selected">Public</option>
105 <option value="public">Public</option>
108 [% IF UsageStatsLibraryType == 'school' %]
109 <option value="school" selected="selected">School</option>
111 <option value="school">School</option>
113 [% IF UsageStatsLibraryType == 'academic' %]
114 <option value="academic" selected="selected">Academic</option>
116 <option value="academic">Academic</option>
118 [% IF UsageStatsLibraryType == 'research' %]
119 <option value="research" selected="selected">Research</option>
121 <option value="research">Research</option>
123 [% IF UsageStatsLibraryType == 'private' %]
124 <option value="private" selected="selected">Private</option>
126 <option value="private">Private</option>
128 [% IF UsageStatsLibraryType == 'societyAssociation' %]
129 <option value="societyAssociation" selected="selected">Society or association</option>
131 <option value="societyAssociation">Society or association</option>
133 [% IF UsageStatsLibraryType == 'corporate' %]
134 <option value="corporate" selected="selected">Corporate</option>
136 <option value="corporate">Corporate</option>
138 [% IF UsageStatsLibraryType == 'government' %]
139 <option value="government" selected="selected">Government</option>
141 <option value="government">Government</option>
143 [% IF UsageStatsLibraryType == 'religiousOrg' %]
144 <option value="religiousOrg" selected="selected">Religious organization</option>
146 <option value="religiousOrg">Religious organization</option>
148 [% IF UsageStatsLibraryType == 'subscription' %]
149 <option value="subscription" selected="selected">Subscription</option>
151 <option value="subscription">Subscription</option>
156 <label for="UsageStatsLibraryUrl">Library URL: </label>
157 <input type="text" name="UsageStatsLibraryUrl" value="[% Koha.Preference('UsageStatsLibraryUrl') | html %]" id="UsageStatsLibraryUrl" />
160 <span class="label">Last update: </span>
161 [% IF UsageStatsLastUpdateTime %]
162 [% UsageStatsLastUpdateTime | html %]
164 Your data have never been shared
168 <label for="UsageStatsGeolocation">Geolocation: </label>
169 <input id="UsageStatsGeolocation" name="UsageStatsGeolocation" value="[% Koha.Preference('UsageStatsGeolocation') | html %]" type="text" value="[% Koha.Preference('UsageStatsLibrariesInfo') | html %]" size="35" readonly="readonly" />
170 <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>
173 <label for="UsageStatsLibrariesInfo">Libraries informations: </label>
174 <select name="UsageStatsLibrariesInfo" id="UsageStatsLibrariesInfo">
175 [% IF Koha.Preference('UsageStatsLibrariesInfo') %]
176 <option value="1" selected="selected">Yes</option>
177 <option value="0">No</option>
179 <option value="1">Yes</option>
180 <option value="0" selected="selected">No</option>
185 <li id="libraries_info">
186 <fieldset class="rows">
187 <legend>Libraries</legend>
189 [% FOR l IN libraries %]
191 <label for="[% l.branchcode | html %]">[% l.branchname | html %]: </label>
192 <div style="float:left;">
193 <div>Country: [% l.branchcountry | html %]</div>
194 <div>Url: [% l.branchurl | html %]</div>
196 Geolocation: <input type="text" id="geolocation_[% l.branchcode | html %]" name="geolocation_[% l.branchcode | html %]" value="[% l.geolocation | html %]" size="35" readonly="readonly" />
197 <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>
206 <label for="MyPublicLink">See your public page: </label>
207 [% IF Koha.Preference('UsageStatsPublicID') %]
208 [% SET my_url = 'https://hea.koha-community.org/libraries/' _ Koha.Preference('UsageStatsPublicID') %]
209 <a href="[% my_url | url %]">[% my_url | html %]</a>
211 You do not have anything public yet.
218 <div class="col-xs-12 col-sm-6">
220 <div id="mapid" style="width:100%;height: 400px;"></div>
226 <fieldset class="action">
227 <input type="hidden" name="op" value="update" />
228 <input type="submit" value="Update your statistics usage" />
229 <a class="cancel" href="/cgi-bin/koha/admin/usage_statistics.pl">Cancel</a>
234 </div> <!-- /.col-sm-10.col-sm-push-2 -->
236 <div class="col-sm-2 col-sm-pull-10">
238 [% INCLUDE 'admin-menu.inc' %]
240 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
241 </div> <!-- /.row -->
243 [% MACRO jsinclude BLOCK %]
244 [% INCLUDE 'calendar.inc' %]
245 [% Asset.js("js/admin-menu.js") | $raw %]
246 [% Asset.js("/lib/leaflet/leaflet.js") | $raw %]
248 function positionMap() {
249 var tbh = $("#mapid");
250 var mapContainer = tbh.parent();
251 mapContainer.css('position', 'relative');
252 mapContainer.css('min-height', tbh.outerHeight(true));
253 tbh.css('position', 'absolute');
256 var offsetTop = mapContainer.offset().top;
257 var s = parseInt($(window).scrollTop(), 10);
258 tbh.css('top', '').css('bottom', '');
260 var mapContainerOffsetBottom = offsetTop + mapContainer.innerHeight();
261 if (s + tbh.outerHeight(true) > mapContainerOffsetBottom) {
262 tbh.css('bottom', 0);
264 tbh.css('top', s - offsetTop);
271 $(document).ready(function() {
272 $(window).scroll(positionMap);
276 var map = L.map('mapid').setView([0,0], 1);
278 L.tileLayer('https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', {
280 attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
281 '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'
284 var default_elt = { 'text': _("Main library"), 'id': 'UsageStatsGeolocation' };
285 var current_elt = default_elt;
288 var title = L.control({position: 'topright'});
289 title.onAdd = function (map) {
290 this._div = L.DomUtil.create('div', 'title');
294 title.update = function (props) {
295 this._div.innerHTML = '<h4>' + _("Click on the map to set the geolocation for %s").format(current_elt.text) + '</h4>';
300 function add_to_map(elt, latlng) {
301 var marker = markers[elt.id];
302 if (marker) map.removeLayer(marker);
303 marker = L.marker(latlng).addTo(map);
304 marker.bindPopup(elt.text);
305 marker.on('mouseover', function (e) {this.openPopup(); });
306 marker.on('mouseout', function (e) {this.closePopup();});
307 markers[elt.id] = marker;
311 [% IF Koha.Preference('UsageStatsGeolocation') %]
312 var latlng = [ [% Koha.Preference('UsageStatsGeolocation') | html %] ];
313 add_to_map( current_elt, latlng );
315 [% FOR l IN libraries %]
316 [% NEXT UNLESS l.geolocation %]
317 add_to_map( { 'text': "[% l.branchname | html %]", 'id': "geolocation_[% l.branchcode | html %]" }, [ [% l.geolocation | html %] ] );
320 // On click, update the geolocation and the marker
321 map.on('click', function(e){
322 add_to_map( current_elt, e.latlng );
323 $("#" + current_elt.id).val(e.latlng.lat + ',' + e.latlng.lng);
327 var group = new L.featureGroup(Object.keys(markers).map(function(key){return markers[key]}));
328 if ( group.getBounds().isValid() ) map.fitBounds(group.getBounds());
330 // On click on the marker icons, update the title of the map
331 $(document).ready(function(){
332 $(".change_geolocation").on('click', function(e){
334 if ( $(this).data('branchname') ) {
335 current_elt = { 'text': $(this).data('branchname'), 'id': $(this).data('id') };
337 current_elt = default_elt;
341 $("#UsageStatsLibrariesInfo").change();
344 $("#UsageStatsLibrariesInfo").on('change', function(){
345 if ( $(this).val() == 1 ) $("#libraries_info").show()
346 else $("#libraries_info").hide();
352 [% INCLUDE 'intranet-bottom.inc' %]