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