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 'm2m_method' => 'cust_contact',
15 'm2m_dstcol' => 'contactnum',
16 'm2_label' => ' ', #'Contact',
17 'm2_error_callback' => $m2_error_callback,
20 #'new_callback' => $new_callback,
21 #'edit_callback' => $edit_callback,
22 #'error_callback' => $error_callback,
24 'menubar' => [], #remove "view all" link
26 #XXX it would be nice if this could instead be after the error but before
28 'html_init' => include('/elements/small_custview.html',
30 $conf->config('countrydefault') || 'US',
37 my $curuser = $FS::CurrentUser::CurrentUser;
38 my $conf = new FS::Conf;
41 if ( $cgi->param('error') ) {
42 $custnum = scalar($cgi->param('custnum'));
45 unless $curuser->access_right(($custnum ? 'Edit' : 'New'). ' customer'); #contacts?
47 } elsif ( $cgi->keywords ) { #editing
48 $custnum = ($cgi->keywords)[0];
51 unless $curuser->access_right('Edit customer');
53 } else { #new customer
55 #this doesn't really work here, we're an edit only
56 die "guru meditation #32";
59 unless $curuser->access_right('New customer');
63 #my $new_callback = sub {
64 # my( $cgi, $prospect_main, $fields_listref, $opt_hashref ) = @_;
67 #my $edit_callback = sub {
68 # my( $cgi, $prospect_main, $fields_listref, $opt_hashref ) = @_;
71 #my $error_callback = sub {
72 # my( $cgi, $prospect_main, $fields_listref, $opt_hashref ) = @_;
75 my $m2_error_callback = sub {
76 my($cgi, $object) = @_;
78 #process_o2m fields in process/cust_main-contacts.html
79 my @fields = qw( first last title comment );
80 my @gfields = ( '', map "_$_", @fields );
83 if ( /^contactnum(\d+)$/ ) {
85 if ( grep $cgi->param("contactnum$num$_"), @gfields ) {
86 my $x = new FS::contact {
87 'contactnum' => scalar($cgi->param("contactnum$num")),
88 map { $_ => scalar($cgi->param("contactnum${num}_$_")) } @fields,