Bug 26988: Adjust for bug 26963
[koha.git] / admin / columns_settings.pl
blob9d19808eafd8842154c30ea6565467c67b9c6aad
1 #!/usr/bin/perl
3 use Modern::Perl;
4 use CGI;
5 use YAML qw( LoadFile );
6 use C4::Auth;
7 use C4::Context;
8 use C4::Output;
9 use C4::Utils::DataTables::TablesSettings qw( get_modules );
10 my $input = CGI->new;
12 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
14 template_name => "admin/columns_settings.tt",
15 query => $input,
16 type => "intranet",
17 flagsrequired => { parameters => 'manage_column_config' },
18 debug => 1,
22 my $action = $input->param('action') // 'list';
24 if ( $action eq 'save' ) {
25 my $module = $input->param('module');
26 my @columnids = $input->multi_param("columnid");
27 my @columns;
28 for my $columnid (@columnids) {
29 next unless $columnid =~ m|^([^#]*)#([^#]*)#(.*)$|;
30 my $is_hidden = $input->param( $columnid . '_hidden' ) // 0;
31 my $cannot_be_toggled =
32 $input->param( $columnid . '_cannot_be_toggled' ) // 0;
33 push @columns,
35 module => $module,
36 page => $1,
37 tablename => $2,
38 columnname => $3,
39 is_hidden => $is_hidden,
40 cannot_be_toggled => $cannot_be_toggled,
44 C4::Utils::DataTables::TablesSettings::update_columns(
46 columns => \@columns,
50 my @table_ids = $input->multi_param('table_id');
51 for my $table_id (@table_ids) {
52 next unless $table_id =~ m|^([^#]*)#(.*)$|;
53 my $default_display_length = $input->param( $table_id . '_default_display_length' );
54 my $default_sort_order = $input->param( $table_id . '_default_sort_order' );
55 if ( defined $default_display_length && $default_display_length ne ""
56 && defined $default_sort_order && $default_sort_order ne "" ) {
57 C4::Utils::DataTables::TablesSettings::update_table_settings(
59 module => $module,
60 page => $1,
61 tablename => $2,
62 default_display_length => $default_display_length,
63 default_sort_order => $default_sort_order,
69 $action = 'list';
72 if ( $action eq 'list' ) {
73 my $modules = C4::Utils::DataTables::TablesSettings::get_modules;
74 $template->param(
75 panel => ( $input->param('panel') || 0 ),
76 modules => $modules,
80 output_html_with_http_headers $input, $cookie, $template->output;