1 <% include( 'elements/browse.html',
2 'title' => ucfirst($classname) . ' Reasons',
3 'menubar' => [ ucfirst($classname).' Reason Types' =>
4 $p."browse/reason_type.html?class=$class"
6 'html_init' => $html_init,
7 'name' => $classname . ' reasons',
9 'disabled_statuspos' => 3,
10 'query' => { 'table' => 'reason',
12 'extra_sql' => $where_clause.
13 ' ORDER BY reason_type',
14 'addl_from' => 'LEFT JOIN reason_type ON reason_type.typenum = reason.reason_type',
16 'count_query' => $count_query,
21 'html_form' => qq!<FORM ACTION="${p}misc/reason_merge.html" METHOD="POST">!,
22 'html_foot' => $html_foot,
28 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
30 $cgi->param('class') =~ /^(\w)$/ or die "illegal class";
33 my $classname = $FS::reason_type::class_name{$class};
34 my $classpurpose = $FS::reason_type::class_purpose{$class};
36 my $html_init = include('/elements/init_overlib.html').
37 ucfirst($classname). " reasons $classpurpose.<BR><BR>".
38 qq!<A HREF="${p}edit/reason.html?class=$class">!.
39 "<I>Add a $classname reason</I></A><BR><BR>";
41 my $where_clause = " WHERE class='$class' ";
43 my $count_query = 'SELECT COUNT(*) FROM reason LEFT JOIN reason_type on ' .
44 'reason_type.typenum = reason.reason_type ' . $where_clause;
46 my $link = [ $p."edit/reason.html?class=$class&reasonnum=", 'reasonnum' ];
50 ucfirst($classname) . ' reason type',
51 ucfirst($classname) . ' reason',
56 sub { shift->reasontype->type },
68 if ( $class eq 'S' or $class eq 'C' ) {
69 push @header, 'Credit unused service';
73 if ( $reason->unused_credit ) {
74 return '<SPAN STYLE="background-color:#00ff00">YES</SPAN>';
76 return '<SPAN STYLE="background-color:#ff0000">NO</SPAN>';
81 if ( $class eq 'S' ) {
82 push @header, 'Suspension fee';
86 my $feepart = $reason->feepart;
87 my ($href, $text, $detail);
89 my $part_fee = FS::part_fee->by_key($feepart) or return '';
90 $text = $part_fee->itemdesc . ': ' . $part_fee->explanation;
91 $detail = $reason->fee_on_unsuspend ? 'unsuspension' : 'suspension';
92 if ( $reason->fee_hold ) {
93 $detail = "next bill after $detail";
95 $detail = "(on $detail)";
96 $href = $p."edit/part_fee.html?$feepart";
98 my $pkgpart = $reason->unsuspend_pkgpart;
99 my $part_pkg = FS::part_pkg->by_key($pkgpart) or return '';
100 $text = $part_pkg->pkg_comment;
101 $href = $p."edit/part_pkg.cgi?$pkgpart";
102 $detail = $reason->unsuspend_hold ?
103 '(on next bill after unsuspension)' : '(on unsuspension)';
105 return '' unless length($text);
107 $text = qq!<A HREF="$href">! . encode_entities($text) . "</A> ".
108 "<FONT SIZE=-1>$detail</FONT>";
115 # reason merge handling
119 my $reasonnum = $reason->reasonnum;
120 qq!<INPUT TYPE="checkbox" NAME="reasonnum" VALUE="$reasonnum">!;
124 my $html_foot = include('/search/elements/checkbox-foot.html',
125 onclick => include( '/elements/popup_link_onclick.html',
126 js_action => q!'! . "${p}misc/reason-merge.html?" . q!' + toCGIString()!,
127 actionlabel => 'Merge reasons',
129 label => 'merge selected reasons',