diff options
author | ivan <ivan> | 2009-12-31 02:20:33 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-12-31 02:20:33 +0000 |
commit | 2e928dafa3cf6383ea9e97f48af61af05e5a292a (patch) | |
tree | 107c9908948a9c5463ffcb80add9323245d6fa54 /httemplate/edit/prospect_main.html | |
parent | 0d2d8c0b11b715fa7ba1d889e04637194d97e275 (diff) |
prospecting: proper contact error handling when you add a prospect
Diffstat (limited to 'httemplate/edit/prospect_main.html')
-rw-r--r-- | httemplate/edit/prospect_main.html | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/httemplate/edit/prospect_main.html b/httemplate/edit/prospect_main.html index c4123a078..8ae76a9a1 100644 --- a/httemplate/edit/prospect_main.html +++ b/httemplate/edit/prospect_main.html @@ -18,11 +18,16 @@ { 'field' => 'contactnum', 'type' => 'contact', 'colspan' => 6, - #actually o2m, but this seems to be working for edit so far - 'm2name_table' => 'contact', - 'm2name_namecol' => 'contactnum', - 'm2_label' => 'Contact', - 'm2_error_callback' => sub { my($cgi, $object) = @_; (); }, #XXX + ##actually o2m, but this seems to be working for edit so far + #'m2name_table' => 'contact', + #'m2name_namecol' => 'contactnum', + #'m2_label' => 'Contact', + #'m2_error_callback' => $m2_error_callback, + + 'o2m_table' => 'contact', + 'm2_label' => 'Contact', + 'm2_error_callback' => $m2_error_callback, + }, { 'field' => 'locationnum', 'type' => 'select-cust_location', @@ -78,6 +83,33 @@ my $error_callback = sub { $prospect_main->set('locationnum', $locationnum); }; +my $m2_error_callback = sub { + my($cgi, $object) = @_; + + #process_o2m fields in process/prospect_main.html + my @fields = qw( first last title comment ); + my @gfields = ( '', map "_$_", @fields ); + + map { + if ( /^contactnum(\d+)$/ ) { + my $num = $1; + if ( grep $cgi->param("contactnum$num$_"), @gfields ) { + my $x = new FS::contact { + 'contactnum' => $cgi->param("contactnum$num"), + map { $_ => scalar($cgi->param("contactnum${num}_$_")) } @fields, + }; + use Data::Dumper; warn Dumper $x; + $x; + } else { + (); + } + } else { + (); + } + } + $cgi->param; +}; + my @agentnums = $FS::CurrentUser::CurrentUser->agentnums; </%init> |