View | Details | Raw Unified | Return to bug 14608
Collapse All | Expand All

(-)a/admin/usage_statistics.pl (+58 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use CGI qw ( -utf8 );
21
use C4::Auth;
22
use C4::Output;
23
use Koha::DateUtils qw( dt_from_string output_pref );
24
25
my $query = new CGI;
26
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
27
    {
28
        template_name   => "admin/usage_statistics.tt",
29
        query           => $query,
30
        type            => "intranet",
31
        authnotrequired => 0,
32
        flagsrequired   => { parameters => '*' },
33
        debug           => 1,
34
    }
35
);
36
37
my $op = $query->param('op') || q||;
38
39
if ( $op eq 'update' ) {
40
    my $UsageStats = $query->param('UsageStats');
41
    my $UsageStatsCountry = $query->param('UsageStatsCountry');
42
    my $UsageStatsLibraryName = $query->param('UsageStatsLibraryName');
43
    my $UsageStatsLibraryType = $query->param('UsageStatsLibraryType');
44
    my $UsageStatsLibraryUrl = $query->param('UsageStatsLibraryUrl');
45
    C4::Context->set_preference('UsageStats', $UsageStats);
46
    C4::Context->set_preference('UsageStatsCountry', $UsageStatsCountry);
47
    C4::Context->set_preference('UsageStatsLibraryName', $UsageStatsLibraryName);
48
    C4::Context->set_preference('UsageStatsLibraryType', $UsageStatsLibraryType);
49
    C4::Context->set_preference('UsageStatsLibraryUrl', $UsageStatsLibraryUrl);
50
51
}
52
53
if ( C4::Context->preference('UsageStatsLastUpdateTime') ) {
54
    my $dt = DateTime->from_epoch( epoch => C4::Context->preference('UsageStatsLastUpdateTime'));
55
    $template->param(UsageStatsLastUpdateTime => output_pref($dt) );
56
}
57
58
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/usage_statistics.tt (-1 / +372 lines)
Line 0 Link Here
0
- 
1
[% USE Koha %]
2
[% USE KohaDates %]
3
[% USE Price %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Administration &rsaquo; Koha usage statistics</title>
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'calendar.inc' %]
8
</head>
9
10
<body id="admin_usage_statistics" class="admin">
11
[% INCLUDE 'header.inc' %]
12
[% INCLUDE 'patrons-admin-search.inc' %]
13
14
<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>
15
16
<div id="doc3" class="yui-t2">
17
   <div id="bd">
18
    <div id="yui-main">
19
    <div class="yui-b">
20
21
[% FOR m IN messages %]
22
    <div class="dialog [% m.type %]">
23
        [% SWITCH m.code %]
24
        [% CASE 'error_on_update' %]
25
            An error occurred when updating this patron category. Perhaps it already exists.
26
        [% CASE 'error_on_insert' %]
27
            An error occurred when inserting this patron category. The patron category might already exist.
28
        [% CASE 'error_on_delete' %]
29
            An error occurred when deleting this patron category. Check the logs.
30
        [% CASE 'success_on_update' %]
31
            Patron category updated successfully.
32
        [% CASE 'success_on_insert' %]
33
            Patron category inserted successfully.
34
        [% CASE 'success_on_delete' %]
35
            Patron category deleted successfully.
36
        [% CASE 'already_exists' %]
37
            This patron category already exists.
38
        [% CASE %]
39
            [% m.code %]
40
        [% END %]
41
    </div>
42
[% END %]
43
44
[% IF NOT Koha.Preference('UsageStats') %]
45
    <div class="dialog message">You are not sharing any data with the Koha community</div>
46
[% END %]
47
48
    <form id="category_form" action="/cgi-bin/koha/admin/usage_statistics.pl" method="post">
49
        <h1>Modify the statistics you share with the Koha community</h1>
50
        <fieldset class="rows">
51
            <ol>
52
                <li>
53
                    <span class="label">Share my Koha usage statistics: </span>
54
                    <select name="UsageStats">
55
                    [% IF Koha.Preference('UsageStats') %]
56
                        <option value="1" selected="selected">Yes</option>
57
                        <option value="0">No</option>
58
                    [% ELSE %]
59
                        <option value="1">Yes</option>
60
                        <option value="0" selected="selected">No</option>
61
                    [% END %]
62
                    </select>
63
                </li>
64
                <li>
65
                    <span class="label">Your country: </span>
66
                    [% SET UsageStatsCountry = Koha.Preference('UsageStatsCountry') %]
67
                    [% SET IsUsageStatsCountryValid = 0 %]
68
                    [% IF NOT UsageStatsCountry %]
69
                        [% SET IsUsageStatsCountryValid = 1 %]
70
                    [% END %]
71
                    <select name="UsageStatsCountry">
72
                        <option value=""></option>
73
                        [% FOR country IN [
74
"Afghanistan",
75
"Albania",
76
"Algeria",
77
"Andorra",
78
"Angola",
79
"Antigua & Deps",
80
"Argentina",
81
"Armenia",
82
"Australia",
83
"Austria",
84
"Azerbaijan",
85
"Bahamas",
86
"Bahrain",
87
"Bangladesh",
88
"Barbados",
89
"Belarus",
90
"Belgium",
91
"Belize",
92
"Benin",
93
"Bhutan",
94
"Bolivia",
95
"Bosnia Herz.",
96
"Botswana",
97
"Brazil",
98
"Brunei",
99
"Bulgaria",
100
"Burkina",
101
"Burundi",
102
"Cambodia",
103
"Cameroon",
104
"Canada",
105
"Cape Verde",
106
"Centr. Afr. Rep",
107
"Chad",
108
"Chile",
109
"China",
110
"Colombia",
111
"Comoros",
112
"Congo",
113
"Costa Rica",
114
"Croatia",
115
"Cuba",
116
"Cyprus",
117
"Czech Republic",
118
"Denmark",
119
"Djibouti",
120
"Dominica",
121
"Dominican Rep.",
122
"East Timor",
123
"Ecuador",
124
"Egypt",
125
"El Salvador",
126
"Equator. Guinea",
127
"Eritrea",
128
"Estonia",
129
"Ethiopia",
130
"Fiji",
131
"Finland",
132
"France",
133
"Gabon",
134
"Gambia",
135
"Georgia",
136
"Germany",
137
"Ghana",
138
"Greece",
139
"Grenada",
140
"Guatemala",
141
"Guinea",
142
"Guinea-Bissau",
143
"Guyana",
144
"Haiti",
145
"Honduras",
146
"Hungary",
147
"Iceland",
148
"India",
149
"Indonesia",
150
"Iran",
151
"Iraq",
152
"Ireland",
153
"Israel",
154
"Italy",
155
"Ivory Coast",
156
"Jamaica",
157
"Japan",
158
"Jordan",
159
"Kazakhstan",
160
"Kenya",
161
"Kiribati",
162
"Korea North",
163
"Korea South",
164
"Kosovo",
165
"Kuwait",
166
"Kyrgyzstan",
167
"Laos",
168
"Latvia",
169
"Lebanon",
170
"Lesotho",
171
"Liberia",
172
"Libya",
173
"Liechtenstein",
174
"Lithuania",
175
"Luxembourg",
176
"Macedonia",
177
"Madagascar",
178
"Malawi",
179
"Malaysia",
180
"Maldives",
181
"Mali",
182
"Malta",
183
"Marshall Isl.",
184
"Mauritania",
185
"Mauritius",
186
"Mexico",
187
"Micronesia",
188
"Moldova",
189
"Monaco",
190
"Mongolia",
191
"Montenegro",
192
"Morocco",
193
"Mozambique",
194
"Myanmar",
195
"Namibia",
196
"Nauru",
197
"Nepal",
198
"Netherlands",
199
"New Zealand",
200
"Nicaragua",
201
"Niger",
202
"Nigeria",
203
"Norway",
204
"Oman",
205
"Pakistan",
206
"Palau",
207
"Panama",
208
"Papua N. Guinea",
209
"Paraguay",
210
"Peru",
211
"Philippines",
212
"Poland",
213
"Portugal",
214
"Qatar",
215
"Romania",
216
"Russian Fed.",
217
"Rwanda",
218
"St Kitts & Nev.",
219
"St Lucia",
220
"Saint Vincent",
221
"Samoa",
222
"San Marino",
223
"Sao Tome",
224
"Saudi Arabia",
225
"Senegal",
226
"Serbia",
227
"Seychelles",
228
"Sierra Leone",
229
"Singapore",
230
"Slovakia",
231
"Slovenia",
232
"Solomon Islands",
233
"Somalia",
234
"South Africa",
235
"Spain",
236
"Sri Lanka",
237
"Sudan",
238
"Suriname",
239
"Swaziland",
240
"Sweden",
241
"Switzerland",
242
"Syria",
243
"Taiwan",
244
"Tajikistan",
245
"Tanzania",
246
"Thailand",
247
"Togo",
248
"Tonga",
249
"Trinidad & Tob.",
250
"Tunisia",
251
"Turkey",
252
"Turkmenistan",
253
"Tuvalu",
254
"Uganda",
255
"Ukraine",
256
"UAE",
257
"United Kingdom",
258
"USA",
259
"Uruguay",
260
"Uzbekistan",
261
"Vanuatu",
262
"Vatican City",
263
"Venezuela",
264
"Vietnam",
265
"Yemen",
266
"Zambia",
267
"Zimbabwe",
268
] %]
269
                            [% IF country == UsageStatsCountry %]
270
                                <option value="[% country %]" selected="selected">[% country %]</option>
271
                                [% SET IsUsageStatsCountryValid = 1 %]
272
                            [% ELSE %]
273
                                <option value="[% country %]">[% country %]</option>
274
                            [% END %]
275
                        [% END %]
276
                    </select>
277
                    [% UNLESS IsUsageStatsCountryValid %]
278
                        Note: The value of your system preference 'UsageStatsCountry' is not valid ([% UsageStatsCountry %]).
279
                        Please select a valid one.
280
                    [% END %]
281
                </li>
282
                <li>
283
                    <span class="label">Library name: </span>
284
                    <input type="text" value="[% Koha.Preference('UsageStatsLibraryName') %]" name="UsageStatsLibraryName" />
285
                </li>
286
                <li>
287
                    <span class="label">Library type: </span>
288
                    [% SET UsageStatsLibraryType = Koha.Preference('UsageStatsLibraryType') %]
289
                    <select name="UsageStatsLibraryType">
290
                        <option value=""></option>
291
                        [% IF UsageStatsLibraryType == 'public' %]
292
                            <option value="public" selected="selected">Public</option>
293
                        [% ELSE %]
294
                            <option value="public">Public</option>
295
                        [% END %]
296
297
                        [% IF UsageStatsLibraryType == 'school' %]
298
                            <option value="school" selected="selected">School</option>
299
                        [% ELSE %]
300
                            <option value="school">School</option>
301
                        [% END %]
302
                        [% IF UsageStatsLibraryType == 'academic' %]
303
                            <option value="academic" selected="selected">Academic</option>
304
                        [% ELSE %]
305
                            <option value="academic">Academic</option>
306
                        [% END %]
307
                        [% IF UsageStatsLibraryType == 'research' %]
308
                            <option value="research" selected="selected">Research</option>
309
                        [% ELSE %]
310
                            <option value="research">Research</option>
311
                        [% END %]
312
                        [% IF UsageStatsLibraryType == 'private' %]
313
                            <option value="private" selected="selected">Private</option>
314
                        [% ELSE %]
315
                            <option value="private">Private</option>
316
                        [% END %]
317
                        [% IF UsageStatsLibraryType == 'societyAssociation' %]
318
                            <option value="societyAssociation" selected="selected">Society or association</option>
319
                        [% ELSE %]
320
                            <option value="societyAssociation">Society or association</option>
321
                        [% END %]
322
                        [% IF UsageStatsLibraryType == 'corporate' %]
323
                            <option value="corporate" selected="selected">Corporate</option>
324
                        [% ELSE %]
325
                            <option value="corporate">Corporate</option>
326
                        [% END %]
327
                        [% IF UsageStatsLibraryType == 'government' %]
328
                            <option value="government" selected="selected">Government</option>
329
                        [% ELSE %]
330
                            <option value="government">Government</option>
331
                        [% END %]
332
                        [% IF UsageStatsLibraryType == 'religiousOrg' %]
333
                            <option value="religiousOrg" selected="selected">Religious organization</option>
334
                        [% ELSE %]
335
                            <option value="religiousOrg">Religious organization</option>
336
                        [% END %]
337
                        [% IF UsageStatsLibraryType == 'subscription' %]
338
                            <option value="subscription" selected="selected">Subscription</option>
339
                        [% ELSE %]
340
                            <option value="subscription">Subscription</option>
341
                        [% END %]
342
                    </select>
343
                </li>
344
                <li>
345
                    <span class="label">Library URL: </span>
346
                    <input type="text" name="UsageStatsLibraryUrl" value="[% Koha.Preference('UsageStatsLibraryUrl') %]" />
347
                </li>
348
                <li>
349
                    <span class="label">Last update: </span>
350
                    [% IF UsageStatsLastUpdateTime %]
351
                        [% UsageStatsLastUpdateTime %]
352
                    [% ELSE %]
353
                        Your data have never been shared
354
                    [% END %]
355
                </li>
356
            </ol>
357
        </fieldset>
358
359
        <fieldset class="action">
360
            <input type="hidden" name="op" value="update" />
361
            <input type="submit" value="Update your statistics usage" />
362
            <a class="cancel" href="/cgi-bin/koha/admin/usage_statistics.pl">Cancel</a>
363
        </fieldset>
364
    </form>
365
366
</div>
367
</div>
368
<div class="yui-b">
369
[% INCLUDE 'admin-menu.inc' %]
370
</div>
371
</div>
372
[% INCLUDE 'intranet-bottom.inc' %]

Return to bug 14608