13d5ada7f0aada7d082da76dc74669ede779c5db
[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             location_kind location_type location_number
27           )
28   };
29
30   $cust_location->locationnum($locationnum) unless $locationnum == -1;
31
32   ( 'cust_location' => $cust_location );
33
34 };
35
36 my @contact_fields = qw( first last title comment emailaddress );
37 foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) {
38   push @contact_fields, 'phonetypenum'.$phone_type->phonetypenum;
39 }
40
41 </%init>