Bug 17670: Grammar mistakes - effect vs affect
[koha.git] / misc / cronjobs / automatic_item_modification_by_age.pl
blob51effd32b1be64b18b183309d128cddd2b16bb55
1 #!/usr/bin/perl
3 use Modern::Perl;
5 use Getopt::Long;
6 use Pod::Usage;
7 use JSON;
9 use C4::Context;
10 use C4::Items;
12 # Getting options
13 my ( $verbose, $help, $confirm );
14 my $result = GetOptions(
15 'h|help' => \$help,
16 'v|verbose' => \$verbose,
17 'c|confirm' => \$confirm,
20 pod2usage(1) if $help;
21 $verbose = 1 unless $confirm;
23 # Load configuration from the syspref
24 my $syspref_content = C4::Context->preference('automatic_item_modification_by_age_configuration');
25 my $rules = eval { JSON::from_json( $syspref_content ) };
26 pod2usage({ -message => "Unable to load the configuration : $@", -exitval => 1 })
27 if $@;
29 my $report = C4::Items::ToggleNewStatus( { rules => $rules, report_only => not $confirm } );
31 if ( $verbose ) {
32 if ( $report ) {
33 say "Item to modify:";
34 while ( my ( $itemnumber, $substitutions ) = each %$report ) {
35 for my $substitution ( @$substitutions ) {
36 if ( defined $substitution->{value} and $substitution->{value} ne q|| ) {
37 say "\titemnumber $itemnumber: $substitution->{field}=$substitution->{value}";
38 } else {
39 say "\titemnumber $itemnumber: field $substitution->{field} to delete";
43 } else {
44 say "There is no item to modify";
48 exit(0);
50 __END__
52 =head1 NAME
54 automatic_item_modification_by_age.pl
56 =head1 SYNOPSIS
58 ./automatic_item_modification_by_age.pl -h
60 Toggle recent acquisitions status.
61 Use this script to delete "new" status for items.
63 =head1 OPTIONS
65 =over 8
67 =item B<-h|--help>
69 Prints this help message.
71 =item B<-v|--verbose>
73 Set the verbose flag.
75 =item B<-c|--confirm>
77 The script will modify the items.
79 =back
81 =head1 AUTHOR
83 Jonathan Druart <jonathan.druart@biblibre.com>
85 =head1 COPYRIGHT
87 Copyright 2013 BibLibre
89 =head1 LICENSE
91 This file is part of Koha.
93 Koha is free software; you can redistribute it and/or modify it
94 under the terms of the GNU General Public License as published by
95 the Free Software Foundation; either version 3 of the License, or
96 (at your option) any later version.
98 Koha is distributed in the hope that it will be useful, but
99 WITHOUT ANY WARRANTY; without even the implied warranty of
100 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
101 GNU General Public License for more details.
103 You should have received a copy of the GNU General Public License
104 along with Koha; if not, see <http://www.gnu.org/licenses>.
106 =cut