1 <& elements/browse.html,
2 'title' => 'Package Definitions - FCC Options',
3 'menubar' => \@menubar,
4 'html_init' => $html_init,
5 'html_form' => $html_form,
6 'name' => 'package definitions',
8 'disabled_statuspos' => 4,
10 'agent_null_right' => $edit_global,
13 { 'select' => $select,
14 'table' => 'part_pkg',
15 'addl_from' => $addl_from,
17 'extra_sql' => $extra_sql,
18 'order_by' => "ORDER BY $orderby"
20 'count_query' => $count_query,
25 'link_field' => 'pkgpart',
26 'html_foot' => $html_foot,
30 my $curuser = $FS::CurrentUser::CurrentUser;
32 my $edit = 'Edit FCC report configuration';
33 my $edit_global = 'Edit FCC report configuration for all agents';
34 my $acl_edit = $curuser->access_right($edit);
35 my $acl_edit_global = $curuser->access_right($edit_global);
38 unless $acl_edit || $acl_edit_global;
40 if ( $cgi->param('redirect') ) {
41 my $session = $cgi->param('redirect');
42 my $pref = $curuser->option("redirect$session");
43 die "unknown redirect session $session\n" unless length($pref);
44 $cgi = new CGI($pref);
45 $cgi->param('redirect', $session);
48 my $conf = new FS::Conf;
50 my $orderby = 'pkgpart';
56 # only ever show recurring packages here
57 $hash{'freq'} = { op=>'!=', value=>'0' };
58 $extra_count = " freq != '0' ";
62 if ( $cgi->param('classnum') =~ /^(\d+)$/ ) {
64 push @where, $classnum ? "classnum = $classnum"
67 $cgi->delete('classnum');
69 # filter by agent permissions
70 push @where, FS::part_pkg->curuser_pkgs_sql
71 unless $acl_edit_global;
73 my $extra_sql = scalar(@where)
74 ? ( scalar(keys %hash) ? ' AND ' : ' WHERE ' ).
78 # pull option values into the select
79 my @optionnames = ( qw(
82 is_broadband technology broadband_upstream broadband_downstream
83 is_phone phone_wholesale phone_vges phone_circuits
84 phone_lines phone_longdistance phone_localloop
85 is_voip voip_lastmile voip_sessions
88 my $select = join(',',
90 '(SELECT classname FROM pkg_class WHERE pkg_class.classnum = part_pkg.classnum) AS classname', # grr, disableable...
95 FS::Report::FCC_477::join_optionnames(@optionnames);
97 $cgi->param('classnum', $classnum) if length($classnum);
99 my $link = [ $p.'edit/part_pkg.cgi?', 'pkgpart' ];
101 my @header = ( '#', 'Package', 'Comment' );
102 my @fields = ( 'pkgpart', 'pkg', 'comment' ,);
104 my @links = ( $link, $link, '', );
106 unless ( length($classnum) ) {
107 push @header, 'Class';
108 push @fields, 'classname';
112 # still include the report_option classes, to help with migration
113 # but not other plan options
115 my %report_optionname_name = map { 'report_option_'.$_->num, $_->name }
116 qsearch('part_pkg_report_option', { disabled => '' });
118 push @header, 'Report classes';
122 my $part_pkg = shift;
123 my %options = $part_pkg->options;
124 # gather any options that are really report options,
125 # convert them to their user-friendly names,
126 # and sort them (I think?)
129 map { $report_optionname_name{$_} }
131 and exists($report_optionname_name{$_}) }
135 foreach (@report_options) {
142 } # foreach @report_options
149 # now the FCC option part
153 push @header, 'FCC report parameters';
155 my $part_pkg = shift;
156 my %hash = $part_pkg->fcc_options;
157 include('/elements/input-fcc_options.html',
158 id => 'pkgpart'.$part_pkg->pkgpart,
159 curr_value => encode_json(\%hash),
165 my $count_extra_sql = $extra_sql;
166 $count_extra_sql =~ s/^\s*AND /WHERE /i;
167 $extra_count = ( $count_extra_sql ? ' AND ' : ' WHERE ' ). $extra_count
169 my $count_query = "SELECT COUNT(*) FROM part_pkg $count_extra_sql $extra_count";
171 # in case of error redirect
172 if ( $cgi->param('redirect') ) {
175 my $part_pkg = shift;
176 my $pkgpart = $part_pkg->pkgpart;
177 '<B><FONT COLOR="#ffffff">' . $cgi->param("error$pkgpart") || '' . '</FONT></B>'
183 include('/elements/init_overlib.html') .
184 include('/elements/input-fcc_options.html', js_only => 1) .
187 my $html_form = qq!<FORM ACTION="${p}edit/process/bulk-part_pkg-fcc.html" METHOD="POST">
189 include('/elements/select-pkg_class.html',
190 #'curr_value' => $classnum,
191 'value' => $classnum, #insist on 0 :/
192 'onchange' => 'filter_change()',
193 'pre_options' => [ '-1' => 'all',
195 'disable_empty' => 1,
199 qq!<SCRIPT TYPE="text/javascript">
200 function filter_change() {
201 window.location = '! . $cgi->self_url . qq!?classnum='
202 + document.getElementById('classnum').value;
207 <INPUT TYPE="submit" VALUE="Save changes">
211 ( 'Package definitions' => $p.'browse/part_pkg.cgi' );
221 button.edit_fcc_options {