View | Details | Raw Unified | Return to bug 24591
Collapse All | Expand All

(-)a/misc/devel/get-prepared-letter.pl (-18 / +76 lines)
Lines 16-54 Link Here
16
# You should have received a copy of the GNU General Public License along
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>.
17
# with Koha; if not, see <http://www.gnu.org/licenses>.
18
18
19
=head1 NAME
20
21
get-prepared-letter.pl - preview letter content
22
23
=head1 SYNOPSIS
24
25
get-prepared-letter.pl --module MODULE --letter-code CODE [options]
26
27
=head1 OPTIONS
28
29
=over
30
31
=item B<--module MODULE>
32
33
The letter module (acquisition, catalogue, circulation, ...)
34
35
=item B<--letter-code CODE>
36
37
The letter code (DUE, PREDUE, ...)
38
39
=item B<--branchcode BRANCHCODE>
40
41
The letter branchcode
42
43
=item B<--message-transport-type TYPE>
44
45
The message transport type (email, print, ...)
46
47
=item B<--lang LANG>
48
49
The letter language (es-ES, fr-FR, ...)
50
51
=item B<--repeat REPEAT>
52
53
A JSON formatted string that will be used as repeat parameter. See
54
documentation of GetPreparedLetter for more informations.
55
56
=item B<--tables TABLES>
57
58
A JSON formatted string that will be used as tables parameter. See
59
documentation of GetPreparedLetter for more informations.
60
61
=item B<--loops LOOPS>
62
63
A JSON formatted string that will be used as loops parameter. See
64
documentation of GetPreparedLetter for more informations.
65
66
=back
67
68
=cut
69
19
use Modern::Perl;
70
use Modern::Perl;
20
71
21
use Getopt::Long;
72
use Getopt::Long;
22
use JSON;
73
use JSON;
74
use Pod::Usage;
23
75
24
use C4::Letters;
76
use C4::Letters;
25
77
26
my ($module, $letter_code, $branchcode, $message_transport_type, $lang, $repeat, $tables, $loops);
78
my $help;
79
my ( $module, $letter_code, $branchcode, $message_transport_type, $lang,
80
    $repeat, $tables, $loops );
27
81
28
GetOptions(
82
GetOptions(
29
    'module=s' => \$module,
83
    'help'                     => \$help,
30
    'letter-code=s' => \$letter_code,
84
    'module=s'                 => \$module,
31
    'branchcode=s' => \$branchcode,
85
    'letter-code=s'            => \$letter_code,
86
    'branchcode=s'             => \$branchcode,
32
    'message-transport-type=s' => \$message_transport_type,
87
    'message-transport-type=s' => \$message_transport_type,
33
    'lang=s' => \$lang,
88
    'lang=s'                   => \$lang,
34
    'repeat=s' => \$repeat,
89
    'repeat=s'                 => \$repeat,
35
    'tables=s' => \$tables,
90
    'tables=s'                 => \$tables,
36
    'loops=s' => \$loops,
91
    'loops=s'                  => \$loops,
37
) or die "Error in command line arguments\n";
92
) or pod2usage( -exitval => 2, -verbose => 1 );
93
94
if ($help) {
95
    pod2usage( -exitval => 0, -verbose => 1 );
96
}
38
97
39
$repeat = $repeat ? decode_json($repeat) : {};
98
$repeat = $repeat ? decode_json($repeat) : {};
40
$tables = $tables ? decode_json($tables) : {};
99
$tables = $tables ? decode_json($tables) : {};
41
$loops = $loops ? decode_json($loops) : {};
100
$loops  = $loops  ? decode_json($loops)  : {};
42
101
43
my $letter = C4::Letters::GetPreparedLetter(
102
my $letter = C4::Letters::GetPreparedLetter(
44
    module => $module,
103
    module                 => $module,
45
    letter_code => $letter_code,
104
    letter_code            => $letter_code,
46
    branchcode => $branchcode,
105
    branchcode             => $branchcode,
47
    message_transport_type => $message_transport_type,
106
    message_transport_type => $message_transport_type,
48
    lang => $lang,
107
    lang                   => $lang,
49
    repeat => $repeat,
108
    repeat                 => $repeat,
50
    tables => $tables,
109
    tables                 => $tables,
51
    loops => $loops,
110
    loops                  => $loops,
52
);
111
);
53
112
54
print "Subject: " . $letter->{title} . "\n\n";
113
print "Subject: " . $letter->{title} . "\n\n";
55
- 

Return to bug 24591