2 ################################################################################
4 # File: $RCSfile: list.cgi,v $
5 # Revision: $Revision: 1.1 $
6 # Description: Manage lists
7 # Author: Andrew@DeFaria.com
8 # Created: Mon Jan 16 20:25:32 PST 2006
9 # Modified: $Date: 2013/06/12 14:05:47 $
12 # (c) Copyright 2000-2006, Andrew@DeFaria.com, all rights reserved.
14 ################################################################################
20 local $0 = $FindBin::Script;
22 use lib $FindBin::Bin;
28 use CGI qw (:standard *table start_div end_div);
29 use CGI::Carp "fatalsToBrowser";
31 my $next = param("next");
32 my $lines = param("lines");
33 my $type = param("type");
34 my $message = param("message");
35 my $Type = ucfirst $type;
40 my $table_name = "list";
45 if (defined $message) {
46 print div {-align => "center"},
47 font {-class => "error"}, $message;
52 -action => "processaction.cgi",
56 # Print some hidden fields to pass along
58 hidden (-name => "type",
60 hidden (-name => "next",
63 my $current = $next + 1;
65 print div {-align => "center"}, b (
66 "(" . $current . "-" . $last . " of " . $total . ")");
67 print start_div {-class => "toolbar",
69 my $prev_button = $prev >= 0 ?
70 a ({-href => "list.cgi?type=$type;next=$prev"},
71 "<img src=/maps/images/previous.gif border=0 alt=Previous align=middle>") : "";
72 my $next_button = ($next + $lines) < $total ?
73 a {-href => "list.cgi?type=$type;next=" . ($next + $lines)},
74 "<img src=/maps/images/next.gif border=0 alt=Next align=middle>" : "";
76 submit ({-name => "action",
77 -value => "Add New Entry",
78 -onClick => "return NoneChecked (document.list);"}),
79 submit ({-name => "action",
80 -value => "Delete Marked",
81 -onClick => "return CheckAtLeast1Checked (document.list) && AreYouSure ('Are you sure you want to delete these entries?');"}),
82 submit ({-name => "action",
83 -value => "Modify Marked",
84 -onClick => "return CheckAtLeast1Checked (document.list);"}),
85 submit ({-name => "action",
86 -value => "Reset Marks",
87 -onClick => "return ClearAll (document.list);"}),
90 print start_table {-align => "center",
97 th {-class => "tableleftend"}, "Seq",
98 th {-class => "tableheader"}, "Mark",
99 th {-class => "tableheader"}, "Username",
100 th {-class => "tableheader"}, "@",
101 th {-class => "tableheader"}, "Domain",
102 th {-class => "tablerightend"}, "Comments"
105 my @list = ReturnList $type, $next, $lines;
111 $record{pattern} = " " if !defined $record{pattern};
112 $record{domain} = " " if !defined $record{domain};
113 $record{comment} = " " if !defined $record{comment};
115 my $leftclass = ($i eq $lines || $record{sequence} eq $total) ?
116 "tablebottomleft" : "tableleftdata";
117 my $dataclass = ($i eq $lines || $record{sequence} eq $total) ?
118 "tablebottomdata" : "tabledata";
119 my $rightclass = ($i eq $lines || $record{sequence} eq $total) ?
120 "tablebottomright" : "tablerightdata";
124 td {-class => $leftclass,
125 -align => "center"}, $record{sequence},
126 td {-class => $dataclass,
128 checkbox ({-name => "action$record{sequence}",
130 td {-class => $dataclass,
131 -align => "right"}, $record{pattern},
132 td {-class => $dataclass,
133 -align => "center"}, "\@",
134 td {-class => $dataclass,
135 -align => "left"}, $record{domain},
136 td {-class => $rightclass,
137 -align => "left"}, $record{comment}
143 print div ({-align => "center"},
144 a ({-href => "/maps/bin/exportlist.cgi?type=$type"},
145 submit ({-name => "export",
146 -value => "Export List"})),
147 a ({-href => "/maps/bin/importlist.cgi?type=$type"},
148 submit ({-name => "import",
149 -value => "Import List"})));
155 my @scripts = ("ListActions.js");
168 NavigationBar $userid;
170 if (!defined $lines) {
171 my %options = GetUserOptions $userid;
172 $lines = $options{"Page"};
175 $total = MAPSDB::count "list", "userid = \"$userid\" and type = \"$type\"";;
177 $next = !defined $next ? 0 : $next;
178 $last = $next + $lines < $total ? $next + $lines : $total;
180 if (($next - $lines) > 0) {
181 $prev = $next - $lines;
183 $prev = $next == 0 ? -1 : 0;