summaryrefslogtreecommitdiff
path: root/FS/FS
diff options
context:
space:
mode:
authorlevinse <levinse>2010-12-10 06:02:53 +0000
committerlevinse <levinse>2010-12-10 06:02:53 +0000
commit457da870c23db87fbbc29d7c667a73f41422dd71 (patch)
treeea61844254e2338dc20cc85e1cbc30b006b731a3 /FS/FS
parent6568e7bb436d6ac4ae2ec984446e8fc4a999f0af (diff)
implement customer note classes, RT9995
Diffstat (limited to 'FS/FS')
-rw-r--r--FS/FS/Conf.pm12
-rw-r--r--FS/FS/Mason.pm1
-rw-r--r--FS/FS/Schema.pm12
-rw-r--r--FS/FS/cust_main.pm7
-rw-r--r--FS/FS/cust_main_note.pm34
-rw-r--r--FS/FS/cust_note_class.pm105
6 files changed, 168 insertions, 3 deletions
diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm
index bcebdf6..ebeebb2 100644
--- a/FS/FS/Conf.pm
+++ b/FS/FS/Conf.pm
@@ -4090,6 +4090,18 @@ and customer address. Include units.',
'description' => 'Enable the alternate address format (location type, number, and kind) on qualifications',
'type' => 'checkbox',
},
+
+ {
+ 'key' => 'note-classes',
+ 'section' => 'UI',
+ 'description' => 'Use customer note classes',
+ 'type' => 'select',
+ 'select_hash' => [
+ 0 => 'Disabled',
+ 1 => 'Enabled',
+ 2 => 'Enabled, with tabs',
+ ],
+ },
{ key => "apacheroot", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
{ key => "apachemachine", section => "deprecated", description => "<b>DEPRECATED</b>", type => "text" },
diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm
index 3b46d77..9b010e8 100644
--- a/FS/FS/Mason.pm
+++ b/FS/FS/Mason.pm
@@ -263,6 +263,7 @@ if ( -e $addl_handler_use_file ) {
use FS::qual_option;
use FS::dsl_note;
use FS::part_pkg_vendor;
+ use FS::cust_note_class;
# Sammath Naur
if ( $FS::Mason::addl_handler_use ) {
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm
index 48363ce..70aab43 100644
--- a/FS/FS/Schema.pm
+++ b/FS/FS/Schema.pm
@@ -932,6 +932,7 @@ sub tables_hashref {
'columns' => [
'notenum', 'serial', '', '', '', '',
'custnum', 'int', '', '', '', '',
+ 'classnum', 'int', 'NULL', '', '', '',
'_date', @date_type, '', '',
'otaker', 'varchar', 'NULL', 32, '', '',
'usernum', 'int', 'NULL', '', '', '',
@@ -941,6 +942,17 @@ sub tables_hashref {
'unique' => [],
'index' => [ [ 'custnum' ], [ '_date' ], [ 'usernum' ], ],
},
+
+ 'cust_note_class' => {
+ 'columns' => [
+ 'classnum', 'serial', '', '', '', '',
+ 'classname', 'varchar', '', $char_d, '', '',
+ 'disabled', 'char', 'NULL', 1, '', '',
+ ],
+ 'primary_key' => 'classnum',
+ 'unique' => [],
+ 'index' => [ ['disabled'] ],
+ },
'cust_category' => {
'columns' => [
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index 03e8cc6..03154ad 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -2209,12 +2209,13 @@ Returns all notes (see L<FS::cust_main_note>) for this customer.
=cut
sub notes {
- my $self = shift;
- #order by?
+ my($self,$orderby_classnum) = (shift,shift);
+ my $orderby = "_DATE DESC";
+ $orderby = "CLASSNUM ASC, $orderby" if $orderby_classnum;
qsearch( 'cust_main_note',
{ 'custnum' => $self->custnum },
'',
- 'ORDER BY _DATE DESC'
+ "ORDER BY $orderby",
);
}
diff --git a/FS/FS/cust_main_note.pm b/FS/FS/cust_main_note.pm
index 0a203a8..06da096 100644
--- a/FS/FS/cust_main_note.pm
+++ b/FS/FS/cust_main_note.pm
@@ -4,6 +4,7 @@ use strict;
use base qw( FS::otaker_Mixin FS::Record );
use Carp;
use FS::Record qw( qsearch qsearchs );
+use FS::cust_note_class;
=head1 NAME
@@ -38,6 +39,8 @@ primary key
=item custnum
+=item classnum
+
=item _date
=item usernum
@@ -106,6 +109,7 @@ sub check {
my $error =
$self->ut_numbern('notenum')
|| $self->ut_number('custnum')
+ || $self->ut_foreign_keyn('classnum', 'cust_note_class', 'classnum')
|| $self->ut_numbern('_date')
|| $self->ut_textn('otaker')
|| $self->ut_anything('comments')
@@ -115,6 +119,36 @@ sub check {
$self->SUPER::check;
}
+=item cust_note_class
+
+Returns the customer note class, as an FS::cust_note_class object, or the empty
+string if there is no note class.
+
+=cut
+
+sub cust_note_class {
+ my $self = shift;
+ if ( $self->classnum ) {
+ qsearchs('cust_note_class', { 'classnum' => $self->classnum } );
+ } else {
+ return '';
+ }
+}
+
+=item classname
+
+Returns the customer note class name, or the empty string if there is no
+customer note class.
+
+=cut
+
+sub classname {
+ my $self = shift;
+ my $cust_note_class = $self->cust_note_class;
+ $cust_note_class ? $cust_note_class->classname : '';
+}
+
+
#false laziness w/otaker_Mixin & cust_attachment
sub otaker {
my $self = shift;
diff --git a/FS/FS/cust_note_class.pm b/FS/FS/cust_note_class.pm
new file mode 100644
index 0000000..0cb9677
--- /dev/null
+++ b/FS/FS/cust_note_class.pm
@@ -0,0 +1,105 @@
+package FS::cust_note_class;
+
+use strict;
+use base qw( FS::class_Common );
+use FS::cust_main_note;
+
+=head1 NAME
+
+FS::cust_note_class - Object methods for cust_note_class records
+
+=head1 SYNOPSIS
+
+ use FS::cust_note_class;
+
+ $record = new FS::cust_note_class \%hash;
+ $record = new FS::cust_note_class { 'column' => 'value' };
+
+ $error = $record->insert;
+
+ $error = $new_record->replace($old_record);
+
+ $error = $record->delete;
+
+ $error = $record->check;
+
+=head1 DESCRIPTION
+
+An FS::cust_note_class object represents a customer note class. Every customer
+note (see L<FS::cust_main_note) has, optionally, a note class. This class
+inherits from FS::class_Common. The following fields are currently supported:
+
+=over 4
+
+=item classnum
+
+primary key
+
+=item classname
+
+classname
+
+=item disabled
+
+disabled
+
+
+=back
+
+=head1 METHODS
+
+=over 4
+
+=item new HASHREF
+
+Creates a new customer note class. To add the note class 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 { 'cust_note_class'; }
+sub _target_table { 'cust_main_note'; }
+
+=item insert
+
+Adds this record to the database. If there is an error, returns the error,
+otherwise returns false.
+
+=cut
+
+=item delete
+
+Delete this record from the database.
+
+=cut
+
+=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
+
+=item check
+
+Checks all fields to make sure this is a valid note class. If there is
+an error, returns the error, otherwise returns false. Called by the insert
+and replace methods.
+
+=cut
+
+=back
+
+=head1 BUGS
+
+=head1 SEE ALSO
+
+L<FS::cust_main_note>, L<FS::Record>, schema.html from the base documentation.
+
+=cut
+
+1;
+