X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fcust_main_note.pm;h=2288d7c4e00e24a83675d9c7eef621153d325029;hp=0a203a8f41424a13628d467e461f080db461e963;hb=bb7e827141c9ed68f30765c9ca2ddcd1d760ad2d;hpb=624b2d44625f69d71175c3348cae635d580c890b diff --git a/FS/FS/cust_main_note.pm b/FS/FS/cust_main_note.pm index 0a203a8f4..2288d7c4e 100644 --- a/FS/FS/cust_main_note.pm +++ b/FS/FS/cust_main_note.pm @@ -1,9 +1,10 @@ package FS::cust_main_note; +use base qw( FS::otaker_Mixin FS::Record ); use strict; -use base qw( FS::otaker_Mixin FS::Record ); use Carp; -use FS::Record qw( qsearch qsearchs ); +use FS::Record qw( qsearchs ); #qw( qsearch qsearchs ); +use FS::Conf; =head1 NAME @@ -38,6 +39,8 @@ primary key =item custnum +=item classnum + =item _date =item usernum @@ -106,15 +109,42 @@ 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') + || $self->ut_numbern('sticky') ; return $error if $error; + if (!$self->classnum) { + my $conf = new FS::Conf; + return 'Note class is required' + if $conf->exists('cust_main_note-require_class'); + } + $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. + +=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;