This commit was generated by cvs2svn to compensate for changes in r6255,
[freeside.git] / httemplate / edit / process / REAL_cust_pkg.cgi
1 %if ( $error ) {
2 %  $cgi->param('error', $error);
3 <% $cgi->redirect(popurl(2). "REAL_cust_pkg.cgi?". $cgi->query_string ) %>
4 %} else { 
5 %  my $custnum = $new->custnum;
6 <% $cgi->redirect(popurl(3). "view/cust_main.cgi?$custnum#cust_pkg$pkgnum" ) %>
7 %}
8 <%init>
9
10 die "access denied"
11   unless $FS::CurrentUser::CurrentUser->access_right('Edit customer package dates');
12
13 my $pkgnum = $cgi->param('pkgnum') or die;
14 my $old = qsearchs('cust_pkg',{'pkgnum'=>$pkgnum});
15 my %hash = $old->hash;
16 $hash{'setup'} = $cgi->param('setup') ? str2time($cgi->param('setup')) : '';
17 $hash{'bill'} = $cgi->param('bill') ? str2time($cgi->param('bill')) : '';
18 $hash{'last_bill'} =
19   $cgi->param('last_bill') ? str2time($cgi->param('last_bill')) : '';
20 $hash{'adjourn'} = $cgi->param('adjourn') ? str2time($cgi->param('adjourn')) : '';
21 $hash{'expire'} = $cgi->param('expire') ? str2time($cgi->param('expire')) : '';
22
23 my $new;
24 my $error;
25 if ( $hash{'bill'} != $old->bill        # if the next bill date was changed
26      && $hash{'bill'} < time            # to a date in the past
27      && ! $cgi->param('bill_areyousure') # and it wasn't confirmed
28    )
29 {
30   $error = '_bill_areyousure';
31 } else {
32   $new = new FS::cust_pkg \%hash;
33   $error = $new->replace($old);
34 }
35
36 </%init>