2 # Show a popup window for selecting a Bacula schedule
4 $trust_unknown_referers = 1;
5 require './bacula-backup-lib.pl';
7 &popup_header($text{'chooser_title'});
9 # Parse into month, day and hour parts
10 if ($in{'schedule'}) {
11 $sched = &parse_schedule($in{'schedule'});
14 $sched = { 'months_all' => 1,
16 'weekdaynums_all' => 1,
22 ref($sched) || &error($sched);
23 print &ui_form_start("schedule_select.cgi", "post");
24 @tds = ( "width=30%", "width=70%" );
27 @months = map { [ $_-1, $text{'month_'.$_} ] } (1 .. 12);
28 print &ui_table_start($text{'chooser_monthsh'}, "width=100%", 2);
29 print &ui_table_row($text{'chooser_months'},
30 &ui_radio("months_all", $sched->{'months_all'} ? 1 : 0,
31 [ [ 1, $text{'chooser_all'} ],
32 [ 0, $text{'chooser_sel'} ] ])."<br>".
33 &select_chooser("months", \@months, $sched->{'months'}),
35 print &ui_table_end();
37 # Show days of month section
38 @days = map { [ $_, $_ ] } (1 .. 31);
39 print &ui_table_start($text{'chooser_daysh'}, "width=100%", 2);
40 print &ui_table_row($text{'chooser_days'},
41 &ui_radio("days_all", $sched->{'days_all'} ? 1 : 0,
42 [ [ 1, $text{'chooser_all'} ],
43 [ 0, $text{'chooser_sel'} ] ])."<br>".
44 &select_chooser("days", \@days, $sched->{'days'}, 8),
46 print &ui_table_end();
48 # Show days of week section
49 @weekdays = map { [ $_, $text{'day_'.$_} ] } (0 .. 6);
50 @weekdaynums = map { [ $_, $text{'weekdaynum_'.$_} ] } (1 .. 5);
51 print &ui_table_start($text{'chooser_weekdaysh'}, "width=100%", 2);
52 print &ui_table_row($text{'chooser_weekdays'},
53 &ui_radio("weekdays_all", $sched->{'weekdays_all'} ? 1 : 0,
54 [ [ 1, $text{'chooser_all'} ],
55 [ 0, $text{'chooser_sel'} ] ])."<br>".
56 &select_chooser("weekdays", \@weekdays, $sched->{'weekdays'}),
58 print &ui_table_row($text{'chooser_weekdaynums'},
59 &ui_radio("weekdaynums_all", $sched->{'weekdaynums_all'} ? 1 : 0,
60 [ [ 1, $text{'chooser_all'} ],
61 [ 0, $text{'chooser_sel'} ] ])."<br>".
62 &select_chooser("weekdaynums", \@weekdaynums,$sched->{'weekdaynums'},5),
64 print &ui_table_end();
67 print &ui_table_start($text{'chooser_timeh'}, "width=100%", 2);
68 print &ui_table_row($text{'chooser_time'},
69 &ui_textbox("hour", $sched->{'hour'}, 3).":".
70 &ui_textbox("minute", $sched->{'minute'}, 3),
72 print &ui_table_end();
74 print &ui_form_end([ [ "ok", $text{'chooser_ok'} ] ]);
78 # select_chooser(name, &opts, &selected, [cols])
81 local ($name, $opts, $sel, $cols) = @_;
83 local %sel = map { $_, 1 } @$sel;
84 local $rv = "<table>\n";
85 for(my $i=0; $i<@$opts; $i++) {
86 $rv .= "<tr>\n" if ($i%$cols == 0);
87 $rv .= "<td>".&ui_checkbox($name, $opts->[$i]->[0], $opts->[$i]->[1],
88 $sel{$opts->[$i]->[0]})."</td>\n";
89 $rv .= "</tr>\n" if ($i%$cols == $cols-1);