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') == 1 %]
61 <option value="2">Undecided</option>
62 <option value="1" selected="selected">Yes</option>
63 <option value="0">No</option>
64 [% ELSIF Koha.Preference('UsageStats') == 0 %]
65 <option value="2">Undecided</option>
66 <option value="1">Yes</option>
67 <option value="0" selected="selected">No</option>
69 <option value="2" selected="selected">Undecided</option>
70 <option value="1">Yes</option>
71 <option value="0">No</option>
76 <label for="UsageStatsCountry">Your country: </label>
77 [% SET UsageStatsCountry = Koha.Preference('UsageStatsCountry') %]
78 [% SET IsUsageStatsCountryValid = 0 %]
79 [% IF NOT UsageStatsCountry %]
80 [% SET IsUsageStatsCountryValid = 1 %]
82 [% PROCESS 'country-list.inc' %]
83 <select name="UsageStatsCountry" id="UsageStatsCountry">
84 <option value=""> </option>
85 [% FOR country IN countries %]
86 [% IF country == UsageStatsCountry %]
87 <option value="[% country | html %]" selected="selected">[% country | html %]</option>
88 [% SET IsUsageStatsCountryValid = 1 %]
90 <option value="[% country | html %]">[% country | html %]</option>
94 [% UNLESS IsUsageStatsCountryValid %]
95 Note: The value of your system preference 'UsageStatsCountry' is not valid ([% UsageStatsCountry | html %]).
96 Please select a valid one.
100 <label for="UsageStatsLibraryName">Library name: </label>
101 <input type="text" value="[% Koha.Preference('UsageStatsLibraryName') | html %]" name="UsageStatsLibraryName" id="UsageStatsLibraryName" />
104 <label for="UsageStatsLibraryType">Library type: </label>
105 [% SET UsageStatsLibraryType = Koha.Preference('UsageStatsLibraryType') %]
106 <select name="UsageStatsLibraryType" id="UsageStatsLibraryType">
107 <option value=""> </option>
108 [% IF UsageStatsLibraryType == 'public' %]
109 <option value="public" selected="selected">Public</option>
111 <option value="public">Public</option>
114 [% IF UsageStatsLibraryType == 'school' %]
115 <option value="school" selected="selected">School</option>
117 <option value="school">School</option>
119 [% IF UsageStatsLibraryType == 'academic' %]
120 <option value="academic" selected="selected">Academic</option>
122 <option value="academic">Academic</option>
124 [% IF UsageStatsLibraryType == 'research' %]
125 <option value="research" selected="selected">Research</option>
127 <option value="research">Research</option>
129 [% IF UsageStatsLibraryType == 'private' %]
130 <option value="private" selected="selected">Private</option>
132 <option value="private">Private</option>
134 [% IF UsageStatsLibraryType == 'societyAssociation' %]
135 <option value="societyAssociation" selected="selected">Society or association</option>
137 <option value="societyAssociation">Society or association</option>
139 [% IF UsageStatsLibraryType == 'corporate' %]
140 <option value="corporate" selected="selected">Corporate</option>
142 <option value="corporate">Corporate</option>
144 [% IF UsageStatsLibraryType == 'government' %]
145 <option value="government" selected="selected">Government</option>
147 <option value="government">Government</option>
149 [% IF UsageStatsLibraryType == 'religiousOrg' %]
150 <option value="religiousOrg" selected="selected">Religious organization</option>
152 <option value="religiousOrg">Religious organization</option>
154 [% IF UsageStatsLibraryType == 'subscription' %]
155 <option value="subscription" selected="selected">Subscription</option>
157 <option value="subscription">Subscription</option>
162 <label for="UsageStatsLibraryUrl">Library URL: </label>
163 <input type="text" name="UsageStatsLibraryUrl" value="[% Koha.Preference('UsageStatsLibraryUrl') | html %]" id="UsageStatsLibraryUrl" />
166 <span class="label">Last update: </span>
167 [% IF UsageStatsLastUpdateTime %]
168 [% UsageStatsLastUpdateTime | html %]
170 Your data have never been shared
174 <label for="UsageStatsGeolocation">Geolocation: </label>
175 <input id="UsageStatsGeolocation" name="UsageStatsGeolocation" value="[% Koha.Preference('UsageStatsGeolocation') | html %]" type="text" value="[% Koha.Preference('UsageStatsLibrariesInfo') | html %]" size="35" readonly="readonly" />
176 <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>
179 <label for="UsageStatsLibrariesInfo">Libraries informations: </label>
180 <select name="UsageStatsLibrariesInfo" id="UsageStatsLibrariesInfo">
181 [% IF Koha.Preference('UsageStatsLibrariesInfo') %]
182 <option value="1" selected="selected">Yes</option>
183 <option value="0">No</option>
185 <option value="1">Yes</option>
186 <option value="0" selected="selected">No</option>
191 <li id="libraries_info">
192 <fieldset class="rows">
193 <legend>Libraries</legend>
195 [% FOR l IN libraries %]
197 <label for="[% l.branchcode | html %]">[% l.branchname | html %]: </label>
198 <div style="float:left;">
199 <div>Country: [% l.branchcountry | html %]</div>
200 <div>Url: [% l.branchurl | html %]</div>
202 Geolocation: <input type="text" id="geolocation_[% l.branchcode | html %]" name="geolocation_[% l.branchcode | html %]" value="[% l.geolocation | html %]" size="35" readonly="readonly" />
203 <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>
212 <label for="MyPublicLink">See your public page: </label>
213 [% IF Koha.Preference('UsageStatsPublicID') %]
214 [% SET my_url = 'https://hea.koha-community.org/libraries/' _ Koha.Preference('UsageStatsPublicID') %]
215 <a href="[% my_url | url %]">[% my_url | html %]</a>
217 You do not have anything public yet.
224 <div class="col-xs-12 col-sm-6">
226 <div id="mapid" style="width:100%;height: 400px;"></div>
232 <fieldset class="action">
233 <input type="hidden" name="op" value="update" />
234 <input type="submit" value="Update your statistics usage" />
235 <a class="cancel" href="/cgi-bin/koha/admin/usage_statistics.pl">Cancel</a>
240 </div> <!-- /.col-sm-10.col-sm-push-2 -->
242 <div class="col-sm-2 col-sm-pull-10">
244 [% INCLUDE 'admin-menu.inc' %]
246 </div> <!-- /.col-sm-2.col-sm-pull-10 -->
247 </div> <!-- /.row -->
249 [% MACRO jsinclude BLOCK %]
250 [% INCLUDE 'calendar.inc' %]
251 [% Asset.js("js/admin-menu.js") | $raw %]
252 [% Asset.js("/lib/leaflet/leaflet.js") | $raw %]
254 function positionMap() {
255 var tbh = $("#mapid");
256 var mapContainer = tbh.parent();
257 mapContainer.css('position', 'relative');
258 mapContainer.css('min-height', tbh.outerHeight(true));
259 tbh.css('position', 'absolute');
262 var offsetTop = mapContainer.offset().top;
263 var s = parseInt($(window).scrollTop(), 10);
264 tbh.css('top', '').css('bottom', '');
266 var mapContainerOffsetBottom = offsetTop + mapContainer.innerHeight();
267 if (s + tbh.outerHeight(true) > mapContainerOffsetBottom) {
268 tbh.css('bottom', 0);
270 tbh.css('top', s - offsetTop);
277 $(document).ready(function() {
278 $(window).scroll(positionMap);
282 var map = L.map('mapid').setView([0,0], 1);
284 L.tileLayer('https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', {
286 attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
287 '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'
290 var default_elt = { 'text': _("Main library"), 'id': 'UsageStatsGeolocation' };
291 var current_elt = default_elt;
294 var title = L.control({position: 'topright'});
295 title.onAdd = function (map) {
296 this._div = L.DomUtil.create('div', 'title');
300 title.update = function (props) {
301 this._div.innerHTML = '<h4>' + _("Click on the map to set the geolocation for %s").format(current_elt.text) + '</h4>';
306 function add_to_map(elt, latlng) {
307 var marker = markers[elt.id];
308 if (marker) map.removeLayer(marker);
309 marker = L.marker(latlng).addTo(map);
310 marker.bindPopup(elt.text);
311 marker.on('mouseover', function (e) {this.openPopup(); });
312 marker.on('mouseout', function (e) {this.closePopup();});
313 markers[elt.id] = marker;
317 [% IF Koha.Preference('UsageStatsGeolocation') %]
318 var latlng = [ [% Koha.Preference('UsageStatsGeolocation') | html %] ];
319 add_to_map( current_elt, latlng );
321 [% FOR l IN libraries %]
322 [% NEXT UNLESS l.geolocation %]
323 add_to_map( { 'text': "[% l.branchname | html %]", 'id': "geolocation_[% l.branchcode | html %]" }, [ [% l.geolocation | html %] ] );
326 // On click, update the geolocation and the marker
327 map.on('click', function(e){
328 add_to_map( current_elt, e.latlng );
329 $("#" + current_elt.id).val(e.latlng.lat + ',' + e.latlng.lng);
333 var group = new L.featureGroup(Object.keys(markers).map(function(key){return markers[key]}));
334 if ( group.getBounds().isValid() ) map.fitBounds(group.getBounds());
336 // On click on the marker icons, update the title of the map
337 $(document).ready(function(){
338 $(".change_geolocation").on('click', function(e){
340 if ( $(this).data('branchname') ) {
341 current_elt = { 'text': $(this).data('branchname'), 'id': $(this).data('id') };
343 current_elt = default_elt;
347 $("#UsageStatsLibrariesInfo").change();
350 $("#UsageStatsLibrariesInfo").on('change', function(){
351 if ( $(this).val() == 1 ) $("#libraries_info").show()
352 else $("#libraries_info").hide();
358 [% INCLUDE 'intranet-bottom.inc' %]