summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--FS/FS.pm2
-rw-r--r--FS/FS/AccessRight.pm2
-rw-r--r--FS/FS/Agent_Mixin.pm42
-rw-r--r--FS/FS/Mason.pm1
-rw-r--r--FS/FS/Schema.pm13
-rw-r--r--FS/FS/access_groupsales.pm153
-rw-r--r--FS/FS/access_right.pm1
-rw-r--r--FS/FS/cust_main.pm2
-rw-r--r--FS/FS/cust_main/Billing_Realtime.pm9
-rw-r--r--FS/FS/cust_pkg.pm4
-rw-r--r--FS/FS/sales.pm32
-rw-r--r--FS/MANIFEST2
-rw-r--r--FS/t/access_groupsales.t5
-rwxr-xr-xbin/part_pkg-bulk_change59
-rwxr-xr-xhttemplate/browse/sales.cgi100
-rw-r--r--httemplate/browse/sales.html32
-rw-r--r--httemplate/edit/process/sales.cgi23
-rw-r--r--httemplate/edit/process/sales.html12
-rwxr-xr-xhttemplate/edit/sales.cgi79
-rwxr-xr-xhttemplate/edit/sales.html21
-rw-r--r--httemplate/elements/menu.html18
21 files changed, 184 insertions, 428 deletions
diff --git a/FS/FS.pm b/FS/FS.pm
index a318a2018..9ba5ba152 100644
--- a/FS/FS.pm
+++ b/FS/FS.pm
@@ -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";
diff --git a/bin/part_pkg-bulk_change b/bin/part_pkg-bulk_change
index cf65c39a2..cb29b1865 100755
--- a/bin/part_pkg-bulk_change
+++ b/bin/part_pkg-bulk_change
@@ -1,14 +1,14 @@
#!/usr/bin/perl
use strict;
-use vars qw( $opt_r $opt_p $opt_o $opt_v );
+use vars qw( $opt_r $opt_p $opt_o $opt_v $opt_t );
use Getopt::Std;
use FS::UID qw(adminsuidsetup);
use FS::Record qw(qsearch qsearchs);
use FS::part_pkg;
use FS::part_pkg_option;
-getopts('rp:o:v:');
+getopts('rp:o:v:t:');
my $user = shift or &usage;
adminsuidsetup $user;
@@ -19,28 +19,41 @@ my %plan;
foreach my $part_pkg ( qsearch('part_pkg',\%plan) ) {
next if ! $part_pkg->freq && $opt_r;
- my %hash = (
- 'pkgpart' => $part_pkg->pkgpart,
- 'optionname' => $opt_o,
- );
-
- my $part_pkg_option = qsearchs('part_pkg_option', \%hash);
-
- if ( $part_pkg_option ) {
- next if $part_pkg_option->optionvalue eq $opt_v;
- $part_pkg_option->optionvalue($opt_v);
- my $error = $part_pkg_option->replace;
- die $error if $error;
- } else {
- $part_pkg_option = new FS::part_pkg_option { %hash, 'optionvalue'=>$opt_v };
- my $error = $part_pkg_option->insert;
- die $error if $error;
+ if ( $opt_o ) {
+
+ my %hash = (
+ 'pkgpart' => $part_pkg->pkgpart,
+ 'optionname' => $opt_o,
+ );
+
+ my $part_pkg_option = qsearchs('part_pkg_option', \%hash);
+
+ if ( $part_pkg_option ) {
+ next if $part_pkg_option->optionvalue eq $opt_v;
+ $part_pkg_option->optionvalue($opt_v);
+ my $error = $part_pkg_option->replace;
+ die $error if $error;
+ } else {
+ $part_pkg_option = new FS::part_pkg_option { %hash,
+ 'optionvalue'=>$opt_v,
+ };
+ my $error = $part_pkg_option->insert;
+ die $error if $error;
+ }
+
+ }
+
+ if ( $opt_t ) {
+
+ $part_pkg->taxclass($opt_t);
+ my $error = $part_pkg->replace;
+
}
}
sub usage {
- die "usage: part_pkg-bulk_change [ -r ] -o option_name -v option_value employee_username\n";
+ die "usage: part_pkg-bulk_change [ -r ] [ -o option_name -v option_value ] [ -t new_taxclass ] employee_username\n";
}
=head1 NAME
@@ -49,18 +62,24 @@ cust_main-bulk_change
=head1 SYNOPSIS
- part_pkg-bulk_change [ -r ] -o option_name -v option_value employee_username
+ part_pkg-bulk_change [ -r ] [ -o option_name -v option_value ] [ -t new_taxclass ] employee_username
=head1 DESCRIPTION
Command-line tool to change a set of package definitions.
+Search options:
+
-r: recurring package definitions only
+Change options:
+
-o: part_pkg_option optionname
-v: part_pkg_option optionvalue
+-t: new taxclass
+
employee_username
=head1 BUGS
diff --git a/httemplate/browse/sales.cgi b/httemplate/browse/sales.cgi
deleted file mode 100755
index af098121d..000000000
--- a/httemplate/browse/sales.cgi
+++ /dev/null
@@ -1,100 +0,0 @@
-<% include("/elements/header.html",'Sales Listing', menubar(
- 'Add new sales person' => '../edit/sales.cgi'
-)) %>
-Sales people bring in business.<BR><BR>
-% if ( dbdef->table('sales')->column('disabled') ) {
-
- <% $cgi->param('showdisabled')
- ? do { $cgi->param('showdisabled', 0);
- '( <a href="'. $cgi->self_url. '">hide disabled sales people</a> )'; }
- : do { $cgi->param('showdisabled', 1);
- '( <a href="'. $cgi->self_url. '">show disabled sales people</a> )'; }
- %>
-% }
-
-
-<% include('/elements/table-grid.html') %>
-% my $bgcolor1 = '#eeeeee';
-% my $bgcolor2 = '#ffffff';
-% my $bgcolor = '';
-
-<TR>
- <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=<% ( $cgi->param('showdisabled') || !dbdef->table('sales')->column('disabled') ) ? 2 : 3 %>>Sales person</TH>
- <TH CLASS="grid" BGCOLOR="#cccccc">Agent</TH>
- <TH CLASS="grid" BGCOLOR="#cccccc">Access Groups</TH>
-</TR>
-
-%foreach my $sales ( sort {
-% $a->getfield('salesnum') cmp $b->getfield('salesnum')
-%} qsearch('sales', \%search ) ) {
-%
-% if ( $bgcolor eq $bgcolor1 ) {
-% $bgcolor = $bgcolor2;
-% } else {
-% $bgcolor = $bgcolor1;
-% }
-
- <TR>
-
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
- <A HREF="<%$p%>edit/sales.cgi?<% $sales->salesnum %>"><% $sales->salesnum %></A>
- </TD>
-
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
- <A HREF="<%$p%>edit/sales.cgi?<% $sales->salesnum %>"><% $sales->salesperson %></A>
- </TD>
-
-% if ( ! $cgi->param('showdisabled') ) {
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="center">
- <% $sales->disabled ? '<FONT COLOR="#FF0000"><B>DISABLED</B></FONT>'
- : '<FONT COLOR="#00CC00"><B>Active</B></FONT>'
- %>
- </TD>
-% }
-
-% my ($agent) = qsearch('agent', { 'agentnum' => $sales->agentnum });
-
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
- <A HREF="<%$p%>edit/sales.cgi?<% $sales->agentnum %>"><% $sales->agentnum %></A>
- <A HREF="<%$p%>edit/agent.cgi?<% $agent->agentnum %>">(<% $agent->agent %>)<BR>
- </TD>
-
- <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
-% foreach my $access_group (
-% map $_->access_group,
-% qsearch('access_groupsales', { 'salesnum' => $sales->salesnum })
-% ) {
- <A HREF="<%$p%>edit/access_group.html?<% $access_group->groupnum %>"><% $access_group->groupname |h %><BR>
-% }
- </TD>
-
- </TR>
-% }
-
- </TABLE>
-
-<SCRIPT TYPE="text/javascript">
- function areyousure(what, href) {
- if ( confirm("Are you sure you want to " + what + "?") == true )
- window.location.href = href;
- }
-</SCRIPT>
-
- </BODY>
-</HTML>
-<%init>
-
-die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
-
-my %search;
-if ( $cgi->param('showdisabled')
- || !dbdef->table('agent')->column('disabled') ) {
- %search = ();
-} else {
- %search = ( 'disabled' => '' );
-}
-
-my $conf = new FS::Conf;
-
-</%init>
diff --git a/httemplate/browse/sales.html b/httemplate/browse/sales.html
new file mode 100644
index 000000000..1cdc49085
--- /dev/null
+++ b/httemplate/browse/sales.html
@@ -0,0 +1,32 @@
+<& elements/browse.html,
+ 'title' => 'Sales People',
+ 'name_singular' => 'sales person',
+ 'menubar' => ['Add a new sales person' => $p.'edit/sales.html'],
+ 'query' => { 'table' => 'sales' },
+ 'count_query' => 'SELECT COUNT(*) FROM sales',
+ 'header' => \@header,
+ 'fields' => \@fields,
+ 'links' => \@links,
+ 'disableable' => 1,
+ 'disabled_statuspos' => 1,
+ 'agent_virt' => 1,
+&>
+<%init>
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+
+die "access denied" unless $curuser->access_right('Edit sales people');
+
+my @header = ( 'Sales person' );
+my @fields = ( 'salesperson' );
+my @links = ( [$p.'edit/sales.html?', 'salesnum'] );
+
+if ( $curuser->access_right('Configuration') ) {
+ push @header, 'Agent';
+ push @fields, 'agent_name';
+ push @links, [ $p.'edit/agent.cgi?', 'agentnum' ];
+}
+
+#Sales people bring in business.<BR><BR>
+
+</%init>
diff --git a/httemplate/edit/process/sales.cgi b/httemplate/edit/process/sales.cgi
deleted file mode 100644
index edef4d65c..000000000
--- a/httemplate/edit/process/sales.cgi
+++ /dev/null
@@ -1,23 +0,0 @@
-<% include( 'elements/process.html',
- 'table' => 'sales',
- 'viewall_dir' => 'browse',
- 'viewall_ext' => 'cgi',
- 'debug' => '1',
- 'process_m2m' => { 'link_table' => 'access_groupsales',
- 'target_table' => 'access_group',
- },
- 'edit_ext' => 'cgi',
- )
-%>
-<%init>
-
-die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
-
-if ( FS::Conf->new->exists('disable_acl_changes') ) {
- errorpage('ACL changes disabled in public demo.');
- die "shouldn't be reached";
-}
-
-</%init>
-
diff --git a/httemplate/edit/process/sales.html b/httemplate/edit/process/sales.html
new file mode 100644
index 000000000..b60276dcb
--- /dev/null
+++ b/httemplate/edit/process/sales.html
@@ -0,0 +1,12 @@
+<& elements/process.html,
+ 'table' => 'sales',
+ 'viewall_dir' => 'browse',
+ 'agent_virt' => 1,
+&>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Edit sales people');
+
+</%init>
+
diff --git a/httemplate/edit/sales.cgi b/httemplate/edit/sales.cgi
deleted file mode 100755
index 3497de505..000000000
--- a/httemplate/edit/sales.cgi
+++ /dev/null
@@ -1,79 +0,0 @@
-<% include("/elements/header.html","$action Sales Person", menubar(
- 'View all sales people' => $p. 'browse/sales.cgi',
-)) %>
-
-<% include('/elements/error.html') %>
-
-<FORM METHOD = POST
- ACTION = "<%popurl(1)%>process/sales.cgi"
->
-
-<INPUT TYPE="hidden" NAME="salesnum" VALUE="<% $sales->salesnum %>">
-Sales #<% $sales->salesnum ? $sales->salesnum : "(NEW)" %>
-
-<% &ntable("#cccccc", 2, '') %>
-
- <TR>
- <TH ALIGN="right">Sales</TH>
- <TD><INPUT TYPE="text" NAME="salesperson" SIZE=32 VALUE="<% $sales->salesperson %>"></TD>
- </TR>
-
- <TR>
- <TD ALIGN="right"><% emt('Agent') %></TD>
- <TD>
- <& /elements/select-agent.html,
- 'curr_value' => $sales->salesnum,
- 'disable_empty' => 1,
- &>
- </TD>
- </TR>
-
- <TR>
- <TD ALIGN="right">Disable</TD>
- <TD><INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<% $sales->disabled eq 'Y' ? ' CHECKED' : '' %>></TD>
- </TR>
-
- <TR>
- <TD ALIGN="right">Access Groups</TD>
- <TD><% include('/elements/checkboxes-table.html',
- 'source_obj' => $sales,
- 'link_table' => 'access_groupsales',
- 'target_table' => 'access_group',
- 'name_col' => 'groupname',
- 'target_link' => $p. 'edit/access_group.html?',
- )
- %>
- </TD>
- </TR>
-
-</TABLE>
-
-<BR>
-<INPUT TYPE="submit" VALUE="<% $sales->salesnum ? "Apply changes" : "Add sales" %>">
-
-</FORM>
-
-<% include('/elements/footer.html') %>
-
-<%init>
-
-die "access denied"
- unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
-
-my $sales;
-if ( $cgi->param('error') ) {
- $sales = new FS::sales ( {
- map { $_, scalar($cgi->param($_)) } fields('sales')
- } );
-} elsif ( $cgi->keywords ) {
- my($query) = $cgi->keywords;
- $query =~ /^(\d+)$/;
- $sales = qsearchs( 'sales', { 'salesnum' => $1 } );
-} else { #adding
- $sales = new FS::sales {};
-}
-my $action = $sales->salesnum ? 'Edit' : 'Add';
-
-my $conf = new FS::Conf;
-
-</%init>
diff --git a/httemplate/edit/sales.html b/httemplate/edit/sales.html
new file mode 100755
index 000000000..65cddfc13
--- /dev/null
+++ b/httemplate/edit/sales.html
@@ -0,0 +1,21 @@
+<& elements/edit.html,
+ 'name_singular' => 'sales person',
+ 'table' => 'sales',
+ 'fields' => [ 'salesperson',
+ { field=>'agentnum', type=>'select-agent', disable_empty=>1, },
+ { field=>'disabled', type=>'checkbox', value=>'Y', },
+ ],
+ 'labels' => { 'salesnum' => 'Sales Person',
+ 'salesperson' => 'Name',
+ 'agentnum' => 'Agent',
+ 'disabled' => 'Disabled',
+ },
+ 'viewall_dir' => 'browse',
+ 'agent_virt' => 1,
+&>
+<%init>
+
+die "access denied"
+ unless $FS::CurrentUser::CurrentUser->access_right('Edit sales people');
+
+</%init>
diff --git a/httemplate/elements/menu.html b/httemplate/elements/menu.html
index a7411b796..15d2f5346 100644
--- a/httemplate/elements/menu.html
+++ b/httemplate/elements/menu.html
@@ -573,7 +573,7 @@ tie my %config_agent, 'Tie::IxHash',
;
tie my %config_sales, 'Tie::IxHash',
- 'Sales' => [ $fsurl.'browse/sales.cgi', 'Sales bring in new business.' ],
+ 'Sales People' => [ $fsurl.'browse/sales.html', 'Sales people bring in new business.' ],
;
tie my %config_billing_rates, 'Tie::IxHash',
@@ -689,13 +689,19 @@ if ( $curuser->access_right('Configuration' ) ) {
'Settings' => [ $fsurl.'config/config-view.cgi', '' ],
'separator' => '', #its a separator!
'Companies' => [ \%config_agent, '' ],
- 'Employees' => [ \%config_employees, '' ],
- 'Sales People' => [ \%config_sales, '' ],
- 'separator2' => '', #its a separator!
- 'Customers' => [ \%config_cust, '' ],
- #or this? 'Customers and Contacts' => [ \%config_cust, '' ],
);
}
+
+$config_menu{'Sales People'} = [ \%config_sales, '' ]
+ if $curuser->access_right('Edit sales people');
+
+if ( $curuser->access_right('Configuration' ) ) {
+ $config_menu{'Employees'} = [ \%config_employees, '' ];
+ $config_menu{'separator2'} = ''; #its a separator!
+ $config_menu{'Customers'} = [ \%config_cust, '' ];
+ #or this? 'Customers and Contacts'
+}
+
$config_menu{'Packages'} = [ \%config_pkg, '' ]
if $curuser->access_right('Configuration' )
|| $curuser->access_right('Edit package definitions')