1 <% include('elements/edit.html',
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 'labels' => { 'custnum' => ' ', #XXX supress this line entirely, its being redundant
6 'contactnum' => 'Contact',
7 #'locationnum' => ' ',
10 { 'field' => 'contactnum',
13 'm2m_method' => 'cust_contact',
14 'm2m_dstcol' => 'contactnum',
15 'm2_label' => 'Contact',
16 'm2_error_callback' => $m2_error_callback,
19 #'new_callback' => $new_callback,
20 #'edit_callback' => $edit_callback,
21 #'error_callback' => $error_callback,
23 'menubar' => [], #remove "view all" link
25 #XXX it would be nice if this could instead be after the error but before
27 'html_init' => include('/elements/small_custview.html',
29 $conf->config('countrydefault') || 'US',
36 my $curuser = $FS::CurrentUser::CurrentUser;
37 my $conf = new FS::Conf;
40 if ( $cgi->param('error') ) {
41 $custnum = scalar($cgi->param('custnum'));
44 unless $curuser->access_right(($custnum ? 'Edit' : 'New'). ' customer'); #contacts?
46 } elsif ( $cgi->keywords ) { #editing
47 $custnum = ($cgi->keywords)[0];
50 unless $curuser->access_right('Edit customer');
52 } else { #new customer
54 #this doesn't really work here, we're an edit only
55 die "guru meditation #32";
58 unless $curuser->access_right('New customer');
62 #my $new_callback = sub {
63 # my( $cgi, $prospect_main, $fields_listref, $opt_hashref ) = @_;
66 #my $edit_callback = sub {
67 # my( $cgi, $prospect_main, $fields_listref, $opt_hashref ) = @_;
70 #my $error_callback = sub {
71 # my( $cgi, $prospect_main, $fields_listref, $opt_hashref ) = @_;
74 my $m2_error_callback = sub {
75 my($cgi, $object) = @_;
77 #process_o2m fields in process/cust_main-contacts.html
78 my @fields = qw( first last title comment );
79 my @gfields = ( '', map "_$_", @fields );
82 if ( /^contactnum(\d+)$/ ) {
84 if ( grep $cgi->param("contactnum$num$_"), @gfields ) {
85 my $x = new FS::contact {
86 'contactnum' => scalar($cgi->param("contactnum$num")),
87 map { $_ => scalar($cgi->param("contactnum${num}_$_")) } @fields,