1 package C4
::UsageStats
;
3 # This file is part of Koha.
5 # Copyright 2014 BibLibre
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 use POSIX
qw(strftime);
32 This package contains what is needed to report Koha statistics to hea
33 hea.koha-community.org is the server that centralize Koha setups informations
34 Koha libraries are encouraged to provide informations about their collections,
39 $needUpdateYN = C4::UsageStats::NeedUpdate;
41 Returns Y (1) if the last update is more than 1 month old
42 This way, even if the cronjob is run every minute, the webservice will be called
48 my $lastupdated = C4
::Context
->preference('UsageStatsLastUpdateTime') || 0;
49 my $now = strftime
( "%s", localtime );
51 # Need to launch cron.
52 return 1 if $now - $lastupdated >= 2592000;
54 # Data don't need to be updated
61 id
=> C4
::Context
->preference('UsageStatsID') || 0,
62 name
=> C4
::Context
->preference('UsageStatsLibraryName') || q
||,
63 url
=> C4
::Context
->preference('UsageStatsLibraryUrl') || q
||,
64 type
=> C4
::Context
->preference('UsageStatsLibraryType') || q
||,
65 country
=> C4
::Context
->preference('UsageStatsCountry') || q
||,
69 # Get database volumetry.
71 qw
/biblio items auth_header old_issues old_reserves borrowers aqorders subscription/
74 $report->{volumetry
}{$_} = _count
($_);
77 # Get systempreferences.
81 AcqWarnOnDuplicateInvoice
100 UseAuthoritiesForTracings
103 IntranetBiblioDefaultView
109 DefaultClassificationSource
110 EasyAnalyticalRecords
117 SpineLabelShowPrintOnBibDetails
118 BlockReturnOfWithdrawnItems
119 CalculateFinesOnReturn
120 AgeRestrictionOverride
123 AllowItemsOnHoldCheckout
124 AllowNotForLoanOverride
125 AllowRenewalLimitOverride
129 AutoRemoveOverduesRestrictions
132 HomeOrHoldingBranchReturn
133 InProcessingToShelvingCart
136 ManInvInNoissuesCharge
140 RentalsInNoissuesCharge
143 TransfersMaxDaysWarning
144 UseBranchTransferLimits
146 UseTransportCostMatrix
149 FinesIncludeGracePeriod
151 RefundLostItemFeeOnReturn
152 WhenLostChargeReplacementFee
154 AllowHoldDateInFuture
155 AllowHoldPolicyOverride
156 AllowHoldsOnDamagedItems
157 AllowHoldsOnPatronsPossessions
159 AutoResumeSuspendedHolds
160 canreservefromotherbranches
161 decreaseLoanHighHolds
162 DisplayMultiPlaceHold
163 emailLibrarianWhenHoldIsPlaced
164 ExpireReservesMaxPickUpDelay
165 OPACAllowHoldDateInFuture
166 OPACAllowUserToChooseBranch
167 ReservesControlBranch
171 TransferWhenCancelAllWaitingHolds
172 AllowAllMessageDeletion
173 AllowOfflineCirculation
175 CircAutoPrintQuickSlip
176 DisplayClearScreenButton
177 FilterBeforeOverdueReport
179 itemBarcodeFallbackSearch
180 itemBarcodeInputFilter
181 previousIssuesDefaultSortOrder
182 RecordLocalUseOnReturn
185 todaysIssuesDefaultSortOrder
186 UpdateTotalIssuesOnCirc
188 WaitingNotifyAtCheckin
189 AllowSelfCheckReturns
194 OPACAmazonCoverImages
199 IDreamBooksReadometer
202 LibraryThingForLibrariesEnabled
205 NovelistSelectEnabled
211 CalendarFirstDayOfWeek
221 AuthorisedValueImages
226 HighlightOwnItemsOnOPAC
227 OpacAddMastheadLibraryPulldown
228 OPACDisplay856uAsImage
236 OpacShowFiltersPulldownMobile
237 OPACShowHoldQueueDetails
238 OpacShowLibrariesPulldownMobile
239 OpacShowRecentComments
240 OPACShowUnusedAuthorities
243 OPACURLOpenInNewWindow
255 OPACPopupAuthorsSearch
265 AllowPurchaseSuggestionBranchChoice
266 OpacAllowPublicListCreation
267 OpacAllowSharingPrivateLists
271 OPACViewOthersSuggestions
275 EnableOpacSearchHistory
279 PatronSelfRegistration
283 AutoEmailPrimaryAddress
285 BorrowerRenewalPeriodBase
288 EnhancedMessagingPreferences
289 ExtendedPatronAttributes
290 intranetreadinghistory
293 TalkingTechItivaPhoneNotification
295 IncludeSeeFromInSearches
301 TraceCompleteSubfields
302 TraceSubjectSubdivisions
308 OPACItemsResultsDisplay
310 IntranetNumbersPreferPhrase
311 OPACNumbersPreferPhrase
313 RenewSerialAddsSuggestion
314 RoutingListAddReserves
319 StaffAuthorisedValueImages
324 StaffDetailItemSelection
334 $report->{systempreferences
}{$_} = C4
::Context
->preference($_);
339 =head2 ReportToCommunity
343 Send to hea.koha-community.org database informations
347 sub ReportToCommunity
{
349 my $json = encode_json
($data);
351 my $url = "http://hea.koha-community.org/upload.pl";
352 my $ua = LWP
::UserAgent
->new;
355 'Content-type' => 'application/json;charset=utf-8',
358 my $content = decode_json
( $res->decoded_content );
359 C4
::Context
->set_preference( 'UsageStatsID',
360 $content->{library
}{id
} );
365 $data = _count($table);
367 Count the number of records in $table tables
374 my $dbh = C4
::Context
->dbh;
375 my $sth = $dbh->prepare("SELECT count(*) from $table");
377 return $sth->fetchrow_array;