1 <& elements/search.html,
2 'html_init' => $html_init,
3 'html_form' => $html_form,
4 'html_foot' => '</FORM>',
5 'title' => emt('Package Search Results'),
8 'count_query' => $count_query,
9 'header' => [ emt('#'),
20 FS::UI::Web::cust_header(),
22 emt('Package options'),
29 sub { ucfirst(shift->status); },
30 sub { FS::part_pkg::freq_pretty(shift); },
32 ( map { time_or_blank($_) }
33 qw( setup bill susp change_date cancel ) ),
35 \&FS::UI::Web::cust_fields,
39 my $cust_location = $cust_pkg->cust_location;
40 ($cust_location->censustract || '<b>unknown</b>').
41 '<font size="-1"> (edit)</font>';
44 # a hidden input in each row with the pkgnum, so that
45 # we can refresh back to this list of pkgnums
48 my $part_pkg = $cust_pkg->part_pkg;
49 my %hash = $part_pkg->fcc_options;
50 '<INPUT NAME="pkgnum" TYPE="hidden" VALUE="' .
51 $cust_pkg->pkgnum . '">' .
52 include('/elements/input-fcc_options.html',
53 id => 'pkgnum'.$cust_pkg->pkgnum.
54 'pkgpart'.$part_pkg->pkgpart,
55 curr_value => encode_json(\%hash),
65 sub { shift->statuscolor; },
66 '', '', '', '', '', '',
67 FS::UI::Web::cust_colors(),
71 'style' => [ '', '', '', '', 'b',
72 '', '', '', '', '', '',
73 FS::UI::Web::cust_styles() ],
74 'size' => [ '', '', '', '', '-1' ],
75 'align' => 'rrlcccrrrrr'. FS::UI::Web::cust_aligns(). 'cl',
80 '', '', '', '', '', '', '', '',
81 ( map { $_ ne 'Cust. Status' ? $clink : '' }
82 FS::UI::Web::cust_header()
89 (map { '' } FS::UI::Web::cust_header()),
90 $pkg_edit_location_link,
97 my $curuser = $FS::CurrentUser::CurrentUser;
98 my $edit = 'Edit FCC report configuration';
99 my $edit_global = 'Edit FCC report configuration for all agents';
100 my $acl_edit = $curuser->access_right($edit);
101 my $acl_edit_global = $curuser->access_right($edit_global);
104 unless $acl_edit || $acl_edit_global;
106 my $conf = new FS::Conf;
110 my ($query, $count_query);
112 if ( $cgi->param('redirect') ) { # then restore the pkgnum list
113 $session = $cgi->param('redirect');
114 my $pref = $curuser->option("redirect$session"); # contains a list of pkgnums
115 die "unknown redirect session $session\n" unless length($pref);
116 my @pkgnums = grep /^\d+$/, split(',', $pref);
118 $query = FS::cust_pkg->search({});
119 $count_query = delete($query->{count_query});
121 my $where = "cust_pkg.pkgnum IN (".join(',', @pkgnums).")";
122 if ( $count_query =~ /WHERE/i ) {
123 $where = " AND ($where) ";
125 $where = " WHERE ($where) ";
127 $query->{extra_sql} .= $where;
128 $count_query .= $where;
130 # build and run the query right now, and then cache the pkgnums it returned
131 my %search_hash = ();
134 for (qw( agentnum 477part 477rownum date )) {
135 $search_hash{$_} = $cgi->param($_) if length($cgi->param($_));
138 $query = FS::cust_pkg->search(\%search_hash);
139 $count_query = delete($query->{'count_query'});
141 my @cust_pkg = qsearch($query);
143 my $pkgnums = join(',', map { $_->pkgnum } @cust_pkg);
144 $session = int(rand(4294967296)); #XXX
145 my $pref = new FS::access_user_pref({
146 'usernum' => $FS::CurrentUser::CurrentUser->usernum,
147 'prefname' => "redirect$session",
148 'prefvalue' => $pkgnums,
149 'expiration' => time + 3600, #1h? 1m?
151 my $pref_error = $pref->insert;
153 die "couldn't even set redirect cookie: $pref_error\n";
156 # and then bail out and reload using the redirect cookie
158 $cgi->param("redirect", $session);
160 $m->print( $cgi->redirect($cgi->self_url) );
164 my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/
170 my $frag = 'cust_pkg'. $self->pkgnum; #hack for IE ignoring real #fragment
171 [ "${p}view/cust_main.cgi?custnum=".$self->custnum.
172 "$show;fragment=$frag#cust_pkg",
178 include('/elements/init_overlib.html') .
179 include('/elements/input-fcc_options.html', js_only => 1) .
184 my $cust_pkg = shift;
185 $cust_pkg->cust_main_custnum
186 ? [ "${p}view/cust_main.cgi?", 'custnum' ]
191 <FORM ACTION="${p}edit/process/bulk-477_cust_pkg.html" METHOD="POST" NAME="477_cust_pkg">
192 <INPUT NAME="redirect" TYPE="hidden" VALUE="$session">
195 my $pkg_edit_location_link = sub {
196 my $cust_pkg = shift;
197 my $locationnum = $cust_pkg->locationnum;
198 include('/elements/popup_link_onclick.html',
199 'action' => $p. "edit/cust_location-censustract.html?locationnum=$locationnum",
200 'actionlabel' => emt('Edit census tract'),
210 my $value = $record->get($column); #mmm closures
211 $value ? time2str('%b %d %Y', $value ) : '';
218 button.edit_fcc_button { float: right; }
222 <script type="text/javascript">
223 function finish_edit_fcc(id) {
225 document.forms['477_cust_pkg'].submit(); //immediately save/refresh