From 172673b3aef143dc426603689d37b65394c4fe1d Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Sat, 24 Mar 2012 13:16:41 -0700 Subject: [PATCH] enhance contacts: contact classes, RT#16819 --- FS/FS.pm | 2 + FS/FS/Schema.pm | 17 +++++- FS/FS/contact_class.pm | 94 ++++++++++++++++++++++++++++++ FS/MANIFEST | 2 + FS/t/contact_class.t | 5 ++ httemplate/browse/contact_class.html | 34 +++++++++++ httemplate/edit/contact_class.html | 6 ++ httemplate/edit/process/contact_class.html | 11 ++++ httemplate/elements/menu.html | 5 +- 9 files changed, 172 insertions(+), 4 deletions(-) create mode 100644 FS/FS/contact_class.pm create mode 100644 FS/t/contact_class.t create mode 100644 httemplate/browse/contact_class.html create mode 100644 httemplate/edit/contact_class.html create mode 100644 httemplate/edit/process/contact_class.html diff --git a/FS/FS.pm b/FS/FS.pm index c3a1ac2f6..830a4a450 100644 --- a/FS/FS.pm +++ b/FS/FS.pm @@ -294,6 +294,8 @@ L - Reason class L - Package reason class +L - Contact class class + L - Contact class L - Contact phone class diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index a36d2dcdb..67b682360 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -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 index 000000000..5fe2b38ed --- /dev/null +++ b/FS/FS/contact_class.pm @@ -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 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, schema.html from the base documentation. + +=cut + +1; + diff --git a/FS/MANIFEST b/FS/MANIFEST index 49d27b437..f0a4a9d6b 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -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 index 000000000..b4164c04a --- /dev/null +++ b/FS/t/contact_class.t @@ -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 index 000000000..88df24b40 --- /dev/null +++ b/httemplate/browse/contact_class.html @@ -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.

'. + qq!Add a contact class

!; + +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 ]; + + diff --git a/httemplate/edit/contact_class.html b/httemplate/edit/contact_class.html new file mode 100644 index 000000000..2e0965dab --- /dev/null +++ b/httemplate/edit/contact_class.html @@ -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 index 000000000..3a73cc6e1 --- /dev/null +++ b/httemplate/edit/process/contact_class.html @@ -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'); + + diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html index c65e990ae..f096dd889 100644 --- a/httemplate/elements/menu.html +++ b/httemplate/elements/menu.html @@ -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, '' ] -- 2.11.0