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 id="doc3" class="yui-t2">
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>
53 <fieldset class="rows">
54 <ol style="float:left;">
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>
62 <option value="1">Yes</option>
63 <option value="0" selected="selected">No</option>
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 %]
74 [% PROCESS 'country-list.inc' %]
75 <select name="UsageStatsCountry" id="UsageStatsCountry">
76 <option value=""> </option>
77 [% FOR country IN countries %]
78 [% IF country == UsageStatsCountry %]
79 <option value="[% country | html %]" selected="selected">[% country | html %]</option>
80 [% SET IsUsageStatsCountryValid = 1 %]
82 <option value="[% country | html %]">[% country | html %]</option>
86 [% UNLESS IsUsageStatsCountryValid %]
87 Note: The value of your system preference 'UsageStatsCountry' is not valid ([% UsageStatsCountry | html %]).
88 Please select a valid one.
92 <label for="UsageStatsLibraryName">Library name: </label>
93 <input type="text" value="[% Koha.Preference('UsageStatsLibraryName') | html %]" name="UsageStatsLibraryName" id="UsageStatsLibraryName" />
96 <label for="UsageStatsLibraryType">Library type: </label>
97 [% SET UsageStatsLibraryType = Koha.Preference('UsageStatsLibraryType') %]
98 <select name="UsageStatsLibraryType" id="UsageStatsLibraryType">
99 <option value=""> </option>
100 [% IF UsageStatsLibraryType == 'public' %]
101 <option value="public" selected="selected">Public</option>
103 <option value="public">Public</option>
106 [% IF UsageStatsLibraryType == 'school' %]
107 <option value="school" selected="selected">School</option>
109 <option value="school">School</option>
111 [% IF UsageStatsLibraryType == 'academic' %]
112 <option value="academic" selected="selected">Academic</option>
114 <option value="academic">Academic</option>
116 [% IF UsageStatsLibraryType == 'research' %]
117 <option value="research" selected="selected">Research</option>
119 <option value="research">Research</option>
121 [% IF UsageStatsLibraryType == 'private' %]
122 <option value="private" selected="selected">Private</option>
124 <option value="private">Private</option>
126 [% IF UsageStatsLibraryType == 'societyAssociation' %]
127 <option value="societyAssociation" selected="selected">Society or association</option>
129 <option value="societyAssociation">Society or association</option>
131 [% IF UsageStatsLibraryType == 'corporate' %]
132 <option value="corporate" selected="selected">Corporate</option>
134 <option value="corporate">Corporate</option>
136 [% IF UsageStatsLibraryType == 'government' %]
137 <option value="government" selected="selected">Government</option>
139 <option value="government">Government</option>
141 [% IF UsageStatsLibraryType == 'religiousOrg' %]
142 <option value="religiousOrg" selected="selected">Religious organization</option>
144 <option value="religiousOrg">Religious organization</option>
146 [% IF UsageStatsLibraryType == 'subscription' %]
147 <option value="subscription" selected="selected">Subscription</option>
149 <option value="subscription">Subscription</option>
154 <label for="UsageStatsLibraryUrl">Library URL: </label>
155 <input type="text" name="UsageStatsLibraryUrl" value="[% Koha.Preference('UsageStatsLibraryUrl') | html %]" id="UsageStatsLibraryUrl" />
158 <span class="label">Last update: </span>
159 [% IF UsageStatsLastUpdateTime %]
160 [% UsageStatsLastUpdateTime | html %]
162 Your data have never been shared
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>
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>
177 <option value="1">Yes</option>
178 <option value="0" selected="selected">No</option>
183 <li id="libraries_info">
184 <fieldset class="rows">
185 <legend>Libraries</legend>
187 [% FOR l IN libraries %]
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>
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>
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>
209 You do not have anything public yet.
214 <div style="clear:right"></div>
215 <div id="mapid" style="width: 600px; height: 400px; margin-left: 40%:"></div>
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>
227 [% INCLUDE 'admin-menu.inc' %]
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');
244 var offsetTop = mapContainer.offset().top;
245 var s = parseInt($(window).scrollTop(), 10);
246 tbh.css('top', '').css('bottom', '');
248 var mapContainerOffsetBottom = offsetTop + mapContainer.innerHeight();
249 if (s + tbh.outerHeight(true) > mapContainerOffsetBottom) {
250 tbh.css('bottom', 0);
252 tbh.css('top', s - offsetTop);
259 $(document).ready(function() {
260 $(window).scroll(positionMap);
264 var map = L.map('mapid').setView([0,0], 1);
266 L.tileLayer('https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', {
268 attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
269 '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'
272 var default_elt = { 'text': _("Main library"), 'id': 'UsageStatsGeolocation' };
273 var current_elt = default_elt;
276 var title = L.control({position: 'topright'});
277 title.onAdd = function (map) {
278 this._div = L.DomUtil.create('div', 'title');
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>';
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;
299 [% IF Koha.Preference('UsageStatsGeolocation') %]
300 var latlng = [ [% Koha.Preference('UsageStatsGeolocation') | html %] ];
301 add_to_map( current_elt, latlng );
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 %] ] );
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);
315 var group = new L.featureGroup(Object.keys(markers).map(function(key){return markers[key]}));
316 if ( group.getBounds().isValid() ) map.fitBounds(group.getBounds());
318 // On click on the marker icons, update the title of the map
319 $(document).ready(function(){
320 $(".change_geolocation").on('click', function(e){
322 if ( $(this).data('branchname') ) {
323 current_elt = { 'text': $(this).data('branchname'), 'id': $(this).data('id') };
325 current_elt = default_elt;
329 $("#UsageStatsLibrariesInfo").change();
332 $("#UsageStatsLibrariesInfo").on('change', function(){
333 if ( $(this).val() == 1 ) $("#libraries_info").show()
334 else $("#libraries_info").hide();
340 [% INCLUDE 'intranet-bottom.inc' %]