1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
%
%my $eventpart = $cgi->param('eventpart');
%
%my $old = qsearchs('part_bill_event',{'eventpart'=>$eventpart}) if $eventpart;
%
%#s/days/seconds/
%$cgi->param('seconds', int( $cgi->param('days') * 86400 ) );
%
%my $error;
%if ( ! $cgi->param('plan_weight_eventcode') ) {
% $error = "Must select an action";
%} else {
%
% $cgi->param('plan_weight_eventcode') =~ /^([\w\-]+):(\d+):(.*)$/s
% or die "illegal plan_weight_eventcode:".
% $cgi->param('plan_weight_eventcode');
% $cgi->param('plan', $1);
% $cgi->param('weight', $2);
% my $eventcode = $3;
% my $plandata = '';
%
% my $rnum;
% my $rtype;
% my $reasonm;
% my $class = '';
% $class='c' if ($eventcode =~ /cancel/);
% $class='s' if ($eventcode =~ /suspend/);
% if ($class) {
% $cgi->param("${class}reason") =~ /^(-?\d+)$/
% or $error = "Invalid ${class}reason";
% $rnum = $1;
% if ($rnum == -1) {
% $cgi->param("new${class}reasonT") =~ /^(\d+)$/
% or $error = "Invalid new${class}reasonT";
% $rtype = $1;
% $cgi->param("new${class}reason") =~ /^([\s\w]+)$/
% or $error = "Invalid new${class}reason";
% $reasonm = $1;
% }
% }
%
% if ($rnum == -1 && !$error) {
% my $reason = new FS::reason ({ 'reason' => $reasonm,
% 'reason_type' => $rtype,
% });
% $error = $reason->insert;
% unless ($error) {
% $rnum = $reason->reasonnum;
% $cgi->param("${class}reason", $rnum);
% $cgi->param("new${class}reason", '');
% $cgi->param("new${class}reasonT", '');
% }
% }
%
% while ( $eventcode =~ /%%%(\w+)%%%/ ) {
% my $field = $1;
% my $value = join(', ', $cgi->param($field) );
% $cgi->param($field, $value); #in case it errors out
% $eventcode =~ s/%%%$field%%%/$value/;
% $plandata .= "$field $value\n";
% }
% $cgi->param('eventcode', $eventcode);
% $cgi->param('plandata', $plandata);
%
% unless($error){
% my $new = new FS::part_bill_event ( {
% map {
% $_, scalar($cgi->param($_));
% } fields('part_bill_event'),
% } );
% $new->setfield('reason', $rnum);
%
% if ( $eventpart ) {
% $error = $new->replace($old);
% } else {
% $error = $new->insert;
% $eventpart = $new->getfield('eventpart');
% }
% }
%}
%
%if ( $error ) {
% $cgi->param('error', $error);
% print $cgi->redirect(popurl(2). "part_bill_event.cgi?". $cgi->query_string );
%} else {
% print $cgi->redirect(popurl(3)."browse/part_bill_event.cgi");
%}
%
%
|