diff options
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Mason.pm | 1 | ||||
-rw-r--r-- | FS/FS/Record.pm | 9 | ||||
-rw-r--r-- | FS/FS/Schema.pm | 13 | ||||
-rw-r--r-- | FS/FS/cable_provider.pm | 112 | ||||
-rw-r--r-- | FS/FS/cust_main.pm | 16 | ||||
-rw-r--r-- | FS/FS/cust_pkg.pm | 24 | ||||
-rw-r--r-- | FS/FS/part_event/Condition/pkg_age_Common.pm | 2 | ||||
-rw-r--r-- | FS/FS/part_export/domain_shellcommands.pm | 3 | ||||
-rw-r--r-- | FS/FS/part_export/shellcommands_withdomain.pm | 27 | ||||
-rw-r--r-- | FS/FS/payby.pm | 12 | ||||
-rw-r--r-- | FS/FS/svc_cable.pm | 60 | ||||
-rw-r--r-- | FS/MANIFEST | 2 | ||||
-rw-r--r-- | FS/t/cable_provider.t | 5 |
13 files changed, 243 insertions, 43 deletions
diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm index f1fc5cba4..1215ca414 100644 --- a/FS/FS/Mason.pm +++ b/FS/FS/Mason.pm @@ -355,6 +355,7 @@ if ( -e $addl_handler_use_file ) { use FS::cable_model; use FS::invoice_mode; use FS::invoice_conf; + use FS::cable_provider; # Sammath Naur if ( $FS::Mason::addl_handler_use ) { diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index fd035249b..71eddc1eb 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -3038,13 +3038,8 @@ Checks to see if the string is encrypted and returns true or false (1/0) to indi sub is_encrypted { my ($self, $value) = @_; - # Possible Bug - Some work may be required here.... - - if ($value =~ /^M/ && length($value) > 80) { - return 1; - } else { - return 0; - } + # could be more precise about it, but this will do for now + $value =~ /^M/ && length($value) > 80; } =item decrypt($value) diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 5ea24e43a..e44b74edc 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -4272,6 +4272,8 @@ sub tables_hashref { 'svc_cable' => { 'columns' => [ 'svcnum', 'int', '', '', '', '', + 'providernum', 'int', 'NULL', '', '', '', + # XXX "Circuit ID/Order number" 'modelnum', 'int', 'NULL', '', '', '', 'serialnum', 'varchar', 'NULL', $char_d, '', '', 'mac_addr', 'varchar', 'NULL', 12, '', '', @@ -4292,6 +4294,17 @@ sub tables_hashref { 'index' => [], }, + 'cable_provider' => { + 'columns' => [ + 'providernum', 'serial', '', '', '', '', + 'provider', 'varchar', '', $char_d, '', '', + 'disabled', 'char', 'NULL', 1, '', '', + ], + 'primary_key' => 'providernum', + 'unique' => [ [ 'provider' ], ], + 'index' => [], + }, + 'vend_main' => { 'columns' => [ 'vendnum', 'serial', '', '', '', '', diff --git a/FS/FS/cable_provider.pm b/FS/FS/cable_provider.pm new file mode 100644 index 000000000..e988192f4 --- /dev/null +++ b/FS/FS/cable_provider.pm @@ -0,0 +1,112 @@ +package FS::cable_provider; + +use strict; +use base qw( FS::Record ); +use FS::Record qw( qsearch qsearchs ); + +=head1 NAME + +FS::cable_provider - Object methods for cable_provider records + +=head1 SYNOPSIS + + use FS::cable_provider; + + $record = new FS::cable_provider \%hash; + $record = new FS::cable_provider { 'column' => 'value' }; + + $error = $record->insert; + + $error = $new_record->replace($old_record); + + $error = $record->delete; + + $error = $record->check; + +=head1 DESCRIPTION + +An FS::cable_provider object represents a cable service provider. +FS::cable_provider inherits from FS::Record. The following fields are +currently supported: + +=over 4 + +=item providernum + +primary key + +=item provider + +provider + +=item disabled + +disabled + + +=back + +=head1 METHODS + +=over 4 + +=item new HASHREF + +Creates a new provider. To add the provider 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 + +# the new method can be inherited from FS::Record, if a table method is defined + +sub table { 'cable_provider'; } + +=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 provider. 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 $error = + $self->ut_numbern('providernum') + || $self->ut_text('provider') + || $self->ut_enum('disabled', [ '', 'Y' ] ) + ; + return $error if $error; + + $self->SUPER::check; +} + +=back + +=head1 BUGS + +=head1 SEE ALSO + +L<FS::Record>, schema.html from the base documentation. + +=cut + +1; + diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index e39312504..a9a4cb0ef 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -2097,6 +2097,21 @@ sub cust_contact { qsearch('contact', { 'custnum' => $self->custnum } ); } +=item cust_payby + +Returns all payment methods (see L<FS::cust_payby>) for this customer. + +=cut + +sub cust_payby { + my $self = shift; + qsearch({ + 'table' => 'cust_payby', + 'hashref' => { 'custnum' => $self->custnum }, + 'order_by' => 'ORDER BY weight ASC', + }); +} + =item unsuspend Unsuspends all unflagged suspended packages (see L</unflagged_suspended_pkgs> @@ -5140,7 +5155,6 @@ sub _upgrade_data { #class method die $error if $error; $cust_main->setfield($_, '') foreach @payfields; - #$DEBUG = 2; $error = $cust_main->replace; die $error if $error; diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 19ef1f326..0cb1b50a2 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -2613,14 +2613,30 @@ sub part_pkg_currency_option { =item cust_svc [ OPTION => VALUE ... ] (current usage) +=item cust_svc_unsorted [ OPTION => VALUE ... ] + Returns the services for this package, as FS::cust_svc objects (see L<FS::cust_svc>). Available options are svcpart and svcdb. If either is spcififed, returns only the matching services. +As an optimization, use the cust_svc_unsorted version if you are not displaying +the results. + =cut sub cust_svc { my $self = shift; + cluck "cust_pkg->cust_svc called" if $DEBUG > 2; + $self->_sort_cust_svc( $self->cust_svc_unsorted_arrayref ); +} + +sub cust_svc_unsorted { + my $self = shift; + @{ $self->cust_svc_unsorted_arrayref }; +} + +sub cust_svc_unsorted_arrayref { + my $self = shift; return () unless $self->num_cust_svc(@_); @@ -2645,13 +2661,7 @@ sub cust_svc { $search{extra_sql} = ' AND svcdb = '. dbh->quote( $opt{'svcdb'} ); } - cluck "cust_pkg->cust_svc called" if $DEBUG > 2; - - #if ( $self->{'_svcnum'} ) { - # values %{ $self->{'_svcnum'}->cache }; - #} else { - $self->_sort_cust_svc( [ qsearch(\%search) ] ); - #} + [ qsearch(\%search) ]; } diff --git a/FS/FS/part_event/Condition/pkg_age_Common.pm b/FS/FS/part_event/Condition/pkg_age_Common.pm index 726b01d70..33e49b8a6 100644 --- a/FS/FS/part_event/Condition/pkg_age_Common.pm +++ b/FS/FS/part_event/Condition/pkg_age_Common.pm @@ -49,7 +49,7 @@ sub condition { } sub pkg_age_age { - my( $self, $cust_pkg, %opt ); + my( $self, $cust_pkg, %opt ) = @_; $self->option_age_from('age', $opt{'time'} ); } diff --git a/FS/FS/part_export/domain_shellcommands.pm b/FS/FS/part_export/domain_shellcommands.pm index 582e29217..8e85d71e1 100644 --- a/FS/FS/part_export/domain_shellcommands.pm +++ b/FS/FS/part_export/domain_shellcommands.pm @@ -49,8 +49,7 @@ The following variables are available for interpolation (prefixed with <code>new <LI><code>$uid</code> - of catchall account <LI><code>$gid</code> - of catchall account <LI><code>$dir</code> - home directory of catchall account - <LI>All other fields in - <a href="../docs/schema.html#svc_domain">svc_domain</a> are also available. + <LI>All other fields in <b>svc_domain</b> are also available. </UL> END ); diff --git a/FS/FS/part_export/shellcommands_withdomain.pm b/FS/FS/part_export/shellcommands_withdomain.pm index 1b59589bf..29715b75b 100644 --- a/FS/FS/part_export/shellcommands_withdomain.pm +++ b/FS/FS/part_export/shellcommands_withdomain.pm @@ -141,7 +141,32 @@ The following variables are available for interpolation (prefixed with <LI><code>$shell</code> <LI><code>$quota</code> <LI><code>@radius_groups</code> - <LI>All other fields in <a href="../docs/schema.html#svc_acct">svc_acct</a> are also available. + <LI><code>$reasonnum (when suspending)</code> + <LI><code>$reasontext (when suspending)</code> + <LI><code>$reasontypenum (when suspending)</code> + <LI><code>$reasontypetext (when suspending)</code> + <LI><code>$pkgnum</code> + <LI><code>$custnum</code> + <LI>All other fields in <b>svc_acct</b> are also available. + <LI>The following fields from <b>cust_main</b> are also available (except during replace): company, address1, address2, city, state, zip, county, daytime, night, fax, otaker, agent_custid, locale. When used on the command line (rather than STDIN), they will be quoted for the shell already (do not add additional quotes). +</UL> +For the package changed command only, the following fields are also available: +<UL> + <LI>$old_pkgnum and $new_pkgnum + <LI>$old_pkgpart and $new_pkgpart + <LI>$old_agent_pkgid and $new_agent_pkgid + <LI>$old_order_date and $new_order_date + <LI>$old_start_date and $new_start_date + <LI>$old_setup and $new_setup + <LI>$old_bill and $new_bill + <LI>$old_last_bill and $new_last_bill + <LI>$old_susp and $new_susp + <LI>$old_adjourn and $new_adjourn + <LI>$old_resume and $new_resume + <LI>$old_cancel and $new_cancel + <LI>$old_unancel and $new_unancel + <LI>$old_expire and $new_expire + <LI>$old_contract_end and $new_contract_end </UL> END ); diff --git a/FS/FS/payby.pm b/FS/FS/payby.pm index e223a050f..b33f8f3d1 100644 --- a/FS/FS/payby.pm +++ b/FS/FS/payby.pm @@ -70,12 +70,12 @@ tie %hash, 'Tie::IxHash', cust_pay => 'CHEK', #this is a customer type only, payments are CHEK... realtime => 1, }, - 'LECB' => { - tinyname => 'phone bill', - shortname => 'Phone bill billing', - longname => 'Phone bill billing', - realtime => 1, - }, + #'LECB' => { + # tinyname => 'phone bill', + # shortname => 'Phone bill billing', + # longname => 'Phone bill billing', + # realtime => 1, + #}, 'BILL' => { tinyname => 'billing', shortname => 'Billing', diff --git a/FS/FS/svc_cable.pm b/FS/FS/svc_cable.pm index 1980c0ee9..596f69995 100644 --- a/FS/FS/svc_cable.pm +++ b/FS/FS/svc_cable.pm @@ -4,6 +4,7 @@ use base qw( FS::svc_Common ); #qw( FS::device_Common FS::svc_Common ); use strict; use Tie::IxHash; use FS::Record qw( qsearchs ); # qw( qsearch qsearchs ); +use FS::cable_provider; use FS::cable_model; =head1 NAME @@ -72,24 +73,35 @@ sub search_sql { sub table_info { tie my %fields, 'Tie::IxHash', - 'svcnum' => 'Service', - 'modelnum' => { label => 'Model', - type => 'select-cable_model', - disable_inventory => 1, - disable_select => 1, - value_callback => sub { - my $svc = shift; - $svc->cable_model->model_name; - }, - }, - 'serialnum' => 'Serial number', - 'mac_addr' => { label => 'MAC address', - type => 'input-mac_addr', - value_callback => sub { - my $svc = shift; - join(':', $svc->mac_addr =~ /../g); - }, - }, + 'svcnum' => 'Service', + 'providernum' => { label => 'Provider', + type => 'select-cable_provider', + disable_inventory => 1, + disable_select => 1, + value_callback => sub { + my $svc = shift; + my $p = $svc->cable_provider; + $p ? $p->provider : ''; + }, + }, + #XXX "Circuit ID/Order number" + 'modelnum' => { label => 'Model', + type => 'select-cable_model', + disable_inventory => 1, + disable_select => 1, + value_callback => sub { + my $svc = shift; + $svc->cable_model->model_name; + }, + }, + 'serialnum' => 'Serial number', + 'mac_addr' => { label => 'MAC address', + type => 'input-mac_addr', + value_callback => sub { + my $svc = shift; + join(':', $svc->mac_addr =~ /../g); + }, + }, ; { @@ -130,6 +142,7 @@ sub check { my $error = $self->ut_numbern('svcnum') + || $self->ut_foreign_key('providernum', 'cable_provider', 'providernum') || $self->ut_foreign_key('modelnum', 'cable_model', 'modelnum') || $self->ut_alpha('serialnum') || $self->ut_mac_addr('mac_addr') @@ -139,6 +152,17 @@ sub check { $self->SUPER::check; } +=item cable_provider + +Returns the cable_provider object for this record. + +=cut + +sub cable_provider { + my $self = shift; + qsearchs('cable_provider', { 'providernum'=>$self->providernum } ); +} + =item cable_model Returns the cable_model object for this record. diff --git a/FS/MANIFEST b/FS/MANIFEST index 339965ef3..5dbe754c1 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -724,3 +724,5 @@ FS/invoice_mode.pm t/invoice_mode.t FS/invoice_conf.pm t/invoice_conf.t +FS/cable_provider.pm +t/cable_provider.t diff --git a/FS/t/cable_provider.t b/FS/t/cable_provider.t new file mode 100644 index 000000000..c794379a9 --- /dev/null +++ b/FS/t/cable_provider.t @@ -0,0 +1,5 @@ +BEGIN { $| = 1; print "1..1\n" } +END {print "not ok 1\n" unless $loaded;} +use FS::cable_provider; +$loaded=1; +print "ok 1\n"; |