summaryrefslogtreecommitdiff
path: root/httemplate/elements/tr-select-cust_location.html
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 /httemplate/elements/tr-select-cust_location.html
parenta46d6ebede6bab9d05b054e82004e07ea8aabbb5 (diff)
prospect qualifications default to prospect address if there's one, other UI cleanups RT#7111
Diffstat (limited to 'httemplate/elements/tr-select-cust_location.html')
-rw-r--r--httemplate/elements/tr-select-cust_location.html47
1 files changed, 31 insertions, 16 deletions
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';