1#!/usr/local/bin/perl
2# Show one scheduled backup
3
4use strict;
5use warnings;
6require './backup-config-lib.pl';
7our (%in, %text);
8&ReadParse();
9
10my $backup;
11if ($in{'new'}) {
12	&ui_print_header(undef, $text{'edit_title1'}, "");
13	$backup = { 'emode' => 0,
14		    'sched' => 1,
15		    'mins' => 0,
16		    'hours' => 0,
17		    'days' => '*',
18		    'months' => '*',
19		    'weekdays' => '*' };
20	}
21else {
22	&ui_print_header(undef, $text{'edit_title2'}, "");
23	$backup = &get_backup($in{'id'});
24	}
25
26print &ui_form_start("save.cgi", "post");
27print &ui_hidden("new", $in{'new'});
28print &ui_hidden("id", $in{'id'});
29
30my @tds = ( "width=20% nowrap" );
31print &ui_hidden_table_start($text{'edit_header'}, "width=100%", 2,
32			     "main", 1, \@tds);
33
34# Show modules to backup
35my @mods = &list_backup_modules();
36my @dmods = split(/\s+/, $backup->{'mods'});
37print &ui_table_row($text{'edit_mods'},
38		    &ui_select("mods", \@dmods,
39		       [ map { [ $_->{'dir'}, $_->{'desc'} ] } @mods ],
40		       10, 1));
41
42# Show destination
43print &ui_table_row($text{'edit_dest'},
44		    &show_backup_destination("dest", $backup->{'dest'}, 0));
45
46# Show files to include
47print &ui_table_row($text{'edit_what'},
48		    &show_backup_what("what", $backup->{'configfile'},
49					      $backup->{'nofiles'},
50					      $backup->{'others'}));
51
52print &ui_hidden_table_end();
53
54print &ui_hidden_table_start($text{'edit_header2'}, "width=100%", 2,
55			     "prepost", 0, \@tds);
56
57# Show pre-backup command
58print &ui_table_row($text{'edit_pre'},
59		    &ui_textbox("pre", $backup->{'pre'}, 60));
60
61# Show post-backup command
62print &ui_table_row($text{'edit_post'},
63		    &ui_textbox("post", $backup->{'post'}, 60));
64
65print &ui_hidden_table_end();
66
67print &ui_hidden_table_start($text{'edit_header3'}, "width=100%", 2,
68			     "sched", 0, \@tds);
69
70# Show email address
71print &ui_table_row($text{'edit_email'},
72		    &ui_textbox("email", $backup->{'email'}, 40));
73
74# Show email mode
75print &ui_table_row($text{'edit_emode'},
76		    &ui_radio("emode", $backup->{'emode'},
77			      [ [ 0, $text{'edit_emode0'} ],
78				[ 1, $text{'edit_emode1'} ] ]));
79
80# Show schedule
81my $job;
82if ($backup) {
83	$job = &find_cron_job($backup);
84	}
85print &ui_table_row($text{'edit_sched'},
86		    &ui_radio("sched", $job || $in{'new'} ? 1 : 0,
87			      [ [ 0, $text{'no'} ],
88				[ 1, $text{'edit_schedyes'} ] ]));
89print &cron::get_times_input($backup);
90
91print &ui_hidden_table_end();
92if ($in{'new'}) {
93	print &ui_form_end([ [ 'create', $text{'create'} ] ], "100%");
94	}
95else {
96	print &ui_form_end([ [ 'save', $text{'save'} ],
97			     [ 'run', $text{'edit_run'} ],
98			     [ 'delete', $text{'delete'} ] ], "100%");
99	}
100
101&ui_print_footer("", $text{'index_return'});
102
103
104