This commit was manufactured by cvs2svn to create tag 'freeside_2_1_1'.
[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                                   ],
21                  'fields'      => [ 'reasonnum',
22                                     sub { shift->reasontype->type },
23                                     'reason',
24                                   ],
25                  'links'       => [ $link,
26                                     $link,
27                                     '',
28                                   ],
29              )
30 %>
31 <%init>
32
33 die "access denied"
34   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
35
36 $cgi->param('class') =~ /^(\w)$/ or die "illegal class";
37 my $class = $1;
38
39 my $classname = $FS::reason_type::class_name{$class};
40 my $classpurpose = $FS::reason_type::class_purpose{$class};
41
42 my $html_init = ucfirst($classname).  " reasons $classpurpose.<BR><BR>".
43 qq!<A HREF="${p}edit/reason.html?class=$class">!.
44 "<I>Add a $classname reason</I></A><BR><BR>";
45
46 my $where_clause = " WHERE class='$class' ";
47
48 my $count_query = 'SELECT COUNT(*) FROM reason LEFT JOIN reason_type on ' .
49                 'reason_type.typenum = reason.reason_type ' . $where_clause;
50
51 my $link = [ $p."edit/reason.html?class=$class&reasonnum=", 'reasonnum' ];
52
53 </%init>