svc_dish and svc_hardware fixes, #11454
authormark <mark>
Fri, 29 Apr 2011 08:58:19 +0000 (08:58 +0000)
committermark <mark>
Fri, 29 Apr 2011 08:58:19 +0000 (08:58 +0000)
FS/FS/Schema.pm
FS/FS/svc_dish.pm
FS/FS/svc_hardware.pm
httemplate/browse/hardware_status.html
httemplate/edit/hardware_status.html
httemplate/edit/svc_dish.cgi
httemplate/edit/svc_hardware.cgi
httemplate/search/report_svc_hardware.html
httemplate/search/svc_hardware.cgi
httemplate/view/svc_dish.cgi
httemplate/view/svc_hardware.cgi

index cc0f21f..5d453ac 100644 (file)
@@ -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' => [ ],
index 5dac4f4..e254bf5 100644 (file)
@@ -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;
index 96a8e76..8f037f7 100644 (file)
@@ -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<FS::hardware_status>)
 
 =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')
   ;
index 9695ed3..89ae830 100644 (file)
@@ -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' ],
index ee5f25d..23e5b6e 100644 (file)
@@ -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>
 
index 77a2239..57df498 100644 (file)
@@ -21,6 +21,11 @@ my @fields = (
     label => 'DISH Account #',
   },
   {
+    field => 'installdate',
+    type  => 'input-date-field',
+    label => 'Install date',
+  },
+  {
     field => 'note',
     type  => 'textarea',
     rows  => 4,
index e6cb22b..cde7449 100644 (file)
@@ -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',
index 4a763b0..07a6241 100755 (executable)
@@ -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',
                   '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',
               ) %>
  
   </TABLE>
index ffbb9f3..2ff868e 100644 (file)
@@ -10,6 +10,7 @@
                                      'Serial #',
                                      'Hardware addr.',
                                      'IP addr.',
+                                     'Smartcard',
                                      FS::UI::Web::cust_header(),
                                    ],
             'fields'            => [ 'svcnum',
                                      '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';
+};
+
 </%init>
index d4aa8bf..768c137 100644 (file)
@@ -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'
+              );
 </%init>
index 9cea341..8201e9d 100644 (file)
@@ -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' );
 </%init>