summaryrefslogtreecommitdiff
path: root/httemplate/misc/location.cgi
blob: 82ad636c404a0c568fd19b330a05be7b3014f7c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<% objToJson(\%hash) %>
<%init>

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     ) ',
                 ' 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 )
  if $cust_location;

</%init>