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 my $link = [ $p.'edit/part_pkg.cgi?', 'pkgpart' ];
99 my @header = ( '#', 'Package', 'Comment' );
100 my @fields = ( 'pkgpart', 'pkg', 'comment' ,);
102 my @links = ( $link, $link, '', );
104 unless ( length($classnum) ) {
105 push @header, 'Class';
106 push @fields, 'classname';
110 # still include the report_option classes, to help with migration
111 # but not other plan options
113 my %report_optionname_name = map { 'report_option_'.$_->num, $_->name }
114 qsearch('part_pkg_report_option', { disabled => '' });
116 push @header, 'Report classes';
120 my $part_pkg = shift;
121 my %options = $part_pkg->options;
122 # gather any options that are really report options,
123 # convert them to their user-friendly names,
124 # and sort them (I think?)
127 map { $report_optionname_name{$_} }
129 and exists($report_optionname_name{$_}) }
133 foreach (@report_options) {
140 } # foreach @report_options
147 # now the FCC option part
151 push @header, 'FCC report parameters';
153 my $part_pkg = shift;
154 my %hash = $part_pkg->fcc_options;
155 include('/elements/input-fcc_options.html',
156 id => 'pkgpart'.$part_pkg->pkgpart,
157 curr_value => encode_json(\%hash),
163 my $count_extra_sql = $extra_sql;
164 $count_extra_sql =~ s/^\s*AND /WHERE /i;
165 $extra_count = ( $count_extra_sql ? ' AND ' : ' WHERE ' ). $extra_count
167 my $count_query = "SELECT COUNT(*) FROM part_pkg $count_extra_sql $extra_count";
169 # in case of error redirect
170 if ( $cgi->param('redirect') ) {
173 my $part_pkg = shift;
174 my $pkgpart = $part_pkg->pkgpart;
175 '<B><FONT COLOR="#ffffff">' . $cgi->param("error$pkgpart") || '' . '</FONT></B>'
181 include('/elements/init_overlib.html') .
182 include('/elements/input-fcc_options.html', js_only => 1) .
186 my $html_form = qq!<FORM ACTION="${p}edit/process/bulk-part_pkg-fcc.html" METHOD="POST" NAME="bulk-part_pkg-fcc">
187 <INPUT TYPE="hidden" NAME="jump">
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,
200 # pass the page selection through so we can jump back to the current spot
201 if ( $cgi->param('maxrecords') =~ /^(\d+)$/ ) {
202 $html_form .= qq!<INPUT TYPE="hidden" NAME="maxrecords" VALUE="$1">!;
204 if ( $cgi->param('offset') =~ /^(\d+)$/ ) {
205 $html_form .= qq!<INPUT TYPE="hidden" NAME="offset" VALUE="$1">!;
208 # restore this only after creating $html_form
209 $cgi->param('classnum', $classnum) if length($classnum);
211 my $html_foot = '</FORM>';
214 ( 'Package definitions' => $p.'browse/part_pkg.cgi' );
224 button.edit_fcc_options {
230 <script type="text/javascript">
231 function finish_edit_fcc(id) {
233 document.forms['bulk-part_pkg-fcc']['jump'].value = id;
234 document.forms['bulk-part_pkg-fcc'].submit(); //immediately save/refresh
237 function filter_change() {
238 window.location = '<% $cgi->self_url %>?classnum='
239 + document.getElementById('classnum').value;