diff options
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Mason.pm | 1 | ||||
-rw-r--r-- | FS/FS/Schema.pm | 18 | ||||
-rw-r--r-- | FS/FS/part_svc.pm | 27 | ||||
-rw-r--r-- | FS/FS/part_svc_msgcat.pm | 131 |
4 files changed, 176 insertions, 1 deletions
diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm index 24ddf7920..d625fbd53 100644 --- a/FS/FS/Mason.pm +++ b/FS/FS/Mason.pm @@ -412,6 +412,7 @@ if ( -e $addl_handler_use_file ) { use FS::fiber_olt; use FS::olt_site; use FS::access_user_page_pref; + use FS::part_svc_msgcat; # Sammath Naur if ( $FS::Mason::addl_handler_use ) { diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 361360a6e..748df8b1b 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -3698,6 +3698,24 @@ sub tables_hashref { ], }, + 'part_svc_msgcat' => { + 'columns' => [ + 'svcpartmsgnum', 'serial', '', '', '', '', + 'svcpart', 'int', '', '', '', '', + 'locale', 'varchar', '', 16, '', '', + 'svc', 'varchar', '', $char_d, '', '', + ], + 'primary_key' => 'svcpartmsgnum', + 'unique' => [ [ 'svcpart', 'locale' ] ], + 'index' => [], + 'foreign_keys' => [ + { columns => [ 'svcpart' ], + table => 'part_svc', + }, + ], + }, + + #(this should be renamed to part_pop) 'svc_acct_pop' => { 'columns' => [ diff --git a/FS/FS/part_svc.pm b/FS/FS/part_svc.pm index 621a55410..dcc78435b 100644 --- a/FS/FS/part_svc.pm +++ b/FS/FS/part_svc.pm @@ -1,5 +1,5 @@ package FS::part_svc; -use base qw(FS::Record); +use base qw(FS::o2m_Common FS::Record); use strict; use vars qw( $DEBUG ); @@ -11,6 +11,7 @@ use FS::part_export; use FS::export_svc; use FS::cust_svc; use FS::part_svc_class; +use FS::part_svc_msgcat; FS::UID->install_callback(sub { # preload the cache and make sure all modules load @@ -621,6 +622,24 @@ sub svc_x { map { $_->svc_x } $self->cust_svc; } +=item svc_locale LOCALE + +Returns a customer-viewable service definition label in the chosen LOCALE. +If there is no entry for that locale or if LOCALE is empty, returns +part_svc.svc. + +=cut + +sub svc_locale { + my( $self, $locale ) = @_; + return $self->svc unless $locale; + my $part_svc_msgcat = qsearchs('part_svc_msgcat', { + svcpart => $self->svcpart, + locale => $locale + }) or return $self->svc; + $part_svc_msgcat->svc; +} + =back =head1 CLASS METHODS @@ -883,6 +902,12 @@ sub process { $param->{'svcpart'} = $new->getfield('svcpart'); } + $error ||= $new->process_o2m( + 'table' => 'part_svc_msgcat', + 'params' => $param, + 'fields' => [ 'locale', 'svc' ], + ); + die "$error\n" if $error; } diff --git a/FS/FS/part_svc_msgcat.pm b/FS/FS/part_svc_msgcat.pm new file mode 100644 index 000000000..6d69198ec --- /dev/null +++ b/FS/FS/part_svc_msgcat.pm @@ -0,0 +1,131 @@ +package FS::part_svc_msgcat; +use base qw( FS::Record ); + +use strict; +use FS::Locales; + +=head1 NAME + +FS::part_svc_msgcat - Object methods for part_svc_msgcat records + +=head1 SYNOPSIS + + use FS::part_svc_msgcat; + + $record = new FS::part_svc_msgcat \%hash; + $record = new FS::part_svc_msgcat { 'column' => 'value' }; + + $error = $record->insert; + + $error = $new_record->replace($old_record); + + $error = $record->delete; + + $error = $record->check; + +=head1 DESCRIPTION + +An FS::part_svc_msgcat object represents localized labels of a service +definition. FS::part_svc_msgcat inherits from FS::Record. The following +fields are currently supported: + +=over 4 + +=item svcpartmsgnum + +primary key + +=item svcpart + +Service definition + +=item locale + +locale + +=item svc + +Localized service name (customer-viewable) + +=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 + +# the new method can be inherited from FS::Record, if a table method is defined + +sub table { 'part_svc_msgcat'; } + +=item insert + +Adds this record to the database. If there is an error, returns the error, +otherwise returns false. + +=cut + +# the insert method can be inherited from FS::Record + +=item delete + +Delete this record from the database. + +=cut + +# the delete method can be inherited from FS::Record + +=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. + +=cut + +# the replace method can be inherited from FS::Record + +=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 + +# the check method should currently be supplied - FS::Record contains some +# data checking routines + +sub check { + my $self = shift; + + my $error = + $self->ut_numbern('svcpartmsgnum') + || $self->ut_foreign_key('svcpart', 'part_svc', 'svcpart') + || $self->ut_enum('locale', [ FS::Locales->locales ] ) + || $self->ut_text('svc') + ; + return $error if $error; + + $self->SUPER::check; +} + +=back + +=head1 BUGS + +=head1 SEE ALSO + +L<FS::part_svc>, L<FS::Record>, schema.html from the base documentation. + +=cut + +1; + |