3 # Copyright 2020 BibLibre
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it under the
8 # terms of the GNU General Public License as published by the Free Software
9 # Foundation; either version 3 of the License, or (at your option) any later
12 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along
17 # with Koha; if not, see <http://www.gnu.org/licenses>.
21 get-prepared-letter.pl - preview letter content
25 get-prepared-letter.pl --module MODULE --letter-code CODE [options]
31 =item B<--module MODULE>
33 The letter module (acquisition, catalogue, circulation, ...)
35 =item B<--letter-code CODE>
37 The letter code (DUE, PREDUE, ...)
39 =item B<--branchcode BRANCHCODE>
43 =item B<--message-transport-type TYPE>
45 The message transport type (email, print, ...)
49 The letter language (es-ES, fr-FR, ...)
51 =item B<--repeat REPEAT>
53 A JSON formatted string that will be used as repeat parameter. See
54 documentation of GetPreparedLetter for more informations.
56 =item B<--tables TABLES>
58 A JSON formatted string that will be used as tables parameter. See
59 documentation of GetPreparedLetter for more informations.
61 =item B<--loops LOOPS>
63 A JSON formatted string that will be used as loops parameter. See
64 documentation of GetPreparedLetter for more informations.
79 my ( $module, $letter_code, $branchcode, $message_transport_type, $lang,
80 $repeat, $tables, $loops );
84 'module=s' => \
$module,
85 'letter-code=s' => \
$letter_code,
86 'branchcode=s' => \
$branchcode,
87 'message-transport-type=s' => \
$message_transport_type,
89 'repeat=s' => \
$repeat,
90 'tables=s' => \
$tables,
92 ) or pod2usage
( -exitval
=> 2, -verbose
=> 1 );
95 pod2usage
( -exitval
=> 0, -verbose
=> 1 );
98 $repeat = $repeat ? decode_json
($repeat) : {};
99 $tables = $tables ? decode_json
($tables) : {};
100 $loops = $loops ? decode_json
($loops) : {};
102 my $letter = C4
::Letters
::GetPreparedLetter
(
104 letter_code
=> $letter_code,
105 branchcode
=> $branchcode,
106 message_transport_type
=> $message_transport_type,
113 print "Subject: " . $letter->{title
} . "\n\n";
114 print $letter->{content
} . "\n";