summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorivan <ivan>2011-03-11 00:45:53 +0000
committerivan <ivan>2011-03-11 00:45:53 +0000
commitfced2ed0147049fded427862a3517c172f86513e (patch)
treed719e4d1a86921802056e09c3ce41ab217734f5a
parenta46d6ebede6bab9d05b054e82004e07ea8aabbb5 (diff)
prospect qualifications default to prospect address if there's one, other UI cleanups RT#7111
-rw-r--r--FS/FS/prospect_main.pm20
-rw-r--r--httemplate/elements/tr-select-cust_location.html47
-rw-r--r--httemplate/elements/tr-td-label.html10
-rw-r--r--httemplate/misc/qual.html55
4 files changed, 85 insertions, 47 deletions
diff --git a/FS/FS/prospect_main.pm b/FS/FS/prospect_main.pm
index 369029bab..bace1f040 100644
--- a/FS/FS/prospect_main.pm
+++ b/FS/FS/prospect_main.pm
@@ -41,14 +41,13 @@ from FS::Record. The following fields are currently supported:
primary key
-=item company
-
-company
+=item agentnum
-=item locationnum
+Agent
-locationnum
+=item company
+company
=back
@@ -222,6 +221,17 @@ sub contact {
qsearch( 'contact', { 'prospectnum' => $self->prospectnum } );
}
+=item cust_location
+
+Returns the locations (see L<FS::cust_location>) associated with this prospect.
+
+=cut
+
+sub cust_location {
+ my $self = shift;
+ qsearch( 'cust_location', { 'prospectnum' => $self->prospectnum } );
+}
+
=item search HASHREF
(Class method)
diff --git a/httemplate/elements/tr-select-cust_location.html b/httemplate/elements/tr-select-cust_location.html
index 5802f4ec2..bb10a83de 100644
--- a/httemplate/elements/tr-select-cust_location.html
+++ b/httemplate/elements/tr-select-cust_location.html
@@ -160,14 +160,8 @@ Example:
% if ( $opt{'is_optional'} ) {
<OPTION VALUE="-2" <% $locationnum == -2 ? 'SELECTED' : ''%>><% $opt{'optional_label'} || '(not required)' |h %>
% }
-% my @locations = $cust_main ? $cust_main->cust_location : ();
-% @locations = qsearch('cust_location',
-% { 'prospectnum' => $prospect_main->prospectnum } )
-% if $prospect_main;
-% push @locations, $cust_location
-% if !$cust_main && $cust_location && $cust_location->locationnum>0;
-% foreach my $loc ( sort $location_sort @locations ) {
-% next if $loc->disabled;
+%
+% foreach my $loc ( @cust_location ) {
<OPTION VALUE="<% $loc->locationnum %>"
<% $locationnum == $loc->locationnum ? 'SELECTED' : '' %>
><% $loc->line |h %>
@@ -200,18 +194,26 @@ my $statedefault = $conf->config('statedefault')
my %opt = @_;
my $cgi = $opt{'cgi'};
-my $cust_pkg = $opt{'cust_pkg'};
+my $cust_pkg = $opt{'cust_pkg'};
my $cust_main = $opt{'cust_main'};
my $prospect_main = $opt{'prospect_main'};
my $prefix = ($cust_main && length($cust_main->ship_last)) ? 'ship_' : '';
-my $locationnum;
-if ( length($opt{'curr_value'}) ) {
- $locationnum = $opt{'curr_value'};
-} else {
+my $locationnum = '';
+if ( $cgi->param('error') ) {
$cgi->param('locationnum') =~ /^(\-?\d*)$/ or die "illegal locationnum";
$locationnum = $1;
+} else {
+ if ( length($opt{'curr_value'}) ) {
+ $locationnum = $opt{'curr_value'};
+ } elsif ($prospect_main) {
+ my @cust_location = $prospect_main->cust_location;
+ $locationnum = $cust_location[0]->locationnum if scalar(@cust_location)==1;
+ } else { #?
+ $cgi->param('locationnum') =~ /^(\-?\d*)$/ or die "illegal locationnum";
+ $locationnum = $1;
+ }
}
#probably could use explicit controls
@@ -248,9 +250,22 @@ my $location_sort = sub {
or lc($a->address2) cmp lc($b->address2)
};
-my $disabled = ( $locationnum < 0 || ($editable && $locationnum) )
- ? ''
- : 'DISABLED';
+my @cust_location = ();
+push @cust_location, $cust_main->cust_location if $cust_main;
+push @cust_location, $prospect_main->cust_location if $prospect_main;
+push @cust_location, $cust_location
+ if !$cust_main && $cust_location && $cust_location->locationnum > 0
+ && ! grep { $_->locationnum == $cust_location->locationnum } @cust_location;
+
+@cust_location = sort $location_sort grep !$_->disabled, @cust_location;
+
+my $disabled =
+ ( $locationnum < 0
+ || ( $editable && $locationnum )
+ || ( $prospect_main && !$opt{'is_optional'} && !@cust_location && $addnew )
+ )
+ ? ''
+ : 'DISABLED';
my $th = $opt{'no_bold'} ? 'TD' : 'TH';
diff --git a/httemplate/elements/tr-td-label.html b/httemplate/elements/tr-td-label.html
index 77c048405..f8473891f 100644
--- a/httemplate/elements/tr-td-label.html
+++ b/httemplate/elements/tr-td-label.html
@@ -1,10 +1,10 @@
<TR>
- <TD ALIGN="right" VALIGN="top" STYLE="<% $style %>" ID="<% $opt{label_id} || $opt{id}. '_label0' %>">
-
- <% $opt{label} %>
-
- </TD>
+ <TD ALIGN = "right"
+ VALIGN = "<% $opt{'valign'} || 'top' %>"
+ STYLE = "<% $style %>"
+ ID = "<% $opt{label_id} || $opt{id}. '_label0' %>"
+ ><% $opt{label} %></TD>
<%init>
diff --git a/httemplate/misc/qual.html b/httemplate/misc/qual.html
index 69a5f8b74..7af2590b7 100644
--- a/httemplate/misc/qual.html
+++ b/httemplate/misc/qual.html
@@ -9,39 +9,47 @@
<% ntable("#cccccc", 2) %>
<% include('/elements/tr-td-label.html',
- 'cgi' => $cgi,
- 'label' => 'Qualify using',
- 'cell_style' => 'font-weight: bold',
- 'id' => 'exportnum',
- )
+ 'cgi' => $cgi,
+ 'label' => 'Qualify using',
+ #'cell_style' => 'font-weight: bold',
+ 'id' => 'exportnum',
+ )
%>
<TD>
<% include('/elements/select.html',
- 'cgi' => $cgi,
- 'field' => 'exportnum',
- 'options' => \@export_options,
- 'labels' => $export_labels,
- 'curr_value' => $cgi->param('exportnum'),
- )
+ 'cgi' => $cgi,
+ 'field' => 'exportnum',
+ 'options' => \@export_options,
+ 'labels' => $export_labels,
+ 'curr_value' => $exportnum,
+ )
%>
</TD>
</TR>
<% include('/elements/tr-input-text.html',
- 'cgi' => $cgi,
- 'label' => 'Service Telephone Number',
- 'field' => 'phonenum',
- 'size' => '12',
- 'value' => $cgi->param('phonenum'),
+ 'cgi' => $cgi,
+ 'label' => 'Service Telephone Number',
+ 'field' => 'phonenum',
+ 'size' => '12',
+ 'value' => scalar($cgi->param('phonenum')),
+
+ 'valign' => 'middle',
+ 'colspan' => 6,
+ 'prefix' => '<TABLE><TR><TD>',
+ 'postfix' => '</TD><TD><FONT SIZE="-2">'. join('<BR>',
+ 'Line-share (non dry loops) - always fill in',
+ 'Dry loops - always leave empty',
+ ). '</FONT></TD></TR></TABLE>',
)
%>
<% include('/elements/tr-select-cust_location.html',
- 'cgi' => $cgi,
- $table => $cust_main_or_prospect_main,
- 'alt_format' => $conf->exists('qual-alt-address-format') ? 1 : 0,
- 'is_optional' => 1,
- 'no_bold' => 1,
+ 'cgi' => $cgi,
+ $table => $cust_main_or_prospect_main,
+ 'alt_format' => $conf->exists('qual-alt-address-format') ? 1 : 0,
+ 'no_bold' => 1,
+ #required for ikano.. config? 'is_optional' => 1,
)
%>
</TABLE>
@@ -84,5 +92,10 @@ foreach my $export ( @exports ) {
push @export_options, $export->exportnum;
$export_labels->{$export->exportnum} = $export->exportname;
}
+my $exportnum = $cgi->param('error')
+ ? scalar($cgi->param('exportnum'))
+ : scalar(@exports) == 1
+ ? $exports[0]->exportnum
+ : '';
</%init>