first part of ACL and re-skinning work and some other small stuff
[freeside.git] / httemplate / edit / cust_credit_bill.cgi
index d2d50cb..409ea3c 100755 (executable)
@@ -1,22 +1,6 @@
 <%
-#<!-- $Id: cust_credit_bill.cgi,v 1.4 2001-10-26 10:24:56 ivan Exp $ -->
-
-use strict;
-use vars qw( $cgi $query $custnum $invnum $otaker $p1 $crednum $amount $reason $cust_credit );
-use Date::Format;
-use CGI;
-use CGI::Carp qw(fatalsToBrowser);
-use Date::Format;
-use FS::UID qw(cgisuidsetup getotaker);
-use FS::CGI qw(header popurl);
-use FS::Record qw(qsearch fields);
-use FS::cust_credit;
-use FS::cust_bill;
-
-
-$cgi = new CGI;
-cgisuidsetup($cgi);
 
+my($crednum, $amount, $invnum);
 if ( $cgi->param('error') ) {
   #$cust_credit_bill = new FS::cust_credit_bill ( {
   #  map { $_, scalar($cgi->param($_)) } fields('cust_credit_bill')
@@ -26,7 +10,7 @@ if ( $cgi->param('error') ) {
   #$refund = $cgi->param('refund');
   $invnum = $cgi->param('invnum');
 } else {
-  ($query) = $cgi->keywords;
+  my($query) = $cgi->keywords;
   $query =~ /^(\d+)$/;
   $crednum = $1;
   $amount = '';
@@ -34,82 +18,82 @@ if ( $cgi->param('error') ) {
   $invnum = '';
 }
 
-$otaker = getotaker;
+my $otaker = getotaker;
 
-$p1 = popurl(1);
+my $p1 = popurl(1);
 
-print $cgi->header( @FS::CGI::header ), header("Apply Credit", '');
-print qq!<FONT SIZE="+1" COLOR="#ff0000">Error: !, $cgi->param('error'),
-      "</FONT><BR><BR>"
-  if $cgi->param('error');
-print <<END;
-    <FORM ACTION="${p1}process/cust_credit_bill.cgi" METHOD=POST>
-END
+%><%=  header("Apply Credit", '') %>
 
-die unless $cust_credit = qsearchs('cust_credit', { 'crednum' => $crednum } );
+<% if ( $cgi->param('error') ) { %>
+  <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT>
+  <BR><BR>
+<% } %>
+
+<FORM ACTION="<%= $p1 %>process/cust_credit_bill.cgi" METHOD=POST>
+
+<%
+my $cust_credit = qsearchs('cust_credit', { 'crednum' => $crednum } );
+die "credit $crednum not found!" unless $cust_credit;
 
 my $credited = $cust_credit->credited;
+%>
+
+Credit #<B><%= $crednum %></B>
+<INPUT TYPE="hidden" NAME="crednum" VALUE="<%= $crednum %>">
+
+<BR>Date: <B><%= time2str("%D", $cust_credit->_date) %></B>
 
-print "Credit # <B>$crednum</B>".
-      qq!<INPUT TYPE="hidden" NAME="crednum" VALUE="$crednum">!.
-      '<BR>Date: <B>'. time2str("%D", $cust_credit->_date). '</B>'.
-      '<BR>Amount: $<B>'. $cust_credit->amount. '</B>'.
-      "<BR>Unapplied amount: \$<B>$credited</B>".
-      '<BR>Reason: <B>'. $cust_credit->reason. '</B>'
-      ;
+<BR>Amount: $<B><%= $cust_credit->amount %></B>
 
+<BR>Unapplied amount: $<B><%= $credited %></B>
+
+<BR>Reason: <B><%= $cust_credit->reason %></B>
+
+<%
 my @cust_bill = grep $_->owed != 0,
                 qsearch('cust_bill', { 'custnum' => $cust_credit->custnum } );
 
-print <<END;
+%>
+
 <SCRIPT>
 function changed(what) {
   cust_bill = what.options[what.selectedIndex].value;
-END
 
-foreach my $cust_bill ( @cust_bill ) {
+<% foreach my $cust_bill ( @cust_bill ) {
   my $invnum = $cust_bill->invnum;
   my $changeto = $cust_bill->owed < $cust_credit->credited
                    ? $cust_bill->owed 
                    : $cust_credit->credited;
-  print <<END;
+%>
   if ( cust_bill == $invnum ) {
-    what.form.amount.value = "$changeto";
+    what.form.amount.value = "<%= $changeto %>";
   }
-END
-}
+<% } %>
 
-print <<END;
   if ( cust_bill == "Refund" ) {
-    what.form.amount.value = "$credited";
+    what.form.amount.value = "<%= $credited %>";
   }
 }
 </SCRIPT>
-END
-
-print qq!<BR>Invoice #<SELECT NAME="invnum" SIZE=1 onChange="changed(this)">!,
-      '<OPTION VALUE="">';
-foreach my $cust_bill ( @cust_bill ) {
-  print '<OPTION'. ( $cust_bill->invnum eq $invnum ? ' SELECTED' : '' ).
-        ' VALUE="'. $cust_bill->invnum. '">'. $cust_bill->invnum.
-        ' -  '. time2str("%D",$cust_bill->_date).
-        ' - $'. $cust_bill->owed;
-}
-print qq!<OPTION VALUE="Refund">Refund!;
-print "</SELECT>";
 
-print qq!<BR>Amount \$<INPUT TYPE="text" NAME="amount" VALUE="$amount" SIZE=8 MAXLENGTH=8>!;
+<BR>Invoice #<SELECT NAME="invnum" SIZE=1 onChange="changed(this)">
+<OPTION VALUE="">
+
+<% foreach my $cust_bill ( @cust_bill ) { %>
+
+<OPTION<%= $cust_bill->invnum eq $invnum ? ' SELECTED' : '' %> VALUE="<%= $cust_bill->invnum %>"><%= $cust_bill->invnum %> - <%= time2str("%D",$cust_bill->_date) %> - $<%= $cust_bill->owed %>
+
+<% } %>
+
+<OPTION VALUE="Refund">Refund
+</SELECT>
+
+<BR>Amount $<INPUT TYPE="text" NAME="amount" VALUE="<%= $amount %>" SIZE=8 MAXLENGTH=8>
 
-print <<END;
 <BR>
-<INPUT TYPE="submit" VALUE="Apply">
-END
+<CENTER><INPUT TYPE="submit" VALUE="Apply"></CENTER>
 
-print <<END;
+</FORM>
 
-    </FORM>
-  </BODY>
+</BODY>
 </HTML>
-END
-
-%>