6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha › Administration › Koha usage statistics</title>
8 [% INCLUDE 'doc-head-close.inc' %]
9 [% Asset.css("lib/leaflet/leaflet.css") %]
12 <body id="admin_usage_statistics" class="admin">
13 [% INCLUDE 'header.inc' %]
14 [% INCLUDE 'cat-search.inc' %]
16 <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>
18 <div id="doc3" class="yui-t2">
23 [% FOR m IN messages %]
24 <div class="dialog [% m.type %]">
26 [% CASE 'error_on_update' %]
27 An error occurred when updating this patron category. Perhaps it already exists.
28 [% CASE 'error_on_insert' %]
29 An error occurred when inserting this patron category. The patron category might already exist.
30 [% CASE 'error_on_delete' %]
31 An error occurred when deleting this patron category. Check the logs.
32 [% CASE 'success_on_update' %]
33 Patron category updated successfully.
34 [% CASE 'success_on_insert' %]
35 Patron category inserted successfully.
36 [% CASE 'success_on_delete' %]
37 Patron category deleted successfully.
38 [% CASE 'already_exists' %]
39 This patron category already exists.
46 [% IF NOT Koha.Preference('UsageStats') %]
47 <div class="dialog message">You are not sharing any data with the Koha community</div>
50 <form id="category_form" action="/cgi-bin/koha/admin/usage_statistics.pl" method="post">
51 <h1>Modify the statistics you share with the Koha community</h1>
52 <fieldset class="rows">
53 <ol style="float:left;">
55 <label for="UsageStats">Share my Koha usage statistics: </label>
56 <select name="UsageStats" id="UsageStats">
57 [% IF Koha.Preference('UsageStats') %]
58 <option value="1" selected="selected">Yes</option>
59 <option value="0">No</option>
61 <option value="1">Yes</option>
62 <option value="0" selected="selected">No</option>
67 <label for="UsageStatsCountry">Your country: </label>
68 [% SET UsageStatsCountry = Koha.Preference('UsageStatsCountry') %]
69 [% SET IsUsageStatsCountryValid = 0 %]
70 [% IF NOT UsageStatsCountry %]
71 [% SET IsUsageStatsCountryValid = 1 %]
73 [% PROCESS 'country-list.inc' %]
74 <select name="UsageStatsCountry" id="UsageStatsCountry">
75 <option value=""> </option>
76 [% FOR country IN countries %]
77 [% IF country == UsageStatsCountry %]
78 <option value="[% country %]" selected="selected">[% country %]</option>
79 [% SET IsUsageStatsCountryValid = 1 %]
81 <option value="[% country %]">[% country %]</option>
85 [% UNLESS IsUsageStatsCountryValid %]
86 Note: The value of your system preference 'UsageStatsCountry' is not valid ([% UsageStatsCountry %]).
87 Please select a valid one.
91 <label for="UsageStatsLibraryName">Library name: </label>
92 <input type="text" value="[% Koha.Preference('UsageStatsLibraryName') | html %]" name="UsageStatsLibraryName" id="UsageStatsLibraryName" />
95 <label for="UsageStatsLibraryType">Library type: </label>
96 [% SET UsageStatsLibraryType = Koha.Preference('UsageStatsLibraryType') %]
97 <select name="UsageStatsLibraryType" id="UsageStatsLibraryType">
98 <option value=""> </option>
99 [% IF UsageStatsLibraryType == 'public' %]
100 <option value="public" selected="selected">Public</option>
102 <option value="public">Public</option>
105 [% IF UsageStatsLibraryType == 'school' %]
106 <option value="school" selected="selected">School</option>
108 <option value="school">School</option>
110 [% IF UsageStatsLibraryType == 'academic' %]
111 <option value="academic" selected="selected">Academic</option>
113 <option value="academic">Academic</option>
115 [% IF UsageStatsLibraryType == 'research' %]
116 <option value="research" selected="selected">Research</option>
118 <option value="research">Research</option>
120 [% IF UsageStatsLibraryType == 'private' %]
121 <option value="private" selected="selected">Private</option>
123 <option value="private">Private</option>
125 [% IF UsageStatsLibraryType == 'societyAssociation' %]
126 <option value="societyAssociation" selected="selected">Society or association</option>
128 <option value="societyAssociation">Society or association</option>
130 [% IF UsageStatsLibraryType == 'corporate' %]
131 <option value="corporate" selected="selected">Corporate</option>
133 <option value="corporate">Corporate</option>
135 [% IF UsageStatsLibraryType == 'government' %]
136 <option value="government" selected="selected">Government</option>
138 <option value="government">Government</option>
140 [% IF UsageStatsLibraryType == 'religiousOrg' %]
141 <option value="religiousOrg" selected="selected">Religious organization</option>
143 <option value="religiousOrg">Religious organization</option>
145 [% IF UsageStatsLibraryType == 'subscription' %]
146 <option value="subscription" selected="selected">Subscription</option>
148 <option value="subscription">Subscription</option>
153 <label for="UsageStatsLibraryUrl">Library URL: </label>
154 <input type="text" name="UsageStatsLibraryUrl" value="[% Koha.Preference('UsageStatsLibraryUrl') %]" id="UsageStatsLibraryUrl" />
157 <span class="label">Last update: </span>
158 [% IF UsageStatsLastUpdateTime %]
159 [% UsageStatsLastUpdateTime %]
161 Your data have never been shared
165 <label for="UsageStatsGeolocation">Geolocation: </label>
166 <input id="UsageStatsGeolocation" name="UsageStatsGeolocation" value="[% Koha.Preference('UsageStatsGeolocation') %]" type="text" value="[% Koha.Preference('UsageStatsLibrariesInfo') %]" size="35" readonly="readonly" />
167 <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>
170 <label for="UsageStatsLibrariesInfo">Libraries informations: </label>
171 <select name="UsageStatsLibrariesInfo" id="UsageStatsLibrariesInfo">
172 [% IF Koha.Preference('UsageStatsLibrariesInfo') %]
173 <option value="1" selected="selected">Yes</option>
174 <option value="0">No</option>
176 <option value="1">Yes</option>
177 <option value="0" selected="selected">No</option>
182 <li id="libraries_info">
183 <fieldset class="rows">
184 <legend>Libraries</legend>
186 [% FOR l IN libraries %]
188 <label for="[% l.branchcode %]">[% l.branchname %]: </label>
189 <div style="float:left;">
190 <div>Country: [% l.branchcountry %]</div>
191 <div>Url: [% l.branchurl %]</div>
193 Geolocation: <input type="text" id="geolocation_[% l.branchcode %]" name="geolocation_[% l.branchcode %]" value="[% l.geolocation %]" size="35" readonly="readonly" />
194 <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>
203 <label for="MyPublicLink">See your public page: </label>
204 [% IF Koha.Preference('UsageStatsPublicID') %]
205 [% SET my_url = 'https://hea.koha-community.org/libraries/' _ Koha.Preference('UsageStatsPublicID') %]
206 <a href="[% my_url %]">[% my_url %]</a>
208 You do not have anything public yet.
213 <div style="clear:right"></div>
214 <div id="mapid" style="width: 600px; height: 400px; margin-left: 40%:"></div>
217 <fieldset class="action">
218 <input type="hidden" name="op" value="update" />
219 <input type="submit" value="Update your statistics usage" />
220 <a class="cancel" href="/cgi-bin/koha/admin/usage_statistics.pl">Cancel</a>
226 [% INCLUDE 'admin-menu.inc' %]
230 [% MACRO jsinclude BLOCK %]
231 [% INCLUDE 'calendar.inc' %]
232 [% Asset.js("js/admin-menu.js") %]
233 <script src="[% interface %]/lib/leaflet/leaflet.js"></script>
234 <script type="text/javascript">
235 function positionMap() {
236 var tbh = $("#mapid");
237 var mapContainer = tbh.parent();
238 mapContainer.css('position', 'relative');
239 mapContainer.css('min-height', tbh.outerHeight(true));
240 tbh.css('position', 'absolute');
243 var offsetTop = mapContainer.offset().top;
244 var s = parseInt($(window).scrollTop(), 10);
245 tbh.css('top', '').css('bottom', '');
247 var mapContainerOffsetBottom = offsetTop + mapContainer.innerHeight();
248 if (s + tbh.outerHeight(true) > mapContainerOffsetBottom) {
249 tbh.css('bottom', 0);
251 tbh.css('top', s - offsetTop);
258 $(document).ready(function() {
259 $(window).scroll(positionMap);
263 var map = L.map('mapid').setView([0,0], 1);
265 L.tileLayer('https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', {
267 attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
268 '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'
271 var default_elt = { 'text': _("Main library"), 'id': 'UsageStatsGeolocation' };
272 var current_elt = default_elt;
275 var title = L.control({position: 'topright'});
276 title.onAdd = function (map) {
277 this._div = L.DomUtil.create('div', 'title');
281 title.update = function (props) {
282 this._div.innerHTML = '<h4>' + _("Click on the map to set the geolocation for %s").format(current_elt.text) + '</h4>';
287 function add_to_map(elt, latlng) {
288 var marker = markers[elt.id];
289 if (marker) map.removeLayer(marker);
290 marker = L.marker(latlng).addTo(map);
291 marker.bindPopup(elt.text);
292 marker.on('mouseover', function (e) {this.openPopup(); });
293 marker.on('mouseout', function (e) {this.closePopup();});
294 markers[elt.id] = marker;
298 [% IF Koha.Preference('UsageStatsGeolocation') %]
299 var latlng = [ [% Koha.Preference('UsageStatsGeolocation') %] ];
300 add_to_map( current_elt, latlng );
302 [% FOR l IN libraries %]
303 [% NEXT UNLESS l.geolocation %]
304 add_to_map( { 'text': "[% l.branchname %]", 'id': "geolocation_[% l.branchcode %]" }, [ [% l.geolocation %] ] );
307 // On click, update the geolocation and the marker
308 map.on('click', function(e){
309 add_to_map( current_elt, e.latlng );
310 $("#" + current_elt.id).val(e.latlng.lat + ',' + e.latlng.lng);
314 var group = new L.featureGroup(Object.keys(markers).map(function(key){return markers[key]}));
315 if ( group.getBounds().isValid() ) map.fitBounds(group.getBounds());
317 // On click on the marker icons, update the title of the map
318 $(document).ready(function(){
319 $(".change_geolocation").on('click', function(e){
321 if ( $(this).data('branchname') ) {
322 current_elt = { 'text': $(this).data('branchname'), 'id': $(this).data('id') };
324 current_elt = default_elt;
328 $("#UsageStatsLibrariesInfo").change();
331 $("#UsageStatsLibrariesInfo").on('change', function(){
332 if ( $(this).val() == 1 ) $("#libraries_info").show()
333 else $("#libraries_info").hide();
339 [% INCLUDE 'intranet-bottom.inc' %]