diff options
author | Ivan Kohler <ivan@freeside.biz> | 2013-09-10 01:33:45 -0700 |
---|---|---|
committer | Ivan Kohler <ivan@freeside.biz> | 2013-09-10 01:33:45 -0700 |
commit | a5dce53ac50026bc6caef192100162f1d86a863f (patch) | |
tree | 9462710dd9281662b9e68f3373ffb8fbb066b2e1 | |
parent | ec9b0f903dfa57efc0c82791b9efa74f0c746bc0 (diff) |
svc_cable service have a single serial / MAC / model, not one-to-many devices like svc_phone and svc_dsl, RT#22009
-rw-r--r-- | FS/FS/cable_device.pm | 140 | ||||
-rw-r--r-- | FS/t/cable_device.t | 5 | ||||
-rw-r--r-- | httemplate/edit/cable_device.html | 117 | ||||
-rw-r--r-- | httemplate/edit/process/cable_device.html | 23 |
4 files changed, 0 insertions, 285 deletions
diff --git a/FS/FS/cable_device.pm b/FS/FS/cable_device.pm deleted file mode 100644 index 1a0f1b998..000000000 --- a/FS/FS/cable_device.pm +++ /dev/null @@ -1,140 +0,0 @@ -package FS::cable_device; - -use strict; -use base qw( FS::Record ); -use FS::Record qw( qsearchs ); # qsearch ); -use FS::part_device; -use FS::svc_cable; - -=head1 NAME - -FS::cable_device - Object methods for cable_device records - -=head1 SYNOPSIS - - use FS::cable_device; - - $record = new FS::cable_device \%hash; - $record = new FS::cable_device { 'column' => 'value' }; - - $error = $record->insert; - - $error = $new_record->replace($old_record); - - $error = $record->delete; - - $error = $record->check; - -=head1 DESCRIPTION - -An FS::cable_device object represents a specific customer cable modem. -FS::cable_device inherits from FS::Record. The following fields are currently -supported: - -=over 4 - -=item devicenum - -primary key - -=item devicepart - -devicepart - -=item svcnum - -svcnum - -=item mac_addr - -mac_addr - -=item serial - -serial - - -=back - -=head1 METHODS - -=over 4 - -=item new HASHREF - -Creates a new record. To add the record to the database, see L<"insert">. - -Note that this stores the hash reference, not a distinct copy of the hash it -points to. You can ask the object for a copy with the I<hash> method. - -=cut - -sub table { 'cable_device'; } - -=item insert - -Adds this record to the database. If there is an error, returns the error, -otherwise returns false. - -=item delete - -Delete this record from the database. - -=item replace OLD_RECORD - -Replaces the OLD_RECORD with this one in the database. If there is an error, -returns the error, otherwise returns false. - -=item check - -Checks all fields to make sure this is a valid record. If there is -an error, returns the error, otherwise returns false. Called by the insert -and replace methods. - -=cut - -sub check { - my $self = shift; - - my $mac = $self->mac_addr; - $mac =~ s/\s+//g; - $mac =~ s/://g; - $self->mac_addr($mac); - - my $error = - $self->ut_numbern('devicenum') - || $self->ut_number('devicepart') - || $self->ut_foreign_key('devicepart', 'part_device', 'devicepart') - || $self->ut_foreign_key('svcnum', 'svc_cable', 'svcnum' ) #cust_svc? - || $self->ut_hexn('mac_addr') - || $self->ut_textn('serial') - ; - return $error if $error; - - $self->SUPER::check; -} - -=item part_device - -Returns the device type record (see L<FS::part_device>) associated with this -customer device. - -=cut - -sub part_device { - my $self = shift; - qsearchs( 'part_device', { 'devicepart' => $self->devicepart } ); -} - -=back - -=head1 BUGS - -=head1 SEE ALSO - -L<FS::Record> - -=cut - -1; - diff --git a/FS/t/cable_device.t b/FS/t/cable_device.t deleted file mode 100644 index 016d2c5c1..000000000 --- a/FS/t/cable_device.t +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN { $| = 1; print "1..1\n" } -END {print "not ok 1\n" unless $loaded;} -use FS::cable_device; -$loaded=1; -print "ok 1\n"; diff --git a/httemplate/edit/cable_device.html b/httemplate/edit/cable_device.html deleted file mode 100644 index 963bbf7a8..000000000 --- a/httemplate/edit/cable_device.html +++ /dev/null @@ -1,117 +0,0 @@ -<% include( 'elements/edit.html', - 'name' => 'Cable device', - 'table' => 'cable_device', - 'labels' => { - 'devicenum' => 'Device', - 'devicepart' => 'Device type', - 'mac_addr' => 'MAC address', - 'serial' => 'Serial number', - }, - 'fields' => [ { 'field' => 'devicepart', - 'type' => 'select-table', - 'table' => 'part_device', - 'name_col' => 'devicename', - 'onchange' => 'devicepart_changed', - 'empty_label' =>'Select device type', - #'hashref' =>{ disabled => '' }, - }, - { field => 'mac_addr', - type => 'select-mac', - }, - { field => 'serial', - type => 'text', #select-serial - }, - { 'field' => 'svcnum', - 'type' => 'hidden', - }, - ], - 'menubar' => [], #disable viewall - #'viewall_dir' => 'browse', - 'new_callback' => sub { - my( $cgi, $object ) = @_; - $object->svcnum( $cgi->param('svcnum') ); - }, - 'html_foot' => $html_foot, - ) -%> -<%init> - -#bad: pretty much entirely false laziness w/phone_device, except for labels and -# the serial field - -my @deviceparts_with_inventory = - map $_->devicepart, - qsearch({ 'table' => 'part_device', - 'extra_sql' => 'WHERE inventory_classnum IS NOT NULL', - }); - -my $html_foot = sub { - my $js = " -<SCRIPT TYPE=\"text/javascript\"> - - function opt(what,value,text) { - var optionName = new Option(text, value, false, false); - var length = what.length; - what.options[length] = optionName; - } - - function devicepart_changed(what){ - - var macsel = document.getElementById('sel_mac_addr'); - var mac = document.getElementById('mac_addr'); - - function update_macs(macs) { - for ( var i = macsel.length; i >= 0; i-- ) - macsel.options[i] = null; - - var macArray = eval('(' + macs + ')' ); - if(macArray.length == 0) - opt(macsel,'','No MAC addresses found in inventory for this device type'); - else - opt(macsel,'','Select MAC address'); - - for ( var i = 0; i < macArray.length; i++ ) { - opt(macsel,macArray[i],macArray[i]); - } - - } - - var devicepart = what.options[what.selectedIndex].value; - - var deviceparts_with_inventory = new Array("; -$js .= join(',', map qq("$_"), @deviceparts_with_inventory); -$js .= "); - - var hasInventory = false; - for ( i = 0; i < deviceparts_with_inventory.length; i++ ) { - if ( deviceparts_with_inventory[i] == devicepart ) - hasInventory = true; - } - - - if(hasInventory) { // do the AJAX thing, disable text field - macsel.style.display = 'inline'; - mac.style.display = 'none'; - mac.value = ''; - get_macs( devicepart, update_macs ); - } else { // clear & display text field only, clear/hide select - mac.style.display = 'inline'; - macsel.style.display = 'none'; - macsel.selectedIndex = 0; - } - - } - - devicepart_changed(document.getElementById('devicepart')); -</SCRIPT>"; - - $js; -}; - -# :/ needs agent-virt so you can't futz with arbitrary devices - -die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific? - - -</%init> diff --git a/httemplate/edit/process/cable_device.html b/httemplate/edit/process/cable_device.html deleted file mode 100644 index 97b4f81d9..000000000 --- a/httemplate/edit/process/cable_device.html +++ /dev/null @@ -1,23 +0,0 @@ -<% include( 'elements/process.html', - 'table' => 'cable_device', - 'redirect' => sub { - my( $cgi, $cable_device ) = @_; - #popurl(3).'view/svc_cable.html?'. - popurl(3).'view/svc_Common.html?svcdb=svc_cable;'. - 'svcnum='. $cable_device->svcnum. - ';devicenum='; - }, - ) -%> -<%init> - -if($cgi->param('sel_mac_addr') && !$cgi->param('mac_addr')) { - $cgi->param('mac_addr',$cgi->param('sel_mac_addr')); -} - -# :/ needs agent-virt so you can't futz with arbitrary devices - -die "access denied" - unless $FS::CurrentUser::CurrentUser->access_right('Provision customer service'); #something else more specific? - -</%init> |