3 Hmm, this is now entirely redundant with edit/cust_main/contacts_new.html, and
4 this one isn't being maintained well. :/
8 'name_singular' => 'customer contacts', #yes, we're editing all of them
9 'table' => 'cust_main',
10 'post_url' => popurl(1). 'process/cust_main-contacts.html',
11 'no_pkey_display' => 1,
13 'contactnum' => ' ', #'Contact',
14 #'locationnum' => ' ',
17 { 'field' => 'contactnum',
20 'custnum' => $custnum,
21 'm2m_method' => 'cust_contact',
22 'm2m_dstcol' => 'contactnum',
23 'm2_label' => ' ', #'Contact',
24 'm2_error_callback' => $m2_error_callback,
27 #'new_callback' => $new_callback,
28 #'edit_callback' => $edit_callback,
29 #'error_callback' => $error_callback,
31 'html_table_class' => 'fsinnerbox',
32 'menubar' => [], #remove "view all" link
34 #XXX it would be nice if this could instead be after the error but before
36 'html_init' => include('/elements/small_custview.html',
38 $conf->config('countrydefault') || 'US',
45 my $curuser = $FS::CurrentUser::CurrentUser;
46 my $conf = new FS::Conf;
49 if ( $cgi->param('error') ) {
50 $custnum = scalar($cgi->param('custnum'));
53 unless $curuser->access_right(($custnum ? 'Edit' : 'New'). ' customer'); #contacts?
55 } elsif ( $cgi->keywords ) { #editing
56 $custnum = ($cgi->keywords)[0];
59 unless $curuser->access_right('Edit customer');
61 } else { #new customer
63 #this doesn't really work here, we're an edit only
64 die "guru meditation #32";
67 unless $curuser->access_right('New customer');
71 #my $new_callback = sub {
72 # my( $cgi, $prospect_main, $fields_listref, $opt_hashref ) = @_;
75 #my $edit_callback = sub {
76 # my( $cgi, $prospect_main, $fields_listref, $opt_hashref ) = @_;
79 #my $error_callback = sub {
80 # my( $cgi, $prospect_main, $fields_listref, $opt_hashref ) = @_;
83 my $m2_error_callback = sub {
84 my($cgi, $object) = @_;
86 #process_o2m fields in process/cust_main-contacts.html
87 my @fields = FS::contact->cgi_contact_fields;
88 my @gfields = ( '', map "_$_", @fields );
91 if ( /^contactnum(\d+)$/ ) {
93 if ( grep $cgi->param("contactnum$num$_"), @gfields ) {
94 my $x = new FS::contact {
95 'contactnum' => scalar($cgi->param("contactnum$num")),
96 map { $_ => scalar($cgi->param("contactnum${num}_$_")) } @fields,