fix several UI nits in FCC 477 report configuration, #24047
[freeside.git] / httemplate / browse / reason.html
1 <% include( 'elements/browse.html',
2                  'title'       => ucfirst($classname) . ' Reasons',
3                  'menubar'     => [ ucfirst($classname).' Reason Types' =>
4                                       $p."browse/reason_type.html?class=$class"
5                                   ],
6                  'html_init'   => $html_init,
7                  'name'        => $classname . ' reasons',
8                  'disableable' => 1,
9                  'disabled_statuspos' => 3,
10                  'query'       => { 'table'     => 'reason',
11                                     'hashref'   => {},
12                                     'extra_sql' => $where_clause. 
13                                                    ' ORDER BY reason_type', 
14                                     'addl_from' => 'LEFT JOIN reason_type ON reason_type.typenum = reason.reason_type', 
15                                   },
16                  'count_query' => $count_query,
17                  'header'      => [ '#',
18                                     ucfirst($classname) . ' Reason Type',
19                                     ucfirst($classname) . ' Reason',
20                                     ($class eq 'S' ?  'Unsuspension Fee' : ()),
21                                   ],
22                  'fields'      => [ 'reasonnum',
23                                     sub { shift->reasontype->type },
24                                     'reason',
25                                     $unsuspend_pkg_comment,
26                                   ],
27                  'links'       => [ $link,
28                                     $link,
29                                     '',
30                                     $unsuspend_pkg_link,
31                                   ],
32              )
33 %>
34 <%init>
35
36 die "access denied"
37   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
38
39 $cgi->param('class') =~ /^(\w)$/ or die "illegal class";
40 my $class = $1;
41
42 my $classname = $FS::reason_type::class_name{$class};
43 my $classpurpose = $FS::reason_type::class_purpose{$class};
44
45 my $html_init = ucfirst($classname).  " reasons $classpurpose.<BR><BR>".
46 qq!<A HREF="${p}edit/reason.html?class=$class">!.
47 "<I>Add a $classname reason</I></A><BR><BR>";
48
49 my $where_clause = " WHERE class='$class' ";
50
51 my $count_query = 'SELECT COUNT(*) FROM reason LEFT JOIN reason_type on ' .
52                 'reason_type.typenum = reason.reason_type ' . $where_clause;
53
54 my $link = [ $p."edit/reason.html?class=$class&reasonnum=", 'reasonnum' ];
55
56 my ($unsuspend_pkg_comment, $unsuspend_pkg_link);
57 if ( $class eq 'S' ) {
58   $unsuspend_pkg_comment = sub {
59     my $pkgpart = shift->unsuspend_pkgpart or return '';
60     my $part_pkg = FS::part_pkg->by_key($pkgpart) or return '';
61     $part_pkg->pkg_comment;
62   };
63
64   my $unsuspend_pkg_link = sub {
65     my $pkgpart = shift->unsuspend_pkgpart or return '';
66     [ $p."edit/part_pkg.cgi?", $pkgpart ];
67   };
68 }
69
70 </%init>