RT# 82949 - changes section name from fees to pricing, better opiton
[freeside.git] / httemplate / edit / process / prospect_main.html
1 <% include('elements/process.html',
2      'table'          => 'prospect_main',
3      'precheck_callback' => $precheck,
4      'args_callback'  => $args_callback,
5      'agent_virt'     => 1,
6      'process_o2m' => {
7        'table'  => 'contact',
8        'fields' => \@contact_fields,
9      },
10      'redirect' => popurl(3). 'view/prospect_main.html?',
11    )
12 %>
13 <%init>
14
15 my $precheck = sub {
16   my $cgi = shift;
17   my $vendor = FS::Conf->new->config('tax_data_vendor');
18   if ( $vendor eq 'avalara' or $vendor eq 'suretax' ) {
19     if ( ! $cgi->param('taxstatusnum') ) {
20       return 'Tax status required';
21     }
22   }
23 };
24
25 my $args_callback = sub {
26   my( $cgi, $object ) = @_;
27
28   $cgi->param('locationnum') =~ /^(\-?\d*)$/
29     or die 'illegal locationnum '. $cgi->param('locationnum');
30   my $locationnum = $1;
31
32   return ( 'cust_location' => '' ) unless $locationnum;
33
34   my $cust_location = new FS::cust_location {
35     map { $_ => scalar($cgi->param($_)) }
36         qw( address1 address2 city county state zip country
37             latitude longitude
38             location_kind location_type location_number
39           )
40   };
41
42   $cust_location->locationnum($locationnum) unless $locationnum == -1;
43
44   ( 'cust_location' => $cust_location );
45
46 };
47
48 my @contact_fields = qw( classnum first last title comment emailaddress );
49 foreach my $phone_type ( qsearch({table=>'phone_type', order_by=>'weight'}) ) {
50   push @contact_fields, 'phonetypenum'.$phone_type->phonetypenum;
51 }
52
53 </%init>