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