X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fedit%2Fprocess%2Fpart_bill_event.cgi;h=1716c71b9d3c6ed3ce3e5d48fd951b48ad21ba7d;hp=eb7c53e5d8d2f1e18425547fc68f6fa625a97afe;hb=c828daa905491e65deb30a2ed34af609cdb96b99;hpb=6991d4986df7fb3a6c7c49b5ae1b3713e87a16c4 diff --git a/httemplate/edit/process/part_bill_event.cgi b/httemplate/edit/process/part_bill_event.cgi index eb7c53e5d..1716c71b9 100755 --- a/httemplate/edit/process/part_bill_event.cgi +++ b/httemplate/edit/process/part_bill_event.cgi @@ -5,21 +5,42 @@ 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'), + } ); + + if ( $eventpart ) { + $error = $new->replace($old); + } else { + $error = $new->insert; + $eventpart = $new->getfield('eventpart'); + } +} if ( $error ) { $cgi->param('error', $error);