summaryrefslogtreecommitdiff
path: root/httemplate/edit
diff options
context:
space:
mode:
authorivan <ivan>2002-01-30 18:22:54 +0000
committerivan <ivan>2002-01-30 18:22:54 +0000
commitc7ff9a58360788ce776022606c4ec3496062013b (patch)
tree82bf1727e804dce87fc452e060466d6da7ddd879 /httemplate/edit
parent1fd6d8cf5d7854860ef4fd10ed89828e0c04ec39 (diff)
fully working invoice event web interface
Diffstat (limited to 'httemplate/edit')
-rwxr-xr-xhttemplate/edit/part_bill_event.cgi53
-rwxr-xr-xhttemplate/edit/process/part_bill_event.cgi46
2 files changed, 68 insertions, 31 deletions
diff --git a/httemplate/edit/part_bill_event.cgi b/httemplate/edit/part_bill_event.cgi
index 939eff360..c41cfe9cf 100755
--- a/httemplate/edit/part_bill_event.cgi
+++ b/httemplate/edit/part_bill_event.cgi
@@ -1,11 +1,11 @@
-<!-- $Id: part_bill_event.cgi,v 1.2 2002-01-30 14:18:08 ivan Exp $ -->
+<!-- $Id: part_bill_event.cgi,v 1.3 2002-01-30 18:22:54 ivan Exp $ -->
<%
-if ( $cgi->param('eventnum') && $cgi->param('eventnum') =~ /^(\d+)$/ ) {
- $cgi->param('eventnum', $1);
+if ( $cgi->param('eventpart') && $cgi->param('eventpart') =~ /^(\d+)$/ ) {
+ $cgi->param('eventpart', $1);
} else {
- $cgi->param('eventnum', '');
+ $cgi->param('eventpart', '');
}
my ($query) = $cgi->keywords;
@@ -33,8 +33,9 @@ print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
"</FONT>"
if $cgi->param('error');
-print '<FORM ACTION="', popurl(1), 'process/part_bill_event.cgi" METHOD=POST>';
-
+print '<FORM ACTION="', popurl(1), 'process/part_bill_event.cgi" METHOD=POST>'.
+ '<INPUT TYPE="hidden" NAME="eventpart" VALUE="'.
+ $part_bill_event->eventpart .'">';
print "Invoice Event #", $hashref->{eventpart} ? $hashref->{eventpart} : "(NEW)";
print ntable("#cccccc",2), <<END;
@@ -50,7 +51,7 @@ for (qw(CARD BILL COMP)) {
}
}
-my $days = $hashref->{seconds}/3600;
+my $days = $hashref->{seconds}/86400;
print <<END;
</SELECT></TD></TR>
@@ -74,8 +75,9 @@ tie my %events, 'Tie::IxHash',
'fee' => {
'name' => 'Late fee',
'code' => '$cust_main->charge( %%%charge%%%, \'%%%reason%%%\' );',
- 'html' => 'Amount <INPUT TYPE="text" SIZE="7" NAME="charge"><BR>'.
- 'Reason <INPUT TYPE="text" NAME="reason">',
+ 'html' =>
+ 'Amount <INPUT TYPE="text" SIZE="7" NAME="charge" VALUE="%%%charge%%%">'.
+ '<BR>Reason <INPUT TYPE="text" NAME="reason" VALUE="%%%reason%%%">',
'weight' => 10,
},
'suspend' => {
@@ -101,29 +103,42 @@ tie my %events, 'Tie::IxHash',
'weight' => 30
},
- 'Generate invoices' => {
+ 'bill' => {
+ 'name' => 'Generate invoices',
'code' => '$cust_main->bill();',
- 'pad' => 40,
+ 'weight' => 40,
},
- 'Apply unapplied payments and credits' => {
+ 'apply' => {
+ 'name' => 'Apply unapplied payments and credits',
'code' => '$cust_main->apply_payments; $cust_main->apply_credits;',
- 'pad' => 50,
+ 'weight' => 50,
},
- 'Collect on invoices' => {
+ 'collect' => {
+ 'name' => 'Collect on invoices',
'code' => '$cust_main->collect();',
- 'pad' => 60,
+ 'weight' => 60,
},
;
foreach my $event ( keys %events ) {
+ my %plandata = map { /^(\w+) (.*)$/; ($1, $2); }
+ split(/\n/, $part_bill_event->plandata);
+ my $html = $events{$event}{html};
+ while ( $html =~ /%%%(\w+)%%%/ ) {
+ my $field = $1;
+ $html =~ s/%%%$field%%%/$plandata{$field}/;
+ }
+
print ntable( "#cccccc", 2).
- qq!<TR><TD><INPUT TYPE="radio" NAME="eventcode" VALUE="!.
- $events{$event}{weight}. ":".
- encode_entities($events{$event}{code}). qq!">$event</TD>!;
- print '<TD>'. $events{$event}{html}. '</TD>' if exists $events{$event}{html};
+ qq!<TR><TD><INPUT TYPE="radio" NAME="plan_weight_eventcode" !;
+ print "CHECKED " if $event eq $part_bill_event->plan;
+ print qq!VALUE="!. $event. ":". $events{$event}{weight}. ":".
+ encode_entities($events{$event}{code}).
+ qq!">$events{$event}{name}</TD>!;
+ print '<TD>'. $html. '</TD>' if $html;
print qq!</TR>!;
print '</TABLE>';
}
diff --git a/httemplate/edit/process/part_bill_event.cgi b/httemplate/edit/process/part_bill_event.cgi
index eb7c53e5d..7c0b54d0d 100755
--- a/httemplate/edit/process/part_bill_event.cgi
+++ b/httemplate/edit/process/part_bill_event.cgi
@@ -5,21 +5,43 @@ my $eventpart = $cgi->param('eventpart');
my $old = qsearchs('part_bill_event',{'eventpart'=>$eventpart}) if $eventpart;
#s/days/seconds/
-$cgi->param('seconds', $cgi->param('days') * 3600 );
-
-my $new = new FS::part_bill_event ( {
- map {
- $_, scalar($cgi->param($_));
- } fields('part_bill_event'),
-} );
+$cgi->param('seconds', $cgi->param('days') * 86400 );
my $error;
-if ( $eventpart ) {
- $error = $new->replace($old);
+if ( ! $cgi->param('plan_weight_eventcode') ) {
+ $error = "Must select an action";
} else {
- $error = $new->insert;
- $eventpart = $new->getfield('eventpart');
-}
+
+ $cgi->param('plan_weight_eventcode') =~ /^(\w+):(\d+):(.*)$/
+ or die "illegal plan_weight_eventcode:".
+ $cgi->param('plan_weight_eventcode');
+ $cgi->param('plan', $1);
+ $cgi->param('weight', $2);
+ my $eventcode = $3;
+ my $plandata = '';
+ while ( $eventcode =~ /%%%(\w+)%%%/ ) {
+ my $field = $1;
+ my $value = $cgi->param($field);
+ $eventcode =~ s/%%%$field%%%/$value/;
+ $plandata .= "$field $value\n";
+ }
+ $cgi->param('eventcode', $eventcode);
+ $cgi->param('plandata', $plandata);
+
+ my $new = new FS::part_bill_event ( {
+ map {
+ $_, scalar($cgi->param($_));
+ } fields('part_bill_event'),
+ } );
+
+ my $error;
+ if ( $eventpart ) {
+ $error = $new->replace($old);
+ } else {
+ $error = $new->insert;
+ $eventpart = $new->getfield('eventpart');
+ }
+}
if ( $error ) {
$cgi->param('error', $error);