Bug 18786: Add ability to create custom payment types
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / usage_statistics.tt
1 [% USE Asset %]
2 [% SET footerjs = 1 %]
3 [% USE Koha %]
4 [% USE KohaDates %]
5 [% USE Price %]
6 [% INCLUDE 'doc-head-open.inc' %]
7 <title>Koha &rsaquo; Administration &rsaquo; Koha usage statistics</title>
8 [% INCLUDE 'doc-head-close.inc' %]
9 [% Asset.css("lib/leaflet/leaflet.css") %]
10 </head>
11
12 <body id="admin_usage_statistics" class="admin">
13 [% INCLUDE 'header.inc' %]
14 [% INCLUDE 'cat-search.inc' %]
15
16 <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>
17
18 <div id="doc3" class="yui-t2">
19    <div id="bd">
20     <div id="yui-main">
21     <div class="yui-b">
22
23 [% FOR m IN messages %]
24     <div class="dialog [% m.type %]">
25         [% SWITCH m.code %]
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.
40         [% CASE %]
41             [% m.code %]
42         [% END %]
43     </div>
44 [% END %]
45
46 [% IF NOT Koha.Preference('UsageStats') %]
47     <div class="dialog message">You are not sharing any data with the Koha community</div>
48 [% END %]
49
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;">
54                 <li>
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>
60                     [% ELSE %]
61                         <option value="1">Yes</option>
62                         <option value="0" selected="selected">No</option>
63                     [% END %]
64                     </select>
65                 </li>
66                 <li>
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 %]
72                     [% END %]
73                     [% PROCESS 'country-list.inc' %]
74                     <select name="UsageStatsCountry" id="UsageStatsCountry">
75                         <option value="">&nbsp;</option>
76                         [% FOR country IN countries %]
77                             [% IF country == UsageStatsCountry %]
78                                 <option value="[% country %]" selected="selected">[% country %]</option>
79                                 [% SET IsUsageStatsCountryValid = 1 %]
80                             [% ELSE %]
81                                 <option value="[% country %]">[% country %]</option>
82                             [% END %]
83                         [% END %]
84                     </select>
85                     [% UNLESS IsUsageStatsCountryValid %]
86                         Note: The value of your system preference 'UsageStatsCountry' is not valid ([% UsageStatsCountry %]).
87                         Please select a valid one.
88                     [% END %]
89                 </li>
90                 <li>
91                     <label for="UsageStatsLibraryName">Library name: </label>
92                     <input type="text" value="[% Koha.Preference('UsageStatsLibraryName') | html %]" name="UsageStatsLibraryName" id="UsageStatsLibraryName" />
93                 </li>
94                 <li>
95                     <label for="UsageStatsLibraryType">Library type: </label>
96                     [% SET UsageStatsLibraryType = Koha.Preference('UsageStatsLibraryType') %]
97                     <select name="UsageStatsLibraryType" id="UsageStatsLibraryType">
98                         <option value="">&nbsp;</option>
99                         [% IF UsageStatsLibraryType == 'public' %]
100                             <option value="public" selected="selected">Public</option>
101                         [% ELSE %]
102                             <option value="public">Public</option>
103                         [% END %]
104
105                         [% IF UsageStatsLibraryType == 'school' %]
106                             <option value="school" selected="selected">School</option>
107                         [% ELSE %]
108                             <option value="school">School</option>
109                         [% END %]
110                         [% IF UsageStatsLibraryType == 'academic' %]
111                             <option value="academic" selected="selected">Academic</option>
112                         [% ELSE %]
113                             <option value="academic">Academic</option>
114                         [% END %]
115                         [% IF UsageStatsLibraryType == 'research' %]
116                             <option value="research" selected="selected">Research</option>
117                         [% ELSE %]
118                             <option value="research">Research</option>
119                         [% END %]
120                         [% IF UsageStatsLibraryType == 'private' %]
121                             <option value="private" selected="selected">Private</option>
122                         [% ELSE %]
123                             <option value="private">Private</option>
124                         [% END %]
125                         [% IF UsageStatsLibraryType == 'societyAssociation' %]
126                             <option value="societyAssociation" selected="selected">Society or association</option>
127                         [% ELSE %]
128                             <option value="societyAssociation">Society or association</option>
129                         [% END %]
130                         [% IF UsageStatsLibraryType == 'corporate' %]
131                             <option value="corporate" selected="selected">Corporate</option>
132                         [% ELSE %]
133                             <option value="corporate">Corporate</option>
134                         [% END %]
135                         [% IF UsageStatsLibraryType == 'government' %]
136                             <option value="government" selected="selected">Government</option>
137                         [% ELSE %]
138                             <option value="government">Government</option>
139                         [% END %]
140                         [% IF UsageStatsLibraryType == 'religiousOrg' %]
141                             <option value="religiousOrg" selected="selected">Religious organization</option>
142                         [% ELSE %]
143                             <option value="religiousOrg">Religious organization</option>
144                         [% END %]
145                         [% IF UsageStatsLibraryType == 'subscription' %]
146                             <option value="subscription" selected="selected">Subscription</option>
147                         [% ELSE %]
148                             <option value="subscription">Subscription</option>
149                         [% END %]
150                     </select>
151                 </li>
152                 <li>
153                     <label for="UsageStatsLibraryUrl">Library URL: </label>
154                     <input type="text" name="UsageStatsLibraryUrl" value="[% Koha.Preference('UsageStatsLibraryUrl') %]" id="UsageStatsLibraryUrl" />
155                 </li>
156                 <li>
157                     <span class="label">Last update: </span>
158                     [% IF UsageStatsLastUpdateTime %]
159                         [% UsageStatsLastUpdateTime %]
160                     [% ELSE %]
161                         Your data have never been shared
162                     [% END %]
163                 </li>
164                 <li>
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>
168                 </li>
169                 <li>
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>
175                         [% ELSE %]
176                             <option value="1">Yes</option>
177                             <option value="0" selected="selected">No</option>
178                         [% END %]
179                     </select>
180                 </li>
181
182                 <li id="libraries_info">
183                     <fieldset class="rows">
184                     <legend>Libraries</legend>
185                     <ol>
186                         [% FOR l IN libraries %]
187                         <li>
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>
192                                 <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>
195                                 </div>
196                             </div>
197                         </li>
198                         [% END %]
199                     </ol>
200                     </fieldset>
201                 </li>
202                 <li>
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>
207                     [% ELSE %]
208                         You do not have anything public yet.
209                     [% END %]
210                 </li>
211
212             </ol>
213             <div style="clear:right"></div>
214         <div id="mapid" style="width: 600px; height: 400px; margin-left: 40%:"></div>
215     </fieldset>
216
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>
221         </fieldset>
222     </form>
223 </div>
224 </div>
225 <div class="yui-b">
226 [% INCLUDE 'admin-menu.inc' %]
227 </div>
228 </div>
229
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');
241             tbh.css('right', 0);
242
243             var offsetTop = mapContainer.offset().top;
244             var s = parseInt($(window).scrollTop(), 10);
245             tbh.css('top', '').css('bottom', '');
246             if (s > offsetTop) {
247                 var mapContainerOffsetBottom = offsetTop + mapContainer.innerHeight();
248                 if (s + tbh.outerHeight(true) > mapContainerOffsetBottom) {
249                     tbh.css('bottom', 0);
250                 } else {
251                     tbh.css('top', s - offsetTop);
252                 }
253             } else {
254                 tbh.css('top', 0);
255             }
256         }
257
258         $(document).ready(function() {
259             $(window).scroll(positionMap);
260             positionMap();
261         });
262
263         var map = L.map('mapid').setView([0,0], 1);
264
265         L.tileLayer('https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', {
266             maxZoom: 18,
267             attribution: 'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
268                 '<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'
269         }).addTo(map);
270
271         var default_elt = { 'text': _("Main library"), 'id': 'UsageStatsGeolocation' };
272         var current_elt = default_elt;
273
274         // Add the title
275         var title = L.control({position: 'topright'});
276         title.onAdd = function (map) {
277             this._div = L.DomUtil.create('div', 'title');
278             this.update();
279             return this._div;
280         };
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>';
283         };
284         title.addTo(map);
285
286         var markers = {};
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;
295         }
296
297         // Init the map
298         [% IF Koha.Preference('UsageStatsGeolocation') %]
299             var latlng = [ [% Koha.Preference('UsageStatsGeolocation') %] ];
300             add_to_map( current_elt, latlng );
301         [% END %]
302         [% FOR l IN libraries %]
303             [% NEXT UNLESS l.geolocation %]
304             add_to_map( { 'text': "[% l.branchname %]", 'id': "geolocation_[% l.branchcode %]" }, [ [% l.geolocation %] ] );
305         [% END %]
306
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);
311         });
312
313         // Auto zoom
314         var group = new L.featureGroup(Object.keys(markers).map(function(key){return markers[key]}));
315         if ( group.getBounds().isValid() ) map.fitBounds(group.getBounds());
316
317         // On click on the marker icons, update the title of the map
318         $(document).ready(function(){
319             $(".change_geolocation").on('click', function(e){
320                 e.preventDefault();
321                 if ( $(this).data('branchname') ) {
322                     current_elt = { 'text': $(this).data('branchname'), 'id': $(this).data('id') };
323                 } else {
324                     current_elt = default_elt;
325                 }
326                 title.update();
327             });
328             $("#UsageStatsLibrariesInfo").change();
329         });
330
331         $("#UsageStatsLibrariesInfo").on('change', function(){
332             if ( $(this).val() == 1 ) $("#libraries_info").show()
333             else $("#libraries_info").hide();
334             positionMap();
335         });
336
337     </script>
338 [% END %]
339 [% INCLUDE 'intranet-bottom.inc' %]