Bug 22566: (QA follow-up) Fix pod complaint
[koha.git] / misc / cronjobs / automatic_item_modification_by_age.pl
blob364f61f1837f4eec19c256b696977663eda4f0f8
1 #!/usr/bin/perl
3 use Modern::Perl;
5 use Getopt::Long;
6 use Pod::Usage;
7 use JSON;
9 use Koha::Script -cron;
10 use C4::Context;
11 use C4::Items;
13 # Getting options
14 my ( $verbose, $help, $confirm );
15 my $result = GetOptions(
16 'h|help' => \$help,
17 'v|verbose' => \$verbose,
18 'c|confirm' => \$confirm,
21 pod2usage(1) if $help;
22 $verbose = 1 unless $confirm;
24 # Load configuration from the syspref
25 my $syspref_content = C4::Context->preference('automatic_item_modification_by_age_configuration');
26 my $rules = eval { JSON::from_json( $syspref_content ) };
27 pod2usage({ -message => "Unable to load the configuration : $@", -exitval => 1 })
28 if $@;
30 my $report = C4::Items::ToggleNewStatus( { rules => $rules, report_only => not $confirm } );
32 if ( $verbose ) {
33 if ( $report ) {
34 say "Item to modify:";
35 while ( my ( $itemnumber, $substitutions ) = each %$report ) {
36 for my $substitution ( @$substitutions ) {
37 if ( defined $substitution->{value} and $substitution->{value} ne q|| ) {
38 say "\titemnumber $itemnumber: $substitution->{field}=$substitution->{value}";
39 } else {
40 say "\titemnumber $itemnumber: field $substitution->{field} to delete";
44 } else {
45 say "There is no item to modify";
49 exit(0);
51 __END__
53 =head1 NAME
55 automatic_item_modification_by_age.pl
57 =head1 SYNOPSIS
59 ./automatic_item_modification_by_age.pl -h
61 Toggle recent acquisitions status.
62 Use this script to delete "new" status for items.
64 =head1 OPTIONS
66 =over 8
68 =item B<-h|--help>
70 Prints this help message.
72 =item B<-v|--verbose>
74 Set the verbose flag.
76 =item B<-c|--confirm>
78 The script will modify the items.
80 =back
82 =head1 AUTHOR
84 Jonathan Druart <jonathan.druart@biblibre.com>
86 =head1 COPYRIGHT
88 Copyright 2013 BibLibre
90 =head1 LICENSE
92 This file is part of Koha.
94 Koha is free software; you can redistribute it and/or modify it
95 under the terms of the GNU General Public License as published by
96 the Free Software Foundation; either version 3 of the License, or
97 (at your option) any later version.
99 Koha is distributed in the hope that it will be useful, but
100 WITHOUT ANY WARRANTY; without even the implied warranty of
101 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
102 GNU General Public License for more details.
104 You should have received a copy of the GNU General Public License
105 along with Koha; if not, see <http://www.gnu.org/licenses>.
107 =cut