1 <& elements/browse.html,
2 'title' => 'Package Definitions - FCC Options',
3 'menubar' => \@menubar,
4 'html_init' => $html_init,
5 'html_form' => $html_form,
6 'html_posttotal' => $html_posttotal,
7 'name' => 'package definitions',
9 'disabled_statuspos' => 4,
11 'agent_null_right' => [ $edit, $edit_global ],
12 'agent_null_right_link' => $edit_global,
15 { 'select' => $select,
16 'table' => 'part_pkg',
17 'addl_from' => $addl_from,
19 'extra_sql' => $extra_sql,
20 'order_by' => "ORDER BY $orderby"
22 'count_query' => $count_query,
27 'link_field' => 'pkgpart',
28 'html_foot' => $html_foot,
32 my $curuser = $FS::CurrentUser::CurrentUser;
34 my $edit = 'Edit package definitions';
35 my $edit_global = 'Edit global package definitions';
36 my $acl_edit = $curuser->access_right($edit);
37 my $acl_edit_global = $curuser->access_right($edit_global);
40 unless $acl_edit || $acl_edit_global;
42 my $conf = new FS::Conf;
44 my $orderby = 'pkgpart';
50 # only ever show recurring packages here
51 $hash{'freq'} = { op=>'!=', value=>'0' };
52 $extra_count = " freq != '0' ";
56 if ( $cgi->param('classnum') =~ /^(\d+)$/ ) {
58 push @where, $classnum ? "classnum = $classnum"
61 $cgi->delete('classnum');
63 # filter by agent permissions
64 push @where, FS::part_pkg->curuser_pkgs_sql
65 unless $acl_edit_global;
67 my $extra_sql = scalar(@where)
68 ? ( scalar(keys %hash) ? ' AND ' : ' WHERE ' ).
72 # pull option values into the select
73 my @optionnames = ( qw(
76 is_broadband technology broadband_upstream broadband_downstream
77 is_phone phone_wholesale phone_vges phone_circuits
78 phone_lines phone_longdistance phone_localloop
79 is_voip voip_lastmile voip_sessions
82 my $select = join(',',
84 '(SELECT classname FROM pkg_class WHERE pkg_class.classnum = part_pkg.classnum) AS classname', # grr, disableable...
89 FS::Report::FCC_477::join_optionnames(@optionnames);
91 #restore this so pagination works
92 $cgi->param('classnum', $classnum) if length($classnum);
94 #should hide this if there aren't any classes
97 include('/elements/select-pkg_class.html',
98 #'curr_value' => $classnum,
99 'value' => $classnum, #insist on 0 :/
100 'onchange' => 'filter_change()',
101 'pre_options' => [ '-1' => 'all',
103 'disable_empty' => 1,
107 my $link = [ $p.'edit/part_pkg.cgi?', 'pkgpart' ];
109 my @header = ( '#', 'Package', 'Comment' );
110 my @fields = ( 'pkgpart', 'pkg', 'comment' ,);
112 my @links = ( $link, $link, '', );
114 unless ( length($classnum) ) {
115 push @header, 'Class';
116 push @fields, 'classname';
120 # still include the report_option classes, to help with migration
121 # but not other plan options
123 my %report_optionname_name = map { 'report_option_'.$_->num, $_->name }
124 qsearch('part_pkg_report_option', { disabled => '' });
126 push @header, 'Report classes';
130 my $part_pkg = shift;
131 my %options = $part_pkg->options;
132 # gather any options that are really report options,
133 # convert them to their user-friendly names,
134 # and sort them (I think?)
137 map { $report_optionname_name{$_} }
139 and exists($report_optionname_name{$_}) }
143 foreach (@report_options) {
150 } # foreach @report_options
157 # now the FCC option part
161 push @header, 'FCC report parameters';
163 my $part_pkg = shift;
164 my %hash = $part_pkg->fcc_options;
165 include('/elements/input-fcc_options.html',
166 id => 'pkgpart'.$part_pkg->pkgpart,
167 curr_value => encode_json(\%hash),
173 my $count_extra_sql = $extra_sql;
174 $count_extra_sql =~ s/^\s*AND /WHERE /i;
175 $extra_count = ( $count_extra_sql ? ' AND ' : ' WHERE ' ). $extra_count
177 my $count_query = "SELECT COUNT(*) FROM part_pkg $count_extra_sql $extra_count";
180 include('/elements/init_overlib.html') .
181 include('/elements/input-fcc_options.html', js_only => 1) .
186 # insert a checkbox column
188 unshift @fields, sub {
189 '<INPUT TYPE="checkbox" NAME="pkgpart" VALUE=' . $_[0]->pkgpart .'>';
195 $html_form = qq!<FORM ACTION="${p}edit/process/bulk-part_pkg-fcc.html" METHOD="POST">!;
197 <INPUT TYPE="submit" VALUE="Save changes">
201 ( 'Package definitions' => $p.'browse/part_pkg.cgi' );
211 button.edit_fcc_options {