1 %# #based on / some false laziness w/ cust_main-contacts.html
3 'name_singular' => 'payment methods', #"customer payment methods" ?
4 'table' => 'cust_main',
5 'post_url' => popurl(1). 'process/cust_payby.html',
6 'no_pkey_display' => 1,
8 'custpaybynum' => ' ', #'Payment method',
9 #'locationnum' => ' ',
12 { field => 'custpaybynum',
13 type => 'selectlayers',
15 grep { ! /^(DCRD|DCHK)$/ }
18 labels => { '' => 'Select payment method',
19 FS::payby->payby2shortname
21 layer_fields => \%payby_fields,
22 layer_values_callback => $payby_layer_values,
23 m2m_method => 'cust_payby',
24 m2m_dstcol => 'custpaybynum',
25 m2_label => ' ', #'Payment method',
26 m2_error_callback => $m2_error_callback,
29 #'new_callback' => $new_callback,
30 #'edit_callback' => $edit_callback,
31 #'error_callback' => $error_callback,
33 'menubar' => [], #remove "view all" link
35 #XXX it would be nice if this could instead be after the error but before
37 'html_init' => include('/elements/small_custview.html',
39 $conf->config('countrydefault') || 'US',
46 my $curuser = $FS::CurrentUser::CurrentUser;
47 my $conf = new FS::Conf;
50 if ( $cgi->param('error') ) {
51 $custnum = scalar($cgi->param('custnum'));
54 unless $curuser->access_right(($custnum ? 'Edit' : 'New'). ' customer'); #payment methods?
56 } elsif ( $cgi->keywords ) { #editing
57 $custnum = ($cgi->keywords)[0];
60 unless $curuser->access_right('Edit customer');
62 } else { #new customer
64 #this doesn't really work here, we're an edit only
65 die "guru meditation #53";
68 unless $curuser->access_right('New customer');
75 'CARD' => [ 'CARD_payinfo' => mt('Card number'),
77 label => 'Expiration',
78 type => 'select-month_year',
81 'CARD_paycvv' => 'CVV2', #XXX help popup
82 'CARD_payname' => mt('Exact name on card'),
83 'CARD_payauto' => { label => mt('Charge future payments to this credit card automatically'),
87 'CHEK' => [ 'CHEK_payinfo1' => mt('Account number'),
88 'CHEK_paytype' => { label => 'Type',
90 #@FS::cust_main::paytypes #??
92 'CHEK_payinfo2' => mt('ABA/Routing number'), #XXX help popup
93 'CHEK_exp_month' => { type => 'hidden',
96 'CHEK_exp_year' => { type => 'hidden',
99 'CHEK_payname' => mt('Bank name'),
100 #'CHEK_paystate' => { label => $paystate_label,
101 # type => 'select-state',
103 'CHEK_payauto' => { label => mt('Charge future payments to this electronic check automatically'),
108 'BILL' => [ 'BILL_payinfo' => mt('P.O.'),
109 'BILL_exp_month' => { type => 'hidden',
112 'BILL_exp_year' => { type => 'hidden',
115 'BILL_payname' => mt('Attention'),
118 'COMP_payinfo' => mt('Approved by'),
124 my $payby_layer_values = sub {
125 my ( $cgi, $cust_payby, $switches ) = @_;
127 # #map { $_ => { $part_event_condition->options } }
128 # # keys %condition_fields
129 # map { my $conditionname = $_;
130 # my %opts = $switches->{'mode'} eq 'error'
131 # ? %{ $cgi_conditions{$conditionname} || {} }
132 # : $part_event_condition->options;
134 # map { ( "$conditionname.$_" => $opts{$_} ); }
137 # ( $conditionname => \%opts );
139 # keys %condition_fields
144 #my $new_callback = sub {
145 # my( $cgi, $cust_main, $fields_listref, $opt_hashref ) = @_;
148 #my $edit_callback = sub {
149 # my( $cgi, $cust_main, $fields_listref, $opt_hashref ) = @_;
152 #my $error_callback = sub {
153 # my( $cgi, $cust_main, $fields_listref, $opt_hashref ) = @_;
156 my $m2_error_callback = sub {
157 my($cgi, $object) = @_;
161 #process_o2m fields in process/cust_main-contacts.html
162 my @fields = qw( first last title comment );
163 my @gfields = ( '', map "_$_", @fields );
166 if ( /^contactnum(\d+)$/ ) {
168 if ( grep $cgi->param("contactnum$num$_"), @gfields ) {
169 my $x = new FS::contact {
170 'contactnum' => scalar($cgi->param("contactnum$num")),
171 map { $_ => scalar($cgi->param("contactnum${num}_$_")) } @fields,