This commit was generated by cvs2svn to compensate for changes in r6255,
[freeside.git] / httemplate / edit / part_bill_event.cgi
index 0921a95..2547067 100755 (executable)
@@ -1,49 +1,12 @@
-<!--mason kludge-->
-%
-%
-%if ( $cgi->param('eventpart') && $cgi->param('eventpart') =~ /^(\d+)$/ ) {
-%  $cgi->param('eventpart', $1);
-%} else {
-%  $cgi->param('eventpart', '');
-%}
-%
-%my ($creason, $newcreasonT, $newcreason);
-%my ($sreason, $newsreasonT, $newsreason);
-%
-%
-%my ($query) = $cgi->keywords;
-%my $action = '';
-%my $part_bill_event = '';
-%my $currentreasonclass = '';
-%if ( $cgi->param('error') ) {
-%  $part_bill_event = new FS::part_bill_event ( {
-%    map { $_, scalar($cgi->param($_)) } fields('part_bill_event')
-%  } );
-%}
-%if ( $query && $query =~ /^(\d+)$/ ) {
-%  $part_bill_event ||= qsearchs('part_bill_event',{'eventpart'=>$1});
-%} else {
-%  $part_bill_event ||= new FS::part_bill_event {};
-%}
-%$action ||= $part_bill_event->eventpart ? 'Edit' : 'Add';
-%my $hashref = $part_bill_event->hashref;
-%
-%
-
-
 <% include('/elements/header.html',
       "$action Invoice Event Definition",
       menubar(
-        'Main Menu' => popurl(2),
         'View all invoice events' => popurl(2). 'browse/part_bill_event.cgi',
       )
     )
 %>
-% if ( $cgi->param('error') ) { 
-
-  <FONT SIZE="+1" COLOR="#ff0000">Error: <% $cgi->param('error') %></FONT>
-% } 
 
+<% include('/elements/error.html') %>
 
 <FORM ACTION="<% popurl(1) %>process/part_bill_event.cgi" NAME="editEvent" METHOD=POST>
 <INPUT TYPE="hidden" NAME="eventpart" VALUE="<% $part_bill_event->eventpart %>">
@@ -141,23 +104,38 @@ Invoice Event #<% $hashref->{eventpart} ? $hashref->{eventpart} : "(NEW)" %>
 %my $conf = new FS::Conf;
 %my $money_char = $conf->config('money_char') || '$';
 %
+%my $late_taxclass = '';
+%my $late_percent_taxclass = '';
+%if ( $conf->exists('enable_taxclasses') ) {
+%  $late_taxclass =
+%    '<BR>Taxclass '.
+%    include('/elements/select-taxclass.html', '%%%late_taxclass%%%',
+%              'name' => 'late_taxclass' );
+%  $late_percent_taxclass =
+%    '<BR>Taxclass '.
+%    include('/elements/select-taxclass.html', '%%%late_percent_taxclass%%%',
+%              'name' => 'late_percent_taxclass' );
+%}
+%
 %#this is pretty kludgy right here.
 %tie my %events, 'Tie::IxHash',
 %
 %  'fee' => {
 %    'name'   => 'Late fee (flat)',
-%    'code'   => '$cust_main->charge( %%%charge%%%, \'%%%reason%%%\' );',
+%    'code'   => '$cust_main->charge( %%%charge%%%, \'%%%reason%%%\', \'$%%%charge%%%\', \'%%%late_taxclass%%%\' );',
 %    'html'   => 
 %      'Amount <INPUT TYPE="text" SIZE="7" NAME="charge" VALUE="%%%charge%%%">'.
-%      '<BR>Reason <INPUT TYPE="text" NAME="reason" VALUE="%%%reason%%%">',
+%      '<BR>Reason <INPUT TYPE="text" NAME="reason" VALUE="%%%reason%%%">'.
+%      $late_taxclass,
 %    'weight' => 10,
 %  },
 %  'fee_percent' => {
 %    'name'   => 'Late fee (percentage)',
-%    'code'   => '$cust_main->charge( sprintf(\'%.2f\', $cust_bill->owed * %%%percent%%% / 100 ), \'%%%reason%%%\' );',
+%    'code'   => '$cust_main->charge( sprintf(\'%.2f\', $cust_bill->owed * %%%percent%%% / 100 ), \'%%%percent_reason%%%\', \'%%%percent%%% percent\', \'%%%late_percent_taxclass%%%\' );',
 %    'html'   => 
 %      'Percent <INPUT TYPE="text" SIZE="2" NAME="percent" VALUE="%%%percent%%%">%'.
-%      '<BR>Reason <INPUT TYPE="text" NAME="reason" VALUE="%%%reason%%%">',
+%      '<BR>Reason <INPUT TYPE="text" NAME="percent_reason" VALUE="%%%percent_reason%%%">'.
+%      $late_percent_taxclass,
 %    'weight' => 10,
 %  },
 %  'suspend' => {
@@ -208,8 +186,8 @@ Invoice Event #<% $hashref->{eventpart} ? $hashref->{eventpart} : "(NEW)" %>
 %
 %  'credit' => {
 %    'name'   => "Create and apply a credit for the customer's balance (i.e. write off as bad debt)",
-%    'code'   => '$cust_main->credit( $cust_main->balance, \'%%%reason%%%\' );',
-%    'html'   => '<INPUT TYPE="text" NAME="reason" VALUE="%%%reason%%%">',
+%    'code'   => '$cust_main->credit( $cust_main->balance, \'%%%credit_reason%%%\' );',
+%    'html'   => '<INPUT TYPE="text" NAME="credit_reason" VALUE="%%%credit_reason%%%">',
 %    'weight' => 30,
 %  },
 %
@@ -504,7 +482,14 @@ Invoice Event #<% $hashref->{eventpart} ? $hashref->{eventpart} : "(NEW)" %>
 <TABLE BGCOLOR="#cccccc" BORDER=0 WIDTH="100%">
 <TR><TD>
 <TABLE BORDER=0 id="Ctable" style="display:<% $currentreasonclass eq 'C' ? 'inline' : 'none' %>">
-<% include('/elements/tr-select-reason.html', 'creason', 'C', $creason, $newcreasonT, $newcreason) %>
+<% include('/elements/tr-select-reason.html',
+             'field'          => 'creason',
+             'reason_class'   => 'C',
+             'curr_value'     => $creason,
+             'init_type'      => $newcreasonT,
+             'init_newreason' => $newcreason
+          )
+%>
 </TABLE>
 </TR></TD>
 </TABLE>
@@ -512,7 +497,14 @@ Invoice Event #<% $hashref->{eventpart} ? $hashref->{eventpart} : "(NEW)" %>
 <TABLE BGCOLOR="#cccccc" BORDER=0 WIDTH="100%">
 <TR><TD>
 <TABLE BORDER=0 id="Stable" style="display:<% $currentreasonclass eq 'S' ? 'inline' : 'none' %>">
-<% include('/elements/tr-select-reason.html', 'sreason', 'S', $sreason, $newsreasonT, $newsreason) %>
+<% include('/elements/tr-select-reason.html',
+             'field'          => 'sreason',
+             'reason_class'   => 'S',
+             'curr_value'     => $sreason,
+             'init_type'      => $newsreasonT,
+             'init_newreason' => $newsreason
+          )
+%>
 </TABLE>
 </TR></TD>
 </TABLE>
@@ -525,7 +517,38 @@ Invoice Event #<% $hashref->{eventpart} ? $hashref->{eventpart} : "(NEW)" %>
 
 
     </FORM>
-  </BODY>
-</HTML>
 
+<% include('/elements/footer.html') %>
+
+<%init>
+
+die "access denied"
+  unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
+
+if ( $cgi->param('eventpart') && $cgi->param('eventpart') =~ /^(\d+)$/ ) {
+  $cgi->param('eventpart', $1);
+} else {
+  $cgi->param('eventpart', '');
+}
+
+my ($creason, $newcreasonT, $newcreason);
+my ($sreason, $newsreasonT, $newsreason);
+
+my ($query) = $cgi->keywords;
+my $action = '';
+my $part_bill_event = '';
+my $currentreasonclass = '';
+if ( $cgi->param('error') ) {
+  $part_bill_event = new FS::part_bill_event ( {
+    map { $_, scalar($cgi->param($_)) } fields('part_bill_event')
+  } );
+}
+if ( $query && $query =~ /^(\d+)$/ ) {
+  $part_bill_event ||= qsearchs('part_bill_event',{'eventpart'=>$1});
+} else {
+  $part_bill_event ||= new FS::part_bill_event {};
+}
+$action ||= $part_bill_event->eventpart ? 'Edit' : 'Add';
+my $hashref = $part_bill_event->hashref;
 
+</%init>