1 <!-- $Id: part_bill_event.cgi,v 1.5 2002-02-04 17:04:33 ivan Exp $ -->
5 if ( $cgi->param('eventpart') && $cgi->param('eventpart') =~ /^(\d+)$/ ) {
6 $cgi->param('eventpart', $1);
8 $cgi->param('eventpart', '');
11 my ($query) = $cgi->keywords;
13 my $part_bill_event = '';
14 if ( $cgi->param('error') ) {
15 $part_bill_event = new FS::part_bill_event ( {
16 map { $_, scalar($cgi->param($_)) } fields('part_bill_event')
19 if ( $query && $query =~ /^(\d+)$/ ) {
20 $part_bill_event ||= qsearchs('part_bill_event',{'eventpart'=>$1});
22 $part_bill_event ||= new FS::part_bill_event {};
24 $action ||= $part_bill_event->pkgpart ? 'Edit' : 'Add';
25 my $hashref = $part_bill_event->hashref;
27 print header("$action Invoice Event Definition", menubar(
28 'Main Menu' => popurl(2),
29 'View all invoice events' => popurl(2). 'browse/part_bill_event.cgi',
32 print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
34 if $cgi->param('error');
36 print '<FORM ACTION="', popurl(1), 'process/part_bill_event.cgi" METHOD=POST>'.
37 '<INPUT TYPE="hidden" NAME="eventpart" VALUE="'.
38 $part_bill_event->eventpart .'">';
39 print "Invoice Event #", $hashref->{eventpart} ? $hashref->{eventpart} : "(NEW)";
41 print ntable("#cccccc",2), <<END;
42 <TR><TD ALIGN="right">Payby</TD><TD><SELECT NAME="payby">
45 for (qw(CARD BILL COMP)) {
46 print qq!<OPTION VALUE="$_"!;
47 if ($part_bill_event->payby eq $_) {
48 print " SELECTED>$_</OPTION>";
54 my $days = $hashref->{seconds}/86400;
58 <TR><TD ALIGN="right">Event</TD><TD><INPUT TYPE="text" NAME="event" VALUE="$hashref->{event}"></TD></TR>
59 <TR><TD ALIGN="right">After</TD><TD><INPUT TYPE="text" NAME="days" VALUE="$days"> days</TD></TR>
62 print '<TR><TD ALIGN="right">Disabled</TD><TD>';
63 print '<INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"';
64 print ' CHECKED' if $hashref->{disabled} eq "Y";
68 print '<TR><TD ALIGN="right">Action</TD><TD>';
72 #this is pretty kludgy right here.
73 tie my %events, 'Tie::IxHash',
77 'code' => '$cust_main->charge( %%%charge%%%, \'%%%reason%%%\' );',
79 'Amount <INPUT TYPE="text" SIZE="7" NAME="charge" VALUE="%%%charge%%%">'.
80 '<BR>Reason <INPUT TYPE="text" NAME="reason" VALUE="%%%reason%%%">',
85 'code' => '$cust_main->suspend();',
90 'code' => '$cust_main->cancel();',
95 'name' => 'Add postal invoicing',
96 'code' => '$cust_main->invoicing_list_addpost(); "";',
101 'name' => 'Pay invoice with a complimentary "payment"',
102 'code' => '$cust_bill->comp();',
107 'name' => 'Run card with a <a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a> realtime gateway',
108 'code' => '$cust_bill->realtime_card();',
112 'realtime-card-cybercash' => {
113 'name' => '(<b>deprecated</b>) Run card with <a href="http://www.cybercash.com/cashregister">CyberCash CashRegister</a> realtime gateway',
114 'code' => '$cust_bill->realtime_card_cybercash();',
119 'name' => 'Add card to the pending credit card batch',
120 'code' => '$cust_bill->batch_card();',
125 'name' => 'Send invoice (email/print)',
126 'code' => '$cust_bill->send();',
131 'name' => 'Generate invoices (normally only used with a <i>Late Fee</i> event)',
132 'code' => '$cust_main->bill();',
137 'name' => 'Apply unapplied payments and credits',
138 'code' => '$cust_main->apply_payments; $cust_main->apply_credits; "";',
143 'name' => 'Collect on invoices (normally only used with a <i>Late Fee</i> and <i>Generate Invoice</i> events)',
144 'code' => '$cust_main->collect();',
150 foreach my $event ( keys %events ) {
151 my %plandata = map { /^(\w+) (.*)$/; ($1, $2); }
152 split(/\n/, $part_bill_event->plandata);
153 my $html = $events{$event}{html};
154 while ( $html =~ /%%%(\w+)%%%/ ) {
156 $html =~ s/%%%$field%%%/$plandata{$field}/;
159 print ntable( "#cccccc", 2).
160 qq!<TR><TD><INPUT TYPE="radio" NAME="plan_weight_eventcode" !;
161 print "CHECKED " if $event eq $part_bill_event->plan;
162 print qq!VALUE="!. $event. ":". $events{$event}{weight}. ":".
163 encode_entities($events{$event}{code}).
164 qq!">$events{$event}{name}</TD>!;
165 print '<TD>'. $html. '</TD>' if $html;
177 print qq!<INPUT TYPE="submit" VALUE="!,
178 $hashref->{eventpart} ? "Apply changes" : "Add invoice event",