summaryrefslogtreecommitdiff
path: root/httemplate/edit/process/prospect_main.html
blob: 7c8cc276e52a089b074735efff417f72cd6b9a20 (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
31
32
33
34
35
36
37
38
39
40
41
42
<% include('elements/process.html',
     'table'          => 'prospect_main',
     'args_callback'  => $args_callback,
     'agent_virt'     => 1,
     'process_o2m' => {
       'table'  => 'contact',
       'fields' => \@contact_fields,
     },
     'redirect' => popurl(3). 'view/prospect_main.html?',
   )
%>
<%init>

my $args_callback = sub {
  my( $cgi, $object ) = @_;

  $cgi->param('locationnum') =~ /^(\-?\d*)$/
    or die 'illegal locationnum '. $cgi->param('locationnum');
  my $locationnum = $1;

  return ( 'cust_location' => '' ) unless $locationnum;

  my $cust_location = new FS::cust_location {
    map { $_ => scalar($cgi->param($_)) }
        qw( address1 address2 city county state zip country
            latitude longitude
            location_kind location_type location_number
          )
  };

  $cust_location->locationnum($locationnum) unless $locationnum == -1;

  ( 'cust_location' => $cust_location );

};

my @contact_fields = qw( classnum first last title comment emailaddress );
foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) {
  push @contact_fields, 'phonetypenum'.$phone_type->phonetypenum;
}

</%init>