[freeside-commits] branch FREESIDE_3_BRANCH updated. ca87449136cd950891603a71e83ba31b55c76938
Ivan
ivan at 420.am
Sat Aug 17 23:19:22 PDT 2013
The branch, FREESIDE_3_BRANCH has been updated
via ca87449136cd950891603a71e83ba31b55c76938 (commit)
from d4e9d68a229b01207ee9e6f3679bb65e7f13cf08 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ca87449136cd950891603a71e83ba31b55c76938
Author: Ivan Kohler <ivan at freeside.biz>
Date: Sat Aug 17 23:19:21 2013 -0700
continue sales person work: customer and package selection, commissions, reporting. RT#23402
diff --git a/FS/FS/Sales_Mixin.pm b/FS/FS/Sales_Mixin.pm
new file mode 100644
index 0000000..3b30ac9
--- /dev/null
+++ b/FS/FS/Sales_Mixin.pm
@@ -0,0 +1,43 @@
+package FS::Sales_Mixin;
+
+use strict;
+use FS::Record qw( qsearchs );
+use FS::sales;
+
+=head1 NAME
+
+FS::Agent_Mixin - Mixin class for objects that have an sales person.
+
+=over 4
+
+=item sales
+
+Returns the sales person (see L<FS::sales>) for this object.
+
+=cut
+
+sub sales {
+ my $self = shift;
+ qsearchs( 'sales', { 'salesnum' => $self->salesnum } );
+}
+
+=item salesperson
+
+Returns the sales person name for this object, if any.
+
+=cut
+
+sub salesperson {
+ my $self = shift;
+ my $sales = $self->sales or return '';
+ $sales->salesperson;
+}
+
+=back
+
+=head1 BUGS
+
+=cut
+
+1;
+
diff --git a/FS/FS/cust_main.pm b/FS/FS/cust_main.pm
index a5450c1..8a1a22e 100644
--- a/FS/FS/cust_main.pm
+++ b/FS/FS/cust_main.pm
@@ -9,7 +9,7 @@ use base qw( FS::cust_main::Packages FS::cust_main::Status
FS::cust_main::Billing_ThirdParty
FS::cust_main::Location
FS::otaker_Mixin FS::payinfo_Mixin FS::cust_main_Mixin
- FS::geocode_Mixin FS::Quotable_Mixin
+ FS::geocode_Mixin FS::Quotable_Mixin FS::Sales_Mixin
FS::o2m_Common
FS::Record
);
diff --git a/httemplate/edit/cust_main/top_misc.html b/httemplate/edit/cust_main/top_misc.html
index b7e86ba..bceb5e1 100644
--- a/httemplate/edit/cust_main/top_misc.html
+++ b/httemplate/edit/cust_main/top_misc.html
@@ -129,6 +129,11 @@
'label' => emt("Class"),
&>
+%#sales person
+<& /elements/tr-select-sales.html,
+ 'curr_value' => $cust_main->salesnum,
+&>
+
%# referral (advertising source)
%my $refnum = $cust_main->refnum || $conf->config('referraldefault') || 0;
%if ( $custnum && ! $conf->exists('editreferrals') ) {
diff --git a/httemplate/elements/select-sales.html b/httemplate/elements/select-sales.html
new file mode 100644
index 0000000..555799e
--- /dev/null
+++ b/httemplate/elements/select-sales.html
@@ -0,0 +1,19 @@
+<& /elements/select-table.html,
+ 'table' => 'sales',
+ 'name_col' => 'salesperson',
+ 'value' => $salesnum || '',
+ 'agent_virt' => 1,
+ 'empty_label' => emt('(none)'),
+ 'hashref' => { 'disabled' => '' },
+ 'order_by' => ' ORDER BY salesperson',
+ %opt,
+&>
+<%init>
+
+my %opt = @_;
+my $salesnum = $opt{'curr_value'} || $opt{'value'};
+
+$opt{'records'} = delete $opt{'sales'}
+ if $opt{'sales'};
+
+</%init>
diff --git a/httemplate/elements/tr-select-sales.html b/httemplate/elements/tr-select-sales.html
new file mode 100644
index 0000000..f77ef50
--- /dev/null
+++ b/httemplate/elements/tr-select-sales.html
@@ -0,0 +1,72 @@
+<%doc>
+
+Example:
+
+ <& /elements/tr-select-sales.html',
+
+ #recommended to keep things "sticky" on errors
+ 'curr_value' => $curr_value,
+
+ ##
+ # optional
+ ##
+
+ 'label' => 'Sales Person',
+ 'empty_label' => 'Select sales person', #override default
+ #on already# 'disable_empty' => 1,
+
+ &>
+
+</%doc>
+% if ( scalar(@sales) == 0 || $opt{'fixed'} ) {
+
+ <INPUT TYPE = "hidden"
+ NAME = "<% $opt{'field'} || 'salesnum' %>"
+ ID = "<% $opt{'field'} || 'salesnum' %>"
+ VALUE = "<% $salesnum %>"
+ >
+
+% if ( scalar(@sales) > 0 ) {
+ <TR>
+ <TD ALIGN="right"><% $opt{'label'} || emt('Sales Person') %></TD>
+ <TD BGCOLOR="#dddddd" <% $colspan %>>
+% my $sales = qsearchs('sales', { 'salesnum' => $salesnum });
+ <% $sales ? $sales->salesperson : '(none)' |h %>
+ </TD>
+ </TR>
+
+% } else { # YUCK. empty row so we don't throw g_row in edit.html off :/
+ <TR>
+ </TR>
+% }
+%
+% } else {
+
+ <TR>
+ <TD ALIGN="right"><% $opt{'label'} || emt('Sales Person') %></TD>
+ <TD <% $colspan %>>
+ <& /elements/select-sales.html,
+ 'curr_value' => $salesnum,
+ 'sales' => \@sales,
+ %opt,
+ &>
+ </TD>
+ </TR>
+
+% }
+
+<%init>
+
+my $curuser = $FS::CurrentUser::CurrentUser;
+
+my %opt = @_;
+my $salesnum = $opt{'curr_value'} || $opt{'value'};
+
+my @sales = qsearch({ 'table' => 'sales',
+ 'hashref' => { 'disabled' => '' },
+ 'extra_sql' => ' AND '. $curuser->agentnums_sql,
+ });
+warn scalar(@sales);
+my $colspan = $opt{'colspan'} ? 'COLSPAN="'.$opt{'colspan'}.'"' : '';
+
+</%init>
diff --git a/httemplate/view/cust_main/misc.html b/httemplate/view/cust_main/misc.html
index 263c266..5311aa5 100644
--- a/httemplate/view/cust_main/misc.html
+++ b/httemplate/view/cust_main/misc.html
@@ -52,6 +52,13 @@
</TR>
% #}
+% if ( $cust_main->salesnum ) {
+ <TR>
+ <TD ALIGN="right"><% mt('Sales Person') |h %></TD>
+ <TD BGCOLOR="#ffffff"><% $cust_main->salesperson |h %></TD>
+ </TR>
+% }
+
% unless ( FS::part_referral->num_part_referral == 1 ) {
% my $referral = qsearchs('part_referral', {
% 'refnum' => $cust_main->refnum
-----------------------------------------------------------------------
Summary of changes:
FS/FS/Sales_Mixin.pm | 43 ++++++++++++++++++
FS/FS/cust_main.pm | 2 +-
httemplate/edit/cust_main/top_misc.html | 5 ++
httemplate/elements/select-sales.html | 19 ++++++++
httemplate/elements/tr-select-sales.html | 72 ++++++++++++++++++++++++++++++
httemplate/view/cust_main/misc.html | 7 +++
6 files changed, 147 insertions(+), 1 deletions(-)
create mode 100644 FS/FS/Sales_Mixin.pm
create mode 100644 httemplate/elements/select-sales.html
create mode 100644 httemplate/elements/tr-select-sales.html
More information about the freeside-commits
mailing list