Bug 24786: (QA follow-up) String fix
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / usage_statistics.tt
blobf8d018234de10c60ad2361599d165eeeb65ac710
1 [% USE raw %]
2 [% USE Asset %]
3 [% SET footerjs = 1 %]
4 [% USE Koha %]
5 [% USE KohaDates %]
6 [% USE Price %]
7 [% INCLUDE 'doc-head-open.inc' %]
8 <title>Koha &rsaquo; Administration &rsaquo; Koha usage statistics</title>
9 [% INCLUDE 'doc-head-close.inc' %]
10 [% Asset.css("lib/leaflet/leaflet.css") | $raw %]
11 </head>
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> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; Usage statistics</div>
19 <div class="main container-fluid">
20     <div class="row">
21         <div class="col-sm-10 col-sm-push-2">
22             <main>
24 [% FOR m IN messages %]
25     <div class="dialog [% m.type | html %]">
26         [% SWITCH m.code %]
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.
41         [% CASE %]
42             [% m.code | html %]
43         [% END %]
44     </div>
45 [% END %]
47 [% IF NOT Koha.Preference('UsageStats') %]
48     <div class="dialog message">You are not sharing any data with the Koha community</div>
49 [% END %]
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         <div class="row">
54             <div class="col-xs-12 col-sm-6">
55                 <fieldset class="rows">
56                     <ol>
57                         <li>
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>
68                             [% ELSE %]
69                                 <option value="2" selected="selected">Undecided</option>
70                                 <option value="1">Yes</option>
71                                 <option value="0">No</option>
72                             [% END %]
73                             </select>
74                         </li>
75                         <li>
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 %]
81                             [% END %]
82                             [% PROCESS 'country-list.inc' %]
83                             <select name="UsageStatsCountry" id="UsageStatsCountry">
84                                 <option value="">&nbsp;</option>
85                                 [% FOR country IN countries %]
86                                     [% IF country == UsageStatsCountry %]
87                                         <option value="[% country | html %]" selected="selected">[% country | html %]</option>
88                                         [% SET IsUsageStatsCountryValid = 1 %]
89                                     [% ELSE %]
90                                         <option value="[% country | html %]">[% country | html %]</option>
91                                     [% END %]
92                                 [% END %]
93                             </select>
94                             [% UNLESS IsUsageStatsCountryValid %]
95                                 Note: The value of your system preference 'UsageStatsCountry' is not valid ([% UsageStatsCountry | html %]).
96                                 Please select a valid one.
97                             [% END %]
98                         </li>
99                         <li>
100                             <label for="UsageStatsLibraryName">Library name: </label>
101                             <input type="text" value="[% Koha.Preference('UsageStatsLibraryName') | html %]" name="UsageStatsLibraryName" id="UsageStatsLibraryName" />
102                         </li>
103                         <li>
104                             <label for="UsageStatsLibraryType">Library type: </label>
105                             [% SET UsageStatsLibraryType = Koha.Preference('UsageStatsLibraryType') %]
106                             <select name="UsageStatsLibraryType" id="UsageStatsLibraryType">
107                                 <option value="">&nbsp;</option>
108                                 [% IF UsageStatsLibraryType == 'public' %]
109                                     <option value="public" selected="selected">Public</option>
110                                 [% ELSE %]
111                                     <option value="public">Public</option>
112                                 [% END %]
114                                 [% IF UsageStatsLibraryType == 'school' %]
115                                     <option value="school" selected="selected">School</option>
116                                 [% ELSE %]
117                                     <option value="school">School</option>
118                                 [% END %]
119                                 [% IF UsageStatsLibraryType == 'academic' %]
120                                     <option value="academic" selected="selected">Academic</option>
121                                 [% ELSE %]
122                                     <option value="academic">Academic</option>
123                                 [% END %]
124                                 [% IF UsageStatsLibraryType == 'research' %]
125                                     <option value="research" selected="selected">Research</option>
126                                 [% ELSE %]
127                                     <option value="research">Research</option>
128                                 [% END %]
129                                 [% IF UsageStatsLibraryType == 'private' %]
130                                     <option value="private" selected="selected">Private</option>
131                                 [% ELSE %]
132                                     <option value="private">Private</option>
133                                 [% END %]
134                                 [% IF UsageStatsLibraryType == 'societyAssociation' %]
135                                     <option value="societyAssociation" selected="selected">Society or association</option>
136                                 [% ELSE %]
137                                     <option value="societyAssociation">Society or association</option>
138                                 [% END %]
139                                 [% IF UsageStatsLibraryType == 'corporate' %]
140                                     <option value="corporate" selected="selected">Corporate</option>
141                                 [% ELSE %]
142                                     <option value="corporate">Corporate</option>
143                                 [% END %]
144                                 [% IF UsageStatsLibraryType == 'government' %]
145                                     <option value="government" selected="selected">Government</option>
146                                 [% ELSE %]
147                                     <option value="government">Government</option>
148                                 [% END %]
149                                 [% IF UsageStatsLibraryType == 'religiousOrg' %]
150                                     <option value="religiousOrg" selected="selected">Religious organization</option>
151                                 [% ELSE %]
152                                     <option value="religiousOrg">Religious organization</option>
153                                 [% END %]
154                                 [% IF UsageStatsLibraryType == 'subscription' %]
155                                     <option value="subscription" selected="selected">Subscription</option>
156                                 [% ELSE %]
157                                     <option value="subscription">Subscription</option>
158                                 [% END %]
159                             </select>
160                         </li>
161                         <li>
162                             <label for="UsageStatsLibraryUrl">Library URL: </label>
163                             <input type="text" name="UsageStatsLibraryUrl" value="[% Koha.Preference('UsageStatsLibraryUrl') | html %]" id="UsageStatsLibraryUrl" />
164                         </li>
165                         <li>
166                             <span class="label">Last update: </span>
167                             [% IF UsageStatsLastUpdateTime %]
168                                 [% UsageStatsLastUpdateTime | html %]
169                             [% ELSE %]
170                                 Your data have never been shared
171                             [% END %]
172                         </li>
173                         <li>
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>
177                         </li>
178                         <li>
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>
184                                 [% ELSE %]
185                                     <option value="1">Yes</option>
186                                     <option value="0" selected="selected">No</option>
187                                 [% END %]
188                             </select>
189                         </li>
191                         <li id="libraries_info">
192                             <fieldset class="rows">
193                             <legend>Libraries</legend>
194                             <ol>
195                                 [% FOR l IN libraries %]
196                                 <li>
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>
201                                         <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>
204                                         </div>
205                                     </div>
206                                 </li>
207                                 [% END %]
208                             </ol>
209                             </fieldset>
210                         </li>
211                         <li>
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>
216                             [% ELSE %]
217                                 You do not have anything public yet.
218                             [% END %]
219                         </li>
221                     </ol>
222                 </fieldset>
223             </div>
224             <div class="col-xs-12 col-sm-6">
225                 <div>
226                     <div id="mapid" style="width:100%;height: 400px;"></div>
227                 </div>
228             </div>
230         </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>
236         </fieldset>
237     </form>
239             </main>
240         </div> <!-- /.col-sm-10.col-sm-push-2 -->
242         <div class="col-sm-2 col-sm-pull-10">
243             <aside>
244                 [% INCLUDE 'admin-menu.inc' %]
245             </aside>
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 %]
253     <script>
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');
260             tbh.css('right', 0);
262             var offsetTop = mapContainer.offset().top;
263             var s = parseInt($(window).scrollTop(), 10);
264             tbh.css('top', '').css('bottom', '');
265             if (s > offsetTop) {
266                 var mapContainerOffsetBottom = offsetTop + mapContainer.innerHeight();
267                 if (s + tbh.outerHeight(true) > mapContainerOffsetBottom) {
268                     tbh.css('bottom', 0);
269                 } else {
270                     tbh.css('top', s - offsetTop);
271                 }
272             } else {
273                 tbh.css('top', 0);
274             }
275         }
277         $(document).ready(function() {
278             $(window).scroll(positionMap);
279             positionMap();
280         });
282         var map = L.map('mapid').setView([0,0], 1);
284         L.tileLayer('https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', {
285             maxZoom: 18,
286             attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
287                 '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'
288         }).addTo(map);
290         var default_elt = { 'text': _("Main library"), 'id': 'UsageStatsGeolocation' };
291         var current_elt = default_elt;
293         // Add the title
294         var title = L.control({position: 'topright'});
295         title.onAdd = function (map) {
296             this._div = L.DomUtil.create('div', 'title');
297             this.update();
298             return this._div;
299         };
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>';
302         };
303         title.addTo(map);
305         var markers = {};
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;
314         }
316         // Init the map
317         [% IF Koha.Preference('UsageStatsGeolocation') %]
318             var latlng = [ [% Koha.Preference('UsageStatsGeolocation') | html %] ];
319             add_to_map( current_elt, latlng );
320         [% END %]
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 %] ] );
324         [% END %]
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);
330         });
332         // Auto zoom
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){
339                 e.preventDefault();
340                 if ( $(this).data('branchname') ) {
341                     current_elt = { 'text': $(this).data('branchname'), 'id': $(this).data('id') };
342                 } else {
343                     current_elt = default_elt;
344                 }
345                 title.update();
346             });
347             $("#UsageStatsLibrariesInfo").change();
348         });
350         $("#UsageStatsLibrariesInfo").on('change', function(){
351             if ( $(this).val() == 1 ) $("#libraries_info").show()
352             else $("#libraries_info").hide();
353             positionMap();
354         });
356     </script>
357 [% END %]
358 [% INCLUDE 'intranet-bottom.inc' %]