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 InProcessingToShelvingCart
135 ManInvInNoissuesCharge
139 RentalsInNoissuesCharge
142 TransfersMaxDaysWarning
143 UseBranchTransferLimits
145 UseTransportCostMatrix
148 FinesIncludeGracePeriod
150 RefundLostItemFeeOnReturn
151 WhenLostChargeReplacementFee
153 AllowHoldDateInFuture
154 AllowHoldPolicyOverride
155 AllowHoldsOnDamagedItems
156 AllowHoldsOnPatronsPossessions
157 AutoResumeSuspendedHolds
158 canreservefromotherbranches
159 decreaseLoanHighHolds
160 DisplayMultiPlaceHold
161 emailLibrarianWhenHoldIsPlaced
162 ExpireReservesMaxPickUpDelay
163 OPACAllowHoldDateInFuture
164 OPACAllowUserToChooseBranch
165 ReservesControlBranch
169 TransferWhenCancelAllWaitingHolds
170 AllowAllMessageDeletion
171 AllowOfflineCirculation
173 CircAutoPrintQuickSlip
174 DisplayClearScreenButton
175 FilterBeforeOverdueReport
177 itemBarcodeFallbackSearch
178 itemBarcodeInputFilter
179 previousIssuesDefaultSortOrder
180 RecordLocalUseOnReturn
183 todaysIssuesDefaultSortOrder
184 UpdateTotalIssuesOnCirc
186 WaitingNotifyAtCheckin
187 AllowSelfCheckReturns
192 OPACAmazonCoverImages
197 IDreamBooksReadometer
200 LibraryThingForLibrariesEnabled
203 NovelistSelectEnabled
210 CalendarFirstDayOfWeek
220 AuthorisedValueImages
225 HighlightOwnItemsOnOPAC
226 OpacAddMastheadLibraryPulldown
227 OPACDisplay856uAsImage
235 OpacShowFiltersPulldownMobile
236 OPACShowHoldQueueDetails
237 OpacShowLibrariesPulldownMobile
238 OpacShowRecentComments
239 OPACShowUnusedAuthorities
242 OPACURLOpenInNewWindow
254 OPACPopupAuthorsSearch
264 AllowPurchaseSuggestionBranchChoice
265 OpacAllowPublicListCreation
266 OpacAllowSharingPrivateLists
269 OPACViewOthersSuggestions
272 EnableOpacSearchHistory
276 PatronSelfRegistration
279 AutoEmailPrimaryAddress
281 BorrowerRenewalPeriodBase
284 EnhancedMessagingPreferences
285 ExtendedPatronAttributes
286 intranetreadinghistory
289 TalkingTechItivaPhoneNotification
291 IncludeSeeFromInSearches
297 TraceCompleteSubfields
298 TraceSubjectSubdivisions
304 OPACItemsResultsDisplay
306 IntranetNumbersPreferPhrase
307 OPACNumbersPreferPhrase
309 RenewSerialAddsSuggestion
310 RoutingListAddReserves
315 StaffAuthorisedValueImages
320 StaffDetailItemSelection
330 $report->{systempreferences
}{$_} = C4
::Context
->preference($_);
335 =head2 ReportToCommunity
339 Send to hea.koha-community.org database informations
343 sub ReportToCommunity
{
345 my $json = encode_json
($data);
347 my $url = "http://hea.koha-community.org/upload.pl";
348 my $ua = LWP
::UserAgent
->new;
351 'Content-type' => 'application/json;charset=utf-8',
354 my $content = decode_json
( $res->decoded_content );
355 C4
::Context
->set_preference( 'UsageStatsID',
356 $content->{library
}{id
} );
361 $data = _count($table);
363 Count the number of records in $table tables
370 my $dbh = C4
::Context
->dbh;
371 my $sth = $dbh->prepare("SELECT count(*) from $table");
373 return $sth->fetchrow_array;