% my @types = qsearch( 'reason_type', { 'class' => $class } );
% if (scalar(@types) < 1) { # we should never reach this
No reason types. Go add some.
|
% }elsif (scalar(@types) == 1) {
Reason Type
|
<% $types[0]->type %>
|
% }else{
Reason Type
|
|
% }
New Reason
|
" style="display:<% $display %>"> |
<%init>
my %opt = @_;
my $name = $opt{'field'};
my $class = $opt{'reason_class'};
my $init_reason = $opt{'curr_value'};
my $controlledbutton = $opt{'control_button'};
( my $func_suffix = $name ) =~ s/\./_/g;
my $id = $opt{'id'} || $func_suffix;
my( $add_access_right, $access_right );
if ($class eq 'C') {
$access_right = 'Cancel customer';
$add_access_right = 'Add on-the-fly cancel reason';
} elsif ($class eq 'S') {
$access_right = 'Suspend customer package';
$add_access_right = 'Add on-the-fly suspend reason';
} elsif ($class eq 'R') {
$access_right = 'Post credit';
$add_access_right = 'Add on-the-fly credit reason';
} else {
die "illegal class: $class";
}
my( $display, $disabled ) = ( 'none', 'DISABLED' );
my( $init_type, $init_newreason ) = ( '', '' );
if ($init_reason == -1 || ref($init_reason) ) {
$display = 'inline';
$disabled = '';
if ( ref($init_reason) ) {
$init_type = $init_reason->{'typenum'};
$init_newreason = $init_reason->{'reason'};
$init_reason = -1;
}
}
my $extra_sql =
"WHERE class = '$class' and (disabled = '' OR disabled is NULL)";
my @reasons = qsearch({
table => 'reason',
hashref => {},
extra_sql => $extra_sql,
addl_from => 'LEFT JOIN reason_type '.
' ON reason_type.typenum = reason.reason_type',
order_by => 'ORDER BY reason_type.type ASC, reason.reason ASC',
});
my $curuser = $FS::CurrentUser::CurrentUser;
%init>