diff options
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS.pm | 2 | ||||
-rw-r--r-- | FS/FS/AccessRight.pm | 2 | ||||
-rw-r--r-- | FS/FS/Agent_Mixin.pm | 42 | ||||
-rw-r--r-- | FS/FS/Mason.pm | 1 | ||||
-rw-r--r-- | FS/FS/Schema.pm | 13 | ||||
-rw-r--r-- | FS/FS/access_groupsales.pm | 153 | ||||
-rw-r--r-- | FS/FS/access_right.pm | 1 | ||||
-rw-r--r-- | FS/FS/cust_main.pm | 2 | ||||
-rw-r--r-- | FS/FS/cust_main/Billing_Realtime.pm | 9 | ||||
-rw-r--r-- | FS/FS/cust_pkg.pm | 4 | ||||
-rw-r--r-- | FS/FS/sales.pm | 32 | ||||
-rw-r--r-- | FS/MANIFEST | 2 | ||||
-rw-r--r-- | FS/t/access_groupsales.t | 5 |
13 files changed, 68 insertions, 200 deletions
@@ -97,8 +97,6 @@ L<FS::access_usergroup> - Employee group membership L<FS::access_groupagent> - Group reseller access -L<FS::access_groupsales> - Group sales access - L<FS::access_right> - Access rights L<FS::svc_acct_pop> - POP (Point of Presence, not Post diff --git a/FS/FS/AccessRight.pm b/FS/FS/AccessRight.pm index 3f6073e14..019ea2178 100644 --- a/FS/FS/AccessRight.pm +++ b/FS/FS/AccessRight.pm @@ -344,6 +344,8 @@ tie my %rights, 'Tie::IxHash', 'Edit advertising sources', { rightname=>'Edit global advertising sources', global=>1 }, + 'Edit sales people', + 'Edit package definitions', { rightname=>'Edit global package definitions', global=>1 }, diff --git a/FS/FS/Agent_Mixin.pm b/FS/FS/Agent_Mixin.pm new file mode 100644 index 000000000..0f84ba96a --- /dev/null +++ b/FS/FS/Agent_Mixin.pm @@ -0,0 +1,42 @@ +package FS::Agent_Mixin; + +use strict; +use FS::Record qw( qsearchs ); +use FS::agent; + +=head1 NAME + +FS::Agent_Mixin - Mixin class for objects that have an agent. + +=over 4 + +=item agent + +Returns the agent (see L<FS::agent>) for this object. + +=cut + +sub agent { + my $self = shift; + qsearchs( 'agent', { 'agentnum' => $self->agentnum } ); +} + +=item agent_name + +Returns the agent name (see L<FS::agent>) for this object. + +=cut + +sub agent_name { + my $self = shift; + $self->agent->agent; +} + +=back + +=head1 BUGS + +=cut + +1; + diff --git a/FS/FS/Mason.pm b/FS/FS/Mason.pm index 1d4a9393d..79930487e 100644 --- a/FS/FS/Mason.pm +++ b/FS/FS/Mason.pm @@ -315,7 +315,6 @@ if ( -e $addl_handler_use_file ) { use FS::tower; use FS::tower_sector; use FS::sales; - use FS::access_groupsales; use FS::contact_class; use FS::part_svc_class; use FS::upload_target; diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index b0e330dfe..2e9a10af7 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -1036,6 +1036,7 @@ sub tables_hashref { 'columns' => [ 'custnum', 'serial', '', '', '', '', 'agentnum', 'int', '', '', '', '', + 'salesnum', 'int', 'NULL', '', '', '', 'agent_custid', 'varchar', 'NULL', $char_d, '', '', 'classnum', 'int', 'NULL', '', '', '', 'custbatch', 'varchar', 'NULL', $char_d, '', '', @@ -1804,6 +1805,7 @@ sub tables_hashref { 'locationnum', 'int', 'NULL', '', '', '', 'otaker', 'varchar', 'NULL', 32, '', '', 'usernum', 'int', 'NULL', '', '', '', + 'salesnum', 'int', 'NULL', '', '', '', 'order_date', @date_type, '', '', 'start_date', @date_type, '', '', 'setup', @date_type, '', '', @@ -3774,17 +3776,6 @@ sub tables_hashref { 'index' => [ [ 'groupnum' ] ], }, - 'access_groupsales' => { - 'columns' => [ - 'groupsalesnum', 'serial', '', '', '', '', - 'groupnum', 'int', '', '', '', '', - 'salesnum', 'int', '', '', '', '', - ], - 'primary_key' => 'groupsalesnum', - 'unique' => [ [ 'groupnum', 'salesnum' ] ], - 'index' => [ [ 'groupnum' ] ], - }, - 'access_right' => { 'columns' => [ 'rightnum', 'serial', '', '', '', '', diff --git a/FS/FS/access_groupsales.pm b/FS/FS/access_groupsales.pm deleted file mode 100644 index 31b07d9f8..000000000 --- a/FS/FS/access_groupsales.pm +++ /dev/null @@ -1,153 +0,0 @@ -package FS::access_groupsales; - -use strict; -use base qw( FS::Record ); -use FS::Record qw( qsearch qsearchs ); - -=head1 NAME - -FS::access_groupsales - Object methods for access_groupsales records - -=head1 SYNOPSIS - - use FS::access_groupsales; - - $record = new FS::access_groupsales \%hash; - $record = new FS::access_groupsales { 'column' => 'value' }; - - $error = $record->insert; - - $error = $new_record->replace($old_record); - - $error = $record->delete; - - $error = $record->check; - -=head1 DESCRIPTION - -An FS::access_groupsales object represents an example. FS::access_groupsales inherits from -FS::Record. The following fields are currently supported: - -=over 4 - -=item groupsalesnum - -primary key - -=item groupnum - -groupnum - -=item salesnum - -salesnum - - -=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 - -# the new method can be inherited from FS::Record, if a table method is defined - -sub table { 'access_groupsales'; } - -=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 example. 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('groupsalesnum') - || $self->ut_number('groupnum') - || $self->ut_number('salesnum') - ; - return $error if $error; - - $self->SUPER::check; -} - -=back - -=item sales - -Returns the associated FS::agent object. - -=cut - -sub sales { - my $self = shift; - qsearchs('sales', { 'salesnum' => $self->salesnum } ); -} - -=item access_group - -Returns the associated FS::access_group object. - -=cut - -sub access_group { - my $self = shift; - qsearchs('access_group', { 'groupnum' => $self->groupnum } ); -} - -=back - - -=head1 BUGS - -The author forgot to customize this manpage. - -=head1 SEE ALSO - -L<FS::Record>, schema.html from the base documentation. - -=cut - -1; - diff --git a/FS/FS/access_right.pm b/FS/FS/access_right.pm index f8e30d0d2..85334ed1f 100644 --- a/FS/FS/access_right.pm +++ b/FS/FS/access_right.pm @@ -235,6 +235,7 @@ sub _upgrade_data { # class method 'Change customer package' => 'Detach customer package', 'Services: Accounts' => 'Services: Cable Subscribers', 'Bulk change customer packages' => 'Bulk move customer services', + 'Configuration' => 'Edit sales people', ; foreach my $old_acl ( keys %onetime ) { diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm index 30d6fa02a..8e7c3e713 100644 --- a/FS/FS/cust_main.pm +++ b/FS/FS/cust_main.pm @@ -76,6 +76,7 @@ use FS::cust_attachment; use FS::contact; use FS::Locales; use FS::upgrade_journal; +use FS::sales; # 1 is mostly method/subroutine entry and options # 2 traces progress of some operations @@ -1696,6 +1697,7 @@ sub check { || $self->ut_foreign_key('bill_locationnum', 'cust_location','locationnum') || $self->ut_foreign_key('ship_locationnum', 'cust_location','locationnum') || $self->ut_foreign_keyn('classnum', 'cust_class', 'classnum') + || $self->ut_foreign_keyn('salesnum', 'sales', 'salesnum') || $self->ut_textn('custbatch') || $self->ut_name('last') || $self->ut_name('first') diff --git a/FS/FS/cust_main/Billing_Realtime.pm b/FS/FS/cust_main/Billing_Realtime.pm index 0fd86b1ee..e5e5291c0 100644 --- a/FS/FS/cust_main/Billing_Realtime.pm +++ b/FS/FS/cust_main/Billing_Realtime.pm @@ -507,8 +507,13 @@ sub realtime_bop { (exists($options{'paytype'}) && $options{'paytype'}) ? uc($options{'paytype'}) : uc($self->getfield('paytype')) || 'PERSONAL CHECKING'; - $content{account_name} = $self->getfield('first'). ' '. - $self->getfield('last'); + + if ( $content{account_type} =~ /BUSINESS/i && $self->company ) { + $content{account_name} = $self->company; + } else { + $content{account_name} = $self->getfield('first'). ' '. + $self->getfield('last'); + } $content{customer_org} = $self->company ? 'B' : 'I'; $content{state_id} = exists($options{'stateid'}) diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm index 89c683e17..3948c2ffd 100644 --- a/FS/FS/cust_pkg.pm +++ b/FS/FS/cust_pkg.pm @@ -34,7 +34,7 @@ use FS::reason; use FS::cust_pkg_discount; use FS::discount; use FS::UI::Web; -use Data::Dumper; +use FS::sales; # need to 'use' these instead of 'require' in sub { cancel, suspend, unsuspend, # setup } @@ -631,6 +631,7 @@ sub check { || $self->ut_numbern('pkgpart') || $self->ut_foreign_keyn('contactnum', 'contact', 'contactnum' ) || $self->ut_foreign_keyn('locationnum', 'cust_location', 'locationnum') + || $self->ut_foreign_keyn('salesnum', 'sales', 'salesnum') || $self->ut_numbern('start_date') || $self->ut_numbern('setup') || $self->ut_numbern('bill') @@ -2240,6 +2241,7 @@ sub set_quantity { use Storable 'thaw'; use MIME::Base64; +use Data::Dumper; sub process_bulk_cust_pkg { my $job = shift; my $param = thaw(decode_base64(shift)); diff --git a/FS/FS/sales.pm b/FS/FS/sales.pm index 3cb61fde3..5dba4d81b 100644 --- a/FS/FS/sales.pm +++ b/FS/FS/sales.pm @@ -1,18 +1,8 @@ package FS::sales; +use base qw( FS::Agent_Mixin FS::Record ); use strict; -use vars qw( @ISA ); -use base qw( FS::Record ); -use Business::CreditCard 0.28; -use FS::Record qw( dbh qsearch qsearchs ); -use FS::cust_main; -use FS::cust_pkg; -use FS::agent_type; -use FS::reg_code; -use FS::TicketSystem; -#use FS::Conf; - -@ISA = qw( FS::m2m_Common FS::Record ); +use FS::agent; =head1 NAME @@ -35,7 +25,7 @@ FS::sales - Object methods for sales records =head1 DESCRIPTION -An FS::sales object represents an example. FS::sales inherits from +An FS::sales object represents a sales person. FS::sales inherits from FS::Record. The following fields are currently supported: =over 4 @@ -61,7 +51,8 @@ disabled =item new HASHREF -Creates a new example. To add the example to the database, see L<"insert">. +Creates a new sales person. To add the sales person 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. @@ -100,7 +91,7 @@ returns the error, otherwise returns false. =item check -Checks all fields to make sure this is a valid example. If there is +Checks all fields to make sure this is a valid sales person. If there is an error, returns the error, otherwise returns false. Called by the insert and replace methods. @@ -114,15 +105,12 @@ sub check { my $error = $self->ut_numbern('salesnum') - || $self->ut_numbern('agentnum') + || $self->ut_text('salesperson') + || $self->ut_foreign_key('agentnum', 'agent', 'agentnum') + || $self->ut_enum('disabled', [ '', 'Y' ]) ; return $error if $error; - if ( $self->dbdef_table->column('disabled') ) { - $error = $self->ut_enum('disabled', [ '', 'Y' ] ); - return $error if $error; - } - $self->SUPER::check; } @@ -130,8 +118,6 @@ sub check { =head1 BUGS -The author forgot to customize this manpage. - =head1 SEE ALSO L<FS::Record>, schema.html from the base documentation. diff --git a/FS/MANIFEST b/FS/MANIFEST index 803c521db..a6e87f6e3 100644 --- a/FS/MANIFEST +++ b/FS/MANIFEST @@ -637,8 +637,6 @@ FS/upgrade_journal.pm t/upgrade_journal.t FS/sales.pm t/sales.t -FS/access_groupsales.pm -t/access_groupsales.t FS/part_svc_class.pm t/part_svc_class.t FS/upload_target.pm diff --git a/FS/t/access_groupsales.t b/FS/t/access_groupsales.t deleted file mode 100644 index 50993cf26..000000000 --- a/FS/t/access_groupsales.t +++ /dev/null @@ -1,5 +0,0 @@ -BEGIN { $| = 1; print "1..1\n" } -END {print "not ok 1\n" unless $loaded;} -use FS::access_groupsales; -$loaded=1; -print "ok 1\n"; |