optimize CDR rating after timed rate perf regression, RT#15739
[freeside.git] / httemplate / edit / part_bill_event.cgi
1 <% include('/elements/header.html',
2       "$action Invoice Event Definition",
3       menubar(
4         'View all invoice events' => popurl(2). 'browse/part_bill_event.cgi',
5       )
6     )
7 %>
8
9 <% include('/elements/error.html') %>
10
11 <FORM ACTION="<% popurl(1) %>process/part_bill_event.cgi" NAME="editEvent" METHOD=POST>
12 <INPUT TYPE="hidden" NAME="eventpart" VALUE="<% $part_bill_event->eventpart %>">
13 Invoice Event #<% $hashref->{eventpart} ? $hashref->{eventpart} : "(NEW)" %>
14
15 <%  ntable("#cccccc",2) %>
16
17   <TR>
18     <TD ALIGN="right">Event name </TD>
19     <TD><INPUT TYPE="text" NAME="event" VALUE="<% $hashref->{event} %>"></TD>
20   </TR>
21
22   <TR>
23     <TD ALIGN="right">For </TD>
24     <TD>
25       <SELECT NAME="payby" <% $hashref->{eventpart} ? '' : 'MULTIPLE SIZE=7'%>>
26 % tie my %payby, 'Tie::IxHash', FS::payby->cust_payby2longname;
27 %           foreach my $payby ( keys %payby ) {
28           <OPTION VALUE="<% $payby %>"<% ($part_bill_event->payby eq $payby) ? ' SELECTED' : '' %>><% $payby{$payby} %></OPTION>
29 % } 
30       </SELECT> customers
31     </TD>
32   </TR>
33 % my $days = $hashref->{seconds}/86400; 
34
35
36   <TR>
37     <TD ALIGN="right">After</TD>
38     <TD><INPUT TYPE="text" NAME="days" VALUE="<% $days %>"> days</TD>
39   </TR>
40
41   <TR>
42     <TD ALIGN="right">Test event</TD>
43     <TD>
44       <SELECT NAME="freq">
45 % tie my %freq, 'Tie::IxHash', '1d' => 'daily', '1m' => 'monthly';
46 %           foreach my $freq ( keys %freq ) {
47 %        
48
49
50           <OPTION VALUE="<% $freq %>"<% ($part_bill_event->freq eq $freq) ? ' SELECTED' : '' %>><% $freq{$freq} %></OPTION>
51 % } 
52
53
54       </SELECT>
55     </TD>
56   </TR>
57
58
59   <TR>
60     <TD ALIGN="right">Disabled</TD>
61     <TD>
62       <INPUT TYPE="checkbox" NAME="disabled" VALUE="Y"<% $hashref->{disabled} eq 'Y' ? ' CHECKED' : '' %>>
63     </TD>
64   </TR>
65
66   <TR>
67     <TD VALIGN="top" ALIGN="right">Action</TD>
68     <TD>
69 %
70 %
71 %#print ntable();
72 %
73 %sub select_pkgpart {
74 %  my $label = shift;
75 %  my $plandata = shift;
76 %  my %selected = map { $_=>1 } split(/,\s*/, $plandata->{$label});
77 %  qq(<SELECT NAME="$label" MULTIPLE>).
78 %  join("\n", map {
79 %    '<OPTION VALUE="'. $_->pkgpart. '"'.
80 %    ( $selected{$_->pkgpart} ? ' SELECTED' : '' ).
81 %    '>'. $_->pkg_comment
82 %  } qsearch('part_pkg', { 'disabled' => '' } ) ).
83 %  '</SELECT>';
84 %}
85 %
86 %sub select_agentnum {
87 %  my $plandata = shift;
88 %  #my $agentnum = $plandata->{'agentnum'};
89 %  my %agentnums = map { $_=>1 } split(/,\s*/, $plandata->{'agentnum'});
90 %  '<SELECT NAME="agentnum" MULTIPLE>'.
91 %  join("\n", map {
92 %    '<OPTION VALUE="'. $_->agentnum. '"'.
93 %    ( $agentnums{$_->agentnum} ? ' SELECTED' : '' ).
94 %    '>'. $_->agent
95 %  } qsearch('agent', { 'disabled' => '' } ) ).
96 %  '</SELECT>';
97 %}
98 %
99 %sub honor_dundate {
100 %  my $label = shift;
101 %  my $plandata = shift;
102 %  '<TABLE>'.
103 %  '<TR><TD ALIGN="right">Allow delay until dun date? </TD>'.
104 %  qq(<TD><INPUT TYPE="checkbox" NAME="$label" VALUE="$label => 1," ).
105 %    ( $plandata->{$label} eq "$label => 1," ? 'CHECKED' : '' ).
106 %  '>'.
107 %  '</TD></TR>'.
108 %  '</TABLE>'
109 %}
110 %
111 %my $conf = new FS::Conf;
112 %my $money_char = $conf->config('money_char') || '$';
113 %
114 %my $late_taxclass = '';
115 %my $late_percent_taxclass = '';
116 %if ( $conf->exists('enable_taxclasses') ) {
117 %  $late_taxclass =
118 %    '<BR>Taxclass '.
119 %    include('/elements/select-taxclass.html',
120 %              'curr_value' => '%%%late_taxclass%%%',
121 %              'name' => 'late_taxclass' );
122 %  $late_percent_taxclass =
123 %    '<BR>Taxclass '.
124 %    include('/elements/select-taxclass.html',
125 %              'curr_value' => '%%%late_percent_taxclass%%%',
126 %              'name' => 'late_percent_taxclass' );
127 %}
128 %
129 %#this is pretty kludgy right here.
130 %tie my %events, 'Tie::IxHash',
131 %
132 %  'fee' => {
133 %    'name'   => 'Late fee (flat)',
134 %    'code'   => '$cust_main->charge( %%%charge%%%, \'%%%reason%%%\', \'$%%%charge%%%\', \'%%%late_taxclass%%%\' );',
135 %    'html'   => 
136 %      'Amount <INPUT TYPE="text" SIZE="7" NAME="charge" VALUE="%%%charge%%%">'.
137 %      '<BR>Reason <INPUT TYPE="text" NAME="reason" VALUE="%%%reason%%%">'.
138 %      $late_taxclass,
139 %    'weight' => 10,
140 %  },
141 %  'fee_percent' => {
142 %    'name'   => 'Late fee (percentage)',
143 %    'code'   => '$cust_main->charge( sprintf(\'%.2f\', $cust_bill->owed * %%%percent%%% / 100 ), \'%%%percent_reason%%%\', \'%%%percent%%% percent\', \'%%%late_percent_taxclass%%%\' );',
144 %    'html'   => 
145 %      'Percent <INPUT TYPE="text" SIZE="2" NAME="percent" VALUE="%%%percent%%%">%'.
146 %      '<BR>Reason <INPUT TYPE="text" NAME="percent_reason" VALUE="%%%percent_reason%%%">'.
147 %      $late_percent_taxclass,
148 %    'weight' => 10,
149 %  },
150 %  'suspend' => {
151 %    'name'   => 'Suspend',
152 %    'code'   => '$cust_main->suspend(reason => %%%sreason%%%, %%%honor_dundate%%% );',
153 %    'html'   => sub { &honor_dundate('honor_dundate', @_) },
154 %    'weight' => 10,
155 %    'reason' => 'S',
156 %  },
157 %  'suspend-if-balance' => {
158 %    'name'   => 'Suspend if balance (this invoice and previous) over',
159 %    'code'   => '$cust_bill->cust_suspend_if_balance_over( %%%balanceover%%%, reason => %%%sreason%%%, %%%balance_honor_dundate%%% );',
160 %    'html'   => sub { " $money_char ". '<INPUT TYPE="text" SIZE="7" NAME="balanceover" VALUE="%%%balanceover%%%"> '. &honor_dundate('balance_honor_dundate', @_) },
161 %    'weight' => 10,
162 %    'reason' => 'S',
163 %  },
164 %  'suspend-if-pkgpart' => {
165 %    'name'   => 'Suspend packages',
166 %    'code'   => '$cust_main->suspend_if_pkgpart({pkgparts => [%%%if_pkgpart%%%,], reason => %%%sreason%%%, %%%if_pkgpart_honor_dundate%%% });',
167 %    'html'   => sub { &select_pkgpart('if_pkgpart', @_). &honor_dundate('if_pkgpart_honor_dundate', @_) },
168 %    'weight' => 10,
169 %    'reason' => 'S',
170 %  },
171 %  'suspend-unless-pkgpart' => {
172 %    'name'   => 'Suspend packages except',
173 %    'code'   => '$cust_main->suspend_unless_pkgpart({unless_pkgpart => [%%%unless_pkgpart%%%], reason => %%%sreason%%%, %%%unless_pkgpart_honor_dundate%%% });',
174 %    'html'   => sub { &select_pkgpart('unless_pkgpart', @_). &honor_dundate('unless_pkgpart_honor_dundate' => @_) },
175 %    'weight' => 10,
176 %    'reason' => 'S',
177 %  },
178 %  'cancel' => {
179 %    'name'   => 'Cancel',
180 %    'code'   => '$cust_main->cancel(reason => %%%creason%%%);',
181 %    'weight' => 80, #10,
182 %    'reason' => 'C',
183 %  },
184 %
185 %  'addpost' => {
186 %    'name' => 'Add postal invoicing',
187 %    'code' => '$cust_main->invoicing_list_addpost(); "";',
188 %    'weight'  => 20,
189 %  },
190 %
191 %  'comp' => {
192 %    'name' => 'Pay invoice with a complimentary "payment"',
193 %    'code' => '$cust_bill->comp();',
194 %    'weight' => 90, #30,
195 %  },
196 %
197 %  'credit' => {
198 %    'name'   => "Create and apply a credit for the customer's balance (i.e. write off as bad debt)",
199 %    'code'   => '$cust_main->credit( $cust_main->balance, \'%%%credit_reason%%%\' );',
200 %    'html'   => '<INPUT TYPE="text" NAME="credit_reason" VALUE="%%%credit_reason%%%">',
201 %    'weight' => 30,
202 %  },
203 %
204 %  'realtime-card' => {
205 %    'name' => 'Run card with a <a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a> realtime gateway',
206 %    'code' => '$cust_bill->realtime_card();',
207 %    'weight' => 30,
208 %  },
209 %
210 %  'realtime-check' => {
211 %    'name' => 'Run check with a <a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a> realtime gateway',
212 %    'code' => '$cust_bill->realtime_ach();',
213 %    'weight' => 30,
214 %  },
215 %
216 %  'realtime-lec' => {
217 %    'name' => 'Run phone bill ("LEC") billing with a <a href="http://search.cpan.org/search?mode=module&query=Business%3A%3AOnlinePayment">Business::OnlinePayment</a> realtime gateway',
218 %    'code' => '$cust_bill->realtime_lec();',
219 %    'weight' => 30,
220 %  },
221 %
222 %  'batch-card' => {
223 %    'name' => 'Add card or check to a pending batch',
224 %    'code' => '$cust_bill->batch_card(%options);',
225 %    'weight' => 40,
226 %  },
227 %
228 %  
229 %  #'retriable' => {
230 %  #  'name' => 'Mark batched card event as retriable',
231 %  #  'code' => '$cust_pay_batch->retriable();',
232 %  #  'weight' => 60,
233 %  #},
234 %
235 %  'send' => {
236 %    'name' => 'Send invoice (email/print/fax)',
237 %    'code' => '$cust_bill->send();',
238 %    'weight' => 50,
239 %  },
240 %
241 %  'send_email' => {
242 %    'name' => 'Send invoice (email only)',
243 %    'code' => '$cust_bill->email();',
244 %    'weight' => 50,
245 %  },
246 %
247 %  'send_alternate' => {
248 %    'name' => 'Send invoice (email/print/fax) with alternate template',
249 %    'code' => '$cust_bill->send(\'%%%templatename%%%\');',
250 %    'html' =>
251 %        '<INPUT TYPE="text" NAME="templatename" VALUE="%%%templatename%%%">',
252 %    'weight' => 50,
253 %  },
254 %
255 %  'send_if_newest' => {
256 %    'name' => 'Send invoice (email/print/fax) with alternate template, if it is still the newest invoice (useful for late notices - set to 31 days or later)',
257 %    'code' => '$cust_bill->send_if_newest(\'%%%if_newest_templatename%%%\');',
258 %    'html' =>
259 %        '<INPUT TYPE="text" NAME="if_newest_templatename" VALUE="%%%if_newest_templatename%%%">',
260 %    'weight' => 50,
261 %  },
262 %
263 %  'send_agent' => {
264 %    'name' => 'Send invoice (email/print/fax) ',
265 %    'code' => '$cust_bill->send( \'%%%agent_templatename%%%\',
266 %                                 [ %%%agentnum%%% ],
267 %                                 \'%%%agent_invoice_from%%%\',
268 %                                 %%%agent_balanceover%%%
269 %                               );',
270 %    'html' => sub {
271 %        '<TABLE BORDER=0>
272 %          <TR>
273 %            <TD ALIGN="right">only for agent(s) </TD>
274 %            <TD>'. &select_agentnum(@_). '</TD>
275 %          </TR>
276 %          <TR>
277 %            <TD ALIGN="right">with template </TD>
278 %            <TD>
279 %              <INPUT TYPE="text" NAME="agent_templatename" VALUE="%%%agent_templatename%%%">
280 %            </TD>
281 %          </TR>
282 %          <TR>
283 %            <TD ALIGN="right">email From: </TD>
284 %            <TD>
285 %              <INPUT TYPE="text" NAME="agent_invoice_from" VALUE="%%%agent_invoice_from%%%">
286 %            </TD>
287 %          </TR>
288 %          <TR>
289 %            <TD ALIGN="right">if balance (this invoice and previous) over
290 %            </TD>
291 %            <TD>
292 %              '. $money_char. '<INPUT TYPE="text" SIZE="7" NAME="agent_balanceover" VALUE="%%%agent_balanceover%%%">
293 %            </TD>
294 %          </TR>
295 %        </TABLE>';
296 %    },
297 %    'weight' => 50,
298 %  },
299 %
300 %  'send_csv_ftp' => {
301 %    'name' => 'Upload CSV invoice data to an FTP server',
302 %    'code' => '$cust_bill->send_csv( protocol   => \'ftp\',
303 %                                     server     => \'%%%ftpserver%%%\',
304 %                                     username   => \'%%%ftpusername%%%\',
305 %                                     password   => \'%%%ftppassword%%%\',
306 %                                     dir        => \'%%%ftpdir%%%\',
307 %                                     \'format\' => \'%%%ftpformat%%%\',
308 %                                   );',
309 %    'html' =>
310 %        '<TABLE BORDER=0>'.
311 %        '<TR><TD ALIGN="right">Format ("default" or "billco"): </TD>'.
312 %          '<TD>'.
313 %            '<!--'.
314 %            '<SELECT NAME="ftpformat">'.
315 %              '<OPTION VALUE="default">Default'.
316 %              '<OPTION VALUE="billco">Billco'.
317 %            '</SELECT>'.
318 %            '-->'.
319 %            '<INPUT TYPE="text" NAME="ftpformat" VALUE="%%%ftpformat%%%">'.
320 %          '</TD></TR>'.
321 %        '<TR><TD ALIGN="right">FTP server: </TD>'.
322 %          '<TD><INPUT TYPE="text" NAME="ftpserver" VALUE="%%%ftpserver%%%">'.
323 %          '</TD></TR>'.
324 %        '<TR><TD ALIGN="right">FTP username: </TD><TD>'.
325 %          '<INPUT TYPE="text" NAME="ftpusername" VALUE="%%%ftpusername%%%">'.
326 %          '</TD></TR>'.
327 %        '<TR><TD ALIGN="right">FTP password: </TD><TD>'.
328 %          '<INPUT TYPE="text" NAME="ftppassword" VALUE="%%%ftppassword%%%">'.
329 %          '</TD></TR>'.
330 %        '<TR><TD ALIGN="right">FTP directory: </TD>'.
331 %          '<TD><INPUT TYPE="text" NAME="ftpdir" VALUE="%%%ftpdir%%%">'.
332 %          '</TD></TR>'.
333 %        '</TABLE>',
334 %    'weight' => 50,
335 %  },
336 %
337 %  'spool_csv' => {
338 %    'name' => 'Spool CSV invoice data',
339 %    'code' => '$cust_bill->spool_csv(
340 %                 \'format\' => \'%%%spoolformat%%%\',
341 %                 \'dest\'   => \'%%%spooldest%%%\',
342 %                 \'balanceover\' => \'%%%spoolbalanceover%%%\',
343 %                 \'agent_spools\' => \'%%%spoolagent_spools%%%\',
344 %               );',
345 %    'html' => sub {
346 %       my $plandata = shift;
347 %
348 %       my $html =
349 %       '<TABLE BORDER=0>'.
350 %       '<TR><TD ALIGN="right">Format: </TD>'.
351 %         '<TD>'.
352 %           '<SELECT NAME="spoolformat">';
353 %
354 %       foreach my $option (qw( default billco )) {
355 %         $html .= qq(<OPTION VALUE="$option");
356 %         $html .= ' SELECTED' if $option eq $plandata->{'spoolformat'};
357 %         $html .= ">\u$option";
358 %       }
359 %
360 %       $html .= 
361 %           '</SELECT>'.
362 %         '</TD></TR>'.
363 %       '<TR><TD ALIGN="right">For destination: </TD>'.
364 %         '<TD>'.
365 %           '<SELECT NAME="spooldest">';
366 %
367 %       tie my %dest, 'Tie::IxHash', 
368 %         ''      => '(all)',
369 %         'POST'  => 'Postal Mail',
370 %         'EMAIL' => 'Email',
371 %         'FAX'   => 'Fax',
372 %       ;
373 %
374 %       foreach my $dest (keys %dest) {
375 %         $html .= qq(<OPTION VALUE="$dest");
376 %         $html .= ' SELECTED' if $dest eq $plandata->{'spooldest'};
377 %         $html .= '>'. $dest{$dest};
378 %       }
379 %
380 %       $html .=
381 %           '</SELECT>'.
382 %         '</TD></TR>'.
383 %
384 %       '<TR>'.
385 %         '<TD ALIGN="right">if balance (this invoice and previous) over </TD>'.
386 %         '<TD>'.
387 %           "$money_char ".
388 %           '<INPUT TYPE="text" SIZE="7" NAME="spoolbalanceover" VALUE="%%%spoolbalanceover%%%">'.
389 %         '</TD>'.
390 %       '<TR><TD ALIGN="right">Individual per-agent spools? </TD>'.
391 %         '<TD><INPUT TYPE="checkbox" NAME="spoolagent_spools" VALUE="1" '.
392 %           ( $plandata->{'spoolagent_spools'} ? 'CHECKED' : '' ).
393 %           '>'.
394 %         '</TD></TR>'.
395 %       '</TABLE>';
396 %
397 %       $html;
398 %    },
399 %    'weight' => 50,
400 %  },
401 %
402 %  'bill' => {
403 %    'name' => 'Generate invoices (normally only used with a <i>Late Fee</i> event)',
404 %    'code' => '$cust_main->bill();',
405 %    'weight'  => 60,
406 %  },
407 %
408 %  'apply' => {
409 %    'name' => 'Apply unapplied payments and credits',
410 %    'code' => '$cust_main->apply_payments_and_credits; "";',
411 %    'weight'  => 70,
412 %  },
413 %
414 %;
415 %
416 <SCRIPT TYPE="text/javascript">var myreasons = new Array();</SCRIPT>
417 %foreach my $event ( keys %events ) {
418 %  my %plandata = map { /^(\w+) (.*)$/; ($1, $2); }
419 %                   split(/\n/, $part_bill_event->plandata);
420 %  my $html = $events{$event}{html};
421 %  if ( ref($html) eq 'CODE' ) {
422 %    $html = &{$html}(\%plandata);
423 %  }
424 %  while ( $html =~ /%%%(\w+)%%%/ ) {
425 %    my $field = $1;
426 %    $html =~ s/%%%$field%%%/$plandata{$field}/;
427 %  }
428 %
429 <SCRIPT TYPE="text/javascript">myreasons.push('<% $events{$event}{reason} %>');
430 </SCRIPT>
431 %  if ($event eq $part_bill_event->plan){
432 %    $currentreasonclass=$events{$event}{reason};
433 %  }
434 %  print ntable( "#cccccc", 2).
435 %        qq!<TR><TD><INPUT TYPE="radio" NAME="plan_weight_eventcode" !;
436 %  print "CHECKED " if $event eq $part_bill_event->plan;
437 %  print qq!onClick="showhide_table()" !;
438 %  print qq!VALUE="!.  $event. ":". $events{$event}{weight}. ":".
439 %        encode_entities($events{$event}{code}).
440 %        qq!">$events{$event}{name}</TD>!;
441 %  print '<TD>'. $html. '</TD>' if $html;
442 %  print qq!</TR>!;
443 %  print '</TABLE>';
444 %  print qq!<HR WIDTH="90%">!;
445 %}
446 %
447 %  if ($currentreasonclass eq 'C'){
448 %    if ($cgi->param('creason') =~ /^(-?\d+)$/){
449 %      $creason =  $1;
450 %    }else{
451 %      $creason = $part_bill_event->reason;
452 %    }
453 %    if ($cgi->param('newcreasonT') =~ /^(\d+)$/){
454 %      $newcreasonT =  $1;
455 %    }
456 %    if ($cgi->param('newcreason') =~ /^([\w\s]+)$/){
457 %      $newcreason =  $1;
458 %    }
459 %  }elsif ($currentreasonclass eq 'S'){
460 %    if ($cgi->param('sreason') =~ /^(-?\d+)$/){
461 %      $sreason =  $1;
462 %    }else{
463 %      $sreason = $part_bill_event->reason;
464 %    }
465 %    if ($cgi->param('newsreasonT') =~ /^(\d+)$/){
466 %      $newsreasonT =  $1;
467 %    }
468 %    if ($cgi->param('newsreason') =~ /^([\w\s]+)$/){
469 %      $newsreason =  $1;
470 %    }
471 %  }
472 %
473
474 </TD></TR>
475 </TABLE>
476
477 <SCRIPT TYPE="text/javascript">
478   function showhide_table()
479   {
480     for(i=0;i<document.editEvent.plan_weight_eventcode.length;i++){
481       if (document.editEvent.plan_weight_eventcode[i].checked == true){
482         currentevent=i;
483       }
484     }
485     if(myreasons[currentevent] == 'C'){
486       document.getElementById('Ctable').style.display = 'inline';
487       document.getElementById('Stable').style.display = 'none';
488     }else if(myreasons[currentevent] == 'S'){
489       document.getElementById('Ctable').style.display = 'none';
490       document.getElementById('Stable').style.display = 'inline';
491     }else{
492       document.getElementById('Ctable').style.display = 'none';
493       document.getElementById('Stable').style.display = 'none';
494     }
495   }
496 </SCRIPT>
497
498 <TABLE BGCOLOR="#cccccc" BORDER=0 WIDTH="100%">
499 <TR><TD>
500 <TABLE BORDER=0 id="Ctable" style="display:<% $currentreasonclass eq 'C' ? 'inline' : 'none' %>">
501 <% include('/elements/tr-select-reason.html',
502              'field'          => 'creason',
503              'reason_class'   => 'C',
504              'curr_value'     => $creason,
505              'init_type'      => $newcreasonT,
506              'init_newreason' => $newcreason
507           )
508 %>
509 </TABLE>
510 </TR></TD>
511 </TABLE>
512
513 <TABLE BGCOLOR="#cccccc" BORDER=0 WIDTH="100%">
514 <TR><TD>
515 <TABLE BORDER=0 id="Stable" style="display:<% $currentreasonclass eq 'S' ? 'inline' : 'none' %>">
516 <% include('/elements/tr-select-reason.html',
517              'field'          => 'sreason',
518              'reason_class'   => 'S',
519              'curr_value'     => $sreason,
520              'init_type'      => $newsreasonT,
521              'init_newreason' => $newsreason
522           )
523 %>
524 </TABLE>
525 </TR></TD>
526 </TABLE>
527     
528 %
529 %print qq!<INPUT TYPE="submit" VALUE="!,
530 %      $hashref->{eventpart} ? "Apply changes" : "Add invoice event",
531 %      qq!">!;
532 %
533
534
535     </FORM>
536
537 <% include('/elements/footer.html') %>
538
539 <%init>
540
541 die "access denied"
542   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
543
544 if ( $cgi->param('eventpart') && $cgi->param('eventpart') =~ /^(\d+)$/ ) {
545   $cgi->param('eventpart', $1);
546 } else {
547   $cgi->param('eventpart', '');
548 }
549
550 my ($creason, $newcreasonT, $newcreason);
551 my ($sreason, $newsreasonT, $newsreason);
552
553 my ($query) = $cgi->keywords;
554 my $action = '';
555 my $part_bill_event = '';
556 my $currentreasonclass = '';
557 if ( $cgi->param('error') ) {
558   $part_bill_event = new FS::part_bill_event ( {
559     map { $_, scalar($cgi->param($_)) } fields('part_bill_event')
560   } );
561 }
562 if ( $query && $query =~ /^(\d+)$/ ) {
563   $part_bill_event ||= qsearchs('part_bill_event',{'eventpart'=>$1});
564 } else {
565   $part_bill_event ||= new FS::part_bill_event {};
566 }
567 $action ||= $part_bill_event->eventpart ? 'Edit' : 'Add';
568 my $hashref = $part_bill_event->hashref;
569
570 </%init>