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, $edit_global ],
11 'agent_null_right_link' => $edit_global,
14 { 'select' => $select,
15 'table' => 'part_pkg',
16 'addl_from' => $addl_from,
18 'extra_sql' => $extra_sql,
19 'order_by' => "ORDER BY $orderby"
21 'count_query' => $count_query,
26 'link_field' => 'pkgpart',
27 'html_foot' => $html_foot,
31 my $curuser = $FS::CurrentUser::CurrentUser;
33 my $edit = 'Edit package definitions';
34 my $edit_global = 'Edit global package definitions';
35 my $acl_edit = $curuser->access_right($edit);
36 my $acl_edit_global = $curuser->access_right($edit_global);
39 unless $acl_edit || $acl_edit_global;
41 if ( $cgi->param('redirect') ) {
42 my $session = $cgi->param('redirect');
43 my $pref = $curuser->option("redirect$session");
44 die "unknown redirect session $session\n" unless length($pref);
45 $cgi = new CGI($pref);
46 $cgi->param('redirect', $session);
49 my $conf = new FS::Conf;
51 my $orderby = 'pkgpart';
57 # only ever show recurring packages here
58 $hash{'freq'} = { op=>'!=', value=>'0' };
59 $extra_count = " freq != '0' ";
63 if ( $cgi->param('classnum') =~ /^(\d+)$/ ) {
65 push @where, $classnum ? "classnum = $classnum"
68 $cgi->delete('classnum');
70 # filter by agent permissions
71 push @where, FS::part_pkg->curuser_pkgs_sql
72 unless $acl_edit_global;
74 my $extra_sql = scalar(@where)
75 ? ( scalar(keys %hash) ? ' AND ' : ' WHERE ' ).
79 # pull option values into the select
80 my @optionnames = ( qw(
83 is_broadband technology broadband_upstream broadband_downstream
84 is_phone phone_wholesale phone_vges phone_circuits
85 phone_lines phone_longdistance phone_localloop
86 is_voip voip_lastmile voip_sessions
89 my $select = join(',',
91 '(SELECT classname FROM pkg_class WHERE pkg_class.classnum = part_pkg.classnum) AS classname', # grr, disableable...
96 FS::Report::FCC_477::join_optionnames(@optionnames);
98 $cgi->param('classnum', $classnum) if length($classnum);
100 my $link = [ $p.'edit/part_pkg.cgi?', 'pkgpart' ];
102 my @header = ( '#', 'Package', 'Comment' );
103 my @fields = ( 'pkgpart', 'pkg', 'comment' ,);
105 my @links = ( $link, $link, '', );
107 unless ( length($classnum) ) {
108 push @header, 'Class';
109 push @fields, 'classname';
113 # still include the report_option classes, to help with migration
114 # but not other plan options
116 my %report_optionname_name = map { 'report_option_'.$_->num, $_->name }
117 qsearch('part_pkg_report_option', { disabled => '' });
119 push @header, 'Report classes';
123 my $part_pkg = shift;
124 my %options = $part_pkg->options;
125 # gather any options that are really report options,
126 # convert them to their user-friendly names,
127 # and sort them (I think?)
130 map { $report_optionname_name{$_} }
132 and exists($report_optionname_name{$_}) }
136 foreach (@report_options) {
143 } # foreach @report_options
150 # now the FCC option part
154 push @header, 'FCC report parameters';
156 my $part_pkg = shift;
157 my %hash = $part_pkg->fcc_options;
158 include('/elements/input-fcc_options.html',
159 id => 'pkgpart'.$part_pkg->pkgpart,
160 curr_value => encode_json(\%hash),
166 my $count_extra_sql = $extra_sql;
167 $count_extra_sql =~ s/^\s*AND /WHERE /i;
168 $extra_count = ( $count_extra_sql ? ' AND ' : ' WHERE ' ). $extra_count
170 my $count_query = "SELECT COUNT(*) FROM part_pkg $count_extra_sql $extra_count";
172 # in case of error redirect
173 if ( $cgi->param('redirect') ) {
176 my $part_pkg = shift;
177 my $pkgpart = $part_pkg->pkgpart;
178 '<B><FONT COLOR="#ffffff">' . $cgi->param("error$pkgpart") || '' . '</FONT></B>'
184 include('/elements/init_overlib.html') .
185 include('/elements/input-fcc_options.html', js_only => 1) .
188 my $html_form = qq!<FORM ACTION="${p}edit/process/bulk-part_pkg-fcc.html" METHOD="POST">
190 include('/elements/select-pkg_class.html',
191 #'curr_value' => $classnum,
192 'value' => $classnum, #insist on 0 :/
193 'onchange' => 'filter_change()',
194 'pre_options' => [ '-1' => 'all',
196 'disable_empty' => 1,
200 qq!<SCRIPT TYPE="text/javascript">
201 function filter_change() {
202 window.location = '! . $cgi->self_url . qq!?classnum='
203 + document.getElementById('classnum').value;
208 <INPUT TYPE="submit" VALUE="Save changes">
212 ( 'Package definitions' => $p.'browse/part_pkg.cgi' );
222 button.edit_fcc_options {