Will things ever be the same again?
[freeside.git] / httemplate / edit / process / REAL_cust_pkg.cgi
1 %
2 %
3 %my $pkgnum = $cgi->param('pkgnum') or die;
4 %my $old = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
5 %my %hash = $old->hash;
6 %$hash{'setup'} = $cgi->param('setup') ? str2time($cgi->param('setup')) : '';
7 %$hash{'bill'} = $cgi->param('bill') ? str2time($cgi->param('bill')) : '';
8 %$hash{'last_bill'} =
9 %  $cgi->param('last_bill') ? str2time($cgi->param('last_bill')) : '';
10 %$hash{'expire'} = $cgi->param('expire') ? str2time($cgi->param('expire')) : '';
11 %
12 %my $new;
13 %my $error;
14 %if ( $hash{'bill'} != $old->bill        # if the next bill date was changed
15 %     && $hash{'bill'} < time            # to a date in the past
16 %     && ! $cgi->param('bill_areyousure') # and it wasn't confirmed
17 %   )
18 %{
19 %  $error = '_bill_areyousure';
20 %} else {
21 %  $new = new FS::cust_pkg \%hash;
22 %  $error = $new->replace($old);
23 %}
24 %
25 %if ( $error ) {
26 %  $cgi->param('error', $error);
27 %  print $cgi->redirect(popurl(2). "REAL_cust_pkg.cgi?". $cgi->query_string );
28 %} else { 
29 %  my $custnum = $new->custnum;
30 %  print $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum".
31 %                       "#cust_pkg$pkgnum" );
32 %}
33 %
34 %
35