7c8cc276e52a089b074735efff417f72cd6b9a20
[freeside.git] / httemplate / edit / process / prospect_main.html
1 <% include('elements/process.html',
2      'table'          => 'prospect_main',
3      'args_callback'  => $args_callback,
4      'agent_virt'     => 1,
5      'process_o2m' => {
6        'table'  => 'contact',
7        'fields' => \@contact_fields,
8      },
9      'redirect' => popurl(3). 'view/prospect_main.html?',
10    )
11 %>
12 <%init>
13
14 my $args_callback = sub {
15   my( $cgi, $object ) = @_;
16
17   $cgi->param('locationnum') =~ /^(\-?\d*)$/
18     or die 'illegal locationnum '. $cgi->param('locationnum');
19   my $locationnum = $1;
20
21   return ( 'cust_location' => '' ) unless $locationnum;
22
23   my $cust_location = new FS::cust_location {
24     map { $_ => scalar($cgi->param($_)) }
25         qw( address1 address2 city county state zip country
26             latitude longitude
27             location_kind location_type location_number
28           )
29   };
30
31   $cust_location->locationnum($locationnum) unless $locationnum == -1;
32
33   ( 'cust_location' => $cust_location );
34
35 };
36
37 my @contact_fields = qw( classnum first last title comment emailaddress );
38 foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) {
39   push @contact_fields, 'phonetypenum'.$phone_type->phonetypenum;
40 }
41
42 </%init>