summaryrefslogtreecommitdiff
path: root/httemplate/search
diff options
context:
space:
mode:
authormark <mark>2011-04-01 02:52:24 +0000
committermark <mark>2011-04-01 02:52:24 +0000
commitb65b8096089410001dfbcd35f9a56f9405b9f5f1 (patch)
treedf16b0422007bd876bc969bdff857d8a510b0aca /httemplate/search
parent19b0c403fbf697a1de92f12abc8a2104daca07bc (diff)
svc_hardware and svc_dish, #11454
Diffstat (limited to 'httemplate/search')
-rwxr-xr-xhttemplate/search/report_svc_hardware.html71
-rwxr-xr-xhttemplate/search/svc_dish.cgi99
-rw-r--r--httemplate/search/svc_hardware.cgi106
3 files changed, 276 insertions, 0 deletions
diff --git a/httemplate/search/report_svc_hardware.html b/httemplate/search/report_svc_hardware.html
new file mode 100755
index 000000000..4a763b0b4
--- /dev/null
+++ b/httemplate/search/report_svc_hardware.html
@@ -0,0 +1,71 @@
+<% include('/elements/header.html', $title ) %>
+
+<FORM ACTION="svc_hardware.cgi" METHOD="GET">
+
+ <TABLE BGCOLOR="#cccccc" CELLSPACING=0>
+ <TR>
+ <TH CLASS="background" COLSPAN=2 ALIGN="left"><FONT SIZE="+1">Search options</FONT></TH>
+ </TR>
+
+ <TR><TD>
+ <% include('/elements/selectlayers.html',
+ 'field' => 'classnum',
+ 'label' => '',
+ 'options' => \@classnums,
+ 'labels' => \%class_labels,
+ 'layer_callback' => \&layer_callback,
+ 'html_between' => '</TD><TD>',
+ ) %>
+ </TD></TR>
+
+ <% include('/elements/tr-input-text.html',
+ 'field' => 'serial',
+ 'label' => 'Serial #',
+ ) %>
+ <% include('/elements/tr-input-text.html',
+ 'field' => 'hw_addr',
+ 'label' => 'Hardware address',
+ ) %>
+ <% include('/elements/tr-input-text.html',
+ 'field' => 'ip_addr',
+ 'label' => 'IP address',
+ ) %>
+ <% include('/elements/tr-select-table.html',
+ 'field' => 'statusnum',
+ 'label' => 'Service status',
+ 'table' => 'hardware_status',
+ 'name_col' => 'label',
+ 'empty_label' => 'any',
+ ) %>
+
+ </TABLE>
+
+<BR>
+<INPUT TYPE="submit" VALUE="Search">
+
+</FORM>
+
+<% include('/elements/footer.html') %>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('List packages'); #?
+
+my $title = 'Hardware Service Report';
+
+my @classes = qsearch('hardware_class', {});
+my @classnums = ('', map { $_->classnum } @classes);
+my %class_labels = ('' => 'Select hardware class',
+ map { $_->classnum => $_->classname } @classes);
+
+sub layer_callback {
+ my $classnum = shift or return '';
+ include('/elements/select-hardware_type.html',
+ 'field' => 'classnum'.$classnum.'typenum',
+ 'classnum' => $classnum,
+ 'empty_label' => 'any',
+ );
+}
+
+</%init>
+
diff --git a/httemplate/search/svc_dish.cgi b/httemplate/search/svc_dish.cgi
new file mode 100755
index 000000000..94da03537
--- /dev/null
+++ b/httemplate/search/svc_dish.cgi
@@ -0,0 +1,99 @@
+<% include( 'elements/search.html',
+ 'title' => 'Dish Network Search Results',
+ 'name' => 'services',
+ 'query' => $sql_query,
+ 'count_query' => $count_query,
+ 'redirect' => $link,
+ 'header' => [ '#',
+ 'Service',
+ 'Account #',
+ FS::UI::Web::cust_header(),
+ ],
+ 'fields' => [ 'svcnum',
+ 'svc',
+ 'acctnum',
+ \&FS::UI::Web::cust_fields,
+ ],
+ 'links' => [ $link,
+ $link,
+ $link,
+ ( map { $_ ne 'Cust. Status' ? $link_cust : '' }
+ FS::UI::Web::cust_header()
+ ),
+ ],
+ 'align' => 'rll'. FS::UI::Web::cust_aligns(),
+ 'color' => [
+ '',
+ '',
+ '',
+ FS::UI::Web::cust_colors(),
+ ],
+ 'style' => [
+ '',
+ '',
+ '',
+ FS::UI::Web::cust_styles(),
+ ],
+ )
+%>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('List services');
+
+#my $conf = new FS::Conf;
+
+my $orderby = 'ORDER BY svcnum';
+my @extra_sql = ();
+if ( $cgi->param('magic') =~ /^(all|unlinked)$/ ) {
+
+ push @extra_sql, 'pkgnum IS NULL'
+ if $cgi->param('magic') eq 'unlinked';
+
+ if ( $cgi->param('sortby') =~ /^(\w+)$/ ) {
+ my $sortby = $1;
+ $orderby = "ORDER BY $sortby";
+ }
+} elsif ( $cgi->param('svcpart') =~ /^(\d+)$/ ) {
+ push @extra_sql, "svcpart = $1";
+}
+
+my $addl_from = ' LEFT JOIN cust_svc USING ( svcnum ) '.
+ ' LEFT JOIN part_svc USING ( svcpart ) '.
+ ' LEFT JOIN cust_pkg USING ( pkgnum ) '.
+ ' LEFT JOIN cust_main USING ( custnum ) ';
+
+#here is the agent virtualization
+push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql(
+ 'null_right' => 'View/link unlinked services'
+ );
+
+my $extra_sql =
+ scalar(@extra_sql)
+ ? ' WHERE '. join(' AND ', @extra_sql )
+ : '';
+
+
+my $count_query = "SELECT COUNT(*) FROM svc_dish $addl_from $extra_sql";
+my $sql_query = {
+ 'table' => 'svc_dish',
+ 'hashref' => {},
+ 'select' => join(', ',
+ 'svc_dish.*',
+ 'part_svc.svc',
+ 'cust_main.custnum',
+ FS::UI::Web::cust_sql_fields(),
+ ),
+ 'extra_sql' => $extra_sql,
+ 'order_by' => $orderby,
+ 'addl_from' => $addl_from,
+};
+
+my $link = [ "${p}view/svc_dish.cgi?", 'svcnum', ];
+
+my $link_cust = sub {
+ my $svc_x = shift;
+ $svc_x->custnum ? [ "${p}view/cust_main.cgi?", 'custnum' ] : '';
+};
+
+</%init>
diff --git a/httemplate/search/svc_hardware.cgi b/httemplate/search/svc_hardware.cgi
new file mode 100644
index 000000000..ffbb9f3b6
--- /dev/null
+++ b/httemplate/search/svc_hardware.cgi
@@ -0,0 +1,106 @@
+<% include('elements/search.html',
+ 'title' => 'Hardware service search results',
+ 'name' => 'installations',
+ 'query' => $sql_query,
+ 'count_query' => $count_query,
+ 'redirect' => $link_svc,
+ 'header' => [ '#',
+ 'Service',
+ 'Device type',
+ 'Serial #',
+ 'Hardware addr.',
+ 'IP addr.',
+ FS::UI::Web::cust_header(),
+ ],
+ 'fields' => [ 'svcnum',
+ 'svc',
+ 'model',
+ 'serial',
+ 'hw_addr',
+ 'ip_addr',
+ \&FS::UI::Web::cust_fields,
+ ],
+ 'links' => [ ($link_svc) x 6,
+ ( map { $_ ne 'Cust. Status' ?
+ $link_cust : '' }
+ FS::UI::Web::cust_header() )
+ ],
+ 'align' => 'rllll' . FS::UI::Web::cust_aligns(),
+ 'color' => [ ('') x 4, FS::UI::Web::cust_colors() ],
+ 'style' => [ ('') x 4, FS::UI::Web::cust_styles() ],
+ )
+%>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('List services');
+
+
+my $addl_from = '
+ LEFT JOIN cust_svc USING ( svcnum )
+ LEFT JOIN part_svc USING ( svcpart )
+ LEFT JOIN cust_pkg USING ( pkgnum )
+ LEFT JOIN cust_main USING ( custnum )
+ LEFT JOIN hardware_type USING ( typenum )';
+
+my @extra_sql;
+push @extra_sql, $FS::CurrentUser::CurrentUser->agentnums_sql(
+ 'null_right' => 'View/link unlinked services'
+ );
+
+if ( $cgi->param('magic') =~ /^(unlinked)$/ ) {
+ push @extra_sql, 'pkgnum IS NULL';
+}
+
+if ( lc($cgi->param('serial')) =~ /^(\w+)$/ ) {
+ push @extra_sql, "LOWER(serial) LIKE '%$1%'";
+}
+
+if ( $cgi->param('hw_addr') =~ /^(\S+)$/ ) {
+ my $hw_addr = uc($1);
+ $hw_addr =~ s/\W//g;
+ push @extra_sql, "hw_addr LIKE '%$hw_addr%'";
+}
+
+my $ip = NetAddr::IP->new($cgi->param('ip_addr'));
+if ( $ip ) {
+ push @extra_sql, "ip_addr = '".lc($ip->addr)."'";
+}
+
+if ( $cgi->param('statusnum') =~ /^(\d+)$/ ) {
+ push @extra_sql, "statusnum = $1";
+}
+
+if ( $cgi->param('classnum') =~ /^(\d+)$/ ) {
+ push @extra_sql, "hardware_type.classnum = $1";
+ if ( $cgi->param('classnum'.$1.'typenum') =~ /^(\d+)$/ ) {
+ push @extra_sql, "svc_hardware.typenum = $1";
+ }
+}
+
+my ($orderby) = $cgi->param('orderby') =~ /^(\w+( ASC| DESC)?)$/i;
+$orderby ||= 'svcnum';
+
+my $extra_sql = '';
+$extra_sql = ' WHERE '.join(' AND ', @extra_sql) if @extra_sql;
+
+my $sql_query = {
+ 'table' => 'svc_hardware',
+ 'select' => join(', ',
+ 'svc_hardware.*',
+ 'part_svc.svc',
+ 'cust_main.custnum',
+ 'hardware_type.model',
+ FS::UI::Web::cust_sql_fields(),
+ ),
+ 'hashref' => {},
+ 'extra_sql' => $extra_sql,
+ 'order_by' => "ORDER BY $orderby",
+ 'addl_from' => $addl_from,
+};
+
+my $count_query = "SELECT COUNT(*) FROM svc_hardware $addl_from $extra_sql";
+my $link_svc = [ $p.'view/svc_hardware.cgi?', 'svcnum' ];
+my $link_cust = [ $p.'view/cust_main.cgi?', 'custnum' ];
+
+</%init>