summaryrefslogtreecommitdiff
path: root/httemplate/edit/process/cust_pay.cgi
blob: 647f6fc6c9a852ab6e45522bb38236ebb87195d6 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
%if ($error) {
%  $cgi->param('error', $error);
<% $cgi->redirect(popurl(2). 'cust_pay.cgi?'. $cgi->query_string ) %>
%} elsif ( $field eq 'invnum' ) {
<% $cgi->redirect(popurl(3). "view/cust_bill.cgi?$linknum") %>
%} elsif ( $field eq 'custnum' ) {
%  if ( $cgi->param('apply') eq 'yes' ) {
%    my $cust_main = qsearchs('cust_main', { 'custnum' => $linknum })
%      or die "unknown custnum $linknum";
%    $cust_main->apply_payments;
%  }
%  if ( $link eq 'popup' ) {
%    
<% header('Payment entered') %>
    <SCRIPT TYPE="text/javascript">
      window.top.location.reload();
    </SCRIPT>

    </BODY></HTML>
%
%  } elsif ( $link eq 'custnum' ) {
<% $cgi->redirect(popurl(3). "view/cust_main.cgi?$linknum") %>
%  } else {
%    die "unknown link $link";
%  }
%
%}
<%init>

die "access denied"
  unless $FS::CurrentUser::CurrentUser->access_right('Post payment');

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

$cgi->param('link') =~ /^(custnum|invnum|popup)$/
  or die "Illegal link: ". $cgi->param('link');
my $field = my $link = $1;
$field = 'custnum' if $field eq 'popup';

my $_date = str2time($cgi->param('_date'));

my $new = new FS::cust_pay ( {
  $field => $linknum,
  _date  => $_date,
  map {
    $_, scalar($cgi->param($_));
  } qw(paid payby payinfo paybatch)
  #} fields('cust_pay')
} );

my $error = $new->insert( 'manual' => 1 );

</%init>