3 # Display a list of all defined periods
5 require './mon-lib.pl';
6 &ui_print_header(undef, $text{'periods_title'}, "");
8 $conf = &get_mon_config();
9 @periods = &find("period", $conf);
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";
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*$/){
20 $dfrom = $2; $dto = $3; $hfrom = $4; $hto = $5;
23 elsif ($p->{'value'} =~ /^\s*(\S+):\s*wd\s+{(\S+)-(\S+)}\s*$/) {
25 $dfrom = $2; $dto = $3;
28 elsif ($p->{'value'} =~ /^\s*(\S+):\s*hr\s+{(\S+)-(\S+)}\s*$/) {
30 $hfrom = $2; $hto = $3;
33 elsif ($p->{'value'} =~ /^\s*(\S+):\s*(.*)$/) {
37 elsif (!$p->{'value'}) {
41 print "<td><input name=name_$i size=20 value='$name'></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);
52 print " \n";
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";
62 # Allow any Time::Period string
63 print "<input name=value_$i size=50 value='$value'>\n";
65 print "</td> </tr>\n";
69 print "<input type=submit value='$text{'save'}'></form>\n";
71 &ui_print_footer("", $text{'index_return'});