enhance contacts: contact classes, RT#16819
authorIvan Kohler <ivan@freeside.biz>
Sat, 24 Mar 2012 20:16:41 +0000 (13:16 -0700)
committerIvan Kohler <ivan@freeside.biz>
Sat, 24 Mar 2012 20:16:41 +0000 (13:16 -0700)
FS/FS.pm
FS/FS/Schema.pm
FS/FS/contact_class.pm [new file with mode: 0644]
FS/MANIFEST
FS/t/contact_class.t [new file with mode: 0644]
httemplate/browse/contact_class.html [new file with mode: 0644]
httemplate/edit/contact_class.html [new file with mode: 0644]
httemplate/edit/process/contact_class.html [new file with mode: 0644]
httemplate/elements/menu.html

index c3a1ac2..830a4a4 100644 (file)
--- a/FS/FS.pm
+++ b/FS/FS.pm
@@ -294,6 +294,8 @@ L<FS::reason> - Reason class
 
 L<FS::cust_pkg_reason> - Package reason class
 
+L<FS::contact_class> - Contact class class
+
 L<FS::contact> - Contact class
 
 L<FS::contact_phone> - Contact phone class
index a36d2dc..67b6823 100644 (file)
@@ -938,7 +938,7 @@ sub tables_hashref {
                  ],
     },
 
-    'cust_recon' => {  # what purpose does this serve?
+    'cust_recon' => {  # (some sort of not-well understood thing for OnPac)
       'columns' => [
         'reconid',      'serial',  '',          '', '', '', 
         'recondate',    @date_type,                 '', '', 
@@ -964,7 +964,17 @@ sub tables_hashref {
       'index' => [],
     },
 
-    #eventually for cust_main too
+    'contact_class' => {
+      'columns' => [
+        'classnum',    'serial',   '',      '', '', '', 
+        'classname',   'varchar',  '', $char_d, '', '', 
+        'disabled',    'char', 'NULL',       1, '', '', 
+      ],
+      'primary_key' => 'classnum',
+      'unique' => [],
+      'index' => [ ['disabled'] ],
+    },
+
     'contact' => {
       'columns' => [
         'contactnum', 'serial',     '',      '', '', '',
@@ -1586,7 +1596,8 @@ sub tables_hashref {
         'percent',    'decimal',     '',   '7,4', '', '',
         'months',     'decimal', 'NULL',   '7,4', '', '',
         'disabled',      'char', 'NULL',       1, '', '', 
-        'setup',      'char', 'NULL',       1, '', '', 
+        'setup',         'char', 'NULL',       1, '', '', 
+        #'linked',        'char', 'NULL',       1, '', '',
       ],
       'primary_key' => 'discountnum',
       'unique' => [],
diff --git a/FS/FS/contact_class.pm b/FS/FS/contact_class.pm
new file mode 100644 (file)
index 0000000..5fe2b38
--- /dev/null
@@ -0,0 +1,94 @@
+package FS::contact_class;
+use base qw( FS::class_Common );
+
+use strict;
+use FS::Record qw( qsearch qsearchs );
+
+=head1 NAME
+
+FS::contact_class - Object methods for contact_class records
+
+=head1 SYNOPSIS
+
+  use FS::contact_class;
+
+  $record = new FS::contact_class \%hash;
+  $record = new FS::contact_class { 'column' => 'value' };
+
+  $error = $record->insert;
+
+  $error = $new_record->replace($old_record);
+
+  $error = $record->delete;
+
+  $error = $record->check;
+
+=head1 DESCRIPTION
+
+An FS::contact_class object represents a contact class.  FS::contact_class
+inherits from FS::class_Common.  The following fields are currently supported:
+
+=over 4
+
+=item classnum
+
+primary key
+
+=item classname
+
+Class name
+
+=item disabled
+
+Disabled flag
+
+=back
+
+=head1 METHODS
+
+=over 4
+
+=item new HASHREF
+
+Creates a new example.  To add the example 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 { 'contact_class'; }
+
+=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 class.  If there is
+an error, returns the error, otherwise returns false.  Called by the insert
+and replace methods.
+
+=back
+
+=head1 BUGS
+
+The author forgot to customize this manpage.
+
+=head1 SEE ALSO
+
+L<FS::Record>, schema.html from the base documentation.
+
+=cut
+
+1;
+
index 49d27b4..f0a4a9d 100644 (file)
@@ -630,3 +630,5 @@ FS/tower_sector.pm
 t/tower_sector.t
 FS/h_svc_cert.pm
 t/h_svc_cert.t
+FS/contact_class.pm
+t/contact_class.t
diff --git a/FS/t/contact_class.t b/FS/t/contact_class.t
new file mode 100644 (file)
index 0000000..b4164c0
--- /dev/null
@@ -0,0 +1,5 @@
+BEGIN { $| = 1; print "1..1\n" }
+END {print "not ok 1\n" unless $loaded;}
+use FS::contact_class;
+$loaded=1;
+print "ok 1\n";
diff --git a/httemplate/browse/contact_class.html b/httemplate/browse/contact_class.html
new file mode 100644 (file)
index 0000000..88df24b
--- /dev/null
@@ -0,0 +1,34 @@
+<% include( 'elements/browse.html',
+                 'title'       => 'Contact classes',
+                 'html_init'   => $html_init,
+                 'name'        => 'contact classes',
+                 'disableable' => 1,
+                 'disabled_statuspos' => 1,
+                 'query'       => { 'table'     => 'contact_class',
+                                    'hashref'   => {},
+                                    'order_by' => 'ORDER BY classnum',
+                                  },
+                 'count_query' => $count_query,
+                 'header'      => $header,
+                 'fields'      => $fields,
+                 'links'       => $links,
+             )
+%>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+my $html_init = 
+  'Contact classes define types for contacts.<BR><BR>'.
+  qq!<A HREF="${p}edit/contact_class.html"><I>Add a contact class</I></A><BR><BR>!;
+
+my $count_query = 'SELECT COUNT(*) FROM contact_class';
+
+my $link = [ $p.'edit/contact_class.html?', 'classnum' ];
+
+my $header = [ '#', 'Class' ];
+my $fields = [ 'classnum', 'classname' ];
+my $links  = [ $link, $link ];
+
+</%init>
diff --git a/httemplate/edit/contact_class.html b/httemplate/edit/contact_class.html
new file mode 100644 (file)
index 0000000..2e0965d
--- /dev/null
@@ -0,0 +1,6 @@
+<% include( 'elements/class_Common.html',
+              'name'   => 'Contact Class',
+              'table'  => 'contact_class',
+             'nocat' => 1,
+          )
+%>
diff --git a/httemplate/edit/process/contact_class.html b/httemplate/edit/process/contact_class.html
new file mode 100644 (file)
index 0000000..3a73cc6
--- /dev/null
@@ -0,0 +1,11 @@
+<% include( 'elements/process.html',
+               'table'       => 'contact_class',
+               'viewall_dir' => 'browse',
+           )
+%>
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+</%init>
index c65e990..f096dd8 100644 (file)
@@ -491,9 +491,11 @@ tie my %config_cust, 'Tie::IxHash',
   'Customer tags'       => [ $fsurl.'browse/part_tag.html', '' ],
   'Customer classes'    =>  [ $fsurl.'browse/cust_class.html', 'Customer classes define groups of customers for reporting.' ],
   'Customer categories' =>  [ $fsurl.'browse/cust_category.html', 'Customer categories define groups of customer classes.' ],
+  'separator'     => '', #its a separator!
+  'Contact classes'    =>  [ $fsurl.'browse/contact_class.html', 'Contact classes define types for contacts.' ],
 ;
   
-$config_cust{'Customer note classes'} = [ $fsurl.'browse/cust_note_class.html', 'Customer note classes define groups of notes for reporting.' ]
+$config_cust{'Note classes'} = [ $fsurl.'browse/cust_note_class.html', 'Note classes define groups of customer notes for reporting.' ]
     if ($conf->exists('note-classes') && $conf->config('note-classes') > 0);
 
 tie my %config_agent, 'Tie::IxHash',
@@ -576,6 +578,7 @@ if ( $curuser->access_right('Configuration' ) ) {
     'Resellers'     => [ \%config_agent, '' ],
     'separator2'    => '', #its a separator!
     'Customers'     => [ \%config_cust, '' ],
+    #or this? 'Customers and Contacts' => [ \%config_cust, '' ],
   );
 }
 $config_menu{'Packages'} = [ \%config_pkg, '' ]