return { map { $_->[0] => 1 } @{$codes} };
}
-our $input = new CGI;
+our $input = CGI->new;
my $searchfield = $input->param('searchfield');
my $script_name = '/cgi-bin/koha/tools/letter.pl';
our $branchcode = $input->param('branchcode');
my $module = $input->param('module') || '';
my $content = $input->param('content');
my $op = $input->param('op') || '';
-my $redirect = $input->param('redirect');
+my $redirect = $input->param('redirect');
+my $section = $input->param('section');
+
my $dbh = C4::Context->dbh;
our ( $template, $borrowernumber, $cookie, $staffflags ) = get_template_and_user(
template_name => 'tools/letter.tt',
query => $input,
type => 'intranet',
- authnotrequired => 0,
flagsrequired => { tools => 'edit_notices' },
debug => 1,
}
script_name => $script_name,
searchfield => $searchfield,
branchcode => $branchcode,
+ section => $section,
action => $script_name
);
if ( $op eq 'add_validate' or $op eq 'copy_validate' ) {
add_validate();
if( $redirect eq "just_save" ){
- print $input->redirect("/cgi-bin/koha/tools/letter.pl?op=add_form&branchcode=$branchcode&module=$module&code=$code&redirect=done");
+ print $input->redirect("/cgi-bin/koha/tools/letter.pl?op=add_form&branchcode=$branchcode&module=$module&code=$code&redirect=done§ion=$section");
exit;
} else {
$op = q{}; # we return to the default screen for the next operation
code => $code,
);
my $first_flag_name = 1;
- my ( $lang, @templates );
+ my $lang;
# The letter name is contained into each mtt row.
# So we can only sent the first one to the template.
for my $letter ( @$letters ) {
$letters{ $lang }{templates}{$mtt} = {
message_transport_type => $letter->{message_transport_type},
is_html => $letter->{is_html},
+ updated_on => $letter->{updated_on},
title => $letter->{title},
content => $letter->{content} // '',
};
push @{$field_selection}, add_fields('aqbooksellers', 'aqbasket', 'aqorders', 'biblio', 'biblioitems');
}
elsif ($module eq 'claimissues') {
- push @{$field_selection}, add_fields('aqbooksellers', 'serial', 'subscription');
- push @{$field_selection},
- {
- value => q{},
- text => '---BIBLIO---'
- };
- foreach(qw(title author serial)) {
- push @{$field_selection}, {value => "biblio.$_", text => ucfirst $_ };
- }
+ push @{$field_selection}, add_fields('aqbooksellers', 'serial', 'subscription', 'biblio', 'biblioitems');
}
elsif ($module eq 'serial') {
push @{$field_selection}, add_fields('branches', 'biblio', 'biblioitems', 'borrowers', 'subscription', 'serial');
push @{$field_selection}, add_fields('issues');
}
- if ( $module eq 'circulation' and $code =~ /^AR_/ ) {
+ if ( $module eq 'circulation' and $code and $code =~ /^AR_/ ) {
push @{$field_selection}, add_fields('article_requests');
}
+
+ if ( $module eq 'members' and $code and $code eq 'PROBLEM_REPORT' ) {
+ push @{$field_selection}, add_fields('problem_reports');
+ }
+
+ if ( $module eq 'ill' ) {
+ push @{$field_selection}, add_fields('illrequests');
+ }
+ }
+
+ my $preview_is_available = 0;
+
+ if ($code) {
+ $preview_is_available = grep {$_ eq $code } qw( CHECKIN CHECKOUT HOLD_SLIP );
}
- my $preview_is_available = grep {/^$code$/} qw(
- CHECKIN CHECKOUT HOLD_SLIP
- );
$template->param(
module => $module,
SQLfieldnames => $field_selection,
my @content = $input->multi_param('content');
my @lang = $input->multi_param('lang');
for my $mtt ( @mtt ) {
- my $is_html = $input->param("is_html_$mtt");
+ my $lang = shift @lang;
+ my $is_html = $input->param("is_html_$mtt\_$lang");
my $title = shift @title;
my $content = shift @content;
- my $lang = shift @lang;
my $letter = C4::Letters::getletter( $oldmodule, $code, $branchcode, $mtt, $lang );
# getletter can return the default letter even if we pass a branchcode
my $dbh = C4::Context->dbh;
my ($sql, @where, @args);
- $sql = "SELECT branchcode, module, code, name, branchname
+ $sql = "SELECT branchcode, module, code, name, branchname, MAX(updated_on) as updated_on
FROM letter
LEFT OUTER JOIN branches USING (branchcode)
";
}
$sql .= " WHERE ".join(" AND ", @where) if @where;
- $sql .= " GROUP BY branchcode,module,code";
+ $sql .= " GROUP BY branchcode,module,code,name,branchname";
+
$sql .= " ORDER BY module, code, branchcode";
return $dbh->selectall_arrayref($sql, { Slice => {} }, @args);