From 91fd4ea0e91ee9e6717e0b12e01eebb8f8b21322 Mon Sep 17 00:00:00 2001 From: mark Date: Fri, 29 Apr 2011 08:58:19 +0000 Subject: [PATCH] svc_dish and svc_hardware fixes, #11454 --- FS/FS/Schema.pm | 5 ++++- FS/FS/svc_dish.pm | 8 ++++++-- FS/FS/svc_hardware.pm | 4 ++++ httemplate/browse/hardware_status.html | 2 ++ httemplate/edit/hardware_status.html | 24 ++++++++++++++++-------- httemplate/edit/svc_dish.cgi | 5 +++++ httemplate/edit/svc_hardware.cgi | 6 ++++++ httemplate/search/report_svc_hardware.html | 10 +++++++++- httemplate/search/svc_hardware.cgi | 26 ++++++++++++++++++++++---- httemplate/view/svc_dish.cgi | 5 ++++- httemplate/view/svc_hardware.cgi | 2 +- 11 files changed, 79 insertions(+), 18 deletions(-) diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index cc0f21ffc..5d453ac27 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -2022,6 +2022,7 @@ sub tables_hashref { 'columns' => [ 'svcnum', 'int', '', '', '', '', 'acctnum', 'varchar', '', 16, '', '', + 'installdate', @date_type, '', '', 'note', 'text', 'NULL', '', '', '', ], 'primary_key' => 'svcnum', @@ -2036,7 +2037,8 @@ sub tables_hashref { 'serial', 'varchar', 'NULL', $char_d, '', '', 'ip_addr', 'varchar', 'NULL', 40, '', '', 'hw_addr', 'varchar', 'NULL', 12, '', '', - 'statusnum','int', 'NULL', '', '', '', + 'smartcard','varchar', 'NULL', 30, '', '', + 'statusnum','int', 'NULL', '', '', '', 'note', 'text', 'NULL', '', '', '', ], 'primary_key' => 'svcnum', @@ -2069,6 +2071,7 @@ sub tables_hashref { 'columns' => [ 'statusnum', 'serial', '', '', '', '', 'label' ,'varchar', '', $char_d, '', '', + 'disabled', 'char', 'NULL', 1, '', '', ], 'primary_key' => 'statusnum', 'unique' => [ ], diff --git a/FS/FS/svc_dish.pm b/FS/FS/svc_dish.pm index 5dac4f4d5..e254bf5d3 100644 --- a/FS/FS/svc_dish.pm +++ b/FS/FS/svc_dish.pm @@ -36,6 +36,8 @@ The following fields are currently supported: =item acctnum - DISH account number +=item installdate - Installation date (as Unix timestamp) + =item note - Installation notes: location on property, physical access, etc. =back @@ -62,8 +64,9 @@ sub table_info { 'display_weight' => 58, 'cancel_weight' => 85, 'fields' => { - 'svcnum' => { label => 'Service' }, - 'acctnum' => { label => 'DISH account#', %opts }, + 'svcnum' => { label => 'Service' }, + 'acctnum' => { label => 'DISH account#', %opts }, + 'installdate' => { label => 'Install date', %opts }, 'note' => { label => 'Installation notes', %opts }, } } @@ -112,6 +115,7 @@ sub check { my $error = $self->ut_numbern('svcnum') || $self->ut_text('acctnum') + || $self->ut_numbern('installdate') || $self->ut_textn('note') ; return $error if $error; diff --git a/FS/FS/svc_hardware.pm b/FS/FS/svc_hardware.pm index 96a8e762b..8f037f712 100644 --- a/FS/FS/svc_hardware.pm +++ b/FS/FS/svc_hardware.pm @@ -45,6 +45,8 @@ The following fields are currently supported: =item serial - Serial number +=item smartcard - Smartcard number, for devices that use a smartcard + =item statusnum - Service status (see L) =item note - Installation notes: location on property, physical access, etc. @@ -82,6 +84,7 @@ sub table_info { 'serial' => { label => 'Serial number', %opts }, 'hw_addr' => { label => 'Hardware address', %opts }, 'ip_addr' => { label => 'IP address', %opts }, + 'smartcard' => { label => 'Smartcard #', %opts }, 'statusnum' => { label => 'Service status', type => 'select', select_table => 'hardware_status', @@ -165,6 +168,7 @@ sub check { || $self->ut_ip46n('ip_addr') || $self->ut_hexn('hw_addr') || $self->ut_alphan('serial') + || $self->ut_alphan('smartcard') || $self->ut_foreign_keyn('statusnum', 'hardware_status', 'statusnum') || $self->ut_textn('note') ; diff --git a/httemplate/browse/hardware_status.html b/httemplate/browse/hardware_status.html index 9695ed399..89ae83035 100644 --- a/httemplate/browse/hardware_status.html +++ b/httemplate/browse/hardware_status.html @@ -2,6 +2,8 @@ 'title' => 'Hardware Statuses', 'name' => 'hardware statuses', 'menubar' => $menubar, + 'disableable' => 1, + 'disabled_statuspos' => 2, 'query' => { 'table' => 'hardware_status', }, 'count_query' => 'SELECT COUNT(*) FROM hardware_status', 'header' => [ '#', 'Status' ], diff --git a/httemplate/edit/hardware_status.html b/httemplate/edit/hardware_status.html index ee5f25db8..23e5b6eba 100644 --- a/httemplate/edit/hardware_status.html +++ b/httemplate/edit/hardware_status.html @@ -1,12 +1,20 @@ <% include( 'elements/edit.html', - 'name' => 'Hardware Status', - 'table' => 'hardware_status', - 'labels' => { - 'statusnum' => 'Status number', - 'label' => 'Description' , - }, - 'viewall_dir' => 'browse', - ) + 'name_singular' => 'Hardware Status', + 'table' => 'hardware_status', + 'labels' => { + 'statusnum' => 'Status number', + 'label' => 'Description' , + 'disabled' => 'Disable status' + }, + 'fields' => [ + 'label', + { field => 'disabled', + type => 'checkbox', + value => 'Y', + }, + ], + 'viewall_dir' => 'browse', + ) %> <%init> diff --git a/httemplate/edit/svc_dish.cgi b/httemplate/edit/svc_dish.cgi index 77a223933..57df49846 100644 --- a/httemplate/edit/svc_dish.cgi +++ b/httemplate/edit/svc_dish.cgi @@ -21,6 +21,11 @@ my @fields = ( label => 'DISH Account #', }, { + field => 'installdate', + type => 'input-date-field', + label => 'Install date', + }, + { field => 'note', type => 'textarea', rows => 4, diff --git a/httemplate/edit/svc_hardware.cgi b/httemplate/edit/svc_hardware.cgi index e6cb22bcb..cde74490e 100644 --- a/httemplate/edit/svc_hardware.cgi +++ b/httemplate/edit/svc_hardware.cgi @@ -35,12 +35,18 @@ my @fields = ( label => 'IP address', }, { + field => 'smartcard', + type => 'text', + label => 'Smartcard #', + }, + { field => 'statusnum', type => 'select-table', table => 'hardware_status', label => 'Service status', name_col => 'label', disable_empty => 1, + hashref => { 'disabled' => '' }, }, { field => 'note', diff --git a/httemplate/search/report_svc_hardware.html b/httemplate/search/report_svc_hardware.html index 4a763b0b4..07a6241e3 100755 --- a/httemplate/search/report_svc_hardware.html +++ b/httemplate/search/report_svc_hardware.html @@ -20,7 +20,7 @@ <% include('/elements/tr-input-text.html', 'field' => 'serial', - 'label' => 'Serial #', + 'label' => 'Serial number', ) %> <% include('/elements/tr-input-text.html', 'field' => 'hw_addr', @@ -30,12 +30,20 @@ 'field' => 'ip_addr', 'label' => 'IP address', ) %> + <% include('/elements/tr-input-text.html', + 'field' => 'smartcard', + 'label' => 'Smartcard #', + ) %> <% include('/elements/tr-select-table.html', 'field' => 'statusnum', 'label' => 'Service status', 'table' => 'hardware_status', 'name_col' => 'label', 'empty_label' => 'any', + 'hashref' => {}, + 'extra_sql' => ' WHERE hardware_status.disabled IS NULL +OR (SELECT COUNT(*) FROM svc_hardware + WHERE svc_hardware.statusnum = hardware_status.statusnum) > 0', ) %> diff --git a/httemplate/search/svc_hardware.cgi b/httemplate/search/svc_hardware.cgi index ffbb9f3b6..2ff868ef5 100644 --- a/httemplate/search/svc_hardware.cgi +++ b/httemplate/search/svc_hardware.cgi @@ -10,6 +10,7 @@ 'Serial #', 'Hardware addr.', 'IP addr.', + 'Smartcard', FS::UI::Web::cust_header(), ], 'fields' => [ 'svcnum', @@ -18,16 +19,19 @@ 'serial', 'hw_addr', 'ip_addr', + 'smartcard', \&FS::UI::Web::cust_fields, ], - 'links' => [ ($link_svc) x 6, + 'links' => [ ($link_svc) x 7, ( 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() ], + 'align' => 'rllllll' . FS::UI::Web::cust_aligns(), + 'color' => [ ('') x 7, + FS::UI::Web::cust_colors() ], + 'style' => [ $svc_cancel_style, ('') x 6, + FS::UI::Web::cust_styles() ], ) %> <%init> @@ -67,6 +71,10 @@ if ( $ip ) { push @extra_sql, "ip_addr = '".lc($ip->addr)."'"; } +if ( lc($cgi->param('smartcard')) =~ /^(\w+)$/ ) { + push @extra_sql, "LOWER(smartcard) LIKE '%$1%'"; +} + if ( $cgi->param('statusnum') =~ /^(\d+)$/ ) { push @extra_sql, "statusnum = $1"; } @@ -78,6 +86,10 @@ if ( $cgi->param('classnum') =~ /^(\d+)$/ ) { } } +if ( $cgi->param('svcpart') =~ /^(\d+)$/ ) { + push @extra_sql, "cust_svc.svcpart = $1"; +} + my ($orderby) = $cgi->param('orderby') =~ /^(\w+( ASC| DESC)?)$/i; $orderby ||= 'svcnum'; @@ -91,6 +103,7 @@ my $sql_query = { 'part_svc.svc', 'cust_main.custnum', 'hardware_type.model', + 'cust_pkg.cancel', FS::UI::Web::cust_sql_fields(), ), 'hashref' => {}, @@ -103,4 +116,9 @@ 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' ]; +my $svc_cancel_style = sub { + my $svc = shift; + ( $svc->getfield('cancel') == 0 ) ? '' : 's'; +}; + diff --git a/httemplate/view/svc_dish.cgi b/httemplate/view/svc_dish.cgi index d4aa8bfdf..768c1372f 100644 --- a/httemplate/view/svc_dish.cgi +++ b/httemplate/view/svc_dish.cgi @@ -12,5 +12,8 @@ my %labels = map { $_ => ( ref($fields->{$_}) : $fields->{$_} ); } keys %$fields; -my @fields = qw( acctnum note ); +my @fields = ('acctnum', + { field => 'installdate', type => 'date' }, + 'note' + ); diff --git a/httemplate/view/svc_hardware.cgi b/httemplate/view/svc_hardware.cgi index 9cea341d7..8201e9db0 100644 --- a/httemplate/view/svc_hardware.cgi +++ b/httemplate/view/svc_hardware.cgi @@ -20,5 +20,5 @@ my $status = { field => 'statusnum', type => 'text', value => sub { $_[0]->status_label } }; -my @fields = ($model, qw( serial hw_addr ip_addr ), $status, 'note' ); +my @fields = ($model, qw( serial hw_addr ip_addr smartcard ), $status, 'note' ); -- 2.11.0