1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
<& elements/browse.html,
'title' => ucwords($classname) . " Reasons",
'html_init' => $html_init,
'name' => $classname . " reason types",
'query' => { 'table' => 'reason_type',
'hashref' => {},
'extra_sql' => $where_clause .
'ORDER BY typenum',
},
'count_query' => $count_query,
'header' => [ '#',
ucwords($classname) . ' Reason Type',
ucwords($classname) . ' Reasons',
],
'fields' => [ 'typenum',
'type',
$reasons_sub,
],
'links' => [ $link,
$link,
'',
],
'disable_total' => 1,
'html_form' => qq!<FORM ACTION="${p}misc/reason_merge.html" METHOD="POST">!,
'html_foot' => $html_foot,
&>
<%init>
sub ucwords {
join(' ', map ucfirst($_), split(/ /, shift));
}
die "access denied"
unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
$cgi->param('class') =~ /^(\w)$/ or die "illegal class";
my $class=$1;
my $classname = ucfirst($FS::reason_type::class_name{$class});
my $html_init = 'Reasons: ' .
include('/elements/menubar.html',
map {
ucfirst($FS::reason_type::class_name{$_}),
$p.'browse/reason_type.html?class=' . $_
} keys (%FS::reason_type::class_name)
);
$html_init .= include('/elements/init_overlib.html').
'<BR><P>' .
$classname . ' reasons ' .
$FS::reason_type::class_purpose{$class} .
'. Reason types allow reasons to be grouped for reporting purposes.' .
qq!<BR><BR><A HREF="${p}edit/reason_type.html?class=$class"><I>! .
($classname =~ /^[aeiou]/i ? 'Add an ' : 'Add a ') .
lc($classname) . ' reason type</I></A>'.
'</P>';
my $reasons_sub = sub {
my $reason_type = shift;
[ ( map {
[
{
'data' => $_->reason,
'align' => 'left',
'link' => $p. "edit/reason.html?class=$class&reasonnum=".
$_->reasonnum,
},
{
'data' => q!<INPUT TYPE="checkbox" NAME="reasonnum" VALUE="! . $_->reasonnum . q!">!,
'align' => 'right',
},
];
}
$reason_type->enabled_reasons ),
[
{
'data' => '(add)',
'align' => 'left',
'link' => $p. "edit/reason.html?class=$class",
'data_style' => 'i',
},
{ 'data' => '' },
]
];
};
my $where_clause = "WHERE class='$class'";
my $count_query = 'SELECT COUNT(*) FROM reason_type ';
$count_query .= $where_clause;
my $link = [ $p.'edit/reason_type.html?class='.$class.'&typenum=', 'typenum' ];
my $html_foot = include('/search/elements/checkbox-foot.html',
onclick => include( '/elements/popup_link_onclick.html',
js_action => q!'! . "${p}misc/reason-merge.html?" . q!' + toCGIString()!,
actionlabel => 'Merge reasons',
),
label => 'merge selected reasons',
minboxes => 2,
) . '</FORM>';
</%init>
|