Project

General

Profile

Download (2.09 KB) Statistics
| Branch: | Revision:
1
#!/usr/bin/perl
2
# list_periods.cgi
3
# Display a list of all defined periods
4

    
5
require './mon-lib.pl';
6
&ui_print_header(undef, $text{'periods_title'}, "");
7

    
8
$conf = &get_mon_config();
9
@periods = &find("period", $conf);
10

    
11
print "<form action=save_periods.cgi method=post>\n";
12
print "<table border width=100%>\n";
13
print "<tr $tb> <td><b>$text{'periods_period'}</b></td> ",
14
      "<td><b>$text{'periods_times'}</b></td> </tr>\n";
15
$i = 0;
16
foreach $p (@periods, { }) {
17
	local ($name, $value, $dfrom, $dto, $hfrom, $hto, $known);
18
	if ($p->{'value'} =~ /^\s*(\S+):\s*wd\s+{(\S+)-(\S+)}\s+hr\s+{(\S+)-(\S+)}\s*$/){
19
		$name = $1;
20
		$dfrom = $2; $dto = $3; $hfrom = $4; $hto = $5;
21
		$known++;
22
		}
23
	elsif ($p->{'value'} =~ /^\s*(\S+):\s*wd\s+{(\S+)-(\S+)}\s*$/) {
24
		$name = $1;
25
		$dfrom = $2; $dto = $3;
26
		$known++;
27
		}
28
	elsif ($p->{'value'} =~ /^\s*(\S+):\s*hr\s+{(\S+)-(\S+)}\s*$/) {
29
		$name = $1;
30
		$hfrom = $2; $hto = $3;
31
		$known++;
32
		}
33
	elsif ($p->{'value'} =~ /^\s*(\S+):\s*(.*)$/) {
34
		$name = $1;
35
		$value = $2;
36
		}
37
	elsif (!$p->{'value'}) {
38
		$known++;
39
		}
40
	print "<tr $cb>\n";
41
	print "<td><input name=name_$i size=20 value='$name'></td>\n";
42
	print "<td>\n";
43
	if ($known || !$p->{'name'}) {
44
		# Show friendly period inputs
45
		printf "<input type=radio name=days_def_$i value=1 %s> %s\n",
46
			$dfrom ? "" : "checked", $text{'periods_alldays'};
47
		printf "<input type=radio name=days_def_$i value=0 %s>\n",
48
			$dfrom ? "checked" : "";
49
		print &day_input("dfrom_$i", $dfrom)," - ",
50
		      &day_input("dto_$i", $dto);
51

    
52
		print "&nbsp;&nbsp;&nbsp;\n";
53

    
54
		printf "<input type=radio name=hours_def_$i value=1 %s> %s\n",
55
			$hfrom ? "" : "checked", $text{'periods_allhours'};
56
		printf "<input type=radio name=hours_def_$i value=0 %s>\n",
57
			$hfrom ? "checked" : "";
58
		print "<input name=hfrom_$i size=4 value='$hfrom'> - ",
59
		      "<input name=hto_$i size=4 value='$hto'></td> </tr>\n";
60
		}
61
	else {
62
		# Allow any Time::Period string
63
		print "<input name=value_$i size=50 value='$value'>\n";
64
		}
65
	print "</td> </tr>\n";
66
	$i++;
67
	}
68
print "</table>\n";
69
print "<input type=submit value='$text{'save'}'></form>\n";
70

    
71
&ui_print_footer("", $text{'index_return'});
72

    
(26-26/46)