-<%
-
-my($paynum, $amount, $invnum);
-if ( $cgi->param('error') ) {
- $paynum = $cgi->param('paynum');
- $amount = $cgi->param('amount');
- $invnum = $cgi->param('invnum');
-} else {
- my($query) = $cgi->keywords;
- $query =~ /^(\d+)$/;
- $paynum = $1;
- $amount = '';
- $invnum = '';
-}
-
-my $otaker = getotaker;
-
-my $p1 = popurl(1);
-
-%><%= header("Apply Payment", '') %>
-
-<% if ( $cgi->param('error') ) { %>
- <FONT SIZE="+1" COLOR="#ff0000">Error: <%= $cgi->param('error') %></FONT>
- <BR><BR>
-<% } %>
-
-<FORM ACTION="<%= $p1 %>process/cust_bill_pay.cgi" METHOD=POST>
-
-<%
-my $cust_pay = qsearchs('cust_pay', { 'paynum' => $paynum } );
-die "payment $paynum not found!" unless $cust_pay;
-
-my $unapplied = $cust_pay->unapplied;
-%>
-
-Payment #<B><%= $paynum %></B>
-<INPUT TYPE="hidden" NAME="paynum" VALUE="<%= $paynum %>">
-
-<BR>Date: <B><%= time2str("%D", $cust_pay->_date) %></B>
-
-<BR>Amount: $<B><%= $cust_pay->paid %></B>
-
-<BR>Unapplied amount: $<B><%= $unapplied %></B>
-
-<%
-my @cust_bill = grep $_->owed != 0,
- qsearch('cust_bill', { 'custnum' => $cust_pay->custnum } );
-
+<% include('elements/ApplicationCommon.html',
+ 'form_action' => 'process/cust_bill_pay.cgi',
+ 'src_table' => 'cust_pay',
+ 'src_thing' => 'payment',
+ 'dst_table' => 'cust_bill',
+ 'dst_thing' => 'invoice',
+ )