summaryrefslogtreecommitdiff
path: root/httemplate/edit/process/cust_credit-pkgnum.html
blob: 559b9329805269b2b58ee2f4daf306118681b615 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
%if ($error) {
%  $cgi->param('error', $error);
<% $cgi->redirect(popurl(2). 'cust_credit-pkgnum.html?'. $cgi->query_string ) %>
%} else {
<& /elements/header-popup.html, emt('Credit package changed') &>
    <SCRIPT TYPE="text/javascript">
      topreload();
    </SCRIPT>

    </BODY></HTML>
%}
<%init>

my $conf = FS::Conf->new;

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Apply credit'); #own ACL?

$cgi->param('crednum') =~ /^(\d+)$/
  or die "Illegal crednum: ". $cgi->param('crednum');
my $crednum = $1;

my $cust_credit = qsearchs({
  'select'    => 'cust_credit.*',
  'table'     => 'cust_credit',
  'addl_from' => 'LEFT JOIN cust_main USING ( custnum )',
  'hashref'   => { crednum => scalar($cgi->param('crednum')), },
  'extra_sql' => ' AND '. $FS::CurrentUser::CurrentUser->agentnums_sql,
})
  or die 'unknown credit';

$cust_credit->pkgnum( $cgi->param('pkgnum') );
my $error = $cust_credit->replace;

</%init>