X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Flocation.cgi;h=188c5c3dfc3d81974e564ad7177d47daac7dbf42;hb=c3da5cf1caa244937d280e0f406927103beef148;hp=419c59f2e0d1863222113f8919dfaacff5dd3e19;hpb=a661ced3f9f678a645780eaa0b183d2de5f100fa;p=freeside.git diff --git a/httemplate/misc/location.cgi b/httemplate/misc/location.cgi index 419c59f2e..188c5c3df 100644 --- a/httemplate/misc/location.cgi +++ b/httemplate/misc/location.cgi @@ -3,17 +3,29 @@ my $locationnum = $cgi->param('arg'); +my $curuser = $FS::CurrentUser::CurrentUser; + my $cust_location = qsearchs({ 'select' => 'cust_location.*', 'table' => 'cust_location', 'hashref' => { 'locationnum' => $locationnum }, - 'addl_from' => 'LEFT JOIN cust_main USING ( custnum )', - 'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql, + 'addl_from' => ' LEFT JOIN cust_main USING ( custnum ) ', + ' LEFT JOIN prospect_main USING ( prospectnum ) ', + 'extra_sql' => ' AND ( '. + ' ( custnum IS NOT NULL AND '. + $curuser->agentnums_sql( table=>'cust_main' ). + ' ) '. + ' OR '. + ' ( prospectnum IS NOT NULL AND '. + $curuser->agentnums_sql( table=>'prospect_main' ). + ' ) '. + ' )', }); my %hash = (); %hash = map { $_ => $cust_location->$_() } - qw( address1 address2 city county state zip country ) + qw( address1 address2 city county state zip country + location_kind location_type location_number ) if $cust_location;