Bug 25650: Add location and itype descriptions in ILS-DI GetRecords
[koha.git] / misc / cronjobs / automatic_item_modification_by_age.pl
blobe944ac8c11fe8f9fdacbc92edeedd407b7e85ac1
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;
12 use C4::Log;
14 # Getting options
15 my ( $verbose, $help, $confirm );
16 my $result = GetOptions(
17 'h|help' => \$help,
18 'v|verbose' => \$verbose,
19 'c|confirm' => \$confirm,
22 pod2usage(1) if $help;
23 $verbose = 1 unless $confirm;
25 # Load configuration from the syspref
26 my $syspref_content = C4::Context->preference('automatic_item_modification_by_age_configuration');
27 my $rules = eval { JSON::from_json( $syspref_content ) };
28 pod2usage({ -message => "Unable to load the configuration : $@", -exitval => 1 })
29 if $@;
31 cronlogaction();
33 my $report = C4::Items::ToggleNewStatus( { rules => $rules, report_only => not $confirm } );
35 if ( $verbose ) {
36 if ( $report ) {
37 say "Item to modify:";
38 while ( my ( $itemnumber, $substitutions ) = each %$report ) {
39 for my $substitution ( @$substitutions ) {
40 if ( defined $substitution->{value} and $substitution->{value} ne q|| ) {
41 say "\titemnumber $itemnumber: $substitution->{field}=$substitution->{value}";
42 } else {
43 say "\titemnumber $itemnumber: field $substitution->{field} to delete";
47 } else {
48 say "There is no item to modify";
52 exit(0);
54 __END__
56 =head1 NAME
58 automatic_item_modification_by_age.pl
60 =head1 SYNOPSIS
62 ./automatic_item_modification_by_age.pl -h
64 Toggle recent acquisitions status.
65 Use this script to delete "new" status for items.
67 =head1 OPTIONS
69 =over 8
71 =item B<-h|--help>
73 Prints this help message.
75 =item B<-v|--verbose>
77 Set the verbose flag.
79 =item B<-c|--confirm>
81 The script will modify the items.
83 =back
85 =head1 AUTHOR
87 Jonathan Druart <jonathan.druart@biblibre.com>
89 =head1 COPYRIGHT
91 Copyright 2013 BibLibre
93 =head1 LICENSE
95 This file is part of Koha.
97 Koha is free software; you can redistribute it and/or modify it
98 under the terms of the GNU General Public License as published by
99 the Free Software Foundation; either version 3 of the License, or
100 (at your option) any later version.
102 Koha is distributed in the hope that it will be useful, but
103 WITHOUT ANY WARRANTY; without even the implied warranty of
104 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
105 GNU General Public License for more details.
107 You should have received a copy of the GNU General Public License
108 along with Koha; if not, see <http://www.gnu.org/licenses>.
110 =cut