summaryrefslogtreecommitdiff
path: root/httemplate/search/477_cust_pkg.html
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate/search/477_cust_pkg.html')
-rw-r--r--httemplate/search/477_cust_pkg.html228
1 files changed, 228 insertions, 0 deletions
diff --git a/httemplate/search/477_cust_pkg.html b/httemplate/search/477_cust_pkg.html
new file mode 100644
index 000000000..b8df9fd0f
--- /dev/null
+++ b/httemplate/search/477_cust_pkg.html
@@ -0,0 +1,228 @@
+<& elements/search.html,
+ 'html_init' => $html_init,
+ 'html_form' => $html_form,
+ 'html_foot' => '</FORM>',
+ 'title' => emt('Package Search Results'),
+ 'name' => 'packages',
+ 'query' => $query,
+ 'count_query' => $count_query,
+ 'header' => [ emt('#'),
+ emt('Quan.'),
+ emt('Package'),
+ emt('Class'),
+ emt('Status'),
+ emt('Freq.'),
+ emt('Setup'),
+ emt('Next bill'),
+ emt('Susp.'),
+ emt('Changed'),
+ emt('Cancel'),
+ FS::UI::Web::cust_header(),
+ emt('Census tract'),
+ emt('Package options'),
+ ],
+ 'fields' => [
+ 'pkgnum',
+ 'quantity',
+ sub { $_[0]->pkg; },
+ 'classname',
+ sub { ucfirst(shift->status); },
+ sub { FS::part_pkg::freq_pretty(shift); },
+
+ ( map { time_or_blank($_) }
+ qw( setup bill susp change_date cancel ) ),
+
+ \&FS::UI::Web::cust_fields,
+
+ sub { # census tract
+ my $cust_pkg = shift;
+ my $cust_location = $cust_pkg->cust_location;
+ ($cust_location->censustract || '<b>unknown</b>').
+ '<font size="-1"> (edit)</font>';
+ },
+
+ # a hidden input in each row with the pkgnum, so that
+ # we can refresh back to this list of pkgnums
+ sub {
+ my $cust_pkg = shift;
+ my $part_pkg = $cust_pkg->part_pkg;
+ my %hash = $part_pkg->fcc_options;
+ '<INPUT NAME="pkgnum" TYPE="hidden" VALUE="' .
+ $cust_pkg->pkgnum . '">' .
+ include('/elements/input-fcc_options.html',
+ id => 'pkgnum'.$cust_pkg->pkgnum.
+ 'pkgpart'.$part_pkg->pkgpart,
+ curr_value => encode_json(\%hash),
+ html_only => 1
+ )
+ },
+ ],
+ 'color' => [
+ '',
+ '',
+ '',
+ '',
+ sub { shift->statuscolor; },
+ '', '', '', '', '', '',
+ FS::UI::Web::cust_colors(),
+ '',
+ '',
+ ],
+ 'style' => [ '', '', '', '', 'b',
+ '', '', '', '', '', '',
+ FS::UI::Web::cust_styles() ],
+ 'size' => [ '', '', '', '', '-1' ],
+ 'align' => 'rrlcccrrrrr'. FS::UI::Web::cust_aligns(). 'cl',
+ 'links' => [
+ $link,
+ $link,
+ $link,
+ '', '', '', '', '', '', '', '',
+ ( map { $_ ne 'Cust. Status' ? $clink : '' }
+ FS::UI::Web::cust_header()
+ ),
+ '',
+ '',
+ ],
+ 'link_onclicks' => [
+ (('') x 11),
+ (map { '' } FS::UI::Web::cust_header()),
+ $pkg_edit_location_link,
+ '',
+ ],
+
+&>
+<%init>
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+my $edit = 'Edit FCC report configuration';
+my $edit_global = 'Edit FCC report configuration for all agents';
+my $acl_edit = $curuser->access_right($edit);
+my $acl_edit_global = $curuser->access_right($edit_global);
+
+die "access denied"
+ unless $acl_edit || $acl_edit_global;
+
+my $conf = new FS::Conf;
+
+my $session;
+
+my ($query, $count_query);
+
+if ( $cgi->param('redirect') ) { # then restore the pkgnum list
+ $session = $cgi->param('redirect');
+ my $pref = $curuser->option("redirect$session"); # contains a list of pkgnums
+ die "unknown redirect session $session\n" unless length($pref);
+ my @pkgnums = grep /^\d+$/, split(',', $pref);
+
+ $query = FS::cust_pkg->search({});
+ $count_query = delete($query->{count_query});
+
+ my $where = "cust_pkg.pkgnum IN (".join(',', @pkgnums).")";
+ if ( $count_query =~ /WHERE/i ) {
+ $where = " AND ($where) ";
+ } else {
+ $where = " WHERE ($where) ";
+ }
+ $query->{extra_sql} .= $where;
+ $count_query .= $where;
+} else {
+ # build and run the query right now, and then cache the pkgnums it returned
+ my %search_hash = ();
+
+ #scalars
+ for (qw( agentnum 477part 477rownum date )) {
+ $search_hash{$_} = $cgi->param($_) if length($cgi->param($_));
+ }
+
+ $query = FS::cust_pkg->search(\%search_hash);
+ $count_query = delete($query->{'count_query'});
+
+ my @cust_pkg = qsearch($query);
+
+ my $pkgnums = join(',', map { $_->pkgnum } @cust_pkg);
+ $session = int(rand(4294967296)); #XXX
+ my $pref = new FS::access_user_pref({
+ 'usernum' => $FS::CurrentUser::CurrentUser->usernum,
+ 'prefname' => "redirect$session",
+ 'prefvalue' => $pkgnums,
+ 'expiration' => time + 3600, #1h? 1m?
+ });
+ my $pref_error = $pref->insert;
+ if ($pref_error) {
+ die "couldn't even set redirect cookie: $pref_error\n";
+ }
+
+ # and then bail out and reload using the redirect cookie
+ $cgi->delete_all();
+ $cgi->param("redirect", $session);
+ $m->clear_buffer;
+ $m->print( $cgi->redirect($cgi->self_url) );
+ $m->abort;
+}
+
+my $show = $curuser->default_customer_view =~ /^(jumbo|packages)$/
+ ? ''
+ : ';show=packages';
+
+my $link = sub {
+ my $self = shift;
+ my $frag = 'cust_pkg'. $self->pkgnum; #hack for IE ignoring real #fragment
+ [ "${p}view/cust_main.cgi?custnum=".$self->custnum.
+ "$show;fragment=$frag#cust_pkg",
+ 'pkgnum'
+ ];
+};
+
+my $html_init =
+ include('/elements/init_overlib.html') .
+ include('/elements/input-fcc_options.html', js_only => 1) .
+ include('.style') .
+ include('.script');
+
+my $clink = sub {
+ my $cust_pkg = shift;
+ $cust_pkg->cust_main_custnum
+ ? [ "${p}view/cust_main.cgi?", 'custnum' ]
+ : '';
+};
+
+my $html_form = qq!
+ <FORM ACTION="${p}edit/process/bulk-477_cust_pkg.html" METHOD="POST" NAME="477_cust_pkg">
+ <INPUT NAME="redirect" TYPE="hidden" VALUE="$session">
+!;
+
+my $pkg_edit_location_link = sub {
+ my $cust_pkg = shift;
+ my $locationnum = $cust_pkg->locationnum;
+ include('/elements/popup_link_onclick.html',
+ 'action' => $p. "edit/cust_location-censustract.html?locationnum=$locationnum",
+ 'actionlabel' => emt('Edit census tract'),
+ 'width' => 700,
+ 'height' => 355,
+ );
+};
+
+sub time_or_blank {
+ my $column = shift;
+ return sub {
+ my $record = shift;
+ my $value = $record->get($column); #mmm closures
+ $value ? time2str('%b %d %Y', $value ) : '';
+ };
+}
+
+</%init>
+<%def .style>
+<style>
+ button.edit_fcc_button { float: right; }
+</style>
+</%def>
+<%def .script>
+<script type="text/javascript">
+ function finish_edit_fcc(id) {
+ cClick();
+ document.forms['477_cust_pkg'].submit(); //immediately save/refresh
+ }
+</script>
+</%def>