2 'name_singular' => 'customer contacts', #yes, we're editing all of them
3 'table' => 'cust_main',
4 'post_url' => popurl(1). 'process/cust_main-contacts.html',
5 'no_pkey_display' => 1,
7 'contactnum' => ' ', #'Contact',
8 #'locationnum' => ' ',
11 { 'field' => 'contactnum',
14 'custnum' => $custnum,
15 'm2m_method' => 'cust_contact',
16 'm2m_dstcol' => 'contactnum',
17 'm2_label' => ' ', #'Contact',
18 'm2_error_callback' => $m2_error_callback,
21 #'new_callback' => $new_callback,
22 #'edit_callback' => $edit_callback,
23 #'error_callback' => $error_callback,
25 'menubar' => [], #remove "view all" link
27 #XXX it would be nice if this could instead be after the error but before
29 'html_init' => include('/elements/small_custview.html',
31 $conf->config('countrydefault') || 'US',
38 my $curuser = $FS::CurrentUser::CurrentUser;
39 my $conf = new FS::Conf;
42 if ( $cgi->param('error') ) {
43 $custnum = scalar($cgi->param('custnum'));
46 unless $curuser->access_right(($custnum ? 'Edit' : 'New'). ' customer'); #contacts?
48 } elsif ( $cgi->keywords ) { #editing
49 $custnum = ($cgi->keywords)[0];
52 unless $curuser->access_right('Edit customer');
54 } else { #new customer
56 #this doesn't really work here, we're an edit only
57 die "guru meditation #32";
60 unless $curuser->access_right('New customer');
64 #my $new_callback = sub {
65 # my( $cgi, $prospect_main, $fields_listref, $opt_hashref ) = @_;
68 #my $edit_callback = sub {
69 # my( $cgi, $prospect_main, $fields_listref, $opt_hashref ) = @_;
72 #my $error_callback = sub {
73 # my( $cgi, $prospect_main, $fields_listref, $opt_hashref ) = @_;
76 my $m2_error_callback = sub {
77 my($cgi, $object) = @_;
79 #process_o2m fields in process/cust_main-contacts.html
80 my @fields = qw( first last title comment );
81 my @gfields = ( '', map "_$_", @fields );
84 if ( /^contactnum(\d+)$/ ) {
86 if ( grep $cgi->param("contactnum$num$_"), @gfields ) {
87 my $x = new FS::contact {
88 'contactnum' => scalar($cgi->param("contactnum$num")),
89 map { $_ => scalar($cgi->param("contactnum${num}_$_")) } @fields,