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",
72 }, "<img src=/maps/images/previous.gif border=0 alt=Previous align=middle>") : "";
73 my $next_button = ($next + $lines) < $total ?
74 a {-href => "list.cgi?type=$type;next=" . ($next + $lines),
76 }, "<img src=/maps/images/next.gif border=0 alt=Next align=middle>" : "";
78 submit ({-name => "action",
79 -value => "Add New Entry",
80 -onClick => "return NoneChecked (document.list);"}),
81 submit ({-name => "action",
82 -value => "Delete Marked",
83 -onClick => "return CheckAtLeast1Checked (document.list) && AreYouSure ('Are you sure you want to delete these entries?');"}),
84 submit ({-name => "action",
85 -value => "Modify Marked",
86 -onClick => "return CheckAtLeast1Checked (document.list);"}),
87 submit ({-name => "action",
88 -value => "Reset Marks",
89 -onClick => "return ClearAll (document.list);"}),
92 print start_table {-align => "center",
99 th {-class => "tableleftend"}, "Seq",
100 th {-class => "tableheader"}, "Mark",
101 th {-class => "tableheader"}, "Username",
102 th {-class => "tableheader"}, "@",
103 th {-class => "tableheader"}, "Domain",
104 th {-class => "tablerightend"}, "Comments"
107 my @list = ReturnList $type, $next, $lines;
113 $record{pattern} = " " if !defined $record{pattern};
114 $record{domain} = " " if !defined $record{domain};
115 $record{comment} = " " if !defined $record{comment};
117 my $leftclass = ($i eq $lines || $record{sequence} eq $total) ?
118 "tablebottomleft" : "tableleftdata";
119 my $dataclass = ($i eq $lines || $record{sequence} eq $total) ?
120 "tablebottomdata" : "tabledata";
121 my $rightclass = ($i eq $lines || $record{sequence} eq $total) ?
122 "tablebottomright" : "tablerightdata";
126 td {-class => $leftclass,
127 -align => "center"}, $record{sequence},
128 td {-class => $dataclass,
130 checkbox ({-name => "action$record{sequence}",
132 td {-class => $dataclass,
133 -align => "right"}, $record{pattern},
134 td {-class => $dataclass,
135 -align => "center"}, "\@",
136 td {-class => $dataclass,
137 -align => "left"}, $record{domain},
138 td {-class => $rightclass,
139 -align => "left"}, $record{comment}
145 print div ({-align => "center"},
146 a ({-href => "/maps/bin/exportlist.cgi?type=$type"},
147 submit ({-name => "export",
148 -value => "Export List"})),
149 a ({-href => "/maps/bin/importlist.cgi?type=$type"},
150 submit ({-name => "import",
151 -value => "Import List"})));
157 my @scripts = ("ListActions.js");
170 NavigationBar $userid;
172 if (!defined $lines) {
173 my %options = GetUserOptions $userid;
174 $lines = $options{"Page"};
177 $total = MAPSDB::count "list", "userid = \"$userid\" and type = \"$type\"";;
179 $next = !defined $next ? 0 : $next;
180 $last = $next + $lines < $total ? $next + $lines : $total;
182 if (($next - $lines) > 0) {
183 $prev = $next - $lines;
185 $prev = $next == 0 ? -1 : 0;