X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Felements%2Ftr-select-reason.html;h=52dc956d528eb803d1cdc7520fdebd4475153bc0;hb=715120170b58861d2957266a2802df2e412979c8;hp=9b402b0eb5cd090aa1b3e3cfe94afd7a1cd5a8d0;hpb=be2bcc10c35d7762178b245cd38382047a7e270d;p=freeside.git diff --git a/httemplate/elements/tr-select-reason.html b/httemplate/elements/tr-select-reason.html index 9b402b0eb..52dc956d5 100755 --- a/httemplate/elements/tr-select-reason.html +++ b/httemplate/elements/tr-select-reason.html @@ -70,11 +70,10 @@ Example: 'id' => $id, 'table' => 'reason', 'records' => \@reasons, - 'label_callback' => sub { my $reason = shift; - $reason->type . ' : ' . $reason->reason }, + 'name_col' => 'label', 'disable_empty' => 1, 'pre_options' => [ 0 => 'Select reason...' ], - 'post_options' => [ -1 => 'Add new reason' ], + 'post_options' => \@post_options, 'curr_value' => $init_reason, 'onchange' => $id.'_changed()', &> @@ -82,6 +81,7 @@ Example: % # "add new reason" fields % # should be a
, but that doesn't fit well into the table +% if ( $curuser->access_right($add_access_right) ) { @@ -91,21 +91,21 @@ Example: field => $id.'_new_reason' &> -% my @types = qsearch( 'reason_type', { 'class' => $class } ); -% if (scalar(@types) < 1) { # we should never reach this +% my @types = qsearch( 'reason_type', { 'class' => $class } ); +% if (scalar(@types) < 1) { # we should never reach this -% } elsif (scalar(@types) == 1) { +% } elsif (scalar(@types) == 1) { <& tr-fixed.html, label => 'Reason type', field => $id.'_new_reason_type', curr_value => $types[0]->typenum, formatted_value => $types[0]->type, &> -% } else { # more than one type, the normal case +% } else { # more than one type, the normal case <& tr-select-table.html, label => 'Reason type', field => $id.'_new_reason_type', @@ -114,9 +114,9 @@ Example: hashref => { 'class' => $class }, disable_empty => 1, &> -% } # scalar(@types) +% } # scalar(@types) -% if ( $class eq 'S' ) { +% if ( $class eq 'S' ) { <& tr-checkbox.html, label => 'Credit the unused portion of service when suspending', field => $id.'_new_unused_credit', @@ -133,10 +133,11 @@ Example: field => $id.'_new_unsuspend_hold', value => 'Y', &> -% } +% }

<% mt('No reason types. Please add some.') |h %>

+% } # if the current user can add a reason % # container for hints @@ -146,6 +147,7 @@ Example: <%init> +my $curuser = $FS::CurrentUser::CurrentUser; my %opt = @_; my $name = $opt{'field'}; @@ -159,6 +161,7 @@ if ( $opt{'cgi'} ) { } my $id = $opt{'id'} || $name; +$id =~ s/\./_/g; # for edit/part_event my $add_access_right; if ($class eq 'C') { @@ -173,11 +176,11 @@ if ($class eq 'C') { my @reasons = qsearch({ 'table' => 'reason', + 'select' => "reason.*, (type || ' : ' || reason) AS label", 'addl_from' => ' LEFT JOIN reason_type'. ' ON (reason.reason_type = reason_type.typenum)', 'hashref' => { disabled => '' }, 'extra_sql' => " AND reason_type.class = '$class'", - 'order_by' => ' ORDER BY type, reason', }); my %all_hints; @@ -217,5 +220,9 @@ if ( $class eq 'S' ) { } } -my $curuser = $FS::CurrentUser::CurrentUser; +my @post_options; +if ( $curuser->access_right($add_access_right) ) { + @post_options = ( -1 => 'Add new reason' ); +} +