d9a92a1de852c2fdecded355d6c2c5325580ec75
[freeside.git] / httemplate / edit / process / cust_pay-pkgnum.html
1 %if ($error) {
2 %  $cgi->param('error', $error);
3 <% $cgi->redirect(popurl(2). 'cust_pay-pkgnum.html?'. $cgi->query_string ) %>
4 %} else {
5 <% header(emt('Payment package changed')) %>
6     <SCRIPT TYPE="text/javascript">
7       window.top.location.reload();
8     </SCRIPT>
9
10     </BODY></HTML>
11 %}
12 <%init>
13
14 my $conf = FS::Conf->new;
15
16 die "access denied"
17   unless $FS::CurrentUser::CurrentUser->access_right('Apply credit'); #own ACL?
18
19 $cgi->param('paynum') =~ /^(\d+)$/
20   or die "Illegal paynum: ". $cgi->param('paynum');
21 my $paynum = $1;
22
23 my $cust_pay = qsearchs({
24   'select'    => 'cust_pay.*',
25   'table'     => 'cust_pay',
26   'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
27   'hashref'   => { paynum => scalar($cgi->param('paynum')), },
28   'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
29 })
30   or die 'unknown payment';
31
32 $cust_pay->pkgnum( $cgi->param('pkgnum') );
33 my $error = $cust_pay->replace;
34
35 </%init>