diff options
Diffstat (limited to 'httemplate/elements')
-rw-r--r-- | httemplate/elements/checkboxes-table.html | 12 | ||||
-rw-r--r-- | httemplate/elements/menu.html | 2 | ||||
-rw-r--r-- | httemplate/elements/select-agent.html | 14 | ||||
-rw-r--r-- | httemplate/elements/select-table.html | 17 | ||||
-rw-r--r-- | httemplate/elements/tr-checkboxes-table.html | 20 |
5 files changed, 55 insertions, 10 deletions
diff --git a/httemplate/elements/checkboxes-table.html b/httemplate/elements/checkboxes-table.html index cdfa58eca..b6b04d111 100644 --- a/httemplate/elements/checkboxes-table.html +++ b/httemplate/elements/checkboxes-table.html @@ -28,9 +28,9 @@ % my $target_pkey = dbdef->table($opt{'target_table'})->primary_key; % % my( $source_pkey, $sourcenum, $source_obj ); -% if ( $opt{'source_obj'} ) { +% if ( $opt{'source_obj'} || $opt{'object'} ) { % -% $source_obj = $opt{'source_obj'}; +% $source_obj = $opt{'source_obj'} || $opt{'object'}; % #$source_table = $source_obj->dbdef_table->table; % $source_pkey = $source_obj->dbdef_table->primary_key; % $sourcenum = $source_obj->$source_pkey(); @@ -48,11 +48,17 @@ % % my $extra_sql = ''; % +% if ( $opt{'agent_virt'} ) { +% $extra_sql .= ' AND' . $FS::CurrentUser::CurrentUser->agentnums_sql( +% 'null_right' => $opt{'agent_null_right'} +% ); +% } +% % if ( $opt{'disable-able'} ) { % $hashref->{'disabled'} = ''; % % $extra_sql .= ( $sourcenum && $source_pkey ) -% ? "OR $source_pkey = $sourcenum" +% ? " OR $source_pkey = $sourcenum" % : ''; % } % diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index 9ace19ea3..5a947ea88 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -334,7 +334,7 @@ $config_menu{'Resellers'} = [ \%config_agent, '' ] $config_menu{'Billing'} = [ \%config_billing, '' ] if $curuser->access_right('Edit billing events') || $curuser->access_right('Edit global billing events'); -if ( $curuser->access_right('Configuration') ) { +if ( $curuser->access_right('Engineering configuration') ) { $config_menu{'Dialup'} = [ \%config_dialup, '' ]; $config_menu{'Fixed (username-less) broadband'} = [ \%config_broadband, '' ]; diff --git a/httemplate/elements/select-agent.html b/httemplate/elements/select-agent.html index 54069a5cb..d8ab50080 100644 --- a/httemplate/elements/select-agent.html +++ b/httemplate/elements/select-agent.html @@ -4,9 +4,8 @@ 'value' => $agentnum || '', 'empty_label' => 'all', 'hashref' => { 'disabled' => '' }, - 'extra_sql' => ' AND '. - $FS::CurrentUser::CurrentUser->agentnums_sql. - ' ORDER BY agent', + 'order_by' => ' ORDER BY agent', + 'disable_empty' => $disable_empty, %opt, ) %> @@ -18,4 +17,13 @@ my $agentnum = $opt{'curr_value'} || $opt{'value'}; $opt{'records'} = delete $opt{'agents'} if $opt{'agents'}; +my $curuser = $FS::CurrentUser::CurrentUser; +my $disable_empty = 1; +if ( $opt{'agent_null_right'} && + $curuser->access_right($opt{'agent_null_right'}) + ) +{ + $disable_empty--; +} + </%init> diff --git a/httemplate/elements/select-table.html b/httemplate/elements/select-table.html index 7339f362c..d24c9abe4 100644 --- a/httemplate/elements/select-table.html +++ b/httemplate/elements/select-table.html @@ -92,14 +92,25 @@ my $name_col = $opt{'name_col'}; my $value = $opt{'curr_value'} || $opt{'value'}; $value = [ split(/\s*,\s*/, $value) ] if $opt{'multiple'} && $value =~ /,/; +my $extra_sql = $opt{'extra_sql'} || ''; +my $hashref = $opt{'hashref'} || {}; + +if ( $opt{'agent_virt'} ) { + $extra_sql .= + ( $extra_sql =~ /WHERE/i || scalar(keys %$hashref ) ? ' AND ' : ' WHERE ' ). + $FS::CurrentUser::CurrentUser->agentnums_sql( + 'null_right' => $opt{'agent_null_right'} + ); +} + my @records = (); if ( $opt{'records'} ) { @records = @{ $opt{'records'} }; } else { @records = qsearch( { 'table' => $opt{'table'}, - 'hashref' => ( $opt{'hashref'} || {} ), - 'extra_sql' => ( $opt{'extra_sql'} || '' ), + 'hashref' => $hashref, + 'extra_sql' => $extra_sql, 'order_by' => ( $opt{'order_by'} || "ORDER BY $name_col" ), }); } @@ -113,7 +124,7 @@ unless ( ! $value $opt{hashref}->{$key} = $value; my $record = qsearchs( { 'table' => $opt{table}, - 'hashref' => $opt{hashref}, + 'hashref' => $hashref, 'extra_sql' => ( $opt{extra_sql} || '' ), }); push @records, $record if $record; diff --git a/httemplate/elements/tr-checkboxes-table.html b/httemplate/elements/tr-checkboxes-table.html new file mode 100644 index 000000000..0099427be --- /dev/null +++ b/httemplate/elements/tr-checkboxes-table.html @@ -0,0 +1,20 @@ +% unless ( $opt{'js_only'} ) { + + <% include('tr-td-label.html', @_ ) %> + + <TD <% $style %>> +% } + + <% include( '/elements/checkboxes-table.html', %opt ) %> + +% unless ( $opt{'js_only'} ) { + </TD> + </TR> +% } +<%init> + +my( %opt ) = @_; + +my $style = $opt{'cell_style'} ? 'STYLE="'. $opt{'cell_style'}. '"' : ''; + +</%init> |